dashdemux2: Fix seeking in a stream with gaps
When there are gaps between segments in the DASH manifest (e.g. it's a recording of a live stream during which the camera was turned on and off a couple times), seeking to a timestamp that belongs into a gap leads to repeat_index calculation yielding a nonsensical negative number (because ts < segment->start). In such event set the playback to continue at the first repetition of the segment that follows after the gap. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8620>
This commit is contained in:
parent
491b72aca3
commit
ddd6a708cb
@ -1710,10 +1710,16 @@ gst_mpd_client2_stream_seek (GstMPDClient2 * client, GstActiveStream * stream,
|
||||
GstClockTime chunk_time;
|
||||
|
||||
selectedChunk = segment;
|
||||
repeat_index =
|
||||
((ts - segment->start) +
|
||||
((GstMediaSegment *) stream->segments->pdata[0])->start) /
|
||||
segment->duration;
|
||||
if (ts < segment->start) {
|
||||
/* Seek time lies in a gap between segments. Continue playing from
|
||||
* the first repetition of selectedChunk. */
|
||||
repeat_index = 0;
|
||||
} else {
|
||||
repeat_index =
|
||||
((ts - segment->start) +
|
||||
((GstMediaSegment *) stream->segments->pdata[0])->start) /
|
||||
segment->duration;
|
||||
}
|
||||
|
||||
chunk_time = segment->start + segment->duration * repeat_index;
|
||||
|
||||
@ -1738,7 +1744,7 @@ gst_mpd_client2_stream_seek (GstMPDClient2 * client, GstActiveStream * stream,
|
||||
}
|
||||
} else if (((forward && flags & GST_SEEK_FLAG_SNAP_AFTER) ||
|
||||
(!forward && flags & GST_SEEK_FLAG_SNAP_BEFORE)) &&
|
||||
ts != chunk_time) {
|
||||
ts > chunk_time) {
|
||||
|
||||
if (repeat_index + 1 < segment->repeat) {
|
||||
repeat_index++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user