matroskademux: early sending pending codec-data for all streams
authorMark Nauwelaerts <mnauw@users.sourceforge.net>
Sat, 22 Mar 2014 16:05:17 +0000 (17:05 +0100)
committerMark Nauwelaerts <mnauw@users.sourceforge.net>
Tue, 25 Mar 2014 20:02:45 +0000 (21:02 +0100)
... 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

index bdd10f6..68f428c 100644 (file)
@@ -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)