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.
diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c
index 461ec7f..0af18c2 100644
--- a/ext/dash/gstdashdemux.c
+++ b/ext/dash/gstdashdemux.c
@@ -1290,6 +1290,10 @@
/* 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 a1d4cda..9443701 100644
--- a/ext/dash/gstmpdparser.c
+++ b/ext/dash/gstmpdparser.c
@@ -4864,6 +4864,11 @@
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) {