Skip to content

Commit 4528c5a

Browse files
PR feedback
1 parent e78c575 commit 4528c5a

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/compat/can_rely_on_request_media_key_system_access.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@ export function canRelyOnRequestMediaKeySystemAccess(keySystem: string): boolean
4040
}
4141
return true;
4242
}
43+
/**
44+
* The PlayReadyHeader sample that will be used to test if the CDM is supported.
45+
* The KID does not matter because no content will be played, it's only to check if
46+
* the CDM is capable of creating a session and generating a request.
47+
*/
48+
export const PLAY_READY_HEADER_EXAMPLE =
49+
'<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><DS_ID>yYIPDBca1kmMfL60IsfgAQ==</DS_ID><CUSTOMATTRIBUTES xmlns=""><encryptionref>312_4024_2018127108</encryptionref></CUSTOMATTRIBUTES><CHECKSUM>U/tsUYRgMzw=</CHECKSUM></DATA></WRMHEADER>';

src/main_thread/decrypt/find_key_system.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { canRelyOnRequestMediaKeySystemAccess } from "../../compat/can_rely_on_request_media_key_system_access";
17+
import {
18+
canRelyOnRequestMediaKeySystemAccess,
19+
PLAY_READY_HEADER_EXAMPLE,
20+
} from "../../compat/can_rely_on_request_media_key_system_access";
1821
import type { ICustomMediaKeySystemAccess } from "../../compat/eme";
1922
import eme from "../../compat/eme";
2023
import shouldRenewMediaKeySystemAccess from "../../compat/should_renew_media_key_system_access";
@@ -378,7 +381,7 @@ export default function getMediaKeySystemAccess(
378381
);
379382

380383
try {
381-
const keySystemAccess = await testOneKeySystem(keyType, keySystemConfigurations);
384+
const keySystemAccess = await testKeySystem(keyType, keySystemConfigurations);
382385
log.info("DRM: Found compatible keysystem", keyType, index + 1);
383386
return {
384387
type: "create-media-key-system-access" as const,
@@ -403,7 +406,7 @@ export default function getMediaKeySystemAccess(
403406
* @param {Array.<MediaKeySystemMediaCapability>} keySystemConfigurations - Configurations for this keySystem
404407
* @returns Promise resolving with the MediaKeySystemAccess. Rejects if unsupported.
405408
*/
406-
export async function testOneKeySystem(
409+
export async function testKeySystem(
407410
keyType: string,
408411
keySystemConfigurations: MediaKeySystemConfiguration[],
409412
) {
@@ -416,10 +419,7 @@ export async function testOneKeySystem(
416419
try {
417420
const mediaKeys = await keySystemAccess.createMediaKeys();
418421
const session = mediaKeys.createSession();
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);
422+
const initData = generatePlayReadyInitData(PLAY_READY_HEADER_EXAMPLE);
423423
await session.generateRequest("cenc", initData);
424424
} catch (err) {
425425
log.debug("DRM: KeySystemAccess was granted but it is not usable");

src/utils/__tests__/generate_init_data.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { utf16LEToStr } from "../string_parsing";
33

44
describe("utils - generatePlayReadyInitData", () => {
55
const playReadyHeader =
6-
'<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>';
6+
'<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><DS_ID>yYIPDBca1kmMfL60IsfgAQ==</DS_ID><CUSTOMATTRIBUTES xmlns=""><encryptionref>312_4024_2018127108</encryptionref></CUSTOMATTRIBUTES></DATA></WRMHEADER>';
77

88
const initData = generatePlayReadyInitData(playReadyHeader);
99
const decodedInitDataUtf16LE = utf16LEToStr(initData);
1010

1111
it("has correct length", () => {
1212
// the expected length for an initData with that PlayReady header.
13-
expect(initData.length).toBe(996);
13+
expect(initData.length).toBe(754);
1414
});
1515

1616
it("has the playerReadyHeader in it", () => {

0 commit comments

Comments
 (0)