rx-player 4.2.0-dev.2024080600 → 4.2.0-dev.2024081300

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 (39) hide show
  1. package/VERSION +1 -1
  2. package/dist/commonjs/main_thread/api/public_api.js +2 -2
  3. package/dist/commonjs/main_thread/decrypt/attach_media_keys.d.ts +6 -1
  4. package/dist/commonjs/main_thread/decrypt/attach_media_keys.d.ts.map +1 -1
  5. package/dist/commonjs/main_thread/decrypt/attach_media_keys.js +2 -1
  6. package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  7. package/dist/commonjs/main_thread/decrypt/content_decryptor.js +2 -1
  8. package/dist/commonjs/main_thread/decrypt/find_key_system.d.ts +17 -5
  9. package/dist/commonjs/main_thread/decrypt/find_key_system.d.ts.map +1 -1
  10. package/dist/commonjs/main_thread/decrypt/find_key_system.js +56 -26
  11. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts +5 -0
  12. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  13. package/dist/commonjs/main_thread/decrypt/get_media_keys.js +4 -2
  14. package/dist/commonjs/main_thread/decrypt/utils/media_keys_infos_store.d.ts +5 -0
  15. package/dist/commonjs/main_thread/decrypt/utils/media_keys_infos_store.d.ts.map +1 -1
  16. package/dist/es2017/main_thread/api/public_api.js +2 -2
  17. package/dist/es2017/main_thread/decrypt/attach_media_keys.d.ts +6 -1
  18. package/dist/es2017/main_thread/decrypt/attach_media_keys.d.ts.map +1 -1
  19. package/dist/es2017/main_thread/decrypt/attach_media_keys.js +2 -1
  20. package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  21. package/dist/es2017/main_thread/decrypt/content_decryptor.js +2 -1
  22. package/dist/es2017/main_thread/decrypt/find_key_system.d.ts +17 -5
  23. package/dist/es2017/main_thread/decrypt/find_key_system.d.ts.map +1 -1
  24. package/dist/es2017/main_thread/decrypt/find_key_system.js +61 -35
  25. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts +5 -0
  26. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  27. package/dist/es2017/main_thread/decrypt/get_media_keys.js +3 -1
  28. package/dist/es2017/main_thread/decrypt/utils/media_keys_infos_store.d.ts +5 -0
  29. package/dist/es2017/main_thread/decrypt/utils/media_keys_infos_store.d.ts.map +1 -1
  30. package/dist/rx-player.js +15 -15
  31. package/package.json +1 -1
  32. package/src/main_thread/api/public_api.ts +2 -2
  33. package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +376 -102
  34. package/src/main_thread/decrypt/__tests__/__global__/utils.ts +4 -23
  35. package/src/main_thread/decrypt/attach_media_keys.ts +7 -0
  36. package/src/main_thread/decrypt/content_decryptor.ts +3 -1
  37. package/src/main_thread/decrypt/find_key_system.ts +78 -43
  38. package/src/main_thread/decrypt/get_media_keys.ts +8 -1
  39. package/src/main_thread/decrypt/utils/media_keys_infos_store.ts +6 -0
@@ -31,7 +31,7 @@ import MediaKeysInfosStore from "./utils/media_keys_infos_store";
31
31
  * @param {Object} currentKeySystemOptions
32
32
  * @returns {null|Object}
33
33
  */
