hls: Exclusion of last three fragment in case of live playback

HLS spec 6.3.3 is saying that
"the client SHOULD NOT choose a segment which starts less than
three target durations from the end of the Playlist file."

To ensure above statement, the third fragment from the end of playlist
should be excluded from seekable range and also from available starting fragment.
(i.e., the fourth fragment from end of playlist is the starting fragment).

https://bugzilla.gnome.org/show_bug.cgi?id=777682
This commit is contained in:
Seungha Yang 2017-01-24 21:32:13 +09:00 committed by Sebastian Dröge
parent e9e6e4a4f6
commit de86258c94
2 changed files with 4 additions and 7 deletions

View file

@ -1454,7 +1454,7 @@ retry:
"sequence:%" G_GINT64_FORMAT " , first_sequence:%" G_GINT64_FORMAT
" , last_sequence:%" G_GINT64_FORMAT, m3u8->sequence,
first_sequence, last_sequence);
if (m3u8->sequence >= last_sequence - 3) {
if (m3u8->sequence > last_sequence - 3) {
//demux->need_segment = TRUE;
/* Make sure we never go below the minimum sequence number */
m3u8->sequence = MAX (first_sequence, last_sequence - 3);

View file

@ -758,11 +758,8 @@ gst_m3u8_update (GstM3U8 * self, gchar * data)
file = g_list_last (self->files);
/* for live streams, start GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE from
* the end of the playlist. See section 6.3.3 of HLS draft. Note
* the -1, because GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE = 1 means
* start 1 target-duration from the end */
for (i = 0; i < GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE - 1 && file->prev;
++i)
* the end of the playlist. See section 6.3.3 of HLS draft */
for (i = 0; i < GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE && file->prev; ++i)
file = file->prev;
} else {
file = g_list_first (self->files);
@ -1140,7 +1137,7 @@ gst_m3u8_get_seek_range (GstM3U8 * m3u8, gint64 * start, gint64 * stop)
}
count = g_list_length (m3u8->files);
for (walk = m3u8->files; walk && count >= min_distance; walk = walk->next) {
for (walk = m3u8->files; walk && count > min_distance; walk = walk->next) {
file = walk->data;
--count;
duration += file->duration;