adaptivedemux2: Initialize and use stream start/current position

The stream start and current position would be properly set when seeking or
activating a stream after playback started. But it would never be properly
initialized.

Set it to NONE initially to indicate to subclasses that no position has been
tracked yet. This will allow them to detect initial stream usage.

Futhermore, once the initial streams setup is done, make sure that it is set to
a valid initial value:
* The minimum stream time in live
* Or else the period start

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2679>
This commit is contained in:
Edward Hervey 2022-05-17 07:07:23 +02:00 committed by GStreamer Marge Bot
parent 7c40fcb66e
commit 4eac7f0e06
2 changed files with 12 additions and 0 deletions

View file

@ -63,6 +63,8 @@ gst_adaptive_demux2_stream_init (GstAdaptiveDemux2Stream * stream)
stream->fragment_bitrates =
g_malloc0 (sizeof (guint64) * NUM_LOOKBACK_FRAGMENTS);
stream->start_position = stream->current_position = GST_CLOCK_TIME_NONE;
gst_segment_init (&stream->parse_segment, GST_FORMAT_TIME);
}

View file

@ -1812,6 +1812,16 @@ gst_adaptive_demux_prepare_streams (GstAdaptiveDemux * demux,
GST_TIME_ARGS (period_start), GST_STIME_ARGS (min_stream_time),
&demux->segment);
/* Synchronize stream start/current positions */
if (min_stream_time == GST_CLOCK_STIME_NONE)
min_stream_time = period_start;
else
min_stream_time += period_start;
for (iter = new_streams; iter; iter = g_list_next (iter)) {
GstAdaptiveDemux2Stream *stream = iter->data;
stream->start_position = stream->current_position = min_stream_time;
}
for (iter = new_streams; iter; iter = g_list_next (iter)) {
GstAdaptiveDemux2Stream *stream = iter->data;
stream->compute_segment = TRUE;