diff --git a/src/compat/can_rely_on_request_media_key_system_access.ts b/src/compat/can_rely_on_request_media_key_system_access.ts
index 4270923af7d..9eff3395cf2 100644
--- a/src/compat/can_rely_on_request_media_key_system_access.ts
+++ b/src/compat/can_rely_on_request_media_key_system_access.ts
@@ -40,3 +40,10 @@ export function canRelyOnRequestMediaKeySystemAccess(keySystem: string): boolean
}
return true;
}
+/**
+ * The PlayReadyHeader sample that will be used to test if the CDM is supported.
+ * The KID does not matter because no content will be played, it's only to check if
+ * the CDM is capable of creating a session and generating a request.
+ */
+export const PLAY_READY_HEADER_EXAMPLE =
+ '16AESCTRckB07BNLskeUq0qd83fTbA==yYIPDBca1kmMfL60IsfgAQ==312_4024_2018127108U/tsUYRgMzw=';
diff --git a/src/main_thread/decrypt/find_key_system.ts b/src/main_thread/decrypt/find_key_system.ts
index 3b74e187015..dee20545ec7 100644
--- a/src/main_thread/decrypt/find_key_system.ts
+++ b/src/main_thread/decrypt/find_key_system.ts
@@ -14,7 +14,10 @@
* limitations under the License.
*/
-import { canRelyOnRequestMediaKeySystemAccess } from "../../compat/can_rely_on_request_media_key_system_access";
+import {
+ canRelyOnRequestMediaKeySystemAccess,
+ PLAY_READY_HEADER_EXAMPLE,
+} from "../../compat/can_rely_on_request_media_key_system_access";
import type { ICustomMediaKeySystemAccess } from "../../compat/eme";
import eme from "../../compat/eme";
import shouldRenewMediaKeySystemAccess from "../../compat/should_renew_media_key_system_access";
@@ -378,7 +381,7 @@ export default function getMediaKeySystemAccess(
);
try {
- const keySystemAccess = await testOneKeySystem(keyType, keySystemConfigurations);
+ const keySystemAccess = await testKeySystem(keyType, keySystemConfigurations);
log.info("DRM: Found compatible keysystem", keyType, index + 1);
return {
type: "create-media-key-system-access" as const,
@@ -403,7 +406,7 @@ export default function getMediaKeySystemAccess(
* @param {Array.} keySystemConfigurations - Configurations for this keySystem
* @returns Promise resolving with the MediaKeySystemAccess. Rejects if unsupported.
*/
-export async function testOneKeySystem(
+export async function testKeySystem(
keyType: string,
keySystemConfigurations: MediaKeySystemConfiguration[],
) {
@@ -416,10 +419,7 @@ export async function testOneKeySystem(
try {
const mediaKeys = await keySystemAccess.createMediaKeys();
const session = mediaKeys.createSession();
- // this is just and an example initData to test if the CDM is capable of generating a request
- const playReadyHeader =
- '16AESCTRckB07BNLskeUq0qd83fTbA==http://drm.canal-plus.com/http://drm.canal-plus.com/yYIPDBca1kmMfL60IsfgAQ==312_4024_2018127108U/tsUYRgMzw=';
- const initData = generatePlayReadyInitData(playReadyHeader);
+ const initData = generatePlayReadyInitData(PLAY_READY_HEADER_EXAMPLE);
await session.generateRequest("cenc", initData);
} catch (err) {
log.debug("DRM: KeySystemAccess was granted but it is not usable");
diff --git a/src/utils/__tests__/generate_init_data.test.ts b/src/utils/__tests__/generate_init_data.test.ts
index 62eb5f624bf..42ab6a4e8ee 100644
--- a/src/utils/__tests__/generate_init_data.test.ts
+++ b/src/utils/__tests__/generate_init_data.test.ts
@@ -3,14 +3,14 @@ import { utf16LEToStr } from "../string_parsing";
describe("utils - generatePlayReadyInitData", () => {
const playReadyHeader =
- '16AESCTRckB07BNLskeUq0qd83fTbA==http://drm.canal-plus.com/http://drm.canal-plus.com/yYIPDBca1kmMfL60IsfgAQ==312_4024_2018127108U/tsUYRgMzw=';
+ '16AESCTRckB07BNLskeUq0qd83fTbA==yYIPDBca1kmMfL60IsfgAQ==312_4024_2018127108';
const initData = generatePlayReadyInitData(playReadyHeader);
const decodedInitDataUtf16LE = utf16LEToStr(initData);
it("has correct length", () => {
// the expected length for an initData with that PlayReady header.
- expect(initData.length).toBe(996);
+ expect(initData.length).toBe(754);
});
it("has the playerReadyHeader in it", () => {