Commit 730b8727 authored by Wim Taymans's avatar Wim Taymans
Browse files

bufferlist: fixes for new API

parent 7ec584fe
......@@ -833,10 +833,10 @@ gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
static GstFlowReturn
gst_app_sink_render_list (GstBaseSink * sink, GstBufferList * list)
{
GstBufferListIterator *it;
GstFlowReturn flow;
GstAppSink *appsink;
GstBuffer *group;
GstBuffer *buffer;
guint i, len;
appsink = GST_APP_SINK_CAST (sink);
......@@ -847,29 +847,16 @@ gst_app_sink_render_list (GstBaseSink * sink, GstBufferList * list)
* then and push them one-by-one */
GST_INFO_OBJECT (sink, "chaining each group in list as a merged buffer");
it = gst_buffer_list_iterate (list);
len = gst_buffer_list_len (list);
if (gst_buffer_list_iterator_next_group (it)) {
do {
group = gst_buffer_list_iterator_merge_group (it);
if (group == NULL) {
group = gst_buffer_new ();
GST_DEBUG_OBJECT (sink, "chaining empty group");
} else {
GST_DEBUG_OBJECT (sink, "chaining group");
}
flow = gst_app_sink_render (sink, group);
gst_buffer_unref (group);
} while (flow == GST_FLOW_OK && gst_buffer_list_iterator_next_group (it));
} else {
GST_DEBUG_OBJECT (sink, "chaining empty group");
group = gst_buffer_new ();
flow = gst_app_sink_render (sink, group);
gst_buffer_unref (group);
flow = GST_FLOW_OK;
for (i = 0; i < len; i++) {
buffer = gst_buffer_list_get (list, i);
flow = gst_app_sink_render (sink, buffer);
if (flow != GST_FLOW_OK)
break;
}
gst_buffer_list_iterator_free (it);
return flow;
}
......
......@@ -520,17 +520,17 @@ gst_base_rtp_audio_payload_push_buffer (GstBaseRTPAudioPayload *
if (priv->buffer_list) {
GstBufferList *list;
GstBufferListIterator *it;
guint i, len;
list = gst_buffer_list_new ();
it = gst_buffer_list_iterate (list);
len = gst_buffer_list_len (list);
/* add both buffers to the buffer list */
gst_buffer_list_iterator_add_group (it);
gst_buffer_list_iterator_add (it, outbuf);
gst_buffer_list_iterator_add (it, buffer);
gst_buffer_list_iterator_free (it);
for (i = 0; i < len; i++) {
/* FIXME */
g_warning ("bufferlist not implemented");
gst_buffer_list_add (list, outbuf);
gst_buffer_list_add (list, buffer);
}
GST_DEBUG_OBJECT (baseaudiopayload, "Pushing list %p", list);
ret = gst_basertppayload_push_list (basepayload, list);
......
......@@ -526,8 +526,8 @@ typedef struct
gboolean rtptime;
} HeaderData;
static GstBufferListItem
set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
static gboolean
set_headers (GstBuffer ** buffer, guint idx, HeaderData * data)
{
GstBaseRTPDepayload *depayload = data->depayload;
......@@ -544,7 +544,7 @@ set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
depayload->priv->discont = FALSE;
}
return GST_BUFFER_LIST_SKIP_GROUP;
return TRUE;
}
static GstFlowReturn
......@@ -567,7 +567,7 @@ gst_base_rtp_depayload_prepare_push (GstBaseRTPDepayload * filter,
gst_buffer_list_foreach (*blist, (GstBufferListFunc) set_headers, &data);
} else {
GstBuffer **buf = obj;
set_headers (buf, 0, 0, &data);
set_headers (buf, 0, &data);
}
/* if this is the first buffer send a NEWSEGMENT */
......
......@@ -710,8 +710,8 @@ typedef struct
guint32 rtptime;
} HeaderData;
static GstBufferListItem
find_timestamp (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
static gboolean
find_timestamp (GstBuffer ** buffer, guint idx, HeaderData * data)
{
data->timestamp = GST_BUFFER_TIMESTAMP (*buffer);
data->offset = GST_BUFFER_OFFSET (*buffer);
......@@ -719,12 +719,12 @@ find_timestamp (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
/* stop when we find a timestamp. We take whatever offset is associated with
* the timestamp (if any) to do perfect timestamps when we need to. */
if (data->timestamp != -1)
return GST_BUFFER_LIST_END;
return FALSE;
else
return GST_BUFFER_LIST_CONTINUE;
return TRUE;
}
static GstBufferListItem
static gboolean
set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
{
GstRTPBuffer rtp;
......@@ -740,7 +740,7 @@ set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
/* increment the seqnum for each buffer */
data->seqnum++;
return GST_BUFFER_LIST_SKIP_GROUP;
return TRUE;
}
/* Updates the SSRC, payload type, seqnum and timestamp of the RTP buffer
......
......@@ -300,8 +300,10 @@ gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
payloadbuf = gst_buffer_new ();
plen = gst_dp_header_payload_length (header);
gst_buffer_take_memory (payloadbuf,
gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
if (plen && payload != NULL) {
gst_buffer_take_memory (payloadbuf,
gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
}
return gst_buffer_join (headerbuf, payloadbuf);
......
......@@ -203,7 +203,7 @@ static gint values[] = { 1, 2, 4 };
static GstBufferList *
create_buffer_list (void)
{
GstBufferListIterator *it;
guint len;
GstBuffer *buffer;
mylist = gst_buffer_list_new ();
......@@ -212,29 +212,23 @@ create_buffer_list (void)
mycaps = gst_caps_from_string ("application/x-gst-check");
fail_if (mycaps == NULL);
it = gst_buffer_list_iterate (mylist);
fail_if (it == NULL);
gst_buffer_list_iterator_add_group (it);
len = gst_buffer_list_len (mylist);
fail_if (len != 0);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[0], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_iterator_add (it, buffer);
gst_buffer_list_iterator_add_group (it);
gst_buffer_list_add (mylist, buffer);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[1], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_iterator_add (it, buffer);
gst_buffer_list_add (mylist, buffer);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
gst_buffer_fill (buffer, 0, &values[2], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_iterator_add (it, buffer);
gst_buffer_list_iterator_free (it);
gst_buffer_list_add (mylist, buffer);
return mylist;
}
......@@ -242,19 +236,16 @@ create_buffer_list (void)
static void
check_buffer_list (GstBufferList * list)
{
GstBufferListIterator *it;
guint len;
GstBuffer *buf;
GstCaps *caps;
fail_unless (list == mylist);
fail_unless (gst_buffer_list_n_groups (list) == 2);
fail_unless (gst_buffer_list_len (list) == 3);
it = gst_buffer_list_iterate (list);
fail_if (it == NULL);
len = gst_buffer_list_len (list);
fail_unless (gst_buffer_list_iterator_next_group (it));
fail_unless (gst_buffer_list_iterator_n_buffers (it) == 1);
buf = gst_buffer_list_iterator_next (it);
buf = gst_buffer_list_get (list, 0);
fail_if (buf == NULL);
gst_check_buffer_data (buf, &values[0], sizeof (gint));
caps = gst_buffer_get_caps (buf);
......@@ -262,23 +253,19 @@ check_buffer_list (GstBufferList * list)
fail_unless (gst_caps_is_equal (caps, mycaps));
gst_caps_unref (caps);
fail_unless (gst_buffer_list_iterator_next_group (it));
fail_unless (gst_buffer_list_iterator_n_buffers (it) == 2);
buf = gst_buffer_list_iterator_next (it);
buf = gst_buffer_list_get (list, 1);
fail_if (buf == NULL);
gst_check_buffer_data (buf, &values[1], sizeof (gint));
caps = gst_buffer_get_caps (buf);
fail_unless (caps == mycaps);
gst_caps_unref (caps);
buf = gst_buffer_list_iterator_next (it);
buf = gst_buffer_list_get (list, 2);
fail_if (buf == NULL);
gst_check_buffer_data (buf, &values[2], sizeof (gint));
caps = gst_buffer_get_caps (buf);
fail_unless (caps == mycaps);
gst_caps_unref (caps);
gst_buffer_list_iterator_free (it);
}
static GstFlowReturn
......@@ -335,8 +322,12 @@ callback_function_buffer (GstAppSink * appsink, gpointer p_counter)
gst_check_buffer_data (buf, &values[0], sizeof (gint));
break;
case 1:
fail_unless_equals_int (gst_buffer_get_size (buf), 2 * sizeof (gint));
gst_check_buffer_data (buf, &values[1], 2 * sizeof (gint));
fail_unless_equals_int (gst_buffer_get_size (buf), sizeof (gint));
gst_check_buffer_data (buf, &values[1], sizeof (gint));
break;
case 2:
fail_unless_equals_int (gst_buffer_get_size (buf), sizeof (gint));
gst_check_buffer_data (buf, &values[2], sizeof (gint));
break;
default:
g_warn_if_reached ();
......@@ -368,7 +359,7 @@ GST_START_TEST (test_buffer_list_fallback)
list = create_buffer_list ();
fail_unless (gst_pad_push_list (mysrcpad, list) == GST_FLOW_OK);
fail_unless_equals_int (counter, 2);
fail_unless_equals_int (counter, 3);
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
cleanup_appsink (sink);
......@@ -395,7 +386,7 @@ GST_START_TEST (test_buffer_list_fallback_signal)
list = create_buffer_list ();
fail_unless (gst_pad_push_list (mysrcpad, list) == GST_FLOW_OK);
fail_unless_equals_int (counter, 2);
fail_unless_equals_int (counter, 3);
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
cleanup_appsink (sink);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment