From 7778e8293a9ebb28404c935e8b6cdd9dc6cc0fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 21 Mar 2017 20:27:10 +0200 Subject: dashdemux: Only snap seeks forwards if the seek position does not happen to be the exact segment position --- ext/dash/gstmpdparser.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index c479f8dbd..5bb5b9d87 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -4791,9 +4791,13 @@ gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, in_segment = ts <= end_time; if (in_segment) { + GstClockTime chunk_time; + selectedChunk = segment; repeat_index = (ts - segment->start) / segment->duration; + chunk_time = segment->start + segment->duration * repeat_index; + /* At the end of a segment in reverse mode, start from the previous fragment */ if (!forward && repeat_index > 0 && ((ts - segment->start) % segment->duration == 0)) @@ -4801,8 +4805,9 @@ gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, if ((flags & GST_SEEK_FLAG_SNAP_NEAREST) == GST_SEEK_FLAG_SNAP_NEAREST) { /* FIXME implement this */ - } else if ((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) || - (!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE)) { + } else if (((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) || + (!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE)) && + ts != chunk_time) { if (repeat_index + 1 < segment->repeat) { repeat_index++; @@ -4833,6 +4838,7 @@ gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, gst_mpd_client_get_segment_duration (client, stream, NULL); GstStreamPeriod *stream_period = gst_mpdparser_get_stream_period (client); guint segments_count = gst_mpd_client_get_segments_counts (client, stream); + GstClockTime index_time; g_return_val_if_fail (stream->cur_seg_template-> MultSegBaseType->SegmentTimeline == NULL, FALSE); @@ -4846,11 +4852,13 @@ gst_mpd_client_stream_seek (GstMpdClient * client, GstActiveStream * stream, ts = 0; index = ts / duration; + index_time = index * duration; if ((flags & GST_SEEK_FLAG_SNAP_NEAREST) == GST_SEEK_FLAG_SNAP_NEAREST) { /* FIXME implement this */ - } else if ((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) || - (!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE)) { + } else if (((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) || + (!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE)) + && ts != index_time) { index++; } -- cgit v1.2.1