Backed out 7 changesets (bug 1863800) for causing bustage on MediaKeySystemAccessManager.cpp

Backed out changeset d89d2efafd8a (bug 1863800)
Backed out changeset 272c033e5d58 (bug 1863800)
Backed out changeset f3f86cc42775 (bug 1863800)
Backed out changeset 68267c6bf0ac (bug 1863800)
Backed out changeset 7fa5617dd0f5 (bug 1863800)
Backed out changeset 750dc1b57c2b (bug 1863800)
Backed out changeset 3eef40828d86 (bug 1863800)
This commit is contained in:
Norisz Fay 2023-12-19 00:10:04 +02:00
parent a23007ad30
commit 19d025b320
18 changed files with 70 additions and 340 deletions

View file

@ -1955,7 +1955,7 @@ already_AddRefed<Promise> ChromeUtils::GetWMFContentDecryptionModuleInformation(
return nullptr;
}
MOZ_ASSERT(domPromise);
MFCDMService::GetAllKeySystemsCapabilities(domPromise);
MFCDMCapabilities::GetAllKeySystemsCapabilities(domPromise);
return domPromise.forget();
}
#endif

View file

@ -127,8 +127,7 @@ bool IsHardwareDecryptionSupported(
}
for (const auto& capabilities : aConfig.mVideoCapabilities) {
if (capabilities.mRobustness.EqualsLiteral("3000") ||
capabilities.mRobustness.EqualsLiteral("HW_SECURE_ALL") ||
capabilities.mRobustness.EqualsLiteral("HW_SECURE_DECODE")) {
capabilities.mRobustness.EqualsLiteral("HW_SECURE_ALL")) {
supportHardwareDecryption = true;
break;
}
@ -207,16 +206,4 @@ bool DoesKeySystemSupportClearLead(const nsAString& aKeySystem) {
return aKeySystem.EqualsLiteral(kWidevineKeySystemName);
}
bool CheckIfHarewareDRMConfigExists(
const nsTArray<dom::MediaKeySystemConfiguration>& aConfigs) {
bool foundHWDRMconfig = false;
for (const auto& config : aConfigs) {
if (IsHardwareDecryptionSupported(config)) {
foundHWDRMconfig = true;
break;
}
}
return foundHWDRMconfig;
}
} // namespace mozilla

View file

@ -93,11 +93,6 @@ void MFCDMCapabilitiesIPDLToKeySystemConfig(
bool DoesKeySystemSupportClearLead(const nsAString& aKeySystem);
// Return true if there is any config in the given configs has hardware DRM
// associated robustness.
bool CheckIfHarewareDRMConfigExists(
const nsTArray<dom::MediaKeySystemConfiguration>& aConfigs);
} // namespace mozilla
#endif // EME_LOG_H_

View file

