From 9a30726226bdff5fbedd509f6462fae1f9526839 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Sat, 22 Mar 2014 17:05:17 +0100 Subject: [PATCH] matroskademux: early sending pending codec-data for all streams ... at least before syncing across all streams might cause some gap activity on any of those streams, notably sparse streams. See also #712134 --- gst/matroska/matroska-demux.c | 53 ++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index bdd10f6..68f428c 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -2627,6 +2627,40 @@ gst_matroska_demux_push_dvd_clut_change_event (GstMatroskaDemux * demux, g_free (buf); } +static void +gst_matroska_demux_push_codec_data_all (GstMatroskaDemux * demux) +{ + gint stream_nr; + + GST_OBJECT_LOCK (demux); + + g_assert (demux->common.num_streams == demux->common.src->len); + for (stream_nr = 0; stream_nr < demux->common.src->len; stream_nr++) { + GstMatroskaTrackContext *stream; + + stream = g_ptr_array_index (demux->common.src, stream_nr); + + if (stream->send_stream_headers) { + if (stream->stream_headers != NULL) { + gst_matroska_demux_push_stream_headers (demux, stream); + } else { + /* FIXME: perhaps we can just disable and skip this stream then */ + GST_ELEMENT_ERROR (demux, STREAM, DECODE, (NULL), + ("Failed to extract stream headers from codec private data")); + } + stream->send_stream_headers = FALSE; + } + + if (stream->send_dvd_event) { + gst_matroska_demux_push_dvd_clut_change_event (demux, stream); + /* FIXME: should we send this event again after (flushing) seek ? */ + stream->send_dvd_event = FALSE; + } + } + + GST_OBJECT_UNLOCK (demux); +} + static GstFlowReturn gst_matroska_demux_add_mpeg_seq_header (GstElement * element, GstMatroskaTrackContext * stream, GstBuffer ** buf) @@ -3344,22 +3378,9 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux, demux->segment_seqnum = 0; } - if (stream->send_stream_headers) { - if (stream->stream_headers != NULL) { - ret = gst_matroska_demux_push_stream_headers (demux, stream); - } else { - /* FIXME: perhaps we can just disable and skip this stream then */ - GST_ELEMENT_ERROR (demux, STREAM, DECODE, (NULL), - ("Failed to extract stream headers from codec private data")); - } - stream->send_stream_headers = FALSE; - } - - if (stream->send_dvd_event) { - gst_matroska_demux_push_dvd_clut_change_event (demux, stream); - /* FIXME: should we send this event again after (flushing) seek ? */ - stream->send_dvd_event = FALSE; - } + /* send pending codec data headers for all streams, + * before we perform sync across all streams */ + gst_matroska_demux_push_codec_data_all (demux); if (block_duration != -1) { if (stream->timecodescale == 1.0) -- 2.7.4