mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 04:00:37 +00:00
hlsdemux2: Minor refactoring of starting segment check
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6610>
This commit is contained in:
parent
5bc9883d68
commit
c924e4cc1e
1 changed files with 28 additions and 28 deletions
|
@ -2110,6 +2110,10 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self,
|
||||||
res = g_ptr_array_index (self->segments, 0);
|
res = g_ptr_array_index (self->segments, 0);
|
||||||
} else {
|
} else {
|
||||||
GstClockTime hold_back = GST_CLOCK_TIME_NONE;
|
GstClockTime hold_back = GST_CLOCK_TIME_NONE;
|
||||||
|
GstM3U8MediaSegment *last_seg;
|
||||||
|
g_assert (self->segments->len);
|
||||||
|
last_seg = g_ptr_array_index (self->segments, self->segments->len - 1);
|
||||||
|
|
||||||
/* Live playlist. If low-latency, use the PART-HOLD-BACK specified distance
|
/* Live playlist. If low-latency, use the PART-HOLD-BACK specified distance
|
||||||
* from the end, otherwise HOLD-BACK distance */
|
* from the end, otherwise HOLD-BACK distance */
|
||||||
if (GST_CLOCK_TIME_IS_VALID (self->part_hold_back))
|
if (GST_CLOCK_TIME_IS_VALID (self->part_hold_back))
|
||||||
|
@ -2135,41 +2139,37 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self,
|
||||||
hold_back = GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE * self->targetduration;
|
hold_back = GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE * self->targetduration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GST_CLOCK_TIME_IS_VALID (hold_back)) {
|
if (GST_CLOCK_TIME_IS_VALID (hold_back)
|
||||||
GstM3U8MediaSegment *last_seg =
|
&& GST_CLOCK_STIME_IS_VALID (last_seg->stream_time)) {
|
||||||
g_ptr_array_index (self->segments, self->segments->len - 1);
|
GstSeekFlags flags =
|
||||||
|
GST_SEEK_FLAG_SNAP_BEFORE | GST_SEEK_FLAG_KEY_UNIT |
|
||||||
|
GST_HLS_M3U8_SEEK_FLAG_ALLOW_PARTIAL;
|
||||||
|
GstClockTime playlist_duration =
|
||||||
|
last_seg->stream_time + last_seg->duration;
|
||||||
|
GstClockTime target_ts;
|
||||||
|
|
||||||
if (GST_CLOCK_STIME_IS_VALID (last_seg->stream_time)) {
|
/* Clamp the hold back so we don't go below zero */
|
||||||
GstSeekFlags flags =
|
if (hold_back > playlist_duration)
|
||||||
GST_SEEK_FLAG_SNAP_BEFORE | GST_SEEK_FLAG_KEY_UNIT |
|
hold_back = playlist_duration;
|
||||||
GST_HLS_M3U8_SEEK_FLAG_ALLOW_PARTIAL;
|
|
||||||
GstClockTime playlist_duration =
|
|
||||||
last_seg->stream_time + last_seg->duration;
|
|
||||||
GstClockTime target_ts;
|
|
||||||
|
|
||||||
/* Clamp the hold back so we don't go below zero */
|
target_ts = playlist_duration - hold_back;
|
||||||
if (hold_back > playlist_duration)
|
|
||||||
hold_back = playlist_duration;
|
|
||||||
|
|
||||||
target_ts = playlist_duration - hold_back;
|
GST_DEBUG ("Hold back is %" GST_TIME_FORMAT
|
||||||
|
" Looking for a segment before %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (hold_back), GST_TIME_ARGS (target_ts));
|
||||||
|
|
||||||
GST_DEBUG ("Hold back is %" GST_TIME_FORMAT
|
if (gst_hls_media_playlist_seek (self, TRUE, flags, target_ts,
|
||||||
" Looking for a segment before %" GST_TIME_FORMAT,
|
seek_result)) {
|
||||||
GST_TIME_ARGS (hold_back), GST_TIME_ARGS (target_ts));
|
|
||||||
|
|
||||||
if (gst_hls_media_playlist_seek (self, TRUE, flags, target_ts,
|
|
||||||
seek_result)) {
|
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
#ifndef GST_DISABLE_GST_DEBUG
|
||||||
GstClockTime distance_from_edge =
|
GstClockTime distance_from_edge =
|
||||||
playlist_duration - seek_result->stream_time;
|
playlist_duration - seek_result->stream_time;
|
||||||
|
|
||||||
GST_DEBUG ("Found starting position %" GST_TIME_FORMAT " which is %"
|
GST_DEBUG ("Found starting position %" GST_TIME_FORMAT " which is %"
|
||||||
GST_TIME_FORMAT " from the live edge",
|
GST_TIME_FORMAT " from the live edge",
|
||||||
GST_TIME_ARGS (seek_result->stream_time),
|
GST_TIME_ARGS (seek_result->stream_time),
|
||||||
GST_TIME_ARGS (distance_from_edge));
|
GST_TIME_ARGS (distance_from_edge));
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue