shaka-player 4.4.3 → 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 (307) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  2. package/.github/workflows/release-please.yaml +2 -27
  3. package/AUTHORS +2 -0
  4. package/CHANGELOG.md +156 -39
  5. package/CODE_OF_CONDUCT.md +1 -1
  6. package/CONTRIBUTORS +2 -0
  7. package/README.md +54 -42
  8. package/demo/asset_card.js +18 -21
  9. package/demo/cast_receiver/index.html +0 -1
  10. package/demo/close_button.js +0 -3
  11. package/demo/common/asset.js +33 -22
  12. package/demo/common/assets.js +249 -60
  13. package/demo/config.js +219 -253
  14. package/demo/custom.js +88 -133
  15. package/demo/front.js +7 -10
  16. package/demo/index.html +19 -22
  17. package/demo/input.js +6 -11
  18. package/demo/input_container.js +8 -9
  19. package/demo/main.js +62 -126
  20. package/demo/search.js +29 -34
  21. package/demo/service_worker.js +0 -3
  22. package/demo/tooltip.js +3 -5
  23. package/demo/visualizer.js +3 -5
  24. package/demo/visualizer_button.js +1 -20
  25. package/dist/controls.css +1 -1
  26. package/dist/controls.css.map +1 -1
  27. package/dist/demo.compiled.debug.js +211 -228
  28. package/dist/demo.compiled.debug.map +4 -4
  29. package/dist/demo.compiled.js +211 -228
  30. package/dist/demo.compiled.map +4 -4
  31. package/dist/deps.js +42 -37
  32. package/dist/locales.js +34 -30
  33. package/dist/receiver.compiled.debug.js +64 -77
  34. package/dist/receiver.compiled.debug.map +4 -4
  35. package/dist/receiver.compiled.js +64 -77
  36. package/dist/receiver.compiled.map +4 -4
  37. package/dist/shaka-player.compiled.d.ts +343 -151
  38. package/dist/shaka-player.compiled.debug.d.ts +343 -151
  39. package/dist/shaka-player.compiled.debug.externs.js +356 -117
  40. package/dist/shaka-player.compiled.debug.js +952 -811
  41. package/dist/shaka-player.compiled.debug.map +4 -4
  42. package/dist/shaka-player.compiled.externs.js +356 -117
  43. package/dist/shaka-player.compiled.js +1165 -1078
  44. package/dist/shaka-player.compiled.map +4 -4
  45. package/dist/shaka-player.ui.d.ts +359 -153
  46. package/dist/shaka-player.ui.debug.d.ts +359 -153
  47. package/dist/shaka-player.ui.debug.externs.js +382 -117
  48. package/dist/shaka-player.ui.debug.js +1084 -918
  49. package/dist/shaka-player.ui.debug.map +4 -4
  50. package/dist/shaka-player.ui.externs.js +382 -117
  51. package/dist/shaka-player.ui.js +1377 -1274
  52. package/dist/shaka-player.ui.map +4 -4
  53. package/docs/design/lcevc-integration.md +14 -14
  54. package/docs/tutorials/ad_monetization.md +54 -0
  55. package/docs/tutorials/basic-usage.md +2 -1
  56. package/docs/tutorials/errors.md +2 -1
  57. package/docs/tutorials/faq.md +27 -55
  58. package/docs/tutorials/index.json +2 -1
  59. package/docs/tutorials/lcevc.md +118 -0
  60. package/docs/tutorials/offline.md +10 -8
  61. package/docs/tutorials/plugins.md +5 -0
  62. package/docs/tutorials/ui-customization.md +17 -0
  63. package/docs/tutorials/ui.md +2 -1
  64. package/docs/tutorials/upgrade.md +3 -0
  65. package/externs/css_style_declaration.js +19 -0
  66. package/externs/lcevc.js +37 -13
  67. package/externs/managedmediasource.js +24 -0
  68. package/externs/media_remote.js +68 -0
  69. package/externs/mediatailor.js +193 -0
  70. package/externs/pictureinpicture.js +11 -0
  71. package/externs/shaka/abr_manager.js +6 -2
  72. package/externs/shaka/ads.js +27 -0
  73. package/externs/shaka/cea.js +7 -0
  74. package/externs/shaka/codecs.js +5 -3
  75. package/externs/shaka/manifest.js +31 -10
  76. package/externs/shaka/manifest_parser.js +24 -1
  77. package/externs/shaka/net.js +2 -2
  78. package/externs/shaka/offline.js +13 -2
  79. package/externs/shaka/player.js +65 -8
  80. package/externs/shaka/text.js +3 -1
  81. package/externs/shaka/transmuxer.js +1 -1
  82. package/karma.conf.js +7 -3
  83. package/lib/abr/simple_abr_manager.js +66 -9
  84. package/lib/ads/ad_manager.js +104 -50
  85. package/lib/ads/media_tailor_ad.js +297 -0
  86. package/lib/ads/media_tailor_ad_manager.js +839 -0
  87. package/lib/cast/cast_receiver.js +1 -1
  88. package/lib/cea/cea_decoder.js +28 -0
  89. package/lib/cea/dummy_caption_decoder.js +5 -0
  90. package/lib/cea/ts_cea_parser.js +15 -2
  91. package/lib/config/codec_switching_strategy.js +24 -0
  92. package/lib/dash/content_protection.js +120 -2
  93. package/lib/dash/dash_parser.js +322 -93
  94. package/lib/dash/mpd_utils.js +62 -37
  95. package/lib/dash/segment_base.js +17 -10
  96. package/lib/dash/segment_list.js +18 -9
  97. package/lib/dash/segment_template.js +122 -107
  98. package/lib/dependencies/all.js +8 -7
  99. package/lib/hls/hls_classes.js +28 -43
  100. package/lib/hls/hls_parser.js +798 -658
  101. package/lib/hls/hls_utils.js +64 -5
  102. package/lib/hls/manifest_text_parser.js +7 -11
  103. package/lib/lcevc/lcevc_dec.js +220 -0
  104. package/lib/media/adaptation_set.js +32 -14
  105. package/lib/media/adaptation_set_criteria.js +86 -16
  106. package/lib/media/closed_caption_parser.js +13 -0
  107. package/lib/media/content_workarounds.js +6 -0
  108. package/lib/media/drm_engine.js +8 -13
  109. package/lib/media/manifest_parser.js +8 -113
  110. package/lib/media/media_source_capabilities.js +10 -3
  111. package/lib/media/media_source_engine.js +286 -44
  112. package/lib/media/play_rate_controller.js +8 -38
  113. package/lib/media/presentation_timeline.js +7 -1
  114. package/lib/media/quality_observer.js +1 -1
  115. package/lib/media/segment_index.js +6 -6
  116. package/lib/media/segment_prefetch.js +92 -24
  117. package/lib/media/segment_reference.js +73 -7
  118. package/lib/media/segment_utils.js +343 -0
  119. package/lib/media/stall_detector.js +0 -3
  120. package/lib/media/streaming_engine.js +73 -38
  121. package/lib/mss/mss_parser.js +19 -2
  122. package/lib/net/networking_engine.js +67 -12
  123. package/lib/net/networking_utils.js +95 -0
  124. package/lib/offline/indexeddb/v1_storage_cell.js +3 -0
  125. package/lib/offline/indexeddb/v2_storage_cell.js +3 -0
  126. package/lib/offline/manifest_converter.js +3 -0
  127. package/lib/offline/offline_manifest_parser.js +10 -0
  128. package/lib/offline/storage.js +14 -7
  129. package/lib/player.js +1098 -1537
  130. package/lib/polyfill/mediasource.js +22 -1
  131. package/lib/text/cue.js +15 -0
  132. package/lib/text/mp4_ttml_parser.js +2 -2
  133. package/lib/text/srt_text_parser.js +2 -2
  134. package/lib/text/stub_text_displayer.js +51 -0
  135. package/lib/text/text_engine.js +3 -2
  136. package/lib/text/ttml_text_parser.js +45 -5
  137. package/lib/text/ui_text_displayer.js +8 -0
  138. package/lib/text/vtt_text_parser.js +40 -22
  139. package/lib/transmuxer/aac_transmuxer.js +1 -1
  140. package/lib/transmuxer/ac3_transmuxer.js +1 -1
  141. package/lib/transmuxer/ec3_transmuxer.js +1 -1
  142. package/lib/transmuxer/h264.js +5 -4
  143. package/lib/transmuxer/h265.js +863 -0
  144. package/lib/transmuxer/mp3_transmuxer.js +1 -1
  145. package/lib/transmuxer/mpeg_ts_transmuxer.js +4 -3
  146. package/lib/transmuxer/mss_transmuxer.js +1 -1
  147. package/lib/transmuxer/ts_transmuxer.js +187 -22
  148. package/lib/util/buffer_utils.js +26 -4
  149. package/lib/util/content_steering_manager.js +358 -0
  150. package/lib/util/error.js +30 -15
  151. package/lib/util/exp_golomb.js +30 -2
  152. package/lib/util/fairplay_utils.js +1 -1
  153. package/lib/util/fake_event.js +8 -1
  154. package/lib/util/id3_utils.js +50 -1
  155. package/lib/util/manifest_parser_utils.js +12 -8
  156. package/lib/util/mp4_generator.js +6 -8
  157. package/lib/util/mutex.js +59 -0
  158. package/lib/util/object_utils.js +1 -1
  159. package/lib/util/periods.js +156 -179
  160. package/lib/util/platform.js +44 -3
  161. package/lib/util/player_configuration.js +43 -6
  162. package/lib/util/state_history.js +6 -2
  163. package/lib/util/stream_utils.js +206 -283
  164. package/lib/util/ts_parser.js +335 -98
  165. package/lib/util/uint8array_utils.js +5 -1
  166. package/lib/util/xml_utils.js +5 -0
  167. package/maintained-branches.md +3 -2
  168. package/package.json +4 -6
  169. package/roadmap.md +25 -5
  170. package/shaka-player.uncompiled.js +2 -2
  171. package/support.html +0 -1
  172. package/test/abr/simple_abr_manager_unit.js +33 -33
  173. package/test/ads/ad_manager_unit.js +3 -2
  174. package/test/cast/cast_receiver_integration.js +50 -4
  175. package/test/cast/cast_utils_unit.js +2 -0
  176. package/test/cea/cea_decoder_unit.js +7 -0
  177. package/test/codec_switching/codec_switching_integration.js +182 -0
  178. package/test/dash/dash_parser_content_protection_unit.js +2 -0
  179. package/test/dash/dash_parser_integration.js +74 -0
  180. package/test/dash/dash_parser_live_unit.js +2 -19
  181. package/test/dash/dash_parser_manifest_unit.js +536 -2
  182. package/test/dash/dash_parser_segment_base_unit.js +2 -0
  183. package/test/dash/dash_parser_segment_list_unit.js +2 -0
  184. package/test/dash/dash_parser_segment_template_unit.js +2 -0
  185. package/test/dash/mpd_utils_unit.js +61 -30
  186. package/test/demo/demo_unit.js +0 -16
  187. package/test/hls/hls_live_unit.js +14 -3
  188. package/test/hls/hls_parser_unit.js +385 -33
  189. package/test/hls/manifest_text_parser_unit.js +32 -99
  190. package/test/media/adaptation_set_criteria_unit.js +284 -15
  191. package/test/media/adaptation_set_unit.js +2 -0
  192. package/test/media/content_workarounds_unit.js +1 -1
  193. package/test/media/drm_engine_unit.js +3 -3
  194. package/test/media/media_source_engine_unit.js +166 -2
  195. package/test/media/play_rate_controller_unit.js +0 -48
  196. package/test/media/segment_index_unit.js +5 -4
  197. package/test/media/segment_prefetch_unit.js +1 -1
  198. package/test/media/streaming_engine_unit.js +17 -17
  199. package/test/mss/mss_parser_unit.js +2 -0
  200. package/test/mss/mss_player_integration.js +3 -2
  201. package/test/net/networking_engine_unit.js +3 -3
  202. package/test/{media/manifest_parser_unit.js → net/networking_utils_unit.js} +2 -2
  203. package/test/offline/manifest_convert_unit.js +14 -0
  204. package/test/offline/offline_integration.js +2 -1
  205. package/test/offline/storage_integration.js +22 -13
  206. package/test/player_external.js +4 -2
  207. package/test/player_integration.js +15 -4
  208. package/test/player_load_graph_integration.js +47 -151
  209. package/test/player_src_equals_external.js +1 -0
  210. package/test/player_src_equals_integration.js +71 -4
  211. package/test/player_unit.js +182 -158
  212. package/test/test/assets/dash-aes-128/Fragments(video=0,format=mpd-time-csf) +0 -0
  213. package/test/test/assets/dash-aes-128/Fragments(video=20000000,format=mpd-time-csf) +0 -0
  214. package/test/test/assets/dash-aes-128/Fragments(video=40000000,format=mpd-time-csf) +0 -0
  215. package/test/test/assets/dash-aes-128/Fragments(video=60000000,format=mpd-time-csf) +0 -0
  216. package/test/test/assets/dash-aes-128/Fragments(video=i,format=mpd-time-csf) +0 -0
  217. package/test/test/assets/dash-aes-128/dash.mpd +18 -0
  218. package/test/test/assets/dash-aes-128/license +1 -0
  219. package/test/test/assets/dash-multi-codec/audio_en_2c_128k_aac.mp4 +0 -0
  220. package/test/test/assets/dash-multi-codec/audio_es_2c_64k_opus.webm +0 -0
  221. package/test/test/assets/dash-multi-codec/dash.mpd +32 -0
  222. package/test/test/assets/dash-multi-codec/video_144p_108k_h264.mp4 +0 -0
  223. package/test/test/assets/hls-ts-h265/0.ts +0 -0
  224. package/test/test/assets/hls-ts-h265/hevc.m3u8 +6 -0
  225. package/test/test/assets/hls-ts-h265/index.m3u8 +7 -0
  226. package/test/test/assets/hls-ts-muxed-aac-h265/0.ts +0 -0
  227. package/test/test/assets/hls-ts-muxed-aac-h265/1.ts +0 -0
  228. package/test/test/assets/hls-ts-muxed-aac-h265/media.m3u8 +9 -0
  229. package/test/test/assets/hls-ts-muxed-ac3-h264/media.m3u8 +24 -0
  230. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00000.ts +0 -0
  231. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00001.ts +0 -0
  232. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00002.ts +0 -0
  233. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00003.ts +0 -0
  234. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00004.ts +0 -0
  235. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00005.ts +0 -0
  236. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0000.ts +0 -0
  237. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0001.ts +0 -0
  238. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0002.ts +0 -0
  239. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0003.ts +0 -0
  240. package/test/test/assets/hls-ts-muxed-ec3-h264/prog_index.m3u8 +14 -0
  241. package/test/test/assets/hls-ts-muxed-mp3-h264/index.m3u8 +23 -0
  242. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-1-v1-a1.ts +0 -0
  243. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-2-v1-a1.ts +0 -0
  244. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-3-v1-a1.ts +0 -0
  245. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-4-v1-a1.ts +0 -0
  246. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-5-v1-a1.ts +0 -0
  247. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-6-v1-a1.ts +0 -0
  248. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-7-v1-a1.ts +0 -0
  249. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-8-v1-a1.ts +0 -0
  250. package/test/test/util/dash_parser_util.js +4 -0
  251. package/test/test/util/fake_ad_manager.js +20 -0
  252. package/test/test/util/fake_media_source_engine.js +13 -2
  253. package/test/test/util/fake_networking_engine.js +9 -1
  254. package/test/test/util/fake_segment_prefetch.js +3 -0
  255. package/test/test/util/manifest_generator.js +11 -3
  256. package/test/test/util/manifest_parser_util.js +14 -2
  257. package/test/test/util/mss_parser_util.js +4 -0
  258. package/test/test/util/offline_utils.js +2 -0
  259. package/test/test/util/simple_fakes.js +2 -2
  260. package/test/test/util/streaming_engine_util.js +10 -4
  261. package/test/test/util/test_scheme.js +6 -0
  262. package/test/test/util/ui_utils.js +4 -3
  263. package/test/text/mp4_ttml_parser_unit.js +4 -4
  264. package/test/text/srt_text_parser_unit.js +1 -1
  265. package/test/text/text_displayer_layout_unit.js +1 -1
  266. package/test/text/text_engine_unit.js +6 -0
  267. package/test/text/ttml_text_parser_unit.js +85 -2
  268. package/test/text/vtt_text_parser_unit.js +103 -31
  269. package/test/transmuxer/transmuxer_engine_integration.js +9 -0
  270. package/test/transmuxer/transmuxer_integration.js +150 -3
  271. package/test/ui/ad_ui_unit.js +2 -2
  272. package/test/ui/ui_customization_unit.js +17 -16
  273. package/test/ui/ui_integration.js +30 -20
  274. package/test/ui/ui_unit.js +28 -29
  275. package/test/util/buffer_utils_unit.js +1 -1
  276. package/test/util/content_steering_manager_unit.js +427 -0
  277. package/test/util/id3_utils_unit.js +52 -0
  278. package/test/util/stream_utils_unit.js +207 -169
  279. package/test/util/ts_parser_unit.js +3 -3
  280. package/third_party/closure-uri/uri.js +13 -1
  281. package/ui/audio_language_selection.js +9 -2
  282. package/ui/controls.js +125 -0
  283. package/ui/externs/ui.js +24 -2
  284. package/ui/language_utils.js +43 -8
  285. package/ui/less/range_elements.less +33 -0
  286. package/ui/locales/en.json +1 -0
  287. package/ui/locales/es-419.json +1 -0
  288. package/ui/locales/es.json +1 -0
  289. package/ui/locales/source.json +4 -0
  290. package/ui/localization.js +10 -0
  291. package/ui/pip_button.js +22 -120
  292. package/ui/remote_button.js +203 -0
  293. package/ui/resolution_selection.js +47 -10
  294. package/ui/seek_bar.js +296 -3
  295. package/ui/text_selection.js +2 -1
  296. package/ui/ui.js +11 -4
  297. package/demo/common/message_ids.js +0 -309
  298. package/demo/locales/en.json +0 -288
  299. package/demo/locales/source.json +0 -1146
  300. package/externs/mux.js +0 -69
  301. package/lib/lcevc/lcevc_dil.js +0 -152
  302. package/lib/routing/node.js +0 -23
  303. package/lib/routing/payload.js +0 -43
  304. package/lib/routing/walker.js +0 -587
  305. package/lib/transmuxer/muxjs_transmuxer.js +0 -242
  306. package/test/routing/walker_unit.js +0 -504
  307. package/test/transmuxer/muxjs_transmuxer_integration.js +0 -177
