rx-player 3.30.0-dev.2023020100 → 3.30.0-dev.2023022200

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 (167) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/VERSION +1 -1
  3. package/dist/_esm5.processed/compat/eme/close_session.js +2 -2
  4. package/dist/_esm5.processed/compat/event_listeners.js +1 -1
  5. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +4 -2
  6. package/dist/_esm5.processed/core/api/debug/buffer_graph.d.ts +28 -0
  7. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +175 -0
  8. package/dist/_esm5.processed/core/api/debug/buffer_size_graph.d.ts +10 -0
  9. package/dist/_esm5.processed/core/api/debug/buffer_size_graph.js +105 -0
  10. package/dist/_esm5.processed/core/api/debug/constants.d.ts +2 -0
  11. package/dist/_esm5.processed/core/api/debug/constants.js +2 -0
  12. package/dist/_esm5.processed/core/api/debug/index.d.ts +2 -0
  13. package/dist/_esm5.processed/core/api/debug/index.js +2 -0
  14. package/dist/_esm5.processed/core/api/debug/modules/general_info.d.ts +3 -0
  15. package/dist/_esm5.processed/core/api/debug/modules/general_info.js +199 -0
  16. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.d.ts +4 -0
  17. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +121 -0
  18. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.d.ts +3 -0
  19. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +35 -0
  20. package/dist/_esm5.processed/core/api/debug/render.d.ts +3 -0
  21. package/dist/_esm5.processed/core/api/debug/render.js +32 -0
  22. package/dist/_esm5.processed/core/api/debug/utils.d.ts +39 -0
  23. package/dist/_esm5.processed/core/api/debug/utils.js +57 -0
  24. package/dist/_esm5.processed/core/api/playback_observer.js +3 -2
  25. package/dist/_esm5.processed/core/api/public_api.d.ts +3 -0
  26. package/dist/_esm5.processed/core/api/public_api.js +24 -13
  27. package/dist/_esm5.processed/core/api/utils.js +3 -3
  28. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.d.ts +5 -5
  29. package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +1 -1
  30. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +1 -1
  31. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +37 -47
  32. package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.js +4 -0
  33. package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.d.ts +17 -8
  34. package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.js +10 -6
  35. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +5 -4
  36. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +22 -5
  37. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +37 -21
  38. package/dist/_esm5.processed/core/fetchers/segment/task_prioritizer.js +21 -23
  39. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +6 -5
  40. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
  41. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +27 -31
  42. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +2 -2
  43. package/dist/_esm5.processed/core/init/utils/create_media_source.js +3 -12
  44. package/dist/_esm5.processed/core/init/utils/end_of_stream.js +6 -3
  45. package/dist/_esm5.processed/core/init/utils/get_loaded_reference.js +2 -1
  46. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +9 -5
  47. package/dist/_esm5.processed/core/init/utils/initialize_content_decryption.js +2 -1
  48. package/dist/_esm5.processed/core/init/utils/media_duration_updater.js +23 -19
  49. package/dist/_esm5.processed/core/init/utils/stream_events_emitter/stream_events_emitter.js +6 -4
  50. package/dist/_esm5.processed/core/init/utils/throw_on_media_error.js +1 -1
  51. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +7 -10
  52. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +4 -2
  53. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +13 -9
  54. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +10 -11
  55. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +26 -12
  56. package/dist/_esm5.processed/core/stream/period/period_stream.js +11 -10
  57. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +15 -15
  58. package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.js +1 -1
  59. package/dist/_esm5.processed/core/stream/representation/utils/downloading_queue.js +16 -6
  60. package/dist/_esm5.processed/experimental/features/debug_element.d.ts +8 -0
  61. package/dist/_esm5.processed/experimental/features/debug_element.js +10 -0
  62. package/dist/_esm5.processed/experimental/features/index.d.ts +1 -0
  63. package/dist/_esm5.processed/experimental/features/index.js +1 -0
  64. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +7 -4
  65. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +5 -4
  66. package/dist/_esm5.processed/features/features_object.js +1 -0
  67. package/dist/_esm5.processed/features/initialize_features.js +13 -10
  68. package/dist/_esm5.processed/features/types.d.ts +3 -0
  69. package/dist/_esm5.processed/manifest/adaptation.js +4 -0
  70. package/dist/_esm5.processed/manifest/manifest.js +2 -0
  71. package/dist/_esm5.processed/manifest/representation.js +11 -4
  72. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +105 -137
  73. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +25 -5
  74. package/dist/_esm5.processed/public_types.d.ts +1 -0
  75. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +13 -12
  76. package/dist/_esm5.processed/transports/dash/low_latency_segment_loader.js +2 -2
  77. package/dist/_esm5.processed/transports/dash/manifest_parser.js +1 -1
  78. package/dist/_esm5.processed/transports/dash/segment_loader.js +4 -4
  79. package/dist/_esm5.processed/transports/local/segment_loader.js +13 -26
  80. package/dist/_esm5.processed/transports/smooth/segment_loader.js +4 -4
  81. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
  82. package/dist/_esm5.processed/utils/cancellable_sleep.js +4 -10
  83. package/dist/_esm5.processed/utils/create_cancellable_promise.d.ts +26 -0
  84. package/dist/_esm5.processed/utils/create_cancellable_promise.js +52 -0
  85. package/dist/_esm5.processed/utils/reference.js +6 -0
  86. package/dist/_esm5.processed/utils/request/xhr.js +1 -1
  87. package/dist/_esm5.processed/utils/task_canceller.d.ts +34 -15
  88. package/dist/_esm5.processed/utils/task_canceller.js +55 -22
  89. package/dist/rx-player.js +739 -626
  90. package/dist/rx-player.min.js +1 -1
  91. package/jest.config.js +1 -0
  92. package/package.json +18 -18
  93. package/scripts/build/constants.d.ts +1 -0
  94. package/scripts/report_build_sizes +4 -0
  95. package/sonar-project.properties +1 -1
  96. package/src/compat/eme/close_session.ts +2 -2
  97. package/src/compat/event_listeners.ts +1 -1
  98. package/src/core/adaptive/adaptive_representation_selector.ts +4 -2
  99. package/src/core/api/debug/buffer_graph.ts +247 -0
  100. package/src/core/api/debug/buffer_size_graph.ts +131 -0
  101. package/src/core/api/debug/constants.ts +2 -0
  102. package/src/core/api/debug/index.ts +3 -0
  103. package/src/core/api/debug/modules/general_info.ts +204 -0
  104. package/src/core/api/debug/modules/segment_buffer_content.ts +155 -0
  105. package/src/core/api/debug/modules/segment_buffer_size.ts +48 -0
  106. package/src/core/api/debug/render.ts +40 -0
  107. package/src/core/api/debug/utils.ts +103 -0
  108. package/src/core/api/playback_observer.ts +4 -2
  109. package/src/core/api/public_api.ts +27 -13
  110. package/src/core/api/utils.ts +3 -3
  111. package/src/core/decrypt/attach_media_keys.ts +1 -1
  112. package/src/core/decrypt/content_decryptor.ts +1 -1
  113. package/src/core/decrypt/session_events_listener.ts +37 -49
  114. package/src/core/decrypt/utils/check_key_statuses.ts +6 -0
  115. package/src/core/fetchers/cdn_prioritizer.ts +18 -9
  116. package/src/core/fetchers/manifest/manifest_fetcher.ts +5 -4
  117. package/src/core/fetchers/segment/segment_fetcher.ts +36 -14
  118. package/src/core/fetchers/segment/task_prioritizer.ts +25 -30
  119. package/src/core/fetchers/utils/schedule_request.ts +6 -5
  120. package/src/core/init/directfile_content_initializer.ts +1 -1
  121. package/src/core/init/media_source_content_initializer.ts +37 -41
  122. package/src/core/init/utils/content_time_boundaries_observer.ts +2 -2
  123. package/src/core/init/utils/create_media_source.ts +4 -16
  124. package/src/core/init/utils/end_of_stream.ts +6 -3
  125. package/src/core/init/utils/get_loaded_reference.ts +2 -1
  126. package/src/core/init/utils/initial_seek_and_play.ts +9 -5
  127. package/src/core/init/utils/initialize_content_decryption.ts +2 -1
  128. package/src/core/init/utils/media_duration_updater.ts +25 -20
  129. package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +6 -4
  130. package/src/core/init/utils/throw_on_media_error.ts +1 -1
  131. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +7 -11
  132. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +4 -2
  133. package/src/core/segment_buffers/segment_buffers_store.ts +16 -13
  134. package/src/core/stream/adaptation/adaptation_stream.ts +10 -11
  135. package/src/core/stream/orchestrator/stream_orchestrator.ts +26 -12
  136. package/src/core/stream/period/period_stream.ts +11 -10
  137. package/src/core/stream/representation/representation_stream.ts +15 -15
  138. package/src/core/stream/representation/utils/append_segment_to_buffer.ts +1 -1
  139. package/src/core/stream/representation/utils/downloading_queue.ts +16 -4
  140. package/src/experimental/features/__tests__/debug_element.test.ts +26 -0
  141. package/src/experimental/features/debug_element.ts +13 -0
  142. package/src/experimental/features/index.ts +1 -0
  143. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +7 -4
  144. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +5 -4
  145. package/src/features/__tests__/initialize_features.test.ts +11 -0
  146. package/src/features/features_object.ts +1 -0
  147. package/src/features/initialize_features.ts +15 -10
  148. package/src/features/types.ts +9 -0
  149. package/src/manifest/adaptation.ts +7 -0
  150. package/src/manifest/manifest.ts +4 -0
  151. package/src/manifest/representation.ts +10 -4
  152. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +116 -151
  153. package/src/parsers/manifest/dash/common/parse_representations.ts +21 -4
  154. package/src/public_types.ts +1 -0
  155. package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +30 -24
  156. package/src/transports/dash/low_latency_segment_loader.ts +2 -2
  157. package/src/transports/dash/manifest_parser.ts +1 -1
  158. package/src/transports/dash/segment_loader.ts +4 -4
  159. package/src/transports/local/segment_loader.ts +14 -30
  160. package/src/transports/smooth/segment_loader.ts +4 -4
  161. package/src/transports/utils/call_custom_manifest_loader.ts +3 -3
  162. package/src/typings/globals.d.ts +2 -0
  163. package/src/utils/cancellable_sleep.ts +5 -14
  164. package/src/utils/create_cancellable_promise.ts +69 -0
  165. package/src/utils/reference.ts +6 -0
  166. package/src/utils/request/xhr.ts +1 -1
  167. package/src/utils/task_canceller.ts +63 -34
