From b104fb203a99eaeee30a412b036e877b62ee296a Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 16 May 2017 17:29:35 +0200 Subject: [PATCH] adaptivedemux: Don't be too aggressive with seek ranges When an accurate seek is requested on a live stream, only requests the exact value for the "starting position" (i.e. start in forward playback and stop in reverse playback). https://bugzilla.gnome.org/show_bug.cgi?id=782698 --- gst-libs/gst/adaptivedemux/gstadaptivedemux.c | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index 64574719d9..2793d99941 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -1560,26 +1560,27 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux, GstPad * pad, changed = TRUE; } - 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_type == GST_SEEK_TYPE_SET && start < range_start) { - GST_DEBUG_OBJECT (demux, - "Non accurate seek before live stream start, setting to range start: %" - GST_TIME_FORMAT, GST_TIME_ARGS (range_start)); - start = range_start; - changed = TRUE; - } - /* truncate stop position also if set */ - if (stop_type == GST_SEEK_TYPE_SET && stop > range_stop) { - GST_DEBUG_OBJECT (demux, - "Non accurate seek beyong now, setting to: %" - GST_TIME_FORMAT, GST_TIME_ARGS (range_stop)); - stop = range_stop; - changed = TRUE; - } + /* Adjust the requested start/stop position if it falls beyond the live + * seek range. + * The only case where we don't adjust is for the starting point of + * an accurate seek (start if forward and stop if backwards) + */ + if (start_type == GST_SEEK_TYPE_SET && start < range_start && + (rate < 0 || !(flags & GST_SEEK_FLAG_ACCURATE))) { + GST_DEBUG_OBJECT (demux, + "seek before live stream start, setting to range start: %" + GST_TIME_FORMAT, GST_TIME_ARGS (range_start)); + start = range_start; + changed = TRUE; + } + /* truncate stop position also if set */ + if (stop_type == GST_SEEK_TYPE_SET && stop > range_stop && + (rate > 0 || !(flags & GST_SEEK_FLAG_ACCURATE))) { + GST_DEBUG_OBJECT (demux, + "seek ending after live start, adjusting to: %" + GST_TIME_FORMAT, GST_TIME_ARGS (range_stop)); + stop = range_stop; + changed = TRUE; } if (start_type == GST_SEEK_TYPE_SET && GST_CLOCK_TIME_IS_VALID (start) &&