shaka-player 4.12.8 → 4.13.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 (261) hide show
  1. package/AUTHORS +1 -0
  2. package/CONTRIBUTORS +4 -0
  3. package/README.md +22 -21
  4. package/cspell.config.yaml +18 -0
  5. package/dist/controls.css +1 -1
  6. package/dist/controls.css.map +1 -1
  7. package/dist/deps.js +29 -24
  8. package/dist/locales.js +33 -33
  9. package/dist/shaka-player.compiled.d.ts +138 -36
  10. package/dist/shaka-player.compiled.debug.d.ts +138 -36
  11. package/dist/shaka-player.compiled.debug.externs.js +367 -107
  12. package/dist/shaka-player.compiled.debug.js +828 -765
  13. package/dist/shaka-player.compiled.debug.map +4 -4
  14. package/dist/shaka-player.compiled.externs.js +367 -107
  15. package/dist/shaka-player.compiled.js +1451 -1416
  16. package/dist/shaka-player.compiled.map +4 -4
  17. package/dist/shaka-player.ui.d.ts +172 -38
  18. package/dist/shaka-player.ui.debug.d.ts +172 -38
  19. package/dist/shaka-player.ui.debug.externs.js +406 -113
  20. package/dist/shaka-player.ui.debug.js +842 -766
  21. package/dist/shaka-player.ui.debug.map +4 -4
  22. package/dist/shaka-player.ui.externs.js +406 -113
  23. package/dist/shaka-player.ui.js +1670 -1628
  24. package/dist/shaka-player.ui.map +4 -4
  25. package/eslint.config.mjs +343 -0
  26. package/externs/airplay.js +1 -1
  27. package/externs/audiotrack.js +1 -1
  28. package/externs/awesomplete.js +1 -1
  29. package/externs/cast-sdk-v2.js +2 -2
  30. package/externs/cmcd.js +16 -1
  31. package/externs/device_sensor_event.js +1 -1
  32. package/externs/ima.js +8 -8
  33. package/externs/isoboxer.js +31 -31
  34. package/externs/jwk_set.js +1 -1
  35. package/externs/lcevc.js +8 -8
  36. package/externs/mediakeys.js +1 -1
  37. package/externs/mediasession.js +3 -2
  38. package/externs/mediatailor.js +18 -18
  39. package/externs/pictureinpicture.js +41 -1
  40. package/externs/playstation.js +2 -2
  41. package/externs/prefixed_eme.js +1 -1
  42. package/externs/shaka/abortable.js +4 -4
  43. package/externs/shaka/abr_manager.js +1 -1
  44. package/externs/shaka/ads.js +45 -6
  45. package/externs/shaka/cea.js +2 -2
  46. package/externs/shaka/codecs.js +4 -4
  47. package/externs/shaka/drm_info.js +6 -6
  48. package/externs/shaka/error.js +5 -5
  49. package/externs/shaka/manifest.js +51 -56
  50. package/externs/shaka/manifest_parser.js +3 -9
  51. package/externs/shaka/net.js +23 -20
  52. package/externs/shaka/offline.js +37 -37
  53. package/externs/shaka/offline_compat_v1.js +10 -10
  54. package/externs/shaka/offline_compat_v2.js +10 -10
  55. package/externs/shaka/player.js +139 -109
  56. package/externs/shaka/text.js +10 -3
  57. package/externs/shaka/transmuxer.js +1 -1
  58. package/externs/videotrack.js +1 -1
  59. package/lib/abr/ewma.js +1 -1
  60. package/lib/abr/simple_abr_manager.js +70 -22
  61. package/lib/ads/ad_manager.js +43 -18
  62. package/lib/ads/ad_utils.js +160 -58
  63. package/lib/ads/ads_stats.js +1 -1
  64. package/lib/ads/client_side_ad_manager.js +2 -2
  65. package/lib/ads/interstitial_ad.js +16 -11
  66. package/lib/ads/interstitial_ad_manager.js +419 -72
  67. package/lib/ads/interstitial_static_ad.js +299 -0
  68. package/lib/ads/media_tailor_ad.js +1 -0
  69. package/lib/ads/media_tailor_ad_manager.js +37 -36
  70. package/lib/ads/server_side_ad_manager.js +7 -6
  71. package/lib/cast/cast_receiver.js +5 -3
  72. package/lib/cast/cast_sender.js +2 -2
  73. package/lib/cast/cast_utils.js +20 -13
  74. package/lib/cea/cea608_data_channel.js +53 -53
  75. package/lib/cea/cea708_service.js +42 -40
  76. package/lib/cea/cea708_window.js +5 -2
  77. package/lib/cea/cea_decoder.js +5 -7
  78. package/lib/cea/mp4_cea_parser.js +1 -1
  79. package/lib/cea/sei_processor.js +1 -1
  80. package/lib/dash/content_protection.js +62 -192
  81. package/lib/dash/dash_parser.js +119 -119
  82. package/lib/dash/mpd_utils.js +14 -13
  83. package/lib/dash/segment_base.js +5 -5
  84. package/lib/dash/segment_list.js +10 -10
  85. package/lib/dash/segment_template.js +55 -53
  86. package/lib/debug/log.js +2 -2
  87. package/lib/dependencies/all.js +2 -1
  88. package/lib/{media → drm}/drm_engine.js +274 -143
  89. package/lib/{util → drm}/drm_utils.js +20 -11
  90. package/lib/drm/playready.js +233 -0
  91. package/lib/hls/hls_classes.js +14 -14
  92. package/lib/hls/hls_parser.js +257 -196
  93. package/lib/hls/hls_utils.js +14 -14
  94. package/lib/hls/manifest_text_parser.js +10 -10
  95. package/lib/media/adaptation_set.js +6 -5
  96. package/lib/media/adaptation_set_criteria.js +51 -379
  97. package/lib/media/buffering_observer.js +5 -4
  98. package/lib/media/closed_caption_parser.js +2 -2
  99. package/lib/media/content_workarounds.js +2 -2
  100. package/lib/media/example_based_criteria.js +69 -0
  101. package/lib/media/gap_jumping_controller.js +14 -1
  102. package/lib/media/manifest_filterer.js +8 -8
  103. package/lib/media/manifest_parser.js +2 -2
  104. package/lib/media/media_source_capabilities.js +20 -1
  105. package/lib/media/media_source_engine.js +84 -35
  106. package/lib/media/mp4_segment_index_parser.js +5 -5
  107. package/lib/media/playhead.js +2 -8
  108. package/lib/media/playhead_observer.js +1 -1
  109. package/lib/media/preference_based_criteria.js +333 -0
  110. package/lib/media/preload_manager.js +53 -37
  111. package/lib/media/presentation_timeline.js +2 -2
  112. package/lib/media/quality_observer.js +35 -35
  113. package/lib/media/region_observer.js +2 -2
  114. package/lib/media/region_timeline.js +3 -3
  115. package/lib/media/segment_index.js +14 -14
  116. package/lib/media/segment_prefetch.js +17 -13
  117. package/lib/media/segment_reference.js +7 -7
  118. package/lib/media/segment_utils.js +9 -9
  119. package/lib/media/streaming_engine.js +77 -38
  120. package/lib/media/time_ranges_utils.js +1 -1
  121. package/lib/media/video_wrapper.js +1 -1
  122. package/lib/media/webm_segment_index_parser.js +4 -4
  123. package/lib/mss/content_protection.js +17 -222
  124. package/lib/mss/mss_parser.js +23 -24
  125. package/lib/net/data_uri_plugin.js +1 -0
  126. package/lib/net/http_fetch_plugin.js +8 -7
  127. package/lib/net/http_plugin_utils.js +5 -2
  128. package/lib/net/http_xhr_plugin.js +4 -3
  129. package/lib/net/networking_engine.js +72 -17
  130. package/lib/net/networking_utils.js +5 -2
  131. package/lib/offline/download_info.js +5 -1
  132. package/lib/offline/download_manager.js +15 -4
  133. package/lib/offline/download_progress_estimator.js +1 -1
  134. package/lib/offline/indexeddb/base_storage_cell.js +9 -9
  135. package/lib/offline/indexeddb/db_connection.js +1 -1
  136. package/lib/offline/indexeddb/db_operation.js +2 -2
  137. package/lib/offline/indexeddb/eme_session_storage_cell.js +1 -1
  138. package/lib/offline/indexeddb/storage_mechanism.js +1 -1
  139. package/lib/offline/indexeddb/v1_storage_cell.js +3 -3
  140. package/lib/offline/indexeddb/v2_storage_cell.js +2 -2
  141. package/lib/offline/manifest_converter.js +11 -12
  142. package/lib/offline/offline_scheme.js +8 -4
  143. package/lib/offline/session_deleter.js +11 -11
  144. package/lib/offline/storage.js +137 -88
  145. package/lib/offline/storage_muxer.js +8 -8
  146. package/lib/offline/stored_content_utils.js +3 -3
  147. package/lib/offline/stream_bandwidth_estimator.js +1 -1
  148. package/lib/player.js +291 -207
  149. package/lib/polyfill/all.js +1 -1
  150. package/lib/polyfill/media_capabilities.js +5 -5
  151. package/lib/polyfill/patchedmediakeys_apple.js +6 -6
  152. package/lib/polyfill/patchedmediakeys_webkit.js +8 -8
  153. package/lib/polyfill/video_play_promise.js +0 -1
  154. package/lib/text/cue.js +3 -2
  155. package/lib/text/lrc_text_parser.js +1 -1
  156. package/lib/text/mp4_ttml_parser.js +1 -1
  157. package/lib/text/mp4_vtt_parser.js +3 -3
  158. package/lib/text/sbv_text_parser.js +1 -1
  159. package/lib/text/simple_text_displayer.js +37 -10
  160. package/lib/text/ssa_text_parser.js +3 -1
  161. package/lib/text/stub_text_displayer.js +12 -5
  162. package/lib/text/text_engine.js +5 -4
  163. package/lib/text/text_utils.js +4 -4
  164. package/lib/text/ttml_text_parser.js +21 -20
  165. package/lib/text/ui_text_displayer.js +20 -13
  166. package/lib/text/vtt_text_parser.js +10 -10
  167. package/lib/text/web_vtt_generator.js +2 -2
  168. package/lib/transmuxer/aac_transmuxer.js +2 -2
  169. package/lib/transmuxer/ac3_transmuxer.js +2 -2
  170. package/lib/transmuxer/adts.js +2 -0
  171. package/lib/transmuxer/ec3.js +3 -3
  172. package/lib/transmuxer/ec3_transmuxer.js +2 -2
  173. package/lib/transmuxer/h264.js +5 -5
  174. package/lib/transmuxer/h265.js +3 -3
  175. package/lib/transmuxer/mp3_transmuxer.js +2 -2
  176. package/lib/transmuxer/mpeg_audio.js +6 -6
  177. package/lib/transmuxer/mss_transmuxer.js +2 -0
  178. package/lib/transmuxer/transmuxer_engine.js +1 -1
  179. package/lib/transmuxer/ts_transmuxer.js +10 -10
  180. package/lib/util/abortable_operation.js +10 -10
  181. package/lib/util/array_utils.js +6 -6
  182. package/lib/util/cmcd_manager.js +149 -18
  183. package/lib/util/cmsd_manager.js +11 -11
  184. package/lib/util/config_utils.js +3 -3
  185. package/lib/util/content_steering_manager.js +17 -17
  186. package/lib/util/data_view_reader.js +3 -3
  187. package/lib/util/ebml_parser.js +1 -1
  188. package/lib/util/error.js +11 -6
  189. package/lib/util/event_manager.js +1 -1
  190. package/lib/util/exp_golomb.js +1 -1
  191. package/lib/util/fairplay_utils.js +6 -1
  192. package/lib/util/fake_event.js +3 -2
  193. package/lib/util/fake_event_target.js +1 -1
  194. package/lib/util/functional.js +8 -8
  195. package/lib/util/id3_utils.js +1 -1
  196. package/lib/util/iterables.js +6 -6
  197. package/lib/util/language_utils.js +17 -17
  198. package/lib/util/manifest_parser_utils.js +13 -13
  199. package/lib/util/map_utils.js +6 -6
  200. package/lib/util/media_ready_state_utils.js +1 -1
  201. package/lib/util/mime_utils.js +15 -4
  202. package/lib/util/mp4_box_parsers.js +5 -5
  203. package/lib/util/mp4_generator.js +31 -30
  204. package/lib/util/mp4_parser.js +2 -2
  205. package/lib/util/multi_map.js +5 -5
  206. package/lib/util/mutex.js +1 -1
  207. package/lib/util/networking.js +1 -1
  208. package/lib/util/object_utils.js +5 -1
  209. package/lib/util/operation_manager.js +1 -1
  210. package/lib/util/periods.js +24 -24
  211. package/lib/util/platform.js +8 -4
  212. package/lib/util/player_configuration.js +50 -17
  213. package/lib/util/pssh.js +34 -6
  214. package/lib/util/public_promise.js +2 -2
  215. package/lib/util/state_history.js +2 -2
  216. package/lib/util/stream_utils.js +138 -120
  217. package/lib/util/string_utils.js +4 -3
  218. package/lib/util/switch_history.js +2 -2
  219. package/lib/util/tXml.js +22 -17
  220. package/lib/util/text_parser.js +2 -2
  221. package/lib/util/timer.js +1 -1
  222. package/lib/util/ts_parser.js +22 -22
  223. package/lib/util/xml_utils.js +1 -0
  224. package/package.json +7 -4
  225. package/project-words.txt +485 -0
  226. package/shaka-player.uncompiled.js +1 -1
  227. package/third_party/closure-uri/uri.js +2 -2
  228. package/third_party/closure-uri/utils.js +2 -2
  229. package/third_party/language-mapping-list/language-mapping-list.js +1 -1
  230. package/ui/ad_statistics_button.js +9 -5
  231. package/ui/airplay_button.js +1 -0
  232. package/ui/audio_language_selection.js +2 -1
  233. package/ui/context_menu.js +2 -2
  234. package/ui/controls.js +7 -7
  235. package/ui/externs/ui.js +29 -21
  236. package/ui/externs/watermark.js +64 -0
  237. package/ui/fast_forward_button.js +1 -1
  238. package/ui/gl_matrix/matrix_4x4.js +11 -5
  239. package/ui/hidden_fast_forward_button.js +1 -1
  240. package/ui/hidden_seek_button.js +1 -1
  241. package/ui/language_utils.js +27 -26
  242. package/ui/less/buttons.less +2 -2
  243. package/ui/localization.js +21 -21
  244. package/ui/loop_button.js +2 -2
  245. package/ui/overflow_menu.js +2 -2
  246. package/ui/playback_rate_selection.js +1 -1
  247. package/ui/presentation_time.js +4 -1
  248. package/ui/range_element.js +2 -2
  249. package/ui/resolution_selection.js +42 -6
  250. package/ui/rewind_button.js +1 -1
  251. package/ui/seek_bar.js +5 -5
  252. package/ui/statistics_button.js +8 -4
  253. package/ui/text_selection.js +3 -2
  254. package/ui/ui.js +32 -2
  255. package/ui/vr_manager.js +3 -3
  256. package/ui/vr_utils.js +14 -14
  257. package/ui/vr_webgl.js +5 -5
  258. package/ui/watermark.js +313 -0
  259. package/.eslintignore +0 -4
  260. package/.eslintrc.js +0 -310
  261. package/lib/polyfill/patchedmediakeys_nop.js +0 -148