@ -30,33 +30,25 @@ namespace mozilla {
/* static */
bool KeySystemConfig::Supports(const nsAString& aKeySystem) {
// Check if Widevine L3 or Clearkey has been downloaded via GMP downloader.
if (IsWidevineKeySystem(aKeySystem) || IsClearkeyKeySystem(aKeySystem)) {
return HaveGMPFor(nsCString(CHROMIUM_CDM_API),
{NS_ConvertUTF16toUTF8(aKeySystem)});
}
nsCString api = nsLiteralCString(CHROMIUM_CDM_API);
nsCString name = NS_ConvertUTF16toUTF8(aKeySystem);
if (HaveGMPFor(api, {name})) {
return true;
}
#ifdef MOZ_WIDGET_ANDROID
// Check if we can use MediaDrm for this keysystem.
if (mozilla::java::MediaDrmProxy::IsSchemeSupported(
NS_ConvertUTF16toUTF8(aKeySystem))) {
if (mozilla::java::MediaDrmProxy::IsSchemeSupported(name)) {
return true;
}
#endif
#if MOZ_WMF_CDM
// Check if Widevine L1 has been downloaded via GMP downloader.
if (IsWidevineExperimentKeySystemAndSupported(aKeySystem)) {
return HaveGMPFor(nsCString(kWidevineExperimentAPIName),
{nsCString(kWidevineExperimentKeySystemName)});
}
if ((IsPlayReadyKeySystemAndSupported(aKeySystem)) &&
if ((IsPlayReadyKeySystemAndSupported(aKeySystem) ||
IsWidevineExperimentKeySystemAndSupported(aKeySystem)) &&
WMFCDMImpl::Supports(aKeySystem)) {
return true;
}
#endif
return false;
}

View file

@ -121,7 +121,6 @@ struct KeySystemConfig {
nsTArray<EMECodecString> mCodecsDecrypted;
};
// Return true if given key system is supported on the current device.
static bool Supports(const nsAString& aKeySystem);
static bool CreateKeySystemConfigs(const nsAString& aKeySystem,
nsTArray<KeySystemConfig>& aOutConfigs);

View file

@ -22,7 +22,6 @@
#include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/MediaKeySession.h"
#include "mozilla/dom/MediaKeySystemAccessBinding.h"
#include "mozilla/dom/MediaKeySystemAccessManager.h"
#include "mozilla/dom/MediaSource.h"
#include "nsDOMString.h"
#include "nsIObserverService.h"
@ -40,9 +39,6 @@
namespace mozilla::dom {
#define LOG(msg, ...) \
EME_LOG("MediaKeySystemAccess::%s " msg, __func__, ##__VA_ARGS__)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeySystemAccess, mParent)
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeySystemAccess)
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeySystemAccess)
@ -57,9 +53,9 @@ MediaKeySystemAccess::MediaKeySystemAccess(
nsPIDOMWindowInner* aParent, const nsAString& aKeySystem,
const MediaKeySystemConfiguration& aConfig)
: mParent(aParent), mKeySystem(aKeySystem), mConfig(aConfig) {
LOG("Created MediaKeySystemAccess for keysystem=%s config=%s",
NS_ConvertUTF16toUTF8(mKeySystem).get(),
mozilla::dom::ToCString(mConfig).get());
EME_LOG("Created MediaKeySystemAccess for keysystem=%s config=%s",
NS_ConvertUTF16toUTF8(mKeySystem).get(),
mozilla::dom::ToCString(mConfig).get());
}
MediaKeySystemAccess::~MediaKeySystemAccess() = default;
@ -88,78 +84,37 @@ already_AddRefed<Promise> MediaKeySystemAccess::CreateMediaKeys(
return keys->Init(aRv);
}
enum class SecureLevel {
Software,
Hardware,
};
static MediaKeySystemStatus EnsureCDMInstalled(const nsAString& aKeySystem,
const SecureLevel aSecure,
nsACString& aOutMessage) {
if (aSecure == SecureLevel::Software &&
!KeySystemConfig::Supports(aKeySystem)) {
if (!KeySystemConfig::Supports(aKeySystem)) {
aOutMessage = "CDM is not installed"_ns;
return MediaKeySystemStatus::Cdm_not_installed;
}
#ifdef MOZ_WMF_CDM
if (aSecure == SecureLevel::Hardware) {
// Ensure we check the hardware key system name.
nsAutoString hardwareKeySystem;
if (IsWidevineKeySystem(aKeySystem) ||
IsWidevineExperimentKeySystemAndSupported(aKeySystem)) {
hardwareKeySystem =
NS_ConvertUTF8toUTF16(kWidevineExperimentKeySystemName);
} else if (IsPlayReadyKeySystemAndSupported(aKeySystem)) {
hardwareKeySystem = NS_ConvertUTF8toUTF16(kPlayReadyKeySystemHardware);
} else {
MOZ_ASSERT_UNREACHABLE("Not supported key system for HWDRM!");
}
if (!KeySystemConfig::Supports(hardwareKeySystem)) {
aOutMessage = "CDM is not installed"_ns;
return MediaKeySystemStatus::Cdm_not_installed;
}
}
#endif
return MediaKeySystemStatus::Available;
}
/* static */
MediaKeySystemStatus MediaKeySystemAccess::GetKeySystemStatus(
const MediaKeySystemAccessRequest& aRequest, nsACString& aOutMessage) {
const nsString& keySystem = aRequest.mKeySystem;
const nsAString& aKeySystem, nsACString& aOutMessage) {
MOZ_ASSERT(StaticPrefs::media_eme_enabled() ||
IsClearkeyKeySystem(keySystem));
IsClearkeyKeySystem(aKeySystem));
LOG("checking if CDM is installed or disabled for %s",
NS_ConvertUTF16toUTF8(keySystem).get());
if (IsClearkeyKeySystem(keySystem)) {
return EnsureCDMInstalled(keySystem, SecureLevel::Software, aOutMessage);
if (IsClearkeyKeySystem(aKeySystem)) {
return EnsureCDMInstalled(aKeySystem, aOutMessage);
}
// This is used to determine if we need to download Widevine L1.
bool shouldCheckL1Installation = false;
#ifdef MOZ_WMF_CDM
if (StaticPrefs::media_eme_widevine_experiment_enabled()) {
shouldCheckL1Installation =
CheckIfHarewareDRMConfigExists(aRequest.mConfigs) ||
IsWidevineExperimentKeySystemAndSupported(keySystem);
}
#endif
// Check Widevine L3
if (IsWidevineKeySystem(keySystem) && !shouldCheckL1Installation) {
if (IsWidevineKeySystem(aKeySystem)) {
if (Preferences::GetBool("media.gmp-widevinecdm.visible", false)) {
if (!Preferences::GetBool("media.gmp-widevinecdm.enabled", false)) {
aOutMessage = "Widevine EME disabled"_ns;
return MediaKeySystemStatus::Cdm_disabled;
}
return EnsureCDMInstalled(keySystem, SecureLevel::Software, aOutMessage);
return EnsureCDMInstalled(aKeySystem, aOutMessage);
#ifdef MOZ_WIDGET_ANDROID
} else if (Preferences::GetBool("media.mediadrm-widevinecdm.visible",
false)) {
nsCString keySystem = NS_ConvertUTF16toUTF8(aKeySystem);
bool supported =
mozilla::java::MediaDrmProxy::IsSchemeSupported(keySystem);
if (!supported) {
@ -173,25 +128,11 @@ MediaKeySystemStatus MediaKeySystemAccess::GetKeySystemStatus(
}
#ifdef MOZ_WMF_CDM
// Check PlayReady, which is a built-in CDM on most Windows versions.
if (IsPlayReadyKeySystemAndSupported(keySystem) &&
KeySystemConfig::Supports(keySystem)) {
if ((IsPlayReadyKeySystemAndSupported(aKeySystem) ||
IsWidevineExperimentKeySystemAndSupported(aKeySystem)) &&
KeySystemConfig::Supports(aKeySystem)) {
return MediaKeySystemStatus::Available;
}
// Check Widevine L1. This can be a request for experimental key systems, or
// for a normal key system with hardware robustness.
if ((IsWidevineExperimentKeySystemAndSupported(keySystem) ||
IsWidevineKeySystem(keySystem)) &&
shouldCheckL1Installation) {
// TODO : if L3 hasn't been installed as well, should we fallback to install
// L3?
if (!Preferences::GetBool("media.gmp-widevinecdm-l1.enabled", false)) {
aOutMessage = "Widevine L1 EME disabled"_ns;
return MediaKeySystemStatus::Cdm_disabled;
}
return EnsureCDMInstalled(keySystem, SecureLevel::Hardware, aOutMessage);
}
#endif
return MediaKeySystemStatus::Cdm_not_supported;
@ -1156,6 +1097,4 @@ nsCString MediaKeySystemAccess::ToCString(
return mozilla::dom::ToCString(aConfig);
}
#undef LOG
} // namespace mozilla::dom

View file

@ -24,8 +24,6 @@ class ErrorResult;
namespace dom {
struct MediaKeySystemAccessRequest;
class MediaKeySystemAccess final : public nsISupports, public nsWrapperCache {
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@ -52,8 +50,7 @@ class MediaKeySystemAccess final : public nsISupports, public nsWrapperCache {
already_AddRefed<Promise> CreateMediaKeys(ErrorResult& aRv);
static MediaKeySystemStatus GetKeySystemStatus(
const MediaKeySystemAccessRequest& aRequest,
nsACString& aOutExceptionMessage);
const nsAString& aKeySystem, nsACString& aOutExceptionMessage);
static void NotifyObservers(nsPIDOMWindowInner* aWindow,
const nsAString& aKeySystem,

View file

@ -31,7 +31,7 @@ namespace mozilla::dom {
MediaKeySystemAccessManager::PendingRequest::PendingRequest(
DetailedPromise* aPromise, const nsAString& aKeySystem,
const Sequence<MediaKeySystemConfiguration>& aConfigs)
: MediaKeySystemAccessRequest(aKeySystem, aConfigs), mPromise(aPromise) {
: mPromise(aPromise), mKeySystem(aKeySystem), mConfigs(aConfigs) {
MOZ_COUNT_CTOR(MediaKeySystemAccessManager::PendingRequest);
}
@ -405,7 +405,7 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
nsAutoCString message;
MediaKeySystemStatus status =
MediaKeySystemAccess::GetKeySystemStatus(*aRequest, message);
MediaKeySystemAccess::GetKeySystemStatus(aRequest->mKeySystem, message);
nsPrintfCString msg(
"MediaKeySystemAccess::GetKeySystemStatus(%s) "
@ -414,15 +414,10 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
nsCString(MediaKeySystemStatusValues::GetString(status)).get(),
message.get());
LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg));
EME_LOG("%s", msg.get());
// We may need to install Widevine CDM to continue.
// We may need to install the CDM to continue.
if (status == MediaKeySystemStatus::Cdm_not_installed &&
(IsWidevineKeySystem(aRequest->mKeySystem)
#ifdef MOZ_WMF_CDM
|| IsWidevineExperimentKeySystemAndSupported(aRequest->mKeySystem)
#endif
)) {
IsWidevineKeySystem(aRequest->mKeySystem)) {
// These are cases which could be resolved by downloading a new(er) CDM.
// When we send the status to chrome, chrome's GMPProvider will attempt to
// download or update the CDM. In AwaitInstall() we add listeners to wait
@ -444,25 +439,13 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
return;
}
nsString keySystem = aRequest->mKeySystem;
#ifdef MOZ_WMF_CDM
// If cdm-not-install is for HWDRM, that means we want to install Widevine
// L1, which requires using hardware key system name for GMP to look up the
// plugin.
if (CheckIfHarewareDRMConfigExists(aRequest->mConfigs)) {
keySystem = NS_ConvertUTF8toUTF16(kWidevineExperimentKeySystemName);
}
#endif
const nsString keySystem = aRequest->mKeySystem;
if (AwaitInstall(std::move(aRequest))) {
// Notify chrome that we're going to wait for the CDM to download/update.
EME_LOG("Await %s for installation",
NS_ConvertUTF16toUTF8(keySystem).get());
MediaKeySystemAccess::NotifyObservers(mWindow, keySystem, status);
} else {
// Failed to await the install. Log failure and give up trying to service
// this request.
EME_LOG("Failed to await %s for installation",
NS_ConvertUTF16toUTF8(keySystem).get());
diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(), keySystem,
false, __func__);
}
@ -472,8 +455,6 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
// Failed due to user disabling something, send a notification to
// chrome, so we can show some UI to explain how the user can rectify
// the situation.
EME_LOG("Notify CDM failure for %s and reject the promise",
NS_ConvertUTF16toUTF8(aRequest->mKeySystem).get());
MediaKeySystemAccess::NotifyObservers(mWindow, aRequest->mKeySystem,
status);
aRequest->RejectPromiseWithNotSupportedError(message);
@ -616,7 +597,7 @@ nsresult MediaKeySystemAccessManager::Observe(nsISupports* aSubject,
for (size_t i = mPendingInstallRequests.Length(); i-- > 0;) {
nsAutoCString message;
MediaKeySystemStatus status = MediaKeySystemAccess::GetKeySystemStatus(
*mPendingInstallRequests[i], message);
mPendingInstallRequests[i]->mKeySystem, message);
if (status == MediaKeySystemStatus::Cdm_not_installed) {
// Not yet installed, don't retry. Keep waiting until timeout.
continue;

View file

@ -85,18 +85,6 @@ class TestGMPVideoDecoder;
*
*/
struct MediaKeySystemAccessRequest {
MediaKeySystemAccessRequest(
const nsAString& aKeySystem,
const Sequence<MediaKeySystemConfiguration>& aConfigs)
: mKeySystem(aKeySystem), mConfigs(aConfigs) {}
virtual ~MediaKeySystemAccessRequest() = default;
// The KeySystem passed for this request.
const nsString mKeySystem;
// The config(s) passed for this request.
const Sequence<MediaKeySystemConfiguration> mConfigs;
};
class MediaKeySystemAccessManager final : public nsIObserver, public nsINamed {
public:
explicit MediaKeySystemAccessManager(nsPIDOMWindowInner* aWindow);
@ -116,7 +104,7 @@ class MediaKeySystemAccessManager final : public nsIObserver, public nsINamed {
private:
// Encapsulates the information for a Navigator.requestMediaKeySystemAccess()
// request that is being processed.
struct PendingRequest : public MediaKeySystemAccessRequest {
struct PendingRequest {
enum class RequestType { Initial, Subsequent };
PendingRequest(DetailedPromise* aPromise, const nsAString& aKeySystem,
@ -125,6 +113,10 @@ class MediaKeySystemAccessManager final : public nsIObserver, public nsINamed {
// The JS promise associated with this request.
RefPtr<DetailedPromise> mPromise;
// The KeySystem passed for this request.
const nsString mKeySystem;
// The config(s) passed for this request.
const Sequence<MediaKeySystemConfiguration> mConfigs;
// If the request is
// - A first attempt request from JS: RequestType::Initial.

View file

@ -52,10 +52,6 @@
# include "mozilla/dom/MediaKeys.h" // MediaKeys::kMediaKeysRequestTopic
#endif
#ifdef MOZ_WMF_CDM
# include "mozilla/MFCDMParent.h"
#endif
namespace mozilla::gmp {
#ifdef __CLASS__
@ -654,12 +650,6 @@ void GeckoMediaPluginServiceParent::UpdateContentProcessGMPCapabilities(
hasH264 = HAS_H264;
}
}
#ifdef MOZ_WMF_CDM
if (name.Equals("gmp-widevinecdm-l1")) {
nsCOMPtr<nsIFile> pluginFile = gmp->GetDirectory();
MFCDMService::UpdateWidevineL1Path(pluginFile);
}
#endif
caps.AppendElement(std::move(x));
}
}

View file

@ -27,10 +27,6 @@
#include "SpecialSystemDirectory.h" // For temp dir
#include "WMFUtils.h"
#ifdef MOZ_WMF_CDM_LPAC_SANDBOX
# include "sandboxBroker.h"
#endif
using Microsoft::WRL::ComPtr;
using Microsoft::WRL::MakeAndInitialize;
@ -440,7 +436,7 @@ LPCWSTR MFCDMParent::GetCDMLibraryName(const nsString& aKeySystem) {
}
if (IsWidevineExperimentKeySystemAndSupported(aKeySystem) ||
IsWidevineKeySystem(aKeySystem)) {
return sWidevineL1Path ? sWidevineL1Path : L"L1-not-found";
return sWidevineL1Path;
}
// TODO : support ClearKey
return L"Unknown";
@ -1103,8 +1099,7 @@ already_AddRefed<MFCDMProxy> MFCDMParent::GetMFCDMProxy() {
}
/* static */
void MFCDMService::GetAllKeySystemsCapabilities(dom::Promise* aPromise) {
MOZ_ASSERT(XRE_IsParentProcess());
void MFCDMCapabilities::GetAllKeySystemsCapabilities(dom::Promise* aPromise) {
const static auto kSandboxKind = ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM;
LaunchMFCDMProcessIfNeeded(kSandboxKind)
->Then(
@ -1124,9 +1119,8 @@ void MFCDMService::GetAllKeySystemsCapabilities(dom::Promise* aPromise) {
}
/* static */
RefPtr<GenericNonExclusivePromise> MFCDMService::LaunchMFCDMProcessIfNeeded(
ipc::SandboxingKind aSandbox) {
MOZ_ASSERT(XRE_IsParentProcess());
RefPtr<GenericNonExclusivePromise>
MFCDMCapabilities::LaunchMFCDMProcessIfNeeded(ipc::SandboxingKind aSandbox) {
MOZ_ASSERT(aSandbox == ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM);
RefPtr<ipc::UtilityProcessManager> utilityProc =
ipc::UtilityProcessManager::GetSingleton();
@ -1174,43 +1168,6 @@ RefPtr<GenericNonExclusivePromise> MFCDMService::LaunchMFCDMProcessIfNeeded(
});
}
/* static */
void MFCDMService::UpdateWidevineL1Path(nsIFile* aFile) {
RefPtr<ipc::UtilityProcessManager> utilityProc =
ipc::UtilityProcessManager::GetSingleton();
if (NS_WARN_IF(!utilityProc)) {
NS_WARNING("Failed to get UtilityProcessManager");
return;
}
// If the MFCDM process hasn't been created yet, then we will set the path
// when creating the process later.
const auto sandboxKind = ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM;
if (!utilityProc->Process(sandboxKind)) {
return;
}
// The MFCDM process has been started, we need to update its L1 path and set
// the permission for LPAC.
nsString widevineL1Path;
MOZ_ASSERT(aFile);
if (NS_WARN_IF(NS_FAILED(aFile->GetTarget(widevineL1Path)))) {
NS_WARNING("MFCDMService::UpdateWidevineL1Path, Failed to get L1 path!");
return;
}
RefPtr<ipc::UtilityAudioDecoderChild> uadc =
ipc::UtilityAudioDecoderChild::GetSingleton(sandboxKind);
if (NS_WARN_IF(!uadc)) {
NS_WARNING("Failed to get UtilityAudioDecoderChild");
return;
}
Unused << uadc->SendUpdateWidevineL1Path(widevineL1Path);
#ifdef MOZ_WMF_CDM_LPAC_SANDBOX
SandboxBroker::EnsureLpacPermsissionsOnDir(widevineL1Path);
#endif
}
#undef MFCDM_REJECT_IF_FAILED
#undef MFCDM_REJECT_IF
#undef MFCDM_RETURN_IF_FAILED

View file

@ -143,17 +143,11 @@ class MFCDMParent final : public PMFCDMParent {
MediaEventListener mExpirationListener;
};
// A helper class only used in the chrome process to handle CDM related tasks.
class MFCDMService {
// A helper class to display CDM capabilites in `about:support`.
class MFCDMCapabilities {
public:
// This is used to display CDM capabilites in `about:support`.
static void GetAllKeySystemsCapabilities(dom::Promise* aPromise);
// If Widevine L1 is downloaded after the MFCDM process is created, then we
// use this method to update the L1 path and setup L1 permission for the MFCDM
// process.
static void UpdateWidevineL1Path(nsIFile* aFile);
private:
static RefPtr<GenericNonExclusivePromise> LaunchMFCDMProcessIfNeeded(
ipc::SandboxingKind aSandbox);

View file

@ -5,4 +5,3 @@ skip-if = ["!wmfme"]
["test_eme_playready.html"]
["test_eme_wideinve_l1_installation.html"]

View file

@ -1,86 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test Widevine L1 installation</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>
<script type="text/javascript" src="eme.js"></script>
</head>
<body>
<script class="testbody" type="text/javascript">
// This test mostly follows the patten of test_eme_request_notifications.html.
var manager = new MediaTestManager;
function SetPrefs(prefs) {
return SpecialPowers.pushPrefEnv({"set": prefs});
}
function observe() {
return new Promise(function(resolve, reject) {
var observer = function(subject, topic, data) {
SpecialPowers.Services.obs.removeObserver(observer, "mediakeys-request");
resolve(JSON.parse(data).status);
};
SpecialPowers.Services.obs.addObserver(observer, "mediakeys-request");
});
}
function Test(test) {
var p = test.prefs ? SetPrefs(test.prefs) : Promise.resolve();
var name = "'" + test.keySystem + "'";
var res = observe().then((status) => {
is(status, test.expectedStatus, name + " expected status");
});
p.then(() => navigator.requestMediaKeySystemAccess(test.keySystem, gCencMediaKeySystemConfig))
.then((keySystemAccess) => keySystemAccess.createMediaKeys());
return res;
}
SimpleTest.waitForExplicitFinish();
const tests = [
// GMP L1 pref is disabled
{
keySystem: "com.widevine.alpha.experiment",
expectedStatus: 'cdm-disabled',
prefs: [
["media.eme.enabled", true],
["media.wmf.media-engine.enabled", 2],
["media.eme.widevine.experiment.enabled", true],
["media.gmp-widevinecdm-l1.enabled", false],
]
},
{
keySystem: "com.widevine.alpha.experiment2",
expectedStatus: 'cdm-disabled',
},
// Enable GMP L1 pref
{
keySystem: "com.widevine.alpha.experiment",
expectedStatus: 'cdm-not-installed',
prefs: [
["media.gmp-widevinecdm-l1.enabled", true],
]
},
{
keySystem: "com.widevine.alpha.experiment2",
expectedStatus: 'cdm-not-installed',
},
];
tests.reduce(function(p, c, i, array) {
return p.then(function() {
return Test(c);
});
}, Promise.resolve())
.then(SimpleTest.finish);
</script>
</body>
</html>

View file

@ -37,8 +37,6 @@ parent:
#ifdef MOZ_WMF_CDM
async GetKeySystemCapabilities() returns (MFCDMCapabilitiesIPDL[] result);
async UpdateWidevineL1Path(nsString path);
#endif
child:

View file

@ -194,12 +194,6 @@ IPCResult UtilityAudioDecoderParent::RecvGetKeySystemCapabilities(
});
return IPC_OK();
}
IPCResult UtilityAudioDecoderParent::RecvUpdateWidevineL1Path(
const nsString& aPath) {
MFCDMParent::SetWidevineL1Path(NS_ConvertUTF16toUTF8(aPath).get());
return IPC_OK();
}
#endif
} // namespace mozilla::ipc

View file

@ -48,8 +48,6 @@ class UtilityAudioDecoderParent final : public PUtilityAudioDecoderParent {
#ifdef MOZ_WMF_CDM
IPCResult RecvGetKeySystemCapabilities(
GetKeySystemCapabilitiesResolver&& aResolver);
IPCResult RecvUpdateWidevineL1Path(const nsString& aPath);
#endif
private:

View file

@ -378,33 +378,37 @@ void UtilityProcessHost::EnsureWidevineL1PathForSandbox(
return;
}
// If Widevine L1 is installed after the MFCDM process starts, we will set it
// path later via MFCDMService::UpdateWideivineL1Path().
nsString widevineL1Path;
nsCOMPtr<nsIFile> pluginFile;
if (NS_WARN_IF(NS_FAILED(gmps->FindPluginDirectoryForAPI(
nsCString(kWidevineExperimentAPIName),
{nsCString(kWidevineExperimentKeySystemName)},
getter_AddRefs(pluginFile))))) {
WMF_LOG("Widevine L1 is not installed yet");
return;
// TODO : install L1 if it's not downloaded yet, and the version change in bug
// 1863800.
static nsString sWidevineL1Path;
if (sWidevineL1Path.IsEmpty()) {
nsCOMPtr<nsIFile> pluginFile;
if (NS_WARN_IF(NS_FAILED(gmps->FindPluginDirectoryForAPI(
nsCString(kWidevineExperimentAPIName),
{nsCString(kWidevineExperimentKeySystemName)},
getter_AddRefs(pluginFile))))) {
WMF_LOG("Widevine L1 is not installed yet");
return;
}
if (!pluginFile) {
WMF_LOG("No plugin file found!");
return;
}
if (NS_WARN_IF(NS_FAILED(pluginFile->GetTarget(sWidevineL1Path)))) {
WMF_LOG("Failed to get L1 path!");
return;
}
MOZ_ASSERT(!sWidevineL1Path.IsEmpty());
WMF_LOG("Store Widevine L1 path=%s",
NS_ConvertUTF16toUTF8(sWidevineL1Path).get());
}
if (!pluginFile) {
WMF_LOG("No plugin file found!");
return;
}
if (NS_WARN_IF(NS_FAILED(pluginFile->GetTarget(widevineL1Path)))) {
WMF_LOG("Failed to get L1 path!");
return;
}
WMF_LOG("Set Widevine L1 path=%s",
NS_ConvertUTF16toUTF8(widevineL1Path).get());
geckoargs::sPluginPath.Put(NS_ConvertUTF16toUTF8(widevineL1Path).get(),
geckoargs::sPluginPath.Put(NS_ConvertUTF16toUTF8(sWidevineL1Path).get(),
aExtraOpts);
SandboxBroker::EnsureLpacPermsissionsOnDir(widevineL1Path);
SandboxBroker::EnsureLpacPermsissionsOnDir(sWidevineL1Path);
}
# undef WMF_LOG