rx-player 3.26.2 → 3.26.3-dev.2022021400

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 (218) hide show
  1. package/.github/workflows/perfs.yml +22 -0
  2. package/CHANGELOG.md +19 -1
  3. package/VERSION +1 -1
  4. package/dist/_esm5.processed/compat/eme/custom_media_keys/index.js +6 -2
  5. package/dist/_esm5.processed/core/abr/buffer_based_chooser.d.ts +28 -6
  6. package/dist/_esm5.processed/core/abr/buffer_based_chooser.js +63 -12
  7. package/dist/_esm5.processed/core/abr/network_analyzer.d.ts +1 -1
  8. package/dist/_esm5.processed/core/abr/pending_requests_store.js +3 -5
  9. package/dist/_esm5.processed/core/abr/representation_estimator.d.ts +1 -1
  10. package/dist/_esm5.processed/core/abr/representation_estimator.js +2 -2
  11. package/dist/_esm5.processed/core/api/media_element_track_choice_manager.d.ts +6 -0
  12. package/dist/_esm5.processed/core/api/media_element_track_choice_manager.js +20 -3
  13. package/dist/_esm5.processed/core/api/public_api.d.ts +3 -3
  14. package/dist/_esm5.processed/core/api/public_api.js +2 -2
  15. package/dist/_esm5.processed/core/api/track_choice_manager.d.ts +6 -6
  16. package/dist/_esm5.processed/core/eme/__tests__/__global__/utils.d.ts +0 -2
  17. package/dist/_esm5.processed/core/eme/__tests__/__global__/utils.js +5 -10
  18. package/dist/_esm5.processed/core/eme/find_key_system.js +15 -5
  19. package/dist/_esm5.processed/core/eme/types.d.ts +2 -2
  20. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.d.ts +4 -4
  21. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +1 -1
  22. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +2 -2
  23. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +5 -1
  24. package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.js +1 -1
  25. package/dist/_esm5.processed/core/init/initialize_directfile.d.ts +2 -2
  26. package/dist/_esm5.processed/core/init/initialize_media_source.d.ts +1 -1
  27. package/dist/_esm5.processed/core/init/manifest_update_scheduler.d.ts +4 -4
  28. package/dist/_esm5.processed/core/init/stream_events_emitter/are_same_stream_events.d.ts +4 -4
  29. package/dist/_esm5.processed/core/init/stream_events_emitter/types.d.ts +2 -2
  30. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +3 -3
  31. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/text_track_cues_store.js +32 -31
  32. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +4 -4
  33. package/dist/_esm5.processed/core/stream/representation/force_garbage_collection.js +3 -4
  34. package/dist/_esm5.processed/errors/request_error.js +3 -1
  35. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/thumbnail_loader.d.ts +2 -2
  36. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/thumbnail_loader.js +1 -3
  37. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +1 -1
  38. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +1 -1
  39. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/types.d.ts +3 -3
  40. package/dist/_esm5.processed/manifest/adaptation.d.ts +2 -2
  41. package/dist/_esm5.processed/manifest/adaptation.js +3 -1
  42. package/dist/_esm5.processed/manifest/manifest.d.ts +9 -9
  43. package/dist/_esm5.processed/manifest/period.d.ts +3 -3
  44. package/dist/_esm5.processed/manifest/representation.d.ts +2 -2
  45. package/dist/_esm5.processed/manifest/representation_index/types.d.ts +18 -18
  46. package/dist/_esm5.processed/manifest/types.d.ts +3 -3
  47. package/dist/_esm5.processed/parsers/manifest/dash/common/get_hdr_information.d.ts +1 -1
  48. package/dist/_esm5.processed/parsers/manifest/dash/common/get_periods_time_infos.d.ts +3 -3
  49. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +6 -6
  50. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_init_segment.d.ts +3 -3
  51. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +2 -2
  52. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +14 -14
  53. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +17 -17
  54. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +1 -1
  55. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +28 -20
  56. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +19 -4
  57. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.d.ts +2 -2
  58. package/dist/_esm5.processed/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +1 -1
  59. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.d.ts +17 -35
  60. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +24 -23
  61. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +8 -8
  62. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.d.ts +18 -27
  63. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +25 -23
  64. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +21 -15
  65. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +19 -19
  66. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.d.ts +15 -38
  67. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +8 -8
  68. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +30 -30
  69. package/dist/_esm5.processed/parsers/manifest/dash/parsers_types.d.ts +3 -3
  70. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +1 -1
  71. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.d.ts +2 -2
  72. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.d.ts +7 -7
  73. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +8 -8
  74. package/dist/_esm5.processed/parsers/manifest/types.d.ts +28 -28
  75. package/dist/_esm5.processed/parsers/manifest/utils/clear_timeline_from_position.d.ts +3 -2
  76. package/dist/_esm5.processed/parsers/manifest/utils/clear_timeline_from_position.js +15 -5
  77. package/dist/_esm5.processed/parsers/manifest/utils/index_helpers.d.ts +2 -2
  78. package/dist/_esm5.processed/parsers/manifest/utils/update_segment_timeline.d.ts +11 -1
  79. package/dist/_esm5.processed/parsers/manifest/utils/update_segment_timeline.js +31 -19
  80. package/dist/_esm5.processed/parsers/texttracks/webvtt/html/to_html.d.ts +2 -2
  81. package/dist/_esm5.processed/parsers/texttracks/webvtt/parse_cue_block.d.ts +1 -1
  82. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +2 -1
  83. package/dist/_esm5.processed/transports/dash/image_pipelines.js +1 -1
  84. package/dist/_esm5.processed/transports/dash/init_segment_loader.js +1 -1
  85. package/dist/_esm5.processed/transports/dash/manifest_parser.js +1 -1
  86. package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +2 -2
  87. package/dist/_esm5.processed/transports/dash/segment_loader.js +2 -2
  88. package/dist/_esm5.processed/transports/dash/segment_parser.d.ts +1 -1
  89. package/dist/_esm5.processed/transports/dash/text_loader.d.ts +1 -1
  90. package/dist/_esm5.processed/transports/dash/text_loader.js +1 -1
  91. package/dist/_esm5.processed/transports/dash/text_parser.d.ts +1 -1
  92. package/dist/_esm5.processed/transports/local/segment_loader.d.ts +1 -2
  93. package/dist/_esm5.processed/transports/local/segment_loader.js +1 -1
  94. package/dist/_esm5.processed/transports/metaplaylist/manifest_loader.d.ts +1 -1
  95. package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +1 -1
  96. package/dist/_esm5.processed/transports/smooth/pipelines.js +1 -1
  97. package/dist/_esm5.processed/transports/smooth/segment_loader.d.ts +0 -1
  98. package/dist/_esm5.processed/transports/smooth/segment_loader.js +2 -2
  99. package/dist/_esm5.processed/transports/types.d.ts +36 -30
  100. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +1 -1
  101. package/dist/_esm5.processed/transports/utils/generate_manifest_loader.d.ts +1 -1
  102. package/dist/_esm5.processed/utils/cancellable_sleep.js +1 -1
  103. package/dist/_esm5.processed/utils/cast_to_observable.d.ts +1 -2
  104. package/dist/_esm5.processed/utils/cast_to_observable.js +1 -1
  105. package/dist/_esm5.processed/utils/request/fetch.d.ts +4 -5
  106. package/dist/_esm5.processed/utils/request/fetch.js +7 -4
  107. package/dist/_esm5.processed/utils/request/xhr.d.ts +6 -6
  108. package/dist/_esm5.processed/utils/request/xhr.js +2 -1
  109. package/dist/_esm5.processed/utils/rx-from_cancellable_promise.d.ts +1 -2
  110. package/dist/rx-player.js +404 -321
  111. package/dist/rx-player.min.js +1 -1
  112. package/package.json +3 -4
  113. package/scripts/doc-generator/generate_header_html.js +6 -7
  114. package/scripts/doc-generator/generate_page_html.js +3 -4
  115. package/scripts/doc-generator/generate_page_list_html.js +4 -5
  116. package/scripts/doc-generator/generate_sidebar_html.js +4 -7
  117. package/scripts/doc-generator/utils.js +0 -11
  118. package/scripts/generate_demo_list.js +3 -3
  119. package/scripts/generate_documentation_list.js +3 -3
  120. package/scripts/launch_static_server.js +127 -67
  121. package/scripts/run_standalone_demo.js +1 -0
  122. package/scripts/start_demo_web_server.js +1 -0
  123. package/sonar-project.properties +1 -1
  124. package/src/compat/__tests__/fullscreen.test.ts +7 -7
  125. package/src/compat/__tests__/is_vtt_cue.test.ts +1 -1
  126. package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +1 -1
  127. package/src/compat/eme/custom_media_keys/index.ts +7 -3
  128. package/src/core/abr/__tests__/{get_estimate_from_buffer_levels.test.ts → buffer_based_chooser.test.ts} +94 -123
  129. package/src/core/abr/buffer_based_chooser.ts +85 -20
  130. package/src/core/abr/network_analyzer.ts +1 -1
  131. package/src/core/abr/pending_requests_store.ts +3 -5
  132. package/src/core/abr/representation_estimator.ts +6 -3
  133. package/src/core/api/media_element_track_choice_manager.ts +22 -3
  134. package/src/core/api/public_api.ts +6 -6
  135. package/src/core/api/track_choice_manager.ts +10 -9
  136. package/src/core/eme/__tests__/__global__/utils.ts +5 -10
  137. package/src/core/eme/find_key_system.ts +14 -12
  138. package/src/core/eme/types.ts +2 -2
  139. package/src/core/fetchers/manifest/manifest_fetcher.ts +5 -5
  140. package/src/core/fetchers/segment/segment_fetcher.ts +6 -3
  141. package/src/core/fetchers/utils/try_urls_with_backoff.ts +1 -1
  142. package/src/core/init/initialize_directfile.ts +2 -2
  143. package/src/core/init/initialize_media_source.ts +2 -2
  144. package/src/core/init/manifest_update_scheduler.ts +7 -7
  145. package/src/core/init/stream_events_emitter/are_same_stream_events.ts +4 -4
  146. package/src/core/init/stream_events_emitter/types.ts +2 -2
  147. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +3 -3
  148. package/src/core/segment_buffers/implementations/text/html/text_track_cues_store.ts +32 -31
  149. package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +4 -4
  150. package/src/core/stream/representation/force_garbage_collection.ts +3 -5
  151. package/src/errors/request_error.ts +4 -1
  152. package/src/experimental/tools/VideoThumbnailLoader/thumbnail_loader.ts +3 -6
  153. package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +1 -1
  154. package/src/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.ts +3 -3
  155. package/src/experimental/tools/mediaCapabilitiesProber/types.ts +3 -3
  156. package/src/manifest/adaptation.ts +6 -4
  157. package/src/manifest/manifest.ts +10 -10
  158. package/src/manifest/period.ts +3 -3
  159. package/src/manifest/representation.ts +2 -2
  160. package/src/manifest/representation_index/types.ts +18 -18
  161. package/src/manifest/types.ts +3 -3
  162. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +1 -0
  163. package/src/parsers/manifest/dash/common/get_hdr_information.ts +1 -1
  164. package/src/parsers/manifest/dash/common/get_periods_time_infos.ts +3 -3
  165. package/src/parsers/manifest/dash/common/indexes/base.ts +6 -6
  166. package/src/parsers/manifest/dash/common/indexes/get_init_segment.ts +4 -2
  167. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +2 -2
  168. package/src/parsers/manifest/dash/common/indexes/list.ts +14 -14
  169. package/src/parsers/manifest/dash/common/indexes/template.ts +17 -16
  170. package/src/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.ts +1 -1
  171. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +50 -22
  172. package/src/parsers/manifest/dash/common/infer_adaptation_type.ts +2 -2
  173. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +1 -1
  174. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +58 -70
  175. package/src/parsers/manifest/dash/common/parse_mpd.ts +8 -8
  176. package/src/parsers/manifest/dash/common/parse_periods.ts +80 -79
  177. package/src/parsers/manifest/dash/common/parse_representation_index.ts +83 -75
  178. package/src/parsers/manifest/dash/common/parse_representations.ts +44 -63
  179. package/src/parsers/manifest/dash/node_parser_types.ts +30 -30
  180. package/src/parsers/manifest/dash/parsers_types.ts +3 -3
  181. package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +1 -1
  182. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +4 -4
  183. package/src/parsers/manifest/smooth/create_parser.ts +23 -21
  184. package/src/parsers/manifest/smooth/representation_index.ts +14 -14
  185. package/src/parsers/manifest/types.ts +28 -28
  186. package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +31 -33
  187. package/src/parsers/manifest/utils/clear_timeline_from_position.ts +15 -6
  188. package/src/parsers/manifest/utils/index_helpers.ts +2 -2
  189. package/src/parsers/manifest/utils/update_segment_timeline.ts +32 -21
  190. package/src/parsers/texttracks/webvtt/html/to_html.ts +2 -2
  191. package/src/parsers/texttracks/webvtt/parse_cue_block.ts +1 -1
  192. package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +2 -2
  193. package/src/transports/dash/image_pipelines.ts +1 -1
  194. package/src/transports/dash/init_segment_loader.ts +1 -1
  195. package/src/transports/dash/manifest_parser.ts +1 -1
  196. package/src/transports/dash/segment_loader.ts +7 -7
  197. package/src/transports/dash/segment_parser.ts +3 -1
  198. package/src/transports/dash/text_loader.ts +2 -2
  199. package/src/transports/dash/text_parser.ts +3 -1
  200. package/src/transports/local/segment_loader.ts +4 -4
  201. package/src/transports/metaplaylist/manifest_loader.ts +1 -1
  202. package/src/transports/metaplaylist/pipelines.ts +1 -1
  203. package/src/transports/smooth/pipelines.ts +7 -7
  204. package/src/transports/smooth/segment_loader.ts +8 -8
  205. package/src/transports/types.ts +37 -30
  206. package/src/transports/utils/call_custom_manifest_loader.ts +6 -6
  207. package/src/transports/utils/generate_manifest_loader.ts +1 -1
  208. package/src/utils/__tests__/flat_map.test.ts +12 -7
  209. package/src/utils/cancellable_sleep.ts +1 -1
  210. package/src/utils/cast_to_observable.ts +1 -2
  211. package/src/utils/request/fetch.ts +16 -13
  212. package/src/utils/request/xhr.ts +9 -7
  213. package/src/utils/rx-from_cancellable_promise.ts +1 -2
  214. package/tsconfig.json +1 -2
  215. package/tsconfig.modules.json +1 -2
  216. package/dist/_esm5.processed/core/abr/get_estimate_from_buffer_levels.d.ts +0 -29
  217. package/dist/_esm5.processed/core/abr/get_estimate_from_buffer_levels.js +0 -67
  218. package/src/core/abr/get_estimate_from_buffer_levels.ts +0 -85
