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
@@ -37,7 +37,7 @@ shaka.dash.MpdUtils = class {
37
37
  */
38
38
  static fillUriTemplate(
39
39
  uriTemplate, representationId, number, subNumber, bandwidth, time) {
40
- /** @type {!Object.<string, ?number|?string>} */
40
+ /** @type {!Object<string, ?number | ?string>} */
41
41
  const valueTable = {
42
42
  'RepresentationID': representationId,
43
43
  'Number': number,
@@ -46,6 +46,7 @@ shaka.dash.MpdUtils = class {
46
46
  'Time': time,
47
47
  };
48
48
 
49
+ // cspell: disable-next-line
49
50
  const re = /\$(RepresentationID|Number|SubNumber|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\$/g; // eslint-disable-line max-len
50
51
  const uri = uriTemplate.replace(re, (match, name, widthStr, format) => {
51
52
  if (match == '$$') {
@@ -129,7 +130,7 @@ shaka.dash.MpdUtils = class {
129
130
  * @param {number} periodDuration The Period's duration in seconds.
130
131
  * Infinity indicates that the Period continues indefinitely.
131
132
  * @param {number} startNumber
132
- * @return {!Array.<shaka.media.PresentationTimeline.TimeRange>}
133
+ * @return {!Array<shaka.media.PresentationTimeline.TimeRange>}
133
134
  */
134
135
  static createTimeline(
135
136
  timePoints, timescale, unscaledPresentationTimeOffset,
@@ -143,7 +144,7 @@ shaka.dash.MpdUtils = class {
143
144
  // Alias.
144
145
  const TXml = shaka.util.TXml;
145
146
 
146
- /** @type {!Array.<shaka.media.PresentationTimeline.TimeRange>} */
147
+ /** @type {!Array<shaka.media.PresentationTimeline.TimeRange>} */
147
148
  const timeline = [];
148
149
  let lastEndTime = -unscaledPresentationTimeOffset;
149
150
 
@@ -186,7 +187,7 @@ shaka.dash.MpdUtils = class {
186
187
  return timeline;
187
188
  } else if (startTime >= nextStartTime) {
188
189
  shaka.log.warning(
189
- 'An "S" element cannot have a negative repeatif its start ',
190
+ 'An "S" element cannot have a negative repeat if its start ',
190
191
  'time exceeds the next "S" element\'s start time:',
191
192
  'ignoring the remaining "S" elements.', timePoint);
192
193
  return timeline;
@@ -207,7 +208,7 @@ shaka.dash.MpdUtils = class {
207
208
  shaka.log.warning(
208
209
  'The last "S" element cannot have a negative repeat',
209
210
  'if its start time exceeds the Period\'s duration:',
210
- 'igoring the last "S" element.', timePoint);
211
+ 'ignoring the last "S" element.', timePoint);
211
212
  return timeline;
212
213
  }
213
214
  repeat = Math.ceil((periodDuration * timescale - startTime) / d) - 1;
@@ -293,7 +294,7 @@ shaka.dash.MpdUtils = class {
293
294
  startNumber = 1;
294
295
  }
295
296
 
296
- /** @type {Array.<shaka.media.PresentationTimeline.TimeRange>} */
297
+ /** @type {Array<shaka.media.PresentationTimeline.TimeRange>} */
297
298
  let timeline = null;
298
299
  const timelineNode =
299
300
  MpdUtils.inheritChild(context, callback, 'SegmentTimeline');
@@ -322,8 +323,8 @@ shaka.dash.MpdUtils = class {
322
323
  * @param {shaka.dash.DashParser.Context} context
323
324
  * @param {function(?shaka.dash.DashParser.InheritanceFrame):
324
325
  * ?shaka.extern.xml.Node} callback
325
- * @return {!Array.<!shaka.extern.xml.Node>}
326
- */
326
+ * @return {!Array<!shaka.extern.xml.Node>}
327
+ */
327
328
  static getNodes(context, callback) {
328
329
  const Functional = shaka.util.Functional;
329
330
  goog.asserts.assert(
@@ -417,9 +418,9 @@ shaka.dash.MpdUtils = class {
417
418
  // Remove the xlink properties, so it won't download again
418
419
  // when re-processed.
419
420
  for (const key of Object.keys(element.attributes)) {
420
- const segs = key.split(':');
421
+ const segments = key.split(':');
421
422
  const namespace = shaka.util.TXml.getKnownNameSpace(NS);
422
- if (segs[0] == namespace) {
423
+ if (segments[0] == namespace) {
423
424
  delete element.attributes[key];
424
425
  }
425
426
  }
@@ -504,7 +505,7 @@ shaka.dash.MpdUtils = class {
504
505
  * @param {boolean} failGracefully
505
506
  * @param {string} baseUri
506
507
  * @param {!shaka.net.NetworkingEngine} networkingEngine
507
- * @param {number=} linkDepth, default set to 0
508
+ * @param {number=} linkDepth default set to 0
508
509
  * @return {!shaka.util.AbortableOperation.<!shaka.extern.xml.Node>}
509
510
  */
510
511
  static processXlinks(
@@ -569,7 +570,7 @@ shaka.dash.MpdUtils = class {
569
570
  * startNumber: number,
570
571
  * scaledPresentationTimeOffset: number,
571
572
  * unscaledPresentationTimeOffset: number,
572
- * timeline: Array.<shaka.media.PresentationTimeline.TimeRange>
573
+ * timeline: Array<shaka.media.PresentationTimeline.TimeRange>
573
574
  * }}
574
575
  *
575
576
  * @description
@@ -587,7 +588,7 @@ shaka.dash.MpdUtils = class {
587
588
  * The presentation time offset of the representation, in seconds.
588
589
  * @property {number} unscaledPresentationTimeOffset
589
590
  * The presentation time offset of the representation, in timescale units.
590
- * @property {Array.<shaka.media.PresentationTimeline.TimeRange>} timeline
591
+ * @property {Array<shaka.media.PresentationTimeline.TimeRange>} timeline
591
592
  * The timeline of the representation, if given. Times in seconds.
592
593
  */
593
594
  shaka.dash.MpdUtils.SegmentInfo;
@@ -136,11 +136,11 @@ shaka.dash.SegmentBase = class {
136
136
  * @param {shaka.dash.DashParser.Context} context
137
137
  * @param {shaka.dash.DashParser.RequestSegmentCallback} requestSegment
138
138
  * @param {shaka.media.InitSegmentReference} initSegmentReference
139
- * @param {!Array.<string>} uris
139
+ * @param {!Array<string>} uris
140
140
  * @param {number} startByte
141
141
  * @param {?number} endByte
142
142
  * @param {number} scaledPresentationTimeOffset
143
- * @return {!Promise.<shaka.media.SegmentIndex>}
143
+ * @return {!Promise<shaka.media.SegmentIndex>}
144
144
  */
145
145
  static async generateSegmentIndexFromUris(
146
146
  context, requestSegment, initSegmentReference, uris, startByte,
@@ -173,7 +173,7 @@ shaka.dash.SegmentBase = class {
173
173
  const results = await Promise.all(responses);
174
174
  const indexData = results[0];
175
175
  const initData = results[1] || null;
176
- /** @type {Array.<!shaka.media.SegmentReference>} */
176
+ /** @type {Array<!shaka.media.SegmentReference>} */
177
177
  let references = null;
178
178
 
179
179
  const timestampOffset = periodStart - scaledPresentationTimeOffset;
@@ -249,7 +249,7 @@ shaka.dash.SegmentBase = class {
249
249
  * Compute the URIs of the segment index from the container.
250
250
  *
251
251
  * @param {shaka.dash.DashParser.Context} context
252
- * @return {!Array.<string>}
252
+ * @return {!Array<string>}
253
253
  * @private
254
254
  */
255
255
  static computeIndexUris_(context) {
@@ -350,7 +350,7 @@ shaka.dash.SegmentBase = class {
350
350
  * @param {shaka.dash.DashParser.RequestSegmentCallback} requestSegment
351
351
  * @param {shaka.media.InitSegmentReference} initSegmentReference
352
352
  * @param {number} scaledPresentationTimeOffset
353
- * @return {!Promise.<shaka.media.SegmentIndex>}
353
+ * @return {!Promise<shaka.media.SegmentIndex>}
354
354
  * @private
355
355
  */
356
356
  static generateSegmentIndex_(
@@ -31,7 +31,7 @@ shaka.dash.SegmentList = class {
31
31
  * Updates the existing SegmentIndex, if any.
32
32
  *
33
33
  * @param {shaka.dash.DashParser.Context} context
34
- * @param {!Object.<string, !shaka.extern.Stream>} streamMap
34
+ * @param {!Object<string, !shaka.extern.Stream>} streamMap
35
35
  * @param {shaka.extern.aesKey|undefined} aesKey
36
36
  * @return {shaka.dash.DashParser.StreamInfo}
37
37
  */
@@ -197,7 +197,7 @@ shaka.dash.SegmentList = class {
197
197
  * @param {number} periodStart in seconds.
198
198
  * @param {?number} periodDuration in seconds.
199
199
  * @param {number} startNumber
200
- * @param {function():!Array.<string>} getBaseUris
200
+ * @param {function(): !Array<string>} getBaseUris
201
201
  * @param {shaka.dash.SegmentList.SegmentListInfo} info
202
202
  * @param {shaka.media.InitSegmentReference} initSegmentReference
203
203
  * @param {shaka.extern.aesKey|undefined} aesKey
@@ -205,7 +205,7 @@ shaka.dash.SegmentList = class {
205
205
  * @param {string} codecs
206
206
  * @param {number} bandwidth
207
207
  * @param {function():string} urlParams
208
- * @return {!Array.<!shaka.media.SegmentReference>}
208
+ * @return {!Array<!shaka.media.SegmentReference>}
209
209
  * @private
210
210
  */
211
211
  static createSegmentReferences_(
@@ -227,7 +227,7 @@ shaka.dash.SegmentList = class {
227
227
  const appendWindowEnd = periodDuration ?
228
228
  periodStart + periodDuration : Infinity;
229
229
 
230
- /** @type {!Array.<!shaka.media.SegmentReference>} */
230
+ /** @type {!Array<!shaka.media.SegmentReference>} */
231
231
  const references = [];
232
232
  let prevEndTime = info.startTime;
233
233
  for (let i = 0; i < max; i++) {
@@ -287,12 +287,12 @@ shaka.dash.SegmentList = class {
287
287
  * Parses the media URIs from the context.
288
288
  *
289
289
  * @param {shaka.dash.DashParser.Context} context
290
- * @return {!Array.<shaka.dash.SegmentList.MediaSegment>}
290
+ * @return {!Array<shaka.dash.SegmentList.MediaSegment>}
291
291
  * @private
292
292
  */
293
293
  static parseMediaSegments_(context) {
294
294
  const Functional = shaka.util.Functional;
295
- /** @type {!Array.<!shaka.extern.xml.Node>} */
295
+ /** @type {!Array<!shaka.extern.xml.Node>} */
296
296
  const segmentLists = [
297
297
  context.representation.segmentList,
298
298
  context.adaptationSet.segmentList,
@@ -347,8 +347,8 @@ shaka.dash.SegmentList.MediaSegment;
347
347
  * startTime: number,
348
348
  * startNumber: number,
349
349
  * scaledPresentationTimeOffset: number,
350
- * timeline: Array.<shaka.media.PresentationTimeline.TimeRange>,
351
- * mediaSegments: !Array.<shaka.dash.SegmentList.MediaSegment>
350
+ * timeline: Array<shaka.media.PresentationTimeline.TimeRange>,
351
+ * mediaSegments: !Array<shaka.dash.SegmentList.MediaSegment>
352
352
  * }}
353
353
  * @private
354
354
  *
@@ -363,9 +363,9 @@ shaka.dash.SegmentList.MediaSegment;
363
363
  * The start number of the segments; 1 or greater.
364
364
  * @property {number} scaledPresentationTimeOffset
365
365
  * The scaledPresentationTimeOffset of the representation, in seconds.
366
- * @property {Array.<shaka.media.PresentationTimeline.TimeRange>} timeline
366
+ * @property {Array<shaka.media.PresentationTimeline.TimeRange>} timeline
367
367
  * The timeline of the representation, if given. Times in seconds.
368
- * @property {!Array.<shaka.dash.SegmentList.MediaSegment>} mediaSegments
368
+ * @property {!Array<shaka.dash.SegmentList.MediaSegment>} mediaSegments
369
369
  * The URI and byte-ranges of the media segments.
370
370
  */
371
371
  shaka.dash.SegmentList.SegmentListInfo;
@@ -33,11 +33,11 @@ shaka.dash.SegmentTemplate = class {
33
33
  *
34
34
  * @param {shaka.dash.DashParser.Context} context
35
35
  * @param {shaka.dash.DashParser.RequestSegmentCallback} requestSegment
36
- * @param {!Object.<string, !shaka.extern.Stream>} streamMap
36
+ * @param {!Object<string, !shaka.extern.Stream>} streamMap
37
37
  * @param {boolean} isUpdate True if the manifest is being updated.
38
38
  * @param {number} segmentLimit The maximum number of segments to generate for
39
39
  * a SegmentTemplate with fixed duration.
40
- * @param {!Object.<string, number>} periodDurationMap
40
+ * @param {!Object<string, number>} periodDurationMap
41
41
  * @param {shaka.extern.aesKey|undefined} aesKey
42
42
  * @param {?number} lastSegmentNumber
43
43
  * @param {boolean} isPatchUpdate
@@ -131,24 +131,6 @@ shaka.dash.SegmentTemplate = class {
131
131
 
132
132
  shaka.log.debug(`New manifest ${periodStart} - ${periodEnd}`);
133
133
 
134
- /* When to fit segments. All refactors should honor/update this table:
135
- *
136
- * | dynamic | infinite | last | should | notes |
137
- * | | period | period | fit | |
138
- * | ------- | -------- | ------ | ------ | ------------------------- |
139
- * | F | F | X | T | typical VOD |
140
- * | F | T | X | X | impossible: infinite VOD |
141
- * | T | F | F | T | typical live, old period |
142
- * | T | F | T | F | typical IPR |
143
- * | T | T | F | X | impossible: old, infinite |
144
- * | T | T | T | F | typical live, new period |
145
- */
146
-
147
- // We never fit the final period of dynamic content, which could be
148
- // infinite live (with no limit to fit to) or IPR (which would expand the
149
- // most recent segment to the end of the presentation).
150
- const shouldFit = !(context.dynamic && context.periodInfo.isLastPeriod);
151
-
152
134
  if (!segmentIndex) {
153
135
  shaka.log.debug(`Creating TSI with end ${periodEnd}`);
154
136
  segmentIndex = new TimelineSegmentIndex(
@@ -160,14 +142,13 @@ shaka.dash.SegmentTemplate = class {
160
142
  periodStart,
161
143
  periodEnd,
162
144
  initSegmentReference,
163
- shouldFit,
164
145
  aesKey,
165
146
  context.representation.segmentSequenceCadence,
166
147
  );
167
148
  } else {
168
149
  const tsi = /** @type {!TimelineSegmentIndex} */(segmentIndex);
169
150
  tsi.appendTemplateInfo(
170
- info, periodStart, periodEnd, shouldFit, initSegmentReference);
151
+ info, periodStart, periodEnd, initSegmentReference);
171
152
 
172
153
  const availabilityStart =
173
154
  context.presentationTimeline.getSegmentAvailabilityStart();
@@ -177,7 +158,9 @@ shaka.dash.SegmentTemplate = class {
177
158
  if (info.timeline &&
178
159
  context.adaptationSet.contentType !== 'image' &&
179
160
  context.adaptationSet.contentType !== 'text') {
180
- const timeline = info.timeline;
161
+ const tsi = /** @type {!TimelineSegmentIndex} */(segmentIndex);
162
+ // getTimeline is the info.timeline but fitted to the period.
163
+ const timeline = tsi.getTimeline();
181
164
  context.presentationTimeline.notifyTimeRange(
182
165
  timeline,
183
166
  periodStart);
@@ -195,7 +178,7 @@ shaka.dash.SegmentTemplate = class {
195
178
  if (segmentIndex instanceof shaka.dash.TimelineSegmentIndex &&
196
179
  segmentIndex.isEmpty()) {
197
180
  segmentIndex.appendTemplateInfo(info, periodStart,
198
- periodEnd, shouldFit, initSegmentReference);
181
+ periodEnd, initSegmentReference);
199
182
  }
200
183
  return Promise.resolve(segmentIndex);
201
184
  },
@@ -319,7 +302,7 @@ shaka.dash.SegmentTemplate = class {
319
302
  shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);
320
303
  } else if (n != 1) {
321
304
  shaka.log.warning(
322
- 'SegmentTemplate containes multiple segment information sources:',
305
+ 'SegmentTemplate contains multiple segment information sources:',
323
306
  'the SegmentTemplate should only contain an index URL template,',
324
307
  'a SegmentTimeline or a segment duration.',
325
308
  context.representation);
@@ -355,7 +338,7 @@ shaka.dash.SegmentTemplate = class {
355
338
  * @param {shaka.dash.DashParser.RequestSegmentCallback} requestSegment
356
339
  * @param {shaka.media.InitSegmentReference} init
357
340
  * @param {shaka.dash.SegmentTemplate.SegmentTemplateInfo} info
358
- * @return {!Promise.<shaka.media.SegmentIndex>}
341
+ * @return {!Promise<shaka.media.SegmentIndex>}
359
342
  * @private
360
343
  */
361
344
  static generateSegmentIndexFromIndexTemplate_(
@@ -383,11 +366,11 @@ shaka.dash.SegmentTemplate = class {
383
366
  * @param {shaka.dash.SegmentTemplate.SegmentTemplateInfo} info
384
367
  * @param {number} segmentLimit The maximum number of segments to generate.
385
368
  * @param {shaka.media.InitSegmentReference} initSegmentReference
386
- * @param {!Object.<string, number>} periodDurationMap
369
+ * @param {!Object<string, number>} periodDurationMap
387
370
  * @param {shaka.extern.aesKey|undefined} aesKey
388
371
  * @param {?number} lastSegmentNumber
389
372
  * @param {number} segmentSequenceCadence
390
- * @return {!Promise.<shaka.media.SegmentIndex>}
373
+ * @return {!Promise<shaka.media.SegmentIndex>}
391
374
  * @private
392
375
  */
393
376
  static generateSegmentIndexFromDuration_(
@@ -699,7 +682,7 @@ shaka.dash.SegmentTemplate = class {
699
682
  const getBaseUris = context.representation.getBaseUris;
700
683
  const urlParams = context.urlParams;
701
684
  const getUris = () => {
702
- goog.asserts.assert(initialization, 'Should have returned earler');
685
+ goog.asserts.assert(initialization, 'Should have returned earlier');
703
686
  const filledTemplate = MpdUtils.fillUriTemplate(
704
687
  initialization, repId, null, null, bandwidth, null);
705
688
  const resolvedUris = ManifestParserUtils.resolveUris(
@@ -728,7 +711,7 @@ shaka.dash.SegmentTemplate = class {
728
711
  *
729
712
  * @extends shaka.media.SegmentIndex
730
713
  * @implements {shaka.util.IReleasable}
731
- * @implements {Iterable.<!shaka.media.SegmentReference>}
714
+ * @implements {Iterable<!shaka.media.SegmentReference>}
732
715
  *
733
716
  * @private
734
717
  *
@@ -739,45 +722,50 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
739
722
  * @param {!shaka.dash.SegmentTemplate.SegmentTemplateInfo} templateInfo
740
723
  * @param {?string} representationId
741
724
  * @param {number} bandwidth
742
- * @param {function():Array.<string>} getBaseUris
725
+ * @param {function(): Array<string>} getBaseUris
743
726
  * @param {function():string} urlParams
744
727
  * @param {number} periodStart
745
728
  * @param {number} periodEnd
746
729
  * @param {shaka.media.InitSegmentReference} initSegmentReference
747
- * @param {boolean} shouldFit
748
730
  * @param {shaka.extern.aesKey|undefined} aesKey
749
731
  * @param {number} segmentSequenceCadence
750
- */
732
+ */
751
733
  constructor(templateInfo, representationId, bandwidth, getBaseUris,
752
- urlParams, periodStart, periodEnd, initSegmentReference, shouldFit,
734
+ urlParams, periodStart, periodEnd, initSegmentReference,
753
735
  aesKey, segmentSequenceCadence) {
754
736
  super([]);
755
737
 
756
738
  /** @private {?shaka.dash.SegmentTemplate.SegmentTemplateInfo} */
757
739
  this.templateInfo_ = templateInfo;
740
+
758
741
  /** @private {?string} */
759
742
  this.representationId_ = representationId;
743
+
760
744
  /** @private {number} */
761
745
  this.bandwidth_ = bandwidth;
762
- /** @private {function():Array.<string>} */
746
+
747
+ /** @private {function(): Array<string>} */
763
748
  this.getBaseUris_ = getBaseUris;
749
+
764
750
  /** @private {function():string} */
765
751
  this.urlParams_ = urlParams;
752
+
766
753
  /** @private {number} */
767
754
  this.periodStart_ = periodStart;
755
+
768
756
  /** @private {number} */
769
757
  this.periodEnd_ = periodEnd;
758
+
770
759
  /** @private {shaka.media.InitSegmentReference} */
771
760
  this.initSegmentReference_ = initSegmentReference;
761
+
772
762
  /** @private {shaka.extern.aesKey|undefined} */
773
763
  this.aesKey_ = aesKey;
764
+
774
765
  /** @private {number} */
775
766
  this.segmentSequenceCadence_ = segmentSequenceCadence;
776
767
 
777
-
778
- if (shouldFit) {
779
- this.fitTimeline();
780
- }
768
+ this.fitTimeline();
781
769
  }
782
770
 
783
771
  /**
@@ -845,11 +833,9 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
845
833
  * @param {shaka.dash.SegmentTemplate.SegmentTemplateInfo} info
846
834
  * @param {number} periodStart
847
835
  * @param {number} periodEnd
848
- * @param {boolean} shouldFit
849
836
  * @param {shaka.media.InitSegmentReference} initSegmentReference
850
837
  */
851
- appendTemplateInfo(info, periodStart, periodEnd, shouldFit,
852
- initSegmentReference) {
838
+ appendTemplateInfo(info, periodStart, periodEnd, initSegmentReference) {
853
839
  this.updateInitSegmentReference(initSegmentReference);
854
840
  if (!this.templateInfo_) {
855
841
  this.templateInfo_ = info;
@@ -883,9 +869,7 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
883
869
  }
884
870
  }
885
871
 
886
- if (shouldFit) {
887
- this.fitTimeline();
888
- }
872
+ this.fitTimeline();
889
873
  }
890
874
 
891
875
  /**
@@ -930,14 +914,19 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
930
914
  return;
931
915
  }
932
916
  const timeline = this.templateInfo_.timeline;
933
- while (timeline.length) {
934
- const lastTimePeriod = timeline[timeline.length - 1];
935
- if (lastTimePeriod.start >= this.periodEnd_) {
936
- timeline.pop();
917
+ goog.asserts.assert(timeline, 'Timeline should be non-null!');
918
+ const newTimeline = [];
919
+ for (const range of timeline) {
920
+ if (range.start >= this.periodEnd_) {
921
+ // Starts after end of period.
922
+ } else if (range.end <= 0) {
923
+ // Ends before start of period.
937
924
  } else {
938
- break;
925
+ // Usable.
926
+ newTimeline.push(range);
939
927
  }
940
928
  }
929
+ this.templateInfo_.timeline = newTimeline;
941
930
 
942
931
  this.evict(this.periodStart_);
943
932
 
@@ -947,6 +936,19 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
947
936
  // find/get() methods whenever possible.
948
937
  }
949
938
 
939
+ /**
940
+ * Get the current timeline
941
+ * @return {!Array<shaka.media.PresentationTimeline.TimeRange>}
942
+ */
943
+ getTimeline() {
944
+ if (!this.templateInfo_) {
945
+ return [];
946
+ }
947
+ const timeline = this.templateInfo_.timeline;
948
+ goog.asserts.assert(timeline, 'Timeline should be non-null!');
949
+ return timeline;
950
+ }
951
+
950
952
  /**
951
953
  * @override
952
954
  */
@@ -1146,7 +1148,7 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
1146
1148
  /**
1147
1149
  * Fill in a specific template with values to get the segment uris
1148
1150
  *
1149
- * @return {!Array.<string>}
1151
+ * @return {!Array<string>}
1150
1152
  * @private
1151
1153
  */
1152
1154
  static createUris_(mediaTemplate, repId, segmentReplacement,
@@ -1170,7 +1172,7 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
1170
1172
  * startNumber: number,
1171
1173
  * scaledPresentationTimeOffset: number,
1172
1174
  * unscaledPresentationTimeOffset: number,
1173
- * timeline: Array.<shaka.media.PresentationTimeline.TimeRange>,
1175
+ * timeline: Array<shaka.media.PresentationTimeline.TimeRange>,
1174
1176
  * mediaTemplate: ?string,
1175
1177
  * indexTemplate: ?string,
1176
1178
  * mimeType: string,
@@ -1194,7 +1196,7 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
1194
1196
  * The presentation time offset of the representation, in seconds.
1195
1197
  * @property {number} unscaledPresentationTimeOffset
1196
1198
  * The presentation time offset of the representation, in timescale units.
1197
- * @property {Array.<shaka.media.PresentationTimeline.TimeRange>} timeline
1199
+ * @property {Array<shaka.media.PresentationTimeline.TimeRange>} timeline
1198
1200
  * The timeline of the representation, if given. Times in seconds.
1199
1201
  * @property {?string} mediaTemplate
1200
1202
  * The media URI template, if given.
package/lib/debug/log.js CHANGED
@@ -129,13 +129,13 @@ shaka.log.MAX_LOG_LEVEL = 3;
129
129
  /**
130
130
  * A Set to indicate which one-time warnings have been issued.
131
131
  *
132
- * @private {!Set.<string>}
132
+ * @private {!Set<string>}
133
133
  */
134
134
  shaka.log.oneTimeWarningIssued_ = new Set();
135
135
 
136
136
 
137
137
  if (window.console) {
138
- /** @private {!Object.<shaka.log.Level, function(...*)>} */
138
+ /** @private {!Object<shaka.log.Level, function(...*)>} */
139
139
  shaka.log.logMap_ = {
140
140
  [shaka.log.Level.ERROR]: (...args) => console.error(...args),
141
141
  [shaka.log.Level.WARNING]: (...args) => console.warn(...args),
@@ -60,11 +60,12 @@ shaka.dependencies.Allowed = {
60
60
  ISOBoxer: 'ISOBoxer',
61
61
  };
62
62
 
63
+ // eslint-disable-next-line jsdoc/require-returns
63
64
  /**
64
65
  * Contains accessor functions to shared dependencies that could be used by
65
66
  * other components. The default accessors can be overridden.
66
67
  *
67
- * @private {!Map.<shaka.dependencies.Allowed, function():?>}
68
+ * @private {!Map<shaka.dependencies.Allowed, function(): ?>}
68
69
  */
69
70
  shaka.dependencies.dependencies_ = new Map([
70
71
  [shaka.dependencies.Allowed.ISOBoxer, () => window.ISOBoxer],