Bug 1276132 - Remove use of #ifdef MOZ_{KEYSYSTEM}_EME in dom/media code. r=jwwang
Instead of controlling visibility of EME keysystems by build config, do it by
preference. This means keysystems can be turned on easier.
MozReview-Commit-ID: Ky1zrHPubOJ
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -273,61 +273,61 @@ MediaKeySystemAccess::GetKeySystemStatus
if (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
if (!Preferences::GetBool("media.eme.clearkey.enabled", true)) {
aOutMessage = NS_LITERAL_CSTRING("ClearKey was disabled");
return MediaKeySystemStatus::Cdm_disabled;
}
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
-#ifdef MOZ_ADOBE_EME
- if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
- if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
- aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
- return MediaKeySystemStatus::Cdm_disabled;
- }
+ if (Preferences::GetBool("media.gmp-eme-adobe.visible", false)) {
+ if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
+ if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
+ aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
+ return MediaKeySystemStatus::Cdm_disabled;
+ }
#ifdef XP_WIN
- // Win Vista and later only.
- if (!IsVistaOrLater()) {
- aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version (Vista) not met for Adobe EME");
- return MediaKeySystemStatus::Cdm_not_supported;
- }
+ // Win Vista and later only.
+ if (!IsVistaOrLater()) {
+ aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version (Vista) not met for Adobe EME");
+ return MediaKeySystemStatus::Cdm_not_supported;
+ }
#endif
#ifdef XP_MACOSX
- if (!nsCocoaFeatures::OnLionOrLater()) {
- aOutMessage = NS_LITERAL_CSTRING("Minimum MacOSX version (10.7) not met for Adobe EME");
- return MediaKeySystemStatus::Cdm_not_supported;
+ if (!nsCocoaFeatures::OnLionOrLater()) {
+ aOutMessage = NS_LITERAL_CSTRING("Minimum MacOSX version (10.7) not met for Adobe EME");
+ return MediaKeySystemStatus::Cdm_not_supported;
+ }
+#endif
+ return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
-#endif
- return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
-#endif
-#ifdef MOZ_WIDEVINE_EME
- if (aKeySystem.EqualsLiteral("com.widevine.alpha")) {
+ if (Preferences::GetBool("media.gmp-widevinecdm.visible", false)) {
+ if (aKeySystem.EqualsLiteral("com.widevine.alpha")) {
#ifdef XP_WIN
- // Win Vista and later only.
- if (!IsVistaOrLater()) {
- aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version (Vista) not met for Widevine EME");
- return MediaKeySystemStatus::Cdm_not_supported;
- }
+ // Win Vista and later only.
+ if (!IsVistaOrLater()) {
+ aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version (Vista) not met for Widevine EME");
+ return MediaKeySystemStatus::Cdm_not_supported;
+ }
#endif
#ifdef XP_MACOSX
- if (!nsCocoaFeatures::OnLionOrLater()) {
- aOutMessage = NS_LITERAL_CSTRING("Minimum MacOSX version (10.7) not met for Widevine EME");
- return MediaKeySystemStatus::Cdm_not_supported;
- }
+ if (!nsCocoaFeatures::OnLionOrLater()) {
+ aOutMessage = NS_LITERAL_CSTRING("Minimum MacOSX version (10.7) not met for Widevine EME");
+ return MediaKeySystemStatus::Cdm_not_supported;
+ }
#endif
- if (!Preferences::GetBool("media.gmp-widevinecdm.enabled", false)) {
- aOutMessage = NS_LITERAL_CSTRING("Widevine EME disabled");
- return MediaKeySystemStatus::Cdm_disabled;
+ if (!Preferences::GetBool("media.gmp-widevinecdm.enabled", false)) {
+ aOutMessage = NS_LITERAL_CSTRING("Widevine EME disabled");
+ return MediaKeySystemStatus::Cdm_disabled;
+ }
+ return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
- return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
-#endif
return MediaKeySystemStatus::Cdm_not_supported;
}
static bool
GMPDecryptsAndDecodesAAC(mozIGeckoMediaPluginService* aGMPS,
const nsAString& aKeySystem,
DecoderDoctorDiagnostics* aDiagnostics)
--- a/dom/media/eme/moz.build
+++ b/dom/media/eme/moz.build
@@ -1,17 +1,14 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-for cdm in CONFIG['MOZ_EME_MODULES']:
- DEFINES['MOZ_%s_EME' % cdm.upper()] = True
-
EXPORTS.mozilla.dom += [
'MediaEncryptedEvent.h',
'MediaKeyError.h',
'MediaKeyMessageEvent.h',
'MediaKeys.h',
'MediaKeySession.h',
'MediaKeyStatusMap.h',
'MediaKeySystemAccess.h',
--- a/dom/media/gmp/GMPChild.cpp
+++ b/dom/media/gmp/GMPChild.cpp
@@ -18,19 +18,17 @@
#include "gmp-video-decode.h"
#include "gmp-video-encode.h"
#include "GMPPlatform.h"
#include "mozilla/dom/CrashReporterChild.h"
#include "mozilla/ipc/ProcessChild.h"
#include "GMPUtils.h"
#include "prio.h"
#include "base/task.h"
-#ifdef MOZ_WIDEVINE_EME
#include "widevine-adapter/WidevineAdapter.h"
-#endif
using namespace mozilla::ipc;
using mozilla::dom::CrashReporterChild;
static const int MAX_VOUCHER_LENGTH = 500000;
#ifdef XP_WIN
#include <stdlib.h> // for _exit()
@@ -371,40 +369,30 @@ GMPChild::AnswerStartPlugin(const nsStri
mGMPLoader = GMPProcessChild::GetGMPLoader();
if (!mGMPLoader) {
NS_WARNING("Failed to get GMPLoader");
delete platformAPI;
return false;
}
-#ifdef MOZ_WIDEVINE_EME
bool isWidevine = aAdapter.EqualsLiteral("widevine");
-#endif
-
#if defined(MOZ_GMP_SANDBOX) && defined(XP_MACOSX)
MacSandboxPluginType pluginType = MacSandboxPluginType_GMPlugin_Default;
-#ifdef MOZ_WIDEVINE_EME
if (isWidevine) {
- pluginType = MacSandboxPluginType_GMPlugin_EME_Widevine;
+ pluginType = MacSandboxPluginType_GMPlugin_EME_Widevine;
}
-#endif
if (!SetMacSandboxInfo(pluginType)) {
NS_WARNING("Failed to set Mac GMP sandbox info");
delete platformAPI;
return false;
}
#endif
- GMPAdapter* adapter = nullptr;
-#ifdef MOZ_WIDEVINE_EME
- if (isWidevine) {
- adapter = new WidevineAdapter();
- }
-#endif
+ GMPAdapter* adapter = (isWidevine) ? new WidevineAdapter() : nullptr;
if (!mGMPLoader->Load(libPath.get(),
libPath.Length(),
mNodeId.BeginWriting(),
mNodeId.Length(),
platformAPI,
adapter)) {
NS_WARNING("Failed to load GMP");
delete platformAPI;
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -35,20 +35,18 @@ using CrashReporter::GetIDFromMinidump;
#endif
#include "mozilla/Telemetry.h"
#ifdef XP_WIN
#include "WMFDecoderModule.h"
#endif
-#ifdef MOZ_WIDEVINE_EME
#include "mozilla/dom/WidevineCDMManifestBinding.h"
#include "widevine-adapter/WidevineAdapter.h"
-#endif
namespace mozilla {
#undef LOG
#undef LOGD
extern LogModule* GetGMPLog();
#define LOG(level, x, ...) MOZ_LOG(GetGMPLog(), (level), (x, ##__VA_ARGS__))
@@ -804,28 +802,24 @@ GMPParent::ReadGMPMetaData()
return GenericPromise::CreateAndReject(rv, __func__);
}
infoFile->AppendRelativePath(mName + NS_LITERAL_STRING(".info"));
if (FileExists(infoFile)) {
return ReadGMPInfoFile(infoFile);
}
-#ifdef MOZ_WIDEVINE_EME
// Maybe this is the Widevine adapted plugin?
nsCOMPtr<nsIFile> manifestFile;
rv = mDirectory->Clone(getter_AddRefs(manifestFile));
if (NS_FAILED(rv)) {
return GenericPromise::CreateAndReject(rv, __func__);
}
manifestFile->AppendRelativePath(NS_LITERAL_STRING("manifest.json"));
return ReadChromiumManifestFile(manifestFile);
-#else
- return GenericPromise::CreateAndReject(rv, __func__);
-#endif
}
RefPtr<GenericPromise>
GMPParent::ReadGMPInfoFile(nsIFile* aFile)
{
GMPInfoFileParser parser;
if (!parser.Init(aFile)) {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
@@ -910,17 +904,16 @@ GMPParent::ReadGMPInfoFile(nsIFile* aFil
if (mCapabilities.IsEmpty()) {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
}
return GenericPromise::CreateAndResolve(true, __func__);
}
-#ifdef MOZ_WIDEVINE_EME
RefPtr<GenericPromise>
GMPParent::ReadChromiumManifestFile(nsIFile* aFile)
{
nsAutoCString json;
if (!ReadIntoString(aFile, json, 5 * 1024)) {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
}
@@ -963,17 +956,16 @@ GMPParent::ParseChromiumManifest(nsStrin
MOZ_ASSERT(mName.EqualsLiteral("widevinecdm"));
mAdapter = NS_LITERAL_STRING("widevine");
#ifdef XP_WIN
mLibs = NS_LITERAL_CSTRING("dxva2.dll");
#endif
return GenericPromise::CreateAndResolve(true, __func__);
}
-#endif
bool
GMPParent::CanBeSharedCrossNodeIds() const
{
return !mAsyncShutdownInProgress &&
mNodeId.IsEmpty() &&
// XXX bug 1159300 hack -- maybe remove after openh264 1.4
// We don't want to use CDM decoders for non-encrypted playback
--- a/dom/media/gmp/GMPParent.h
+++ b/dom/media/gmp/GMPParent.h
@@ -162,20 +162,18 @@ public:
private:
~GMPParent();
RefPtr<GeckoMediaPluginServiceParent> mService;
bool EnsureProcessLoaded();
RefPtr<GenericPromise> ReadGMPMetaData();
RefPtr<GenericPromise> ReadGMPInfoFile(nsIFile* aFile);
-#ifdef MOZ_WIDEVINE_EME
RefPtr<GenericPromise> ParseChromiumManifest(nsString aJSON); // Main thread.
RefPtr<GenericPromise> ReadChromiumManifestFile(nsIFile* aFile); // GMP thread.
-#endif
#ifdef MOZ_CRASHREPORTER
void WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes);
void GetCrashID(nsString& aResult);
#endif
void ActorDestroy(ActorDestroyReason aWhy) override;
PCrashReporterParent* AllocPCrashReporterParent(const NativeThreadId& aThread) override;
bool DeallocPCrashReporterParent(PCrashReporterParent* aCrashReporter) override;
--- a/dom/media/gmp/moz.build
+++ b/dom/media/gmp/moz.build
@@ -1,17 +1,14 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-for cdm in CONFIG['MOZ_EME_MODULES']:
- DEFINES['MOZ_%s_EME' % cdm.upper()] = True
-
XPIDL_MODULE = 'content_geckomediaplugins'
XPIDL_SOURCES += [
'mozIGeckoMediaPluginChromeService.idl',
'mozIGeckoMediaPluginService.idl',
]
EXPORTS += [
@@ -115,23 +112,19 @@ UNIFIED_SOURCES += [
'GMPVideoEncoderParent.cpp',
'GMPVideoHost.cpp',
'GMPVideoi420FrameImpl.cpp',
'GMPVideoPlaneImpl.cpp',
]
DIRS += [
'rlz',
+ 'widevine-adapter',
]
-if 'widevine' in CONFIG['MOZ_EME_MODULES']:
- DIRS += [
- 'widevine-adapter',
- ]
-
IPDL_SOURCES += [
'GMPTypes.ipdlh',
'PGMP.ipdl',
'PGMPAudioDecoder.ipdl',
'PGMPContent.ipdl',
'PGMPDecryptor.ipdl',
'PGMPService.ipdl',
'PGMPStorage.ipdl',