GNOME Bugzilla – Bug 777682
hls: m3u8: Set sequence position for live
Last modified: 2017-01-31 11:25:20 UTC
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.
Created attachment 344095 [details] [review] hls: m3u8: Set sequence position for live
Review of attachment 344095 [details] [review]: ::: ext/hls/m3u8.c @@ +765,3 @@ for (i = 0; i < GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE - 1 && file->prev; + ++i) { + sequence_pos -= GST_M3U8_MEDIA_FILE (file->data)->duration; You should probably check here that sequence_pos never becomes < 0 (i.e. wraps around)
Created attachment 344131 [details] [review] hls: m3u8: Set sequence position for live
Created attachment 344132 [details] [review] hlsdemux: Consider timestamp of the first fragment in playlist when live seeking During live playback, the first fragment in a updated playlist can be advanced from that of startup playlist. Meanwhile, since hlsdemux finds target seek position by just accumulating fragment's duration, the base should be adjusted to the updated first fragment's timestamp.
Created attachment 344148 [details] [review] 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).
(In reply to Seungha Yang from comment #5) > Created attachment 344148 [details] [review] [review] > hls: Exclusion of last three fragment in case of live playback > Current hlsdemux starts from the 4th fragment of the end of playlist. But, m3u8 parser set the starting fragment to the 3rd one always, and go back it to the 4th in hlsdemux. It seems weird to me.. 12 0:00:01.589298541 29752 0x1203ca0 DEBUG hls m3u8.c:746:gst_m3u8_update: Live playlist range 0:00:00.000000000 -> 0:05:00.000000000 13 0:00:01.589317656 29752 0x1203ca0 DEBUG hls m3u8.c:773:gst_m3u8_update: first sequence: 358891 14 0:00:01.589325910 29752 0x1203ca0 LOG hls m3u8.c:777:gst_m3u8_update: processed media playlist 01.m3u8, 30 fragments 15 0:00:01.589339508 29752 0x1203ca0 DEBUG hlsdemux gsthlsdemux.c:1455:gst_hls_demux_update_playlist:<hlsdemux0> sequence:358891 , first_sequence:358864 , last_sequence:358893 16 0:00:01.589350707 29752 0x1203ca0 DEBUG hlsdemux gsthlsdemux.c:1462:gst_hls_demux_update_playlist:<hlsdemux0> Sequence is beyond playlist. Moving back to 358890 Also, following code check equality but there is nothing changed if they are equal. However, still print updating log https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/ext/hls/gsthlsdemux.c#n1456
Comment on attachment 344131 [details] [review] hls: m3u8: Set sequence position for live This patch's sequence position setting is wrong, I will update soon.
Created attachment 344195 [details] [review] hls: m3u8: Set sequence position for live
Comment on attachment 344195 [details] [review] hls: m3u8: Set sequence position for live This does not apply to latest GIT master
Review of attachment 344195 [details] [review]: ::: ext/hls/m3u8.c @@ +760,3 @@ + sequence_pos = + self->last_file_end - GST_M3U8_MEDIA_FILE (file->data)->duration; Why would that never be negative? @@ +771,2 @@ file = file->prev; + sequence_pos -= GST_M3U8_MEDIA_FILE (file->data)->duration; And this?
Comment on attachment 344148 [details] [review] hls: Exclusion of last three fragment in case of live playback This also breaks the unit test Running suite(s): hlsdemux_m3u8 0:00:00.019038343 20758 0x55fa9c4e5e90 WARN hlsdemux_m3u m3u8.c:1414:gst_hls_master_playlist_new_from_data: Data doesn't start with #EXTM3U 0:00:00.023648468 20761 0x55fa9c4e5e90 WARN hlsdemux_m3u m3u8.c:1553:gst_hls_master_playlist_new_from_data: variant stream without uri, dropping 0:00:00.035432128 20771 0x55fa9c4e5e90 WARN hlsdemux_m3u m3u8.c:576:gst_m3u8_update: EXTINF duration (0:00:10.321000000) > TARGETDURATION (0:00:10.000000000) 0:00:00.035466645 20771 0x55fa9c4e5e90 WARN hlsdemux_m3u m3u8.c:576:gst_m3u8_update: EXTINF duration (0:00:10.234400000) > TARGETDURATION (0:00:10.000000000) 0:00:00.036834068 20772 0x55fa9c4e5e90 WARN hlsdemux_m3u m3u8.c:654:gst_m3u8_update: Encryption method NONE not supported 0:00:00.038077800 20773 0x55fa9c4e5e90 WARN hlsdemux_m3u m3u8.c:476:gst_m3u8_update: Data doesn't start with #EXTM3U 92%: Checks: 25, Failures: 2, Errors: 0 elements/hlsdemux_m3u8.c:520:F:m3u8client:test_live_playlist:0: 'pl->sequence' (2680) is not equal to '2681' (2681) elements/hlsdemux_m3u8.c:555:F:m3u8client:test_live_playlist_rotated:0: 'pl->sequence' (2680) is not equal to '2681' (2681)
Created attachment 344371 [details] [review] tests: hlsdemux_m3u: Fix live startup sequence and seek range
Created attachment 344372 [details] [review] hls: m3u8: Set sequence position for live
(In reply to Sebastian Dröge (slomo) from comment #10) > Review of attachment 344195 [details] [review] [review]: > > ::: ext/hls/m3u8.c > @@ +760,3 @@ > > + sequence_pos = > + self->last_file_end - GST_M3U8_MEDIA_FILE (file->data)->duration; > > Why would that never be negative? It doesn't make sense that it is negative at that moment, but for safe, I added one more condition :) > > @@ +771,2 @@ > file = file->prev; > + sequence_pos -= GST_M3U8_MEDIA_FILE (file->data)->duration; > > And this? Since for loop is checking the file duration, it never be negative At line 768 for (i = 0; i < GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE && file->prev && GST_M3U8_MEDIA_FILE (file->prev->data)->duration <= sequence_pos; ++i) { .... Please apply "hls: m3u8: Set sequence position for live" on top of "hls: Exclusion of last three fragment in case of live playback"
(In reply to Sebastian Dröge (slomo) from comment #11) > Comment on attachment 344148 [details] [review] [review] > hls: Exclusion of last three fragment in case of live playback > > This also breaks the unit test Please refer to "tests: hlsdemux_m3u: Fix live startup sequence and seek range" I modified unit test code.
Created attachment 344373 [details] [review] tests: hlsdemux: Fix live startup sequence and seek range
Attachment 344132 [details] pushed as e9e6e4a - hlsdemux: Consider timestamp of the first fragment in playlist when live seeking Attachment 344148 [details] pushed as de86258 - hls: Exclusion of last three fragment in case of live playback Attachment 344372 [details] pushed as b5cf96f - hls: m3u8: Set sequence position for live Attachment 344373 [details] pushed as d59571e - tests: hlsdemux: Fix live startup sequence and seek range