adaptivedemux: allow seeking before start in live streams
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 7 Mar 2016 17:04:33 +0000 (17:04 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Tue, 2 Aug 2016 11:52:34 +0000 (12:52 +0100)
Some derived classes (at least dashdemux) expose a seeking range
based on wall clock. This means that a subsequent seek to the start
of this range will be before the allowed range.

To solve this, seeks without the ACCURATE flag are allowed to seek
before the start for live streams, in which case the segment is
shifted to start at the start of the new seek range. If there is
an end position, is is shifted too, to keep the duration constant.

https://bugzilla.gnome.org/show_bug.cgi?id=753751

gst-libs/gst/adaptivedemux/gstadaptivedemux.c

index 3c30c7d973c10ca2035757dc1d77e972bd8e6c35..b18c2580f22d06c162e0b025711b8e1b7b3be589 100644 (file)
@@ -1341,6 +1341,23 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux, GstPad * pad,
       gst_event_unref (event);
       return FALSE;
     }
+
+    if (!(flags & GST_SEEK_FLAG_ACCURATE)) {
+      /* If the accurate flag is not set, we allow seeking before the start
+       * to map to the start for live cases, since those can return a "moving
+       * target" based on wall time.
+       */
+      if (start < range_start) {
+        guint64 dt = range_start - start;
+        GST_DEBUG_OBJECT (demux,
+            "Non accurate seek before live stream start, offsetting by %"
+            GST_TIME_FORMAT, GST_TIME_ARGS (dt));
+        start = range_start;
+        if (stop != GST_CLOCK_TIME_NONE)
+          stop += dt;
+      }
+    }
+
     if (start < range_start || start >= range_stop) {
       GST_MANIFEST_UNLOCK (demux);
       GST_API_UNLOCK (demux);