[0.11] gst-plugins-good: matroskademux: do not consider duration of non-finalized file

Sebastian Dröge slomo at kemper.freedesktop.org
Tue Jan 10 05:33:26 PST 2012


Module: gst-plugins-good
Branch: 0.11
Commit: a7d6690f92e6c739d3b3e28d99d1f7840f8c59d9
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=a7d6690f92e6c739d3b3e28d99d1f7840f8c59d9

Author: Branko Subasic <branko at axis.com>
Date:   Wed Dec 21 17:43:10 2011 +0100

matroskademux: do not consider duration of non-finalized file

... to avoid it clamping requested seek position.

Non-finalized file case, determined by whether
_parse_blockgroup_or_simpleblock ever updates the segment duration.

Fixes #652195.

---

 gst/matroska/matroska-demux.c |   18 ++++++++++++++++++
 gst/matroska/matroska-demux.h |    3 +++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 2ce2d76..e80febc 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -480,6 +480,8 @@ gst_matroska_demux_reset (GstElement * element)
     gst_buffer_unref (demux->common.cached_buffer);
     demux->common.cached_buffer = NULL;
   }
+
+  demux->invalid_duration = FALSE;
 }
 
 static GstBuffer *
@@ -1928,6 +1930,16 @@ gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
    * segment when we close the current segment. */
   memcpy (&seeksegment, &demux->common.segment, sizeof (GstSegment));
 
+  /* pull mode without index means that the actual duration is not known,
+   * we might be playing a file that's still being recorded
+   * so, invalidate our current duration, which is only a moving target,
+   * and should not be used to clamp anything */
+  if (!demux->streaming && !demux->common.index &&
+      demux->invalid_duration) {
+    gst_segment_set_duration (&seeksegment, GST_FORMAT_TIME,
+        GST_CLOCK_TIME_NONE);
+  }
+
   if (event) {
     GST_DEBUG_OBJECT (demux, "configuring seek");
     gst_segment_set_seek (&seeksegment, rate, format, flags,
@@ -1942,6 +1954,11 @@ gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
     }
   }
 
+  /* restore segment duration (if any effect),
+   * would be determined again when parsing, but anyway ... */
+  gst_segment_set_duration (&seeksegment, GST_FORMAT_TIME,
+      demux->common.segment.duration);
+
   flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
   keyunit = ! !(flags & GST_SEEK_FLAG_KEY_UNIT);
 
@@ -3501,6 +3518,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
           gst_element_post_message (GST_ELEMENT_CAST (demux),
               gst_message_new_duration (GST_OBJECT_CAST (demux),
                   GST_FORMAT_TIME, GST_CLOCK_TIME_NONE));
+          demux->invalid_duration = TRUE;
         } else {
           GST_OBJECT_UNLOCK (demux);
         }
diff --git a/gst/matroska/matroska-demux.h b/gst/matroska/matroska-demux.h
index 2b08b2e..22093ea 100644
--- a/gst/matroska/matroska-demux.h
+++ b/gst/matroska/matroska-demux.h
@@ -95,6 +95,9 @@ typedef struct _GstMatroskaDemux {
 
   /* gap handling */
   guint64                  max_gap_time;
+
+  /* for non-finalized files, with invalid segment duration */
+  gboolean                 invalid_duration;
 } GstMatroskaDemux;
 
 typedef struct _GstMatroskaDemuxClass {



More information about the gstreamer-commits mailing list