mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
gdppay: update to 1.x reality
* stream-start-id is mandatory at the beginning, so add that to the gdp headers * caps must be sent before new segment, invert the order from legacy 0.10 code And fix the tests as a ref is now kept for those buffers that compose the header
This commit is contained in:
parent
c8eb403e38
commit
a029a35036
3 changed files with 61 additions and 23 deletions
|
@ -200,6 +200,10 @@ gst_gdp_pay_reset (GstGDPPay * this)
|
|||
gst_buffer_unref (this->new_segment_buf);
|
||||
this->new_segment_buf = NULL;
|
||||
}
|
||||
if (this->streamstartid_buf) {
|
||||
gst_buffer_unref (this->streamstartid_buf);
|
||||
this->streamstartid_buf = NULL;
|
||||
}
|
||||
this->sent_streamheader = FALSE;
|
||||
this->offset = 0;
|
||||
}
|
||||
|
@ -312,7 +316,7 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
|
|||
{
|
||||
GstCaps *caps;
|
||||
/* We use copies of these to avoid circular refcounts */
|
||||
GstBuffer *new_segment_buf, *caps_buf, *tag_buf;
|
||||
GstBuffer *new_segment_buf, *caps_buf, *tag_buf, *streamstartid_buf;
|
||||
GstStructure *structure;
|
||||
GstFlowReturn r = GST_FLOW_OK;
|
||||
gboolean version_one_zero = TRUE;
|
||||
|
@ -326,8 +330,9 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
|
|||
version_one_zero = FALSE;
|
||||
|
||||
if (version_one_zero) {
|
||||
if (!this->new_segment_buf || !this->caps_buf) {
|
||||
GST_DEBUG_OBJECT (this, "1.0, missing new_segment or caps, returning");
|
||||
if (!this->new_segment_buf || !this->caps_buf || !this->streamstartid_buf) {
|
||||
GST_DEBUG_OBJECT (this, "1.0, missing new_segment or caps or stream "
|
||||
"start id, returning");
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
} else {
|
||||
|
@ -342,6 +347,27 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
|
|||
* We do this here so the offsets match the order the buffers go out in */
|
||||
g_value_init (&array, GST_TYPE_ARRAY);
|
||||
|
||||
if (version_one_zero) {
|
||||
gst_gdp_stamp_buffer (this, this->streamstartid_buf);
|
||||
GST_DEBUG_OBJECT (this, "appending copy of stream start id buffer %p",
|
||||
this->streamstartid_buf);
|
||||
streamstartid_buf = gst_buffer_copy (this->streamstartid_buf);
|
||||
g_value_init (&value, GST_TYPE_BUFFER);
|
||||
gst_value_set_buffer (&value, streamstartid_buf);
|
||||
gst_value_array_append_value (&array, &value);
|
||||
g_value_unset (&value);
|
||||
gst_buffer_unref (streamstartid_buf);
|
||||
}
|
||||
|
||||
gst_gdp_stamp_buffer (this, this->caps_buf);
|
||||
GST_DEBUG_OBJECT (this, "appending copy of caps buffer %p", this->caps_buf);
|
||||
caps_buf = gst_buffer_copy (this->caps_buf);
|
||||
g_value_init (&value, GST_TYPE_BUFFER);
|
||||
gst_value_set_buffer (&value, caps_buf);
|
||||
gst_value_array_append_value (&array, &value);
|
||||
g_value_unset (&value);
|
||||
gst_buffer_unref (caps_buf);
|
||||
|
||||
if (version_one_zero) {
|
||||
gst_gdp_stamp_buffer (this, this->new_segment_buf);
|
||||
GST_DEBUG_OBJECT (this, "1.0, appending copy of new segment buffer %p",
|
||||
|
@ -368,15 +394,6 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
|
|||
}
|
||||
}
|
||||
|
||||
gst_gdp_stamp_buffer (this, this->caps_buf);
|
||||
GST_DEBUG_OBJECT (this, "appending copy of caps buffer %p", this->caps_buf);
|
||||
caps_buf = gst_buffer_copy (this->caps_buf);
|
||||
g_value_init (&value, GST_TYPE_BUFFER);
|
||||
gst_value_set_buffer (&value, caps_buf);
|
||||
gst_value_array_append_value (&array, &value);
|
||||
g_value_unset (&value);
|
||||
gst_buffer_unref (caps_buf);
|
||||
|
||||
/* we also need to add GDP serializations of the streamheaders of the
|
||||
* incoming caps */
|
||||
structure = gst_caps_get_structure (this->caps, 0);
|
||||
|
@ -462,6 +479,20 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
|
|||
}
|
||||
|
||||
/* push out these streamheader buffers, then flush our internal queue */
|
||||
GST_DEBUG_OBJECT (this, "Pushing GDP stream-start-id buffer %p",
|
||||
this->streamstartid_buf);
|
||||
r = gst_pad_push (this->srcpad, gst_buffer_ref (this->streamstartid_buf));
|
||||
if (r != GST_FLOW_OK) {
|
||||
GST_WARNING_OBJECT (this, "pushing GDP stream-start-id buffer returned %d",
|
||||
r);
|
||||
goto done;
|
||||
}
|
||||
GST_DEBUG_OBJECT (this, "Pushing GDP caps buffer %p", this->caps_buf);
|
||||
r = gst_pad_push (this->srcpad, gst_buffer_ref (this->caps_buf));
|
||||
if (r != GST_FLOW_OK) {
|
||||
GST_WARNING_OBJECT (this, "pushing GDP caps buffer returned %d", r);
|
||||
goto done;
|
||||
}
|
||||
GST_DEBUG_OBJECT (this, "Pushing GDP new_segment buffer %p with offset %"
|
||||
G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT, this->new_segment_buf,
|
||||
GST_BUFFER_OFFSET (this->new_segment_buf),
|
||||
|
@ -481,12 +512,6 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
|
|||
goto done;
|
||||
}
|
||||
}
|
||||
GST_DEBUG_OBJECT (this, "Pushing GDP caps buffer %p", this->caps_buf);
|
||||
r = gst_pad_push (this->srcpad, gst_buffer_ref (this->caps_buf));
|
||||
if (r != GST_FLOW_OK) {
|
||||
GST_WARNING_OBJECT (this, "pushing GDP caps buffer returned %d", r);
|
||||
goto done;
|
||||
}
|
||||
this->sent_streamheader = TRUE;
|
||||
GST_DEBUG_OBJECT (this, "need to push %d queued buffers",
|
||||
g_list_length (this->queue));
|
||||
|
@ -663,6 +688,17 @@ gst_gdp_pay_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
/* if we got a new segment or tag event, we should put it on our streamheader,
|
||||
* and not send it on */
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_STREAM_START:
|
||||
GST_DEBUG_OBJECT (this, "Storing stream start id in buffer %p",
|
||||
outbuffer);
|
||||
|
||||
if (this->streamstartid_buf)
|
||||
gst_buffer_unref (this->streamstartid_buf);
|
||||
this->streamstartid_buf = outbuffer;
|
||||
|
||||
GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_HEADER);
|
||||
gst_gdp_pay_reset_streamheader (this);
|
||||
break;
|
||||
case GST_EVENT_SEGMENT:
|
||||
GST_DEBUG_OBJECT (this, "Storing in caps buffer %p as new_segment_buf",
|
||||
outbuffer);
|
||||
|
|
|
@ -52,6 +52,7 @@ struct _GstGDPPay
|
|||
|
||||
GstCaps *caps; /* incoming caps */
|
||||
|
||||
GstBuffer *streamstartid_buf;
|
||||
GstBuffer *caps_buf;
|
||||
GstBuffer *new_segment_buf;
|
||||
GstBuffer *tag_buf;
|
||||
|
|
|
@ -166,7 +166,7 @@ GST_START_TEST (test_audio)
|
|||
check_caps_buffer (2, caps);
|
||||
|
||||
/* third buffer is the serialized new_segment event */
|
||||
check_segment_buffer (1);
|
||||
check_segment_buffer (2);
|
||||
|
||||
/* the fourth buffer is the GDP buffer for our pushed buffer */
|
||||
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
||||
|
@ -311,9 +311,10 @@ GST_START_TEST (test_streamheader)
|
|||
sh = gst_structure_get_value (structure, "streamheader");
|
||||
fail_unless (G_VALUE_TYPE (sh) == GST_TYPE_ARRAY);
|
||||
shbuffers = g_value_peek_pointer (sh);
|
||||
/* a serialized new_segment, a serialized caps, and serialization of our
|
||||
/* a serialized stream-start-id, a serialized new_segment,
|
||||
* a serialized caps, and serialization of our
|
||||
* incoming streamheader */
|
||||
fail_unless_equals_int (shbuffers->len, 3);
|
||||
fail_unless_equals_int (shbuffers->len, 4);
|
||||
|
||||
gst_caps_unref (sinkcaps);
|
||||
|
||||
|
@ -326,7 +327,7 @@ GST_START_TEST (test_streamheader)
|
|||
|
||||
/* third buffer is the serialized new_segment event;
|
||||
* the element also holds a ref to it */
|
||||
check_segment_buffer (1);
|
||||
check_segment_buffer (2);
|
||||
|
||||
/* the fourth buffer is the GDP buffer for our pushed buffer */
|
||||
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
||||
|
@ -508,7 +509,7 @@ GST_START_TEST (test_crc)
|
|||
/* third buffer is the serialized new_segment event */
|
||||
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
||||
buffers = g_list_remove (buffers, outbuffer);
|
||||
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
|
||||
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
|
||||
|
||||
/* verify the header checksum */
|
||||
/* CRC's start at 58 in the header */
|
||||
|
|
Loading…
Reference in a new issue