package/dist/rx-player.js CHANGED
@@ -1284,13 +1284,20 @@ if (is_node/* default */.Z || navigator.requestMediaKeySystemAccess != null && !
1284
1284
 
1285
1285
  if (supported) {
1286
1286
  var keySystemConfigurationResponse = {
1287
- videoCapabilities: videoCapabilities,
1288
- audioCapabilities: audioCapabilities,
1289
1287
  initDataTypes: ["cenc"],
1290
1288
  distinctiveIdentifier: "not-allowed",
1291
1289
  persistentState: "required",
1292
1290
  sessionTypes: ["temporary", "persistent-license"]
1293
- }; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1291
+ };
1292
+
1293
+ if (videoCapabilities !== undefined) {
1294
+ keySystemConfigurationResponse.videoCapabilities = videoCapabilities;
1295
+ }
1296
+
1297
+ if (audioCapabilities !== undefined) {
1298
+ keySystemConfigurationResponse.audioCapabilities = audioCapabilities;
1299
+ } // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1300
+
1294
1301
 
1295
1302
  var customMediaKeys = createCustomMediaKeys(keyType);
1296
1303
  return (0,of.of)(new CustomMediaKeySystemAccess(keyType, customMediaKeys, keySystemConfigurationResponse));
@@ -3375,10 +3382,17 @@ function shouldValidateMetadata() {
3375
3382
  /* harmony export */ "Z": function() { return /* binding */ MediaElementTrackChoiceManager; }
3376
3383
  /* harmony export */ });
3377
3384
  /* harmony import */ var _babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4578);
3378
- /* harmony import */ var _utils_event_emitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1959);
3385
+ /* harmony import */ var _utils_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(811);
3386
+ /* harmony import */ var _utils_event_emitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1959);
3379
3387
  /* harmony import */ var _utils_languages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7829);
3380
3388
 
3381
3389
 
3390
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3391
+
3392
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3393
+
3394
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
3395
+
3382
3396
  /**
3383
3397
  * Copyright 2015 CANAL+ Group
3384
3398
  *
@@ -3396,6 +3410,7 @@ function shouldValidateMetadata() {
3396
3410
  */
3397
3411
 
3398
3412
 
3413
+
3399
3414
  /**
3400
3415
  * Check if track array is different from an other one
3401
3416
  * @param {Array.<Object>} oldTrackArray
@@ -3615,7 +3630,8 @@ var MediaElementTrackChoiceManager = /*#__PURE__*/function (_EventEmitter) {
3615
3630
  nativeTrack = _this$_audioTracks$i.nativeTrack;
3616
3631
 
3617
3632
  if (track.id === id) {
3618
- nativeTrack.enabled = true;
3633
+ this._enableAudioTrackFromIndex(i);
3634
+
3619
3635
  this._audioTrackLockedOn = nativeTrack;
3620
3636
  return;
3621
3637
  }
@@ -3910,7 +3926,8 @@ var MediaElementTrackChoiceManager = /*#__PURE__*/function (_EventEmitter) {
3910
3926
  var nativeTrack = this._audioTracks[i].nativeTrack;
3911
3927
 
3912
3928
  if (nativeTrack === this._audioTrackLockedOn) {
3913
- nativeTrack.enabled = true;
3929
+ this._enableAudioTrackFromIndex(i);
3930
+
3914
3931
  return;
3915
3932
  }
3916
3933
  }
@@ -3940,7 +3957,8 @@ var MediaElementTrackChoiceManager = /*#__PURE__*/function (_EventEmitter) {
3940
3957
  var audioTrack = this._audioTracks[j];
3941
3958
 
3942
3959
  if (audioTrack.track.normalized === normalized && audioTrack.track.audioDescription === track.audioDescription) {
3943
- audioTrack.nativeTrack.enabled = true;
3960
+ this._enableAudioTrackFromIndex(j);
3961
+
3944
3962
  return;
3945
3963
  }
3946
3964
  }
@@ -4316,10 +4334,29 @@ var MediaElementTrackChoiceManager = /*#__PURE__*/function (_EventEmitter) {
4316
4334
  return;
4317
4335
  };
4318
4336
  }
4337
+ }
4338
+ /**
4339
+ * Enable an audio track (and disable all others), based on its index in the
4340
+ * `this._audioTracks` array.
4341
+ * @param {number} index}
4342
+ */
4343
+ ;
4344
+
4345
+ _proto._enableAudioTrackFromIndex = function _enableAudioTrackFromIndex(index) {
4346
+ (0,_utils_assert__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z)(index < this._audioTracks.length); // Seen on Safari MacOS only (2022-02-14), not disabling ALL audio tracks
4347
+ // first (even the wanted one), can lead to the media not playing.
4348
+
4349
+ for (var _iterator = _createForOfIteratorHelperLoose(this._audioTracks), _step; !(_step = _iterator()).done;) {
4350
+ var audioTrack = _step.value;
4351
+ audioTrack.nativeTrack.enabled = false;
4352
+ }
4353
+
4354
+ this._audioTracks[index].nativeTrack.enabled = true;
4355
+ return;
4319
4356
  };
4320
4357
 
4321
4358
  return MediaElementTrackChoiceManager;
