mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1825142 - part5 : use mock CDM (clearkey) to test all supported key systems. r=jolin
Adding a test to test whether we can generate request via the MFCDM for all supported key systems. Differential Revision: https://phabricator.services.mozilla.com/D196509
This commit is contained in:
parent
7434df899e
commit
07c9d08e7e
@ -37,6 +37,12 @@ bool KeySystemConfig::Supports(const nsAString& aKeySystem) {
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
# ifdef MOZ_WMF_CDM
|
||||
// Test only, pretend we have already installed CDMs.
|
||||
if (StaticPrefs::media_eme_wmf_use_mock_cdm_for_external_cdms()) {
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
// Check if Widevine L3 or Clearkey has been downloaded via GMP downloader.
|
||||
if (IsWidevineKeySystem(aKeySystem) || IsClearkeyKeySystem(aKeySystem)) {
|
||||
return HaveGMPFor(nsCString(CHROMIUM_CDM_API),
|
||||
|
@ -434,6 +434,10 @@ MFCDMParent::~MFCDMParent() {
|
||||
|
||||
/* static */
|
||||
LPCWSTR MFCDMParent::GetCDMLibraryName(const nsString& aKeySystem) {
|
||||
if (IsWMFClearKeySystemAndSupported(aKeySystem) ||
|
||||
StaticPrefs::media_eme_wmf_use_mock_cdm_for_external_cdms()) {
|
||||
return L"wmfclearkey.dll";
|
||||
}
|
||||
// PlayReady is a built-in CDM on Windows, no need to load external library.
|
||||
if (IsPlayReadyKeySystemAndSupported(aKeySystem)) {
|
||||
return L"";
|
||||
@ -442,9 +446,6 @@ LPCWSTR MFCDMParent::GetCDMLibraryName(const nsString& aKeySystem) {
|
||||
IsWidevineKeySystem(aKeySystem)) {
|
||||
return sWidevineL1Path ? sWidevineL1Path : L"L1-not-found";
|
||||
}
|
||||
if (IsWMFClearKeySystemAndSupported(aKeySystem)) {
|
||||
return L"wmfclearkey.dll";
|
||||
}
|
||||
return L"Unknown";
|
||||
}
|
||||
|
||||
@ -517,13 +518,14 @@ HRESULT MFCDMParent::LoadFactory(
|
||||
// "<key_system>.ContentDecryptionModuleFactory". In addition, when querying
|
||||
// factory, need to use original Widevine key system name.
|
||||
nsString stringId;
|
||||
if (IsWidevineExperimentKeySystemAndSupported(aKeySystem) ||
|
||||
IsWidevineKeySystem(aKeySystem)) {
|
||||
if (StaticPrefs::media_eme_wmf_use_mock_cdm_for_external_cdms() ||
|
||||
IsWMFClearKeySystemAndSupported(aKeySystem)) {
|
||||
stringId.AppendLiteral("org.w3.clearkey");
|
||||
} else if (IsWidevineExperimentKeySystemAndSupported(aKeySystem) ||
|
||||
IsWidevineKeySystem(aKeySystem)) {
|
||||
// Widevine's DLL expects "<key_system>.ContentDecryptionModuleFactory" for
|
||||
// the class Id.
|
||||
stringId.AppendLiteral("com.widevine.alpha.ContentDecryptionModuleFactory");
|
||||
} else if (IsWMFClearKeySystemAndSupported(aKeySystem)) {
|
||||
stringId = aKeySystem;
|
||||
}
|
||||
MFCDM_PARENT_SLOG("Query factory by classId '%s",
|
||||
NS_ConvertUTF16toUTF8(stringId).get());
|
||||
|
@ -3,6 +3,6 @@ subsuite = "media"
|
||||
tags = "media-engine-compatible"
|
||||
skip-if = ["!wmfme"]
|
||||
|
||||
["test_eme_playready.html"]
|
||||
["test_eme_mfcdm_generate_request.html"]
|
||||
|
||||
["test_eme_wideinve_l1_installation.html"]
|
||||
|
93
dom/media/test/test_eme_mfcdm_generate_request.html
Normal file
93
dom/media/test/test_eme_mfcdm_generate_request.html
Normal file
@ -0,0 +1,93 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media Engine only test : test EME API for supported key systems</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/**
|
||||
* This test is aiming to test whether we can use EME API to generate a request
|
||||
* for all supported key systems. However, we use our mock CDM (MF ClearKey) for
|
||||
* external key systems like Widevine and PlayReady in order to avoid any
|
||||
* possible interfering, such as returning incorrect support types (bug 1851914)
|
||||
* and we can also test hardward DRM key system without being limited by
|
||||
* machine capability.
|
||||
*
|
||||
* As this test doesn't involve any communication with the license server, that
|
||||
* is why we can use our mock CDM (no decryption needed).
|
||||
*/
|
||||
|
||||
add_task(async function setupTestingPrefs() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["media.wmf.media-engine.enabled", 2],
|
||||
["media.eme.playready.enabled", true],
|
||||
["media.eme.widevine.experiment.enabled", true],
|
||||
// This is used to trigger Widevine CDM installation check
|
||||
["media.gmp-widevinecdm-l1.enabled", true],
|
||||
["media.eme.wmf.clearkey.enabled", true],
|
||||
// Use the mock clearkey CDM to create cdm for all other key systems.
|
||||
["media.eme.wmf.use-mock-cdm-for-external-cdms", true],
|
||||
// Our mock CDM doesn't implement 'IsTypeSupportedEx()', only 'IsTypeSupported()'
|
||||
["media.eme.playready.istypesupportedex", false],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
const kKeySystems = [
|
||||
"com.microsoft.playready.recommendation",
|
||||
"com.microsoft.playready.recommendation.3000",
|
||||
"com.microsoft.playready.recommendation.3000.clearlead",
|
||||
"com.widevine.alpha.experiment",
|
||||
"com.widevine.alpha.experiment2",
|
||||
"org.w3.clearkey",
|
||||
];
|
||||
|
||||
add_task(async function testKeySystemRequestForMFCDMs() {
|
||||
for (let keySystem of kKeySystems) {
|
||||
await testKeySystemRequest(keySystem);
|
||||
info(`done testing ${keySystem}!`);
|
||||
}
|
||||
});
|
||||
|
||||
async function testKeySystemRequest(keySystem) {
|
||||
const fakeKID = '{"kids":["a1234567890"]}';
|
||||
// Mock CDM only supports temporary type.
|
||||
const sessionType = 'temporary';
|
||||
const configs = [{
|
||||
initDataTypes: ['keyids'],
|
||||
videoCapabilities: [{ contentType: `video/mp4;codecs="avc1.640028"` }],
|
||||
sessionTypes : [sessionType],
|
||||
}];
|
||||
info(`requestMediaKeySystemAccess for ${keySystem}`);
|
||||
let access = await navigator.requestMediaKeySystemAccess(keySystem, configs)
|
||||
.catch(e => ok(false, `failed to create key system access`));
|
||||
|
||||
info('creating media key');
|
||||
let mediaKeys = await access.createMediaKeys()
|
||||
.catch(e => ok(false, `failed to create media key`));;
|
||||
|
||||
info(`creating a temporary media key session`);
|
||||
let session = mediaKeys.createSession(sessionType);
|
||||
let messagePromise = new Promise(r => {
|
||||
session.addEventListener('message', event => {
|
||||
is(event.messageType, 'license-request',
|
||||
'MediaKeyMessage type should be license-request');
|
||||
ok(true, `created request and received message event`);
|
||||
session.close().then(() => { r(); });
|
||||
});
|
||||
});
|
||||
await session.generateRequest(
|
||||
'keyids',
|
||||
new TextEncoder().encode(fakeKID))
|
||||
.catch(e => ok(false, `failed to generate request`));
|
||||
await messagePromise;
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,65 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media Engine only test : test EME API for PlayReady key system</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/**
|
||||
* This test is used to ensure that the basic EME API operations work on the
|
||||
* PlayReady's key system.
|
||||
*/
|
||||
|
||||
add_task(async function setupTestingPrefs() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["media.wmf.media-engine.enabled", 1],
|
||||
["media.eme.playready.enabled", true],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function testPlayReadyKeySystemRequest() {
|
||||
// From https://testweb.playready.microsoft.com/Content/Content3X
|
||||
const KID_H264 = '{"kids":["a2c786d0f9ef4cb3b333cd323a4284a5"]}';
|
||||
const sessionTypes = ['temporary', 'persistent-license'];
|
||||
const keySystem = "com.microsoft.playready.recommendation";
|
||||
for (const sessionType of sessionTypes) {
|
||||
const configs = [{
|
||||
initDataTypes: ['keyids'],
|
||||
videoCapabilities: [{ contentType: `video/mp4;codecs="avc1.640028"` }],
|
||||
sessionTypes : [sessionType],
|
||||
}];
|
||||
info(`requestMediaKeySystemAccess for ${keySystem}`);
|
||||
let access = await navigator.requestMediaKeySystemAccess(keySystem, configs)
|
||||
.catch(e => ok(false, `failed to create key system access`));
|
||||
|
||||
info('creating media key');
|
||||
let mediaKeys = await access.createMediaKeys()
|
||||
.catch(e => ok(false, `failed to create media key`));;
|
||||
|
||||
info(`creating a ${sessionType} media key session`);
|
||||
let session = mediaKeys.createSession(sessionType);
|
||||
let messagePromise = new Promise(r => {
|
||||
session.addEventListener('message', event => {
|
||||
is(event.messageType, 'license-request',
|
||||
'MediaKeyMessage type should be license-request');
|
||||
ok(true, `created request and received message event`);
|
||||
session.close().then(() => { r(); });
|
||||
});
|
||||
});
|
||||
await session.generateRequest(
|
||||
'keyids',
|
||||
new TextEncoder().encode(KID_H264))
|
||||
.catch(e => ok(false, `failed to generate request`));
|
||||
await messagePromise;
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -10284,6 +10284,14 @@
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# [TEST-ONLY] use Media Foundation clearkey CDM dll to mock as an external CDM,
|
||||
# external CDM like Widevine and PlayReady so that we won't be interfered by
|
||||
# unexpected behaviors caused by the external library.
|
||||
- name: media.eme.wmf.use-mock-cdm-for-external-cdms
|
||||
type: RelaxedAtomicBool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Enable PlayReady DRM for EME
|
||||
- name: media.eme.playready.enabled
|
||||
type: RelaxedAtomicBool
|
||||
|
Loading…
Reference in New Issue
Block a user