From 19eba961d20b796277b3af5762e9c07b4364bfb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 21 Mar 2017 20:37:17 +0200 Subject: dashdemux: Implement SNAP_NEAREST seeks --- ext/dash/gstmpdparser.c | 17 +++++++++++++++-- 1 file 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) { -- cgit v1.2.1