From fd429d3233b47108d877086aa1cfbfef71e13505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 26 Dec 2014 11:48:56 +0000 Subject: gdppay: use public API for accessing stream header arrays in caps Don't rely on core implementation details, which are private and may change. It's also not needed here, the performance impact is close to none. Also copy buffer before changing its metadata. --- gst/gdp/gstgdppay.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'gst/gdp') diff --git a/gst/gdp/gstgdppay.c b/gst/gdp/gstgdppay.c index 751f5f691..33ac591eb 100644 --- a/gst/gdp/gstgdppay.c +++ b/gst/gdp/gstgdppay.c @@ -289,22 +289,24 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this) structure = gst_caps_get_structure (this->caps, 0); if (gst_structure_has_field (structure, "streamheader")) { const GValue *sh; - GArray *buffers; GstBuffer *buffer; - int i; + int i, num; sh = gst_structure_get_value (structure, "streamheader"); - buffers = g_value_peek_pointer (sh); + num = gst_value_array_get_size (sh); GST_DEBUG_OBJECT (this, - "Need to serialize %d incoming streamheader buffers on ours", - buffers->len); - for (i = 0; i < buffers->len; ++i) { - GValue *bufval; + "Need to serialize %d incoming streamheader buffers on ours", num); + for (i = 0; i < num; ++i) { + const GValue *bufval; GstBuffer *outbuffer; - bufval = &g_array_index (buffers, GValue, i); - buffer = g_value_peek_pointer (bufval); + bufval = gst_value_array_get_value (sh, i); + buffer = gst_value_get_buffer (bufval); + + /* Make copy before modifying buffer metadata */ + buffer = gst_buffer_copy (buffer); + /* this buffer is deserialized by gdpdepay as a regular buffer, it needs HEADER, because it's a streamheader - otherwise it is mixed with regular data buffers */ @@ -314,6 +316,9 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this) GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE; outbuffer = gst_gdp_pay_buffer_from_buffer (this, buffer); + + gst_buffer_unref (buffer); + if (!outbuffer) { g_value_unset (&array); goto no_buffer; -- cgit v1.2.1