@@ -403,7 +403,7 @@ shaka.cea.Mp4CeaParser.BitstreamFormat = {
403
403
  H266: 3,
404
404
  };
405
405
 
406
- /** @private {Object.<string, shaka.cea.Mp4CeaParser.BitstreamFormat>} */
406
+ /** @private {Object<string, shaka.cea.Mp4CeaParser.BitstreamFormat>} */
407
407
  shaka.cea.Mp4CeaParser.CodecBitstreamMap_ = {
408
408
  // AVC
409
409
  'avc1': shaka.cea.Mp4CeaParser.BitstreamFormat.H264,
@@ -14,7 +14,7 @@ shaka.cea.SeiProcessor = class {
14
14
  /**
15
15
  * Processes supplemental enhancement information data.
16
16
  * @param {!Uint8Array} naluData NALU from which SEI data is to be processed.
17
- * @return {!Array.<!Uint8Array>}
17
+ * @return {!Array<!Uint8Array>}
18
18
  */
19
19
  process(naluData) {
20
20
  const seiPayloads = [];
@@ -8,7 +8,7 @@ goog.provide('shaka.dash.ContentProtection');
8
8
 
9
9
  goog.require('goog.asserts');
10
10
  goog.require('shaka.log');
11
- goog.require('shaka.util.BufferUtils');
11
+ goog.require('shaka.drm.PlayReady');
12
12
  goog.require('shaka.util.Error');
13
13
  goog.require('shaka.util.ManifestParserUtils');
14
14
  goog.require('shaka.util.Platform');
@@ -26,18 +26,18 @@ shaka.dash.ContentProtection = class {
26
26
  /**
27
27
  * Parses info from the ContentProtection elements at the AdaptationSet level.
28
28
  *
29
- * @param {!Array.<!shaka.extern.xml.Node>} elems
29
+ * @param {!Array<!shaka.extern.xml.Node>} elements
30
30
  * @param {boolean} ignoreDrmInfo
31
- * @param {!Object.<string, string>} keySystemsByURI
31
+ * @param {!Object<string, string>} keySystemsByURI
32
32
  * @return {shaka.dash.ContentProtection.Context}
33
33
  */
34
- static parseFromAdaptationSet(elems, ignoreDrmInfo, keySystemsByURI) {
34
+ static parseFromAdaptationSet(elements, ignoreDrmInfo, keySystemsByURI) {
35
35
  const ContentProtection = shaka.dash.ContentProtection;
36
36
  const ManifestParserUtils = shaka.util.ManifestParserUtils;
37
- const parsed = ContentProtection.parseElements_(elems);
38
- /** @type {Array.<shaka.extern.InitDataOverride>} */
37
+ const parsed = ContentProtection.parseElements_(elements);
38
+ /** @type {Array<shaka.extern.InitDataOverride>} */
39
39
  let defaultInit = null;
40
- /** @type {!Array.<shaka.extern.DrmInfo>} */
40
+ /** @type {!Array<shaka.extern.DrmInfo>} */
41
41
  let drmInfos = [];
42
42
  let parsedNonCenc = [];
43
43
  /** @type {?shaka.dash.ContentProtection.Aes128Info} */
@@ -149,17 +149,17 @@ shaka.dash.ContentProtection = class {
149
149
  * Parses the given ContentProtection elements found at the Representation
150
150
  * level. This may update the |context|.
151
151
  *
152
- * @param {!Array.<!shaka.extern.xml.Node>} elems
152
+ * @param {!Array<!shaka.extern.xml.Node>} elements
153
153
  * @param {shaka.dash.ContentProtection.Context} context
154
154
  * @param {boolean} ignoreDrmInfo
155
- * @param {!Object.<string, string>} keySystemsByURI
155
+ * @param {!Object<string, string>} keySystemsByURI
156
156
  * @return {?string} The parsed key ID
157
157
  */
158
158
  static parseFromRepresentation(
159
- elems, context, ignoreDrmInfo, keySystemsByURI) {
159
+ elements, context, ignoreDrmInfo, keySystemsByURI) {
160
160
  const ContentProtection = shaka.dash.ContentProtection;
161
161
  const repContext = ContentProtection.parseFromAdaptationSet(
162
- elems, ignoreDrmInfo, keySystemsByURI);
162
+ elements, ignoreDrmInfo, keySystemsByURI);
163
163
 
164
164
  if (context.firstRepresentation) {
165
165
  const asUnknown = context.drmInfos.length == 1 &&
@@ -242,11 +242,11 @@ shaka.dash.ContentProtection = class {
242
242
  return textContents;
243
243
  }
244
244
  }
245
- const mslaurlNode = shaka.util.TXml.findChildNS(
245
+ const msLaUrlNode = shaka.util.TXml.findChildNS(
246
246
  element.node, 'urn:microsoft', 'laurl');
247
- if (mslaurlNode) {
247
+ if (msLaUrlNode) {
248
248
  return StringUtils.htmlUnescape(
249
- mslaurlNode.attributes['licenseUrl']) || '';
249
+ msLaUrlNode.attributes['licenseUrl']) || '';
250
250
  }
251
251
  return '';
252
252
  }
@@ -285,107 +285,6 @@ shaka.dash.ContentProtection = class {
285
285
  return '';
286
286
  }
287
287
 
288
- /**
289
- * Parses an Array buffer starting at byteOffset for PlayReady Object Records.
290
- * Each PRO Record is preceded by its PlayReady Record type and length in
291
- * bytes.
292
- *
293
- * PlayReady Object Record format: https://goo.gl/FTcu46
294
- *
295
- * @param {!DataView} view
296
- * @param {number} byteOffset
297
- * @return {!Array.<shaka.dash.ContentProtection.PlayReadyRecord>}
298
- * @private
299
- */
300
- static parseMsProRecords_(view, byteOffset) {
301
- const records = [];
302
-
303
- while (byteOffset < view.byteLength - 1) {
304
- const type = view.getUint16(byteOffset, true);
305
- byteOffset += 2;
306
-
307
- const byteLength = view.getUint16(byteOffset, true);
308
- byteOffset += 2;
309
-
310
- if ((byteLength & 1) != 0 || byteLength + byteOffset > view.byteLength) {
311
- shaka.log.warning('Malformed MS PRO object');
312
- return [];
313
- }
314
-
315
- const recordValue = shaka.util.BufferUtils.toUint8(
316
- view, byteOffset, byteLength);
317
- records.push({
318
- type: type,
319
- value: recordValue,
320
- });
321
-
322
- byteOffset += byteLength;
323
- }
324
-
325
- return records;
326
- }
327
-
328
- /**
329
- * Parses a buffer for PlayReady Objects. The data
330
- * should contain a 32-bit integer indicating the length of
331
- * the PRO in bytes. Following that, a 16-bit integer for
332
- * the number of PlayReady Object Records in the PRO. Lastly,
333
- * a byte array of the PRO Records themselves.
334
- *
335
- * PlayReady Object format: https://goo.gl/W8yAN4
336
- *
337
- * @param {BufferSource} data
338
- * @return {!Array.<shaka.dash.ContentProtection.PlayReadyRecord>}
339
- * @private
340
- */
341
- static parseMsPro_(data) {
342
- let byteOffset = 0;
343
- const view = shaka.util.BufferUtils.toDataView(data);
344
-
345
- // First 4 bytes is the PRO length (DWORD)
346
- const byteLength = view.getUint32(byteOffset, /* littleEndian= */ true);
347
- byteOffset += 4;
348
-
349
- if (byteLength != data.byteLength) {
350
- // Malformed PRO
351
- shaka.log.warning('PlayReady Object with invalid length encountered.');
352
- return [];
353
- }
354
-
355
- // Skip PRO Record count (WORD)
356
- byteOffset += 2;
357
-
358
- // Rest of the data contains the PRO Records
359
- const ContentProtection = shaka.dash.ContentProtection;
360
- return ContentProtection.parseMsProRecords_(view, byteOffset);
361
- }
362
-
363
- /**
364
- * PlayReady Header format: https://goo.gl/dBzxNA
365
- *
366
- * @param {!shaka.extern.xml.Node} xml
367
- * @return {string}
368
- * @private
369
- */
370
- static getLaurl_(xml) {
371
- const TXml = shaka.util.TXml;
372
- // LA_URL element is optional and no more than one is
373
- // allowed inside the DATA element. Only absolute URLs are allowed.
374
- // If the LA_URL element exists, it must not be empty.
375
- for (const elem of TXml.getElementsByTagName(xml, 'DATA')) {
376
- if (elem.children) {
377
- for (const child of elem.children) {
378
- if (child.tagName == 'LA_URL') {
379
- return /** @type{string} */(shaka.util.TXml.getTextContents(child));
380
- }
381
- }
382
- }
383
- }
384
-
385
- // Not found
386
- return '';
387
- }
388
-
389
288
  /**
390
289
  * Gets a PlayReady license URL from a content protection element
391
290
  * containing a PlayReady Header Object
@@ -394,46 +293,43 @@ shaka.dash.ContentProtection = class {
394
293
  * @return {string}
395
294
  */
396
295
  static getPlayReadyLicenseUrl(element) {
397
- const dashIfLaurlNode = shaka.util.TXml.findChildNS(
296
+ const TXml = shaka.util.TXml;
297
+ const dashIfLaurlNode = TXml.findChildNS(
398
298
  element.node, shaka.dash.ContentProtection.DashIfNamespaceUri_,
399
299
  'Laurl',
400
300
  );
401
301
  if (dashIfLaurlNode) {
402
- const textContents = shaka.util.TXml.getTextContents(dashIfLaurlNode);
302
+ const textContents = TXml.getTextContents(dashIfLaurlNode);
403
303
  if (textContents) {
404
304
  return textContents;
405
305
  }
406
306
  }
407
307
 
408
- const proNode = shaka.util.TXml.findChildNS(
308
+ const proNode = TXml.findChildNS(
409
309
  element.node, 'urn:microsoft:playready', 'pro');
410
-
411
- if (!proNode || !shaka.util.TXml.getTextContents(proNode)) {
412
- return '';
413
- }
414
-
415
- const ContentProtection = shaka.dash.ContentProtection;
416
- const PLAYREADY_RECORD_TYPES = ContentProtection.PLAYREADY_RECORD_TYPES;
417
-
418
- const textContent =
419
- /** @type {string} */ (shaka.util.TXml.getTextContents(proNode));
420
- const bytes = shaka.util.Uint8ArrayUtils.fromBase64(textContent);
421
- const records = ContentProtection.parseMsPro_(bytes);
422
- const record = records.filter((record) => {
423
- return record.type === PLAYREADY_RECORD_TYPES.RIGHTS_MANAGEMENT;
424
- })[0];
425
-
426
- if (!record) {
427
- return '';
310
+ if (proNode) {
311
+ const textContents = TXml.getTextContents(proNode);
312
+ if (textContents) {
313
+ return shaka.drm.PlayReady.getLicenseUrl(proNode);
314
+ }
428
315
  }
429
316
 
430
- const xml = shaka.util.StringUtils.fromUTF16(record.value, true);
431
- const rootElement = shaka.util.TXml.parseXmlString(xml, 'WRMHEADER');
432
- if (!rootElement) {
433
- return '';
317
+ const psshNode = TXml.findChildNS(
318
+ element.node, shaka.dash.ContentProtection.CencNamespaceUri_, 'pssh');
319
+ if (psshNode) {
320
+ const textContents = TXml.getTextContents(psshNode);
321
+ if (textContents) {
322
+ const proData = shaka.util.Pssh.getPsshData(
323
+ shaka.util.Uint8ArrayUtils.fromBase64(textContents));
324
+ const proString = shaka.util.Uint8ArrayUtils.toStandardBase64(proData);
325
+ const reBuildProNode =
326
+ TXml.parseXmlString('<pro>' + proString + '</pro>');
327
+ goog.asserts.assert(reBuildProNode, 'Must have pro node');
328
+ return shaka.drm.PlayReady.getLicenseUrl(reBuildProNode);
329
+ }
434
330
  }
435
331
 
436
- return ContentProtection.getLaurl_(rootElement);
332
+ return '';
437
333
  }
438
334
 
439
335
  /**
@@ -441,7 +337,7 @@ shaka.dash.ContentProtection = class {
441
337
  * containing a PlayReady Pro Object
442
338
  *
443
339
  * @param {shaka.dash.ContentProtection.Element} element
444
- * @return {?Array.<shaka.extern.InitDataOverride>}
340
+ * @return {?Array<shaka.extern.InitDataOverride>}
445
341
  * @private
446
342
  */
447
343
  static getInitDataFromPro_(element) {
@@ -453,7 +349,7 @@ shaka.dash.ContentProtection = class {
453
349
 
454
350
  const Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;
455
351
  const textContent =
456
- /** @type{string} */ (shaka.util.TXml.getTextContents(proNode));
352
+ /** @type {string} */ (shaka.util.TXml.getTextContents(proNode));
457
353
  const data = Uint8ArrayUtils.fromBase64(textContent);
458
354
  const systemId = new Uint8Array([
459
355
  0x9a, 0x04, 0xf0, 0x79, 0x98, 0x40, 0x42, 0x86,
@@ -476,8 +372,8 @@ shaka.dash.ContentProtection = class {
476
372
  * Creates ClearKey initData from Default_KID value retrieved from previously
477
373
  * parsed ContentProtection tag.
478
374
  * @param {shaka.dash.ContentProtection.Element} element
479
- * @param {!Set.<string>} keyIds
480
- * @return {?Array.<shaka.extern.InitDataOverride>}
375
+ * @param {!Set<string>} keyIds
376
+ * @return {?Array<shaka.extern.InitDataOverride>}
481
377
  * @private
482
378
  */
483
379
  static getInitDataClearKey_(element, keyIds) {
@@ -506,12 +402,12 @@ shaka.dash.ContentProtection = class {
506
402
  /**
507
403
  * Creates DrmInfo objects from the given element.
508
404
  *
509
- * @param {Array.<shaka.extern.InitDataOverride>} defaultInit
405
+ * @param {Array<shaka.extern.InitDataOverride>} defaultInit
510
406
  * @param {string} encryptionScheme
511
- * @param {!Array.<shaka.dash.ContentProtection.Element>} elements
512
- * @param {!Object.<string, string>} keySystemsByURI
513
- * @param {!Set.<string>} keyIds
514
- * @return {!Array.<shaka.extern.DrmInfo>}
407
+ * @param {!Array<shaka.dash.ContentProtection.Element>} elements
408
+ * @param {!Object<string, string>} keySystemsByURI
409
+ * @param {!Set<string>} keyIds
410
+ * @return {!Array<shaka.extern.DrmInfo>}
515
411
  * @private
516
412
  */
517
413
  static convertElements_(defaultInit, encryptionScheme, elements,
@@ -520,7 +416,7 @@ shaka.dash.ContentProtection = class {
520
416
  const ManifestParserUtils = shaka.util.ManifestParserUtils;
521
417
  const licenseUrlParsers = ContentProtection.licenseUrlParsers_;
522
418
 
523
- /** @type {!Array.<shaka.extern.DrmInfo>} */
419
+ /** @type {!Array<shaka.extern.DrmInfo>} */
524
420
  const out = [];
525
421
 
526
422
  for (const element of elements) {
@@ -557,16 +453,16 @@ shaka.dash.ContentProtection = class {
557
453
  * Parses the given ContentProtection elements. If there is an error, it
558
454
  * removes those elements.
559
455
  *
560
- * @param {!Array.<!shaka.extern.xml.Node>} elems
561
- * @return {!Array.<shaka.dash.ContentProtection.Element>}
456
+ * @param {!Array<!shaka.extern.xml.Node>} elements
457
+ * @return {!Array<shaka.dash.ContentProtection.Element>}
562
458
  * @private
563
459
  */
564
- static parseElements_(elems) {
565
- /** @type {!Array.<shaka.dash.ContentProtection.Element>} */
460
+ static parseElements_(elements) {
461
+ /** @type {!Array<shaka.dash.ContentProtection.Element>} */
566
462
  const out = [];
567
463
 
568
- for (const elem of elems) {
569
- const parsed = shaka.dash.ContentProtection.parseElement_(elem);
464
+ for (const element of elements) {
465
+ const parsed = shaka.dash.ContentProtection.parseElement_(element);
570
466
  if (parsed) {
571
467
  out.push(parsed);
572
468
  }
@@ -590,7 +486,7 @@ shaka.dash.ContentProtection = class {
590
486
  let schemeUri = elem.attributes['schemeIdUri'];
591
487
  /** @type {?string} */
592
488
  let keyId = TXml.getAttributeNS(elem, NS, 'default_KID');
593
- /** @type {!Array.<string>} */
489
+ /** @type {!Array<string>} */
594
490
  const psshs = TXml.findChildrenNS(elem, NS, 'pssh')
595
491
  .map(TXml.getContents);
596
492
 
@@ -613,7 +509,7 @@ shaka.dash.ContentProtection = class {
613
509
  }
614
510
  }
615
511
 
616
- /** @type {!Array.<shaka.extern.InitDataOverride>} */
512
+ /** @type {!Array<shaka.extern.InitDataOverride>} */
617
513
  let init = [];
618
514
  try {
619
515
  // Try parsing PSSH data.
@@ -715,37 +611,11 @@ shaka.dash.ContentProtection = class {
715
611
  }
716
612
  };
717
613
 
718
- /**
719
- * @typedef {{
720
- * type: number,
721
- * value: !Uint8Array
722
- * }}
723
- *
724
- * @description
725
- * The parsed result of a PlayReady object record.
726
- *
727
- * @property {number} type
728
- * Type of data stored in the record.
729
- * @property {!Uint8Array} value
730
- * Record content.
731
- */
732
- shaka.dash.ContentProtection.PlayReadyRecord;
733
-
734
- /**
735
- * Enum for PlayReady record types.
736
- * @enum {number}
737
- */
738
- shaka.dash.ContentProtection.PLAYREADY_RECORD_TYPES = {
739
- RIGHTS_MANAGEMENT: 0x001,
740
- RESERVED: 0x002,
741
- EMBEDDED_LICENSE: 0x003,
742
- };
743
-
744
614
  /**
745
615
  * @typedef {{
746
616
  * defaultKeyId: ?string,
747
- * defaultInit: Array.<shaka.extern.InitDataOverride>,
748
- * drmInfos: !Array.<shaka.extern.DrmInfo>,
617
+ * defaultInit: Array<shaka.extern.InitDataOverride>,
618
+ * drmInfos: !Array<shaka.extern.DrmInfo>,
749
619
  * aes128Info: ?shaka.dash.ContentProtection.Aes128Info,
750
620
  * firstRepresentation: boolean
751
621
  * }}
@@ -757,10 +627,10 @@ shaka.dash.ContentProtection.PLAYREADY_RECORD_TYPES = {
757
627
  * @property {?string} defaultKeyId
758
628
  * The default key ID to use. This is used by parseKeyIds as a default. This
759
629
  * can be null to indicate that there is no default.
760
- * @property {Array.<shaka.extern.InitDataOverride>} defaultInit
630
+ * @property {Array<shaka.extern.InitDataOverride>} defaultInit
761
631
  * The default init data override. This can be null to indicate that there
762
632
  * is no default.
763
- * @property {!Array.<shaka.extern.DrmInfo>} drmInfos
633
+ * @property {!Array<shaka.extern.DrmInfo>} drmInfos
764
634
  * The DrmInfo objects.
765
635
  * @property {?shaka.dash.ContentProtection.Aes128Info} aes128Info
766
636
  * The AES-128 key info.
@@ -794,7 +664,7 @@ shaka.dash.ContentProtection.Aes128Info;
794
664
  * node: !shaka.extern.xml.Node,
795
665
  * schemeUri: string,
796
666
  * keyId: ?string,
797
- * init: Array.<shaka.extern.InitDataOverride>,
667
+ * init: Array<shaka.extern.InitDataOverride>,
798
668
  * encryptionScheme: ?string
799
669
  * }}
800
670
  *
@@ -807,7 +677,7 @@ shaka.dash.ContentProtection.Aes128Info;
807
677
  * The scheme URI.
808
678
  * @property {?string} keyId
809
679
  * The default key ID, if present.
810
- * @property {Array.<shaka.extern.InitDataOverride>} init
680
+ * @property {Array<shaka.extern.InitDataOverride>} init
811
681
  * The init data, if present. If there is no init data, it will be null. If
812
682
  * this is non-null, there is at least one element.
813
683
  * @property {?string} encryptionScheme
@@ -818,7 +688,7 @@ shaka.dash.ContentProtection.Element;
818
688
  /**
819
689
  * A map of key system name to license server url parser.
820
690
  *
821
- * @const {!Map.<string, function(shaka.dash.ContentProtection.Element)>}
691
+ * @const {!Map<string, function(shaka.dash.ContentProtection.Element)>}
822
692
  * @private
823
693
  */
824
694
  shaka.dash.ContentProtection.licenseUrlParsers_ = new Map()