mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-08 16:35:40 +00:00
bufferlist: add function to add a list of buffers
Add a function to add a list of buffers to the bufferlist.
This commit is contained in:
parent
1afaa1680f
commit
0447e72c97
4 changed files with 79 additions and 0 deletions
|
@ -526,6 +526,52 @@ gst_buffer_list_iterator_add (GstBufferListIterator * it, GstBuffer * buffer)
|
|||
buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_buffer_list_iterator_add_list:
|
||||
* @it: a #GstBufferListIterator
|
||||
* @list: a #GList
|
||||
*
|
||||
* Inserts @list of buffers into the #GstBufferList iterated with @it. The list is
|
||||
* inserted into the current group, immediately before the buffer that would be
|
||||
* returned by gst_buffer_list_iterator_next(). The list is inserted before
|
||||
* the implicit cursor, a subsequent call to gst_buffer_list_iterator_next()
|
||||
* will return the buffer after the last buffer of the inserted list, if any.
|
||||
*
|
||||
* This function takes ownership of @list and all its buffers.
|
||||
*
|
||||
* Since: 0.10.31
|
||||
*/
|
||||
void
|
||||
gst_buffer_list_iterator_add_list (GstBufferListIterator * it, GList * list)
|
||||
{
|
||||
GList *last;
|
||||
|
||||
g_return_if_fail (it != NULL);
|
||||
g_return_if_fail (it->next != it->list->buffers);
|
||||
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
if (it->next) {
|
||||
last = list;
|
||||
while (last->next)
|
||||
last = last->next;
|
||||
|
||||
last->next = it->next;
|
||||
list->prev = it->next->prev;
|
||||
it->next->prev = last;
|
||||
if (list->prev)
|
||||
list->prev->next = list;
|
||||
} else {
|
||||
last = it->list->buffers;
|
||||
while (last->next)
|
||||
last = last->next;
|
||||
|
||||
last->next = list;
|
||||
list->prev = last;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_buffer_list_iterator_add_group:
|
||||
* @it: a #GstBufferListIterator
|
||||
|
|
|
@ -220,6 +220,7 @@ GstBuffer * gst_buffer_list_iterator_next (GstBufferListIte
|
|||
gboolean gst_buffer_list_iterator_next_group (GstBufferListIterator *it);
|
||||
|
||||
void gst_buffer_list_iterator_add (GstBufferListIterator *it, GstBuffer *buffer);
|
||||
void gst_buffer_list_iterator_add_list (GstBufferListIterator *it, GList *list);
|
||||
void gst_buffer_list_iterator_add_group (GstBufferListIterator *it);
|
||||
void gst_buffer_list_iterator_remove (GstBufferListIterator *it);
|
||||
GstBuffer * gst_buffer_list_iterator_steal (GstBufferListIterator *it);
|
||||
|
|
|
@ -766,6 +766,36 @@ GST_START_TEST (test_foreach)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_list)
|
||||
{
|
||||
GstBufferListIterator *it;
|
||||
GList *l = NULL;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
gchar name[10];
|
||||
g_snprintf (name, 10, "%d", i);
|
||||
l = g_list_append (l, buffer_from_string (name));
|
||||
}
|
||||
|
||||
/* add buffers to the list */
|
||||
it = gst_buffer_list_iterate (list);
|
||||
gst_buffer_list_iterator_add_group (it);
|
||||
gst_buffer_list_iterator_add_list (it, l);
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
GstBuffer *buf;
|
||||
gchar name[10];
|
||||
|
||||
buf = gst_buffer_list_get (list, 0, i);
|
||||
g_snprintf (name, 10, "%d", i);
|
||||
fail_unless (memcmp (name, (gchar *) GST_BUFFER_DATA (buf),
|
||||
GST_BUFFER_SIZE (buf)) == 0);
|
||||
}
|
||||
gst_buffer_list_iterator_free (it);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
gst_buffer_list_suite (void)
|
||||
|
@ -783,6 +813,7 @@ gst_buffer_list_suite (void)
|
|||
tcase_add_test (tc_chain, test_do);
|
||||
tcase_add_test (tc_chain, test_merge);
|
||||
tcase_add_test (tc_chain, test_foreach);
|
||||
tcase_add_test (tc_chain, test_list);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ EXPORTS
|
|||
gst_buffer_list_iterate
|
||||
gst_buffer_list_iterator_add
|
||||
gst_buffer_list_iterator_add_group
|
||||
gst_buffer_list_iterator_add_list
|
||||
gst_buffer_list_iterator_do
|
||||
gst_buffer_list_iterator_free
|
||||
gst_buffer_list_iterator_merge_group
|
||||
|
|
Loading…
Reference in a new issue