From b8b2946e03305cc60ac17b7df9437aad58c22a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 22 Mar 2017 12:04:35 +0200 Subject: [PATCH] dashdemux: In reverse playback mode, if seeking to the beginning of a fragment, start with the previous one instead There's no point to start downloading a fragment just to output 1ns. --- ext/dash/gstdashdemux.c | 4 ++++ ext/dash/gstmpdparser.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c index 461ec7fab2..0af18c2bb1 100644 --- a/ext/dash/gstdashdemux.c +++ b/ext/dash/gstdashdemux.c @@ -1290,6 +1290,10 @@ gst_dash_demux_stream_sidx_seek (GstDashDemuxStream * dashstream, /* FIXME in reverse mode, if we are exactly at a fragment start it makes more * sense to start from the end of the previous fragment */ + if (!forward && idx > 0 && entry->pts == ts) { + idx--; + entry = &sidx->entries[idx]; + } /* Now entry->pts <= ts < entry->pts + entry->duration, need to adjust for * snapping */ diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index a1d4cdace1..9443701913 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -4864,6 +4864,11 @@ gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, ts = 0; index = ts / duration; + + /* At the end of a segment in reverse mode, start from the previous fragment */ + if (!forward && index > 0 && ts % duration == 0) + index--; + index_time = index * duration; if ((flags & GST_SEEK_FLAG_SNAP_NEAREST) == GST_SEEK_FLAG_SNAP_NEAREST) {