summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2017-03-21 20:37:17 +0200
committerSebastian Dröge <sebastian@centricular.com>2017-03-21 20:38:09 +0200
commit19eba961d20b796277b3af5762e9c07b4364bfb6 (patch)
tree20006b100df1ac097d656836fdb5e50ee3e6ade9
parent0cc777b3b02dd89afc41a2565eccd5477781bc7e (diff)
downloadgstreamer-plugins-bad-19eba961d20b796277b3af5762e9c07b4364bfb6.tar.gz
dashdemux: Implement SNAP_NEAREST seeks
-rw-r--r--ext/dash/gstmpdparser.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c
index 5bb5b9d87..a1d4cdace 100644
--- a/ext/dash/gstmpdparser.c
+++ b/ext/dash/gstmpdparser.c
@@ -4804,7 +4804,19 @@ gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream,
repeat_index--;
if ((flags & GST_SEEK_FLAG_SNAP_NEAREST) == GST_SEEK_FLAG_SNAP_NEAREST) {
- /* FIXME implement this */
+ if (repeat_index + 1 < segment->repeat) {
+ if (ts - chunk_time > chunk_time + segment->duration - ts)
+ repeat_index++;
+ } else if (index + 1 < stream->segments->len) {
+ GstMediaSegment *next_segment =
+ g_ptr_array_index (stream->segments, index + 1);
+
+ if (ts - chunk_time > next_segment->start - ts) {
+ repeat_index = 0;
+ selectedChunk = next_segment;
+ index++;
+ }
+ }
} else if (((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) ||
(!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE)) &&
ts != chunk_time) {
@@ -4855,7 +4867,8 @@ gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream,
index_time = index * duration;
if ((flags & GST_SEEK_FLAG_SNAP_NEAREST) == GST_SEEK_FLAG_SNAP_NEAREST) {
- /* FIXME implement this */
+ if (ts - index_time > index_time + duration - ts)
+ index++;
} else if (((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) ||
(!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE))
&& ts != index_time) {