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
@@ -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,23 +696,39 @@ 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
709
708
  // timeShiftBufferDepth is still available, and anything less than
710
709
  // minBufferTime will cause buffering issues.
711
- //
712
- // We have decided that our default will be the configured value, or
713
- // 1.5 * minBufferTime if not configured. This is fairly conservative.
714
- // Content providers should provide a suggestedPresentationDelay whenever
715
- // possible to optimize the live streaming experience.
716
- const defaultPresentationDelay =
717
- this.config_.defaultPresentationDelay || minBufferTime * 1.5;
718
- const presentationDelay = suggestedPresentationDelay != null ?
719
- suggestedPresentationDelay : defaultPresentationDelay;
710
+ let delay = 0;
711
+ if (suggestedPresentationDelay != null) {
712
+ // 1. If a suggestedPresentationDelay is provided by the manifest, that
713
+ // will be used preferentially.
714
+ // This is given a minimum bound of segmentAvailabilityDuration.
715
+ // Content providers should provide a suggestedPresentationDelay
716
+ // whenever possible to optimize the live streaming experience.
717
+ delay = Math.min(
718
+ suggestedPresentationDelay,
719
+ segmentAvailabilityDuration || Infinity);
720
+ } else if (this.config_.defaultPresentationDelay > 0) {
721
+ // 2. If the developer provides a value for
722
+ // "manifest.defaultPresentationDelay", that is used as a fallback.
723
+ delay = this.config_.defaultPresentationDelay;
724
+ } else {
725
+ // 3. Otherwise, we default to the lower of segmentAvailabilityDuration
726
+ // and 1.5 * minBufferTime. This is fairly conservative.
727
+ delay = Math.min(
728
+ minBufferTime * 1.5, segmentAvailabilityDuration || Infinity);
729
+ }
720
730
  presentationTimeline = new shaka.media.PresentationTimeline(
721
- presentationStartTime, presentationDelay,
722
- this.config_.dash.autoCorrectDrift);
731
+ presentationStartTime, delay, this.config_.dash.autoCorrectDrift);
723
732
  }
724
733
 
725
734
  presentationTimeline.setStatic(mpdType == 'static');
@@ -774,20 +783,7 @@ shaka.dash.DashParser = class {
774
783
  presentationTimeline.setDuration(duration || Infinity);
775
784
  }
776
785
 
