hls: m3u8: Set sequence position for live

hls live starts playback from the allowed latest fragment,
but its "sequence position" is set to zero, and so stream
time is also set to zero.

This does not make sense, because hls live allows seeking to past position,
and it's negative stream time from downstream element's point of view.
Note that, allowed seekable range (and seeking query) is
from the first fragment of playlist to the allowed latest fragment.

https://bugzilla.gnome.org/show_bug.cgi?id=777682
This commit is contained in:
Seungha Yang 2017-01-27 08:50:10 +09:00 committed by Sebastian Dröge
parent de86258c94
commit b5cf96fc35

View file

@ -754,19 +754,30 @@ gst_m3u8_update (GstM3U8 * self, gchar * data)
if (GST_M3U8_IS_LIVE (self)) {
gint i;
GstClockTime sequence_pos = 0;
file = g_list_last (self->files);
if (self->last_file_end >= GST_M3U8_MEDIA_FILE (file->data)->duration) {
sequence_pos =
self->last_file_end - GST_M3U8_MEDIA_FILE (file->data)->duration;
}
/* for live streams, start GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE from
* 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)
for (i = 0; i < GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE && file->prev &&
GST_M3U8_MEDIA_FILE (file->prev->data)->duration <= sequence_pos;
++i) {
file = file->prev;
sequence_pos -= GST_M3U8_MEDIA_FILE (file->data)->duration;
}
self->sequence_position = sequence_pos;
} else {
file = g_list_first (self->files);
self->sequence_position = 0;
}
self->current_file = file;
self->sequence = GST_M3U8_MEDIA_FILE (file->data)->sequence;
self->sequence_position = 0;
GST_DEBUG ("first sequence: %u", (guint) self->sequence);
}