shaka-player 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  2. package/AUTHORS +2 -0
  3. package/CHANGELOG.md +98 -0
  4. package/CODE_OF_CONDUCT.md +1 -1
  5. package/CONTRIBUTORS +2 -0
  6. package/README.md +38 -32
  7. package/demo/common/asset.js +11 -17
  8. package/demo/common/assets.js +117 -11
  9. package/demo/config.js +28 -1
  10. package/demo/custom.js +52 -38
  11. package/demo/main.js +11 -3
  12. package/demo/search.js +7 -0
  13. package/dist/controls.css +1 -1
  14. package/dist/controls.css.map +1 -1
  15. package/dist/demo.compiled.debug.js +133 -124
  16. package/dist/demo.compiled.debug.map +3 -3
  17. package/dist/demo.compiled.js +133 -124
  18. package/dist/demo.compiled.map +3 -3
  19. package/dist/deps.js +20 -18
  20. package/dist/locales.js +35 -31
  21. package/dist/receiver.compiled.debug.js +58 -50
  22. package/dist/receiver.compiled.debug.map +3 -3
  23. package/dist/receiver.compiled.js +58 -50
  24. package/dist/receiver.compiled.map +3 -3
  25. package/dist/shaka-player.compiled.d.ts +440 -390
  26. package/dist/shaka-player.compiled.debug.d.ts +440 -390
  27. package/dist/shaka-player.compiled.debug.externs.js +162 -77
  28. package/dist/shaka-player.compiled.debug.js +786 -736
  29. package/dist/shaka-player.compiled.debug.map +4 -4
  30. package/dist/shaka-player.compiled.externs.js +162 -77
  31. package/dist/shaka-player.compiled.js +1154 -1121
  32. package/dist/shaka-player.compiled.map +4 -4
  33. package/dist/shaka-player.ui.d.ts +491 -437
  34. package/dist/shaka-player.ui.debug.d.ts +491 -437
  35. package/dist/shaka-player.ui.debug.externs.js +167 -77
  36. package/dist/shaka-player.ui.debug.js +877 -811
  37. package/dist/shaka-player.ui.debug.map +4 -4
  38. package/dist/shaka-player.ui.externs.js +167 -77
  39. package/dist/shaka-player.ui.js +1362 -1318
  40. package/dist/shaka-player.ui.map +4 -4
  41. package/docs/tutorials/ad_monetization.md +54 -0
  42. package/docs/tutorials/basic-usage.md +2 -1
  43. package/docs/tutorials/errors.md +2 -1
  44. package/docs/tutorials/offline.md +10 -8
  45. package/docs/tutorials/plugins.md +5 -0
  46. package/docs/tutorials/ui-customization.md +13 -0
  47. package/docs/tutorials/ui.md +2 -1
  48. package/docs/tutorials/upgrade.md +3 -0
  49. package/externs/managedmediasource.js +24 -0
  50. package/externs/shaka/abr_manager.js +6 -2
  51. package/externs/shaka/cea.js +7 -0
  52. package/externs/shaka/codecs.js +5 -3
  53. package/externs/shaka/manifest.js +21 -5
  54. package/externs/shaka/manifest_parser.js +17 -0
  55. package/externs/shaka/net.js +2 -2
  56. package/externs/shaka/offline.js +9 -2
  57. package/externs/shaka/player.js +53 -7
  58. package/externs/shaka/text.js +3 -1
  59. package/externs/shaka/transmuxer.js +1 -1
  60. package/lib/abr/simple_abr_manager.js +25 -8
  61. package/lib/ads/media_tailor_ad_manager.js +14 -3
  62. package/lib/cast/cast_receiver.js +1 -1
  63. package/lib/cea/cea_decoder.js +28 -0
  64. package/lib/cea/dummy_caption_decoder.js +5 -0
  65. package/lib/dash/dash_parser.js +249 -83
  66. package/lib/dash/mpd_utils.js +52 -31
  67. package/lib/dash/segment_base.js +4 -5
  68. package/lib/dash/segment_list.js +5 -4
  69. package/lib/dash/segment_template.js +83 -26
  70. package/lib/hls/hls_classes.js +28 -43
  71. package/lib/hls/hls_parser.js +761 -649
  72. package/lib/hls/hls_utils.js +64 -5
  73. package/lib/hls/manifest_text_parser.js +7 -11
  74. package/lib/media/adaptation_set.js +20 -13
  75. package/lib/media/adaptation_set_criteria.js +70 -18
  76. package/lib/media/closed_caption_parser.js +13 -0
  77. package/lib/media/content_workarounds.js +6 -0
  78. package/lib/media/drm_engine.js +8 -13
  79. package/lib/media/manifest_parser.js +8 -113
  80. package/lib/media/media_source_capabilities.js +10 -3
  81. package/lib/media/media_source_engine.js +75 -21
  82. package/lib/media/play_rate_controller.js +8 -38
  83. package/lib/media/presentation_timeline.js +7 -1
  84. package/lib/media/quality_observer.js +1 -1
  85. package/lib/media/segment_index.js +5 -5
  86. package/lib/media/segment_prefetch.js +92 -24
  87. package/lib/media/segment_reference.js +67 -1
  88. package/lib/media/segment_utils.js +343 -0
  89. package/lib/media/stall_detector.js +0 -3
  90. package/lib/media/streaming_engine.js +41 -21
  91. package/lib/mss/mss_parser.js +18 -2
  92. package/lib/net/networking_engine.js +66 -12
  93. package/lib/net/networking_utils.js +95 -0
  94. package/lib/offline/indexeddb/v1_storage_cell.js +2 -0
  95. package/lib/offline/indexeddb/v2_storage_cell.js +2 -0
  96. package/lib/offline/manifest_converter.js +2 -0
  97. package/lib/offline/offline_manifest_parser.js +10 -0
  98. package/lib/offline/storage.js +11 -7
  99. package/lib/player.js +993 -1502
  100. package/lib/polyfill/mediasource.js +22 -1
  101. package/lib/text/mp4_ttml_parser.js +2 -2
  102. package/lib/text/srt_text_parser.js +2 -2
  103. package/lib/text/stub_text_displayer.js +51 -0
  104. package/lib/text/text_engine.js +3 -2
  105. package/lib/text/ttml_text_parser.js +28 -5
  106. package/lib/text/ui_text_displayer.js +4 -0
  107. package/lib/text/vtt_text_parser.js +7 -2
  108. package/lib/transmuxer/aac_transmuxer.js +1 -1
  109. package/lib/transmuxer/ac3_transmuxer.js +1 -1
  110. package/lib/transmuxer/ec3_transmuxer.js +1 -1
  111. package/lib/transmuxer/h264.js +5 -4
  112. package/lib/transmuxer/h265.js +5 -4
  113. package/lib/transmuxer/mp3_transmuxer.js +1 -1
  114. package/lib/transmuxer/mpeg_ts_transmuxer.js +1 -1
  115. package/lib/transmuxer/mss_transmuxer.js +1 -1
  116. package/lib/transmuxer/ts_transmuxer.js +33 -13
  117. package/lib/util/buffer_utils.js +26 -4
  118. package/lib/util/content_steering_manager.js +358 -0
  119. package/lib/util/error.js +2 -6
  120. package/lib/util/fairplay_utils.js +1 -1
  121. package/lib/util/fake_event.js +5 -1
  122. package/lib/util/id3_utils.js +50 -1
  123. package/lib/util/manifest_parser_utils.js +12 -8
  124. package/lib/util/mp4_generator.js +2 -4
  125. package/lib/util/mutex.js +59 -0
  126. package/lib/util/object_utils.js +1 -1
  127. package/lib/util/periods.js +154 -179
  128. package/lib/util/platform.js +4 -3
  129. package/lib/util/player_configuration.js +35 -6
  130. package/lib/util/stream_utils.js +105 -98
  131. package/lib/util/ts_parser.js +124 -73
  132. package/lib/util/uint8array_utils.js +5 -1
  133. package/lib/util/xml_utils.js +5 -0
  134. package/maintained-branches.md +2 -2
  135. package/package.json +1 -1
  136. package/roadmap.md +15 -5
  137. package/shaka-player.uncompiled.js +0 -1
  138. package/test/abr/simple_abr_manager_unit.js +33 -33
  139. package/test/ads/ad_manager_unit.js +3 -2
  140. package/test/cast/cast_receiver_integration.js +3 -4
  141. package/test/cast/cast_utils_unit.js +2 -0
  142. package/test/cea/cea_decoder_unit.js +7 -0
  143. package/test/codec_switching/codec_switching_integration.js +2 -1
  144. package/test/dash/dash_parser_integration.js +2 -1
  145. package/test/dash/dash_parser_live_unit.js +0 -19
  146. package/test/dash/dash_parser_manifest_unit.js +494 -2
  147. package/test/dash/mpd_utils_unit.js +61 -30
  148. package/test/hls/hls_live_unit.js +12 -3
  149. package/test/hls/hls_parser_unit.js +377 -27
  150. package/test/hls/manifest_text_parser_unit.js +32 -99
  151. package/test/media/adaptation_set_criteria_unit.js +172 -21
  152. package/test/media/adaptation_set_unit.js +1 -0
  153. package/test/media/content_workarounds_unit.js +1 -1
  154. package/test/media/drm_engine_unit.js +3 -3
  155. package/test/media/media_source_engine_unit.js +1 -1
  156. package/test/media/play_rate_controller_unit.js +0 -48
  157. package/test/media/segment_index_unit.js +2 -1
  158. package/test/mss/mss_player_integration.js +3 -2
  159. package/test/net/networking_engine_unit.js +3 -3
  160. package/test/{media/manifest_parser_unit.js → net/networking_utils_unit.js} +2 -2
  161. package/test/offline/manifest_convert_unit.js +9 -0
  162. package/test/offline/offline_integration.js +2 -1
  163. package/test/offline/storage_integration.js +21 -9
  164. package/test/player_external.js +4 -2
  165. package/test/player_integration.js +15 -4
  166. package/test/player_load_graph_integration.js +47 -151
  167. package/test/player_src_equals_external.js +1 -0
  168. package/test/player_src_equals_integration.js +71 -4
  169. package/test/player_unit.js +80 -27
  170. package/test/test/util/fake_media_source_engine.js +5 -0
  171. package/test/test/util/fake_networking_engine.js +9 -1
  172. package/test/test/util/fake_segment_prefetch.js +3 -0
  173. package/test/test/util/manifest_generator.js +4 -0
  174. package/test/test/util/manifest_parser_util.js +14 -2
  175. package/test/test/util/offline_utils.js +1 -0
  176. package/test/test/util/simple_fakes.js +2 -2
  177. package/test/test/util/streaming_engine_util.js +3 -0
  178. package/test/test/util/test_scheme.js +6 -0
  179. package/test/test/util/ui_utils.js +4 -3
  180. package/test/text/mp4_ttml_parser_unit.js +4 -4
  181. package/test/text/srt_text_parser_unit.js +1 -1
  182. package/test/text/text_displayer_layout_unit.js +1 -1
  183. package/test/text/text_engine_unit.js +6 -0
  184. package/test/text/ttml_text_parser_unit.js +33 -2
  185. package/test/transmuxer/transmuxer_engine_integration.js +9 -0
  186. package/test/transmuxer/transmuxer_integration.js +33 -3
  187. package/test/ui/ad_ui_unit.js +2 -2
  188. package/test/ui/ui_customization_unit.js +17 -16
  189. package/test/ui/ui_integration.js +30 -20
  190. package/test/ui/ui_unit.js +25 -19
  191. package/test/util/buffer_utils_unit.js +1 -1
  192. package/test/util/content_steering_manager_unit.js +427 -0
  193. package/test/util/id3_utils_unit.js +52 -0
  194. package/test/util/stream_utils_unit.js +17 -113
  195. package/test/util/ts_parser_unit.js +3 -3
  196. package/third_party/closure-uri/uri.js +13 -1
  197. package/ui/audio_language_selection.js +9 -2
  198. package/ui/externs/ui.js +17 -2
  199. package/ui/language_utils.js +43 -8
  200. package/ui/less/range_elements.less +33 -0
  201. package/ui/locales/en.json +1 -0
  202. package/ui/locales/es-419.json +1 -0
  203. package/ui/locales/es.json +1 -0
  204. package/ui/locales/source.json +4 -0
  205. package/ui/localization.js +10 -0
  206. package/ui/remote_button.js +3 -1
  207. package/ui/resolution_selection.js +47 -10
  208. package/ui/seek_bar.js +296 -3
  209. package/ui/text_selection.js +2 -1
  210. package/ui/ui.js +6 -2
  211. package/lib/routing/node.js +0 -23
  212. package/lib/routing/payload.js +0 -47
  213. package/lib/routing/walker.js +0 -587
  214. package/test/routing/walker_unit.js +0 -505
