Flush the parser at the end of each m3u8 download
If an m3u8 was missing a trailing newline, the last line of input would remain buffered in the parser. This could cause VOD playlists to be misinterpreted as live or a final segment to be switched. Fixes #113.
Showing
2 changed files
with
13 additions
and
0 deletions
... | @@ -74,6 +74,7 @@ | ... | @@ -74,6 +74,7 @@ |
74 | 74 | ||
75 | parser = new videojs.m3u8.Parser(); | 75 | parser = new videojs.m3u8.Parser(); |
76 | parser.push(xhr.responseText); | 76 | parser.push(xhr.responseText); |
77 | parser.end(); | ||
77 | parser.manifest.uri = url; | 78 | parser.manifest.uri = url; |
78 | 79 | ||
79 | // merge this playlist into the master | 80 | // merge this playlist into the master |
... | @@ -232,6 +233,7 @@ | ... | @@ -232,6 +233,7 @@ |
232 | 233 | ||
233 | parser = new videojs.m3u8.Parser(); | 234 | parser = new videojs.m3u8.Parser(); |
234 | parser.push(this.responseText); | 235 | parser.push(this.responseText); |
236 | parser.end(); | ||
235 | 237 | ||
236 | loader.state = 'HAVE_MASTER'; | 238 | loader.state = 'HAVE_MASTER'; |
237 | 239 | ... | ... |
... | @@ -551,4 +551,15 @@ | ... | @@ -551,4 +551,15 @@ |
551 | loader.media('low.m3u8'); | 551 | loader.media('low.m3u8'); |
552 | strictEqual(mediaChanges, 2, 'ignored a no-op media change'); | 552 | strictEqual(mediaChanges, 2, 'ignored a no-op media change'); |
553 | }); | 553 | }); |
554 | |||
555 | test('does not misintrepret playlists missing newlines at the end', function() { | ||
556 | var loader = new videojs.Hls.PlaylistLoader('media.m3u8'); | ||
557 | requests.shift().respond(200, null, | ||
558 | '#EXTM3U\n' + | ||
559 | '#EXT-X-MEDIA-SEQUENCE:0\n' + | ||
560 | '#EXTINF:10,\n' + | ||
561 | 'low-0.ts\n' + | ||
562 | '#EXT-X-ENDLIST'); // no newline | ||
563 | ok(loader.media().endList, 'flushed the final line of input'); | ||
564 | }); | ||
554 | })(window); | 565 | })(window); | ... | ... |
-
Please register or sign in to post a comment