shaka-player 4.12.9 → 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 (259) 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 +36 -36
  9. package/dist/shaka-player.compiled.d.ts +131 -36
  10. package/dist/shaka-player.compiled.debug.d.ts +131 -36
  11. package/dist/shaka-player.compiled.debug.externs.js +355 -107
  12. package/dist/shaka-player.compiled.debug.js +799 -742
  13. package/dist/shaka-player.compiled.debug.map +4 -4
  14. package/dist/shaka-player.compiled.externs.js +355 -107
  15. package/dist/shaka-player.compiled.js +1456 -1423
  16. package/dist/shaka-player.compiled.map +4 -4
  17. package/dist/shaka-player.ui.d.ts +165 -38
  18. package/dist/shaka-player.ui.debug.d.ts +165 -38
  19. package/dist/shaka-player.ui.debug.externs.js +394 -113
  20. package/dist/shaka-player.ui.debug.js +808 -738
  21. package/dist/shaka-player.ui.debug.map +4 -4
  22. package/dist/shaka-player.ui.externs.js +394 -113
  23. package/dist/shaka-player.ui.js +1671 -1632
  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 +137 -108
  56. package/externs/shaka/text.js +3 -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 +34 -24
  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 +98 -108
  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 +14 -14
  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/manifest_filterer.js +8 -8
  102. package/lib/media/manifest_parser.js +2 -2
  103. package/lib/media/media_source_capabilities.js +20 -1
  104. package/lib/media/media_source_engine.js +71 -26
  105. package/lib/media/mp4_segment_index_parser.js +5 -5
  106. package/lib/media/playhead.js +2 -8
  107. package/lib/media/playhead_observer.js +1 -1
  108. package/lib/media/preference_based_criteria.js +333 -0
  109. package/lib/media/preload_manager.js +53 -37
  110. package/lib/media/presentation_timeline.js +2 -2
  111. package/lib/media/quality_observer.js +35 -35
  112. package/lib/media/region_observer.js +2 -2
  113. package/lib/media/region_timeline.js +3 -3
  114. package/lib/media/segment_index.js +14 -14
  115. package/lib/media/segment_prefetch.js +17 -13
  116. package/lib/media/segment_reference.js +7 -7
  117. package/lib/media/segment_utils.js +9 -9
  118. package/lib/media/streaming_engine.js +77 -38
  119. package/lib/media/time_ranges_utils.js +1 -1
  120. package/lib/media/video_wrapper.js +1 -1
  121. package/lib/media/webm_segment_index_parser.js +4 -4
  122. package/lib/mss/content_protection.js +17 -222
  123. package/lib/mss/mss_parser.js +23 -24
  124. package/lib/net/data_uri_plugin.js +1 -0
  125. package/lib/net/http_fetch_plugin.js +8 -7
  126. package/lib/net/http_plugin_utils.js +5 -2
  127. package/lib/net/http_xhr_plugin.js +4 -3
  128. package/lib/net/networking_engine.js +72 -17
  129. package/lib/net/networking_utils.js +5 -2
  130. package/lib/offline/download_info.js +5 -1
  131. package/lib/offline/download_manager.js +15 -4
  132. package/lib/offline/download_progress_estimator.js +1 -1
  133. package/lib/offline/indexeddb/base_storage_cell.js +9 -9
  134. package/lib/offline/indexeddb/db_connection.js +1 -1
  135. package/lib/offline/indexeddb/db_operation.js +2 -2
  136. package/lib/offline/indexeddb/eme_session_storage_cell.js +1 -1
  137. package/lib/offline/indexeddb/storage_mechanism.js +1 -1
  138. package/lib/offline/indexeddb/v1_storage_cell.js +3 -3
  139. package/lib/offline/indexeddb/v2_storage_cell.js +2 -2
  140. package/lib/offline/manifest_converter.js +11 -12
  141. package/lib/offline/offline_scheme.js +8 -4
  142. package/lib/offline/session_deleter.js +11 -11
  143. package/lib/offline/storage.js +137 -88
  144. package/lib/offline/storage_muxer.js +8 -8
  145. package/lib/offline/stored_content_utils.js +3 -3
  146. package/lib/offline/stream_bandwidth_estimator.js +1 -1
  147. package/lib/player.js +270 -207
  148. package/lib/polyfill/all.js +1 -1
  149. package/lib/polyfill/media_capabilities.js +5 -5
  150. package/lib/polyfill/patchedmediakeys_apple.js +6 -6
  151. package/lib/polyfill/patchedmediakeys_webkit.js +8 -8
  152. package/lib/polyfill/video_play_promise.js +0 -1
  153. package/lib/text/cue.js +3 -2
  154. package/lib/text/lrc_text_parser.js +1 -1
  155. package/lib/text/mp4_ttml_parser.js +1 -1
  156. package/lib/text/mp4_vtt_parser.js +3 -3
  157. package/lib/text/sbv_text_parser.js +1 -1
  158. package/lib/text/ssa_text_parser.js +3 -1
  159. package/lib/text/stub_text_displayer.js +5 -5
  160. package/lib/text/text_engine.js +5 -4
  161. package/lib/text/text_utils.js +4 -4
  162. package/lib/text/ttml_text_parser.js +21 -20
  163. package/lib/text/ui_text_displayer.js +13 -13
  164. package/lib/text/vtt_text_parser.js +10 -10
  165. package/lib/text/web_vtt_generator.js +2 -2
  166. package/lib/transmuxer/aac_transmuxer.js +2 -2
  167. package/lib/transmuxer/ac3_transmuxer.js +2 -2
  168. package/lib/transmuxer/adts.js +2 -0
  169. package/lib/transmuxer/ec3.js +3 -3
  170. package/lib/transmuxer/ec3_transmuxer.js +2 -2
  171. package/lib/transmuxer/h264.js +5 -5
  172. package/lib/transmuxer/h265.js +3 -3
  173. package/lib/transmuxer/mp3_transmuxer.js +2 -2
  174. package/lib/transmuxer/mpeg_audio.js +6 -6
  175. package/lib/transmuxer/mss_transmuxer.js +2 -0
  176. package/lib/transmuxer/transmuxer_engine.js +1 -1
  177. package/lib/transmuxer/ts_transmuxer.js +10 -10
  178. package/lib/util/abortable_operation.js +10 -10
  179. package/lib/util/array_utils.js +6 -6
  180. package/lib/util/cmcd_manager.js +149 -18
  181. package/lib/util/cmsd_manager.js +11 -11
  182. package/lib/util/config_utils.js +3 -3
  183. package/lib/util/content_steering_manager.js +17 -17
  184. package/lib/util/data_view_reader.js +3 -3
  185. package/lib/util/ebml_parser.js +1 -1
  186. package/lib/util/error.js +11 -6
  187. package/lib/util/event_manager.js +1 -1
  188. package/lib/util/exp_golomb.js +1 -1
  189. package/lib/util/fairplay_utils.js +6 -1
  190. package/lib/util/fake_event.js +3 -2
  191. package/lib/util/fake_event_target.js +1 -1
  192. package/lib/util/functional.js +8 -8
  193. package/lib/util/id3_utils.js +1 -1
  194. package/lib/util/iterables.js +6 -6
  195. package/lib/util/language_utils.js +17 -17
  196. package/lib/util/manifest_parser_utils.js +13 -13
  197. package/lib/util/map_utils.js +6 -6
  198. package/lib/util/media_ready_state_utils.js +1 -1
  199. package/lib/util/mime_utils.js +15 -4
  200. package/lib/util/mp4_box_parsers.js +5 -5
  201. package/lib/util/mp4_generator.js +31 -30
  202. package/lib/util/mp4_parser.js +2 -2
  203. package/lib/util/multi_map.js +5 -5
  204. package/lib/util/mutex.js +1 -1
  205. package/lib/util/networking.js +1 -1
  206. package/lib/util/object_utils.js +5 -1
  207. package/lib/util/operation_manager.js +1 -1
  208. package/lib/util/periods.js +24 -24
  209. package/lib/util/platform.js +8 -4
  210. package/lib/util/player_configuration.js +50 -17
  211. package/lib/util/pssh.js +34 -6
  212. package/lib/util/public_promise.js +2 -2
  213. package/lib/util/state_history.js +2 -2
  214. package/lib/util/stream_utils.js +138 -120
  215. package/lib/util/string_utils.js +4 -3
  216. package/lib/util/switch_history.js +2 -2
  217. package/lib/util/tXml.js +22 -17
  218. package/lib/util/text_parser.js +2 -2
  219. package/lib/util/timer.js +1 -1
  220. package/lib/util/ts_parser.js +22 -22
  221. package/lib/util/xml_utils.js +1 -0
  222. package/package.json +7 -4
  223. package/project-words.txt +485 -0
  224. package/shaka-player.uncompiled.js +1 -1
  225. package/third_party/closure-uri/uri.js +2 -2
  226. package/third_party/closure-uri/utils.js +2 -2
  227. package/third_party/language-mapping-list/language-mapping-list.js +1 -1
  228. package/ui/ad_statistics_button.js +9 -5
  229. package/ui/airplay_button.js +1 -0
  230. package/ui/audio_language_selection.js +2 -1
  231. package/ui/context_menu.js +2 -2
  232. package/ui/controls.js +7 -7
  233. package/ui/externs/ui.js +29 -21
  234. package/ui/externs/watermark.js +64 -0
  235. package/ui/fast_forward_button.js +1 -1
  236. package/ui/gl_matrix/matrix_4x4.js +11 -5
  237. package/ui/hidden_fast_forward_button.js +1 -1
  238. package/ui/hidden_seek_button.js +1 -1
  239. package/ui/language_utils.js +27 -26
  240. package/ui/less/buttons.less +2 -2
  241. package/ui/localization.js +21 -21
  242. package/ui/loop_button.js +2 -2
  243. package/ui/overflow_menu.js +2 -2
  244. package/ui/playback_rate_selection.js +1 -1
  245. package/ui/presentation_time.js +4 -1
  246. package/ui/range_element.js +2 -2
  247. package/ui/resolution_selection.js +42 -6
  248. package/ui/rewind_button.js +1 -1
  249. package/ui/seek_bar.js +5 -5
  250. package/ui/statistics_button.js +8 -4
  251. package/ui/text_selection.js +3 -2
  252. package/ui/ui.js +32 -2
  253. package/ui/vr_manager.js +3 -3
  254. package/ui/vr_utils.js +14 -14
  255. package/ui/vr_webgl.js +5 -5
  256. package/ui/watermark.js +313 -0
  257. package/.eslintignore +0 -4
  258. package/.eslintrc.js +0 -310
  259. package/lib/polyfill/patchedmediakeys_nop.js +0 -148