777
- // The segments are available earlier than the availability start time.
778
- // If the stream is low latency and the user has not configured the
779
- // lowLatencyMode, but if it has been configured to activate the
780
- // lowLatencyMode if a stream of this type is detected, we automatically
781
- // activate the lowLatencyMode.
782
- if (this.isLowLatency_ && !this.lowLatencyMode_) {
783
- const autoLowLatencyMode = this.playerInterface_.isAutoLowLatencyMode();
784
- if (autoLowLatencyMode) {
785
- this.playerInterface_.enableLowLatencyMode();
786
- this.lowLatencyMode_ = this.playerInterface_.isLowLatencyMode();
787
- }
788
- }
789
-
790
- if (this.lowLatencyMode_) {
786
+ if (this.isLowLatency_ && this.lowLatencyMode_) {
791
787
  presentationTimeline.setAvailabilityTimeOffset(
792
788
  this.minTotalAvailabilityTimeOffset_);
793
789
  }
@@ -800,10 +796,7 @@ shaka.dash.DashParser = class {
800
796
 
801
797
  await contentSteeringPromise;
802
798
 
803
- // Set minBufferTime to 0 for low-latency DASH live stream to achieve the
804
- // best latency
805
- if (this.lowLatencyMode_) {
806
- minBufferTime = 0;
799
+ if (this.isLowLatency_ && this.lowLatencyMode_) {
807
800
  const presentationDelay = suggestedPresentationDelay != null ?
808
801
  suggestedPresentationDelay : this.config_.defaultPresentationDelay;
809
802
  presentationTimeline.setDelay(presentationDelay);
@@ -819,7 +812,6 @@ shaka.dash.DashParser = class {
819
812
  textStreams: this.periodCombiner_.getTextStreams(),
820
813
  imageStreams: this.periodCombiner_.getImageStreams(),
821
814
  offlineSessionIds: [],
822
- minBufferTime: minBufferTime || 0,
823
815
  sequenceMode: this.config_.dash.sequenceMode,
824
816
  ignoreManifestTimestampsInSegmentsMode: false,
825
817
  type: shaka.media.ManifestParser.DASH,
@@ -986,7 +978,7 @@ shaka.dash.DashParser = class {
986
978
 
987
979
  /**
988
980
  * Handles manifest type changes, this transition is expected to be
989
- * "dyanmic" to "static".
981
+ * "dynamic" to "static".
990
982
  *
991
983
  * @param {!string} mpdType
992
984
  * @private
@@ -1310,11 +1302,11 @@ shaka.dash.DashParser = class {
1310
1302
  * children.
1311
1303
  *
1312
1304
  * @param {shaka.dash.DashParser.Context} context
1313
- * @param {function():!Array.<string>} getBaseUris
1305
+ * @param {function(): !Array<string>} getBaseUris
1314
1306
  * @param {!shaka.extern.xml.Node} mpd
1315
1307
  * @param {!boolean} newPeriod
1316
1308
  * @return {{
1317
- * periods: !Array.<shaka.extern.Period>,
1309
+ * periods: !Array<shaka.extern.Period>,
1318
1310
  * duration: ?number,
1319
1311
  * durationDerivedFromPeriods: boolean
1320
1312
  * }}
@@ -1471,8 +1463,8 @@ shaka.dash.DashParser = class {
1471
1463
  if (prevEnd != null) {
1472
1464
  const threshold =
1473
1465
  shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS;
1474
- const diference = prevEnd - seekRangeStart - presentationDuration;
1475
- if (Math.abs(diference) > threshold) {
1466
+ const difference = prevEnd - seekRangeStart - presentationDuration;
1467
+ if (Math.abs(difference) > threshold) {
1476
1468
  shaka.log.warning(
1477
1469
  '@mediaPresentationDuration does not match the total duration ',
1478
1470
  'of all Periods.');
@@ -1530,7 +1522,7 @@ shaka.dash.DashParser = class {
1530
1522
  * was done before this was called so start and duration are valid.
1531
1523
  *
1532
1524
  * @param {shaka.dash.DashParser.Context} context
1533
- * @param {function():!Array.<string>} getBaseUris
1525
+ * @param {function(): !Array<string>} getBaseUris
1534
1526
  * @param {shaka.dash.DashParser.PeriodInfo} periodInfo
1535
1527
  * @return {shaka.extern.Period}
1536
1528
  * @private
@@ -1662,10 +1654,10 @@ shaka.dash.DashParser = class {
1662
1654
  * Gets the streams from the given sets or returns an empty array if disabled
1663
1655
  * or no streams are found.
1664
1656
  * @param {boolean} disabled
1665
- * @param {!Array.<!shaka.dash.DashParser.AdaptationInfo>} adaptationSets
1657
+ * @param {!Array<!shaka.dash.DashParser.AdaptationInfo>} adaptationSets
1666
1658
  * @param {string} contentType
1667
- @private
1668
- */
1659
+ * @private
1660
+ */
1669
1661
  getStreamsFromSets_(disabled, adaptationSets, contentType) {
1670
1662
  if (disabled || !adaptationSets.length) {
1671
1663
  return [];
@@ -1886,7 +1878,7 @@ shaka.dash.DashParser = class {
1886
1878
  // Some closed caption descriptions have channel number and
1887
1879
  // language ("CC1=eng") others may only have language ("eng,spa").
1888
1880
  if (!captionStr.includes('=')) {
1889
- // When the channel assignemnts are not explicitly provided and
1881
+ // When the channel assignments are not explicitly provided and
1890
1882
  // there are only 2 values provided, it is highly likely that the
1891
1883
  // assignments are CC1 and CC3 (most commonly used CC streams).
1892
1884
  // Otherwise, cycle through all channels arbitrarily (CC1 - CC4)
@@ -1933,7 +1925,7 @@ shaka.dash.DashParser = class {
1933
1925
  language = captionStr;
1934
1926
  } else {
1935
1927
  // Otherwise, CEA-708 caption values take the form "
1936
- // 1=lang:eng;2=lang:deu" i.e. serviceNumber=lang:threelettercode.
1928
+ // 1=lang:eng;2=lang:deu" i.e. serviceNumber=lang:threeLetterCode.
1937
1929
  const serviceAndLanguage = captionStr.split('=');
1938
1930
  service = `svc${serviceAndLanguage[0]}`;
1939
1931
 
@@ -1968,10 +1960,10 @@ shaka.dash.DashParser = class {
1968
1960
  }
1969
1961
  }
1970
1962
 
1971
- const contentProtectionElems =
1963
+ const contentProtectionElements =
1972
1964
  TXml.findChildren(elem, 'ContentProtection');
1973
1965
  const contentProtection = ContentProtection.parseFromAdaptationSet(
1974
- contentProtectionElems,
1966
+ contentProtectionElements,
1975
1967
  this.config_.dash.ignoreDrmInfo,
1976
1968
  this.config_.dash.keySystemsByURI);
1977
1969
 
@@ -1982,6 +1974,20 @@ shaka.dash.DashParser = class {
1982
1974
 
1983
1975
  // Parse Representations into Streams.
1984
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
+ }
1985
1991
  const streams = representations.map((representation) => {
1986
1992
  const parsedRepresentation = this.parseRepresentation_(context,
1987
1993
  contentProtection, kind, language, label, main, roleValues,
@@ -2108,11 +2114,11 @@ shaka.dash.DashParser = class {
2108
2114
  * @param {string} language
2109
2115
  * @param {?string} label
2110
2116
  * @param {boolean} isPrimary
2111
- * @param {!Array.<string>} roles
2112
- * @param {Map.<string, string>} closedCaptions
2117
+ * @param {!Array<string>} roles
2118
+ * @param {Map<string, string>} closedCaptions
2113
2119
  * @param {!shaka.extern.xml.Node} node
2114
- * @param {?shaka.media.ManifestParser.AccessibilityPurpose}
2115
- * accessibilityPurpose
2120
+ * @param {?shaka.media.ManifestParser.AccessibilityPurpose
2121
+ * } accessibilityPurpose
2116
2122
  * @param {?number} lastSegmentNumber
2117
2123
  *
2118
2124
  * @return {?shaka.extern.Stream} The Stream, or null when there is a
@@ -2152,13 +2158,13 @@ shaka.dash.DashParser = class {
2152
2158
 
2153
2159
  context.roles = roles;
2154
2160
 
2155
- const supplementalPropertyElems =
2161
+ const supplementalPropertyElements =
2156
2162
  TXml.findChildren(node, 'SupplementalProperty');
2157
- const essentialPropertyElems =
2163
+ const essentialPropertyElements =
2158
2164
  TXml.findChildren(node, 'EssentialProperty');
2159
2165
 
2160
2166
  let representationUrlParams = null;
2161
- let urlParamsElement = essentialPropertyElems.find((element) => {
2167
+ let urlParamsElement = essentialPropertyElements.find((element) => {
2162
2168
  const schemeId = element.attributes['schemeIdUri'];
2163
2169
  return schemeId == 'urn:mpeg:dash:urlparam:2014';
2164
2170
  });
@@ -2166,7 +2172,7 @@ shaka.dash.DashParser = class {
2166
2172
  representationUrlParams =
2167
2173
  this.getURLParametersFunction_(urlParamsElement);
2168
2174
  } else {
2169
- urlParamsElement = supplementalPropertyElems.find((element) => {
2175
+ urlParamsElement = supplementalPropertyElements.find((element) => {
2170
2176
  const schemeId = element.attributes['schemeIdUri'];
2171
2177
  return schemeId == 'urn:mpeg:dash:urlparam:2014';
2172
2178
  });
@@ -2280,17 +2286,17 @@ shaka.dash.DashParser = class {
2280
2286
  throw error;
2281
2287
  }
2282
2288
 
2283
- const contentProtectionElems =
2289
+ const contentProtectionElements =
2284
2290
  TXml.findChildren(node, 'ContentProtection');
2285
2291
  const keyId = shaka.dash.ContentProtection.parseFromRepresentation(
2286
- contentProtectionElems, contentProtection,
2292
+ contentProtectionElements, contentProtection,
2287
2293
  this.config_.dash.ignoreDrmInfo,
2288
2294
  this.config_.dash.keySystemsByURI);
2289
2295
  const keyIds = new Set(keyId ? [keyId] : []);
2290
2296
 
2291
2297
  // Detect the presence of E-AC3 JOC audio content, using DD+JOC signaling.
2292
2298
  // See: ETSI TS 103 420 V1.2.1 (2018-10)
2293
- const hasJoc = supplementalPropertyElems.some((element) => {
2299
+ const hasJoc = supplementalPropertyElements.some((element) => {
2294
2300
  const expectedUri = 'tag:dolby.com,2018:dash:EC3_ExtensionType:2018';
2295
2301
  const expectedValue = 'JOC';
2296
2302
  return element.attributes['schemeIdUri'] == expectedUri &&
@@ -2315,7 +2321,7 @@ shaka.dash.DashParser = class {
2315
2321
 
2316
2322
  let tilesLayout;
2317
2323
  if (isImage) {
2318
- const thumbnailTileElem = essentialPropertyElems.find((element) => {
2324
+ const thumbnailTileElem = essentialPropertyElements.find((element) => {
2319
2325
  const expectedUris = [
2320
2326
  'http://dashif.org/thumbnail_tile',
2321
2327
  'http://dashif.org/guidelines/thumbnail_tile',
@@ -2546,14 +2552,13 @@ shaka.dash.DashParser = class {
2546
2552
  *
2547
2553
  * @param {!shaka.extern.xml.Node} elem
2548
2554
  * @param {?shaka.dash.DashParser.InheritanceFrame} parent
2549
- * @param {?function():!Array.<string>} getBaseUris
2555
+ * @param {?function(): !Array<string>} getBaseUris
2550
2556
  * @return {shaka.dash.DashParser.InheritanceFrame}
2551
2557
  * @private
2552
2558
  */
2553
2559
  createFrame_(elem, parent, getBaseUris) {
2554
2560
  goog.asserts.assert(parent || getBaseUris,
2555
2561
  'Must provide either parent or getBaseUris');
2556
- const SCTE214 = shaka.dash.DashParser.SCTE214_;
2557
2562
  const SegmentUtils = shaka.media.SegmentUtils;
2558
2563
  const ManifestParserUtils = shaka.util.ManifestParserUtils;
2559
2564
  const TXml = shaka.util.TXml;
@@ -2611,11 +2616,6 @@ shaka.dash.DashParser = class {
2611
2616
  const allCodecs = [
2612
2617
  elem.attributes['codecs'] || parent.codecs,
2613
2618
  ];
2614
- const supplementalCodecs =
2615
- TXml.getAttributeNS(elem, SCTE214, 'supplementalCodecs');
2616
- if (supplementalCodecs) {
2617
- allCodecs.push(supplementalCodecs);
2618
- }
2619
2619
  const codecs = SegmentUtils.codecsFiltering(allCodecs).join(',');
2620
2620
  const frameRate =
2621
2621
  TXml.parseAttr(elem, 'frameRate', evalDivision) || parent.frameRate;
@@ -2711,12 +2711,12 @@ shaka.dash.DashParser = class {
2711
2711
  * of the ones parsed from inBandEventStreams and the ones provided in
2712
2712
  * emsgSchemeIdUris.
2713
2713
  *
2714
- * @param {!Array.<!shaka.extern.xml.Node>} inBandEventStreams
2714
+ * @param {!Array<!shaka.extern.xml.Node>} inBandEventStreams
2715
2715
  * Array of InbandEventStream
2716
2716
  * elements to parse and add to the returned array.
2717
- * @param {!Array.<string>} emsgSchemeIdUris Array of parsed
2717
+ * @param {!Array<string>} emsgSchemeIdUris Array of parsed
2718
2718
  * InbandEventStream schemeIdUri attributes to add to the returned array.
2719
- * @return {!Array.<string>} schemeIdUris Array of parsed
2719
+ * @return {!Array<string>} schemeIdUris Array of parsed
2720
2720
  * InbandEventStream schemeIdUri attributes.
2721
2721
  * @private
2722
2722
  */
@@ -2732,7 +2732,7 @@ shaka.dash.DashParser = class {
2732
2732
  }
2733
2733
 
2734
2734
  /**
2735
- * @param {!Array.<!shaka.extern.xml.Node>} audioChannelConfigs An array of
2735
+ * @param {!Array<!shaka.extern.xml.Node>} audioChannelConfigs An array of
2736
2736
  * AudioChannelConfiguration elements.
2737
2737
  * @return {?number} The number of audio channels, or null if unknown.
2738
2738
  * @private
@@ -2899,10 +2899,10 @@ shaka.dash.DashParser = class {
2899
2899
  /**
2900
2900
  * Makes a request to the given URI and calculates the clock offset.
2901
2901
  *
2902
- * @param {function():!Array.<string>} getBaseUris
2902
+ * @param {function(): !Array<string>} getBaseUris
2903
2903
  * @param {string} uri
2904
2904
  * @param {string} method
2905
- * @return {!Promise.<number>}
2905
+ * @return {!Promise<number>}
2906
2906
  * @private
2907
2907
  */
2908
2908
  async requestForTiming_(getBaseUris, uri, method) {
@@ -2942,13 +2942,13 @@ shaka.dash.DashParser = class {
2942
2942
  /**
2943
2943
  * Parses an array of UTCTiming elements.
2944
2944
  *
2945
- * @param {function():!Array.<string>} getBaseUris
2946
- * @param {!Array.<!shaka.extern.xml.Node>} elems
2947
- * @return {!Promise.<number>}
2945
+ * @param {function(): !Array<string>} getBaseUris
2946
+ * @param {!Array<!shaka.extern.xml.Node>} elements
2947
+ * @return {!Promise<number>}
2948
2948
  * @private
2949
2949
  */
2950
- async parseUtcTiming_(getBaseUris, elems) {
2951
- const schemesAndValues = elems.map((elem) => {
2950
+ async parseUtcTiming_(getBaseUris, elements) {
2951
+ const schemesAndValues = elements.map((elem) => {
2952
2952
  return {
2953
2953
  scheme: elem.attributes['schemeIdUri'],
2954
2954
  value: elem.attributes['value'],
@@ -3070,11 +3070,11 @@ shaka.dash.DashParser = class {
3070
3070
  /**
3071
3071
  * Makes a network request on behalf of SegmentBase.createStreamInfo.
3072
3072
  *
3073
- * @param {!Array.<string>} uris
3073
+ * @param {!Array<string>} uris
3074
3074
  * @param {?number} startByte
3075
3075
  * @param {?number} endByte
3076
3076
  * @param {boolean} isInit
3077
- * @return {!Promise.<BufferSource>}
3077
+ * @return {!Promise<BufferSource>}
3078
3078
  * @private
3079
3079
  */
3080
3080
  async requestSegment_(uris, startByte, endByte, isInit) {
@@ -3125,7 +3125,7 @@ shaka.dash.DashParser = class {
3125
3125
  * @param {shaka.extern.Request} request
3126
3126
  * @param {shaka.net.NetworkingEngine.RequestType} type
3127
3127
  * @param {shaka.extern.RequestContext=} context
3128
- * @return {!Promise.<shaka.extern.Response>}
3128
+ * @return {!Promise<shaka.extern.Response>}
3129
3129
  * @private
3130
3130
  */
3131
3131
  makeNetworkRequest_(request, type, context) {
@@ -3180,9 +3180,9 @@ shaka.dash.DashParser = class {
3180
3180
  * mpdId: string,
3181
3181
  * type: string,
3182
3182
  * mediaPresentationDuration: ?number,
3183
- * profiles: !Array.<string>,
3183
+ * profiles: !Array<string>,
3184
3184
  * availabilityTimeOffset: number,
3185
- * getBaseUris: ?function():!Array.<string>,
3185
+ * getBaseUris: ?function():!Array<string>,
3186
3186
  * publishTime: number
3187
3187
  * }}
3188
3188
  *
@@ -3192,12 +3192,12 @@ shaka.dash.DashParser = class {
3192
3192
  * Specifies the type of the dash manifest i.e. "static"
3193
3193
  * @property {?number} mediaPresentationDuration
3194
3194
  * Media presentation duration, or null if unknown.
3195
- * @property {!Array.<string>} profiles
3195
+ * @property {!Array<string>} profiles
3196
3196
  * Profiles of DASH are defined to enable interoperability and the
3197
3197
  * signaling of the use of features.
3198
3198
  * @property {number} availabilityTimeOffset
3199
3199
  * Specifies the total availabilityTimeOffset of the segment.
3200
- * @property {?function():!Array.<string>} getBaseUris
3200
+ * @property {?function():!Array<string>} getBaseUris
3201
3201
  * An array of absolute base URIs.
3202
3202
  * @property {number} publishTime
3203
3203
  * Time when manifest has been published, in seconds.
@@ -3221,8 +3221,8 @@ shaka.dash.DashParser.UP_NAMESPACE_ = 'urn:mpeg:dash:schema:urlparam:2014';
3221
3221
 
3222
3222
  /**
3223
3223
  * @typedef {
3224
- * function(!Array.<string>, ?number, ?number, boolean):
3225
- * !Promise.<BufferSource>
3224
+ * function(!Array<string>, ?number, ?number, boolean):
3225
+ * !Promise<BufferSource>
3226
3226
  * }
3227
3227
  */
3228
3228
  shaka.dash.DashParser.RequestSegmentCallback;
@@ -3233,7 +3233,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
3233
3233
  * segmentBase: ?shaka.extern.xml.Node,
3234
3234
  * segmentList: ?shaka.extern.xml.Node,
3235
3235
  * segmentTemplate: ?shaka.extern.xml.Node,
3236
- * getBaseUris: function():!Array.<string>,
3236
+ * getBaseUris: function():!Array<string>,
3237
3237
  * width: (number|undefined),
3238
3238
  * height: (number|undefined),
3239
3239
  * contentType: string,
@@ -3241,7 +3241,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
3241
3241
  * codecs: string,
3242
3242
  * frameRate: (number|undefined),
3243
3243
  * pixelAspectRatio: (string|undefined),
3244
- * emsgSchemeIdUris: !Array.<string>,
3244
+ * emsgSchemeIdUris: !Array<string>,
3245
3245
  * id: ?string,
3246
3246
  * position: (number|undefined),
3247
3247
  * language: ?string,
@@ -3264,7 +3264,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
3264
3264
  * The XML node for SegmentList.
3265
3265
  * @property {?shaka.extern.xml.Node} segmentTemplate
3266
3266
  * The XML node for SegmentTemplate.
3267
- * @property {function():!Array.<string>} getBaseUris
3267
+ * @property {function():!Array<string>} getBaseUris
3268
3268
  * Function than returns an array of absolute base URIs for the frame.
3269
3269
  * @property {(number|undefined)} width
3270
3270
  * The inherited width value.
@@ -3280,7 +3280,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
3280
3280
  * The inherited framerate value.
3281
3281
  * @property {(string|undefined)} pixelAspectRatio
3282
3282
  * The inherited pixel aspect ratio value.
3283
- * @property {!Array.<string>} emsgSchemeIdUris
3283
+ * @property {!Array<string>} emsgSchemeIdUris
3284
3284
  * emsg registered schemeIdUris.
3285
3285
  * @property {?string} id
3286
3286
  * The ID of the element.
@@ -3319,8 +3319,8 @@ shaka.dash.DashParser.InheritanceFrame;
3319
3319
  * indexRangeWarningGiven: boolean,
3320
3320
  * availabilityTimeOffset: number,
3321
3321
  * mediaPresentationDuration: ?number,
3322
- * profiles: !Array.<string>,
3323
- * roles: ?Array.<string>,
3322
+ * profiles: !Array<string>,
3323
+ * roles: ?Array<string>,
3324
3324
  * urlParams: function():string
3325
3325
  * }}
3326
3326
  *
@@ -3347,7 +3347,7 @@ shaka.dash.DashParser.InheritanceFrame;
3347
3347
  * True if the warning about SegmentURL@indexRange has been printed.
3348
3348
  * @property {number} availabilityTimeOffset
3349
3349
  * The sum of the availabilityTimeOffset values that apply to the element.
3350
- * @property {!Array.<string>} profiles
3350
+ * @property {!Array<string>} profiles
3351
3351
  * Profiles of DASH are defined to enable interoperability and the signaling
3352
3352
  * of the use of features.
3353
3353
  * @property {?number} mediaPresentationDuration
@@ -3388,10 +3388,10 @@ shaka.dash.DashParser.PeriodInfo;
3388
3388
  * contentType: ?string,
3389
3389
  * language: string,
3390
3390
  * main: boolean,
3391
- * streams: !Array.<shaka.extern.Stream>,
3392
- * drmInfos: !Array.<shaka.extern.DrmInfo>,
3391
+ * streams: !Array<shaka.extern.Stream>,
3392
+ * drmInfos: !Array<shaka.extern.DrmInfo>,
3393
3393
  * trickModeFor: ?string,
3394
- * representationIds: !Array.<string>
3394
+ * representationIds: !Array<string>
3395
3395
  * }}
3396
3396
  *
3397
3397
  * @description
@@ -3405,22 +3405,22 @@ shaka.dash.DashParser.PeriodInfo;
3405
3405
  * The language of the AdaptationSet.
3406
3406
  * @property {boolean} main
3407
3407
  * Whether the AdaptationSet has the 'main' type.
3408
- * @property {!Array.<shaka.extern.Stream>} streams
3408
+ * @property {!Array<shaka.extern.Stream>} streams
3409
3409
  * The streams this AdaptationSet contains.
3410
- * @property {!Array.<shaka.extern.DrmInfo>} drmInfos
3410
+ * @property {!Array<shaka.extern.DrmInfo>} drmInfos
3411
3411
  * The DRM info for the AdaptationSet.
3412
3412
  * @property {?string} trickModeFor
3413
3413
  * If non-null, this AdaptationInfo represents trick mode tracks. This
3414
3414
  * property is the ID of the normal AdaptationSet these tracks should be
3415
3415
  * associated with.
3416
- * @property {!Array.<string>} representationIds
3416
+ * @property {!Array<string>} representationIds
3417
3417
  * An array of the IDs of the Representations this AdaptationSet contains.
3418
3418
  */
3419
3419
  shaka.dash.DashParser.AdaptationInfo;
3420
3420
 
3421
3421
 
3422
3422
  /**
3423
- * @typedef {function():!Promise.<shaka.media.SegmentIndex>}
3423
+ * @typedef {function(): !Promise<shaka.media.SegmentIndex>}
3424
3424
  * @description
3425
3425
  * An async function which generates and returns a SegmentIndex.
3426
3426
  */
@@ -3436,8 +3436,8 @@ shaka.dash.DashParser.GenerateSegmentIndexFunction;
3436
3436
  * Contains information about a Stream. This is passed from the createStreamInfo
3437
3437
  * methods.
3438
3438
  *
3439
- * @property {shaka.dash.DashParser.GenerateSegmentIndexFunction}
3440
- * generateSegmentIndex
3439
+ * @property {shaka.dash.DashParser.GenerateSegmentIndexFunction
3440
+ * } generateSegmentIndex
3441
3441
  * An async function to create the SegmentIndex for the stream.
3442
3442
  */
3443
3443
  shaka.dash.DashParser.StreamInfo;