Skip to content

Commit 5dd6167

Browse files
author
Florent Bouisset
committed
use generate init Data instead of having a raw uint8Array
1 parent fc626f9 commit 5dd6167

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/compat/can_rely_on_request_media_key_system_access.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ import { isEdgeChromium } from "./browser_detection";
3131
* 'generateRequest' on 'MediaKeySession': Failed to create MF PR CdmSession".
3232
* In this particular case, the work-around was to consider recommendation.3000 as not supported
3333
* and try another keySystem.
34-
*
34+
* @param keySystem - The key system in use.
3535
* @returns {boolean}
3636
*/
37-
export function canRelyOnRequestMediaKeySystemAccess(keySystem): boolean {
38-
if (!isEdgeChromium && ) {
39-
return true;
37+
export function canRelyOnRequestMediaKeySystemAccess(keySystem: string): boolean {
38+
if (isEdgeChromium && keySystem.indexOf("playready") !== -1) {
39+
return false;
4040
}
41-
return false;
41+
return true;
4242
}

src/main_thread/decrypt/find_key_system.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import log from "../../log";
2424
import type { IKeySystemOption } from "../../public_types";
2525
import arrayIncludes from "../../utils/array_includes";
2626
import flatMap from "../../utils/flat_map";
27+
import { generatePlayReadyInitData } from "../../utils/generate_init_data";
2728
import isNullOrUndefined from "../../utils/is_null_or_undefined";
2829
import type { CancellationSignal } from "../../utils/task_canceller";
2930
import MediaKeysInfosStore from "./utils/media_keys_infos_store";
@@ -410,20 +411,15 @@ export async function testOneKeySystem(
410411
keyType,
411412
keySystemConfigurations,
412413
);
413-
// const shouldTestEMEWorkflow = true;
414414

415-
if (!canRelyOnRequestMediaKeySystemAccess()) {
415+
if (!canRelyOnRequestMediaKeySystemAccess(keyType)) {
416416
try {
417417
const mediaKeys = await keySystemAccess.createMediaKeys();
418418
const session = mediaKeys.createSession();
419-
// this is an example initData.
420-
const initData = new Uint8Array([
421-
0, 0, 0, 96, 112, 115, 115, 104, 0, 0, 0, 0, 237, 239, 139, 169, 121, 214, 74,
422-
206, 163, 200, 39, 220, 213, 29, 33, 237, 0, 0, 0, 64, 8, 1, 18, 16, 152, 28, 134,
423-
221, 177, 134, 78, 139, 186, 110, 143, 92, 30, 232, 180, 46, 26, 8, 87, 105, 100,
424-
101, 118, 105, 110, 101, 34, 26, 48, 49, 72, 84, 83, 57, 52, 84, 75, 55, 70, 68,
425-
66, 86, 75, 82, 57, 69, 88, 48, 89, 83, 88, 88, 82, 51, 72, 227, 220, 149, 155, 6,
426-
]);
419+
// this is just and an example initData to test if the CDM is capable of generating a request
420+
const playReadyHeader =
421+
'<WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"><DATA><PROTECTINFO><KEYLEN>16</KEYLEN><ALGID>AESCTR</ALGID></PROTECTINFO><KID>ckB07BNLskeUq0qd83fTbA==</KID><LA_URL>http://drm.canal-plus.com/</LA_URL><LUI_URL>http://drm.canal-plus.com/</LUI_URL><DS_ID>yYIPDBca1kmMfL60IsfgAQ==</DS_ID><CUSTOMATTRIBUTES xmlns=""><encryptionref>312_4024_2018127108</encryptionref></CUSTOMATTRIBUTES><CHECKSUM>U/tsUYRgMzw=</CHECKSUM></DATA></WRMHEADER>';
422+
const initData = generatePlayReadyInitData(playReadyHeader);
427423
await session.generateRequest("cenc", initData);
428424
} catch (err) {
429425
log.debug("DRM: KeySystemAccess was granted but it is not usable");

0 commit comments

Comments
 (0)