rx-player 3.29.0-dev.2022090500 → 3.29.0-dev.2022091500

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 (142) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/VERSION +1 -1
  3. package/dist/_esm5.processed/core/api/option_utils.js +7 -11
  4. package/dist/_esm5.processed/core/api/public_api.d.ts +4 -4
  5. package/dist/_esm5.processed/core/api/public_api.js +18 -19
  6. package/dist/_esm5.processed/core/api/{media_element_track_choice_manager.d.ts → tracks_management/media_element_track_choice_manager.d.ts} +2 -2
  7. package/dist/_esm5.processed/core/api/{media_element_track_choice_manager.js → tracks_management/media_element_track_choice_manager.js} +3 -3
  8. package/dist/_esm5.processed/core/api/{track_choice_manager.d.ts → tracks_management/track_choice_manager.d.ts} +2 -2
  9. package/dist/_esm5.processed/core/api/{track_choice_manager.js → tracks_management/track_choice_manager.js} +7 -7
  10. package/dist/_esm5.processed/core/api/{emit_seek_events.d.ts → utils.d.ts} +24 -1
  11. package/dist/_esm5.processed/core/api/{emit_seek_events.js → utils.js} +32 -1
  12. package/dist/_esm5.processed/core/decrypt/content_decryptor.d.ts +26 -0
  13. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +101 -9
  14. package/dist/_esm5.processed/core/decrypt/session_events_listener.d.ts +15 -18
  15. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +9 -7
  16. package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.d.ts +19 -22
  17. package/dist/_esm5.processed/core/decrypt/utils/check_key_statuses.js +87 -16
  18. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.d.ts +1 -2
  19. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.js +1 -2
  20. package/dist/_esm5.processed/core/fetchers/index.d.ts +2 -2
  21. package/dist/_esm5.processed/core/fetchers/segment/index.d.ts +2 -3
  22. package/dist/_esm5.processed/core/fetchers/segment/prioritized_segment_fetcher.d.ts +9 -9
  23. package/dist/_esm5.processed/core/fetchers/segment/prioritized_segment_fetcher.js +17 -15
  24. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +33 -40
  25. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +156 -153
  26. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.d.ts +3 -3
  27. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +2 -2
  28. package/dist/_esm5.processed/core/fetchers/segment/task_prioritizer.d.ts +145 -0
  29. package/dist/_esm5.processed/core/fetchers/segment/task_prioritizer.js +325 -0
  30. package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.d.ts +2 -2
  31. package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.js +3 -3
  32. package/dist/_esm5.processed/core/init/create_media_source.d.ts +10 -0
  33. package/dist/_esm5.processed/core/init/create_media_source.js +1 -1
  34. package/dist/_esm5.processed/core/init/stall_avoider.d.ts +2 -1
  35. package/dist/_esm5.processed/core/init/stall_avoider.js +2 -1
  36. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +1 -1
  37. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +3 -3
  38. package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +6 -2
  39. package/dist/_esm5.processed/core/stream/orchestrator/{get_blacklisted_ranges.d.ts → get_time_ranges_for_content.d.ts} +1 -1
  40. package/dist/_esm5.processed/core/stream/orchestrator/{get_blacklisted_ranges.js → get_time_ranges_for_content.js} +1 -1
  41. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +61 -19
  42. package/dist/_esm5.processed/core/stream/representation/downloading_queue.d.ts +8 -4
  43. package/dist/_esm5.processed/core/stream/representation/downloading_queue.js +200 -83
  44. package/dist/_esm5.processed/core/stream/types.d.ts +3 -1
  45. package/dist/_esm5.processed/errors/encrypted_media_error.d.ts +6 -1
  46. package/dist/_esm5.processed/errors/encrypted_media_error.js +4 -5
  47. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/index.d.ts +1 -1
  48. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/index.js +1 -1
  49. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.d.ts +26 -0
  50. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.js +60 -0
  51. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts +6 -5
  52. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +40 -9
  53. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.d.ts +3 -2
  54. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.js +7 -14
  55. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/types.d.ts +1 -1
  56. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/{thumbnail_loader.d.ts → video_thumbnail_loader.d.ts} +1 -13
  57. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +331 -0
  58. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader_error.d.ts +1 -2
  59. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader_error.js +1 -2
  60. package/dist/_esm5.processed/features/initialize_features.js +2 -1
  61. package/dist/_esm5.processed/features/list/directfile.js +1 -1
  62. package/dist/_esm5.processed/features/types.d.ts +1 -1
  63. package/dist/_esm5.processed/manifest/index.d.ts +2 -2
  64. package/dist/_esm5.processed/public_types.d.ts +47 -0
  65. package/dist/_esm5.processed/utils/reference.d.ts +23 -3
  66. package/dist/_esm5.processed/utils/reference.js +23 -2
  67. package/dist/rx-player.js +1250 -1013
  68. package/dist/rx-player.min.js +1 -1
  69. package/package.json +1 -1
  70. package/sonar-project.properties +1 -1
  71. package/src/core/api/README.md +1 -1
  72. package/src/core/api/__tests__/{get_player_state.test.ts → utils.test.ts} +1 -1
  73. package/src/core/api/option_utils.ts +1 -5
  74. package/src/core/api/public_api.ts +15 -13
  75. package/src/core/api/{__tests__ → tracks_management/__tests__}/media_element_track_choice_manager.test.ts +0 -0
  76. package/src/core/api/{media_element_track_choice_manager.ts → tracks_management/media_element_track_choice_manager.ts} +6 -6
  77. package/src/core/api/{track_choice_manager.ts → tracks_management/track_choice_manager.ts} +9 -9
  78. package/src/core/api/{get_player_state.ts → utils.ts} +62 -11
  79. package/src/core/decrypt/content_decryptor.ts +112 -13
  80. package/src/core/decrypt/session_events_listener.ts +34 -30
  81. package/src/core/decrypt/utils/check_key_statuses.ts +89 -45
  82. package/src/core/decrypt/utils/persistent_sessions_store.ts +1 -2
  83. package/src/core/fetchers/index.ts +0 -12
  84. package/src/core/fetchers/segment/__tests__/task_prioritizer.test.ts +763 -0
  85. package/src/core/fetchers/segment/index.ts +0 -12
  86. package/src/core/fetchers/segment/prioritized_segment_fetcher.ts +40 -47
  87. package/src/core/fetchers/segment/segment_fetcher.ts +249 -268
  88. package/src/core/fetchers/segment/segment_fetcher_creator.ts +6 -7
  89. package/src/core/fetchers/segment/task_prioritizer.ts +460 -0
  90. package/src/core/fetchers/utils/try_urls_with_backoff.ts +3 -3
  91. package/src/core/init/create_media_source.ts +1 -1
  92. package/src/core/init/stall_avoider.ts +2 -1
  93. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +1 -1
  94. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +3 -3
  95. package/src/core/segment_buffers/implementations/types.ts +6 -2
  96. package/src/core/stream/orchestrator/{get_blacklisted_ranges.ts → get_time_ranges_for_content.ts} +1 -1
  97. package/src/core/stream/orchestrator/stream_orchestrator.ts +114 -56
  98. package/src/core/stream/representation/downloading_queue.ts +269 -142
  99. package/src/core/stream/types.ts +3 -1
  100. package/src/errors/encrypted_media_error.ts +20 -1
  101. package/src/experimental/tools/VideoThumbnailLoader/index.ts +1 -1
  102. package/src/experimental/tools/VideoThumbnailLoader/load_and_push_segment.ts +74 -0
  103. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +50 -16
  104. package/src/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.ts +14 -21
  105. package/src/experimental/tools/VideoThumbnailLoader/types.ts +7 -4
  106. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +407 -0
  107. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader_error.ts +1 -2
  108. package/src/features/__tests__/initialize_features.test.ts +3 -1
  109. package/src/features/initialize_features.ts +2 -1
  110. package/src/features/list/__tests__/directfile.test.ts +1 -1
  111. package/src/features/list/directfile.ts +1 -1
  112. package/src/features/types.ts +1 -1
  113. package/src/manifest/index.ts +2 -0
  114. package/src/public_types.ts +53 -0
  115. package/src/utils/reference.ts +58 -4
  116. package/dist/_esm5.processed/core/api/get_player_state.d.ts +0 -28
  117. package/dist/_esm5.processed/core/api/get_player_state.js +0 -56
  118. package/dist/_esm5.processed/core/fetchers/segment/prioritizer.d.ts +0 -232
  119. package/dist/_esm5.processed/core/fetchers/segment/prioritizer.js +0 -422
  120. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/create_request.d.ts +0 -29
  121. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/create_request.js +0 -68
  122. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/get_complete_segment_id.d.ts +0 -24
  123. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/get_complete_segment_id.js +0 -29
  124. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/get_content_infos.d.ts +0 -25
  125. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/get_content_infos.js +0 -40
  126. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/get_initialized_source_buffer.d.ts +0 -33
  127. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/get_initialized_source_buffer.js +0 -124
  128. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_segments.d.ts +0 -17
  129. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_segments.js +0 -41
  130. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/push_data.d.ts +0 -22
  131. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/push_data.js +0 -21
  132. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/thumbnail_loader.js +0 -212
  133. package/src/core/api/emit_seek_events.ts +0 -66
  134. package/src/core/fetchers/segment/__tests__/prioritizer.test.ts +0 -962
  135. package/src/core/fetchers/segment/prioritizer.ts +0 -558
  136. package/src/experimental/tools/VideoThumbnailLoader/create_request.ts +0 -113
  137. package/src/experimental/tools/VideoThumbnailLoader/get_complete_segment_id.ts +0 -34
  138. package/src/experimental/tools/VideoThumbnailLoader/get_content_infos.ts +0 -48
  139. package/src/experimental/tools/VideoThumbnailLoader/get_initialized_source_buffer.ts +0 -171
  140. package/src/experimental/tools/VideoThumbnailLoader/load_segments.ts +0 -69
  141. package/src/experimental/tools/VideoThumbnailLoader/push_data.ts +0 -48
  142. package/src/experimental/tools/VideoThumbnailLoader/thumbnail_loader.ts +0 -311
