From 5b7f60dada60ce1b8dfcddc25012a906357e92e3 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 7 Mar 2016 17:04:33 +0000 Subject: [PATCH] adaptivedemux: allow seeking before start in live streams 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index 3c30c7d973..b18c2580f2 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -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);