@@ -36,10 +36,7 @@ describe('ManifestTextParser', () => {
36
36
 
37
37
  // playlist text:
38
38
  '#EXTM3U\n' +
39
- '#EXT-X-TARGETDURATION:6\n',
40
-
41
- // manifest URI:
42
- 'https://test/manifest.m3u8');
39
+ '#EXT-X-TARGETDURATION:6\n');
43
40
  });
44
41
 
45
42
  it('parses a Master Playlist', () => {
@@ -60,10 +57,7 @@ describe('ManifestTextParser', () => {
60
57
  '#EXTM3U\n' +
61
58
  '#EXT-X-TARGETDURATION:6\n' +
62
59
  '#EXT-X-STREAM-INF:BANDWIDTH=2165224\n' +
63
- 'prog_index.m3u8',
64
-
65
- // manifest URI:
66
- 'https://test/manifest.m3u8');
60
+ 'prog_index.m3u8');
67
61
  });
68
62
 
69
63
  it('ignores comments', () => {
@@ -78,10 +72,7 @@ describe('ManifestTextParser', () => {
78
72
  // playlist text:
79
73
  '#EXTM3U\n' +
80
74
  '#Comment\n' +
81
- '#EXT-X-TARGETDURATION:6',
82
-
83
- // manifest URI:
84
- 'https://test/manifest.m3u8');
75
+ '#EXT-X-TARGETDURATION:6');
85
76
  });
