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; return nullptr;
} }
MOZ_ASSERT(domPromise); MOZ_ASSERT(domPromise);
MFCDMService::GetAllKeySystemsCapabilities(domPromise); MFCDMCapabilities::GetAllKeySystemsCapabilities(domPromise);
return domPromise.forget(); return domPromise.forget();
} }
#endif #endif

View file

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

View file

@ -93,11 +93,6 @@ void MFCDMCapabilitiesIPDLToKeySystemConfig(
bool DoesKeySystemSupportClearLead(const nsAString& aKeySystem); 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 } // namespace mozilla
#endif // EME_LOG_H_ #endif // EME_LOG_H_

View file

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

View file

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

View file

@ -22,7 +22,6 @@
#include "mozilla/dom/KeySystemNames.h" #include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/MediaKeySession.h" #include "mozilla/dom/MediaKeySession.h"
#include "mozilla/dom/MediaKeySystemAccessBinding.h" #include "mozilla/dom/MediaKeySystemAccessBinding.h"
#include "mozilla/dom/MediaKeySystemAccessManager.h"
#include "mozilla/dom/MediaSource.h" #include "mozilla/dom/MediaSource.h"
#include "nsDOMString.h" #include "nsDOMString.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
@ -40,9 +39,6 @@
namespace mozilla::dom { namespace mozilla::dom {
#define LOG(msg, ...) \
EME_LOG("MediaKeySystemAccess::%s " msg, __func__, ##__VA_ARGS__)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeySystemAccess, mParent) NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeySystemAccess, mParent)
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeySystemAccess) NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeySystemAccess)
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeySystemAccess) NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeySystemAccess)
@ -57,7 +53,7 @@ MediaKeySystemAccess::MediaKeySystemAccess(
nsPIDOMWindowInner* aParent, const nsAString& aKeySystem, nsPIDOMWindowInner* aParent, const nsAString& aKeySystem,
const MediaKeySystemConfiguration& aConfig) const MediaKeySystemConfiguration& aConfig)
: mParent(aParent), mKeySystem(aKeySystem), mConfig(aConfig) { : mParent(aParent), mKeySystem(aKeySystem), mConfig(aConfig) {
LOG("Created MediaKeySystemAccess for keysystem=%s config=%s", EME_LOG("Created MediaKeySystemAccess for keysystem=%s config=%s",
NS_ConvertUTF16toUTF8(mKeySystem).get(), NS_ConvertUTF16toUTF8(mKeySystem).get(),
mozilla::dom::ToCString(mConfig).get()); mozilla::dom::ToCString(mConfig).get());
} }
@ -88,78 +84,37 @@ already_AddRefed<Promise> MediaKeySystemAccess::CreateMediaKeys(
return keys->Init(aRv); return keys->Init(aRv);
} }
enum class SecureLevel {
Software,
Hardware,
};
static MediaKeySystemStatus EnsureCDMInstalled(const nsAString& aKeySystem, static MediaKeySystemStatus EnsureCDMInstalled(const nsAString& aKeySystem,
const SecureLevel aSecure,
nsACString& aOutMessage) { nsACString& aOutMessage) {
if (aSecure == SecureLevel::Software && if (!KeySystemConfig::Supports(aKeySystem)) {
!KeySystemConfig::Supports(aKeySystem)) {
aOutMessage = "CDM is not installed"_ns; aOutMessage = "CDM is not installed"_ns;
return MediaKeySystemStatus::Cdm_not_installed; 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; return MediaKeySystemStatus::Available;
} }
/* static */ /* static */
MediaKeySystemStatus MediaKeySystemAccess::GetKeySystemStatus( MediaKeySystemStatus MediaKeySystemAccess::GetKeySystemStatus(
const MediaKeySystemAccessRequest& aRequest, nsACString& aOutMessage) { const nsAString& aKeySystem, nsACString& aOutMessage) {
const nsString& keySystem = aRequest.mKeySystem;
MOZ_ASSERT(StaticPrefs::media_eme_enabled() || MOZ_ASSERT(StaticPrefs::media_eme_enabled() ||
IsClearkeyKeySystem(keySystem)); IsClearkeyKeySystem(aKeySystem));
LOG("checking if CDM is installed or disabled for %s", if (IsClearkeyKeySystem(aKeySystem)) {
NS_ConvertUTF16toUTF8(keySystem).get()); return EnsureCDMInstalled(aKeySystem, aOutMessage);
if (IsClearkeyKeySystem(keySystem)) {
return EnsureCDMInstalled(keySystem, SecureLevel::Software, aOutMessage);
} }
// This is used to determine if we need to download Widevine L1. if (IsWidevineKeySystem(aKeySystem)) {
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 (Preferences::GetBool("media.gmp-widevinecdm.visible", false)) { if (Preferences::GetBool("media.gmp-widevinecdm.visible", false)) {
if (!Preferences::GetBool("media.gmp-widevinecdm.enabled", false)) { if (!Preferences::GetBool("media.gmp-widevinecdm.enabled", false)) {
aOutMessage = "Widevine EME disabled"_ns; aOutMessage = "Widevine EME disabled"_ns;
return MediaKeySystemStatus::Cdm_disabled; return MediaKeySystemStatus::Cdm_disabled;
} }
return EnsureCDMInstalled(keySystem, SecureLevel::Software, aOutMessage); return EnsureCDMInstalled(aKeySystem, aOutMessage);
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID
} else if (Preferences::GetBool("media.mediadrm-widevinecdm.visible", } else if (Preferences::GetBool("media.mediadrm-widevinecdm.visible",
false)) { false)) {
nsCString keySystem = NS_ConvertUTF16toUTF8(aKeySystem);
bool supported = bool supported =
mozilla::java::MediaDrmProxy::IsSchemeSupported(keySystem); mozilla::java::MediaDrmProxy::IsSchemeSupported(keySystem);
if (!supported) { if (!supported) {
@ -173,25 +128,11 @@ MediaKeySystemStatus MediaKeySystemAccess::GetKeySystemStatus(
} }
#ifdef MOZ_WMF_CDM #ifdef MOZ_WMF_CDM
// Check PlayReady, which is a built-in CDM on most Windows versions. if ((IsPlayReadyKeySystemAndSupported(aKeySystem) ||
if (IsPlayReadyKeySystemAndSupported(keySystem) && IsWidevineExperimentKeySystemAndSupported(aKeySystem)) &&
KeySystemConfig::Supports(keySystem)) { KeySystemConfig::Supports(aKeySystem)) {
return MediaKeySystemStatus::Available; 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 #endif
return MediaKeySystemStatus::Cdm_not_supported; return MediaKeySystemStatus::Cdm_not_supported;
@ -1156,6 +1097,4 @@ nsCString MediaKeySystemAccess::ToCString(
return mozilla::dom::ToCString(aConfig); return mozilla::dom::ToCString(aConfig);
} }
#undef LOG
} // namespace mozilla::dom } // namespace mozilla::dom

View file

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

View file

@ -31,7 +31,7 @@ namespace mozilla::dom {
MediaKeySystemAccessManager::PendingRequest::PendingRequest( MediaKeySystemAccessManager::PendingRequest::PendingRequest(
DetailedPromise* aPromise, const nsAString& aKeySystem, DetailedPromise* aPromise, const nsAString& aKeySystem,
const Sequence<MediaKeySystemConfiguration>& aConfigs) const Sequence<MediaKeySystemConfiguration>& aConfigs)
: MediaKeySystemAccessRequest(aKeySystem, aConfigs), mPromise(aPromise) { : mPromise(aPromise), mKeySystem(aKeySystem), mConfigs(aConfigs) {
MOZ_COUNT_CTOR(MediaKeySystemAccessManager::PendingRequest); MOZ_COUNT_CTOR(MediaKeySystemAccessManager::PendingRequest);
} }
@ -405,7 +405,7 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
nsAutoCString message; nsAutoCString message;
MediaKeySystemStatus status = MediaKeySystemStatus status =
MediaKeySystemAccess::GetKeySystemStatus(*aRequest, message); MediaKeySystemAccess::GetKeySystemStatus(aRequest->mKeySystem, message);
nsPrintfCString msg( nsPrintfCString msg(
"MediaKeySystemAccess::GetKeySystemStatus(%s) " "MediaKeySystemAccess::GetKeySystemStatus(%s) "
@ -414,15 +414,10 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
nsCString(MediaKeySystemStatusValues::GetString(status)).get(), nsCString(MediaKeySystemStatusValues::GetString(status)).get(),
message.get()); message.get());
LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg)); 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 && if (status == MediaKeySystemStatus::Cdm_not_installed &&
(IsWidevineKeySystem(aRequest->mKeySystem) IsWidevineKeySystem(aRequest->mKeySystem)) {
#ifdef MOZ_WMF_CDM
|| IsWidevineExperimentKeySystemAndSupported(aRequest->mKeySystem)
#endif
)) {
// These are cases which could be resolved by downloading a new(er) CDM. // 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 // 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 // download or update the CDM. In AwaitInstall() we add listeners to wait
@ -444,25 +439,13 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
return; return;
} }
nsString keySystem = aRequest->mKeySystem; const 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
if (AwaitInstall(std::move(aRequest))) { if (AwaitInstall(std::move(aRequest))) {
// Notify chrome that we're going to wait for the CDM to download/update. // 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); MediaKeySystemAccess::NotifyObservers(mWindow, keySystem, status);
} else { } else {
// Failed to await the install. Log failure and give up trying to service // Failed to await the install. Log failure and give up trying to service
// this request. // this request.
EME_LOG("Failed to await %s for installation",
NS_ConvertUTF16toUTF8(keySystem).get());
diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(), keySystem, diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(), keySystem,
false, __func__); false, __func__);
} }
@ -472,8 +455,6 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
// Failed due to user disabling something, send a notification to // Failed due to user disabling something, send a notification to
// chrome, so we can show some UI to explain how the user can rectify // chrome, so we can show some UI to explain how the user can rectify
// the situation. // the situation.
EME_LOG("Notify CDM failure for %s and reject the promise",
NS_ConvertUTF16toUTF8(aRequest->mKeySystem).get());
MediaKeySystemAccess::NotifyObservers(mWindow, aRequest->mKeySystem, MediaKeySystemAccess::NotifyObservers(mWindow, aRequest->mKeySystem,
status); status);
aRequest->RejectPromiseWithNotSupportedError(message); aRequest->RejectPromiseWithNotSupportedError(message);
@ -616,7 +597,7 @@ nsresult MediaKeySystemAccessManager::Observe(nsISupports* aSubject,
for (size_t i = mPendingInstallRequests.Length(); i-- > 0;) { for (size_t i = mPendingInstallRequests.Length(); i-- > 0;) {
nsAutoCString message; nsAutoCString message;
MediaKeySystemStatus status = MediaKeySystemAccess::GetKeySystemStatus( MediaKeySystemStatus status = MediaKeySystemAccess::GetKeySystemStatus(
*mPendingInstallRequests[i], message); mPendingInstallRequests[i]->mKeySystem, message);
if (status == MediaKeySystemStatus::Cdm_not_installed) { if (status == MediaKeySystemStatus::Cdm_not_installed) {
// Not yet installed, don't retry. Keep waiting until timeout. // Not yet installed, don't retry. Keep waiting until timeout.
continue; 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 { class MediaKeySystemAccessManager final : public nsIObserver, public nsINamed {
public: public:
explicit MediaKeySystemAccessManager(nsPIDOMWindowInner* aWindow); explicit MediaKeySystemAccessManager(nsPIDOMWindowInner* aWindow);
@ -116,7 +104,7 @@ class MediaKeySystemAccessManager final : public nsIObserver, public nsINamed {
private: private:
// Encapsulates the information for a Navigator.requestMediaKeySystemAccess() // Encapsulates the information for a Navigator.requestMediaKeySystemAccess()
// request that is being processed. // request that is being processed.
struct PendingRequest : public MediaKeySystemAccessRequest { struct PendingRequest {
enum class RequestType { Initial, Subsequent }; enum class RequestType { Initial, Subsequent };
PendingRequest(DetailedPromise* aPromise, const nsAString& aKeySystem, PendingRequest(DetailedPromise* aPromise, const nsAString& aKeySystem,
@ -125,6 +113,10 @@ class MediaKeySystemAccessManager final : public nsIObserver, public nsINamed {
// The JS promise associated with this request. // The JS promise associated with this request.
RefPtr<DetailedPromise> mPromise; 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 // If the request is
// - A first attempt request from JS: RequestType::Initial. // - A first attempt request from JS: RequestType::Initial.

View file

@ -52,10 +52,6 @@
# include "mozilla/dom/MediaKeys.h" // MediaKeys::kMediaKeysRequestTopic # include "mozilla/dom/MediaKeys.h" // MediaKeys::kMediaKeysRequestTopic
#endif #endif
#ifdef MOZ_WMF_CDM
# include "mozilla/MFCDMParent.h"
#endif
namespace mozilla::gmp { namespace mozilla::gmp {
#ifdef __CLASS__ #ifdef __CLASS__
@ -654,12 +650,6 @@ void GeckoMediaPluginServiceParent::UpdateContentProcessGMPCapabilities(
hasH264 = HAS_H264; 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)); caps.AppendElement(std::move(x));
} }
} }

View file

@ -27,10 +27,6 @@
#include "SpecialSystemDirectory.h" // For temp dir #include "SpecialSystemDirectory.h" // For temp dir
#include "WMFUtils.h" #include "WMFUtils.h"
#ifdef MOZ_WMF_CDM_LPAC_SANDBOX
# include "sandboxBroker.h"
#endif
using Microsoft::WRL::ComPtr; using Microsoft::WRL::ComPtr;
using Microsoft::WRL::MakeAndInitialize; using Microsoft::WRL::MakeAndInitialize;
@ -440,7 +436,7 @@ LPCWSTR MFCDMParent::GetCDMLibraryName(const nsString& aKeySystem) {
} }
if (IsWidevineExperimentKeySystemAndSupported(aKeySystem) || if (IsWidevineExperimentKeySystemAndSupported(aKeySystem) ||
IsWidevineKeySystem(aKeySystem)) { IsWidevineKeySystem(aKeySystem)) {
return sWidevineL1Path ? sWidevineL1Path : L"L1-not-found"; return sWidevineL1Path;
} }
// TODO : support ClearKey // TODO : support ClearKey
return L"Unknown"; return L"Unknown";
@ -1103,8 +1099,7 @@ already_AddRefed<MFCDMProxy> MFCDMParent::GetMFCDMProxy() {
} }
/* static */ /* static */
void MFCDMService::GetAllKeySystemsCapabilities(dom::Promise* aPromise) { void MFCDMCapabilities::GetAllKeySystemsCapabilities(dom::Promise* aPromise) {
MOZ_ASSERT(XRE_IsParentProcess());
const static auto kSandboxKind = ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM; const static auto kSandboxKind = ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM;
LaunchMFCDMProcessIfNeeded(kSandboxKind) LaunchMFCDMProcessIfNeeded(kSandboxKind)
->Then( ->Then(
@ -1124,9 +1119,8 @@ void MFCDMService::GetAllKeySystemsCapabilities(dom::Promise* aPromise) {
} }
/* static */ /* static */
RefPtr<GenericNonExclusivePromise> MFCDMService::LaunchMFCDMProcessIfNeeded( RefPtr<GenericNonExclusivePromise>
ipc::SandboxingKind aSandbox) { MFCDMCapabilities::LaunchMFCDMProcessIfNeeded(ipc::SandboxingKind aSandbox) {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(aSandbox == ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM); MOZ_ASSERT(aSandbox == ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM);
RefPtr<ipc::UtilityProcessManager> utilityProc = RefPtr<ipc::UtilityProcessManager> utilityProc =
ipc::UtilityProcessManager::GetSingleton(); 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_FAILED
#undef MFCDM_REJECT_IF #undef MFCDM_REJECT_IF
#undef MFCDM_RETURN_IF_FAILED #undef MFCDM_RETURN_IF_FAILED

View file

@ -143,17 +143,11 @@ class MFCDMParent final : public PMFCDMParent {
MediaEventListener mExpirationListener; MediaEventListener mExpirationListener;
}; };
// A helper class only used in the chrome process to handle CDM related tasks. // A helper class to display CDM capabilites in `about:support`.
class MFCDMService { class MFCDMCapabilities {
public: public:
// This is used to display CDM capabilites in `about:support`.
static void GetAllKeySystemsCapabilities(dom::Promise* aPromise); 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: private:
static RefPtr<GenericNonExclusivePromise> LaunchMFCDMProcessIfNeeded( static RefPtr<GenericNonExclusivePromise> LaunchMFCDMProcessIfNeeded(
ipc::SandboxingKind aSandbox); ipc::SandboxingKind aSandbox);

View file

@ -5,4 +5,3 @@ skip-if = ["!wmfme"]
["test_eme_playready.html"] ["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 #ifdef MOZ_WMF_CDM
async GetKeySystemCapabilities() returns (MFCDMCapabilitiesIPDL[] result); async GetKeySystemCapabilities() returns (MFCDMCapabilitiesIPDL[] result);
async UpdateWidevineL1Path(nsString path);
#endif #endif
child: child:

View file

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

View file

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

View file

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