@@ -57,7 +57,7 @@ shaka.dash.DashParser = class {
57
57
  /** @private {?shaka.extern.ManifestParser.PlayerInterface} */
58
58
  this.playerInterface_ = null;
59
59
 
60
- /** @private {!Array.<string>} */
60
+ /** @private {!Array<string>} */
61
61
  this.manifestUris_ = [];
62
62
 
63
63
  /** @private {?shaka.extern.Manifest} */
@@ -98,20 +98,20 @@ shaka.dash.DashParser = class {
98
98
  * A map of IDs to Stream objects.
99
99
  * ID: Period@id,Representation@id
100
100
  * e.g.: '1,23'
101
- * @private {!Object.<string, !shaka.extern.Stream>}
101
+ * @private {!Object<string, !shaka.extern.Stream>}
102
102
  */
103
103
  this.streamMap_ = {};
104
104
 
105
105
  /**
106
106
  * A map of Period IDs to Stream Map IDs.
107
107
  * Use to have direct access to streamMap key.
108
- * @private {!Object.<string, !Array<string>>}
108
+ * @private {!Object<string, !Array<string>>}
109
109
  */
110
110
  this.indexStreamMap_ = {};
111
111
 
112
112
  /**
113
113
  * A map of period ids to their durations
114
- * @private {!Object.<string, number>}
114
+ * @private {!Object<string, number>}
115
115
  */
116
116
  this.periodDurations_ = {};
117
117
 
@@ -155,7 +155,7 @@ shaka.dash.DashParser = class {
155
155
 
156
156
  /**
157
157
  * Period IDs seen in previous manifest.
158
- * @private {!Array.<string>}
158
+ * @private {!Array<string>}
159
159
  */
160
160
  this.lastManifestUpdatePeriodIds_ = [];
161
161
 
@@ -193,7 +193,7 @@ shaka.dash.DashParser = class {
193
193
  /** @private {function():boolean} */
194
194
  this.isPreloadFn_ = () => false;
195
195
 
196
- /** @private {?Array.<string>} */
196
+ /** @private {?Array<string>} */
197
197
  this.lastCalculatedBaseUris_ = [];
198
198
  }
199
199
 
@@ -382,7 +382,7 @@ shaka.dash.DashParser = class {
382
382
  /**
383
383
  * Makes a network request for the manifest and parses the resulting data.
384
384
  *
385
- * @return {!Promise.<number>} Resolves with the time it took, in seconds, to
385
+ * @return {!Promise<number>} Resolves with the time it took, in seconds, to
386
386
  * fulfill the request and parse the data.
387
387
  * @private
388
388
  */
@@ -525,11 +525,11 @@ shaka.dash.DashParser = class {
525
525
 
526
526
  // Get any Location elements. This will update the manifest location and
527
527
  // the base URI.
528
- /** @type {!Array.<string>} */
528
+ /** @type {!Array<string>} */
529
529
  let manifestBaseUris = [finalManifestUri];
530
- /** @type {!Array.<string>} */
530
+ /** @type {!Array<string>} */
531
531
  const locations = [];
532
- /** @type {!Map.<string, string>} */
532
+ /** @type {!Map<string, string>} */
533
533
  const locationsMapping = new Map();
534
534
  const locationsObjs = TXml.findChildren(mpd, 'Location');
535
535
  for (const locationsObj of locationsObjs) {
@@ -551,11 +551,11 @@ shaka.dash.DashParser = class {
551
551
  locations.push(finalUri);
552
552
  }
553
553
  if (this.contentSteeringManager_) {
554
- const steeringlocations = this.contentSteeringManager_.getLocations(
554
+ const steeringLocations = this.contentSteeringManager_.getLocations(
555
555
  'Location', /* ignoreBaseUrls= */ true);
556
- if (steeringlocations.length > 0) {
557
- this.manifestUris_ = steeringlocations;
558
- manifestBaseUris = steeringlocations;
556
+ if (steeringLocations.length > 0) {
557
+ this.manifestUris_ = steeringLocations;
558
+ manifestBaseUris = steeringLocations;
559
559
  }
560
560
  } else if (locations.length) {
561
561
  this.manifestUris_ = locations;
@@ -643,13 +643,6 @@ shaka.dash.DashParser = class {
643
643
  }
644
644
  this.manifestPatchContext_.availabilityTimeOffset = availabilityTimeOffset;
645
645
 
646
- const ignoreMinBufferTime = this.config_.dash.ignoreMinBufferTime;
647
- let minBufferTime = 0;
648
- if (!ignoreMinBufferTime) {
649
- minBufferTime =
650
- TXml.parseAttr(mpd, 'minBufferTime', TXml.parseDuration) || 0;
651
- }
652
-
653
646
  this.updatePeriod_ = /** @type {number} */ (TXml.parseAttr(
654
647
  mpd, 'minimumUpdatePeriod', TXml.parseDuration, -1));
655
648
 
@@ -703,6 +696,12 @@ shaka.dash.DashParser = class {
703
696
  }
704
697
  }
705
698
  } else {
699
+ const ignoreMinBufferTime = this.config_.dash.ignoreMinBufferTime;
700
+ let minBufferTime = 0;
701
+ if (!ignoreMinBufferTime) {
702
+ minBufferTime =
703
+ TXml.parseAttr(mpd, 'minBufferTime', TXml.parseDuration) || 0;
704
+ }
706
705
  // DASH IOP v3.0 suggests using a default delay between minBufferTime
707
706
  // and timeShiftBufferDepth. This is literally the range of all
708
707
  // feasible choices for the value. Nothing older than
@@ -784,20 +783,7 @@ shaka.dash.DashParser = class {
784
783
  presentationTimeline.setDuration(duration || Infinity);
785
784
  }
786
785
 
787
- // The segments are available earlier than the availability start time.
788
- // If the stream is low latency and the user has not configured the
789
- // lowLatencyMode, but if it has been configured to activate the
790
- // lowLatencyMode if a stream of this type is detected, we automatically
791
- // activate the lowLatencyMode.
792
- if (this.isLowLatency_ && !this.lowLatencyMode_) {
793
- const autoLowLatencyMode = this.playerInterface_.isAutoLowLatencyMode();
794
- if (autoLowLatencyMode) {
795
- this.playerInterface_.enableLowLatencyMode();
796
- this.lowLatencyMode_ = this.playerInterface_.isLowLatencyMode();
797
- }
798
- }
799
-
800
- if (this.lowLatencyMode_) {
786
+ if (this.isLowLatency_ && this.lowLatencyMode_) {
801
787
  presentationTimeline.setAvailabilityTimeOffset(
802
788
  this.minTotalAvailabilityTimeOffset_);
803
789
  }
@@ -810,10 +796,7 @@ shaka.dash.DashParser = class {
810
796
 
811
797
  await contentSteeringPromise;
812
798
 
813
- // Set minBufferTime to 0 for low-latency DASH live stream to achieve the
814
- // best latency
815
- if (this.lowLatencyMode_) {
816
- minBufferTime = 0;
799
+ if (this.isLowLatency_ && this.lowLatencyMode_) {
817
800
  const presentationDelay = suggestedPresentationDelay != null ?
818
801
  suggestedPresentationDelay : this.config_.defaultPresentationDelay;
819
802
  presentationTimeline.setDelay(presentationDelay);
@@ -829,7 +812,6 @@ shaka.dash.DashParser = class {
829
812
  textStreams: this.periodCombiner_.getTextStreams(),
830
813
  imageStreams: this.periodCombiner_.getImageStreams(),
831
814
  offlineSessionIds: [],
832
- minBufferTime: minBufferTime || 0,
833
815
  sequenceMode: this.config_.dash.sequenceMode,
834
816
  ignoreManifestTimestampsInSegmentsMode: false,
835
817
  type: shaka.media.ManifestParser.DASH,
@@ -996,7 +978,7 @@ shaka.dash.DashParser = class {
996
978
 
997
979
  /**
998
980
  * Handles manifest type changes, this transition is expected to be
999
- * "dyanmic" to "static".
981
+ * "dynamic" to "static".
1000
982
  *
1001
983
  * @param {!string} mpdType
1002
984
  * @private
@@ -1320,11 +1302,11 @@ shaka.dash.DashParser = class {
1320
1302
  * children.
1321
1303
  *
1322
1304
  * @param {shaka.dash.DashParser.Context} context
1323
- * @param {function():!Array.<string>} getBaseUris
1305
+ * @param {function(): !Array<string>} getBaseUris
1324
1306
  * @param {!shaka.extern.xml.Node} mpd
1325
1307
  * @param {!boolean} newPeriod
1326
1308
  * @return {{
1327
- * periods: !Array.<shaka.extern.Period>,
1309
+ * periods: !Array<shaka.extern.Period>,
1328
1310
  * duration: ?number,
1329
1311
  * durationDerivedFromPeriods: boolean
1330
1312
  * }}
@@ -1481,8 +1463,8 @@ shaka.dash.DashParser = class {
1481
1463
  if (prevEnd != null) {
1482
1464
  const threshold =
1483
1465
  shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS;
1484
- const diference = prevEnd - seekRangeStart - presentationDuration;
1485
- if (Math.abs(diference) > threshold) {
1466
+ const difference = prevEnd - seekRangeStart - presentationDuration;
1467
+ if (Math.abs(difference) > threshold) {
1486
1468
  shaka.log.warning(
1487
1469
  '@mediaPresentationDuration does not match the total duration ',
1488
1470
  'of all Periods.');
@@ -1540,7 +1522,7 @@ shaka.dash.DashParser = class {
1540
1522
  * was done before this was called so start and duration are valid.
1541
1523
  *
1542
1524
  * @param {shaka.dash.DashParser.Context} context
1543
- * @param {function():!Array.<string>} getBaseUris
1525
+ * @param {function(): !Array<string>} getBaseUris
1544
1526
  * @param {shaka.dash.DashParser.PeriodInfo} periodInfo
1545
1527
  * @return {shaka.extern.Period}
1546
1528
  * @private
@@ -1672,10 +1654,10 @@ shaka.dash.DashParser = class {
1672
1654
  * Gets the streams from the given sets or returns an empty array if disabled
1673
1655
  * or no streams are found.
1674
1656
  * @param {boolean} disabled
1675
- * @param {!Array.<!shaka.dash.DashParser.AdaptationInfo>} adaptationSets
1657
+ * @param {!Array<!shaka.dash.DashParser.AdaptationInfo>} adaptationSets
1676
1658
  * @param {string} contentType
1677
- @private
1678
- */
1659
+ * @private
1660
+ */
1679
1661
  getStreamsFromSets_(disabled, adaptationSets, contentType) {
1680
1662
  if (disabled || !adaptationSets.length) {
1681
1663
  return [];
@@ -1896,7 +1878,7 @@ shaka.dash.DashParser = class {
1896
1878
  // Some closed caption descriptions have channel number and
1897
1879
  // language ("CC1=eng") others may only have language ("eng,spa").
1898
1880
  if (!captionStr.includes('=')) {
1899
- // When the channel assignemnts are not explicitly provided and
1881
+ // When the channel assignments are not explicitly provided and
1900
1882
  // there are only 2 values provided, it is highly likely that the
1901
1883
  // assignments are CC1 and CC3 (most commonly used CC streams).
1902
1884
  // Otherwise, cycle through all channels arbitrarily (CC1 - CC4)
@@ -1943,7 +1925,7 @@ shaka.dash.DashParser = class {
1943
1925
  language = captionStr;
1944
1926
  } else {
1945
1927
  // Otherwise, CEA-708 caption values take the form "
1946
- // 1=lang:eng;2=lang:deu" i.e. serviceNumber=lang:threelettercode.
1928
+ // 1=lang:eng;2=lang:deu" i.e. serviceNumber=lang:threeLetterCode.
1947
1929
  const serviceAndLanguage = captionStr.split('=');
1948
1930
  service = `svc${serviceAndLanguage[0]}`;
1949
1931
 
@@ -1978,10 +1960,10 @@ shaka.dash.DashParser = class {
1978
1960
  }
1979
1961
  }
1980
1962
 
1981
- const contentProtectionElems =
1963
+ const contentProtectionElements =
1982
1964
  TXml.findChildren(elem, 'ContentProtection');
1983
1965
  const contentProtection = ContentProtection.parseFromAdaptationSet(
1984
- contentProtectionElems,
1966
+ contentProtectionElements,
1985
1967
  this.config_.dash.ignoreDrmInfo,
1986
1968
  this.config_.dash.keySystemsByURI);
1987
1969
 
@@ -1992,6 +1974,20 @@ shaka.dash.DashParser = class {
1992
1974
 
1993
1975
  // Parse Representations into Streams.
1994
1976
  const representations = TXml.findChildren(elem, 'Representation');
1977
+ if (!this.config_.dash.ignoreSupplementalCodecs) {
1978
+ const supplementalRepresentations = [];
1979
+ for (const rep of representations) {
1980
+ const supplementalCodecs = TXml.getAttributeNS(
1981
+ rep, shaka.dash.DashParser.SCTE214_, 'supplementalCodecs');
1982
+ if (supplementalCodecs) {
1983
+ // Duplicate representations with their supplementalCodecs
1984
+ const obj = shaka.util.ObjectUtils.cloneObject(rep);
1985
+ obj.attributes['codecs'] = supplementalCodecs.split(' ').join(',');
1986
+ supplementalRepresentations.push(obj);
1987
+ }
1988
+ }
1989
+ representations.push(...supplementalRepresentations);
1990
+ }
1995
1991
  const streams = representations.map((representation) => {
1996
1992
  const parsedRepresentation = this.parseRepresentation_(context,
1997
1993
  contentProtection, kind, language, label, main, roleValues,
@@ -2118,11 +2114,11 @@ shaka.dash.DashParser = class {
2118
2114
  * @param {string} language
2119
2115
  * @param {?string} label
2120
2116
  * @param {boolean} isPrimary
2121
- * @param {!Array.<string>} roles
2122
- * @param {Map.<string, string>} closedCaptions
2117
+ * @param {!Array<string>} roles
2118
+ * @param {Map<string, string>} closedCaptions
2123
2119
  * @param {!shaka.extern.xml.Node} node
2124
- * @param {?shaka.media.ManifestParser.AccessibilityPurpose}
2125
- * accessibilityPurpose
2120
+ * @param {?shaka.media.ManifestParser.AccessibilityPurpose
2121
+ * } accessibilityPurpose
2126
2122
  * @param {?number} lastSegmentNumber
2127
2123
  *
2128
2124
  * @return {?shaka.extern.Stream} The Stream, or null when there is a
@@ -2162,13 +2158,13 @@ shaka.dash.DashParser = class {
2162
2158
 
2163
2159
  context.roles = roles;
2164
2160
 
2165
- const supplementalPropertyElems =
2161
+ const supplementalPropertyElements =
2166
2162
  TXml.findChildren(node, 'SupplementalProperty');
2167
- const essentialPropertyElems =
2163
+ const essentialPropertyElements =
2168
2164
  TXml.findChildren(node, 'EssentialProperty');
2169
2165
 
2170
2166
  let representationUrlParams = null;
2171
- let urlParamsElement = essentialPropertyElems.find((element) => {
2167
+ let urlParamsElement = essentialPropertyElements.find((element) => {
2172
2168
  const schemeId = element.attributes['schemeIdUri'];
2173
2169
  return schemeId == 'urn:mpeg:dash:urlparam:2014';
2174
2170
  });
@@ -2176,7 +2172,7 @@ shaka.dash.DashParser = class {
2176
2172
  representationUrlParams =
2177
2173
  this.getURLParametersFunction_(urlParamsElement);
2178
2174
  } else {
2179
- urlParamsElement = supplementalPropertyElems.find((element) => {
2175
+ urlParamsElement = supplementalPropertyElements.find((element) => {
2180
2176
  const schemeId = element.attributes['schemeIdUri'];
2181
2177
  return schemeId == 'urn:mpeg:dash:urlparam:2014';
2182
2178
  });
@@ -2290,17 +2286,17 @@ shaka.dash.DashParser = class {
2290
2286
  throw error;
2291
2287
  }
2292
2288
 
2293
- const contentProtectionElems =
2289
+ const contentProtectionElements =
2294
2290
  TXml.findChildren(node, 'ContentProtection');
2295
2291
  const keyId = shaka.dash.ContentProtection.parseFromRepresentation(
2296
- contentProtectionElems, contentProtection,
2292
+ contentProtectionElements, contentProtection,
2297
2293
  this.config_.dash.ignoreDrmInfo,
2298
2294
  this.config_.dash.keySystemsByURI);
2299
2295
  const keyIds = new Set(keyId ? [keyId] : []);
2300
2296
 
2301
2297
  // Detect the presence of E-AC3 JOC audio content, using DD+JOC signaling.
2302
2298
  // See: ETSI TS 103 420 V1.2.1 (2018-10)
2303
- const hasJoc = supplementalPropertyElems.some((element) => {
2299
+ const hasJoc = supplementalPropertyElements.some((element) => {
2304
2300
  const expectedUri = 'tag:dolby.com,2018:dash:EC3_ExtensionType:2018';
2305
2301
  const expectedValue = 'JOC';
2306
2302
  return element.attributes['schemeIdUri'] == expectedUri &&
@@ -2325,7 +2321,7 @@ shaka.dash.DashParser = class {
2325
2321
 
2326
2322
  let tilesLayout;
2327
2323
  if (isImage) {
2328
- const thumbnailTileElem = essentialPropertyElems.find((element) => {
2324
+ const thumbnailTileElem = essentialPropertyElements.find((element) => {
2329
2325
  const expectedUris = [
2330
2326
  'http://dashif.org/thumbnail_tile',
2331
2327
  'http://dashif.org/guidelines/thumbnail_tile',
@@ -2556,14 +2552,13 @@ shaka.dash.DashParser = class {
2556
2552
  *
2557
2553
  * @param {!shaka.extern.xml.Node} elem
2558
2554
  * @param {?shaka.dash.DashParser.InheritanceFrame} parent
2559
- * @param {?function():!Array.<string>} getBaseUris
2555
+ * @param {?function(): !Array<string>} getBaseUris
2560
2556
  * @return {shaka.dash.DashParser.InheritanceFrame}
2561
2557
  * @private
2562
2558
  */
2563
2559
  createFrame_(elem, parent, getBaseUris) {
2564
2560
  goog.asserts.assert(parent || getBaseUris,
2565
2561
  'Must provide either parent or getBaseUris');
2566
- const SCTE214 = shaka.dash.DashParser.SCTE214_;
2567
2562
  const SegmentUtils = shaka.media.SegmentUtils;
2568
2563
  const ManifestParserUtils = shaka.util.ManifestParserUtils;
2569
2564
  const TXml = shaka.util.TXml;
@@ -2621,11 +2616,6 @@ shaka.dash.DashParser = class {
2621
2616
  const allCodecs = [
2622
2617
  elem.attributes['codecs'] || parent.codecs,
2623
2618
  ];
2624
- const supplementalCodecs =
2625
- TXml.getAttributeNS(elem, SCTE214, 'supplementalCodecs');
2626
- if (supplementalCodecs) {
2627
- allCodecs.push(supplementalCodecs);
2628
- }
2629
2619
  const codecs = SegmentUtils.codecsFiltering(allCodecs).join(',');
2630
2620
  const frameRate =
2631
2621
  TXml.parseAttr(elem, 'frameRate', evalDivision) || parent.frameRate;
@@ -2721,12 +2711,12 @@ shaka.dash.DashParser = class {
2721
2711
  * of the ones parsed from inBandEventStreams and the ones provided in
2722
2712
  * emsgSchemeIdUris.
2723
2713
  *
2724
- * @param {!Array.<!shaka.extern.xml.Node>} inBandEventStreams
2714
+ * @param {!Array<!shaka.extern.xml.Node>} inBandEventStreams
2725
2715
  * Array of InbandEventStream
2726
2716
  * elements to parse and add to the returned array.
2727
- * @param {!Array.<string>} emsgSchemeIdUris Array of parsed
2717
+ * @param {!Array<string>} emsgSchemeIdUris Array of parsed
2728
2718
  * InbandEventStream schemeIdUri attributes to add to the returned array.
2729
- * @return {!Array.<string>} schemeIdUris Array of parsed
2719
+ * @return {!Array<string>} schemeIdUris Array of parsed
2730
2720
  * InbandEventStream schemeIdUri attributes.
2731
2721
  * @private
2732
2722
  */
@@ -2742,7 +2732,7 @@ shaka.dash.DashParser = class {
2742
2732
  }
2743
2733
 
2744
2734
  /**
2745
- * @param {!Array.<!shaka.extern.xml.Node>} audioChannelConfigs An array of
2735
+ * @param {!Array<!shaka.extern.xml.Node>} audioChannelConfigs An array of
2746
2736
  * AudioChannelConfiguration elements.
2747
2737
  * @return {?number} The number of audio channels, or null if unknown.
2748
2738
  * @private
@@ -2909,10 +2899,10 @@ shaka.dash.DashParser = class {
2909
2899
  /**
2910
2900
  * Makes a request to the given URI and calculates the clock offset.
2911
2901
  *
2912
- * @param {function():!Array.<string>} getBaseUris
2902
+ * @param {function(): !Array<string>} getBaseUris
2913
2903
  * @param {string} uri
2914
2904
  * @param {string} method
2915
- * @return {!Promise.<number>}
2905
+ * @return {!Promise<number>}
2916
2906
  * @private
2917
2907
  */
2918
2908
  async requestForTiming_(getBaseUris, uri, method) {
@@ -2952,13 +2942,13 @@ shaka.dash.DashParser = class {
2952
2942
  /**
2953
2943
  * Parses an array of UTCTiming elements.
2954
2944
  *
2955
- * @param {function():!Array.<string>} getBaseUris
2956
- * @param {!Array.<!shaka.extern.xml.Node>} elems
2957
- * @return {!Promise.<number>}
2945
+ * @param {function(): !Array<string>} getBaseUris
2946
+ * @param {!Array<!shaka.extern.xml.Node>} elements
2947
+ * @return {!Promise<number>}
2958
2948
  * @private
2959
2949
  */
2960
- async parseUtcTiming_(getBaseUris, elems) {
2961
- const schemesAndValues = elems.map((elem) => {
2950
+ async parseUtcTiming_(getBaseUris, elements) {
2951
+ const schemesAndValues = elements.map((elem) => {
2962
2952
  return {
2963
2953
  scheme: elem.attributes['schemeIdUri'],
2964
2954
  value: elem.attributes['value'],
@@ -3080,11 +3070,11 @@ shaka.dash.DashParser = class {
3080
3070
  /**
3081
3071
  * Makes a network request on behalf of SegmentBase.createStreamInfo.
3082
3072
  *
3083
- * @param {!Array.<string>} uris
3073
+ * @param {!Array<string>} uris
3084
3074
  * @param {?number} startByte
3085
3075
  * @param {?number} endByte
3086
3076
  * @param {boolean} isInit
3087
- * @return {!Promise.<BufferSource>}
3077
+ * @return {!Promise<BufferSource>}
3088
3078
  * @private
3089
3079
  */
3090
3080
  async requestSegment_(uris, startByte, endByte, isInit) {
@@ -3135,7 +3125,7 @@ shaka.dash.DashParser = class {
3135
3125
  * @param {shaka.extern.Request} request
3136
3126
  * @param {shaka.net.NetworkingEngine.RequestType} type
3137
3127
  * @param {shaka.extern.RequestContext=} context
3138
- * @return {!Promise.<shaka.extern.Response>}
3128
+ * @return {!Promise<shaka.extern.Response>}
3139
3129
  * @private
3140
3130
  */
3141
3131
  makeNetworkRequest_(request, type, context) {
@@ -3190,9 +3180,9 @@ shaka.dash.DashParser = class {
3190
3180
  * mpdId: string,
3191
3181
  * type: string,
3192
3182
  * mediaPresentationDuration: ?number,
3193
- * profiles: !Array.<string>,
3183
+ * profiles: !Array<string>,
3194
3184
  * availabilityTimeOffset: number,
3195
- * getBaseUris: ?function():!Array.<string>,
3185
+ * getBaseUris: ?function():!Array<string>,
3196
3186
  * publishTime: number
3197
3187
  * }}
3198
3188
  *
@@ -3202,12 +3192,12 @@ shaka.dash.DashParser = class {
3202
3192
  * Specifies the type of the dash manifest i.e. "static"
3203
3193
  * @property {?number} mediaPresentationDuration
3204
3194
  * Media presentation duration, or null if unknown.
3205
- * @property {!Array.<string>} profiles
3195
+ * @property {!Array<string>} profiles
3206
3196
  * Profiles of DASH are defined to enable interoperability and the
3207
3197
  * signaling of the use of features.
3208
3198
  * @property {number} availabilityTimeOffset
3209
3199
  * Specifies the total availabilityTimeOffset of the segment.
3210
- * @property {?function():!Array.<string>} getBaseUris
3200
+ * @property {?function():!Array<string>} getBaseUris
3211
3201
  * An array of absolute base URIs.
3212
3202
  * @property {number} publishTime
3213
3203
  * Time when manifest has been published, in seconds.
@@ -3231,8 +3221,8 @@ shaka.dash.DashParser.UP_NAMESPACE_ = 'urn:mpeg:dash:schema:urlparam:2014';
3231
3221
 
3232
3222
  /**
3233
3223
  * @typedef {
3234
- * function(!Array.<string>, ?number, ?number, boolean):
3235
- * !Promise.<BufferSource>
3224
+ * function(!Array<string>, ?number, ?number, boolean):
3225
+ * !Promise<BufferSource>
3236
3226
  * }
3237
3227
  */
3238
3228
  shaka.dash.DashParser.RequestSegmentCallback;
@@ -3243,7 +3233,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
3243
3233
  * segmentBase: ?shaka.extern.xml.Node,
3244
3234
  * segmentList: ?shaka.extern.xml.Node,
3245
3235
  * segmentTemplate: ?shaka.extern.xml.Node,
3246
- * getBaseUris: function():!Array.<string>,
3236
+ * getBaseUris: function():!Array<string>,
3247
3237
  * width: (number|undefined),
3248
3238
  * height: (number|undefined),
3249
3239
  * contentType: string,
@@ -3251,7 +3241,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
3251
3241
  * codecs: string,
3252
3242
  * frameRate: (number|undefined),
3253
3243
  * pixelAspectRatio: (string|undefined),
3254
- * emsgSchemeIdUris: !Array.<string>,
3244
+ * emsgSchemeIdUris: !Array<string>,
3255
3245
  * id: ?string,
3256
3246
  * position: (number|undefined),
3257
3247
  * language: ?string,
@@ -3274,7 +3264,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
3274
3264
  * The XML node for SegmentList.
3275
3265
  * @property {?shaka.extern.xml.Node} segmentTemplate
3276
3266
  * The XML node for SegmentTemplate.
3277
- * @property {function():!Array.<string>} getBaseUris
3267
+ * @property {function():!Array<string>} getBaseUris
3278
3268
  * Function than returns an array of absolute base URIs for the frame.
3279
3269
  * @property {(number|undefined)} width
3280
3270
  * The inherited width value.
@@ -3290,7 +3280,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
3290
3280
  * The inherited framerate value.
3291
3281
  * @property {(string|undefined)} pixelAspectRatio
3292
3282
  * The inherited pixel aspect ratio value.
3293
- * @property {!Array.<string>} emsgSchemeIdUris
3283
+ * @property {!Array<string>} emsgSchemeIdUris
3294
3284
  * emsg registered schemeIdUris.
3295
3285
  * @property {?string} id
3296
3286
  * The ID of the element.
@@ -3329,8 +3319,8 @@ shaka.dash.DashParser.InheritanceFrame;
3329
3319
  * indexRangeWarningGiven: boolean,
3330
3320
  * availabilityTimeOffset: number,
3331
3321
  * mediaPresentationDuration: ?number,
3332
- * profiles: !Array.<string>,
3333
- * roles: ?Array.<string>,
3322
+ * profiles: !Array<string>,
3323
+ * roles: ?Array<string>,
3334
3324
  * urlParams: function():string
3335
3325
  * }}
3336
3326
  *
@@ -3357,7 +3347,7 @@ shaka.dash.DashParser.InheritanceFrame;
3357
3347
  * True if the warning about SegmentURL@indexRange has been printed.
3358
3348
  * @property {number} availabilityTimeOffset
3359
3349
  * The sum of the availabilityTimeOffset values that apply to the element.
3360
- * @property {!Array.<string>} profiles
3350
+ * @property {!Array<string>} profiles
3361
3351
  * Profiles of DASH are defined to enable interoperability and the signaling
3362
3352
  * of the use of features.
3363
3353
  * @property {?number} mediaPresentationDuration
@@ -3398,10 +3388,10 @@ shaka.dash.DashParser.PeriodInfo;
3398
3388
  * contentType: ?string,
3399
3389
  * language: string,
3400
3390
  * main: boolean,
3401
- * streams: !Array.<shaka.extern.Stream>,
3402
- * drmInfos: !Array.<shaka.extern.DrmInfo>,
3391
+ * streams: !Array<shaka.extern.Stream>,
3392
+ * drmInfos: !Array<shaka.extern.DrmInfo>,
3403
3393
  * trickModeFor: ?string,
3404
- * representationIds: !Array.<string>
3394
+ * representationIds: !Array<string>
3405
3395
  * }}
3406
3396
  *
3407
3397
  * @description
@@ -3415,22 +3405,22 @@ shaka.dash.DashParser.PeriodInfo;
3415
3405
  * The language of the AdaptationSet.
3416
3406
  * @property {boolean} main
3417
3407
  * Whether the AdaptationSet has the 'main' type.
3418
- * @property {!Array.<shaka.extern.Stream>} streams
3408
+ * @property {!Array<shaka.extern.Stream>} streams
3419
3409
  * The streams this AdaptationSet contains.
3420
- * @property {!Array.<shaka.extern.DrmInfo>} drmInfos
3410
+ * @property {!Array<shaka.extern.DrmInfo>} drmInfos
3421
3411
  * The DRM info for the AdaptationSet.
3422
3412
  * @property {?string} trickModeFor
3423
3413
  * If non-null, this AdaptationInfo represents trick mode tracks. This
3424
3414
  * property is the ID of the normal AdaptationSet these tracks should be
3425
3415
  * associated with.
3426
- * @property {!Array.<string>} representationIds
3416
+ * @property {!Array<string>} representationIds
3427
3417
  * An array of the IDs of the Representations this AdaptationSet contains.
3428
3418
  */
3429
3419
  shaka.dash.DashParser.AdaptationInfo;
3430
3420
 
3431
3421
 
3432
3422
  /**
3433
- * @typedef {function():!Promise.<shaka.media.SegmentIndex>}
3423
+ * @typedef {function(): !Promise<shaka.media.SegmentIndex>}
3434
3424
  * @description
3435
3425
  * An async function which generates and returns a SegmentIndex.
3436
3426
  */
@@ -3446,8 +3436,8 @@ shaka.dash.DashParser.GenerateSegmentIndexFunction;
3446
3436
  * Contains information about a Stream. This is passed from the createStreamInfo
3447
3437
  * methods.
3448
3438
  *
3449
- * @property {shaka.dash.DashParser.GenerateSegmentIndexFunction}
3450
- * generateSegmentIndex
3439
+ * @property {shaka.dash.DashParser.GenerateSegmentIndexFunction
3440
+ * } generateSegmentIndex
3451
3441
  * An async function to create the SegmentIndex for the stream.
3452
3442
  */
3453
3443
  shaka.dash.DashParser.StreamInfo;