34
- function checkCachedMediaKeySystemAccess(keySystems, currentKeySystemAccess, currentKeySystemOptions) {
34
+ function checkCachedMediaKeySystemAccess(keySystems, askedConfiguration, currentKeySystemAccess, currentKeySystemOptions) {
35
35
  const mksConfiguration = currentKeySystemAccess.getConfiguration();
36
36
  if (shouldRenewMediaKeySystemAccess() || isNullOrUndefined(mksConfiguration)) {
37
37
  return null;
@@ -56,6 +56,7 @@ function checkCachedMediaKeySystemAccess(keySystems, currentKeySystemAccess, cur
56
56
  return {
57
57
  keySystemOptions: firstCompatibleOption,
58
58
  keySystemAccess: currentKeySystemAccess,
59
+ askedConfiguration,
59
60
  };
60
61
  }
61
62
  return null;
@@ -173,6 +174,27 @@ function buildKeySystemConfigurations(keySystemTypeInfo) {
173
174
  persistentState,
174
175
  sessionTypes,
175
176
  };
177
+ if (audioCapabilitiesConfig !== undefined) {
178
+ if (videoCapabilitiesConfig !== undefined) {
179
+ return [wantedMediaKeySystemConfiguration];
180
+ }
181
+ return [
182
+ wantedMediaKeySystemConfiguration,
183
+ Object.assign(Object.assign({}, wantedMediaKeySystemConfiguration), {
184
+ // Re-try without `videoCapabilities` in case the EME implementation is
185
+ // buggy
186
+ videoCapabilities: undefined }),
187
+ ];
188
+ }
189
+ else if (videoCapabilitiesConfig !== undefined) {
190
+ return [
191
+ wantedMediaKeySystemConfiguration,
192
+ Object.assign(Object.assign({}, wantedMediaKeySystemConfiguration), {
193
+ // Re-try without `audioCapabilities` in case the EME implementation is
194
+ // buggy
195
+ audioCapabilities: undefined }),
196
+ ];
197
+ }
176
198
  return [
177
199
  wantedMediaKeySystemConfiguration,
178
200
  // Some legacy implementations have issues with `audioCapabilities` and
@@ -183,23 +205,21 @@ function buildKeySystemConfigurations(keySystemTypeInfo) {
183
205
  }
184
206
  /**
185
207
  * Extract from the current mediaKeys the supported Codecs.
186
- * @param {Object | undefined} audioCapabilitiesConfig - The audio capabilities provided to the KeySystem.
187
- * @param {Object | undefined} videoCapabilitiesConfig - The video capabilities provided to the KeySystem.
188
- * @param {Object | undefined} mksConfiguration - The result of getConfiguration() of the media keys.
208
+ * @param {Object} initialConfiguration - The MediaKeySystemConfiguration given
209
+ * to the `navigator.requestMediaKeySystemAccess` API.
210
+ * @param {Object | undefined} mksConfiguration - The result of
211
+ * getConfiguration() of the media keys.
189
212
  * @return {Array} The list of supported codec by the CDM.
190
213
  */
191
- export function extractCodecSupportListFromConfiguration(audioCapabilitiesConfig, videoCapabilitiesConfig, mksConfiguration) {
192
- var _a, _b;
193
- const { EME_DEFAULT_AUDIO_CODECS, EME_DEFAULT_VIDEO_CODECS } = config.getCurrent();
194
- const testedAudioCodecs = (audioCapabilitiesConfig === null || audioCapabilitiesConfig === void 0 ? void 0 : audioCapabilitiesConfig.type) === "contentType"
195
- ? audioCapabilitiesConfig === null || audioCapabilitiesConfig === void 0 ? void 0 : audioCapabilitiesConfig.value
196
- : EME_DEFAULT_AUDIO_CODECS;
197
- const testedVideoCodecs = (videoCapabilitiesConfig === null || videoCapabilitiesConfig === void 0 ? void 0 : videoCapabilitiesConfig.type) === "contentType"
198
- ? videoCapabilitiesConfig.value
199
- : EME_DEFAULT_VIDEO_CODECS;
200
- const testedCodecs = testedAudioCodecs.concat(testedVideoCodecs);
201
- const supportedVideoCodecs = (_a = mksConfiguration.videoCapabilities) === null || _a === void 0 ? void 0 : _a.map((entry) => entry.contentType);
202
- const supportedAudioCodecs = (_b = mksConfiguration.audioCapabilities) === null || _b === void 0 ? void 0 : _b.map((entry) => entry.contentType);
214
+ export function extractCodecSupportListFromConfiguration(initialConfiguration, mksConfiguration) {
215
+ var _a, _b, _c, _d, _e, _f;
216
+ const testedAudioCodecs = (_b = (_a = initialConfiguration.audioCapabilities) === null || _a === void 0 ? void 0 : _a.map((v) => v.contentType)) !== null && _b !== void 0 ? _b : [];
217
+ const testedVideoCodecs = (_d = (_c = initialConfiguration.videoCapabilities) === null || _c === void 0 ? void 0 : _c.map((v) => v.contentType)) !== null && _d !== void 0 ? _d : [];
218
+ const testedCodecs = testedAudioCodecs
219
+ .concat(testedVideoCodecs)
220
+ .filter((c) => c !== undefined);
221
+ const supportedVideoCodecs = (_e = mksConfiguration.videoCapabilities) === null || _e === void 0 ? void 0 : _e.map((entry) => entry.contentType);
222
+ const supportedAudioCodecs = (_f = mksConfiguration.audioCapabilities) === null || _f === void 0 ? void 0 : _f.map((entry) => entry.contentType);
203
223
  const supportedCodecs = [
204
224
  ...(supportedVideoCodecs !== null && supportedVideoCodecs !== void 0 ? supportedVideoCodecs : []),
205
225
  ...(supportedAudioCodecs !== null && supportedAudioCodecs !== void 0 ? supportedAudioCodecs : []),
@@ -249,15 +269,16 @@ export default function getMediaKeySystemAccess(mediaElement, keySystemsConfigs,
249
269
  if (eme.implementation === currentState.emeImplementation.implementation) {
250
270
  // Fast way to find a compatible keySystem if the currently loaded
251
271
  // one as exactly the same compatibility options.
252
- const cachedKeySystemAccess = checkCachedMediaKeySystemAccess(keySystemsConfigs, currentState.mediaKeySystemAccess, currentState.keySystemOptions);
272
+ const cachedKeySystemAccess = checkCachedMediaKeySystemAccess(keySystemsConfigs, currentState.askedConfiguration, currentState.mediaKeySystemAccess, currentState.keySystemOptions);
253
273
  if (cachedKeySystemAccess !== null) {
254
274
  log.info("DRM: Found cached compatible keySystem");
255
275
  return Promise.resolve({
256
276
  type: "reuse-media-key-system-access",
257
277
  value: {
258
278
  mediaKeySystemAccess: cachedKeySystemAccess.keySystemAccess,
279
+ askedConfiguration: cachedKeySystemAccess.askedConfiguration,
259
280
  options: cachedKeySystemAccess.keySystemOptions,
260
- codecSupport: extractCodecSupportListFromConfiguration(cachedKeySystemAccess.keySystemOptions.audioCapabilitiesConfig, cachedKeySystemAccess.keySystemOptions.videoCapabilitiesConfig, cachedKeySystemAccess.keySystemAccess.getConfiguration()),
281
+ codecSupport: extractCodecSupportListFromConfiguration(cachedKeySystemAccess.askedConfiguration, cachedKeySystemAccess.keySystemAccess.getConfiguration()),
261
282
  },
262
283
  });
263
284
  }
@@ -314,25 +335,30 @@ export default function getMediaKeySystemAccess(mediaElement, keySystemsConfigs,
314
335
  const keySystemConfigurations = buildKeySystemConfigurations(chosenType);
315
336
  log.debug(`DRM: Request keysystem access ${keyType},` +
316
337
  `${index + 1} of ${keySystemsType.length}`);
317
- try {
318
- const keySystemAccess = await testKeySystem(keyType, keySystemConfigurations);
319
- log.info("DRM: Found compatible keysystem", keyType, index + 1);
320
- return {
321
- type: "create-media-key-system-access",
322
- value: {
323
- options: keySystemOptions,
324
- mediaKeySystemAccess: keySystemAccess,
325
- codecSupport: extractCodecSupportListFromConfiguration(keySystemOptions.audioCapabilitiesConfig, keySystemOptions.videoCapabilitiesConfig, keySystemAccess.getConfiguration()),
326
- },
327
- };
328
- }
329
- catch (_) {
330
- log.debug("DRM: Rejected access to keysystem", keyType, index + 1);
331
- if (cancelSignal.cancellationError !== null) {
332
- throw cancelSignal.cancellationError;
338
+ let keySystemAccess;
339
+ for (let configIdx = 0; configIdx < keySystemConfigurations.length; configIdx++) {
340
+ const keySystemConfiguration = keySystemConfigurations[configIdx];
341
+ try {
342
+ keySystemAccess = await testKeySystem(keyType, [keySystemConfiguration]);
343
+ log.info("DRM: Found compatible keysystem", keyType, index + 1);
344
+ return {
345
+ type: "create-media-key-system-access",
346
+ value: {
347
+ options: keySystemOptions,
348
+ mediaKeySystemAccess: keySystemAccess,
349
+ askedConfiguration: keySystemConfiguration,
350
+ codecSupport: extractCodecSupportListFromConfiguration(keySystemConfiguration, keySystemAccess.getConfiguration()),
351
+ },
352
+ };
353
+ }
354
+ catch (_) {
355
+ log.debug("DRM: Rejected access to keysystem", keyType, index + 1, configIdx);
356
+ if (cancelSignal.cancellationError !== null) {
357
+ throw cancelSignal.cancellationError;
358
+ }
333
359
  }
334
- return recursivelyTestKeySystems(index + 1);
335
360
  }
361
+ return recursivelyTestKeySystems(index + 1);
336
362
  }
337
363
  }
338
364
  /**
@@ -23,6 +23,11 @@ import type { IMediaKeySessionStores } from "./types";
23
23
  export interface IMediaKeysInfos {
24
24
  /** The MediaKeySystemAccess which allowed to create the MediaKeys instance. */
25
25
  mediaKeySystemAccess: MediaKeySystemAccess | ICustomMediaKeySystemAccess;
26
+ /**
27
+ * The MediaKeySystemConfiguration that has been provided to the
28
+ * `requestMediaKeySystemAccess` API.
29
+ */
30
+ askedConfiguration: MediaKeySystemConfiguration;
26
31
  /** The MediaKeys instance. */
27
32
  mediaKeys: MediaKeys | ICustomMediaKeys;
28
33
  /** Stores allowing to create and retrieve MediaKeySessions. */
@@ -1 +1 @@
1
- {"version":3,"file":"get_media_keys.d.ts","sourceRoot":"","sources":["../../../../src/main_thread/decrypt/get_media_keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CA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B,CAAC;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAuBtD,8CAA8C;AAC9C,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,oBAAoB,EAAE,oBAAoB,GAAG,2BAA2B,CAAC;IACzE;;;OAGG;IACH,kBAAkB,EAAE,2BAA2B,CAAC;IAChD,8BAA8B;IAC9B,SAAS,EAAE,SAAS,GAAG,gBAAgB,CAAC;IACxC,+DAA+D;IAC/D,MAAM,EAAE,sBAAsB,CAAC;IAC/B,qEAAqE;IACrE,OAAO,EAAE,gBAAgB,CAAC;IAC1B,yBAAyB;IACzB,YAAY,EAAE,iBAAiB,CAAC;CACjC;AAED;;;;;;;;;;;;GAYG;AACH,wBAA8B,iBAAiB,CAC7C,YAAY,EAAE,aAAa,EAC3B,iBAAiB,EAAE,gBAAgB,EAAE,EACrC,YAAY,EAAE,kBAAkB,GAC/B,OAAO,CAAC,eAAe,CAAC,CAmD1B"}
@@ -53,7 +53,7 @@ export default async function getMediaKeysInfos(mediaElement, keySystemsConfigs,
53
53
  if (cancelSignal.cancellationError !== null) {
54
54
  throw cancelSignal.cancellationError;
55
55
  }
56
- const { options, mediaKeySystemAccess, codecSupport } = evt.value;
56
+ const { options, mediaKeySystemAccess, askedConfiguration, codecSupport } = evt.value;
57
57
  const currentState = MediaKeysInfosStore.getState(mediaElement);
58
58
  const persistentSessionsStore = createPersistentSessionsStorage(options);
59
59
  if (canReuseMediaKeys() &&
@@ -69,6 +69,7 @@ export default async function getMediaKeysInfos(mediaElement, keySystemsConfigs,
69
69
  return {
70
70
  mediaKeys,
71
71
  mediaKeySystemAccess,
72
+ askedConfiguration,
72
73
  stores: { loadedSessionsStore, persistentSessionsStore },
73
74
  options,
74
75
  codecSupport,
@@ -81,6 +82,7 @@ export default async function getMediaKeysInfos(mediaElement, keySystemsConfigs,
81
82
  return {
82
83
  mediaKeys,
83
84
  mediaKeySystemAccess,
85
+ askedConfiguration,
84
86
  stores: { loadedSessionsStore, persistentSessionsStore },
85
87
  options,
86
88
  codecSupport,
@@ -22,6 +22,11 @@ export interface IMediaElementMediaKeysInfos {
22
22
  emeImplementation: IEmeApiImplementation;
23
23
  /** Last keySystemOptions used with that HTMLMediaElement. */
24
24
  keySystemOptions: IKeySystemOption;
25
+ /**
26
+ * The actual MediaKeySystemConfiguration asked to the
27
+ * `requestMediaKeySystemAccess` API.
28
+ */
29
+ askedConfiguration: MediaKeySystemConfiguration;
25
30
  /**
26
31
  * Last MediaKeySystemAccess used to create a MediaKeys bound to that
27
32
  * HTMLMediaElement.
@@ -1 +1 @@
1
- {"version":3,"file":"media_keys_infos_store.d.ts","sourceRoot":"","sources":["../../../../../src/main_thread/decrypt/utils/media_keys_infos_store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,mBAAmB,MAAM,yBAAyB,CAAC;AAE/D,6EAA6E;AAC7E,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,EAAE,qBAAqB,CAAC;IAEzC,6DAA6D;IAC7D,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC;;;OAGG;IACH,oBAAoB,EAAE,2BAA2B,GAAG,oBAAoB,CAAC;IAEzE,8DAA8D;IAC9D,SAAS,EAAE,SAAS,GAAG,gBAAgB,CAAC;IAExC;;;OAGG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;;IASC;;;;OAIG;2BACoB,aAAa,SAAS,2BAA2B,GAAG,IAAI,GAAG,IAAI;IAItF;;;;OAIG;2BACoB,aAAa,GAAG,2BAA2B,GAAG,IAAI;IAKzE;;;OAGG;6BACsB,aAAa,GAAG,IAAI;;AAxB/C,wBA2BE"}
1
+ {"version":3,"file":"media_keys_infos_store.d.ts","sourceRoot":"","sources":["../../../../../src/main_thread/decrypt/utils/media_keys_infos_store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,mBAAmB,MAAM,yBAAyB,CAAC;AAE/D,6EAA6E;AAC7E,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,EAAE,qBAAqB,CAAC;IAEzC,6DAA6D;IAC7D,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC;;;OAGG;IACH,kBAAkB,EAAE,2BAA2B,CAAC;IAEhD;;;OAGG;IACH,oBAAoB,EAAE,2BAA2B,GAAG,oBAAoB,CAAC;IAEzE,8DAA8D;IAC9D,SAAS,EAAE,SAAS,GAAG,gBAAgB,CAAC;IAExC;;;OAGG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;;IASC;;;;OAIG;2BACoB,aAAa,SAAS,2BAA2B,GAAG,IAAI,GAAG,IAAI;IAItF;;;;OAIG;2BACoB,aAAa,GAAG,2BAA2B,GAAG,IAAI;IAKzE;;;OAGG;6BACsB,aAAa,GAAG,IAAI;;AAxB/C,wBA2BE"}