@@ -29,22 +29,24 @@ shaka.dash.MpdUtils = class {
29
29
  * @param {string} uriTemplate
30
30
  * @param {?string} representationId
31
31
  * @param {?number} number
32
+ * @param {?number} subNumber
32
33
  * @param {?number} bandwidth
33
- * @param {?number} time
34
+ * @param {?(number|bigint)} time
34
35
  * @return {string} A URI string.
35
36
  * @see ISO/IEC 23009-1:2014 section 5.3.9.4.4
36
37
  */
37
38
  static fillUriTemplate(
38
- uriTemplate, representationId, number, bandwidth, time) {
39
+ uriTemplate, representationId, number, subNumber, bandwidth, time) {
39
40
  /** @type {!Object.<string, ?number|?string>} */
40
41
  const valueTable = {
41
42
  'RepresentationID': representationId,
42
43
  'Number': number,
44
+ 'SubNumber': subNumber,
43
45
  'Bandwidth': bandwidth,
44
46
  'Time': time,
45
47
  };
46
48
 
47
- const re = /\$(RepresentationID|Number|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\$/g; // eslint-disable-line max-len
49
+ const re = /\$(RepresentationID|Number|SubNumber|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\$/g; // eslint-disable-line max-len
48
50
  const uri = uriTemplate.replace(re, (match, name, widthStr, format) => {
49
51
  if (match == '$$') {
50
52
  return '$';
@@ -71,11 +73,15 @@ shaka.dash.MpdUtils = class {
71
73
  }
72
74
 
73
75
  if (name == 'Time') {
74
- goog.asserts.assert(typeof value == 'number',
75
- 'Time value should be a number!');
76
- goog.asserts.assert(Math.abs(value - Math.round(value)) < 0.2,
77
- 'Calculated $Time$ values must be close to integers');
78
- value = Math.round(value);
76
+ if (typeof value != 'bigint') {
77
+ goog.asserts.assert(typeof value == 'number',
78
+ 'Time value should be a number or bigint!');
79
+ if (Math.abs(value - Math.round(value)) >= 0.2) {
80
+ shaka.log.alwaysWarn(
81
+ 'Calculated $Time$ values must be close to integers');
82
+ }
83
+ value = Math.round(value);
84
+ }
79
85
  }
80
86
 
81
87
  /** @type {string} */
@@ -122,11 +128,12 @@ shaka.dash.MpdUtils = class {
122
128
  * @param {number} unscaledPresentationTimeOffset
123
129
  * @param {number} periodDuration The Period's duration in seconds.
124
130
  * Infinity indicates that the Period continues indefinitely.
131
+ * @param {number} startNumber
125
132
  * @return {!Array.<shaka.media.PresentationTimeline.TimeRange>}
126
133
  */
127
134
  static createTimeline(
128
135
  segmentTimeline, timescale, unscaledPresentationTimeOffset,
129
- periodDuration) {
136
+ periodDuration, startNumber) {
130
137
  goog.asserts.assert(
131
138
  timescale > 0 && timescale < Infinity,
132
139
  'timescale must be a positive, finite integer');
@@ -150,6 +157,10 @@ shaka.dash.MpdUtils = class {
150
157
  XmlUtils.parseAttr(timePoint, 'd', XmlUtils.parseNonNegativeInt);
151
158
  const r = XmlUtils.parseAttr(timePoint, 'r', XmlUtils.parseInt);
152
159
 
160
+ const k = XmlUtils.parseAttr(timePoint, 'k', XmlUtils.parseInt);
161
+
162
+ const partialSegments = k || 0;
163
+
153
164
  // Adjust the start time to account for the presentation time offset.
154
165
  if (t != null) {
155
166
  t -= unscaledPresentationTimeOffset;
@@ -232,6 +243,8 @@ shaka.dash.MpdUtils = class {
232
243
  start: startTime / timescale,
233
244
  end: endTime / timescale,
234
245
  unscaledStart: startTime,
246
+ partialSegments: partialSegments,
247
+ segmentPosition: timeline.length + startNumber,
235
248
  };
236
249
  timeline.push(item);
237
250
 
@@ -295,7 +308,7 @@ shaka.dash.MpdUtils = class {
295
308
  if (timelineNode) {
296
309
  timeline = MpdUtils.createTimeline(
297
310
  timelineNode, timescale, unscaledPresentationTimeOffset,
298
- context.periodInfo.duration || Infinity);
311
+ context.periodInfo.duration || Infinity, startNumber);
299
312
  }
300
313
 
301
314
  const scaledPresentationTimeOffset =
@@ -311,30 +324,46 @@ shaka.dash.MpdUtils = class {
311
324
  }
312
325
 
313
326
  /**
314
- * Searches the inheritance for a Segment* with the given attribute.
315
- *
327
+ * Parses common attributes for Representation, AdaptationSet, and Period.
316
328
  * @param {shaka.dash.DashParser.Context} context
317
329
  * @param {function(?shaka.dash.DashParser.InheritanceFrame):Element} callback
318
- * Gets the Element that contains the attribute to inherit.
319
- * @param {string} attribute
320
- * @return {?string}
321
- */
322
- static inheritAttribute(context, callback, attribute) {
330
+ * @return {!Array.<!Element>}
331
+ */
332
+ static getNodes(context, callback) {
323
333
  const Functional = shaka.util.Functional;
324
334
  goog.asserts.assert(
325
335
  callback(context.representation),
326
- 'There must be at least one element of the given type');
336
+ 'There must be at least one element of the given type',
337
+ );
327
338
 
328
- /** @type {!Array.<!Element>} */
329
- const nodes = [
339
+ return [
330
340
  callback(context.representation),
331
341
  callback(context.adaptationSet),
332
342
  callback(context.period),
333
343
  ].filter(Functional.isNotNull);
344
+ }
334
345
 
335
- return nodes
336
- .map((s) => { return s.getAttribute(attribute); })
337
- .reduce((all, part) => { return all || part; });
346
+ /**
347
+ * Searches the inheritance for a Segment* with the given attribute.
348
+ *
349
+ * @param {shaka.dash.DashParser.Context} context
350
+ * @param {function(?shaka.dash.DashParser.InheritanceFrame):Element} callback
351
+ * Gets the Element that contains the attribute to inherit.
352
+ * @param {string} attribute
353
+ * @return {?string}
354
+ */
355
+ static inheritAttribute(context, callback, attribute) {
356
+ const MpdUtils = shaka.dash.MpdUtils;
357
+ const nodes = MpdUtils.getNodes(context, callback);
358
+
359
+ let result = null;
360
+ for (const node of nodes) {
361
+ result = node.getAttribute(attribute);
362
+ if (result) {
363
+ break;
364
+ }
365
+ }
366
+ return result;
338
367
  }
339
368
 
340
369
  /**
@@ -347,22 +376,18 @@ shaka.dash.MpdUtils = class {
347
376
  * @return {Element}
348
377
  */
349
378
  static inheritChild(context, callback, child) {
350
- const Functional = shaka.util.Functional;
351
- goog.asserts.assert(
352
- callback(context.representation),
353
- 'There must be at least one element of the given type');
354
-
355
- /** @type {!Array.<!Element>} */
356
- const nodes = [
357
- callback(context.representation),
358
- callback(context.adaptationSet),
359
- callback(context.period),
360
- ].filter(Functional.isNotNull);
379
+ const MpdUtils = shaka.dash.MpdUtils;
380
+ const nodes = MpdUtils.getNodes(context, callback);
361
381
 
362
382
  const XmlUtils = shaka.util.XmlUtils;
363
- return nodes
364
- .map((s) => { return XmlUtils.findChild(s, child); })
365
- .reduce((all, part) => { return all || part; });
383
+ let result = null;
384
+ for (const node of nodes) {
385
+ result = XmlUtils.findChild(node, child);
386
+ if (result) {
387
+ break;
388
+ }
389
+ }
390
+ return result;
366
391
  }
367
392
 
368
393
  /**
@@ -31,9 +31,10 @@ shaka.dash.SegmentBase = class {
31
31
  *
32
32
  * @param {shaka.dash.DashParser.Context} context
33
33
  * @param {function(?shaka.dash.DashParser.InheritanceFrame):Element} callback
34
+ * @param {shaka.extern.aes128Key|undefined} aes128Key
34
35
  * @return {shaka.media.InitSegmentReference}
35
36
  */
36
- static createInitSegment(context, callback) {
37
+ static createInitSegment(context, callback, aes128Key) {
37
38
  const MpdUtils = shaka.dash.MpdUtils;
38
39
  const XmlUtils = shaka.util.XmlUtils;
39
40
  const ManifestParserUtils = shaka.util.ManifestParserUtils;
@@ -44,11 +45,10 @@ shaka.dash.SegmentBase = class {
44
45
  return null;
45
46
  }
46
47
 
47
- let resolvedUris = context.representation.baseUris;
48
+ let resolvedUris = context.representation.getBaseUris();
48
49
  const uri = initialization.getAttribute('sourceURL');
49
50
  if (uri) {
50
- resolvedUris = ManifestParserUtils.resolveUris(
51
- context.representation.baseUris, [uri]);
51
+ resolvedUris = ManifestParserUtils.resolveUris(resolvedUris, [uri]);
52
52
  }
53
53
 
54
54
  let startByte = 0;
@@ -63,7 +63,13 @@ shaka.dash.SegmentBase = class {
63
63
  const getUris = () => resolvedUris;
64
64
  const qualityInfo = shaka.dash.SegmentBase.createQualityInfo(context);
65
65
  return new shaka.media.InitSegmentReference(
66
- getUris, startByte, endByte, qualityInfo);
66
+ getUris,
67
+ startByte,
68
+ endByte,
69
+ qualityInfo,
70
+ /* timescale= */ null,
71
+ /* segmentData= */ null,
72
+ aes128Key);
67
73
  }
68
74
 
69
75
  /**
@@ -71,9 +77,10 @@ shaka.dash.SegmentBase = class {
71
77
  *
72
78
  * @param {shaka.dash.DashParser.Context} context
73
79
  * @param {shaka.dash.DashParser.RequestSegmentCallback} requestSegment
80
+ * @param {shaka.extern.aes128Key|undefined} aes128Key
74
81
  * @return {shaka.dash.DashParser.StreamInfo}
75
82
  */
76
- static createStreamInfo(context, requestSegment) {
83
+ static createStreamInfo(context, requestSegment, aes128Key) {
77
84
  goog.asserts.assert(context.representation.segmentBase,
78
85
  'Should only be called with SegmentBase');
79
86
  // Since SegmentBase does not need updates, simply treat any call as
@@ -95,8 +102,8 @@ shaka.dash.SegmentBase = class {
95
102
  const scaledPresentationTimeOffset =
96
103
  (unscaledPresentationTimeOffset / timescale) || 0;
97
104
 
98
- const initSegmentReference =
99
- SegmentBase.createInitSegment(context, SegmentBase.fromInheritance_);
105
+ const initSegmentReference = SegmentBase.createInitSegment(
106
+ context, SegmentBase.fromInheritance_, aes128Key);
100
107
 
101
108
  // Throws an immediate error if the format is unsupported.
102
109
  SegmentBase.checkSegmentIndexRangeSupport_(context, initSegmentReference);
@@ -241,12 +248,12 @@ shaka.dash.SegmentBase = class {
241
248
  const representationIndex = MpdUtils.inheritChild(
242
249
  context, SegmentBase.fromInheritance_, 'RepresentationIndex');
243
250
 
244
- let indexUris = context.representation.baseUris;
251
+ let indexUris = context.representation.getBaseUris();
245
252
  if (representationIndex) {
246
253
  const representationUri = representationIndex.getAttribute('sourceURL');
247
254
  if (representationUri) {
248
255
  indexUris = ManifestParserUtils.resolveUris(
249
- context.representation.baseUris, [representationUri]);
256
+ indexUris, [representationUri]);
250
257
  }
251
258
  }
252
259
 
@@ -31,15 +31,16 @@ shaka.dash.SegmentList = class {
31
31
  *
32
32
  * @param {shaka.dash.DashParser.Context} context
33
33
  * @param {!Object.<string, !shaka.extern.Stream>} streamMap
34
+ * @param {shaka.extern.aes128Key|undefined} aes128Key
34
35
  * @return {shaka.dash.DashParser.StreamInfo}
35
36
  */
36
- static createStreamInfo(context, streamMap) {
37
+ static createStreamInfo(context, streamMap, aes128Key) {
37
38
  goog.asserts.assert(context.representation.segmentList,
38
39
  'Should only be called with SegmentList');
39
40
  const SegmentList = shaka.dash.SegmentList;
40
41
 
41
42
  const initSegmentReference = shaka.dash.SegmentBase.createInitSegment(
42
- context, SegmentList.fromInheritance_);
43
+ context, SegmentList.fromInheritance_, aes128Key);
43
44
  const info = SegmentList.parseSegmentListInfo_(context);
44
45
 
45
46
  SegmentList.checkSegmentListInfo_(context, info);
@@ -58,8 +59,8 @@ shaka.dash.SegmentList = class {
58
59
 
59
60
  const references = SegmentList.createSegmentReferences_(
60
61
  context.periodInfo.start, context.periodInfo.duration,
61
- info.startNumber, context.representation.baseUris, info,
62
- initSegmentReference);
62
+ info.startNumber, context.representation.getBaseUris, info,
63
+ initSegmentReference, aes128Key);
63
64
 
64
65
  const isNew = !segmentIndex;
65
66
  if (segmentIndex) {
@@ -194,15 +195,16 @@ shaka.dash.SegmentList = class {
194
195
  * @param {number} periodStart in seconds.
195
196
  * @param {?number} periodDuration in seconds.
196
197
  * @param {number} startNumber
197
- * @param {!Array.<string>} baseUris
198
+ * @param {function():!Array.<string>} getBaseUris
198
199
  * @param {shaka.dash.SegmentList.SegmentListInfo} info
199
200
  * @param {shaka.media.InitSegmentReference} initSegmentReference
201
+ * @param {shaka.extern.aes128Key|undefined} aes128Key
200
202
  * @return {!Array.<!shaka.media.SegmentReference>}
201
203
  * @private
202
204
  */
203
205
  static createSegmentReferences_(
204
- periodStart, periodDuration, startNumber, baseUris, info,
205
- initSegmentReference) {
206
+ periodStart, periodDuration, startNumber, getBaseUris, info,
207
+ initSegmentReference, aes128Key) {
206
208
  const ManifestParserUtils = shaka.util.ManifestParserUtils;
207
209
 
208
210
  let max = info.mediaSegments.length;
@@ -244,7 +246,8 @@ shaka.dash.SegmentList = class {
244
246
  let uris = null;
245
247
  const getUris = () => {
246
248
  if (uris == null) {
247
- uris = ManifestParserUtils.resolveUris(baseUris, [segment.mediaUri]);
249
+ uris = ManifestParserUtils.resolveUris(
250
+ getBaseUris(), [segment.mediaUri]);
248
251
  }
249
252
  return uris;
250
253
  };
@@ -257,7 +260,13 @@ shaka.dash.SegmentList = class {
257
260
  segment.end,
258
261
  initSegmentReference,
259
262
  timestampOffset,
260
- appendWindowStart, appendWindowEnd));
263
+ appendWindowStart, appendWindowEnd,
264
+ /* partialReferences= */ [],
265
+ /* tilesLayout= */ '',
266
+ /* tileDuration= */ null,
267
+ /* syncTime= */ null,
268
+ shaka.media.SegmentReference.Status.AVAILABLE,
269
+ aes128Key));
261
270
  prevEndTime = endTime;
262
271
  }
263
272