86
77
 
87
78
  /**
@@ -94,7 +85,7 @@ describe('ManifestTextParser', () => {
94
85
  shaka.util.Error.Severity.CRITICAL,
95
86
  shaka.util.Error.Category.MANIFEST,
96
87
  code));
97
- expect(() => parser.parsePlaylist(data, /* uri= */ '')).toThrow(error);
88
+ expect(() => parser.parsePlaylist(data)).toThrow(error);
98
89
  }
99
90
  });
100
91
 
@@ -110,10 +101,7 @@ describe('ManifestTextParser', () => {
110
101
 
111
102
  // playlist text:
112
103
  '#EXTM3U\n' +
113
- '#EXT-X-INDEPENDENT-SEGMENTS',
114
-
115
- // manifest URI:
116
- 'https://test/manifest.m3u8');
104
+ '#EXT-X-INDEPENDENT-SEGMENTS');
117
105
 
118
106
  verifyPlaylist(
119
107
  {
@@ -125,10 +113,7 @@ describe('ManifestTextParser', () => {
125
113
 
126
114
  // playlist text:
127
115
  '#EXTM3U\n' +
128
- '#EXT-X-PLAYLIST-TYPE:VOD',
129
-
130
- // manifest URI:
131
- 'https://test/manifest.m3u8');
116
+ '#EXT-X-PLAYLIST-TYPE:VOD');
132
117
 
133
118
  verifyPlaylist(
134
119
  {
@@ -140,10 +125,7 @@ describe('ManifestTextParser', () => {
140
125
 
141
126
  // playlist text:
142
127
  '#EXTM3U\n' +
143
- '#EXT-X-MEDIA-SEQUENCE:1',
144
-
145
- // manifest URI:
146
- 'https://test/manifest.m3u8');
128
+ '#EXT-X-MEDIA-SEQUENCE:1');
147
129
  });
148
130
 
149
131
  it('parses tags with attributes', () => {
@@ -158,10 +140,7 @@ describe('ManifestTextParser', () => {
158
140
 
159
141
  // playlist text:
160
142
  '#EXTM3U\n' +
161
- '#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS',
162
-
163
- // manifest URI:
164
- 'https://test/manifest.m3u8');
143
+ '#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS');
165
144
 
166
145
  verifyPlaylist(
167
146
  {
@@ -177,10 +156,7 @@ describe('ManifestTextParser', () => {
177
156
 
178
157
  // playlist text:
179
158
  '#EXTM3U\n' +
180
- '#EXT-X-MEDIA:URI="main.mp4",BYTERANGE="720@0"',
181
-
182
- // manifest URI:
183
- 'https://test/manifest.m3u8');
159
+ '#EXT-X-MEDIA:URI="main.mp4",BYTERANGE="720@0"');
184
160
  });
185
161
 
186
162
  it('parses tags with commas in attribute values', () => {
@@ -197,10 +173,7 @@ describe('ManifestTextParser', () => {
197
173
 
198
174
  // playlist text:
199
175
  '#EXTM3U\n' +
200
- '#EXT-X-MEDIA:CODECS="avc1.64002a,mp4a.40.2"',
201
-
202
- // manifest URI:
203
- 'https://test/manifest.m3u8');
176
+ '#EXT-X-MEDIA:CODECS="avc1.64002a,mp4a.40.2"');
204
177
 
205
178
  verifyPlaylist(
206
179
  {
@@ -216,10 +189,7 @@ describe('ManifestTextParser', () => {
216
189
 
217
190
  // playlist text:
218
191
  '#EXTM3U\n' +
219
- '#EXT-X-MEDIA:CODECS="avc1.64002a,mp4a.40.2,avc2.64000"',
220
-
221
- // manifest URI:
222
- 'https://test/manifest.m3u8');
192
+ '#EXT-X-MEDIA:CODECS="avc1.64002a,mp4a.40.2,avc2.64000"');
223
193
 
224
194
  verifyPlaylist(
225
195
  {
@@ -236,10 +206,7 @@ describe('ManifestTextParser', () => {
236
206
 
237
207
  // playlist text:
238
208
  '#EXTM3U\n' +
239
- '#EXT-X-MEDIA:CODECS="avc1.64002a,mp4a.40.2",AUDIO="a1,a2"',
240
-
241
- // manifest URI:
242
- 'https://test/manifest.m3u8');
209
+ '#EXT-X-MEDIA:CODECS="avc1.64002a,mp4a.40.2",AUDIO="a1,a2"');
243
210
 
244
211
  verifyPlaylist(
245
212
  {
@@ -255,10 +222,7 @@ describe('ManifestTextParser', () => {
255
222
 
256
223
  // playlist text:
257
224
  '#EXTM3U\n' +
258
- '#EXT-X-MEDIA:CODECS="av01.0.08M.08,mp4a.40.2"',
259
-
260
- // manifest URI:
261
- 'https://test/manifest.m3u8');
225
+ '#EXT-X-MEDIA:CODECS="av01.0.08M.08,mp4a.40.2"');
262
226
  });
263
227
 
264
228
  it('rejects invalid tags', () => {
@@ -268,7 +232,7 @@ describe('ManifestTextParser', () => {
268
232
  shaka.util.Error.Code.INVALID_HLS_TAG,
269
233
  'invalid tag'));
270
234
  const text = shaka.util.StringUtils.toUTF8('#EXTM3U\ninvalid tag');
271
- expect(() => parser.parsePlaylist(text, /* uri= */ '')).toThrow(error);
235
+ expect(() => parser.parsePlaylist(text)).toThrow(error);
272
236
  });
273
237
  });
274
238
 
@@ -307,7 +271,7 @@ describe('ManifestTextParser', () => {
307
271
  new shaka.hls.Tag(/* id= */ 0, 'EXT-X-MEDIA-SEQUENCE', [], '1'),
308
272
  ],
309
273
  segments: [
310
- new shaka.hls.Segment('https://test/manifest.m3u8', 'https://test/test.mp4',
274
+ new shaka.hls.Segment('https://test/test.mp4',
311
275
  [
312
276
  new shaka.hls.Tag(/* id= */ 2, 'EXTINF', [], '5.99467'),
313
277
  ]),
@@ -318,10 +282,7 @@ describe('ManifestTextParser', () => {
318
282
  '#EXTM3U\n' +
319
283
  '#EXT-X-MEDIA-SEQUENCE:1\n' +
320
284
  '#EXTINF:5.99467\n' +
321
- 'https://test/test.mp4\n',
322
-
323
- // manifest URI:
324
- 'https://test/manifest.m3u8');
285
+ 'https://test/test.mp4\n');
325
286
  });
326
287
 
327
288
  it('handles tags with both value and attributes', () => {
@@ -332,7 +293,7 @@ describe('ManifestTextParser', () => {
332
293
  new shaka.hls.Tag(/* id= */ 0, 'EXT-X-MEDIA-SEQUENCE', [], '1'),
333
294
  ],
334
295
  segments: [
335
- new shaka.hls.Segment('https://test/manifest.m3u8', 'https://test/test.mp4', [
296
+ new shaka.hls.Segment('https://test/test.mp4', [
336
297
  new shaka.hls.Tag(
337
298
  /* id= */ 2,
338
299
  'EXTINF',
@@ -346,10 +307,7 @@ describe('ManifestTextParser', () => {
346
307
  '#EXTM3U\n' +
347
308
  '#EXT-X-MEDIA-SEQUENCE:1\n' +
348
309
  '#EXTINF:5.99467,pid=180\n' +
349
- 'https://test/test.mp4\n',
350
-
351
- // manifest URI:
352
- 'https://test/manifest.m3u8');
310
+ 'https://test/test.mp4\n');
353
311
  });
354
312
 
355
313
  it('handles manifests with a segment tag before a playlist tag', () => {
@@ -360,7 +318,7 @@ describe('ManifestTextParser', () => {
360
318
  new shaka.hls.Tag(/* id= */ 2, 'EXT-X-TARGETDURATION', [], '6'),
361
319
  ],
362
320
  segments: [
363
- new shaka.hls.Segment('https://test/manifest.m3u8', 'https://test/test.mp4',
321
+ new shaka.hls.Segment('https://test/test.mp4',
364
322
  [
365
323
  new shaka.hls.Tag(/* id= */ 1, 'EXT-X-KEY',
366
324
  [
@@ -378,22 +336,18 @@ describe('ManifestTextParser', () => {
378
336
  '#EXT-X-KEY:METHOD="AES-128",URI="http://key.com",IV="123"\n' +
379
337
  '#EXT-X-TARGETDURATION:6\n' +
380
338
  '#EXTINF:5.99467\n' +
381
- 'https://test/test.mp4\n',
382
-
383
- // manifest URI:
384
- 'https://test/manifest.m3u8');
339
+ 'https://test/test.mp4\n');
385
340
  });
386
341
 
387
342
  it('tracks playlist URI', () => {
388
343
  verifyPlaylist(
389
344
  {
390
- absoluteUri: 'https://test/manifest.m3u8',
391
345
  type: shaka.hls.PlaylistType.MEDIA,
392
346
  tags: [
393
347
  new shaka.hls.Tag(/* id= */ 0, 'EXT-X-MEDIA-SEQUENCE', [], '1'),
394
348
  ],
395
349
  segments: [
396
- new shaka.hls.Segment('https://test/manifest.m3u8', 'test.mp4',
350
+ new shaka.hls.Segment('test.mp4',
397
351
  [
398
352
  new shaka.hls.Tag(/* id= */ 2, 'EXTINF', [], '5.99467'),
399
353
  ]),
@@ -404,10 +358,7 @@ describe('ManifestTextParser', () => {
404
358
  '#EXTM3U\n' +
405
359
  '#EXT-X-MEDIA-SEQUENCE:1\n' +
406
360
  '#EXTINF:5.99467\n' +
407
- 'test.mp4\n',
408
-
409
- // manifest URI:
410
- 'https://test/manifest.m3u8');
361
+ 'test.mp4\n');
411
362
  });
412
363
  });
413
364
 
@@ -427,17 +378,14 @@ describe('ManifestTextParser', () => {
427
378
  new shaka.hls.Tag(/* id= */ 0, 'EXT-X-TARGETDURATION', [], '6'),
428
379
  ],
429
380
  segments: [
430
- new shaka.hls.Segment('https://test/manifest.m3u8', 'uri',
381
+ new shaka.hls.Segment('uri',
431
382
  [new shaka.hls.Tag(2, 'EXTINF', [], '5')]),
432
- new shaka.hls.Segment('https://test/manifest.m3u8', 'uri2',
383
+ new shaka.hls.Segment('uri2',
433
384
  [new shaka.hls.Tag(3, 'EXTINF', [], '4')]),
434
385
  ],
435
386
  },
436
387
 
437
- manifestText,
438
-
439
- // manifest URI:
440
- 'https://test/manifest.m3u8');
388
+ manifestText);
441
389
  });
442
390
 
443
391
  it('identifies playlist tags', () => {
@@ -449,19 +397,16 @@ describe('ManifestTextParser', () => {
449
397
  new shaka.hls.Tag(/* id= */ 4, 'EXT-X-ENDLIST', []),
450
398
  ],
451
399
  segments: [
452
- new shaka.hls.Segment('https://test/manifest.m3u8', 'uri',
400
+ new shaka.hls.Segment('uri',
453
401
  [new shaka.hls.Tag(2, 'EXTINF', [], '5')]),
454
- new shaka.hls.Segment('https://test/manifest.m3u8', 'uri2',
402
+ new shaka.hls.Segment('uri2',
455
403
  [new shaka.hls.Tag(3, 'EXTINF', [], '4')]),
456
404
  ],
457
405
  },
458
406
 
459
407
  // Append a playlist tag to the manifest text so it appears after
460
408
  // segment-related tags.
461
- manifestText + '#EXT-X-ENDLIST',
462
-
463
- // manifest URI:
464
- 'https://test/manifest.m3u8');
409
+ manifestText + '#EXT-X-ENDLIST');
465
410
  });
466
411
 
467
412
  it('parses segments with partial segments', () => {
@@ -508,14 +453,12 @@ describe('ManifestTextParser', () => {
508
453
  ],
509
454
  segments: [
510
455
  new shaka.hls.Segment(
511
- /* absoluteMediaPlaylistUri= */ 'https://test/manifest.m3u8',
512
456
  /* verbatimSegmentUri= */ 'uri',
513
457
  /* tags= */ [
514
458
  new shaka.hls.Tag(3, 'EXTINF', [], '5'),
515
459
  mapTag,
516
460
  ]),
517
461
  new shaka.hls.Segment(
518
- /* absoluteMediaPlaylistUri= */ 'https://test/manifest.m3u8',
519
462
  /* verbatimSegmentUri= */ 'uri2',
520
463
  /* tags= */ [
521
464
  new shaka.hls.Tag(6, 'EXTINF', [], '2'),
@@ -523,15 +466,12 @@ describe('ManifestTextParser', () => {
523
466
  ],
524
467
  /* partialSegments= */ partialSegments1),
525
468
  new shaka.hls.Segment(
526
- /* absoluteMediaPlaylistUri= */ '',
527
469
  /* verbatimSegmentUri= */ '',
528
470
  /* tags= */ [mapTag],
529
471
  /* partialSegments= */ partialSegments2),
530
472
  ],
531
473
  },
532
- manifestTextWithPartialSegments,
533
- // manifest URI:
534
- 'https://test/manifest.m3u8');
474
+ manifestTextWithPartialSegments);
535
475
  });
536
476
 
537
477
  it('parses segments with preload hint segments', () => {
@@ -577,22 +517,18 @@ describe('ManifestTextParser', () => {
577
517
  ],
578
518
  segments: [
579
519
  new shaka.hls.Segment(
580
- /* absoluteMediaPlaylistUri= */ 'https://test/manifest.m3u8',
581
520
  /* verbatimSegmentUri= */ 'uri',
582
521
  /* tags= */ [
583
522
  new shaka.hls.Tag(3, 'EXTINF', [], '5'),
584
523
  mapTag,
585
524
  ]),
586
525
  new shaka.hls.Segment(
587
- /* absoluteMediaPlaylistUri= */ '',
588
526
  /* verbatimSegmentUri= */ '',
589
527
  /* tags= */ [preloadMapTag],
590
528
  /* partialSegments= */ preloadSegment),
591
529
  ],
592
530
  },
593
- manifestTextWithPreloadSegments,
594
- // manifest URI:
595
- 'https://test/manifest.m3u8');
531
+ manifestTextWithPreloadSegments);
596
532
  });
597
533
  });
598
534
 
@@ -600,13 +536,10 @@ describe('ManifestTextParser', () => {
600
536
  /**
601
537
  * @param {!Object} expectedPlaylist
602
538
  * @param {string} playlistText
603
- * @param {string} absoluteManifestUri
604
539
  */
605
- function verifyPlaylist(expectedPlaylist, playlistText, absoluteManifestUri) {
540
+ function verifyPlaylist(expectedPlaylist, playlistText) {
606
541
  const playlistBuffer = shaka.util.StringUtils.toUTF8(playlistText);
607
- const actualPlaylist =
608
- parser.parsePlaylist(playlistBuffer, absoluteManifestUri);
609
-
542
+ const actualPlaylist = parser.parsePlaylist(playlistBuffer);
610
543
  expect(actualPlaylist).toEqual(jasmine.objectContaining(expectedPlaylist));
611
544
  }
612
545
  });
@@ -19,7 +19,12 @@ describe('AdaptationSetCriteria', () => {
19
19
  });
20
20
  });
21
21
 
22
- const builder = new shaka.media.PreferenceBasedCriteria('en', '', 0, '');
22
+ const builder = new shaka.media.PreferenceBasedCriteria(
23
+ /* language= */ 'en',
24
+ /* role= */ '',
25
+ /* channelCount= */ 0,
26
+ /* hdrLevel= */ '',
27
+ /* videoLayout= */ '');
23
28
  const set = builder.create(manifest.variants);
24
29
 
25
30
  checkSet(set, [
@@ -40,7 +45,12 @@ describe('AdaptationSetCriteria', () => {
40
45
  });
41
46
  });
42
47
 
43
- const builder = new shaka.media.PreferenceBasedCriteria('en', '', 0, '');
48
+ const builder = new shaka.media.PreferenceBasedCriteria(
49
+ /* language= */ 'en',
50
+ /* role= */ '',
51
+ /* channelCount= */ 0,
52
+ /* hdrLevel= */ '',
53
+ /* videoLayout= */ '');
44
54
  const set = builder.create(manifest.variants);
45
55
 
46
56
  checkSet(set, [
@@ -86,8 +96,14 @@ describe('AdaptationSetCriteria', () => {
86
96
  return true;
87
97
  };
88
98
 
89
- const builder = new shaka.media.PreferenceBasedCriteria('en', '', 0, '',
90
- undefined, shaka.config.CodecSwitchingStrategy.SMOOTH);
99
+ const builder = new shaka.media.PreferenceBasedCriteria(
100
+ /* language= */ 'en',
101
+ /* role= */ '',
102
+ /* channelCount= */ 0,
103
+ /* hdrLevel= */ '',
104
+ /* videoLayout= */ '',
105
+ /* label= */ '',
106
+ shaka.config.CodecSwitchingStrategy.SMOOTH);
91
107
  const set = builder.create(manifest.variants);
92
108
 
93
109
  expect(Array.from(set.values()).length).toBe(3);
@@ -126,8 +142,14 @@ describe('AdaptationSetCriteria', () => {
126
142
  });
127
143
  });
128
144
 
129
- const builder = new shaka.media.PreferenceBasedCriteria('en', '', 0, '',
130
- undefined, shaka.config.CodecSwitchingStrategy.RELOAD);
145
+ const builder = new shaka.media.PreferenceBasedCriteria(
146
+ /* language= */ 'en',
147
+ /* role= */ '',
148
+ /* channelCount= */ 0,
149
+ /* hdrLevel= */ '',
150
+ /* videoLayout= */ '',
151
+ /* label= */ '',
152
+ shaka.config.CodecSwitchingStrategy.RELOAD);
131
153
  const set = builder.create(manifest.variants);
132
154
 
133
155
  expect(Array.from(set.values()).length).toBe(1);
@@ -156,7 +178,11 @@ describe('AdaptationSetCriteria', () => {
156
178
  });
157
179
 
158
180
  const builder = new shaka.media.PreferenceBasedCriteria(
159
- 'en', 'main', 0, '');
181
+ /* language= */ 'en',
182
+ /* role= */ 'main',
183
+ /* channelCount= */ 0,
184
+ /* hdrLevel= */ '',
185
+ /* videoLayout= */ '');
160
186
  const set = builder.create(manifest.variants);
161
187
 
162
188
  checkSet(set, [
@@ -205,7 +231,12 @@ describe('AdaptationSetCriteria', () => {
205
231
  });
206
232
  });
207
233
 
208
- const builder = new shaka.media.PreferenceBasedCriteria('en', '', 0, '');
234
+ const builder = new shaka.media.PreferenceBasedCriteria(
235
+ /* language= */ 'en',
236
+ /* role= */ '',
237
+ /* channelCount= */ 0,
238
+ /* hdrLevel= */ '',
239
+ /* videoLayout= */ '');
209
240
  const set = builder.create(manifest.variants);
210
241
 
211
242
  // Which role is chosen is an implementation detail.
@@ -263,7 +294,12 @@ describe('AdaptationSetCriteria', () => {
263
294
  });
264
295
  });
265
296
 
266
- const builder = new shaka.media.PreferenceBasedCriteria('zh', '', 0, '');
297
+ const builder = new shaka.media.PreferenceBasedCriteria(
298
+ /* language= */ 'zh',
299
+ /* role= */ '',
300
+ /* channelCount= */ 0,
301
+ /* hdrLevel= */ '',
302
+ /* videoLayout= */ '');
267
303
  const set = builder.create(manifest.variants);
268
304
 
269
305
  // Which role is chosen is an implementation detail.
@@ -299,7 +335,12 @@ describe('AdaptationSetCriteria', () => {
299
335
  });
300
336
  });
301
337
 
302
- const builder = new shaka.media.PreferenceBasedCriteria('zh', '', 0, '');
338
+ const builder = new shaka.media.PreferenceBasedCriteria(
339
+ /* language= */ 'zh',
340
+ /* role= */ '',
341
+ /* channelCount= */ 0,
342
+ /* hdrLevel= */ '',
343
+ /* videoLayout= */ '');
303
344
  const set = builder.create(manifest.variants);
304
345
 
305
346
  // Which language is chosen is an implementation detail.
@@ -356,7 +397,11 @@ describe('AdaptationSetCriteria', () => {
356
397
  });
357
398
 
358
399
  const builder = new shaka.media.PreferenceBasedCriteria(
359
- 'zh', '', 0, '');
400
+ /* language= */ 'zh',
401
+ /* role= */ '',
402
+ /* channelCount= */ 0,
403
+ /* hdrLevel= */ '',
404
+ /* videoLayout= */ '');
360
405
  const set = builder.create(manifest.variants);
361
406
 
362
407
  // Which role is chosen is an implementation detail. Each role is
@@ -414,7 +459,11 @@ describe('AdaptationSetCriteria', () => {
414
459
  });
415
460
 
416
461
  const builder = new shaka.media.PreferenceBasedCriteria(
417
- 'zh', '', 0, '');
462
+ /* language= */ 'zh',
463
+ /* role= */ '',
464
+ /* channelCount= */ 0,
465
+ /* hdrLevel= */ '',
466
+ /* videoLayout= */ '');
418
467
  const set = builder.create(manifest.variants);
419
468
 
420
469
  checkSet(set, [
@@ -442,7 +491,45 @@ describe('AdaptationSetCriteria', () => {
442
491
  });
443
492
  });
444
493
 
445
- const builder = new shaka.media.PreferenceBasedCriteria('', '', 0, 'PQ');
494
+ const builder = new shaka.media.PreferenceBasedCriteria(
495
+ /* language= */ '',
496
+ /* role= */ '',
497
+ /* channelCount= */ 0,
498
+ /* hdrLevel= */ 'PQ',
499
+ /* videoLayout= */ '');
500
+ const set = builder.create(manifest.variants);
501
+
502
+ checkSet(set, [
503
+ manifest.variants[0],
504
+ manifest.variants[2],
505
+ ]);
506
+ });
507
+
508
+ it('chooses variants with preferred video layout (CH-STEREO)', () => {
509
+ const manifest = shaka.test.ManifestGenerator.generate((manifest) => {
510
+ manifest.addVariant(1, (variant) => {
511
+ variant.addVideo(10, (stream) => {
512
+ stream.videoLayout = 'CH-STEREO';
513
+ });
514
+ });
515
+ manifest.addVariant(2, (variant) => {
516
+ variant.addVideo(20, (stream) => {
517
+ stream.videoLayout = 'CH-MONO';
518
+ });
519
+ });
520
+ manifest.addVariant(3, (variant) => {
521
+ variant.addVideo(30, (stream) => {
522
+ stream.videoLayout = '';
523
+ });
524
+ });
525
+ });
526
+
527
+ const builder = new shaka.media.PreferenceBasedCriteria(
528
+ /* language= */ '',
529
+ /* role= */ '',
530
+ /* channelCount= */ 0,
531
+ /* hdrLevel= */ '',
532
+ /* videoLayout= */ 'CH-STEREO');
446
533
  const set = builder.create(manifest.variants);
447
534
 
448
535
  checkSet(set, [
@@ -451,6 +538,38 @@ describe('AdaptationSetCriteria', () => {
451
538
  ]);
452
539
  });
453
540
 
541
+ it('chooses variants with preferred video layout (CH-MONO)', () => {
542
+ const manifest = shaka.test.ManifestGenerator.generate((manifest) => {
543
+ manifest.addVariant(1, (variant) => {
544
+ variant.addVideo(10, (stream) => {
545
+ stream.videoLayout = 'CH-STEREO';
546
+ });
547
+ });
548
+ manifest.addVariant(2, (variant) => {
549
+ variant.addVideo(20, (stream) => {
550
+ stream.videoLayout = 'CH-MONO';
551
+ });
552
+ });
553
+ manifest.addVariant(3, (variant) => {
554
+ variant.addVideo(30, (stream) => {
555
+ stream.videoLayout = 'CH-STEREO';
556
+ });
557
+ });
558
+ });
559
+
560
+ const builder = new shaka.media.PreferenceBasedCriteria(
561
+ /* language= */ '',
562
+ /* role= */ '',
563
+ /* channelCount= */ 0,
564
+ /* hdrLevel= */ '',
565
+ /* videoLayout= */ 'CH-MONO');
566
+ const set = builder.create(manifest.variants);
567
+
568
+ checkSet(set, [
569
+ manifest.variants[1],
570
+ ]);
571
+ });
572
+
454
573
  it('chooses variants with preferred audio channels count', () => {
455
574
  const manifest = shaka.test.ManifestGenerator.generate((manifest) => {
456
575
  manifest.addVariant(1, (variant) => {
@@ -470,7 +589,12 @@ describe('AdaptationSetCriteria', () => {
470
589
  });
471
590
  });
472
591
 
473
- const builder = new shaka.media.PreferenceBasedCriteria('', '', 2, '');
592
+ const builder = new shaka.media.PreferenceBasedCriteria(
593
+ /* language= */ '',
594
+ /* role= */ '',
595
+ /* channelCount= */ 2,
596
+ /* hdrLevel= */ '',
597
+ /* videoLayout= */ '');
474
598
  const set = builder.create(manifest.variants);
475
599
 
476
600
  checkSet(set, [
@@ -499,8 +623,12 @@ describe('AdaptationSetCriteria', () => {
499
623
  });
500
624
  });
501
625
 
502
- const builder =
503
- new shaka.media.PreferenceBasedCriteria('', '', 6, '');
626
+ const builder = new shaka.media.PreferenceBasedCriteria(
627
+ /* language= */ '',
628
+ /* role= */ '',
629
+ /* channelCount= */ 6,
630
+ /* hdrLevel= */ '',
631
+ /* videoLayout= */ '');
504
632
  const set = builder.create(manifest.variants);
505
633
 
506
634
  checkSet(set, [
@@ -529,7 +657,12 @@ describe('AdaptationSetCriteria', () => {
529
657
  });
530
658
  });
531
659
 
532
- const builder = new shaka.media.PreferenceBasedCriteria('', '', 2, '');
660
+ const builder = new shaka.media.PreferenceBasedCriteria(
661
+ /* language= */ '',
662
+ /* role= */ '',
663
+ /* channelCount= */ 2,
664
+ /* hdrLevel= */ '',
665
+ /* videoLayout= */ '');
533
666
  const set = builder.create(manifest.variants);
534
667
 
535
668
  checkSet(set, [
@@ -558,7 +691,12 @@ describe('AdaptationSetCriteria', () => {
558
691
  });
559
692
 
560
693
  const builder = new shaka.media.PreferenceBasedCriteria(
561
- '', '', 0, '', 'preferredLabel');
694
+ /* language= */ '',
695
+ /* role= */ '',
696
+ /* channelCount= */ 0,
697
+ /* hdrLevel= */ '',
698
+ /* videoLayout= */ '',
699
+ /* label= */ 'preferredLabel');
562
700
  const set = builder.create(manifest.variants);
563
701
 
564
702
  checkSet(set, [
@@ -600,7 +738,12 @@ describe('AdaptationSetCriteria', () => {
600
738
  });
601
739
 
602
740
  const builder = new shaka.media.PreferenceBasedCriteria(
603
- 'zh', '', 0, '', 'preferredLabel');
741
+ /* language= */ 'zh',
742
+ /* role= */ '',
743
+ /* channelCount= */ 0,
744
+ /* hdrLevel= */ '',
745
+ /* videoLayout= */ '',
746
+ /* label= */ 'preferredLabel');
604
747
  const set = builder.create(manifest.variants);
605
748
 
606
749
  checkSet(set, [
@@ -609,7 +752,7 @@ describe('AdaptationSetCriteria', () => {
609
752
  ]);
610
753
  });
611
754
 
612
- it('filters by audio group if present', () => {
755
+ it('filters by audio group if enabled', () => {
613
756
  const manifest = shaka.test.ManifestGenerator.generate((manifest) => {
614
757
  manifest.addVariant(1, (variant) => {
615
758
  variant.language = 'en';
@@ -634,7 +777,15 @@ describe('AdaptationSetCriteria', () => {
634
777
  });
635
778
  });
636
779
 
637
- const builder = new shaka.media.PreferenceBasedCriteria('en', '', 0, '');
780
+ const builder = new shaka.media.PreferenceBasedCriteria(
781
+ /* language= */ 'en',
782
+ /* role= */ '',
783
+ /* channelCount= */ 0,
784
+ /* hdrLevel= */ '',
785
+ /* videoLayout= */ '',
786
+ /* label= */ '',
787
+ shaka.config.CodecSwitchingStrategy.RELOAD,
788
+ /* enableAudioGroups= */ true);
638
789
  const set = builder.create(manifest.variants);
639
790
 
640
791
  checkSet(set, [
@@ -222,6 +222,7 @@ describe('AdaptationSet', () => {
222
222
  accessibilityPurpose: null,
223
223
  external: false,
224
224
  groupId: null,
225
+ fastSwitching: false,
225
226
  };
226
227
  }
227
228
  });