Merge branch 'master' into saucytravis3_thefinaldimension
Conflicts: package.json
Showing
43 changed files
with
436 additions
and
86 deletions
docs/live.md
0 → 100644
1 | # Live HLS Research | ||
2 | This document is a collection of notes on Live HLS implementations in the wild. | ||
3 | |||
4 | There are two varieties of Live HLS. In the first, playlists are | ||
5 | persistent and strictly appended to. In the alternative form, the | ||
6 | maximum number of segments in a playlist is relatively stable and an | ||
7 | old segment is removed every time a new segment becomes available. | ||
8 | |||
9 | On iOS devices, both stream types report a duration of `Infinity`. The | ||
10 | `currentTime` is equal to the amount of the stream that has been | ||
11 | played back on the device. | ||
12 | |||
13 | ## Akamai HD2 | ||
14 | |||
15 | ## OnceLIVE | ||
16 | "Sliding window" live streams. | ||
17 | |||
18 | ### Variant Playlists | ||
19 | Once variant playlists look like standard HLS variant playlists. | ||
20 | |||
21 | ### Media Playlists | ||
22 | OnceLIVE uses "sliding window" manifests for live playback. The media | ||
23 | playlists do not have an `EXT-X-ENDLIST` and don't declare a | ||
24 | `EXT-X-PLAYLIST-TYPE`. On first request, the stream media playlist | ||
25 | returned four segment URLs with a starting media sequence of one, | ||
26 | preceded by a `EXT-X-DISCONTINUITY` tag. As playback progressed, that | ||
27 | number grew to 13 segment URLs, at which point it stabilized. That | ||
28 | would equate to a steady-state 65 second window at 5 seconds per | ||
29 | segment. | ||
30 | |||
31 | OnceLive documentation is [available on the Unicorn Media | ||
32 | website](http://www.unicornmedia.com/documents/2013/02/oncelive_implementationguide.pdf). | ||
33 | |||
34 | Here's a script to quickly parse out segment URLs: | ||
35 | |||
36 | ```shell | ||
37 | curl $ONCE_MEDIA_PLAYLIST | grep '^http' | ||
38 | ``` | ||
39 | |||
40 | An example media playlist might look something like this: | ||
41 | ```m3u8 | ||
42 | #EXTM3U | ||
43 | #EXT-X-TARGETDURATION:5 | ||
44 | #EXT-X-MEDIA-SEQUENCE:3 | ||
45 | #EXTINF:5,3 | ||
46 | http://example.com/0/1/content.ts?visitguid=uuid&asseturl=http://once.example.com/asset.lrm&failoverurl=http://example.com/blank.jpg | ||
47 | #EXTINF:5,4 | ||
48 | http://example.com/1/2/content.ts?visitguid=uuid&asseturl=http://once.example.com/asset.lrm&failoverurl=http://example.com/blank.jpg | ||
49 | #EXTINF:5,5 | ||
50 | http://example.com/2/3/content.ts?visitguid=uuid&asseturl=http://once.example.com/asset.lrm&failoverurl=http://example.com/blank.jpg | ||
51 | #EXTINF:5,6 | ||
52 | http://example.com/3/4/content.ts?visitguid=uuid&asseturl=http://once.example.com/asset.lrm&failoverurl=http://example.com/blank.jpg | ||
53 | ``` | ||
54 | |||
55 | ## Zencoder Live |
... | @@ -61,7 +61,7 @@ | ... | @@ -61,7 +61,7 @@ |
61 | type="application/x-mpegURL"> | 61 | type="application/x-mpegURL"> |
62 | </video> | 62 | </video> |
63 | <script> | 63 | <script> |
64 | videojs.options.flash.swf = 'node_modules/videojs-swf/dist/video-js.swf'; | 64 | videojs.options.flash.swf = 'node_modules/video.js/dist/video-js/video-js.swf'; |
65 | // initialize the player | 65 | // initialize the player |
66 | var player = videojs('video'); | 66 | var player = videojs('video'); |
67 | 67 | ... | ... |
1 | { | 1 | { |
2 | "name": "videojs-contrib-hls", | 2 | "name": "videojs-contrib-hls", |
3 | "version": "0.3.1", | 3 | "version": "0.3.2", |
4 | "engines": { | 4 | "engines": { |
5 | "node": ">= 0.10.12" | 5 | "node": ">= 0.10.12" |
6 | }, | 6 | }, |
... | @@ -34,10 +34,12 @@ | ... | @@ -34,10 +34,12 @@ |
34 | "karma-phantomjs-launcher": "~0.1.1", | 34 | "karma-phantomjs-launcher": "~0.1.1", |
35 | "karma-safari-launcher": "~0.1.1", | 35 | "karma-safari-launcher": "~0.1.1", |
36 | "karma-qunit": "~0.1.1" | 36 | "karma-qunit": "~0.1.1" |
37 | "video.js": "^4.5" | ||
38 | }, | ||
39 | "peerDependencies": { | ||
40 | "video.js": "^4.5" | ||
37 | }, | 41 | }, |
38 | "dependencies": { | 42 | "dependencies": { |
39 | "video.js": "git+https://github.com/videojs/video.js.git#v4.4.1", | ||
40 | "videojs-swf": "git+https://github.com/videojs/video-js-swf.git#v4.4.0", | ||
41 | "videojs-contrib-media-sources": "git+https://github.com/videojs/videojs-contrib-media-sources.git" | 43 | "videojs-contrib-media-sources": "git+https://github.com/videojs/videojs-contrib-media-sources.git" |
42 | } | 44 | } |
43 | } | 45 | } | ... | ... |
... | @@ -344,13 +344,10 @@ | ... | @@ -344,13 +344,10 @@ |
344 | byterange.offset = entry.offset; | 344 | byterange.offset = entry.offset; |
345 | } | 345 | } |
346 | }, | 346 | }, |
347 | 'endlist': function() { | ||
348 | this.manifest.endList = true; | ||
349 | }, | ||
347 | 'inf': function() { | 350 | 'inf': function() { |
348 | if (!this.manifest.playlistType) { | ||
349 | this.manifest.playlistType = 'VOD'; | ||
350 | this.trigger('info', { | ||
351 | message: 'defaulting playlist type to VOD' | ||
352 | }); | ||
353 | } | ||
354 | if (!('mediaSequence' in this.manifest)) { | 351 | if (!('mediaSequence' in this.manifest)) { |
355 | this.manifest.mediaSequence = 0; | 352 | this.manifest.mediaSequence = 0; |
356 | this.trigger('info', { | 353 | this.trigger('info', { | ... | ... |
This diff is collapsed.
Click to expand it.
1 | (function(window, undefined) { | 1 | (function(window, undefined) { |
2 | var | 2 | var |
3 | //manifestController = this.manifestController, | 3 | //manifestController = this.manifestController, |
4 | ParseStream = window.videojs.m3u8.ParseStream, | 4 | m3u8 = window.videojs.m3u8, |
5 | ParseStream = m3u8.ParseStream, | ||
5 | parseStream, | 6 | parseStream, |
6 | LineStream = window.videojs.m3u8.LineStream, | 7 | LineStream = m3u8.LineStream, |
7 | lineStream, | 8 | lineStream, |
8 | Parser = window.videojs.m3u8.Parser, | 9 | Parser = m3u8.Parser, |
9 | parser; | 10 | parser; |
10 | 11 | ||
11 | /* | 12 | /* |
... | @@ -506,19 +507,15 @@ | ... | @@ -506,19 +507,15 @@ |
506 | ok(!event, 'no event is triggered'); | 507 | ok(!event, 'no event is triggered'); |
507 | }); | 508 | }); |
508 | 509 | ||
509 | module('m3u8 parser', { | 510 | module('m3u8 parser'); |
510 | setup: function() { | ||
511 | parser = new Parser(); | ||
512 | } | ||
513 | }); | ||
514 | 511 | ||
515 | test('should create a parser', function() { | 512 | test('can be constructed', function() { |
516 | notStrictEqual(parser, undefined, 'parser is defined'); | 513 | notStrictEqual(new Parser(), undefined, 'parser is defined'); |
517 | }); | 514 | }); |
518 | 515 | ||
519 | module('m3u8s'); | 516 | module('m3u8s'); |
520 | 517 | ||
521 | test('parses the example manifests as expected', function() { | 518 | test('parses static manifests as expected', function() { |
522 | var key; | 519 | var key; |
523 | for (key in window.manifests) { | 520 | for (key in window.manifests) { |
524 | if (window.expected[key]) { | 521 | if (window.expected[key]) { | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "playlists": [{ | 3 | "playlists": [ |
4 | { | ||
4 | "attributes": { | 5 | "attributes": { |
5 | "PROGRAM-ID": 1, | 6 | "PROGRAM-ID": 1, |
6 | "BANDWIDTH": 240000, | 7 | "BANDWIDTH": 240000, |
... | @@ -10,13 +11,15 @@ | ... | @@ -10,13 +11,15 @@ |
10 | } | 11 | } |
11 | }, | 12 | }, |
12 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686811001&videoId=1824650741001" | 13 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686811001&videoId=1824650741001" |
13 | }, { | 14 | }, |
15 | { | ||
14 | "attributes": { | 16 | "attributes": { |
15 | "PROGRAM-ID": 1, | 17 | "PROGRAM-ID": 1, |
16 | "BANDWIDTH": 40000 | 18 | "BANDWIDTH": 40000 |
17 | }, | 19 | }, |
18 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824683759001&videoId=1824650741001" | 20 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824683759001&videoId=1824650741001" |
19 | }, { | 21 | }, |
22 | { | ||
20 | "attributes": { | 23 | "attributes": { |
21 | "PROGRAM-ID": 1, | 24 | "PROGRAM-ID": 1, |
22 | "BANDWIDTH": 440000, | 25 | "BANDWIDTH": 440000, |
... | @@ -26,7 +29,8 @@ | ... | @@ -26,7 +29,8 @@ |
26 | } | 29 | } |
27 | }, | 30 | }, |
28 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686593001&videoId=1824650741001" | 31 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686593001&videoId=1824650741001" |
29 | }, { | 32 | }, |
33 | { | ||
30 | "attributes": { | 34 | "attributes": { |
31 | "PROGRAM-ID": 1, | 35 | "PROGRAM-ID": 1, |
32 | "BANDWIDTH": 1928000, | 36 | "BANDWIDTH": 1928000, |
... | @@ -36,5 +40,6 @@ | ... | @@ -36,5 +40,6 @@ |
36 | } | 40 | } |
37 | }, | 41 | }, |
38 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824687660001&videoId=1824650741001" | 42 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824687660001&videoId=1824650741001" |
39 | }] | 43 | } |
44 | ] | ||
40 | } | 45 | } | ... | ... |
... | @@ -20,5 +20,6 @@ | ... | @@ -20,5 +20,6 @@ |
20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" | 20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" |
21 | } | 21 | } |
22 | ], | 22 | ], |
23 | "targetDuration": 8 | 23 | "targetDuration": 8, |
24 | "endList": true | ||
24 | } | 25 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "mediaSequence": 0, | 3 | "mediaSequence": 0, |
4 | "playlistType": "VOD", | ||
5 | "segments": [ | 4 | "segments": [ |
6 | { | 5 | { |
7 | "duration": 10, | 6 | "duration": 10, |
... | @@ -28,5 +27,6 @@ | ... | @@ -28,5 +27,6 @@ |
28 | "uri": "/test/ts-files/zencoder/haze/Haze_Mantel_President_encoded_1200-00006.ts" | 27 | "uri": "/test/ts-files/zencoder/haze/Haze_Mantel_President_encoded_1200-00006.ts" |
29 | } | 28 | } |
30 | ], | 29 | ], |
31 | "targetDuration": 10 | 30 | "targetDuration": 10, |
31 | "endList": true | ||
32 | } | 32 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "playlists": [{ | 3 | "playlists": [ |
4 | { | ||
4 | "attributes": { | 5 | "attributes": { |
5 | "PROGRAM-ID": 1, | 6 | "PROGRAM-ID": 1, |
6 | "BANDWIDTH": 240000, | 7 | "BANDWIDTH": 240000, |
... | @@ -10,13 +11,15 @@ | ... | @@ -10,13 +11,15 @@ |
10 | } | 11 | } |
11 | }, | 12 | }, |
12 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686811001&videoId=1824650741001" | 13 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686811001&videoId=1824650741001" |
13 | }, { | 14 | }, |
15 | { | ||
14 | "attributes": { | 16 | "attributes": { |
15 | "PROGRAM-ID": 1, | 17 | "PROGRAM-ID": 1, |
16 | "BANDWIDTH": 40000 | 18 | "BANDWIDTH": 40000 |
17 | }, | 19 | }, |
18 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824683759001&videoId=1824650741001" | 20 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824683759001&videoId=1824650741001" |
19 | }, { | 21 | }, |
22 | { | ||
20 | "attributes": { | 23 | "attributes": { |
21 | "PROGRAM-ID": 1, | 24 | "PROGRAM-ID": 1, |
22 | "BANDWIDTH": 440000, | 25 | "BANDWIDTH": 440000, |
... | @@ -26,7 +29,8 @@ | ... | @@ -26,7 +29,8 @@ |
26 | } | 29 | } |
27 | }, | 30 | }, |
28 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686593001&videoId=1824650741001" | 31 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824686593001&videoId=1824650741001" |
29 | }, { | 32 | }, |
33 | { | ||
30 | "attributes": { | 34 | "attributes": { |
31 | "PROGRAM-ID": 1, | 35 | "PROGRAM-ID": 1, |
32 | "BANDWIDTH": 1928000, | 36 | "BANDWIDTH": 1928000, |
... | @@ -36,5 +40,6 @@ | ... | @@ -36,5 +40,6 @@ |
36 | } | 40 | } |
37 | }, | 41 | }, |
38 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824687660001&videoId=1824650741001" | 42 | "uri": "http://c.brightcove.com/services/mobile/streaming/index/rendition.m3u8?assetId=1824687660001&videoId=1824650741001" |
39 | }] | 43 | } |
44 | ] | ||
40 | } | 45 | } | ... | ... |
... | @@ -28,5 +28,6 @@ | ... | @@ -28,5 +28,6 @@ |
28 | "uri": "/test/ts-files/zencoder/haze/Haze_Mantel_President_encoded_1200-00006.ts" | 28 | "uri": "/test/ts-files/zencoder/haze/Haze_Mantel_President_encoded_1200-00006.ts" |
29 | } | 29 | } |
30 | ], | 30 | ], |
31 | "targetDuration": 10 | 31 | "targetDuration": 10, |
32 | "endList": true | ||
32 | } | 33 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "mediaSequence": 1, | 3 | "mediaSequence": 1, |
4 | "playlistType": "VOD", | ||
5 | "segments": [ | 4 | "segments": [ |
6 | { | 5 | { |
7 | "duration": 6.64, | 6 | "duration": 6.64, |
8 | "uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts" | 7 | "uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts" |
9 | } | 8 | } |
10 | ], | 9 | ], |
11 | "targetDuration": 8 | 10 | "targetDuration": 8, |
11 | "endList": true | ||
12 | } | 12 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -20,5 +20,6 @@ | ... | @@ -20,5 +20,6 @@ |
20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" | 20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" |
21 | } | 21 | } |
22 | ], | 22 | ], |
23 | "targetDuration": 8 | 23 | "targetDuration": 8, |
24 | "endList": true | ||
24 | } | 25 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "mediaSequence": 0, | 3 | "mediaSequence": 0, |
4 | "playlistType": "VOD", | ||
5 | "segments": [ | 4 | "segments": [ |
6 | { | 5 | { |
7 | "duration": 10, | 6 | "duration": 10, |
... | @@ -28,5 +27,6 @@ | ... | @@ -28,5 +27,6 @@ |
28 | "uri": "/test/ts-files/zencoder/haze/Haze_Mantel_President_encoded_1200-00006.ts" | 27 | "uri": "/test/ts-files/zencoder/haze/Haze_Mantel_President_encoded_1200-00006.ts" |
29 | } | 28 | } |
30 | ], | 29 | ], |
31 | "targetDuration": 10 | 30 | "targetDuration": 10, |
31 | "endList": true | ||
32 | } | 32 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "mediaSequence": 0, | 3 | "mediaSequence": 0, |
4 | "playlistType": "VOD", | ||
5 | "segments": [ | 4 | "segments": [ |
6 | { | 5 | { |
7 | "duration": 10, | 6 | "duration": 10, |
8 | "uri": "/test/ts-files/zencoder/gogo/00001.ts" | 7 | "uri": "/test/ts-files/zencoder/gogo/00001.ts" |
9 | } | 8 | } |
10 | ] | 9 | ], |
10 | "endList": true | ||
11 | } | 11 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "mediaSequence": 0, | 3 | "mediaSequence": 0, |
4 | "playlistType": "VOD", | ||
5 | "segments": [ | 4 | "segments": [ |
6 | { | 5 | { |
7 | "duration": 10, | 6 | "duration": 10, |
... | @@ -24,5 +23,6 @@ | ... | @@ -24,5 +23,6 @@ |
24 | "uri": "/test/ts-files/zencoder/gogo/00005.ts" | 23 | "uri": "/test/ts-files/zencoder/gogo/00005.ts" |
25 | } | 24 | } |
26 | ], | 25 | ], |
27 | "targetDuration": 10 | 26 | "targetDuration": 10, |
27 | "endList": true | ||
28 | } | 28 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "mediaSequence": 0, | 3 | "mediaSequence": 0, |
4 | "playlistType": "VOD", | ||
5 | "segments": [ | 4 | "segments": [ |
6 | { | 5 | { |
7 | "duration": 10, | 6 | "duration": 10, |
8 | "uri": "/test/ts-files/zencoder/gogo/00001.ts" | 7 | "uri": "/test/ts-files/zencoder/gogo/00001.ts" |
9 | } | 8 | } |
10 | ], | 9 | ], |
11 | "targetDuration": 10 | 10 | "targetDuration": 10, |
11 | "endList": true | ||
12 | } | 12 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "playlists": [{ | 3 | "playlists": [ |
4 | { | ||
4 | "attributes": { | 5 | "attributes": { |
5 | "PROGRAM-ID": 1, | 6 | "PROGRAM-ID": 1, |
6 | "BANDWIDTH": 240000, | 7 | "BANDWIDTH": 240000, |
... | @@ -10,13 +11,15 @@ | ... | @@ -10,13 +11,15 @@ |
10 | } | 11 | } |
11 | }, | 12 | }, |
12 | "uri": "media.m3u8" | 13 | "uri": "media.m3u8" |
13 | }, { | 14 | }, |
15 | { | ||
14 | "attributes": { | 16 | "attributes": { |
15 | "PROGRAM-ID": 1, | 17 | "PROGRAM-ID": 1, |
16 | "BANDWIDTH": 40000 | 18 | "BANDWIDTH": 40000 |
17 | }, | 19 | }, |
18 | "uri": "media1.m3u8" | 20 | "uri": "media1.m3u8" |
19 | }, { | 21 | }, |
22 | { | ||
20 | "attributes": { | 23 | "attributes": { |
21 | "PROGRAM-ID": 1, | 24 | "PROGRAM-ID": 1, |
22 | "BANDWIDTH": 440000, | 25 | "BANDWIDTH": 440000, |
... | @@ -26,7 +29,8 @@ | ... | @@ -26,7 +29,8 @@ |
26 | } | 29 | } |
27 | }, | 30 | }, |
28 | "uri": "media2.m3u8" | 31 | "uri": "media2.m3u8" |
29 | }, { | 32 | }, |
33 | { | ||
30 | "attributes": { | 34 | "attributes": { |
31 | "PROGRAM-ID": 1, | 35 | "PROGRAM-ID": 1, |
32 | "BANDWIDTH": 1928000, | 36 | "BANDWIDTH": 1928000, |
... | @@ -36,5 +40,6 @@ | ... | @@ -36,5 +40,6 @@ |
36 | } | 40 | } |
37 | }, | 41 | }, |
38 | "uri": "media3.m3u8" | 42 | "uri": "media3.m3u8" |
39 | }] | 43 | } |
44 | ] | ||
40 | } | 45 | } | ... | ... |
... | @@ -20,5 +20,6 @@ | ... | @@ -20,5 +20,6 @@ |
20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" | 20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" |
21 | } | 21 | } |
22 | ], | 22 | ], |
23 | "targetDuration": 8 | 23 | "targetDuration": 8, |
24 | "endList": true | ||
24 | } | 25 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
test/manifest/missingEndlist.json
0 → 100644
test/manifest/missingEndlist.m3u8
0 → 100644
... | @@ -20,5 +20,6 @@ | ... | @@ -20,5 +20,6 @@ |
20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" | 20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" |
21 | } | 21 | } |
22 | ], | 22 | ], |
23 | "targetDuration": 8 | 23 | "targetDuration": 8, |
24 | "endList": true | ||
24 | } | 25 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -20,5 +20,6 @@ | ... | @@ -20,5 +20,6 @@ |
20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" | 20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" |
21 | } | 21 | } |
22 | ], | 22 | ], |
23 | "targetDuration": 8 | 23 | "targetDuration": 8, |
24 | "endList": true | ||
24 | } | 25 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "allowCache": true, | 2 | "allowCache": true, |
3 | "mediaSequence": 0, | 3 | "mediaSequence": 0, |
4 | "playlistType": "VOD", | ||
5 | "targetDuration": 10, | 4 | "targetDuration": 10, |
6 | "segments": [{ | 5 | "segments": [ |
6 | { | ||
7 | "uri": "001.ts" | 7 | "uri": "001.ts" |
8 | }, { | 8 | }, |
9 | { | ||
9 | "uri": "002.ts", | 10 | "uri": "002.ts", |
10 | "duration": 9 | 11 | "duration": 9 |
11 | }, { | 12 | }, |
13 | { | ||
12 | "uri": "003.ts", | 14 | "uri": "003.ts", |
13 | "duration": 7 | 15 | "duration": 7 |
14 | }, { | 16 | }, |
17 | { | ||
15 | "uri": "004.ts", | 18 | "uri": "004.ts", |
16 | "duration": 10 | 19 | "duration": 10 |
17 | }] | 20 | } |
21 | ] | ||
18 | } | 22 | } | ... | ... |
... | @@ -20,5 +20,6 @@ | ... | @@ -20,5 +20,6 @@ |
20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" | 20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" |
21 | } | 21 | } |
22 | ], | 22 | ], |
23 | "targetDuration": 8 | 23 | "targetDuration": 8, |
24 | "endList": true | ||
24 | } | 25 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -8,5 +8,6 @@ | ... | @@ -8,5 +8,6 @@ |
8 | "uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts" | 8 | "uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts" |
9 | } | 9 | } |
10 | ], | 10 | ], |
11 | "targetDuration": 8 | 11 | "targetDuration": 8, |
12 | "endList": true | ||
12 | } | 13 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -20,5 +20,6 @@ | ... | @@ -20,5 +20,6 @@ |
20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" | 20 | "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" |
21 | } | 21 | } |
22 | ], | 22 | ], |
23 | "targetDuration": 8 | 23 | "targetDuration": 8, |
24 | "endList": true | ||
24 | } | 25 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -105,6 +105,7 @@ module('HLS', { | ... | @@ -105,6 +105,7 @@ module('HLS', { |
105 | this.readyState = 4; | 105 | this.readyState = 4; |
106 | this.onreadystatechange(); | 106 | this.onreadystatechange(); |
107 | }; | 107 | }; |
108 | this.abort = function() {}; | ||
108 | }; | 109 | }; |
109 | xhrUrls = []; | 110 | xhrUrls = []; |
110 | }, | 111 | }, |
... | @@ -170,7 +171,7 @@ test('sets the duration if one is available on the playlist', function() { | ... | @@ -170,7 +171,7 @@ test('sets the duration if one is available on the playlist', function() { |
170 | type: 'sourceopen' | 171 | type: 'sourceopen' |
171 | }); | 172 | }); |
172 | 173 | ||
173 | strictEqual(1, calls, 'duration is set'); | 174 | strictEqual(calls, 2, 'duration is set'); |
174 | }); | 175 | }); |
175 | 176 | ||
176 | test('calculates the duration if needed', function() { | 177 | test('calculates the duration if needed', function() { |
... | @@ -181,13 +182,15 @@ test('calculates the duration if needed', function() { | ... | @@ -181,13 +182,15 @@ test('calculates the duration if needed', function() { |
181 | } | 182 | } |
182 | durations.push(duration); | 183 | durations.push(duration); |
183 | }; | 184 | }; |
184 | player.hls('manifest/liveMissingSegmentDuration.m3u8'); | 185 | player.hls('http://example.com/manifest/missingExtinf.m3u8'); |
185 | videojs.mediaSources[player.currentSrc()].trigger({ | 186 | videojs.mediaSources[player.currentSrc()].trigger({ |
186 | type: 'sourceopen' | 187 | type: 'sourceopen' |
187 | }); | 188 | }); |
188 | 189 | ||
189 | strictEqual(durations.length, 1, 'duration is set'); | 190 | strictEqual(durations.length, 2, 'duration is set'); |
190 | strictEqual(durations[0], 6.64 + (2 * 8), 'duration is calculated'); | 191 | strictEqual(durations[0], |
192 | player.hls.media.segments.length * 10, | ||
193 | 'duration is calculated'); | ||
191 | }); | 194 | }); |
192 | 195 | ||
193 | test('starts downloading a segment on loadedmetadata', function() { | 196 | test('starts downloading a segment on loadedmetadata', function() { |
... | @@ -400,15 +403,12 @@ test('downloads additional playlists if required', function() { | ... | @@ -400,15 +403,12 @@ test('downloads additional playlists if required', function() { |
400 | called = true; | 403 | called = true; |
401 | return playlist; | 404 | return playlist; |
402 | } | 405 | } |
403 | playlist.segments = []; | 406 | playlist.segments = [1, 1, 1]; |
404 | return playlist; | 407 | return playlist; |
405 | }; | 408 | }; |
406 | xhrUrls = []; | 409 | xhrUrls = []; |
407 | 410 | ||
408 | // the playlist selection is revisited after a new segment is downloaded | 411 | // the playlist selection is revisited after a new segment is downloaded |
409 | player.currentTime = function() { | ||
410 | return 1; | ||
411 | }; | ||
412 | player.trigger('timeupdate'); | 412 | player.trigger('timeupdate'); |
413 | 413 | ||
414 | strictEqual(2, xhrUrls.length, 'requests were made'); | 414 | strictEqual(2, xhrUrls.length, 'requests were made'); |
... | @@ -867,10 +867,246 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () { | ... | @@ -867,10 +867,246 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () { |
867 | 867 | ||
868 | test('has no effect if native HLS is available', function() { | 868 | test('has no effect if native HLS is available', function() { |
869 | videojs.hls.supportsNativeHls = true; | 869 | videojs.hls.supportsNativeHls = true; |
870 | player.hls('manifest/master.m3u8'); | 870 | player.hls('http://example.com/manifest/master.m3u8'); |
871 | 871 | ||
872 | ok(!(player.currentSrc() in videojs.mediaSources), | 872 | ok(!(player.currentSrc() in videojs.mediaSources), |
873 | 'no media source was opened'); | 873 | 'no media source was opened'); |
874 | }); | 874 | }); |
875 | 875 | ||
876 | test('reloads live playlists', function() { | ||
877 | var callbacks = []; | ||
878 | // capture timeouts | ||
879 | window.setTimeout = function(callback, timeout) { | ||
880 | callbacks.push({ callback: callback, timeout: timeout }); | ||
881 | }; | ||
882 | player.hls('http://example.com/manifest/missingEndlist.m3u8'); | ||
883 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
884 | type: 'sourceopen' | ||
885 | }); | ||
886 | |||
887 | strictEqual(1, callbacks.length, 'refresh was scheduled'); | ||
888 | strictEqual(player.hls.media.targetDuration * 1000, | ||
889 | callbacks[0].timeout, | ||
890 | 'waited one target duration'); | ||
891 | }); | ||
892 | |||
893 | test('duration is Infinity for live playlists', function() { | ||
894 | player.hls('http://example.com/manifest/missingEndlist.m3u8'); | ||
895 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
896 | type: 'sourceopen' | ||
897 | }); | ||
898 | |||
899 | strictEqual(Infinity, player.duration(), 'duration is infinity'); | ||
900 | }); | ||
901 | |||
902 | test('does not reload playlists with an endlist tag', function() { | ||
903 | var callbacks = []; | ||
904 | // capture timeouts | ||
905 | window.setTimeout = function(callback, timeout) { | ||
906 | callbacks.push({ callback: callback, timeout: timeout }); | ||
907 | }; | ||
908 | player.hls('manifest/media.m3u8'); | ||
909 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
910 | type: 'sourceopen' | ||
911 | }); | ||
912 | |||
913 | strictEqual(0, callbacks.length, 'no refresh was scheduled'); | ||
914 | }); | ||
915 | |||
916 | test('reloads a live playlist after half a target duration if it has not ' + | ||
917 | 'changed since the last request', function() { | ||
918 | var callbacks = []; | ||
919 | // capture timeouts | ||
920 | window.setTimeout = function(callback, timeout) { | ||
921 | callbacks.push({ callback: callback, timeout: timeout }); | ||
922 | }; | ||
923 | player.hls('http://example.com/manifest/missingEndlist.m3u8'); | ||
924 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
925 | type: 'sourceopen' | ||
926 | }); | ||
927 | |||
928 | strictEqual(callbacks.length, 1, 'full-length refresh scheduled'); | ||
929 | callbacks.pop().callback(); | ||
930 | |||
931 | strictEqual(1, callbacks.length, 'half-length refresh was scheduled'); | ||
932 | strictEqual(callbacks[0].timeout, | ||
933 | player.hls.media.targetDuration / 2 * 1000, | ||
934 | 'waited half a target duration'); | ||
935 | }); | ||
936 | |||
937 | test('merges playlist reloads', function() { | ||
938 | var | ||
939 | oldPlaylist, | ||
940 | callback; | ||
941 | // capture timeouts | ||
942 | window.setTimeout = function(cb) { | ||
943 | callback = cb; | ||
944 | }; | ||
945 | |||
946 | player.hls('http://example.com/manifest/missingEndlist.m3u8'); | ||
947 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
948 | type: 'sourceopen' | ||
949 | }); | ||
950 | oldPlaylist = player.hls.media; | ||
951 | |||
952 | callback(); | ||
953 | ok(oldPlaylist !== player.hls.media, 'player.hls.media was updated'); | ||
954 | }); | ||
955 | |||
956 | test('updates the media index when a playlist reloads', function() { | ||
957 | var callback; | ||
958 | window.setTimeout = function(cb) { | ||
959 | callback = cb; | ||
960 | }; | ||
961 | // the initial playlist | ||
962 | window.manifests['live-updating'] = | ||
963 | '#EXTM3U\n' + | ||
964 | '#EXTINF:10,\n' + | ||
965 | '0.ts\n' + | ||
966 | '#EXTINF:10,\n' + | ||
967 | '1.ts\n' + | ||
968 | '#EXTINF:10,\n' + | ||
969 | '2.ts\n'; | ||
970 | |||
971 | player.hls('http://example.com/live-updating.m3u8'); | ||
972 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
973 | type: 'sourceopen' | ||
974 | }); | ||
975 | |||
976 | // play the stream until 2.ts is playing | ||
977 | player.hls.mediaIndex = 3; | ||
978 | |||
979 | // reload the updated playlist | ||
980 | window.manifests['live-updating'] = | ||
981 | '#EXTM3U\n' + | ||
982 | '#EXTINF:10,\n' + | ||
983 | '1.ts\n' + | ||
984 | '#EXTINF:10,\n' + | ||
985 | '2.ts\n' + | ||
986 | '#EXTINF:10,\n' + | ||
987 | '3.ts\n'; | ||
988 | callback(); | ||
989 | |||
990 | strictEqual(player.hls.mediaIndex, 2, 'mediaIndex is updated after the reload'); | ||
991 | }); | ||
992 | |||
993 | test('mediaIndex is zero before the first segment loads', function() { | ||
994 | window.manifests['first-seg-load'] = | ||
995 | '#EXTM3U\n' + | ||
996 | '#EXTINF:10,\n' + | ||
997 | '0.ts\n'; | ||
998 | window.XMLHttpRequest = function() { | ||
999 | this.open = function() {}; | ||
1000 | this.send = function() {}; | ||
1001 | }; | ||
1002 | player.hls('http://example.com/first-seg-load.m3u8'); | ||
1003 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
1004 | type: 'sourceopen' | ||
1005 | }); | ||
1006 | |||
1007 | strictEqual(player.hls.mediaIndex, 0, 'mediaIndex is zero'); | ||
1008 | }); | ||
1009 | |||
1010 | test('reloads out-of-date live playlists when switching variants', function() { | ||
1011 | player.hls('http://example.com/master.m3u8'); | ||
1012 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
1013 | type: 'sourceopen' | ||
1014 | }); | ||
1015 | |||
1016 | player.hls.master = { | ||
1017 | playlists: [{ | ||
1018 | mediaSequence: 15, | ||
1019 | segments: [1, 1, 1] | ||
1020 | }, { | ||
1021 | uri: 'http://example.com/variant-update.m3u8', | ||
1022 | mediaSequence: 0, | ||
1023 | segments: [1, 1] | ||
1024 | }] | ||
1025 | }; | ||
1026 | // playing segment 15 on playlist zero | ||
1027 | player.hls.media = player.hls.master.playlists[0]; | ||
1028 | player.mediaIndex = 1; | ||
1029 | window.manifests['variant-update'] = '#EXTM3U\n' + | ||
1030 | '#EXT-X-MEDIA-SEQUENCE:16\n' + | ||
1031 | '#EXTINF:10,\n' + | ||
1032 | '16.ts\n' + | ||
1033 | '#EXTINF:10,\n' + | ||
1034 | '17.ts\n'; | ||
1035 | |||
1036 | // switch playlists | ||
1037 | player.hls.selectPlaylist = function() { | ||
1038 | return player.hls.master.playlists[1]; | ||
1039 | }; | ||
1040 | // timeupdate downloads segment 16 then switches playlists | ||
1041 | player.trigger('timeupdate'); | ||
1042 | |||
1043 | strictEqual(player.mediaIndex, 1, 'mediaIndex points at the next segment'); | ||
1044 | }); | ||
1045 | |||
1046 | test('does not reload master playlists', function() { | ||
1047 | var callbacks = []; | ||
1048 | window.setTimeout = function(callback) { | ||
1049 | callbacks.push(callback); | ||
1050 | }; | ||
1051 | |||
1052 | player.hls('http://example.com/master.m3u8'); | ||
1053 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
1054 | type: 'sourceopen' | ||
1055 | }); | ||
1056 | |||
1057 | strictEqual(callbacks.length, 0, 'no reload scheduled'); | ||
1058 | }); | ||
1059 | |||
1060 | test('only reloads the active media playlist', function() { | ||
1061 | var callbacks = [], urls = [], responses = []; | ||
1062 | window.setTimeout = function(callback) { | ||
1063 | callbacks.push(callback); | ||
1064 | }; | ||
1065 | |||
1066 | player.hls('http://example.com/missingEndlist.m3u8'); | ||
1067 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
1068 | type: 'sourceopen' | ||
1069 | }); | ||
1070 | |||
1071 | window.XMLHttpRequest = function() { | ||
1072 | this.open = function(method, url) { | ||
1073 | urls.push(url); | ||
1074 | }; | ||
1075 | this.send = function() { | ||
1076 | var xhr = this; | ||
1077 | responses.push(function() { | ||
1078 | xhr.readyState = 4; | ||
1079 | xhr.responseText = '#EXTM3U\n' + | ||
1080 | '#EXT-X-MEDIA-SEQUENCE:1\n' + | ||
1081 | '#EXTINF:10,\n' + | ||
1082 | '1.ts\n'; | ||
1083 | xhr.response = new Uint8Array([1]).buffer; | ||
1084 | xhr.onreadystatechange(); | ||
1085 | }); | ||
1086 | }; | ||
1087 | }; | ||
1088 | player.hls.selectPlaylist = function() { | ||
1089 | return player.hls.master.playlists[1]; | ||
1090 | }; | ||
1091 | player.hls.master.playlists.push({ | ||
1092 | uri: 'http://example.com/switched.m3u8' | ||
1093 | }); | ||
1094 | |||
1095 | player.trigger('timeupdate'); | ||
1096 | strictEqual(callbacks.length, 1, 'a refresh is scheduled'); | ||
1097 | strictEqual(responses.length, 1, 'segment requested'); | ||
1098 | |||
1099 | responses.shift()(); // segment response | ||
1100 | responses.shift()(); // loaded switched.m3u8 | ||
1101 | |||
1102 | urls = []; | ||
1103 | callbacks.shift()(); // out-of-date refresh of missingEndlist.m3u8 | ||
1104 | callbacks.shift()(); // refresh switched.m3u8 | ||
1105 | |||
1106 | strictEqual(urls.length, 1, 'one refresh was made'); | ||
1107 | strictEqual(urls[0], | ||
1108 | 'http://example.com/switched.m3u8', | ||
1109 | 'refreshed the active playlist'); | ||
1110 | }); | ||
1111 | |||
876 | })(window, window.videojs); | 1112 | })(window, window.videojs); | ... | ... |
-
Please register or sign in to post a comment