summaryrefslogtreecommitdiff
path: root/ext/hls
diff options
context:
space:
mode:
authorSeungha Yang <sh.yang@lge.com>2017-01-27 08:50:10 +0900
committerSebastian Dröge <sebastian@centricular.com>2017-01-31 13:23:34 +0200
commitb5cf96fc35f78f4435368331859568475205ea0c (patch)
tree695d303e6ad080896ae165658b4d0700497310de /ext/hls
parentde86258c9443cffa7a4e78d7df4b5c2c18f640b0 (diff)
downloadgstreamer-plugins-bad-b5cf96fc35f78f4435368331859568475205ea0c.tar.gz
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
Diffstat (limited to 'ext/hls')
-rw-r--r--ext/hls/m3u8.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c
index eca52914b..e85592ee3 100644
--- a/ext/hls/m3u8.c
+++ b/ext/hls/m3u8.c
@@ -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);
}