@@ -159,8 +159,7 @@ function getAdaptationSetSwitchingIDs(adaptation) {
159
159
  * @returns {Array.<Object>}
160
160
  */
161
161
  export default function parseAdaptationSets(adaptationsIR, context) {
162
- var _a;
163
- var _b, _c, _d, _e, _f, _g, _h, _j;
162
+ var _a, _b, _c, _d, _e, _f;
164
163
  var parsedAdaptations = { video: [],
165
164
  audio: [],
166
165
  text: [],
@@ -168,14 +167,6 @@ export default function parseAdaptationSets(adaptationsIR, context) {
168
167
  var trickModeAdaptations = [];
169
168
  var adaptationSwitchingInfos = {};
170
169
  var parsedAdaptationsIDs = [];
171
- /**
172
- * Index of the last parsed Video AdaptationSet with a Role set as "main" in
173
- * `parsedAdaptations.video`.
174
- * `-1` if not yet encountered.
175
- * Used as we merge all main video AdaptationSet due to a comprehension of the
176
- * DASH-IF IOP.
177
- */
178
- var lastMainVideoAdapIdx = -1;
179
170
  for (var adaptationIdx = 0; adaptationIdx < adaptationsIR.length; adaptationIdx++) {
180
171
  var adaptation = adaptationsIR[adaptationIdx];
181
172
  var adaptationChildren = adaptation.children;
@@ -184,8 +175,8 @@ export default function parseAdaptationSets(adaptationsIR, context) {
184
175
  roles.some(function (role) { return role.value === "main"; }) &&
185
176
  roles.some(function (role) { return role.schemeIdUri === "urn:mpeg:dash:role:2011"; });
186
177
  var representationsIR = adaptation.children.representations;
187
- var availabilityTimeComplete = (_b = adaptation.attributes.availabilityTimeComplete) !== null && _b !== void 0 ? _b : context.availabilityTimeComplete;
188
- var availabilityTimeOffset = ((_c = adaptation.attributes.availabilityTimeOffset) !== null && _c !== void 0 ? _c : 0) +
178
+ var availabilityTimeComplete = (_a = adaptation.attributes.availabilityTimeComplete) !== null && _a !== void 0 ? _a : context.availabilityTimeComplete;
179
+ var availabilityTimeOffset = ((_b = adaptation.attributes.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0) +
189
180
  context.availabilityTimeOffset;
190
181
  var adaptationMimeType = adaptation.attributes.mimeType;
191
182
  var adaptationCodecs = adaptation.attributes.codecs;
@@ -199,9 +190,8 @@ export default function parseAdaptationSets(adaptationsIR, context) {
199
190
  if (type === undefined) {
200
191
  continue;
201
192
  }
202
- var priority = (_d = adaptation.attributes.selectionPriority) !== null && _d !== void 0 ? _d : 1;
193
+ var priority = (_c = adaptation.attributes.selectionPriority) !== null && _c !== void 0 ? _c : 1;
203
194
  var originalID = adaptation.attributes.id;
204
- var newID = void 0;
205
195
  var adaptationSetSwitchingIDs = getAdaptationSetSwitchingIDs(adaptation);
206
196
  var parentSegmentTemplates = [];
207
197
  if (context.segmentTemplate !== undefined) {
@@ -230,134 +220,112 @@ export default function parseAdaptationSets(adaptationsIR, context) {
230
220
  arrayFind(essentialProperties, function (scheme) {
231
221
  return scheme.schemeIdUri === "http://dashif.org/guidelines/trickmode";
232
222
  }) : undefined;
233
- var trickModeAttachedAdaptationIds = (_e = trickModeProperty === null || trickModeProperty === void 0 ? void 0 : trickModeProperty.value) === null || _e === void 0 ? void 0 : _e.split(" ");
223
+ var trickModeAttachedAdaptationIds = (_d = trickModeProperty === null || trickModeProperty === void 0 ? void 0 : trickModeProperty.value) === null || _d === void 0 ? void 0 : _d.split(" ");
234
224
  var isTrickModeTrack = trickModeAttachedAdaptationIds !== undefined;
235
- if (type === "video" &&
236
- isMainAdaptation &&
237
- lastMainVideoAdapIdx >= 0 &&
238
- parsedAdaptations.video.length > lastMainVideoAdapIdx &&
239
- !isTrickModeTrack) {
240
- var videoMainAdaptation = parsedAdaptations.video[lastMainVideoAdapIdx][0];
241
- reprCtxt.unsafelyBaseOnPreviousAdaptation = (_g = (_f = context
242
- .unsafelyBaseOnPreviousPeriod) === null || _f === void 0 ? void 0 : _f.getAdaptation(videoMainAdaptation.id)) !== null && _g !== void 0 ? _g : null;
243
- var representations = parseRepresentations(representationsIR, adaptation, reprCtxt);
244
- (_a = videoMainAdaptation.representations).push.apply(_a, representations);
245
- newID = videoMainAdaptation.id;
225
+ var accessibilities = adaptationChildren.accessibilities;
226
+ var isDub = void 0;
227
+ if (roles !== undefined &&
228
+ roles.some(function (role) { return role.value === "dub"; })) {
229
+ isDub = true;
230
+ }
231
+ var isClosedCaption = void 0;
232
+ if (type !== "text") {
233
+ isClosedCaption = false;
246
234
  }
247
235
  else {
248
- var accessibilities = adaptationChildren.accessibilities;
249
- var isDub = void 0;
250
- if (roles !== undefined &&
251
- roles.some(function (role) { return role.value === "dub"; })) {
252
- isDub = true;
253
- }
254
- var isClosedCaption = void 0;
255
- if (type !== "text") {
256
- isClosedCaption = false;
257
- }
258
- else {
259
- isClosedCaption = isCaptionning(accessibilities, roles);
260
- }
261
- var isForcedSubtitle = void 0;
262
- if (type === "text" &&
263
- roles !== undefined &&
264
- roles.some(function (role) { return role.value === "forced-subtitle" ||
265
- role.value === "forced_subtitle"; })) {
266
- isForcedSubtitle = true;
267
- }
268
- var isAudioDescription = void 0;
269
- if (type !== "audio") {
270
- isAudioDescription = false;
271
- }
272
- else if (accessibilities !== undefined) {
273
- isAudioDescription = accessibilities.some(isVisuallyImpaired);
274
- }
275
- var isSignInterpreted = void 0;
276
- if (type !== "video") {
277
- isSignInterpreted = false;
278
- }
279
- else if (accessibilities !== undefined) {
280
- isSignInterpreted = accessibilities.some(hasSignLanguageInterpretation);
281
- }
282
- var adaptationID = getAdaptationID(adaptation, { isAudioDescription: isAudioDescription, isForcedSubtitle: isForcedSubtitle, isClosedCaption: isClosedCaption, isSignInterpreted: isSignInterpreted, isTrickModeTrack: isTrickModeTrack, type: type });
283
- // Avoid duplicate IDs
284
- while (arrayIncludes(parsedAdaptationsIDs, adaptationID)) {
285
- adaptationID += "-dup";
286
- }
287
- newID = adaptationID;
288
- parsedAdaptationsIDs.push(adaptationID);
289
- reprCtxt.unsafelyBaseOnPreviousAdaptation = (_j = (_h = context
290
- .unsafelyBaseOnPreviousPeriod) === null || _h === void 0 ? void 0 : _h.getAdaptation(adaptationID)) !== null && _j !== void 0 ? _j : null;
291
- var representations = parseRepresentations(representationsIR, adaptation, reprCtxt);
292
- var parsedAdaptationSet = { id: adaptationID, representations: representations, type: type, isTrickModeTrack: isTrickModeTrack };
293
- if (adaptation.attributes.language != null) {
294
- parsedAdaptationSet.language = adaptation.attributes.language;
295
- }
296
- if (isClosedCaption != null) {
297
- parsedAdaptationSet.closedCaption = isClosedCaption;
298
- }
299
- if (isAudioDescription != null) {
300
- parsedAdaptationSet.audioDescription = isAudioDescription;
301
- }
302
- if (isDub === true) {
303
- parsedAdaptationSet.isDub = true;
304
- }
305
- if (isForcedSubtitle !== undefined) {
306
- parsedAdaptationSet.forcedSubtitles = isForcedSubtitle;
307
- }
308
- if (isSignInterpreted === true) {
309
- parsedAdaptationSet.isSignInterpreted = true;
310
- }
311
- if (label !== undefined) {
312
- parsedAdaptationSet.label = label;
313
- }
314
- if (trickModeAttachedAdaptationIds !== undefined) {
315
- trickModeAdaptations.push({ adaptation: parsedAdaptationSet, trickModeAttachedAdaptationIds: trickModeAttachedAdaptationIds });
316
- }
317
- else {
318
- // look if we have to merge this into another Adaptation
319
- var mergedIntoIdx = -1;
320
- var _loop_1 = function (id) {
321
- var _k;
322
- var switchingInfos = adaptationSwitchingInfos[id];
323
- if (switchingInfos !== undefined &&
324
- switchingInfos.newID !== newID &&
325
- arrayIncludes(switchingInfos.adaptationSetSwitchingIDs, originalID)) {
326
- mergedIntoIdx = arrayFindIndex(parsedAdaptations[type], function (a) { return a[0].id === id; });
327
- var mergedInto = parsedAdaptations[type][mergedIntoIdx];
328
- if (mergedInto !== undefined &&
329
- mergedInto[0].audioDescription ===
330
- parsedAdaptationSet.audioDescription &&
331
- mergedInto[0].closedCaption ===
332
- parsedAdaptationSet.closedCaption &&
333
- mergedInto[0].language === parsedAdaptationSet.language) {
334
- log.info("DASH Parser: merging \"switchable\" AdaptationSets", originalID, id);
335
- (_k = mergedInto[0].representations).push.apply(_k, parsedAdaptationSet.representations);
336
- if (type === "video" &&
337
- isMainAdaptation &&
338
- !mergedInto[1].isMainAdaptation) {
339
- lastMainVideoAdapIdx = Math.max(lastMainVideoAdapIdx, mergedIntoIdx);
340
- }
341
- mergedInto[1] = {
342
- priority: Math.max(priority, mergedInto[1].priority),
343
- isMainAdaptation: isMainAdaptation ||
344
- mergedInto[1].isMainAdaptation,
345
- indexInMpd: Math.min(adaptationIdx, mergedInto[1].indexInMpd),
346
- };
347
- }
348
- }
349
- };
350
- for (var _i = 0, adaptationSetSwitchingIDs_1 = adaptationSetSwitchingIDs; _i < adaptationSetSwitchingIDs_1.length; _i++) {
351
- var id = adaptationSetSwitchingIDs_1[_i];
352
- _loop_1(id);
353
- }
354
- if (mergedIntoIdx < 0) {
355
- parsedAdaptations[type].push([parsedAdaptationSet,
356
- { priority: priority, isMainAdaptation: isMainAdaptation, indexInMpd: adaptationIdx }]);
357
- if (type === "video" && isMainAdaptation) {
358
- lastMainVideoAdapIdx = parsedAdaptations.video.length - 1;
236
+ isClosedCaption = isCaptionning(accessibilities, roles);
237
+ }
238
+ var isForcedSubtitle = void 0;
239
+ if (type === "text" &&
240
+ roles !== undefined &&
241
+ roles.some(function (role) { return role.value === "forced-subtitle" ||
242
+ role.value === "forced_subtitle"; })) {
243
+ isForcedSubtitle = true;
244
+ }
245
+ var isAudioDescription = void 0;
246
+ if (type !== "audio") {
247
+ isAudioDescription = false;
248
+ }
249
+ else if (accessibilities !== undefined) {
250
+ isAudioDescription = accessibilities.some(isVisuallyImpaired);
251
+ }
252
+ var isSignInterpreted = void 0;
253
+ if (type !== "video") {
254
+ isSignInterpreted = false;
255
+ }
256
+ else if (accessibilities !== undefined) {
257
+ isSignInterpreted = accessibilities.some(hasSignLanguageInterpretation);
258
+ }
259
+ var adaptationID = getAdaptationID(adaptation, { isAudioDescription: isAudioDescription, isForcedSubtitle: isForcedSubtitle, isClosedCaption: isClosedCaption, isSignInterpreted: isSignInterpreted, isTrickModeTrack: isTrickModeTrack, type: type });
260
+ // Avoid duplicate IDs
261
+ while (arrayIncludes(parsedAdaptationsIDs, adaptationID)) {
262
+ adaptationID += "-dup";
263
+ }
264
+ var newID = adaptationID;
265
+ parsedAdaptationsIDs.push(adaptationID);
266
+ reprCtxt.unsafelyBaseOnPreviousAdaptation = (_f = (_e = context
267
+ .unsafelyBaseOnPreviousPeriod) === null || _e === void 0 ? void 0 : _e.getAdaptation(adaptationID)) !== null && _f !== void 0 ? _f : null;
268
+ var representations = parseRepresentations(representationsIR, adaptation, reprCtxt);
269
+ var parsedAdaptationSet = { id: adaptationID, representations: representations, type: type, isTrickModeTrack: isTrickModeTrack };
270
+ if (adaptation.attributes.language != null) {
271
+ parsedAdaptationSet.language = adaptation.attributes.language;
272
+ }
273
+ if (isClosedCaption != null) {
274
+ parsedAdaptationSet.closedCaption = isClosedCaption;
275
+ }
276
+ if (isAudioDescription != null) {
277
+ parsedAdaptationSet.audioDescription = isAudioDescription;
278
+ }
279
+ if (isDub === true) {
280
+ parsedAdaptationSet.isDub = true;
281
+ }
282
+ if (isForcedSubtitle !== undefined) {
283
+ parsedAdaptationSet.forcedSubtitles = isForcedSubtitle;
284
+ }
285
+ if (isSignInterpreted === true) {
286
+ parsedAdaptationSet.isSignInterpreted = true;
287
+ }
288
+ if (label !== undefined) {
289
+ parsedAdaptationSet.label = label;
290
+ }
291
+ if (trickModeAttachedAdaptationIds !== undefined) {
292
+ trickModeAdaptations.push({ adaptation: parsedAdaptationSet, trickModeAttachedAdaptationIds: trickModeAttachedAdaptationIds });
293
+ }
294
+ else {
295
+ // look if we have to merge this into another Adaptation
296
+ var mergedIntoIdx = -1;
297
+ var _loop_1 = function (id) {
298
+ var _g;
299
+ var switchingInfos = adaptationSwitchingInfos[id];
300
+ if (switchingInfos !== undefined &&
301
+ switchingInfos.newID !== newID &&
302
+ arrayIncludes(switchingInfos.adaptationSetSwitchingIDs, originalID)) {
303
+ mergedIntoIdx = arrayFindIndex(parsedAdaptations[type], function (a) { return a[0].id === id; });
304
+ var mergedInto = parsedAdaptations[type][mergedIntoIdx];
305
+ if (mergedInto !== undefined &&
306
+ mergedInto[0].audioDescription ===
307
+ parsedAdaptationSet.audioDescription &&
308
+ mergedInto[0].closedCaption ===
309
+ parsedAdaptationSet.closedCaption &&
310
+ mergedInto[0].language === parsedAdaptationSet.language) {
311
+ log.info("DASH Parser: merging \"switchable\" AdaptationSets", originalID, id);
312
+ (_g = mergedInto[0].representations).push.apply(_g, parsedAdaptationSet.representations);
313
+ mergedInto[1] = {
314
+ priority: Math.max(priority, mergedInto[1].priority),
315
+ isMainAdaptation: isMainAdaptation ||
316
+ mergedInto[1].isMainAdaptation,
317
+ indexInMpd: Math.min(adaptationIdx, mergedInto[1].indexInMpd),
318
+ };
359
319
  }
360
320
  }
321
+ };
322
+ for (var _i = 0, adaptationSetSwitchingIDs_1 = adaptationSetSwitchingIDs; _i < adaptationSetSwitchingIDs_1.length; _i++) {
323
+ var id = adaptationSetSwitchingIDs_1[_i];
324
+ _loop_1(id);
325
+ }
326
+ if (mergedIntoIdx < 0) {
327
+ parsedAdaptations[type].push([parsedAdaptationSet,
328
+ { priority: priority, isMainAdaptation: isMainAdaptation, indexInMpd: adaptationIdx }]);
361
329
  }
362
330
  }
363
331
  if (originalID != null && adaptationSwitchingInfos[originalID] == null) {
@@ -13,6 +13,15 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
17
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
18
+ if (ar || !(i in from)) {
19
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
20
+ ar[i] = from[i];
21
+ }
22
+ }
23
+ return to.concat(ar || Array.prototype.slice.call(from));
24
+ };
16
25
  import log from "../../../../log";
17
26
  import arrayFind from "../../../../utils/array_find";
18
27
  import objectAssign from "../../../../utils/object_assign";
@@ -45,11 +54,8 @@ function combineInbandEventStreams(representation, adaptation) {
45
54
  * @returns {Object | undefined}
46
55
  */
47
56
  function getHDRInformation(_a) {
48
- var adaptationProfiles = _a.adaptationProfiles, manifestProfiles = _a.manifestProfiles, codecs = _a.codecs;
57
+ var adaptationProfiles = _a.adaptationProfiles, essentialProperties = _a.essentialProperties, supplementalProperties = _a.supplementalProperties, manifestProfiles = _a.manifestProfiles, codecs = _a.codecs;
49
58
  var profiles = (adaptationProfiles !== null && adaptationProfiles !== void 0 ? adaptationProfiles : "") + (manifestProfiles !== null && manifestProfiles !== void 0 ? manifestProfiles : "");
50
- if (codecs === undefined) {
51
- return undefined;
52
- }
53
59
  if (profiles.indexOf("http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10") !== -1) {
54
60
  if (codecs === "hvc1.2.4.L153.B0" ||
55
61
  codecs === "hev1.2.4.L153.B0") {
@@ -58,7 +64,18 @@ function getHDRInformation(_a) {
58
64
  colorSpace: "rec2020" };
59
65
  }
60
66
  }
61
- if (/^vp(08|09|10)/.exec(codecs)) {
67
+ var transferCharacteristicScheme = arrayFind(__spreadArray(__spreadArray([], (essentialProperties !== null && essentialProperties !== void 0 ? essentialProperties : []), true), (supplementalProperties !== null && supplementalProperties !== void 0 ? supplementalProperties : []), true), function (p) { return p.schemeIdUri === "urn:mpeg:mpegB:cicp:TransferCharacteristics"; });
68
+ if (transferCharacteristicScheme !== undefined) {
69
+ switch (transferCharacteristicScheme.value) {
70
+ case "15":
71
+ return undefined; // SDR
72
+ case "16":
73
+ return { eotf: "pq" };
74
+ case "18":
75
+ return { eotf: "hlg" };
76
+ }
77
+ }
78
+ if (codecs !== undefined && /^vp(08|09|10)/.exec(codecs)) {
62
79
  return getWEBMHDRInformation(codecs);
63
80
  }
64
81
  }
@@ -218,6 +235,9 @@ export default function parseRepresentations(representationsIR, adaptation, cont
218
235
  }
219
236
  parsedRepresentation.hdrInfo =
220
237
  getHDRInformation({ adaptationProfiles: adaptation.attributes.profiles,
238
+ supplementalProperties: adaptation.children
239
+ .supplementalProperties,
240
+ essentialProperties: adaptation.children.essentialProperties,
221
241
  manifestProfiles: context.manifestProfiles, codecs: codecs });
222
242
  parsedRepresentations.push(parsedRepresentation);
223
243
  };
@@ -206,6 +206,7 @@ export interface IAdaptation {
206
206
  normalizedLanguage?: string | undefined;
207
207
  isAudioDescription?: boolean | undefined;
208
208
  isClosedCaption?: boolean | undefined;
209
+ isSignInterpreted?: boolean | undefined;
209
210
  isTrickModeTrack?: boolean | undefined;
210
211
  representations: IRepresentation[];
211
212
  getAvailableBitrates(): number[];
@@ -37,10 +37,9 @@ import inferSegmentContainer from "../utils/infer_segment_container";
37
37
  export default function addSegmentIntegrityChecks(segmentLoader) {
38
38
  return function (url, content, loaderOptions, initialCancelSignal, callbacks) {
39
39
  return new Promise(function (resolve, reject) {
40
- var requestCanceller = new TaskCanceller({ cancelOn: initialCancelSignal });
41
- // Reject the `CancellationError` when `requestCanceller`'s signal emits
42
- // `stopRejectingOnCancel` here is a function allowing to stop this mechanism
43
- var stopRejectingOnCancel = requestCanceller.signal.register(reject);
40
+ var requestCanceller = new TaskCanceller();
41
+ var unlinkCanceller = requestCanceller.linkToSignal(initialCancelSignal);
42
+ requestCanceller.signal.register(reject);
44
43
  segmentLoader(url, content, loaderOptions, requestCanceller.signal, __assign(__assign({}, callbacks), { onNewChunk: function (data) {
45
44
  try {
46
45
  trowOnIntegrityError(data);
@@ -48,17 +47,18 @@ export default function addSegmentIntegrityChecks(segmentLoader) {
48
47
  }
49
48
  catch (err) {
50
49
  // Do not reject with a `CancellationError` after cancelling the request
51
- stopRejectingOnCancel();
50
+ cleanUpCancellers();
52
51
  // Cancel the request
53
52
  requestCanceller.cancel();
54
53
  // Reject with thrown error
55
54
  reject(err);
56
55
  }
57
- } })).then(function (info) {
58
- if (requestCanceller.isUsed) {
56
+ } }))
57
+ .finally(function () { return cleanUpCancellers(); })
58
+ .then(function (info) {
59
+ if (requestCanceller.isUsed()) {
59
60
  return;
60
61
  }
61
- stopRejectingOnCancel();
62
62
  if (info.resultType === "segment-loaded") {
63
63
  try {
64
64
  trowOnIntegrityError(info.resultData.responseData);
@@ -69,10 +69,11 @@ export default function addSegmentIntegrityChecks(segmentLoader) {
69
69
  }
70
70
  }
71
71
  resolve(info);
72
- }, function (error) {
73
- stopRejectingOnCancel();
74
- reject(error);
75
- });
72
+ }, reject);
73
+ function cleanUpCancellers() {
74
+ requestCanceller.signal.deregister(reject);
75
+ unlinkCanceller();
76
+ }
76
77
  });
77
78
  /**
78
79
  * If the data's seems to be corrupted, throws an `INTEGRITY_ERROR` error.
@@ -47,14 +47,14 @@ export default function lowLatencySegmentLoader(url, content, options, callbacks
47
47
  partialChunk = res[1];
48
48
  for (var i = 0; i < completeChunks.length; i++) {
49
49
  callbacks.onNewChunk(completeChunks[i]);
50
- if (cancelSignal.isCancelled) {
50
+ if (cancelSignal.isCancelled()) {
51
51
  return;
52
52
  }
53
53
  }
54
54
  callbacks.onProgress({ duration: info.duration,
55
55
  size: info.size,
56
56
  totalSize: info.totalSize });
57
- if (cancelSignal.isCancelled) {
57
+ if (cancelSignal.isCancelled()) {
58
58
  return;
59
59
  }
60
60
  }
@@ -97,7 +97,7 @@ export default function generateManifestParser(options) {
97
97
  if (parserResponse.value.warnings.length > 0) {
98
98
  onWarnings(parserResponse.value.warnings);
99
99
  }
100
- if (cancelSignal.isCancelled) {
100
+ if (cancelSignal.isCancelled()) {
101
101
  return Promise.reject(cancelSignal.cancellationError);
102
102
  }
103
103
  var manifest = new Manifest(parserResponse.value.parsed, options);
@@ -91,7 +91,7 @@ export default function generateSegmentLoader(_a) {
91
91
  * @param {Object} _args
92
92
  */
93
93
  var resolve = function (_args) {
94
- if (hasFinished || cancelSignal.isCancelled) {
94
+ if (hasFinished || cancelSignal.isCancelled()) {
95
95
  return;
96
96
  }
97
97
  hasFinished = true;
@@ -107,7 +107,7 @@ export default function generateSegmentLoader(_a) {
107
107
  */
108
108
  var reject = function (err) {
109
109
  var _a, _b, _c;
110
- if (hasFinished || cancelSignal.isCancelled) {
110
+ if (hasFinished || cancelSignal.isCancelled()) {
111
111
  return;
112
112
  }
113
113
  hasFinished = true;
@@ -120,7 +120,7 @@ export default function generateSegmentLoader(_a) {
120
120
  rej(emittedErr);
121
121
  };
122
122
  var progress = function (_args) {
123
- if (hasFinished || cancelSignal.isCancelled) {
123
+ if (hasFinished || cancelSignal.isCancelled()) {
124
124
  return;
125
125
  }
126
126
  callbacks.onProgress({ duration: _args.duration,
@@ -132,7 +132,7 @@ export default function generateSegmentLoader(_a) {
132
132
  * the "regular" implementation
133
133
  */
134
134
  var fallback = function () {
135
- if (hasFinished || cancelSignal.isCancelled) {
135
+ if (hasFinished || cancelSignal.isCancelled()) {
136
136
  return;
137
137
  }
138
138
  hasFinished = true;
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { CustomLoaderError } from "../../errors";
17
+ import createCancellablePromise from "../../utils/create_cancellable_promise";
17
18
  import isNullOrUndefined from "../../utils/is_null_or_undefined";
18
19
  /**
19
20
  * @param {Function} customSegmentLoader
@@ -21,7 +22,7 @@ import isNullOrUndefined from "../../utils/is_null_or_undefined";
21
22
  * @returns {Promise}
22
23
  */
23
24
  function loadInitSegment(customSegmentLoader, cancelSignal) {
24
- return new Promise(function (res, rej) {
25
+ return createCancellablePromise(cancelSignal, function (res, rej) {
25
26
  /** `true` when the custom segmentLoader should not be active anymore. */
26
27
  var hasFinished = false;
27
28
  /**
@@ -29,11 +30,10 @@ function loadInitSegment(customSegmentLoader, cancelSignal) {
29
30
  * @param {Object} _args
30
31
  */
31
32
  var resolve = function (_args) {
32
- if (hasFinished || cancelSignal.isCancelled) {
33
+ if (hasFinished || cancelSignal.isCancelled()) {
33
34
  return;
34
35
  }
35
36
  hasFinished = true;
36
- cancelSignal.deregister(abortLoader);
37
37
  res({ resultType: "segment-loaded",
38
38
  resultData: { responseData: _args.data,
39
39
  size: _args.size,
@@ -44,20 +44,15 @@ function loadInitSegment(customSegmentLoader, cancelSignal) {
44
44
  * @param {*} err - The corresponding error encountered
45
45
  */
46
46
  var reject = function (err) {
47
- if (hasFinished || cancelSignal.isCancelled) {
47
+ if (hasFinished || cancelSignal.isCancelled()) {
48
48
  return;
49
49
  }
50
50
  hasFinished = true;
51
- cancelSignal.deregister(abortLoader);
52
51
  rej(err);
53
52
  };
54
53
  var abort = customSegmentLoader({ resolve: resolve, reject: reject });
55
- cancelSignal.register(abortLoader);
56
- /**
57
- * The logic to run when this loader is cancelled while pending.
58
- * @param {Error} err
59
- */
60
- function abortLoader(err) {
54
+ /** The logic to run when this loader is cancelled while pending. */
55
+ return function () {
61
56
  if (hasFinished) {
62
57
  return;
63
58
  }
@@ -65,8 +60,7 @@ function loadInitSegment(customSegmentLoader, cancelSignal) {
65
60
  if (typeof abort === "function") {
66
61
  abort();
67
62
  }
68
- rej(err);
69
- }
63
+ };
70
64
  });
71
65
  }
72
66
  /**
@@ -76,7 +70,7 @@ function loadInitSegment(customSegmentLoader, cancelSignal) {
76
70
  * @returns {Promise.<Object>}
77
71
  */
78
72
  function loadSegment(segment, customSegmentLoader, cancelSignal) {
79
- return new Promise(function (res, rej) {
73
+ return createCancellablePromise(cancelSignal, function (res, rej) {
80
74
  /** `true` when the custom segmentLoader should not be active anymore. */
81
75
  var hasFinished = false;
82
76
  /**
@@ -84,11 +78,10 @@ function loadSegment(segment, customSegmentLoader, cancelSignal) {
84
78
  * @param {Object} _args
85
79
  */
86
80
  var resolve = function (_args) {
87
- if (hasFinished || cancelSignal.isCancelled) {
81
+ if (hasFinished || cancelSignal.isCancelled()) {
88
82
  return;
89
83
  }
90
84
  hasFinished = true;
91
- cancelSignal.deregister(abortLoader);
92
85
  res({ resultType: "segment-loaded",
93
86
  resultData: { responseData: _args.data,
94
87
  size: _args.size,
@@ -100,11 +93,10 @@ function loadSegment(segment, customSegmentLoader, cancelSignal) {
100
93
  */
101
94
  var reject = function (err) {
102
95
  var _a, _b, _c;
103
- if (hasFinished || cancelSignal.isCancelled) {
96
+ if (hasFinished || cancelSignal.isCancelled()) {
104
97
  return;
105
98
  }
106
99
  hasFinished = true;
107
- cancelSignal.deregister(abortLoader);
108
100
  // Format error and send it
109
101
  var castedErr = err;
110
102
  var message = (_a = castedErr === null || castedErr === void 0 ? void 0 : castedErr.message) !== null && _a !== void 0 ? _a : "Unknown error when fetching a local segment through a " +
@@ -113,12 +105,8 @@ function loadSegment(segment, customSegmentLoader, cancelSignal) {
113
105
  rej(emittedErr);
114
106
  };
115
107
  var abort = customSegmentLoader(segment, { resolve: resolve, reject: reject });
116
- cancelSignal.register(abortLoader);
117
- /**
118
- * The logic to run when this loader is cancelled while pending.
119
- * @param {Error} err
120
- */
121
- function abortLoader(err) {
108
+ /** The logic to run when this loader is cancelled while pending. */
109
+ return function () {
122
110
  if (hasFinished) {
123
111
  return;
124
112
  }
@@ -126,8 +114,7 @@ function loadSegment(segment, customSegmentLoader, cancelSignal) {
126
114
  if (typeof abort === "function") {
127
115
  abort();
128
116
  }
129
- rej(err);
130
- }
117
+ };
131
118
  });
132
119
  }
133
120
  /**
@@ -119,7 +119,7 @@ var generateSegmentLoader = function (_a) {
119
119
  * @param {Object} args
120
120
  */
121
121
  var resolve = function (_args) {
122
- if (hasFinished || cancelSignal.isCancelled) {
122
+ if (hasFinished || cancelSignal.isCancelled()) {
123
123
  return;
124
124
  }
125
125
  hasFinished = true;
@@ -145,7 +145,7 @@ var generateSegmentLoader = function (_a) {
145
145
  */
146
146
  var reject = function (err) {
147
147
  var _a, _b, _c;
148
- if (hasFinished || cancelSignal.isCancelled) {
148
+ if (hasFinished || cancelSignal.isCancelled()) {
149
149
  return;
150
150
  }
151
151
  hasFinished = true;
@@ -158,7 +158,7 @@ var generateSegmentLoader = function (_a) {
158
158
  rej(emittedErr);
159
159
  };
160
160
  var progress = function (_args) {
161
- if (hasFinished || cancelSignal.isCancelled) {
161
+ if (hasFinished || cancelSignal.isCancelled()) {
162
162
  return;
163
163
  }
164
164
  callbacks.onProgress({ duration: _args.duration,
@@ -166,7 +166,7 @@ var generateSegmentLoader = function (_a) {
166
166
  totalSize: _args.totalSize });
167
167
  };
168
168
  var fallback = function () {
169
- if (hasFinished || cancelSignal.isCancelled) {
169
+ if (hasFinished || cancelSignal.isCancelled()) {
170
170
  return;
171
171
  }
172
172
  hasFinished = true;