package/CHANGELOG.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # Changelog
2
2
 
3
- ## v3.29.0-dev.2022090500 (2022-09-05)
3
+ ## v3.29.0-dev.2022091300 (2022-09-15)
4
4
 
5
5
  ### Features
6
6
 
7
7
  - add `networkConfig.segmentRequestTimeout` and `networkConfig.manifestRequestTimeout` options to loadVideo to configure the timeout of respectively segment and manifest requests [#1156]
8
8
  - add `timeout` property to the first argument communicated to a `segmentLoader` (from `loadVideo`'s `transportOptions`) [#1156]
9
9
  - add `timeout` property to a new third argument communicated to a `manifestLoader` (from `loadVideo`'s `transportOptions`) [#1156]
10
+ - add `keySystems[].onKeyExpiration` to `loadVideo` options to configure the behavior the RxPlayer should have on key expiration [#1157]
11
+ - add `keyStatuses` property to an `EncryptedMediaError` with the `KEY_STATUS_CHANGE_ERROR` code to communicate which key id and key statuses caused issues. [#1157]
10
12
 
11
13
  ### Bug fixes
12
14
 
@@ -19,6 +21,7 @@
19
21
  ### Other improvements
20
22
 
21
23
  - In the experimental "local" transport, add `incomingRanges` property to signal the time ranges of remaining data, allowing better discontinuity handling and duration estimates for sill-loading dowloaded contents [#1151]
24
+ - Only send through `"warning"` events, just one `EncryptedMediaError` with a `KEY_STATUS_CHANGE_ERROR` code when multiple ones arises at the same time [#1157]
22
25
 
23
26
  ## v3.28.0 (2022-07-12)
24
27
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 3.29.0-dev.2022090500
1
+ 3.29.0-dev.2022091500
@@ -269,14 +269,14 @@ function checkReloadOptions(options) {
269
269
  * @returns {Object}
270
270
  */
271
271
  function parseLoadVideoOptions(options) {
272
- var _a, _b, _c, _d, _e, _f;
272
+ var _a, _b, _c, _d, _e, _f, _g;
273
273
  var url;
274
274
  var transport;
275
275
  var keySystems;
276
276
  var textTrackMode;
277
277
  var textTrackElement;
278
278
  var startAt;
279
- var _g = config.getCurrent(), DEFAULT_AUDIO_TRACK_SWITCHING_MODE = _g.DEFAULT_AUDIO_TRACK_SWITCHING_MODE, DEFAULT_AUTO_PLAY = _g.DEFAULT_AUTO_PLAY, DEFAULT_CODEC_SWITCHING_BEHAVIOR = _g.DEFAULT_CODEC_SWITCHING_BEHAVIOR, DEFAULT_ENABLE_FAST_SWITCHING = _g.DEFAULT_ENABLE_FAST_SWITCHING, DEFAULT_MANUAL_BITRATE_SWITCHING_MODE = _g.DEFAULT_MANUAL_BITRATE_SWITCHING_MODE, DEFAULT_SHOW_NATIVE_SUBTITLE = _g.DEFAULT_SHOW_NATIVE_SUBTITLE, DEFAULT_TEXT_TRACK_MODE = _g.DEFAULT_TEXT_TRACK_MODE;
279
+ var _h = config.getCurrent(), DEFAULT_AUDIO_TRACK_SWITCHING_MODE = _h.DEFAULT_AUDIO_TRACK_SWITCHING_MODE, DEFAULT_AUTO_PLAY = _h.DEFAULT_AUTO_PLAY, DEFAULT_CODEC_SWITCHING_BEHAVIOR = _h.DEFAULT_CODEC_SWITCHING_BEHAVIOR, DEFAULT_ENABLE_FAST_SWITCHING = _h.DEFAULT_ENABLE_FAST_SWITCHING, DEFAULT_MANUAL_BITRATE_SWITCHING_MODE = _h.DEFAULT_MANUAL_BITRATE_SWITCHING_MODE, DEFAULT_SHOW_NATIVE_SUBTITLE = _h.DEFAULT_SHOW_NATIVE_SUBTITLE, DEFAULT_TEXT_TRACK_MODE = _h.DEFAULT_TEXT_TRACK_MODE;
280
280
  if (isNullOrUndefined(options)) {
281
281
  throw new Error("No option set on loadVideo");
282
282
  }
@@ -363,8 +363,8 @@ function parseLoadVideoOptions(options) {
363
363
  "Please use the `TextTrackRenderer` tool instead.");
364
364
  var supplementaryTextTracks = Array.isArray(options.supplementaryTextTracks) ?
365
365
  options.supplementaryTextTracks : [options.supplementaryTextTracks];
366
- for (var _h = 0, supplementaryTextTracks_1 = supplementaryTextTracks; _h < supplementaryTextTracks_1.length; _h++) {
367
- var supplementaryTextTrack = supplementaryTextTracks_1[_h];
366
+ for (var _j = 0, supplementaryTextTracks_1 = supplementaryTextTracks; _j < supplementaryTextTracks_1.length; _j++) {
367
+ var supplementaryTextTrack = supplementaryTextTracks_1[_j];
368
368
  if (typeof supplementaryTextTrack.language !== "string" ||
369
369
  typeof supplementaryTextTrack.mimeType !== "string" ||
370
370
  typeof supplementaryTextTrack.url !== "string") {
@@ -379,8 +379,8 @@ function parseLoadVideoOptions(options) {
379
379
  "Please use the `parseBifThumbnails` tool instead.");
380
380
  var supplementaryImageTracks = Array.isArray(options.supplementaryImageTracks) ?
381
381
  options.supplementaryImageTracks : [options.supplementaryImageTracks];
382
- for (var _j = 0, supplementaryImageTracks_1 = supplementaryImageTracks; _j < supplementaryImageTracks_1.length; _j++) {
383
- var supplementaryImageTrack = supplementaryImageTracks_1[_j];
382
+ for (var _k = 0, supplementaryImageTracks_1 = supplementaryImageTracks; _k < supplementaryImageTracks_1.length; _k++) {
383
+ var supplementaryImageTrack = supplementaryImageTracks_1[_k];
384
384
  if (typeof supplementaryImageTrack.mimeType !== "string" ||
385
385
  typeof supplementaryImageTrack.url !== "string") {
386
386
  throw new Error("Invalid supplementary image track given. " +
@@ -448,11 +448,7 @@ function parseLoadVideoOptions(options) {
448
448
  startAt = options.startAt;
449
449
  }
450
450
  }
451
- var networkConfig = isNullOrUndefined(options.networkConfig) ?
452
- {} :
453
- { manifestRetry: options.networkConfig.manifestRetry,
454
- offlineRetry: options.networkConfig.offlineRetry,
455
- segmentRetry: options.networkConfig.segmentRetry };
451
+ var networkConfig = (_g = options.networkConfig) !== null && _g !== void 0 ? _g : {};
456
452
  // TODO without cast
457
453
  /* eslint-disable @typescript-eslint/consistent-type-assertions */
458
454
  return { autoPlay: autoPlay, defaultAudioTrack: defaultAudioTrack, defaultTextTrack: defaultTextTrack, enableFastSwitching: enableFastSwitching, hideNativeSubtitle: hideNativeSubtitle, keySystems: keySystems, initialManifest: initialManifest, lowLatencyMode: lowLatencyMode, manualBitrateSwitchingMode: manualBitrateSwitchingMode, audioTrackSwitchingMode: audioTrackSwitchingMode, minimumManifestUpdateInterval: minimumManifestUpdateInterval, networkConfig: networkConfig, onCodecSwitch: onCodecSwitch, startAt: startAt, textTrackElement: textTrackElement, textTrackMode: textTrackMode, transport: transport, transportOptions: transportOptions, url: url };
@@ -38,7 +38,7 @@ declare class Player extends EventEmitter<IPublicAPIEvent> {
38
38
  readonly log: Logger;
39
39
  /**
40
40
  * Current state of the RxPlayer.
41
- * Please use `getPlayerState()` instead.
41
+ * Please use `getLoadedContentState()` instead.
42
42
  */
43
43
  state: IPlayerState;
44
44
  /**
@@ -351,9 +351,9 @@ declare class Player extends EventEmitter<IPublicAPIEvent> {
351
351
  *
352
352
  * Note that switching to or getting out of a trickmode video track may
353
353
  * lead to the player being a brief instant in a `"RELOADING"` state (notified
354
- * through `playerStateChange` events and the `getPlayerState` method). When in
355
- * that state, a black screen may be displayed and multiple RxPlayer APIs will
356
- * not be usable.
354
+ * through `playerStateChange` events and the `getLoadedContentState` method).
355
+ * When in that state, a black screen may be displayed and multiple RxPlayer
356
+ * APIs will not be usable.
357
357
  *
358
358
  * @param {Number} rate
359
359
  * @param {Object} opts
@@ -63,11 +63,10 @@ import warnOnce from "../../utils/warn_once";
63
63
  import { clearOnStop, disposeDecryptionResources, getCurrentKeySystem, } from "../decrypt";
64
64
  import { ManifestFetcher, SegmentFetcherCreator, } from "../fetchers";
65
65
  import initializeMediaSourcePlayback from "../init";
66
- import emitSeekEvents from "./emit_seek_events";
67
- import getPlayerState, { PLAYER_STATES, } from "./get_player_state";
68
66
  import { checkReloadOptions, parseConstructorOptions, parseLoadVideoOptions, } from "./option_utils";
69
67
  import PlaybackObserver from "./playback_observer";
70
- import TrackChoiceManager from "./track_choice_manager";
68
+ import TrackChoiceManager from "./tracks_management/track_choice_manager";
69
+ import { emitSeekEvents, getLoadedContentState, } from "./utils";
71
70
  /* eslint-disable @typescript-eslint/naming-convention */
72
71
  var getPageActivityRef = events.getPageActivityRef, getPictureOnPictureStateRef = events.getPictureOnPictureStateRef, getVideoVisibilityRef = events.getVideoVisibilityRef, getVideoWidthRef = events.getVideoWidthRef, onFullscreenChange$ = events.onFullscreenChange$, onTextTrackChanges$ = events.onTextTrackChanges$;
73
72
  /**
@@ -88,7 +87,7 @@ var Player = /** @class */ (function (_super) {
88
87
  // Workaround to support Firefox autoplay on FF 42.
89
88
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
90
89
  videoElement.preload = "auto";
91
- _this.version = /* PLAYER_VERSION */ "3.29.0-dev.2022090500";
90
+ _this.version = /* PLAYER_VERSION */ "3.29.0-dev.2022091500";
92
91
  _this.log = log;
93
92
  _this.state = "STOPPED";
94
93
  _this.videoElement = videoElement;
@@ -160,7 +159,7 @@ var Player = /** @class */ (function (_super) {
160
159
  _this._priv_contentInfos = null;
161
160
  _this._priv_contentEventsMemory = {};
162
161
  _this._priv_stopAtEnd = stopAtEnd;
163
- _this._priv_setPlayerState(PLAYER_STATES.STOPPED);
162
+ _this._priv_setPlayerState("STOPPED" /* PLAYER_STATES.STOPPED */);
164
163
  _this._priv_preferredAudioTracks = preferredAudioTracks;
165
164
  _this._priv_preferredTextTracks = preferredTextTracks;
166
165
  _this._priv_preferredVideoTracks = preferredVideoTracks;
@@ -227,8 +226,8 @@ var Player = /** @class */ (function (_super) {
227
226
  this._priv_contentInfos.currentContentCanceller.cancel();
228
227
  }
229
228
  this._priv_cleanUpCurrentContentState();
230
- if (this.state !== PLAYER_STATES.STOPPED) {
231
- this._priv_setPlayerState(PLAYER_STATES.STOPPED);
229
+ if (this.state !== "STOPPED" /* PLAYER_STATES.STOPPED */) {
230
+ this._priv_setPlayerState("STOPPED" /* PLAYER_STATES.STOPPED */);
232
231
  }
233
232
  };
234
233
  /**
@@ -550,18 +549,18 @@ var Player = /** @class */ (function (_super) {
550
549
  stateChangingEvent$.pipe(startWith(null)),
551
550
  ]).pipe(takeUntil(stoppedContent$), map(function (_a) {
552
551
  var stalledStatus = _a[0];
553
- return getPlayerState(videoElement, stalledStatus);
552
+ return getLoadedContentState(videoElement, stalledStatus);
554
553
  }));
555
554
  /** Emit all player "state" updates. */
556
- var playerState$ = observableConcat(observableOf(PLAYER_STATES.LOADING), // Begin with LOADING
555
+ var playerState$ = observableConcat(observableOf("LOADING" /* PLAYER_STATES.LOADING */), // Begin with LOADING
557
556
  loaded$.pipe(switchMap(function (_, i) {
558
557
  var isFirstLoad = i === 0;
559
558
  return observableMerge(
560
559
  // Purposely subscribed first so a RELOADING triggered synchronously
561
560
  // after a LOADED state is catched.
562
- reloading$.pipe(map(function () { return PLAYER_STATES.RELOADING; })),
561
+ reloading$.pipe(map(function () { return "RELOADING" /* PLAYER_STATES.RELOADING */; })),
563
562
  // Only switch to LOADED state for the first (i.e. non-RELOADING) load
564
- isFirstLoad ? observableOf(PLAYER_STATES.LOADED) :
563
+ isFirstLoad ? observableOf("LOADED" /* PLAYER_STATES.LOADED */) :
565
564
  EMPTY,
566
565
  // Purposely put last so any other state change happens after we've
567
566
  // already switched to LOADED
@@ -569,7 +568,7 @@ var Player = /** @class */ (function (_super) {
569
568
  // For the first load, we prefer staying at the LOADED state over
570
569
  // PAUSED when autoPlay is disabled.
571
570
  // For consecutive loads however, there's no LOADED state.
572
- skipWhile(function (state) { return isFirstLoad && state === PLAYER_STATES.PAUSED; })));
571
+ skipWhile(function (state) { return isFirstLoad && state === "PAUSED" /* PLAYER_STATES.PAUSED */; })));
573
572
  }))).pipe(distinctUntilChanged());
574
573
  var playbackSubscription;
575
574
  stoppedContent$.subscribe(function () {
@@ -606,7 +605,7 @@ var Player = /** @class */ (function (_super) {
606
605
  log.info("API: Previous playback finished. Stopping and cleaning-up...");
607
606
  contentInfos.currentContentCanceller.cancel();
608
607
  _this._priv_cleanUpCurrentContentState();
609
- _this._priv_setPlayerState(PLAYER_STATES.STOPPED);
608
+ _this._priv_setPlayerState("STOPPED" /* PLAYER_STATES.STOPPED */);
610
609
  }
611
610
  },
612
611
  });
@@ -911,9 +910,9 @@ var Player = /** @class */ (function (_super) {
911
910
  *
912
911
  * Note that switching to or getting out of a trickmode video track may
913
912
  * lead to the player being a brief instant in a `"RELOADING"` state (notified
914
- * through `playerStateChange` events and the `getPlayerState` method). When in
915
- * that state, a black screen may be displayed and multiple RxPlayer APIs will
916
- * not be usable.
913
+ * through `playerStateChange` events and the `getLoadedContentState` method).
914
+ * When in that state, a black screen may be displayed and multiple RxPlayer
915
+ * APIs will not be usable.
917
916
  *
918
917
  * @param {Number} rate
919
918
  * @param {Object} opts
@@ -1881,7 +1880,7 @@ var Player = /** @class */ (function (_super) {
1881
1880
  this._priv_cleanUpCurrentContentState();
1882
1881
  this._priv_currentError = formattedError;
1883
1882
  log.error("API: The player stopped because of an error", error instanceof Error ? error : "");
1884
- this._priv_setPlayerState(PLAYER_STATES.STOPPED);
1883
+ this._priv_setPlayerState("STOPPED" /* PLAYER_STATES.STOPPED */);
1885
1884
  // TODO This condition is here because the eventual callback called when the
1886
1885
  // player state is updated can launch a new content, thus the error will not
1887
1886
  // be here anymore, in which case triggering the "error" event is unwanted.
@@ -2219,7 +2218,7 @@ var Player = /** @class */ (function (_super) {
2219
2218
  log.warn("API: Cannot perform time update: no content loaded.");
2220
2219
  return;
2221
2220
  }
2222
- if (this.state === PLAYER_STATES.RELOADING) {
2221
+ if (this.state === "RELOADING" /* PLAYER_STATES.RELOADING */) {
2223
2222
  return;
2224
2223
  }
2225
2224
  var _b = this._priv_contentInfos, isDirectFile = _b.isDirectFile, manifest = _b.manifest;
@@ -2295,5 +2294,5 @@ var Player = /** @class */ (function (_super) {
2295
2294
  };
2296
2295
  return Player;
2297
2296
  }(EventEmitter));
2298
- Player.version = /* PLAYER_VERSION */ "3.29.0-dev.2022090500";
2297
+ Player.version = /* PLAYER_VERSION */ "3.29.0-dev.2022091500";
2299
2298
  export default Player;
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { IAudioTrack, ITextTrack, IVideoTrack, IAudioTrackPreference, ITextTrackPreference, IVideoTrackPreference, IAvailableVideoTrack, IAvailableAudioTrack, IAvailableTextTrack } from "../../public_types";
17
- import EventEmitter from "../../utils/event_emitter";
16
+ import { IAudioTrack, ITextTrack, IVideoTrack, IAudioTrackPreference, ITextTrackPreference, IVideoTrackPreference, IAvailableVideoTrack, IAvailableAudioTrack, IAvailableTextTrack } from "../../../public_types";
17
+ import EventEmitter from "../../../utils/event_emitter";
18
18
  /** Events emitted by the MediaElementTrackChoiceManager. */
19
19
  interface IMediaElementTrackChoiceManagerEvents {
20
20
  availableVideoTracksChange: IAvailableVideoTrack[];
@@ -28,9 +28,9 @@ var __extends = (this && this.__extends) || (function () {
28
28
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
29
  };
30
30
  })();
31
- import assert from "../../utils/assert";
32
- import EventEmitter from "../../utils/event_emitter";
33
- import normalizeLanguage from "../../utils/languages";
31
+ import assert from "../../../utils/assert";
32
+ import EventEmitter from "../../../utils/event_emitter";
33
+ import normalizeLanguage from "../../../utils/languages";
34
34
  /**
35
35
  * Check if track array is different from an other one
36
36
  * @param {Array.<Object>} oldTrackArray
@@ -18,8 +18,8 @@
18
18
  * switching for an easier API management.
19
19
  */
20
20
  import { Subject } from "rxjs";
21
- import { Adaptation, Period } from "../../manifest";
22
- import { IAudioTrack, IAudioTrackPreference, IAvailableAudioTrack, IAvailableTextTrack, IAvailableVideoTrack, ITextTrack, ITextTrackPreference, IVideoTrack, IVideoTrackPreference } from "../../public_types";
21
+ import { Adaptation, Period } from "../../../manifest";
22
+ import { IAudioTrack, IAudioTrackPreference, IAvailableAudioTrack, IAvailableTextTrack, IAvailableVideoTrack, ITextTrack, ITextTrackPreference, IVideoTrack, IVideoTrackPreference } from "../../../public_types";
23
23
  /**
24
24
  * Manage audio and text tracks for all active periods.
25
25
  * Choose the audio and text tracks for each period and record this choice.
@@ -13,13 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import log from "../../log";
17
- import arrayFind from "../../utils/array_find";
18
- import arrayIncludes from "../../utils/array_includes";
19
- import isNullOrUndefined from "../../utils/is_null_or_undefined";
20
- import normalizeLanguage from "../../utils/languages";
21
- import SortedList from "../../utils/sorted_list";
22
- import takeFirstSet from "../../utils/take_first_set";
16
+ import log from "../../../log";
17
+ import arrayFind from "../../../utils/array_find";
18
+ import arrayIncludes from "../../../utils/array_includes";
19
+ import isNullOrUndefined from "../../../utils/is_null_or_undefined";
20
+ import normalizeLanguage from "../../../utils/languages";
21
+ import SortedList from "../../../utils/sorted_list";
22
+ import takeFirstSet from "../../../utils/take_first_set";
23
23
  /**
24
24
  * Transform an array of IAudioTrackPreference into an array of
25
25
  * INormalizedPreferredAudioTrack to be exploited by the TrackChoiceManager.
@@ -14,6 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Observable } from "rxjs";
17
+ import { IPlayerState } from "../../public_types";
18
+ import { IStallingSituation } from "../init";
17
19
  import { IPlaybackObservation } from "./playback_observer";
18
20
  /**
19
21
  * Returns Observable which will emit:
@@ -24,4 +26,25 @@ import { IPlaybackObservation } from "./playback_observer";
24
26
  * @param {Observable} observation$
25
27
  * @returns {Observable}
26
28
  */
27
- export default function emitSeekEvents(mediaElement: HTMLMediaElement | null, observation$: Observable<IPlaybackObservation>): Observable<"seeking" | "seeked">;
29
+ export declare function emitSeekEvents(mediaElement: HTMLMediaElement | null, observation$: Observable<IPlaybackObservation>): Observable<"seeking" | "seeked">;
30
+ /** Player state dictionnary. */
31
+ export declare const enum PLAYER_STATES {
32
+ STOPPED = "STOPPED",
33
+ LOADED = "LOADED",
34
+ LOADING = "LOADING",
35
+ PLAYING = "PLAYING",
36
+ PAUSED = "PAUSED",
37
+ ENDED = "ENDED",
38
+ BUFFERING = "BUFFERING",
39
+ SEEKING = "SEEKING",
40
+ RELOADING = "RELOADING"
41
+ }
42
+ /**
43
+ * Get state string for a _loaded_ content.
44
+ * @param {HTMLMediaElement} mediaElement
45
+ * @param {Object} stalledStatus - Current stalled state:
46
+ * - null when not stalled
47
+ * - a description of the situation if stalled.
48
+ * @returns {string}
49
+ */
50
+ export declare function getLoadedContentState(mediaElement: HTMLMediaElement, stalledStatus: IStallingSituation | null): IPlayerState;
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { defer as observableDefer, EMPTY, filter, map, merge as observableMerge, startWith, switchMap, take, } from "rxjs";
17
+ import config from "../../config";
17
18
  /**
18
19
  * Returns Observable which will emit:
19
20
  * - `"seeking"` when we are seeking in the given mediaElement
@@ -23,7 +24,7 @@ import { defer as observableDefer, EMPTY, filter, map, merge as observableMerge,
23
24
  * @param {Observable} observation$
24
25
  * @returns {Observable}
25
26
  */
26
- export default function emitSeekEvents(mediaElement, observation$) {
27
+ export function emitSeekEvents(mediaElement, observation$) {
27
28
  return observableDefer(function () {
28
29
  if (mediaElement === null) {
29
30
  return EMPTY;
@@ -38,3 +39,33 @@ export default function emitSeekEvents(mediaElement, observation$) {
38
39
  return observableMerge(isSeeking$, hasSeeked$);
39
40
  });
40
41
  }
42
+ /**
43
+ * Get state string for a _loaded_ content.
44
+ * @param {HTMLMediaElement} mediaElement
45
+ * @param {Object} stalledStatus - Current stalled state:
46
+ * - null when not stalled
47
+ * - a description of the situation if stalled.
48
+ * @returns {string}
49
+ */
50
+ export function getLoadedContentState(mediaElement, stalledStatus) {
51
+ var FORCED_ENDED_THRESHOLD = config.getCurrent().FORCED_ENDED_THRESHOLD;
52
+ if (mediaElement.ended) {
53
+ return "ENDED" /* PLAYER_STATES.ENDED */;
54
+ }
55
+ if (stalledStatus !== null) {
56
+ // On some old browsers (e.g. Chrome 54), the browser does not
57
+ // emit an 'ended' event in some conditions. Detect if we
58
+ // reached the end by comparing the current position and the
59
+ // duration instead.
60
+ var gapBetweenDurationAndCurrentTime = Math.abs(mediaElement.duration -
61
+ mediaElement.currentTime);
62
+ if (FORCED_ENDED_THRESHOLD != null &&
63
+ gapBetweenDurationAndCurrentTime < FORCED_ENDED_THRESHOLD) {
64
+ return "ENDED" /* PLAYER_STATES.ENDED */;
65
+ }
66
+ return stalledStatus === "seeking" ? "SEEKING" /* PLAYER_STATES.SEEKING */ :
67
+ "BUFFERING" /* PLAYER_STATES.BUFFERING */;
68
+ }
69
+ return mediaElement.paused ? "PAUSED" /* PLAYER_STATES.PAUSED */ :
70
+ "PLAYING" /* PLAYER_STATES.PLAYING */;
71
+ }
@@ -143,6 +143,16 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
143
143
  */
144
144
  private _processInitializationData;
145
145
  private _tryToUseAlreadyCreatedSession;
146
+ /**
147
+ * Callback that should be called if an error that made the current
148
+ * `ContentDecryptor` instance unusable arised.
149
+ * This callbacks takes care of resetting state and sending the right events.
150
+ *
151
+ * Once called, no further actions should be taken.
152
+ *
153
+ * @param {*} err - The error object which describes the issue. Will be
154
+ * formatted and sent in an "error" event.
155
+ */
146
156
  private _onFatalError;
147
157
  /**
148
158
  * Return `true` if the `ContentDecryptor` has either been disposed or
@@ -150,8 +160,24 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
150
160
  * @returns {boolean}
151
161
  */
152
162
  private _isStopped;
163
+ /**
164
+ * Start processing the next initialization data of the `_initDataQueue` if it
165
+ * isn't lock.
166
+ */
153
167
  private _processCurrentInitDataQueue;
168
+ /**
169
+ * Lock new initialization data (from the `_initDataQueue`) from being
170
+ * processed until `_unlockInitDataQueue` is called.
171
+ *
172
+ * You may want to call this method when performing operations which may have
173
+ * an impact on the handling of other initialization data.
174
+ */
154
175
  private _lockInitDataQueue;
176
+ /**
177
+ * Unlock `_initDataQueue` and start processing the first element.
178
+ *
179
+ * Should have no effect if the `_initDataQueue` was not locked.
180
+ */
155
181
  private _unlockInitDataQueue;
156
182
  }
157
183
  /** Events sent by the `ContentDecryptor`, in a `{ event: payload }` format. */
@@ -100,6 +100,7 @@ import createOrLoadSession from "./create_or_load_session";
100
100
  import initMediaKeys from "./init_media_keys";
101
101
  import SessionEventsListener, { BlacklistedSessionError, } from "./session_events_listener";
102
102
  import setServerCertificate from "./set_server_certificate";
103
+ import { DecommissionedSessionError } from "./utils/check_key_statuses";
103
104
  import cleanOldStoredPersistentInfo from "./utils/clean_old_stored_persistent_info";
104
105
  import getDrmSystemId from "./utils/get_drm_system_id";
105
106
  import InitDataValuesContainer from "./utils/init_data_values_container";
@@ -351,7 +352,7 @@ var ContentDecryptor = /** @class */ (function (_super) {
351
352
  .reduce(function (acc, kid) { return "".concat(acc, ", ").concat(bytesToHex(kid)); }, "");
352
353
  log.debug("DRM: Blacklisting new key ids", hexKids);
353
354
  }
354
- updateDecipherability(initializationData.content.manifest, [], keyIds);
355
+ updateDecipherability(initializationData.content.manifest, [], keyIds, []);
355
356
  }
356
357
  return [2 /*return*/];
357
358
  }
@@ -380,7 +381,7 @@ var ContentDecryptor = /** @class */ (function (_super) {
380
381
  createdSess.keyStatuses.blacklisted.push(innerKid);
381
382
  }
382
383
  }
383
- updateDecipherability(initializationData.content.manifest, createdSess.keyStatuses.whitelisted, createdSess.keyStatuses.blacklisted);
384
+ updateDecipherability(initializationData.content.manifest, createdSess.keyStatuses.whitelisted, createdSess.keyStatuses.blacklisted, []);
384
385
  return [2 /*return*/];
385
386
  }
386
387
  }
@@ -428,7 +429,7 @@ var ContentDecryptor = /** @class */ (function (_super) {
428
429
  _this.trigger("warning", evt.value);
429
430
  return;
430
431
  }
431
- var linkedKeys = getKeyIdsLinkedToSession(initializationData, sessionInfo.record, options.singleLicensePer, sessionInfo.source === "created-session" /* MediaKeySessionLoadingType.Created */, evt.value.whitelistedKeyIds, evt.value.blacklistedKeyIDs);
432
+ var linkedKeys = getKeyIdsLinkedToSession(initializationData, sessionInfo.record, options.singleLicensePer, sessionInfo.source === "created-session" /* MediaKeySessionLoadingType.Created */, evt.value.whitelistedKeyIds, evt.value.blacklistedKeyIds);
432
433
  sessionInfo.record.associateKeyIds(linkedKeys.whitelisted);
433
434
  sessionInfo.record.associateKeyIds(linkedKeys.blacklisted);
434
435
  sessionInfo.keyStatuses = { whitelisted: linkedKeys.whitelisted,
@@ -443,11 +444,36 @@ var ContentDecryptor = /** @class */ (function (_super) {
443
444
  isSessionPersisted = true;
444
445
  }
445
446
  if (initializationData.content !== undefined) {
446
- updateDecipherability(initializationData.content.manifest, linkedKeys.whitelisted, linkedKeys.blacklisted);
447
+ updateDecipherability(initializationData.content.manifest, linkedKeys.whitelisted, linkedKeys.blacklisted, []);
447
448
  }
448
449
  _this._unlockInitDataQueue();
449
450
  },
450
451
  error: function (err) {
452
+ var _a;
453
+ if (err instanceof DecommissionedSessionError) {
454
+ log.warn("DRM: A session's closing condition has been triggered");
455
+ _this._lockInitDataQueue();
456
+ var indexOf = _this._currentSessions.indexOf(sessionInfo);
457
+ if (indexOf >= 0) {
458
+ _this._currentSessions.splice(indexOf);
459
+ }
460
+ if (initializationData.content !== undefined) {
461
+ updateDecipherability(initializationData.content.manifest, [], [], sessionInfo.record.getAssociatedKeyIds());
462
+ }
463
+ (_a = stores.persistentSessionsStore) === null || _a === void 0 ? void 0 : _a.delete(mediaKeySession.sessionId);
464
+ stores.loadedSessionsStore.closeSession(mediaKeySession)
465
+ .catch(function (e) {
466
+ var closeError = e instanceof Error ? e :
467
+ "unknown error";
468
+ log.warn("DRM: failed to close expired session", closeError);
469
+ })
470
+ .then(function () { return _this._unlockInitDataQueue(); })
471
+ .catch(function (retryError) { return _this._onFatalError(retryError); });
472
+ if (!_this._isStopped()) {
473
+ _this.trigger("warning", err.reason);
474
+ }
475
+ return;
476
+ }
451
477
  if (!(err instanceof BlacklistedSessionError)) {
452
478
  _this._onFatalError(err);
453
479
  return;
@@ -559,7 +585,7 @@ var ContentDecryptor = /** @class */ (function (_super) {
559
585
  }
560
586
  log.info("DRM: Current initialization data is linked to blacklisted keys. " +
561
587
  "Marking Representations as not decipherable");
562
- updateDecipherability(initializationData.content.manifest, [], initializationData.keyIds);
588
+ updateDecipherability(initializationData.content.manifest, [], initializationData.keyIds, []);
563
589
  return true;
564
590
  }
565
591
  }
@@ -586,13 +612,23 @@ var ContentDecryptor = /** @class */ (function (_super) {
586
612
  }
587
613
  return false;
588
614
  };
615
+ /**
616
+ * Callback that should be called if an error that made the current
617
+ * `ContentDecryptor` instance unusable arised.
618
+ * This callbacks takes care of resetting state and sending the right events.
619
+ *
620
+ * Once called, no further actions should be taken.
621
+ *
622
+ * @param {*} err - The error object which describes the issue. Will be
623
+ * formatted and sent in an "error" event.
624
+ */
589
625
  ContentDecryptor.prototype._onFatalError = function (err) {
590
626
  if (this._canceller.isUsed) {
591
627
  return;
592
628
  }
593
629
  var formattedErr = err instanceof Error ?
594
630
  err :
595
- new OtherError("NONE", "Unknown encryption error");
631
+ new OtherError("NONE", "Unknown decryption error");
596
632
  this.error = formattedErr;
597
633
  this._initDataQueue.length = 0;
598
634
  this._stateData = { state: ContentDecryptorState.Error,
@@ -615,6 +651,10 @@ var ContentDecryptor = /** @class */ (function (_super) {
615
651
  return this._stateData.state === ContentDecryptorState.Disposed ||
616
652
  this._stateData.state === ContentDecryptorState.Error;
617
653
  };
654
+ /**
655
+ * Start processing the next initialization data of the `_initDataQueue` if it
656
+ * isn't lock.
657
+ */
618
658
  ContentDecryptor.prototype._processCurrentInitDataQueue = function () {
619
659
  while (this._stateData.isInitDataQueueLocked === false) {
620
660
  var initData = this._initDataQueue.shift();
@@ -624,11 +664,23 @@ var ContentDecryptor = /** @class */ (function (_super) {
624
664
  this.onInitializationData(initData);
625
665
  }
626
666
  };
667
+ /**
668
+ * Lock new initialization data (from the `_initDataQueue`) from being
669
+ * processed until `_unlockInitDataQueue` is called.
670
+ *
671
+ * You may want to call this method when performing operations which may have
672
+ * an impact on the handling of other initialization data.
673
+ */
627
674
  ContentDecryptor.prototype._lockInitDataQueue = function () {
628
675
  if (this._stateData.isInitDataQueueLocked === false) {
629
676
  this._stateData.isInitDataQueueLocked = true;
630
677
  }
631
678
  };
679
+ /**
680
+ * Unlock `_initDataQueue` and start processing the first element.
681
+ *
682
+ * Should have no effect if the `_initDataQueue` was not locked.
683
+ */
632
684
  ContentDecryptor.prototype._unlockInitDataQueue = function () {
633
685
  if (this._stateData.isMediaKeysAttached !== true) {
634
686
  log.error("DRM: Trying to unlock in the wrong state");
@@ -651,7 +703,25 @@ function canCreatePersistentSession(mediaKeySystemAccess) {
651
703
  return sessionTypes !== undefined &&
652
704
  arrayIncludes(sessionTypes, "persistent-license");
653
705
  }
654
- function updateDecipherability(manifest, whitelistedKeyIds, blacklistedKeyIDs) {
706
+ /**
707
+ * Change the decipherability of Representations which have their key id in one
708
+ * of the given Arrays:
709
+ *
710
+ * - Those who have a key id listed in `whitelistedKeyIds` will have their
711
+ * decipherability updated to `true`
712
+ *
713
+ * - Those who have a key id listed in `blacklistedKeyIds` will have their
714
+ * decipherability updated to `false`
715
+ *
716
+ * - Those who have a key id listed in `delistedKeyIds` will have their
717
+ * decipherability updated to `undefined`.
718
+ *
719
+ * @param {Object} manifest
720
+ * @param {Array.<Uint8Array>} whitelistedKeyIds
721
+ * @param {Array.<Uint8Array>} blacklistedKeyIds
722
+ * @param {Array.<Uint8Array>} delistedKeyIds
723
+ */
724
+ function updateDecipherability(manifest, whitelistedKeyIds, blacklistedKeyIds, delistedKeyIds) {
655
725
  manifest.updateRepresentationsDeciperability(function (representation) {
656
726
  if (representation.contentProtections === undefined) {
657
727
  return representation.decipherable;
@@ -660,8 +730,8 @@ function updateDecipherability(manifest, whitelistedKeyIds, blacklistedKeyIDs) {
660
730
  if (contentKIDs !== undefined) {
661
731
  for (var i = 0; i < contentKIDs.length; i++) {
662
732
  var elt = contentKIDs[i];
663
- for (var j = 0; j < blacklistedKeyIDs.length; j++) {
664
- if (areKeyIdsEqual(blacklistedKeyIDs[j], elt.keyId)) {
733
+ for (var j = 0; j < blacklistedKeyIds.length; j++) {
734
+ if (areKeyIdsEqual(blacklistedKeyIds[j], elt.keyId)) {
665
735
  return false;
666
736
  }
667
737
  }
@@ -670,11 +740,22 @@ function updateDecipherability(manifest, whitelistedKeyIds, blacklistedKeyIDs) {
670
740
  return true;
671
741
  }
672
742
  }
743
+ for (var j = 0; j < delistedKeyIds.length; j++) {
744
+ if (areKeyIdsEqual(delistedKeyIds[j], elt.keyId)) {
745
+ return undefined;
746
+ }
747
+ }
673
748
  }
674
749
  }
675
750
  return representation.decipherable;
676
751
  });
677
752
  }
753
+ /**
754
+ * Update decipherability to `false` to any Representation which is linked to
755
+ * the given initialization data.
756
+ * @param {Object} manifest
757
+ * @param {Object} initData
758
+ */
678
759
  function blackListProtectionData(manifest, initData) {
679
760
  manifest.updateRepresentationsDeciperability(function (representation) {
680
761
  var _a, _b;
@@ -874,6 +955,12 @@ function getKeyIdsLinkedToSession(initializationData, keySessionRecord, singleLi
874
955
  /** associatedKeyIds starts with the whitelisted one. */
875
956
  blacklisted: associatedKeyIds.slice(usableKeyIds.length) };
876
957
  }
958
+ /**
959
+ * Push all kei ids in the given `set` and add it to the `arr` Array only if it
960
+ * isn't already present in it.
961
+ * @param {Set.<Uint8Array>} set
962
+ * @param {Array.<Uint8Array>} arr
963
+ */
877
964
  function mergeKeyIdSetIntoArray(set, arr) {
878
965
  var setArr = Array.from(set.values());
879
966
  var _loop_4 = function (kid) {
@@ -887,6 +974,11 @@ function mergeKeyIdSetIntoArray(set, arr) {
887
974
  _loop_4(kid);
888
975
  }
889
976
  }
977
+ /**
978
+ * Add to the given `set` all key ids found in the given `Period`.
979
+ * @param {Set.<Uint8Array>} set
980
+ * @param {Object} period
981
+ */
890
982
  function addKeyIdsFromPeriod(set, period) {
891
983
  for (var _i = 0, _a = period.getAdaptations(); _i < _a.length; _i++) {
892
984
  var adaptation = _a[_i];