4322
- }(_utils_event_emitter__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z);
4359
+ }(_utils_event_emitter__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z);
4323
4360
  /**
4324
4361
  * Disable all text track elements in the given array from showing.
4325
4362
  * @param {Array.<Object>} textTracks
@@ -5480,26 +5517,25 @@ function buildKeySystemConfigurations(ksName, keySystem) {
5480
5517
  // https://www.w3.org/TR/encrypted-media/#get-supported-configuration-and-consent
5481
5518
 
5482
5519
 
5483
- var videoCapabilities = (0,flat_map/* default */.Z)(videoRobustnesses, function (robustness) {
5484
- return [{
5485
- contentType: "video/mp4;codecs=\"avc1.4d401e\"",
5486
- robustness: robustness
5487
- }, {
5488
- contentType: "video/mp4;codecs=\"avc1.42e01e\"",
5489
- robustness: robustness
5490
- }, {
5491
- contentType: "video/webm;codecs=\"vp8\"",
5492
- robustness: robustness
5493
- }];
5520
+ var videoCapabilities = (0,flat_map/* default */.Z)(audioRobustnesses, function (robustness) {
5521
+ return ["video/mp4;codecs=\"avc1.4d401e\"", "video/mp4;codecs=\"avc1.42e01e\"", "video/webm;codecs=\"vp8\""].map(function (contentType) {
5522
+ return robustness !== undefined ? {
5523
+ contentType: contentType,
5524
+ robustness: robustness
5525
+ } : {
5526
+ contentType: contentType
5527
+ };
5528
+ });
5494
5529
  });
5495
5530
  var audioCapabilities = (0,flat_map/* default */.Z)(audioRobustnesses, function (robustness) {
5496
- return [{
5497
- contentType: "audio/mp4;codecs=\"mp4a.40.2\"",
5498
- robustness: robustness
5499
- }, {
5500
- contentType: "audio/webm;codecs=opus",
5501
- robustness: robustness
5502
- }];
5531
+ return ["audio/mp4;codecs=\"mp4a.40.2\"", "audio/webm;codecs=opus"].map(function (contentType) {
5532
+ return robustness !== undefined ? {
5533
+ contentType: contentType,
5534
+ robustness: robustness
5535
+ } : {
5536
+ contentType: contentType
5537
+ };
5538
+ });
5503
5539
  }); // TODO Re-test with a set contentType but an undefined robustness on the
5504
5540
  // STBs on which this problem was found.
5505
5541
  //
@@ -10287,8 +10323,8 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10287
10323
  var ret = []; // begins at the end as most of the time the player will ask for the last
10288
10324
  // CuesGroup
10289
10325
 
10290
- for (var i = cuesBuffer.length - 1; i >= 0; i--) {
10291
- var segment = cuesBuffer[i];
10326
+ for (var cueIdx = cuesBuffer.length - 1; cueIdx >= 0; cueIdx--) {
10327
+ var segment = cuesBuffer[cueIdx];
10292
10328
 
10293
10329
  if (time < segment.end && time >= segment.start) {
10294
10330
  var cues = segment.cues;
@@ -10318,10 +10354,10 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10318
10354
  var to = Math.max(from, _to);
10319
10355
  var cuesBuffer = this._cuesBuffer;
10320
10356
 
10321
- for (var i = 0; i < cuesBuffer.length; i++) {
10322
- if (cuesBuffer[i].end > from) {
10357
+ for (var cueIdx = 0; cueIdx < cuesBuffer.length; cueIdx++) {
10358
+ if (cuesBuffer[cueIdx].end > from) {
10323
10359
  // this cuesInfos is concerned by the remove
10324
- var startCuesInfos = cuesBuffer[i];
10360
+ var startCuesInfos = cuesBuffer[cueIdx];
10325
10361
 
10326
10362
  if (startCuesInfos.start >= to) {
10327
10363
  // our cuesInfos is strictly after this interval, we have nothing to do
@@ -10340,8 +10376,8 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10340
10376
  cuesInfos1 = _removeCuesInfosBetwe[0],
10341
10377
  cuesInfos2 = _removeCuesInfosBetwe[1];
10342
10378
 
10343
- this._cuesBuffer[i] = cuesInfos1;
10344
- cuesBuffer.splice(i + 1, 0, cuesInfos2);
10379
+ this._cuesBuffer[cueIdx] = cuesInfos1;
10380
+ cuesBuffer.splice(cueIdx + 1, 0, cuesInfos2);
10345
10381
  } // No cuesInfos can be concerned after this one, we can quit
10346
10382
 
10347
10383
 
@@ -10351,8 +10387,8 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10351
10387
 
10352
10388
  if (startCuesInfos.start >= from) {
10353
10389
  // all the segment is concerned
10354
- cuesBuffer.splice(i, 1);
10355
- i--; // one less element, we have to decrement the loop
10390
+ cuesBuffer.splice(cueIdx, 1);
10391
+ cueIdx--; // one less element, we have to decrement the loop
10356
10392
  } else {
10357
10393
  // only the end is concerned
10358
10394
  startCuesInfos.cues = getCuesBefore(startCuesInfos.cues, from);
@@ -10442,8 +10478,8 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10442
10478
  }
10443
10479
  }
10444
10480
 
10445
- for (var i = 0; i < cuesBuffer.length; i++) {
10446
- var cuesInfos = cuesBuffer[i];
10481
+ for (var cueIdx = 0; cueIdx < cuesBuffer.length; cueIdx++) {
10482
+ var cuesInfos = cuesBuffer[cueIdx];
10447
10483
 
10448
10484
  if (start < cuesInfos.end) {
10449
10485
  if (areNearlyEqual(start, cuesInfos.start)) {
@@ -10454,7 +10490,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10454
10490
  // Result: |AAAAA|
10455
10491
  // Which means:
10456
10492
  // 1. replace the current cue with ours
10457
- cuesBuffer[i] = cuesInfosToInsert;
10493
+ cuesBuffer[cueIdx] = cuesInfosToInsert;
10458
10494
  return;
10459
10495
  } else if (end < cuesInfos.end) {
10460
10496
  // our cue overlaps with the current one:
@@ -10467,7 +10503,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10467
10503
  // 3. add ours before the current one
10468
10504
  cuesInfos.cues = getCuesAfter(cuesInfos.cues, end);
10469
10505
  cuesInfos.start = end;
10470
- cuesBuffer.splice(i, 0, cuesInfosToInsert);
10506
+ cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);
10471
10507
  return;
10472
10508
  } // our cue goes beyond the current one:
10473
10509
  // ours: |AAAAAAA|
@@ -10478,11 +10514,11 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10478
10514
 
10479
10515
 
10480
10516
  do {
10481
- cuesBuffer.splice(i, 1);
10482
- cuesInfos = cuesBuffer[i];
10517
+ cuesBuffer.splice(cueIdx, 1);
10518
+ cuesInfos = cuesBuffer[cueIdx];
10483
10519
  } while (cuesInfos !== undefined && end > cuesInfos.end);
10484
10520
 
10485
- onIndexOfNextCueFound(i);
10521
+ onIndexOfNextCueFound(cueIdx);
10486
10522
  return;
10487
10523
  } else if (start < cuesInfos.start) {
10488
10524
  if (end < cuesInfos.start) {
@@ -10492,7 +10528,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10492
10528
  // Result: |AAAAAAA| |BBBB|
10493
10529
  // Which means:
10494
10530
  // - add ours before the current one
10495
- cuesBuffer.splice(i, 0, cuesInfosToInsert);
10531
+ cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);
10496
10532
  return;
10497
10533
  } else if (areNearlyEqual(end, cuesInfos.start)) {
10498
10534
  // our cue goes just before the current one:
@@ -10503,14 +10539,14 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10503
10539
  // - update start time of the current one to be sure
10504
10540
  // - add ours before the current one
10505
10541
  cuesInfos.start = end;
10506
- cuesBuffer.splice(i, 0, cuesInfosToInsert);
10542
+ cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);
10507
10543
  return;
10508
10544
  } else if (areNearlyEqual(end, cuesInfos.end)) {
10509
10545
  // ours: |AAAAAAA|
10510
10546
  // the current one: |BBBB|
10511
10547
  // Result: |AAAAAAA|
10512
10548
  // Replace
10513
- cuesBuffer.splice(i, 1, cuesInfosToInsert);
10549
+ cuesBuffer.splice(cueIdx, 1, cuesInfosToInsert);
10514
10550
  return;
10515
10551
  } else if (end < cuesInfos.end) {
10516
10552
  // ours: |AAAAAAA|
@@ -10518,7 +10554,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10518
10554
  // Result: |AAAAAAABB|
10519
10555
  cuesInfos.cues = getCuesAfter(cuesInfos.cues, end);
10520
10556
  cuesInfos.start = end;
10521
- cuesBuffer.splice(i, 0, cuesInfosToInsert);
10557
+ cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);
10522
10558
  return;
10523
10559
  } // ours: |AAAAAAA|
10524
10560
  // the current one: |BBB|...
@@ -10526,11 +10562,11 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10526
10562
 
10527
10563
 
10528
10564
  do {
10529
- cuesBuffer.splice(i, 1);
10530
- cuesInfos = cuesBuffer[i];
10565
+ cuesBuffer.splice(cueIdx, 1);
10566
+ cuesInfos = cuesBuffer[cueIdx];
10531
10567
  } while (cuesInfos !== undefined && end > cuesInfos.end);
10532
10568
 
10533
- onIndexOfNextCueFound(i);
10569
+ onIndexOfNextCueFound(cueIdx);
10534
10570
  return;
10535
10571
  } // else -> start > cuesInfos.start
10536
10572
 
@@ -10541,7 +10577,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10541
10577
  // Result: |BBAAAAAA|
10542
10578
  cuesInfos.cues = getCuesBefore(cuesInfos.cues, start);
10543
10579
  cuesInfos.end = start;
10544
- cuesBuffer.splice(i + 1, 0, cuesInfosToInsert);
10580
+ cuesBuffer.splice(cueIdx + 1, 0, cuesInfosToInsert);
10545
10581
  return;
10546
10582
  } else if (cuesInfos.end > end) {
10547
10583
  // ours: |AAAAAA|
@@ -10551,9 +10587,9 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10551
10587
  cuesInfos1 = _removeCuesInfosBetwe2[0],
10552
10588
  cuesInfos2 = _removeCuesInfosBetwe2[1];
10553
10589
 
10554
- this._cuesBuffer[i] = cuesInfos1;
10555
- cuesBuffer.splice(i + 1, 0, cuesInfosToInsert);
10556
- cuesBuffer.splice(i + 2, 0, cuesInfos2);
10590
+ this._cuesBuffer[cueIdx] = cuesInfos1;
10591
+ cuesBuffer.splice(cueIdx + 1, 0, cuesInfosToInsert);
10592
+ cuesBuffer.splice(cueIdx + 2, 0, cuesInfos2);
10557
10593
  return;
10558
10594
  } else {
10559
10595
  // ours: |AAAAAA|
@@ -10561,14 +10597,15 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
10561
10597
  // Result: |BBAAAAAA|...
10562
10598
  cuesInfos.cues = getCuesBefore(cuesInfos.cues, start);
10563
10599
  cuesInfos.end = start;
10564
- cuesInfos = cuesBuffer[i + 1];
10600
+ var nextCueIdx = cueIdx + 1;
10601
+ cuesInfos = cuesBuffer[nextCueIdx];
10565
10602
 
10566
10603
  while (cuesInfos !== undefined && end > cuesInfos.end) {
10567
- cuesBuffer.splice(i, 1);
10568
- cuesInfos = cuesBuffer[i];
10604
+ cuesBuffer.splice(nextCueIdx, 1);
10605
+ cuesInfos = cuesBuffer[nextCueIdx];
10569
10606
  }
10570
10607
 
10571
- onIndexOfNextCueFound(i);
10608
+ onIndexOfNextCueFound(nextCueIdx);
10572
10609
  return;
10573
10610
  }
10574
10611
  }
@@ -13765,7 +13802,11 @@ var RequestError = /*#__PURE__*/function (_Error) {
13765
13802
  Object.setPrototypeOf((0,_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(_this), RequestError.prototype);
13766
13803
  _this.name = "RequestError";
13767
13804
  _this.url = url;
13768
- _this.xhr = xhr;
13805
+
13806
+ if (xhr !== undefined) {
13807
+ _this.xhr = xhr;
13808
+ }
13809
+
13769
13810
  _this.status = status;
13770
13811
  _this.type = type;
13771
13812
  _this.message = type;
@@ -14393,9 +14434,12 @@ var Adaptation = /*#__PURE__*/function () {
14393
14434
  representationFilter = _options.representationFilter,
14394
14435
  isManuallyAdded = _options.isManuallyAdded;
14395
14436
  this.id = parsedAdaptation.id;
14396
- this.isTrickModeTrack = parsedAdaptation.isTrickModeTrack;
14397
14437
  this.type = parsedAdaptation.type;
14398
14438
 
14439
+ if (parsedAdaptation.isTrickModeTrack !== undefined) {
14440
+ this.isTrickModeTrack = parsedAdaptation.isTrickModeTrack;
14441
+ }
14442
+
14399
14443
  if (parsedAdaptation.language !== undefined) {
14400
14444
  this.language = parsedAdaptation.language;
14401
14445
  this.normalizedLanguage = (0,languages/* default */.ZP)(parsedAdaptation.language);
@@ -19072,7 +19116,7 @@ function constructTimelineFromElements(elements, scaledPeriodStart) {
19072
19116
  var nextItem = initialTimeline[_i + 1] === undefined ? null : initialTimeline[_i + 1];
19073
19117
  var timelineElement = convertElementsToIndexSegment(item, previousItem, nextItem, scaledPeriodStart);
19074
19118
 
19075
- if (timelineElement != null) {
19119
+ if (timelineElement !== null) {
19076
19120
  timeline.push(timelineElement);
19077
19121
  }
19078
19122
  }
@@ -19374,6 +19418,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
19374
19418
  var availabilityTimeComplete = context.availabilityTimeComplete,
19375
19419
  manifestBoundsCalculator = context.manifestBoundsCalculator,
19376
19420
  isDynamic = context.isDynamic,
19421
+ isLastPeriod = context.isLastPeriod,
19377
19422
  representationBaseURLs = context.representationBaseURLs,
19378
19423
  representationId = context.representationId,
19379
19424
  representationBitrate = context.representationBitrate,
@@ -19386,6 +19431,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
19386
19431
  var indexTimeOffset = presentationTimeOffset - scaledStart;
19387
19432
  this._manifestBoundsCalculator = manifestBoundsCalculator;
19388
19433
  this._isEMSGWhitelisted = isEMSGWhitelisted;
19434
+ this._isLastPeriod = isLastPeriod;
19389
19435
  this._lastUpdate = context.receivedTime == null ? performance.now() : context.receivedTime;
19390
19436
  this._unsafelyBaseOnPreviousIndex = null;
19391
19437
 
@@ -19592,6 +19638,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
19592
19638
  this._scaledPeriodEnd = newIndex._scaledPeriodEnd;
19593
19639
  this._lastUpdate = newIndex._lastUpdate;
19594
19640
  this._manifestBoundsCalculator = newIndex._manifestBoundsCalculator;
19641
+ this._isLastPeriod = newIndex._isLastPeriod;
19595
19642
  }
19596
19643
  /**
19597
19644
  * Update this RepresentationIndex with a shorter version of it coming from a
@@ -19609,11 +19656,17 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
19609
19656
  newIndex._index.timeline = newIndex._getTimeline();
19610
19657
  }
19611
19658
 
19612
- (0,update_segment_timeline/* default */.Z)(this._index.timeline, newIndex._index.timeline);
19659
+ var hasReplaced = (0,update_segment_timeline/* default */.Z)(this._index.timeline, newIndex._index.timeline);
19660
+
19661
+ if (hasReplaced) {
19662
+ this._index.startNumber = newIndex._index.startNumber;
19663
+ }
19664
+
19613
19665
  this._isDynamic = newIndex._isDynamic;
19614
19666
  this._scaledPeriodStart = newIndex._scaledPeriodStart;
19615
19667
  this._scaledPeriodEnd = newIndex._scaledPeriodEnd;
19616
19668
  this._lastUpdate = newIndex._lastUpdate;
19669
+ this._isLastPeriod = newIndex._isLastPeriod;
19617
19670
  }
19618
19671
  /**
19619
19672
  * Returns `true` if this RepresentationIndex currently contains its last
@@ -19624,7 +19677,13 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
19624
19677
  ;
19625
19678
 
19626
19679
  _proto.isFinished = function isFinished() {
19627
- if (!this._isDynamic) {
19680
+ if (!this._isDynamic || !this._isLastPeriod) {
19681
+ // Either the content is not dynamic, in which case no new segment will
19682
+ // be generated, either it is but this index is not linked to the current
19683
+ // last Period in the MPD, in which case it is inferred that it has been
19684
+ // completely generated. Note that this second condition might break very
19685
+ // very rare use cases where old Periods are still being generated, yet it
19686
+ // should fix more cases than it breaks.
19628
19687
  return true;
19629
19688
  }
19630
19689
 
@@ -19679,7 +19738,11 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
19679
19738
  }
19680
19739
 
19681
19740
  var scaledFirstPosition = (0,index_helpers/* toIndexTime */.gT)(firstPosition, this._index);
19682
- (0,clear_timeline_from_position/* default */.Z)(this._index.timeline, scaledFirstPosition);
19741
+ var nbEltsRemoved = (0,clear_timeline_from_position/* default */.Z)(this._index.timeline, scaledFirstPosition);
19742
+
19743
+ if (this._index.startNumber !== undefined) {
19744
+ this._index.startNumber += nbEltsRemoved;
19745
+ }
19683
19746
  };
19684
19747
 
19685
19748
  TimelineRepresentationIndex.getIndexEnd = function getIndexEnd(timeline, scaledPeriodEnd) {
@@ -20274,24 +20337,25 @@ function resolveBaseURLs(currentBaseURLs, newBaseUrlsIR) {
20274
20337
  * Parse the specific segment indexing information found in a representation
20275
20338
  * into a IRepresentationIndex implementation.
20276
20339
  * @param {Array.<Object>} representation
20277
- * @param {Object} representationInfos
20340
+ * @param {Object} context
20278
20341
  * @returns {Array.<Object>}
20279
20342
  */
20280
20343
 
20281
- function parseRepresentationIndex(representation, representationInfos) {
20344
+ function parseRepresentationIndex(representation, context) {
20282
20345
  var _a, _b;
20283
20346
 
20284
- var representationBaseURLs = resolveBaseURLs(representationInfos.baseURLs, representation.children.baseURLs);
20285
- var aggressiveMode = representationInfos.aggressiveMode,
20286
- availabilityTimeOffset = representationInfos.availabilityTimeOffset,
20287
- manifestBoundsCalculator = representationInfos.manifestBoundsCalculator,
20288
- isDynamic = representationInfos.isDynamic,
20289
- periodEnd = representationInfos.end,
20290
- periodStart = representationInfos.start,
20291
- receivedTime = representationInfos.receivedTime,
20292
- timeShiftBufferDepth = representationInfos.timeShiftBufferDepth,
20293
- unsafelyBaseOnPreviousRepresentation = representationInfos.unsafelyBaseOnPreviousRepresentation,
20294
- inbandEventStreams = representationInfos.inbandEventStreams;
20347
+ var representationBaseURLs = resolveBaseURLs(context.baseURLs, representation.children.baseURLs);
20348
+ var aggressiveMode = context.aggressiveMode,
20349
+ availabilityTimeOffset = context.availabilityTimeOffset,
20350
+ manifestBoundsCalculator = context.manifestBoundsCalculator,
20351
+ isDynamic = context.isDynamic,
20352
+ periodEnd = context.end,
20353
+ periodStart = context.start,
20354
+ receivedTime = context.receivedTime,
20355
+ timeShiftBufferDepth = context.timeShiftBufferDepth,
20356
+ unsafelyBaseOnPreviousRepresentation = context.unsafelyBaseOnPreviousRepresentation,
20357
+ inbandEventStreams = context.inbandEventStreams,
20358
+ isLastPeriod = context.isLastPeriod;
20295
20359
 
20296
20360
  var isEMSGWhitelisted = function isEMSGWhitelisted(inbandEvent) {
20297
20361
  if (inbandEventStreams === undefined) {
@@ -20304,12 +20368,13 @@ function parseRepresentationIndex(representation, representationInfos) {
20304
20368
  });
20305
20369
  };
20306
20370
 
20307
- var context = {
20371
+ var reprIndexCtxt = {
20308
20372
  aggressiveMode: aggressiveMode,
20309
20373
  availabilityTimeComplete: true,
20310
20374
  availabilityTimeOffset: availabilityTimeOffset,
20311
20375
  unsafelyBaseOnPreviousRepresentation: unsafelyBaseOnPreviousRepresentation,
20312
20376
  isEMSGWhitelisted: isEMSGWhitelisted,
20377
+ isLastPeriod: isLastPeriod,
20313
20378
  manifestBoundsCalculator: manifestBoundsCalculator,
20314
20379
  isDynamic: isDynamic,
20315
20380
  periodEnd: periodEnd,
@@ -20324,12 +20389,12 @@ function parseRepresentationIndex(representation, representationInfos) {
20324
20389
 
20325
20390
  if (representation.children.segmentBase !== undefined) {
20326
20391
  var segmentBase = representation.children.segmentBase;
20327
- representationIndex = new base/* default */.Z(segmentBase, context);
20392
+ representationIndex = new base/* default */.Z(segmentBase, reprIndexCtxt);
20328
20393
  } else if (representation.children.segmentList !== undefined) {
20329
20394
  var segmentList = representation.children.segmentList;
20330
- representationIndex = new ListRepresentationIndex(segmentList, context);
20331
- } else if (representation.children.segmentTemplate !== undefined || representationInfos.parentSegmentTemplates.length > 0) {
20332
- var segmentTemplates = representationInfos.parentSegmentTemplates.slice();
20395
+ representationIndex = new ListRepresentationIndex(segmentList, reprIndexCtxt);
20396
+ } else if (representation.children.segmentTemplate !== undefined || context.parentSegmentTemplates.length > 0) {
20397
+ var segmentTemplates = context.parentSegmentTemplates.slice();
20333
20398
  var childSegmentTemplate = representation.children.segmentTemplate;
20334
20399
 
20335
20400
  if (childSegmentTemplate !== undefined) {
@@ -20337,25 +20402,25 @@ function parseRepresentationIndex(representation, representationInfos) {
20337
20402
  }
20338
20403
 
20339
20404
  var segmentTemplate = object_assign/* default.apply */.Z.apply(void 0, [{}].concat(segmentTemplates));
20340
- context.availabilityTimeComplete = (_a = segmentTemplate.availabilityTimeComplete) !== null && _a !== void 0 ? _a : representationInfos.availabilityTimeComplete;
20341
- context.availabilityTimeOffset = ((_b = segmentTemplate.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0) + representationInfos.availabilityTimeOffset;
20342
- representationIndex = timeline.isTimelineIndexArgument(segmentTemplate) ? new timeline(segmentTemplate, context) : new TemplateRepresentationIndex(segmentTemplate, context);
20405
+ reprIndexCtxt.availabilityTimeComplete = (_a = segmentTemplate.availabilityTimeComplete) !== null && _a !== void 0 ? _a : context.availabilityTimeComplete;
20406
+ reprIndexCtxt.availabilityTimeOffset = ((_b = segmentTemplate.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0) + context.availabilityTimeOffset;
20407
+ representationIndex = timeline.isTimelineIndexArgument(segmentTemplate) ? new timeline(segmentTemplate, reprIndexCtxt) : new TemplateRepresentationIndex(segmentTemplate, reprIndexCtxt);
20343
20408
  } else {
20344
- var adaptationChildren = representationInfos.adaptation.children;
20409
+ var adaptationChildren = context.adaptation.children;
20345
20410
 
20346
20411
  if (adaptationChildren.segmentBase !== undefined) {
20347
20412
  var _segmentBase = adaptationChildren.segmentBase;
20348
- representationIndex = new base/* default */.Z(_segmentBase, context);
20413
+ representationIndex = new base/* default */.Z(_segmentBase, reprIndexCtxt);
20349
20414
  } else if (adaptationChildren.segmentList !== undefined) {
20350
20415
  var _segmentList = adaptationChildren.segmentList;
20351
- representationIndex = new ListRepresentationIndex(_segmentList, context);
20416
+ representationIndex = new ListRepresentationIndex(_segmentList, reprIndexCtxt);
20352
20417
  } else {
20353
20418
  representationIndex = new TemplateRepresentationIndex({
20354
20419
  duration: Number.MAX_VALUE,
20355
20420
  timescale: 1,
20356
20421
  startNumber: 0,
20357
20422
  media: ""
20358
- }, context);
20423
+ }, reprIndexCtxt);
20359
20424
  }
20360
20425
  }
20361
20426
 
@@ -20447,12 +20512,12 @@ function getHDRInformation(_ref) {
20447
20512
  /**
20448
20513
  * Process intermediate representations to create final parsed representations.
20449
20514
  * @param {Array.<Object>} representationsIR
20450
- * @param {Object} adaptationInfos
20515
+ * @param {Object} context
20451
20516
  * @returns {Array.<Object>}
20452
20517
  */
20453
20518
 
20454
20519
 
20455
- function parseRepresentations(representationsIR, adaptation, adaptationInfos) {
20520
+ function parseRepresentations(representationsIR, adaptation, context) {
20456
20521
  var _a, _b, _c, _d;
20457
20522
 
20458
20523
  var parsedRepresentations = [];
@@ -20469,18 +20534,18 @@ function parseRepresentations(representationsIR, adaptation, adaptationInfos) {
20469
20534
  } // Retrieve previous version of the Representation, if one.
20470
20535
 
20471
20536
 
20472
- var unsafelyBaseOnPreviousRepresentation = (_b = (_a = adaptationInfos.unsafelyBaseOnPreviousAdaptation) === null || _a === void 0 ? void 0 : _a.getRepresentation(representationID)) !== null && _b !== void 0 ? _b : null;
20537
+ var unsafelyBaseOnPreviousRepresentation = (_b = (_a = context.unsafelyBaseOnPreviousAdaptation) === null || _a === void 0 ? void 0 : _a.getRepresentation(representationID)) !== null && _b !== void 0 ? _b : null;
20473
20538
  var inbandEventStreams = combineInbandEventStreams(representation, adaptation);
20474
- var availabilityTimeComplete = (_c = representation.attributes.availabilityTimeComplete) !== null && _c !== void 0 ? _c : adaptationInfos.availabilityTimeComplete;
20475
- var availabilityTimeOffset = ((_d = representation.attributes.availabilityTimeOffset) !== null && _d !== void 0 ? _d : 0) + adaptationInfos.availabilityTimeOffset;
20476
- var representationInfos = (0,object_assign/* default */.Z)({}, adaptationInfos, {
20539
+ var availabilityTimeComplete = (_c = representation.attributes.availabilityTimeComplete) !== null && _c !== void 0 ? _c : context.availabilityTimeComplete;
20540
+ var availabilityTimeOffset = ((_d = representation.attributes.availabilityTimeOffset) !== null && _d !== void 0 ? _d : 0) + context.availabilityTimeOffset;
20541
+ var reprIndexCtxt = (0,object_assign/* default */.Z)({}, context, {
20477
20542
  availabilityTimeOffset: availabilityTimeOffset,
20478
20543
  availabilityTimeComplete: availabilityTimeComplete,
20479
20544
  unsafelyBaseOnPreviousRepresentation: unsafelyBaseOnPreviousRepresentation,
20480
20545
  adaptation: adaptation,
20481
20546
  inbandEventStreams: inbandEventStreams
20482
20547
  });
20483
- var representationIndex = parseRepresentationIndex(representation, representationInfos); // Find bitrate
20548
+ var representationIndex = parseRepresentationIndex(representation, reprIndexCtxt); // Find bitrate
20484
20549
 
20485
20550
  var representationBitrate = void 0;
20486
20551
 
@@ -20599,7 +20664,7 @@ function parseRepresentations(representationsIR, adaptation, adaptationInfos) {
20599
20664
 
20600
20665
  parsedRepresentation.hdrInfo = getHDRInformation({
20601
20666
  adaptationProfiles: adaptation.attributes.profiles,
20602
- manifestProfiles: adaptationInfos.manifestProfiles,
20667
+ manifestProfiles: context.manifestProfiles,
20603
20668
  codecs: codecs
20604
20669
  });
20605
20670
  parsedRepresentations.push(parsedRepresentation);
@@ -20651,7 +20716,7 @@ function parse_adaptation_sets_arrayLikeToArray(arr, len) { if (len == null || l
20651
20716
  */
20652
20717
 
20653
20718
  function isVisuallyImpaired(accessibility) {
20654
- if (accessibility == null) {
20719
+ if (accessibility === undefined) {
20655
20720
  return false;
20656
20721
  }
20657
20722
 
@@ -20669,7 +20734,7 @@ function isVisuallyImpaired(accessibility) {
20669
20734
 
20670
20735
 
20671
20736
  function isHardOfHearing(accessibility) {
20672
- if (accessibility == null) {
20737
+ if (accessibility === undefined) {
20673
20738
  return false;
20674
20739
  }
20675
20740
 
@@ -20685,7 +20750,7 @@ function isHardOfHearing(accessibility) {
20685
20750
 
20686
20751
 
20687
20752
  function hasSignLanguageInterpretation(accessibility) {
20688
- if (accessibility == null) {
20753
+ if (accessibility === undefined) {
20689
20754
  return false;
20690
20755
  }
20691
20756
 
@@ -20783,12 +20848,12 @@ function getAdaptationSetSwitchingIDs(adaptation) {
20783
20848
  * Note that the AdaptationSets returned are sorted by priority (from the most
20784
20849
  * priority to the least one).
20785
20850
  * @param {Array.<Object>} adaptationsIR
20786
- * @param {Object} periodInfos
20851
+ * @param {Object} context
20787
20852
  * @returns {Array.<Object>}
20788
20853
  */
20789
20854
 
20790
20855
 
20791
- function parseAdaptationSets(adaptationsIR, periodInfos) {
20856
+ function parseAdaptationSets(adaptationsIR, context) {
20792
20857
  var _a, _b, _c, _d, _e, _f, _g;
20793
20858
 
20794
20859
  var parsedAdaptations = {};
@@ -20826,8 +20891,8 @@ function parseAdaptationSets(adaptationsIR, periodInfos) {
20826
20891
  return role.schemeIdUri === "urn:mpeg:dash:role:2011";
20827
20892
  });
20828
20893
  var representationsIR = adaptation.children.representations;
20829
- var availabilityTimeComplete = (_a = adaptation.attributes.availabilityTimeComplete) !== null && _a !== void 0 ? _a : periodInfos.availabilityTimeComplete;
20830
- var availabilityTimeOffset = ((_b = adaptation.attributes.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0) + periodInfos.availabilityTimeOffset;
20894
+ var availabilityTimeComplete = (_a = adaptation.attributes.availabilityTimeComplete) !== null && _a !== void 0 ? _a : context.availabilityTimeComplete;
20895
+ var availabilityTimeOffset = ((_b = adaptation.attributes.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0) + context.availabilityTimeOffset;
20831
20896
  var adaptationMimeType = adaptation.attributes.mimeType;
20832
20897
  var adaptationCodecs = adaptation.attributes.codecs;
20833
20898
  var type = inferAdaptationType(representationsIR, (0,is_non_empty_string/* default */.Z)(adaptationMimeType) ? adaptationMimeType : null, (0,is_non_empty_string/* default */.Z)(adaptationCodecs) ? adaptationCodecs : null, adaptationChildren.roles != null ? adaptationChildren.roles : null);
@@ -20841,27 +20906,28 @@ function parseAdaptationSets(adaptationsIR, periodInfos) {
20841
20906
  var adaptationSetSwitchingIDs = getAdaptationSetSwitchingIDs(adaptation);
20842
20907
  var parentSegmentTemplates = [];
20843
20908
 
20844
- if (periodInfos.segmentTemplate !== undefined) {
20845
- parentSegmentTemplates.push(periodInfos.segmentTemplate);
20909
+ if (context.segmentTemplate !== undefined) {
20910
+ parentSegmentTemplates.push(context.segmentTemplate);
20846
20911
  }
20847
20912
 
20848
20913
  if (adaptation.children.segmentTemplate !== undefined) {
20849
20914
  parentSegmentTemplates.push(adaptation.children.segmentTemplate);
20850
20915
  }
20851
20916
 
20852
- var adaptationInfos = {
20853
- aggressiveMode: periodInfos.aggressiveMode,
20917
+ var reprCtxt = {
20918
+ aggressiveMode: context.aggressiveMode,
20854
20919
  availabilityTimeComplete: availabilityTimeComplete,
20855
20920
  availabilityTimeOffset: availabilityTimeOffset,
20856
- baseURLs: resolveBaseURLs(periodInfos.baseURLs, adaptationChildren.baseURLs),
20857
- manifestBoundsCalculator: periodInfos.manifestBoundsCalculator,
20858
- end: periodInfos.end,
20859
- isDynamic: periodInfos.isDynamic,
20860
- manifestProfiles: periodInfos.manifestProfiles,
20921
+ baseURLs: resolveBaseURLs(context.baseURLs, adaptationChildren.baseURLs),
20922
+ manifestBoundsCalculator: context.manifestBoundsCalculator,
20923
+ end: context.end,
20924
+ isDynamic: context.isDynamic,
20925
+ isLastPeriod: context.isLastPeriod,
20926
+ manifestProfiles: context.manifestProfiles,
20861
20927
  parentSegmentTemplates: parentSegmentTemplates,
20862
- receivedTime: periodInfos.receivedTime,
20863
- start: periodInfos.start,
20864
- timeShiftBufferDepth: periodInfos.timeShiftBufferDepth,
20928
+ receivedTime: context.receivedTime,
20929
+ start: context.start,
20930
+ timeShiftBufferDepth: context.timeShiftBufferDepth,
20865
20931
  unsafelyBaseOnPreviousAdaptation: null
20866
20932
  };
20867
20933
  var trickModeProperty = Array.isArray(essentialProperties) ? (0,array_find/* default */.Z)(essentialProperties, function (scheme) {
@@ -20876,8 +20942,8 @@ function parseAdaptationSets(adaptationsIR, periodInfos) {
20876
20942
  // Add to the already existing main video adaptation
20877
20943
  // TODO remove that ugly custom logic?
20878
20944
  var videoMainAdaptation = parsedAdaptations.video[lastMainAdaptationIndex.video];
20879
- adaptationInfos.unsafelyBaseOnPreviousAdaptation = (_e = (_d = periodInfos.unsafelyBaseOnPreviousPeriod) === null || _d === void 0 ? void 0 : _d.getAdaptation(videoMainAdaptation.id)) !== null && _e !== void 0 ? _e : null;
20880
- var representations = parseRepresentations(representationsIR, adaptation, adaptationInfos);
20945
+ reprCtxt.unsafelyBaseOnPreviousAdaptation = (_e = (_d = context.unsafelyBaseOnPreviousPeriod) === null || _d === void 0 ? void 0 : _d.getAdaptation(videoMainAdaptation.id)) !== null && _e !== void 0 ? _e : null;
20946
+ var representations = parseRepresentations(representationsIR, adaptation, reprCtxt);
20881
20947
 
20882
20948
  (_videoMainAdaptation$ = videoMainAdaptation.representations).push.apply(_videoMainAdaptation$, representations);
20883
20949
 
@@ -20930,9 +20996,9 @@ function parseAdaptationSets(adaptationsIR, periodInfos) {
20930
20996
 
20931
20997
  newID = adaptationID;
20932
20998
  parsedAdaptationsIDs.push(adaptationID);
20933
- adaptationInfos.unsafelyBaseOnPreviousAdaptation = (_g = (_f = periodInfos.unsafelyBaseOnPreviousPeriod) === null || _f === void 0 ? void 0 : _f.getAdaptation(adaptationID)) !== null && _g !== void 0 ? _g : null;
20999
+ reprCtxt.unsafelyBaseOnPreviousAdaptation = (_g = (_f = context.unsafelyBaseOnPreviousPeriod) === null || _f === void 0 ? void 0 : _f.getAdaptation(adaptationID)) !== null && _g !== void 0 ? _g : null;
20934
21000
 
20935
- var _representations = parseRepresentations(representationsIR, adaptation, adaptationInfos);
21001
+ var _representations = parseRepresentations(representationsIR, adaptation, reprCtxt);
20936
21002
 
20937
21003
  var parsedAdaptationSet = {
20938
21004
  id: adaptationID,
@@ -21078,37 +21144,38 @@ var generatePeriodID = (0,id_generator/* default */.Z)();
21078
21144
  /**
21079
21145
  * Process intermediate periods to create final parsed periods.
21080
21146
  * @param {Array.<Object>} periodsIR
21081
- * @param {Object} contextInfos
21147
+ * @param {Object} context
21082
21148
  * @returns {Array.<Object>}
21083
21149
  */
21084
21150
 
21085
- function parsePeriods(periodsIR, contextInfos) {
21151
+ function parsePeriods(periodsIR, context) {
21086
21152
  var _a, _b, _c, _d, _e, _f;
21087
21153
 
21088
21154
  var parsedPeriods = [];
21089
- var periodsTimeInformation = getPeriodsTimeInformation(periodsIR, contextInfos);
21155
+ var periodsTimeInformation = getPeriodsTimeInformation(periodsIR, context);
21090
21156
 
21091
21157
  if (periodsTimeInformation.length !== periodsIR.length) {
21092
21158
  throw new Error("MPD parsing error: the time information are incoherent.");
21093
21159
  }
21094
21160
 
21095
- var isDynamic = contextInfos.isDynamic,
21096
- timeShiftBufferDepth = contextInfos.timeShiftBufferDepth;
21161
+ var isDynamic = context.isDynamic,
21162
+ timeShiftBufferDepth = context.timeShiftBufferDepth;
21097
21163
  var manifestBoundsCalculator = new ManifestBoundsCalculator({
21098
21164
  isDynamic: isDynamic,
21099
21165
  timeShiftBufferDepth: timeShiftBufferDepth
21100
21166
  });
21101
21167
 
21102
- if (!isDynamic && contextInfos.duration != null) {
21103
- manifestBoundsCalculator.setLastPosition(contextInfos.duration);
21168
+ if (!isDynamic && context.duration != null) {
21169
+ manifestBoundsCalculator.setLastPosition(context.duration);
21104
21170
  } // We parse it in reverse because we might need to deduce the buffer depth from
21105
21171
  // the last Periods' indexes
21106
21172
 
21107
21173
 
21108
21174
  var _loop = function _loop(i) {
21175
+ var isLastPeriod = i === periodsIR.length - 1;
21109
21176
  var periodIR = periodsIR[i];
21110
- var xlinkInfos = contextInfos.xlinkInfos.get(periodIR);
21111
- var periodBaseURLs = resolveBaseURLs(contextInfos.baseURLs, periodIR.children.baseURLs);
21177
+ var xlinkInfos = context.xlinkInfos.get(periodIR);
21178
+ var periodBaseURLs = resolveBaseURLs(context.baseURLs, periodIR.children.baseURLs);
21112
21179
  var _periodsTimeInformati = periodsTimeInformation[i],
21113
21180
  periodStart = _periodsTimeInformati.periodStart,
21114
21181
  periodDuration = _periodsTimeInformati.periodDuration,
@@ -21129,27 +21196,31 @@ function parsePeriods(periodsIR, contextInfos) {
21129
21196
  periodID += "-dup";
21130
21197
  }
21131
21198
 
21132
- var receivedTime = xlinkInfos !== undefined ? xlinkInfos.receivedTime : contextInfos.receivedTime;
21133
- var unsafelyBaseOnPreviousPeriod = (_b = (_a = contextInfos.unsafelyBaseOnPreviousManifest) === null || _a === void 0 ? void 0 : _a.getPeriod(periodID)) !== null && _b !== void 0 ? _b : null;
21199
+ var receivedTime = xlinkInfos !== undefined ? xlinkInfos.receivedTime : context.receivedTime;
21200
+ var unsafelyBaseOnPreviousPeriod = (_b = (_a = context.unsafelyBaseOnPreviousManifest) === null || _a === void 0 ? void 0 : _a.getPeriod(periodID)) !== null && _b !== void 0 ? _b : null;
21134
21201
  var availabilityTimeComplete = (_c = periodIR.attributes.availabilityTimeComplete) !== null && _c !== void 0 ? _c : true;
21135
21202
  var availabilityTimeOffset = (_d = periodIR.attributes.availabilityTimeOffset) !== null && _d !== void 0 ? _d : 0;
21136
- var periodInfos = {
21137
- aggressiveMode: contextInfos.aggressiveMode,
21203
+ var aggressiveMode = context.aggressiveMode,
21204
+ manifestProfiles = context.manifestProfiles;
21205
+ var segmentTemplate = periodIR.children.segmentTemplate;
21206
+ var adapCtxt = {
21207
+ aggressiveMode: aggressiveMode,
21138
21208
  availabilityTimeComplete: availabilityTimeComplete,
21139
21209
  availabilityTimeOffset: availabilityTimeOffset,
21140
21210
  baseURLs: periodBaseURLs,
21141
21211
  manifestBoundsCalculator: manifestBoundsCalculator,
21142
21212
  end: periodEnd,
21143
21213
  isDynamic: isDynamic,
21144
- manifestProfiles: contextInfos.manifestProfiles,
21214
+ isLastPeriod: isLastPeriod,
21215
+ manifestProfiles: manifestProfiles,
21145
21216
  receivedTime: receivedTime,
21146
- segmentTemplate: periodIR.children.segmentTemplate,
21217
+ segmentTemplate: segmentTemplate,
21147
21218
  start: periodStart,
21148
21219
  timeShiftBufferDepth: timeShiftBufferDepth,
21149
21220
  unsafelyBaseOnPreviousPeriod: unsafelyBaseOnPreviousPeriod
21150
21221
  };
21151
- var adaptations = parseAdaptationSets(periodIR.children.adaptations, periodInfos);
21152
- var namespaces = ((_e = contextInfos.xmlNamespaces) !== null && _e !== void 0 ? _e : []).concat((_f = periodIR.attributes.namespaces) !== null && _f !== void 0 ? _f : []);
21222
+ var adaptations = parseAdaptationSets(periodIR.children.adaptations, adapCtxt);
21223
+ var namespaces = ((_e = context.xmlNamespaces) !== null && _e !== void 0 ? _e : []).concat((_f = periodIR.attributes.namespaces) !== null && _f !== void 0 ? _f : []);
21153
21224
  var streamEvents = generateStreamEvents(periodIR.children.eventStreams, periodStart, namespaces);
21154
21225
  var parsedPeriod = {
21155
21226
  id: periodID,
@@ -21174,7 +21245,7 @@ function parsePeriods(periodsIR, contextInfos) {
21174
21245
 
21175
21246
  manifestBoundsCalculator.setLastPosition(_lastPosition, _positionTime);
21176
21247
  } else {
21177
- var _guessedLastPositionFromClock = guessLastPositionFromClock(contextInfos, periodStart);
21248
+ var _guessedLastPositionFromClock = guessLastPositionFromClock(context, periodStart);
21178
21249
 
21179
21250
  if (_guessedLastPositionFromClock !== undefined) {
21180
21251
  var guessedLastPosition = _guessedLastPositionFromClock[0],
@@ -21190,9 +21261,9 @@ function parsePeriods(periodsIR, contextInfos) {
21190
21261
  _loop(i);
21191
21262
  }
21192
21263
 
21193
- if (contextInfos.isDynamic && !manifestBoundsCalculator.lastPositionIsKnown()) {
21264
+ if (context.isDynamic && !manifestBoundsCalculator.lastPositionIsKnown()) {
21194
21265
  // Guess a last time the last position
21195
- var guessedLastPositionFromClock = guessLastPositionFromClock(contextInfos, 0);
21266
+ var guessedLastPositionFromClock = guessLastPositionFromClock(context, 0);
21196
21267
 
21197
21268
  if (guessedLastPositionFromClock !== undefined) {
21198
21269
  var lastPosition = guessedLastPositionFromClock[0],
@@ -21226,14 +21297,14 @@ function parsePeriods(periodsIR, contextInfos) {
21226
21297
  * the live time more directly from that previous one, we might be better off
21227
21298
  * than just using the clock.
21228
21299
  *
21229
- * @param {Object} contextInfos
21300
+ * @param {Object} context
21230
21301
  * @param {number} minimumTime
21231
21302
  * @returns {Array.<number|undefined>}
21232
21303
  */
21233
21304
 
21234
- function guessLastPositionFromClock(contextInfos, minimumTime) {
21235
- if (contextInfos.clockOffset != null) {
21236
- var lastPosition = contextInfos.clockOffset / 1000 - contextInfos.availabilityStartTime;
21305
+ function guessLastPositionFromClock(context, minimumTime) {
21306
+ if (context.clockOffset != null) {
21307
+ var lastPosition = context.clockOffset / 1000 - context.availabilityStartTime;
21237
21308
  var positionTime = performance.now() / 1000;
21238
21309
  var timeInSec = positionTime + lastPosition;
21239
21310
 
@@ -21246,7 +21317,7 @@ function guessLastPositionFromClock(contextInfos, minimumTime) {
21246
21317
  if (now >= minimumTime) {
21247
21318
  log/* default.warn */.Z.warn("DASH Parser: no clock synchronization mechanism found." + " Using the system clock instead.");
21248
21319
 
21249
- var _lastPosition2 = now - contextInfos.availabilityStartTime;
21320
+ var _lastPosition2 = now - context.availabilityStartTime;
21250
21321
 
21251
21322
  var _positionTime2 = performance.now() / 1000;
21252
21323
 
@@ -24026,28 +24097,35 @@ function parseFromDocument(document, args) {
24026
24097
  * Remove segments which starts before the given `firstAvailablePosition` from
24027
24098
  * the timeline. `firstAvailablePosition` has to be time scaled.
24028
24099
  * @param {Array.<Object>}
24029
- * @returns {number}
24100
+ * @returns {number} - Returns the number of removed segments. This includes
24101
+ * potential implicit segment from decremented `repeatCount` attributes.
24030
24102
  */
24031
24103
  function clearTimelineFromPosition(timeline, firstAvailablePosition) {
24104
+ var nbEltsRemoved = 0;
24105
+
24032
24106
  while (timeline.length > 0) {
24033
24107
  var firstElt = timeline[0];
24034
24108
 
24035
24109
  if (firstElt.start >= firstAvailablePosition) {
24036
- return; // all clear
24110
+ return nbEltsRemoved; // all clear
24037
24111
  }
24038
24112
 
24039
- if (firstElt.repeatCount <= 0) {
24113
+ if (firstElt.repeatCount === -1) {
24114
+ return nbEltsRemoved;
24115
+ } else if (firstElt.repeatCount === 0) {
24040
24116
  timeline.shift();
24117
+ nbEltsRemoved += 1;
24041
24118
  } else {
24042
24119
  // we have a segment repetition
24043
24120
  var nextElt = timeline[1];
24044
24121
 
24045
24122
  if (nextElt !== undefined && nextElt.start <= firstAvailablePosition) {
24046
24123
  timeline.shift();
24124
+ nbEltsRemoved += 1;
24047
24125
  } else {
24048
24126
  // no next segment or next segment is available
24049
24127
  if (firstElt.duration <= 0) {
24050
- return;
24128
+ return nbEltsRemoved;
24051
24129
  }
24052
24130
 
24053
24131
  var nextStart = firstElt.start + firstElt.duration;
@@ -24061,16 +24139,20 @@ function clearTimelineFromPosition(timeline, firstAvailablePosition) {
24061
24139
  if (nextRepeat > firstElt.repeatCount) {
24062
24140
  // every start is before
24063
24141
  timeline.shift();
24142
+ nbEltsRemoved = firstElt.repeatCount + 1;
24064
24143
  } else {
24065
24144
  // some repetitions start after and some before
24066
24145
  var newRepeat = firstElt.repeatCount - nextRepeat;
24067
24146
  firstElt.start = nextStart;
24068
24147
  firstElt.repeatCount = newRepeat;
24069
- return;
24148
+ nbEltsRemoved += nextRepeat;
24149
+ return nbEltsRemoved;
24070
24150
  }
24071
24151
  }
24072
24152
  }
24073
24153
  }
24154
+
24155
+ return nbEltsRemoved;
24074
24156
  }
24075
24157
 
24076
24158
  /***/ }),
@@ -24353,22 +24435,29 @@ function isSegmentStillAvailable(segment, timeline, timescale, indexTimeOffset)
24353
24435
  /**
24354
24436
  * Update a complete array of segments in a given timeline with a [generally]
24355
24437
  * smaller but [generally] newer set of segments.
24438
+ *
24439
+ * Returns a boolean:
24440
+ * - If set to `true`, the old timeline was emptied and completely replaced by
24441
+ * the content of the newer timeline.
24442
+ * This could happen either if a problem happened while trying to update or
24443
+ * when the update is actually bigger than what it is updating.
24444
+ * - If set to `false`, the older timeline was either updated to add the newer
24445
+ * segments, or untouched.
24446
+ *
24356
24447
  * @param {Array.<Object>} oldTimeline
24357
24448
  * @param {Array.<Object>} newTimeline
24449
+ * @returns {boolean}
24358
24450
  */
24359
24451
 
24360
24452
  function updateSegmentTimeline(oldTimeline, newTimeline) {
24361
- var prevTimelineLength = oldTimeline.length;
24362
-
24363
24453
  if (oldTimeline.length === 0) {
24364
- oldTimeline.splice.apply(oldTimeline, [0, prevTimelineLength].concat(newTimeline));
24365
- return;
24366
- }
24367
-
24368
- if (newTimeline.length === 0) {
24369
- return;
24454
+ oldTimeline.push.apply(oldTimeline, newTimeline);
24455
+ return true;
24456
+ } else if (newTimeline.length === 0) {
24457
+ return false;
24370
24458
  }
24371
24459
 
24460
+ var prevTimelineLength = oldTimeline.length;
24372
24461
  var newIndexStart = newTimeline[0].start;
24373
24462
  var oldLastElt = oldTimeline[prevTimelineLength - 1];
24374
24463
  var oldIndexEnd = (0,_index_helpers__WEBPACK_IMPORTED_MODULE_0__/* .getIndexSegmentEnd */ .jH)(oldLastElt, newTimeline[0]);
@@ -24382,24 +24471,26 @@ function updateSegmentTimeline(oldTimeline, newTimeline) {
24382
24471
 
24383
24472
  if (currStart === newIndexStart) {
24384
24473
  // replace that one and those after it
24385
- oldTimeline.splice.apply(oldTimeline, [i, prevTimelineLength - i].concat(newTimeline));
24386
- return;
24474
+ var nbEltsToRemove = prevTimelineLength - i;
24475
+ oldTimeline.splice.apply(oldTimeline, [i, nbEltsToRemove].concat(newTimeline));
24476
+ return false;
24387
24477
  } else if (currStart < newIndexStart) {
24388
24478
  // first to be before
24389
24479
  var currElt = oldTimeline[i];
24390
24480
 
24391
24481
  if (currElt.start + currElt.duration > newIndexStart) {
24392
- // the new Manifest overlaps a previous segment (weird). Remove the latter.
24393
- _log__WEBPACK_IMPORTED_MODULE_2__/* ["default"].warn */ .Z.warn("RepresentationIndex: Manifest update removed previous segments");
24394
- oldTimeline.splice.apply(oldTimeline, [i, prevTimelineLength - i].concat(newTimeline));
24395
- return;
24482
+ // The new Manifest overlaps a previous segment (weird)
24483
+ // In that improbable case, we'll just completely replace segments
24484
+ _log__WEBPACK_IMPORTED_MODULE_2__/* ["default"].warn */ .Z.warn("RepresentationIndex: Manifest update removed all previous segments");
24485
+ oldTimeline.splice.apply(oldTimeline, [0, prevTimelineLength].concat(newTimeline));
24486
+ return true;
24396
24487
  } else if (currElt.repeatCount === undefined || currElt.repeatCount <= 0) {
24397
24488
  if (currElt.repeatCount < 0) {
24398
24489
  currElt.repeatCount = Math.floor((newIndexStart - currElt.start) / currElt.duration) - 1;
24399
24490
  }
24400
24491
 
24401
24492
  oldTimeline.splice.apply(oldTimeline, [i + 1, prevTimelineLength - (i + 1)].concat(newTimeline));
24402
- return;
24493
+ return false;
24403
24494
  } // else, there is a positive repeat we might want to update
24404
24495
 
24405
24496
 
@@ -24409,7 +24500,7 @@ function updateSegmentTimeline(oldTimeline, newTimeline) {
24409
24500
  // our new index comes directly after
24410
24501
  // put it after this one
24411
24502
  oldTimeline.splice.apply(oldTimeline, [i + 1, prevTimelineLength - (i + 1)].concat(newTimeline));
24412
- return;
24503
+ return false;
24413
24504
  }
24414
24505
 
24415
24506
  var newCurrRepeat = (newIndexStart - currElt.start) / currElt.duration - 1;
@@ -24421,14 +24512,14 @@ function updateSegmentTimeline(oldTimeline, newTimeline) {
24421
24512
  oldTimeline.splice.apply(oldTimeline, [i, prevTimelineLength - i].concat(newTimeline));
24422
24513
  oldTimeline[i].start = currElt.start;
24423
24514
  oldTimeline[i].repeatCount = newRepeatCount;
24424
- return;
24515
+ return false;
24425
24516
  }
24426
24517
 
24427
24518
  _log__WEBPACK_IMPORTED_MODULE_2__/* ["default"].warn */ .Z.warn("RepresentationIndex: Manifest update removed previous segments");
24428
24519
  oldTimeline[i].repeatCount = Math.floor(newCurrRepeat); // put it after this one
24429
24520
 
24430
24521
  oldTimeline.splice.apply(oldTimeline, [i + 1, prevTimelineLength - (i + 1)].concat(newTimeline));
24431
- return;
24522
+ return false;
24432
24523
  }
24433
24524
  } // if we got here, it means that every segments in the previous manifest are
24434
24525
  // after the new one. This is unusual.
@@ -24441,12 +24532,12 @@ function updateSegmentTimeline(oldTimeline, newTimeline) {
24441
24532
  if (prevLastElt.repeatCount !== undefined && prevLastElt.repeatCount < 0) {
24442
24533
  if (prevLastElt.start > newLastElt.start) {
24443
24534
  _log__WEBPACK_IMPORTED_MODULE_2__/* ["default"].warn */ .Z.warn("RepresentationIndex: The new index is older than the previous one");
24444
- return; // the old comes after
24535
+ return false;
24445
24536
  } else {
24446
24537
  // the new has more depth
24447
24538
  _log__WEBPACK_IMPORTED_MODULE_2__/* ["default"].warn */ .Z.warn("RepresentationIndex: The new index is \"bigger\" than the previous one");
24448
24539
  oldTimeline.splice.apply(oldTimeline, [0, prevTimelineLength].concat(newTimeline));
24449
- return;
24540
+ return true;
24450
24541
  }
24451
24542
  }
24452
24543
 
@@ -24455,13 +24546,13 @@ function updateSegmentTimeline(oldTimeline, newTimeline) {
24455
24546
 
24456
24547
  if (prevLastTime >= newLastTime) {
24457
24548
  _log__WEBPACK_IMPORTED_MODULE_2__/* ["default"].warn */ .Z.warn("RepresentationIndex: The new index is older than the previous one");
24458
- return; // the old comes after
24549
+ return false;
24459
24550
  } // the new one has more depth. full update
24460
24551
 
24461
24552
 
24462
24553
  _log__WEBPACK_IMPORTED_MODULE_2__/* ["default"].warn */ .Z.warn("RepresentationIndex: The new index is \"bigger\" than the previous one");
24463
24554
  oldTimeline.splice.apply(oldTimeline, [0, prevTimelineLength].concat(newTimeline));
24464
- return;
24555
+ return true;
24465
24556
  }
24466
24557
 
24467
24558
  /***/ }),
@@ -29113,9 +29204,8 @@ __webpack_require__.d(__webpack_exports__, {
29113
29204
  var features = __webpack_require__(7874);
29114
29205
  // EXTERNAL MODULE: ./src/transports/utils/generate_manifest_loader.ts + 1 modules
29115
29206
  var generate_manifest_loader = __webpack_require__(8791);
29116
- // EXTERNAL MODULE: ./node_modules/pinkie/index.js
29117
- var pinkie = __webpack_require__(8555);
29118
- var pinkie_default = /*#__PURE__*/__webpack_require__.n(pinkie);
29207
+ // EXTERNAL MODULE: ./src/utils/promise.ts
29208
+ var promise = __webpack_require__(9589);
29119
29209
  // EXTERNAL MODULE: ./src/utils/request/index.ts + 1 modules
29120
29210
  var request = __webpack_require__(4597);
29121
29211
  // EXTERNAL MODULE: ./src/utils/take_first_set.ts
@@ -29153,7 +29243,7 @@ function imageLoader(url, content, cancelSignal, callbacks) {
29153
29243
  var segment = content.segment;
29154
29244
 
29155
29245
  if (segment.isInit || url === null) {
29156
- return pinkie_default().resolve({
29246
+ return promise/* default.resolve */.Z.resolve({
29157
29247
  resultType: "segment-created",
29158
29248
  resultData: null
29159
29249
  });
@@ -29351,7 +29441,7 @@ function generateManifestParser(options) {
29351
29441
  }
29352
29442
 
29353
29443
  if (cancelSignal.isCancelled) {
29354
- return pinkie_default().reject(cancelSignal.cancellationError);
29444
+ return promise/* default.reject */.Z.reject(cancelSignal.cancellationError);
29355
29445
  }
29356
29446
 
29357
29447
  var manifest = new src_manifest/* default */.ZP(parserResponse.value.parsed, options);
@@ -29412,7 +29502,7 @@ function generateManifestParser(options) {
29412
29502
  });
29413
29503
  });
29414
29504
  });
29415
- return pinkie_default().all(externalResources).then(function (loadedResources) {
29505
+ return promise/* default.all */.Z.all(externalResources).then(function (loadedResources) {
29416
29506
  if (value.format === "string") {
29417
29507
  assertLoadedResourcesFormatString(loadedResources);
29418
29508
  return processMpdParserResponse(value["continue"](loadedResources));
@@ -29631,11 +29721,16 @@ function fetchRequest(options) {
29631
29721
  cancellation = err;
29632
29722
  abortFetch();
29633
29723
  });
29634
- return fetch(options.url, {
29635
- headers: headers,
29636
- method: "GET",
29637
- signal: !(0,is_null_or_undefined/* default */.Z)(abortController) ? abortController.signal : undefined
29638
- }).then(function (response) {
29724
+ var fetchOpts = {
29725
+ method: "GET"
29726
+ };
29727
+
29728
+ if (headers !== undefined) {
29729
+ fetchOpts.headers = headers;
29730
+ }
29731
+
29732
+ fetchOpts.signal = !(0,is_null_or_undefined/* default */.Z)(abortController) ? abortController.signal : null;
29733
+ return fetch(options.url, fetchOpts).then(function (response) {
29639
29734
  if (!(0,is_null_or_undefined/* default */.Z)(timeout)) {
29640
29735
  clearTimeout(timeout);
29641
29736
  }
@@ -29821,6 +29916,7 @@ var check_isobmff_integrity = __webpack_require__(4460);
29821
29916
 
29822
29917
 
29823
29918
 
29919
+
29824
29920
  /**
29825
29921
  * Add multiple checks on the response given by the `segmentLoader` in argument.
29826
29922
  * If the response appear to be corrupted, the returned Promise will reject with
@@ -29831,7 +29927,7 @@ var check_isobmff_integrity = __webpack_require__(4460);
29831
29927
 
29832
29928
  function addSegmentIntegrityChecks(segmentLoader) {
29833
29929
  return function (url, content, initialCancelSignal, callbacks) {
29834
- return new Promise(function (res, rej) {
29930
+ return new promise/* default */.Z(function (res, rej) {
29835
29931
  var canceller = new task_canceller/* default */.ZP();
29836
29932
  var unregisterCancelLstnr = initialCancelSignal.register(function onCheckCancellation(err) {
29837
29933
  canceller.cancel();
@@ -29986,7 +30082,7 @@ function initSegmentLoader(url, segment, cancelSignal, callbacks) {
29986
30082
  cancelSignal: cancelSignal,
29987
30083
  onProgress: callbacks.onProgress
29988
30084
  });
29989
- return pinkie_default().all([rangeRequest$, indexRequest$]).then(function (_ref) {
30085
+ return promise/* default.all */.Z.all([rangeRequest$, indexRequest$]).then(function (_ref) {
29990
30086
  var initData = _ref[0],
29991
30087
  indexData = _ref[1];
29992
30088
  var data = (0,byte_parsing/* concat */.zo)(new Uint8Array(initData.responseData), new Uint8Array(indexData.responseData));
@@ -30246,7 +30342,7 @@ function generateSegmentLoader(_ref) {
30246
30342
 
30247
30343
  function segmentLoader(url, content, cancelSignal, callbacks) {
30248
30344
  if (url == null) {
30249
- return pinkie_default().resolve({
30345
+ return promise/* default.resolve */.Z.resolve({
30250
30346
  resultType: "segment-created",
30251
30347
  resultData: null
30252
30348
  });
@@ -30265,7 +30361,7 @@ function generateSegmentLoader(_ref) {
30265
30361
  transport: "dash",
30266
30362
  url: url
30267
30363
  };
30268
- return new Promise(function (res, rej) {
30364
+ return new promise/* default */.Z(function (res, rej) {
30269
30365
  /** `true` when the custom segmentLoader should not be active anymore. */
30270
30366
  var hasFinished = false;
30271
30367
  /**
@@ -31062,7 +31158,7 @@ function generateTextTrackLoader(_ref) {
31062
31158
  var range = segment.range;
31063
31159
 
31064
31160
  if (url === null) {
31065
- return pinkie_default().resolve({
31161
+ return promise/* default.resolve */.Z.resolve({
31066
31162
  resultType: "segment-created",
31067
31163
  resultData: null
31068
31164
  });
@@ -31596,9 +31692,6 @@ __webpack_require__.d(__webpack_exports__, {
31596
31692
  "Z": function() { return /* binding */ transports_smooth; }
31597
31693
  });
31598
31694
 
31599
- // EXTERNAL MODULE: ./node_modules/pinkie/index.js
31600
- var pinkie = __webpack_require__(8555);
31601
- var pinkie_default = /*#__PURE__*/__webpack_require__.n(pinkie);
31602
31695
  // EXTERNAL MODULE: ./src/features/index.ts
31603
31696
  var features = __webpack_require__(7874);
31604
31697
  // EXTERNAL MODULE: ./src/log.ts + 1 modules
@@ -33324,6 +33417,8 @@ function createPSSHBox(systemId, privateData) {
33324
33417
 
33325
33418
  /* harmony default export */ var smooth = (create_parser);
33326
33419
 
33420
+ // EXTERNAL MODULE: ./src/utils/promise.ts
33421
+ var promise = __webpack_require__(9589);
33327
33422
  // EXTERNAL MODULE: ./src/utils/request/index.ts + 1 modules
33328
33423
  var request = __webpack_require__(4597);
33329
33424
  // EXTERNAL MODULE: ./src/utils/warn_once.ts
@@ -34587,12 +34682,12 @@ var generateSegmentLoader = function generateSegmentLoader(_ref) {
34587
34682
  responseData = new Uint8Array(0);
34588
34683
  }
34589
34684
 
34590
- return pinkie_default().resolve({
34685
+ return promise/* default.resolve */.Z.resolve({
34591
34686
  resultType: "segment-created",
34592
34687
  resultData: responseData
34593
34688
  });
34594
34689
  } else if (url === null) {
34595
- return pinkie_default().resolve({
34690
+ return promise/* default.resolve */.Z.resolve({
34596
34691
  resultType: "segment-created",
34597
34692
  resultData: null
34598
34693
  });
@@ -34611,7 +34706,7 @@ var generateSegmentLoader = function generateSegmentLoader(_ref) {
34611
34706
  return regularSegmentLoader(url, content, callbacks, cancelSignal, checkMediaSegmentIntegrity);
34612
34707
  }
34613
34708
 
34614
- return new Promise(function (res, rej) {
34709
+ return new promise/* default */.Z(function (res, rej) {
34615
34710
  /** `true` when the custom segmentLoader should not be active anymore. */
34616
34711
  var hasFinished = false;
34617
34712
  /**
@@ -34792,7 +34887,7 @@ function addNextSegments(adaptation, nextSegments, dlSegment) {
34792
34887
  // TODO (v4.x.x) Remove that function
34793
34888
  resolveManifestUrl: function resolveManifestUrl(url, cancelSignal) {
34794
34889
  if (url === undefined) {
34795
- return pinkie_default().resolve(undefined);
34890
+ return promise/* default.resolve */.Z.resolve(undefined);
34796
34891
  }
34797
34892
 
34798
34893
  var resolving;
@@ -34813,7 +34908,7 @@ function addNextSegments(adaptation, nextSegments, dlSegment) {
34813
34908
  return extractedURL;
34814
34909
  });
34815
34910
  } else {
34816
- resolving = pinkie_default().resolve(url);
34911
+ resolving = promise/* default.resolve */.Z.resolve(url);
34817
34912
  }
34818
34913
 
34819
34914
  var token = extractToken(url);
@@ -34933,7 +35028,7 @@ function addNextSegments(adaptation, nextSegments, dlSegment) {
34933
35028
  representation = content.representation;
34934
35029
 
34935
35030
  if (segment.isInit || url === null) {
34936
- return pinkie_default().resolve({
35031
+ return promise/* default.resolve */.Z.resolve({
34937
35032
  resultType: "segment-created",
34938
35033
  resultData: null
34939
35034
  });
@@ -35128,7 +35223,7 @@ function addNextSegments(adaptation, nextSegments, dlSegment) {
35128
35223
  loadSegment: function loadSegment(url, content, cancelSignal, callbacks) {
35129
35224
  if (content.segment.isInit || url === null) {
35130
35225
  // image do not need an init segment. Passthrough directly to the parser
35131
- return pinkie_default().resolve({
35226
+ return promise/* default.resolve */.Z.resolve({
35132
35227
  resultType: "segment-created",
35133
35228
  resultData: null
35134
35229
  });
@@ -35427,11 +35522,10 @@ __webpack_require__.d(__webpack_exports__, {
35427
35522
  var assert_unreachable = __webpack_require__(7904);
35428
35523
  // EXTERNAL MODULE: ./src/utils/request/index.ts + 1 modules
35429
35524
  var request = __webpack_require__(4597);
35430
- // EXTERNAL MODULE: ./node_modules/pinkie/index.js
35431
- var pinkie = __webpack_require__(8555);
35432
- var pinkie_default = /*#__PURE__*/__webpack_require__.n(pinkie);
35433
35525
  // EXTERNAL MODULE: ./src/errors/custom_loader_error.ts
35434
35526
  var custom_loader_error = __webpack_require__(7839);
35527
+ // EXTERNAL MODULE: ./src/utils/promise.ts
35528
+ var promise = __webpack_require__(9589);
35435
35529
  ;// CONCATENATED MODULE: ./src/transports/utils/call_custom_manifest_loader.ts
35436
35530
  /**
35437
35531
  * Copyright 2015 CANAL+ Group
@@ -35452,7 +35546,7 @@ var custom_loader_error = __webpack_require__(7839);
35452
35546
 
35453
35547
  function callCustomManifestLoader(customManifestLoader, fallbackManifestLoader) {
35454
35548
  return function (url, cancelSignal) {
35455
- return new (pinkie_default())(function (res, rej) {
35549
+ return new promise/* default */.Z(function (res, rej) {
35456
35550
  var timeAPIsDelta = Date.now() - performance.now();
35457
35551
  /** `true` when the custom segmentLoader should not be active anymore. */
35458
35552
 
@@ -36456,12 +36550,11 @@ function toUint8Array(input) {
36456
36550
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
36457
36551
 
36458
36552
  "use strict";
36459
- /* harmony import */ var pinkie__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8555);
36460
- /* harmony import */ var pinkie__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(pinkie__WEBPACK_IMPORTED_MODULE_0__);
36461
- /* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1480);
36553
+ /* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1480);
36462
36554
  /* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3102);
36463
36555
  /* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2817);
36464
36556
  /* harmony import */ var _is_null_or_undefined__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1946);
36557
+ /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9589);
36465
36558
  /**
36466
36559
  * Copyright 2015 CANAL+ Group
36467
36560
  *
@@ -36488,9 +36581,9 @@ function toUint8Array(input) {
36488
36581
  */
36489
36582
 
36490
36583
  function castToObservable(value) {
36491
- if (value instanceof rxjs__WEBPACK_IMPORTED_MODULE_1__/* .Observable */ .y) {
36584
+ if (value instanceof rxjs__WEBPACK_IMPORTED_MODULE_0__/* .Observable */ .y) {
36492
36585
  return value;
36493
- } else if (value instanceof (pinkie__WEBPACK_IMPORTED_MODULE_0___default()) || value instanceof Promise || !(0,_is_null_or_undefined__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z)(value) && typeof value.then === "function") {
36586
+ } else if (value instanceof _promise__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z || value instanceof Promise || !(0,_is_null_or_undefined__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z)(value) && typeof value.then === "function") {
36494
36587
  return (0,rxjs__WEBPACK_IMPORTED_MODULE_3__/* .from */ .D)(value);
36495
36588
  }
36496
36589
 
@@ -38516,6 +38609,8 @@ var request_error = __webpack_require__(9105);
38516
38609
  var is_non_empty_string = __webpack_require__(6923);
38517
38610
  // EXTERNAL MODULE: ./src/utils/is_null_or_undefined.ts
38518
38611
  var is_null_or_undefined = __webpack_require__(1946);
38612
+ // EXTERNAL MODULE: ./src/utils/promise.ts
38613
+ var promise = __webpack_require__(9589);
38519
38614
  ;// CONCATENATED MODULE: ./src/utils/request/xhr.ts
38520
38615
  /**
38521
38616
  * Copyright 2015 CANAL+ Group
@@ -38536,6 +38631,7 @@ var is_null_or_undefined = __webpack_require__(1946);
38536
38631
 
38537
38632
 
38538
38633
 
38634
+
38539
38635
  var DEFAULT_REQUEST_TIMEOUT = config/* default.DEFAULT_REQUEST_TIMEOUT */.Z.DEFAULT_REQUEST_TIMEOUT;
38540
38636
  var DEFAULT_RESPONSE_TYPE = "json";
38541
38637
  function request(options) {
@@ -38545,7 +38641,7 @@ function request(options) {
38545
38641
  responseType: (0,is_null_or_undefined/* default */.Z)(options.responseType) ? DEFAULT_RESPONSE_TYPE : options.responseType,
38546
38642
  timeout: (0,is_null_or_undefined/* default */.Z)(options.timeout) ? DEFAULT_REQUEST_TIMEOUT : options.timeout
38547
38643
  };
38548
- return new Promise(function (resolve, reject) {
38644
+ return new promise/* default */.Z(function (resolve, reject) {
38549
38645
  var onProgress = options.onProgress,
38550
38646
  cancelSignal = options.cancelSignal;
38551
38647
  var url = requestOptions.url,
@@ -45154,9 +45250,6 @@ var asyncToGenerator = __webpack_require__(5861);
45154
45250
  // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js
45155
45251
  var regenerator = __webpack_require__(7757);
45156
45252
  var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);
45157
- // EXTERNAL MODULE: ./node_modules/pinkie/index.js
45158
- var pinkie = __webpack_require__(8555);
45159
- var pinkie_default = /*#__PURE__*/__webpack_require__.n(pinkie);
45160
45253
  // EXTERNAL MODULE: ./src/utils/assert.ts
45161
45254
  var assert = __webpack_require__(811);
45162
45255
  // EXTERNAL MODULE: ./src/utils/task_canceller.ts
@@ -45280,7 +45373,7 @@ var is_known_error = __webpack_require__(9822);
45280
45373
  */
45281
45374
 
45282
45375
  function cancellableSleep(delay, cancellationSignal) {
45283
- return new (pinkie_default())(function (res, rej) {
45376
+ return new promise/* default */.Z(function (res, rej) {
45284
45377
  var timeout = setTimeout(function () {
45285
45378
  unregisterCancelSignal();
45286
45379
  res();
@@ -45429,7 +45522,7 @@ function getRequestErrorType(error) {
45429
45522
 
45430
45523
  function tryURLsWithBackoff(urls, performRequest, options, cancellationSignal) {
45431
45524
  if (cancellationSignal.isCancelled) {
45432
- return pinkie_default().reject(cancellationSignal.cancellationError);
45525
+ return promise/* default.reject */.Z.reject(cancellationSignal.cancellationError);
45433
45526
  }
45434
45527
 
45435
45528
  var baseDelay = options.baseDelay,
@@ -45445,7 +45538,7 @@ function tryURLsWithBackoff(urls, performRequest, options, cancellationSignal) {
45445
45538
 
45446
45539
  if (urlsToTry.length === 0) {
45447
45540
  log/* default.warn */.Z.warn("Fetchers: no URL given to `tryURLsWithBackoff`.");
45448
- return pinkie_default().reject(new Error("No URL to request"));
45541
+ return promise/* default.reject */.Z.reject(new Error("No URL to request"));
45449
45542
  }
45450
45543
 
45451
45544
  return tryURLsRecursively(urlsToTry[0], 0);
@@ -46004,7 +46097,7 @@ var ManifestFetcher = /*#__PURE__*/function () {
46004
46097
 
46005
46098
 
46006
46099
  function isPromise(val) {
46007
- return val instanceof (pinkie_default()) || val instanceof Promise;
46100
+ return val instanceof promise/* default */.Z || val instanceof Promise;
46008
46101
  }
46009
46102
  ;// CONCATENATED MODULE: ./src/core/fetchers/manifest/index.ts
46010
46103
  /**
@@ -46780,7 +46873,8 @@ function segment_fetcher_createSegmentFetcher(bufferType, pipeline, callbacks, o
46780
46873
  /**
46781
46874
  * If the request succeeded, set to the corresponding
46782
46875
  * `IChunkCompleteInformation` object.
46783
- * If the request failed or was cancelled, set to `null`.
46876
+ * For any other completion cases: if the request either failed, was
46877
+ * cancelled or just if no request was needed, set to `null`.
46784
46878
  *
46785
46879
  * Stays to `undefined` when the request is still pending.
46786
46880
  */
@@ -46895,6 +46989,8 @@ function segment_fetcher_createSegmentFetcher(bufferType, pipeline, callbacks, o
46895
46989
  if (res.resultType !== "segment-created") {
46896
46990
  requestInfo = res.resultData;
46897
46991
  sendNetworkMetricsIfAvailable();
46992
+ } else {
46993
+ requestInfo = null;
46898
46994
  }
46899
46995
 
46900
46996
  if (!canceller.isUsed) {
@@ -47467,7 +47563,7 @@ function getBufferLevels(bitrates) {
47467
47563
  return Vp * (gp + (bitrates[boundedIndex] * utilities[boundedIndex - 1] - bitrates[boundedIndex - 1] * utilities[boundedIndex]) / (bitrates[boundedIndex] - bitrates[boundedIndex - 1])) + 4;
47468
47564
  }
47469
47565
  }
47470
- ;// CONCATENATED MODULE: ./src/core/abr/get_estimate_from_buffer_levels.ts
47566
+ ;// CONCATENATED MODULE: ./src/core/abr/buffer_based_chooser.ts
47471
47567
  /**
47472
47568
  * Copyright 2015 CANAL+ Group
47473
47569
  *
@@ -47485,123 +47581,111 @@ function getBufferLevels(bitrates) {
47485
47581
  */
47486
47582
 
47487
47583
 
47584
+
47488
47585
  /**
47489
- * From the buffer gap, choose a representation.
47490
- * @param {Object} playbackObservation
47491
- * @param {Array.<Number>} bitrates
47492
- * @param {Array.<Number>} bufferLevels
47493
- * @returns {Object|undefined}
47586
+ * Choose a bitrate based on the currently available buffer.
47587
+ *
47588
+ * This algorithm is based on the deviation of the BOLA algorithm.
47589
+ * It is a hybrid solution that also relies on a given bitrate's
47590
+ * "maintainability".
47591
+ * Each time a chunk is downloaded, from the ratio between the chunk duration
47592
+ * and chunk's request time, we can assume that the representation is
47593
+ * "maintanable" or not.
47594
+ * If so, we may switch to a better quality, or conversely to a worse quality.
47595
+ *
47596
+ * @class BufferBasedChooser
47494
47597
  */
47495
47598
 
47496
- function getEstimateFromBufferLevels(playbackObservation, bitrates, bufferLevels) {
47497
- var bufferGap = playbackObservation.bufferGap,
47498
- currentBitrate = playbackObservation.currentBitrate,
47499
- currentScore = playbackObservation.currentScore,
47500
- speed = playbackObservation.speed;
47501
-
47502
- if (currentBitrate == null) {
47503
- return bitrates[0];
47599
+ var BufferBasedChooser = /*#__PURE__*/function () {
47600
+ /**
47601
+ * @param {Array.<number>} number;
47602
+ */
47603
+ function BufferBasedChooser(bitrates) {
47604
+ this._levelsMap = getBufferLevels(bitrates);
47605
+ this._bitrates = bitrates;
47606
+ log/* default.debug */.Z.debug("ABR: Steps for buffer based chooser.", this._levelsMap.map(function (l, i) {
47607
+ return {
47608
+ bufferLevel: l,
47609
+ bitrate: bitrates[i]
47610
+ };
47611
+ }));
47504
47612
  }
47613
+ /**
47614
+ * @param {Object} playbackObservation
47615
+ * @returns {number|undefined}
47616
+ */
47505
47617
 
47506
- var currentBitrateIndex = (0,array_find_index/* default */.Z)(bitrates, function (b) {
47507
- return b === currentBitrate;
47508
- });
47509
47618
 
47510
- if (currentBitrateIndex < 0 || bitrates.length !== bufferLevels.length) {
47511
- log/* default.error */.Z.error("ABR: Current Bitrate not found in the calculated levels");
47512
- return bitrates[0];
47513
- }
47619
+ var _proto = BufferBasedChooser.prototype;
47514
47620
 
47515
- var scaledScore;
47621
+ _proto.getEstimate = function getEstimate(playbackObservation) {
47622
+ var bufferLevels = this._levelsMap;
47623
+ var bitrates = this._bitrates;
47624
+ var bufferGap = playbackObservation.bufferGap,
47625
+ currentBitrate = playbackObservation.currentBitrate,
47626
+ currentScore = playbackObservation.currentScore,
47627
+ speed = playbackObservation.speed;
47516
47628
 
47517
- if (currentScore != null) {
47518
- scaledScore = speed === 0 ? currentScore : currentScore / speed;
47519
- }
47629
+ if (currentBitrate == null) {
47630
+ return bitrates[0];
47631
+ }
47520
47632
 
47521
- if (scaledScore != null && scaledScore > 1) {
47522
- var currentBufferLevel = bufferLevels[currentBitrateIndex];
47633
+ var currentBitrateIndex = (0,array_find_index/* default */.Z)(bitrates, function (b) {
47634
+ return b === currentBitrate;
47635
+ });
47523
47636
 
47524
- var nextIndex = function () {
47525
- for (var i = currentBitrateIndex + 1; i < bufferLevels.length; i++) {
47526
- if (bufferLevels[i] > currentBufferLevel) {
47527
- return i;
47528
- }
47529
- }
47530
- }();
47637
+ if (currentBitrateIndex < 0 || bitrates.length !== bufferLevels.length) {
47638
+ log/* default.error */.Z.error("ABR: Current Bitrate not found in the calculated levels");
47639
+ return bitrates[0];
47640
+ }
47531
47641
 
47532
- if (nextIndex != null) {
47533
- var nextBufferLevel = bufferLevels[nextIndex];
47642
+ var scaledScore;
47534
47643
 
47535
- if (bufferGap >= nextBufferLevel) {
47536
- return bitrates[nextIndex];
47537
- }
47644
+ if (currentScore != null) {
47645
+ scaledScore = speed === 0 ? currentScore : currentScore / speed;
47538
47646
  }
47539
- }
47540
47647
 
47541
- if (scaledScore == null || scaledScore < 1.15) {
47542
- var _currentBufferLevel = bufferLevels[currentBitrateIndex];
47648
+ if (scaledScore != null && scaledScore > 1) {
47649
+ var currentBufferLevel = bufferLevels[currentBitrateIndex];
47543
47650
 
47544
- if (bufferGap < _currentBufferLevel) {
47545
- for (var i = currentBitrateIndex - 1; i >= 0; i--) {
47546
- if (bitrates[i] < currentBitrate) {
47547
- return bitrates[i];
47651
+ var nextIndex = function () {
47652
+ for (var i = currentBitrateIndex + 1; i < bufferLevels.length; i++) {
47653
+ if (bufferLevels[i] > currentBufferLevel) {
47654
+ return i;
47655
+ }
47548
47656
  }
47549
- }
47657
+ }();
47658
+
47659
+ if (nextIndex != null) {
47660
+ var nextBufferLevel = bufferLevels[nextIndex];
47550
47661
 
47551
- return currentBitrate;
47662
+ if (bufferGap >= nextBufferLevel) {
47663
+ return bitrates[nextIndex];
47664
+ }
47665
+ }
47552
47666
  }
47553
- }
47554
47667
 
47555
- return currentBitrate;
47556
- }
47557
- ;// CONCATENATED MODULE: ./src/core/abr/buffer_based_chooser.ts
47558
- /**
47559
- * Copyright 2015 CANAL+ Group
47560
- *
47561
- * Licensed under the Apache License, Version 2.0 (the "License");
47562
- * you may not use this file except in compliance with the License.
47563
- * You may obtain a copy of the License at
47564
- *
47565
- * http://www.apache.org/licenses/LICENSE-2.0
47566
- *
47567
- * Unless required by applicable law or agreed to in writing, software
47568
- * distributed under the License is distributed on an "AS IS" BASIS,
47569
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47570
- * See the License for the specific language governing permissions and
47571
- * limitations under the License.
47572
- */
47668
+ if (scaledScore == null || scaledScore < 1.15) {
47669
+ var _currentBufferLevel = bufferLevels[currentBitrateIndex];
47573
47670
 
47671
+ if (bufferGap < _currentBufferLevel) {
47672
+ for (var i = currentBitrateIndex - 1; i >= 0; i--) {
47673
+ if (bitrates[i] < currentBitrate) {
47674
+ return bitrates[i];
47675
+ }
47676
+ }
47574
47677
 
47678
+ return currentBitrate;
47679
+ }
47680
+ }
47575
47681
 
47682
+ return currentBitrate;
47683
+ };
47684
+
47685
+ return BufferBasedChooser;
47686
+ }();
47576
47687
 
47577
- /**
47578
- * Choose a bitrate based on the currently available buffer.
47579
- *
47580
- * This algorithm is based on the deviation of the BOLA algorithm.
47581
- * It is a hybrid solution that also relies on a given bitrate's
47582
- * "maintainability".
47583
- * Each time a chunk is downloaded, from the ratio between the chunk duration
47584
- * and chunk's request time, we can assume that the representation is
47585
- * "maintanable" or not.
47586
- * If so, we may switch to a better quality, or conversely to a worse quality.
47587
- *
47588
- * @param {Observable} update$
47589
- * @param {Array.<number>} bitrates
47590
- * @returns {Observable}
47591
- */
47592
47688
 
47593
- function BufferBasedChooser(update$, bitrates) {
47594
- var levelsMap = getBufferLevels(bitrates);
47595
- log/* default.debug */.Z.debug("ABR: Steps for buffer based chooser.", levelsMap.map(function (l, i) {
47596
- return {
47597
- bufferLevel: l,
47598
- bitrate: bitrates[i]
47599
- };
47600
- }));
47601
- return update$.pipe((0,map/* map */.U)(function (playbackObservation) {
47602
- return getEstimateFromBufferLevels(playbackObservation, bitrates, levelsMap);
47603
- }));
47604
- }
47605
47689
  // EXTERNAL MODULE: ./src/utils/array_find.ts
47606
47690
  var array_find = __webpack_require__(3274);
47607
47691
  ;// CONCATENATED MODULE: ./src/core/abr/network_analyzer.ts
@@ -48396,11 +48480,8 @@ var PendingRequestsStore = /*#__PURE__*/function () {
48396
48480
 
48397
48481
  _proto.remove = function remove(id) {
48398
48482
  if (this._currentRequests[id] == null) {
48399
- // TODO This breaks github actions.
48400
- // Find why
48401
- // if (__ENVIRONMENT__.CURRENT_ENV === __ENVIRONMENT__.DEV as number) {
48402
- // throw new Error("ABR: can't remove unknown request");
48403
- // }
48483
+ if (false) {}
48484
+
48404
48485
  log/* default.warn */.Z.warn("ABR: can't remove unknown request");
48405
48486
  }
48406
48487
 
@@ -48888,7 +48969,10 @@ function RepresentationEstimator(_ref) {
48888
48969
  var bitrates = representations.map(function (r) {
48889
48970
  return r.bitrate;
48890
48971
  });
48891
- var bufferBasedEstimation$ = BufferBasedChooser(bufferBasedobservation$, bitrates).pipe((0,startWith/* startWith */.O)(undefined));
48972
+ var bufferBasedChooser = new BufferBasedChooser(bitrates);
48973
+ var bufferBasedEstimation$ = bufferBasedobservation$.pipe((0,map/* map */.U)(function (bbo) {
48974
+ return bufferBasedChooser.getEstimate(bbo);
48975
+ }), (0,startWith/* startWith */.O)(undefined));
48892
48976
  return (0,combineLatest/* combineLatest */.a)([observation$, minAutoBitrate$, maxAutoBitrate$, filters$, bufferBasedEstimation$]).pipe((0,withLatestFrom/* withLatestFrom */.M)(currentRepresentation$), (0,map/* map */.U)(function (_ref4) {
48893
48977
  var _ref4$ = _ref4[0],
48894
48978
  observation = _ref4$[0],
@@ -52228,20 +52312,19 @@ function selectGCedRanges(position, buffered, gcGap) {
52228
52312
 
52229
52313
  var cleanedupRanges = []; // start by trying to remove all ranges that do not contain the
52230
52314
  // current time and respect the gcGap
52231
- // respect the gcGap? FIXME?
52232
52315
 
52233
52316
  for (var i = 0; i < outerRanges.length; i++) {
52234
52317
  var outerRange = outerRanges[i];
52235
52318
 
52236
- if (position - gcGap < outerRange.end) {
52319
+ if (position - gcGap > outerRange.end) {
52237
52320
  cleanedupRanges.push(outerRange);
52238
- } else if (position + gcGap > outerRange.start) {
52321
+ } else if (position + gcGap < outerRange.start) {
52239
52322
  cleanedupRanges.push(outerRange);
52240
52323
  }
52241
52324
  } // try to clean up some space in the current range
52242
52325
 
52243
52326
 
52244
- if (innerRange != null) {
52327
+ if (innerRange !== null) {
52245
52328
  log/* default.debug */.Z.debug("Stream: GC removing part of inner range", cleanedupRanges);
52246
52329
 
52247
52330
  if (position - gcGap > innerRange.start) {
@@ -58518,7 +58601,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
58518
58601
  videoElement.preload = "auto";
58519
58602
  _this.version =
58520
58603
  /* PLAYER_VERSION */
58521
- "3.26.2";
58604
+ "3.26.3-dev.2022021400";
58522
58605
  _this.log = log/* default */.Z;
58523
58606
  _this.state = "STOPPED";
58524
58607
  _this.videoElement = videoElement;
@@ -61303,7 +61386,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
61303
61386
 
61304
61387
  Player.version =
61305
61388
  /* PLAYER_VERSION */
61306
- "3.26.2";
61389
+ "3.26.3-dev.2022021400";
61307
61390
  /* harmony default export */ var public_api = (Player);
61308
61391
  ;// CONCATENATED MODULE: ./src/core/api/index.ts
61309
61392
  /**