summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--browser/app/profile/firefox.js19
-rw-r--r--browser/base/content/browser-media.js4
-rw-r--r--browser/base/jar.mn2
-rw-r--r--browser/components/preferences/in-content/content.js2
-rw-r--r--browser/components/preferences/in-content/content.xul4
-rw-r--r--browser/components/preferences/in-content/jar.mn2
-rw-r--r--browser/installer/package-manifest.in2
-rw-r--r--build/moz.configure/old.configure1
-rw-r--r--dom/base/Navigator.cpp8
-rw-r--r--dom/base/Navigator.h4
-rw-r--r--dom/base/nsDocument.cpp4
-rw-r--r--dom/base/nsDocument.h2
-rw-r--r--dom/canvas/CanvasRenderingContext2D.cpp2
-rw-r--r--dom/html/HTMLMediaElement.cpp43
-rw-r--r--dom/html/HTMLMediaElement.h10
-rw-r--r--dom/media/MediaDecoderOwner.h2
-rw-r--r--dom/media/MediaFormatReader.cpp12
-rw-r--r--dom/media/mediasource/TrackBuffersManager.cpp4
-rw-r--r--dom/media/webaudio/AudioContext.cpp2
-rw-r--r--dom/webidl/HTMLMediaElement.webidl2
-rw-r--r--dom/webidl/Navigator.webidl2
-rw-r--r--dom/webidl/moz.build2
-rw-r--r--layout/base/nsLayoutUtils.cpp2
-rw-r--r--mobile/android/app/mobile.js6
-rw-r--r--old-configure.in32
-rw-r--r--toolkit/moz.configure46
-rw-r--r--toolkit/toolkit.mozbuild6
27 files changed, 167 insertions, 60 deletions
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index b46d944e8..94615ded0 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1330,20 +1330,21 @@ pref("identity.fxaccounts.migrateToDevEdition", false);
pref("ui.key.menuAccessKeyFocuses", true);
#endif
+#ifdef MOZ_EME
// Encrypted media extensions.
-#ifdef XP_LINUX
-// On Linux EME is visible but disabled by default. This is so that the
-// "Play DRM content" checkbox in the Firefox UI is unchecked by default.
+// EME is visible but disabled by default. This is so that the
+// "Play DRM content" checkbox in the browser UI is unchecked by default.
// DRM requires downloading and installing proprietary binaries, which
-// users on an open source operating systems didn't opt into. The first
-// time a site using EME is encountered, the user will be prompted to
-// enable DRM, whereupon the EME plugin binaries will be downloaded if
-// permission is granted.
+// users didn't necessarily opt-in to by installing the browser.
+// The first time a site using EME is encountered, the user will be
+// prompted to enable DRM, whereupon the EME plugin binaries will be
+// downloaded if permission is granted.
pref("media.eme.enabled", false);
+pref("media.eme.apiVisible", true);
#else
-pref("media.eme.enabled", true);
+// Disable redundant interfaces
+pref("media.eme.apiVisible", false);
#endif
-pref("media.eme.apiVisible", true);
// Decode using Gecko Media Plugins in <video>, if a system decoder is not
// availble and the preferred GMP is available.
diff --git a/browser/base/content/browser-media.js b/browser/base/content/browser-media.js
index a013dbd8a..f721be74d 100644
--- a/browser/base/content/browser-media.js
+++ b/browser/base/content/browser-media.js
@@ -5,12 +5,16 @@
var gEMEHandler = {
get uiEnabled() {
+#ifdef MOZ_EME
let emeUIEnabled = Services.prefs.getBoolPref("browser.eme.ui.enabled");
// Force-disable on WinXP:
if (navigator.platform.toLowerCase().startsWith("win")) {
emeUIEnabled = emeUIEnabled && parseFloat(Services.sysinfo.get("version")) >= 6;
}
return emeUIEnabled;
+#else
+ return false;
+#endif
},
ensureEMEEnabled: function(browser, keySystem) {
Services.prefs.setBoolPref("media.eme.enabled", true);
diff --git a/browser/base/jar.mn b/browser/base/jar.mn
index 3fa5ea408..a65c77338 100644
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -80,7 +80,7 @@ browser.jar:
content/browser/browser-fullZoom.js (content/browser-fullZoom.js)
content/browser/browser-fxaccounts.js (content/browser-fxaccounts.js)
content/browser/browser-gestureSupport.js (content/browser-gestureSupport.js)
- content/browser/browser-media.js (content/browser-media.js)
+* content/browser/browser-media.js (content/browser-media.js)
content/browser/browser-places.js (content/browser-places.js)
content/browser/browser-plugins.js (content/browser-plugins.js)
content/browser/browser-refreshblocker.js (content/browser-refreshblocker.js)
diff --git a/browser/components/preferences/in-content/content.js b/browser/components/preferences/in-content/content.js
index 5ba334b02..a957b1dd5 100644
--- a/browser/components/preferences/in-content/content.js
+++ b/browser/components/preferences/in-content/content.js
@@ -78,6 +78,7 @@ var gContentPane = {
document.getElementById("notificationsPolicyLearnMore").setAttribute("href",
notificationInfoURL);
+#ifdef MOZ_EME
let drmInfoURL =
Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content";
document.getElementById("playDRMContentLink").setAttribute("href", drmInfoURL);
@@ -91,6 +92,7 @@ var gContentPane = {
// of the pane hiding/showing code potentially interfering:
document.getElementById("drmGroup").setAttribute("style", "display: none !important");
}
+#endif
},
// UTILITY FUNCTIONS
diff --git a/browser/components/preferences/in-content/content.xul b/browser/components/preferences/in-content/content.xul
index c646c16a2..9434cba62 100644
--- a/browser/components/preferences/in-content/content.xul
+++ b/browser/components/preferences/in-content/content.xul
@@ -6,10 +6,12 @@
<preferences id="contentPreferences" hidden="true" data-category="paneContent">
+#ifdef MOZ_EME
<!-- DRM content -->
<preference id="media.eme.enabled"
name="media.eme.enabled"
type="bool"/>
+#endif
<!-- Popups -->
<preference id="dom.disable_open_during_load"
@@ -40,6 +42,7 @@
<html:a class="help-button" target="_blank" aria-label="&helpButton.label;"></html:a>
</hbox>
+#ifdef MOZ_EME
<groupbox id="drmGroup" data-category="paneContent" hidden="true">
<caption><label>&drmContent.label;</label></caption>
<grid id="contentGrid2">
@@ -60,6 +63,7 @@
</rows>
</grid>
</groupbox>
+#endif
<groupbox id="notificationsGroup" data-category="paneContent" hidden="true">
<caption><label>&notificationsPolicy.label;</label></caption>
diff --git a/browser/components/preferences/in-content/jar.mn b/browser/components/preferences/in-content/jar.mn
index 52f536e96..3497ff555 100644
--- a/browser/components/preferences/in-content/jar.mn
+++ b/browser/components/preferences/in-content/jar.mn
@@ -12,7 +12,7 @@ browser.jar:
content/browser/preferences/in-content/containers.js
content/browser/preferences/in-content/advanced.js
content/browser/preferences/in-content/applications.js
- content/browser/preferences/in-content/content.js
+* content/browser/preferences/in-content/content.js
content/browser/preferences/in-content/sync.js
content/browser/preferences/in-content/security.js
content/browser/preferences/in-content/search.js
diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in
index c2269c069..dee6a3faa 100644
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -821,8 +821,10 @@ bin/libfreebl_32int64_3.so
; media
+#ifdef MOZ_EME
@RESPATH@/gmp-clearkey/0.1/@DLL_PREFIX@clearkey@DLL_SUFFIX@
@RESPATH@/gmp-clearkey/0.1/clearkey.info
+#endif
; gfx
#ifdef XP_WIN
diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure
index b33f18623..c9bdc9682 100644
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -175,6 +175,7 @@ def old_configure_options(*options):
'--enable-directshow',
'--enable-dtrace',
'--enable-dump-painting',
+ '--enable-eme',
'--enable-elf-hack',
'--enable-extensions',
'--enable-faststripe',
diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
index 8b20d0196..5c315517c 100644
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -97,8 +97,10 @@
#endif
#include "mozilla/dom/ContentChild.h"
+#ifdef MOZ_EME
#include "mozilla/EMEUtils.h"
#include "mozilla/DetailedPromise.h"
+#endif
namespace mozilla {
namespace dom {
@@ -214,7 +216,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorkerContainer)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
+#ifdef MOZ_EME
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeySystemAccessManager)
+#endif
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresentation)
#ifdef MOZ_GAMEPAD
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepadServiceTest)
@@ -288,10 +292,12 @@ Navigator::Invalidate()
mServiceWorkerContainer = nullptr;
+#ifdef MOZ_EME
if (mMediaKeySystemAccessManager) {
mMediaKeySystemAccessManager->Shutdown();
mMediaKeySystemAccessManager = nullptr;
}
+#endif
#ifdef MOZ_GAMEPAD
if (mGamepadServiceTest) {
@@ -1884,6 +1890,7 @@ Navigator::GetUserAgent(nsPIDOMWindowInner* aWindow, nsIURI* aURI,
return siteSpecificUA->GetUserAgentForURIAndWindow(aURI, aWindow, aUserAgent);
}
+#ifdef MOZ_EME
static nsCString
ToCString(const nsString& aString)
{
@@ -2009,6 +2016,7 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
mMediaKeySystemAccessManager->Request(promise, aKeySystem, aConfigs);
return promise.forget();
}
+#endif
Presentation*
Navigator::GetPresentation(ErrorResult& aRv)
diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h
index 4b4ae6759..d47a80bc1 100644
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -18,7 +18,9 @@
#include "nsString.h"
#include "nsTArray.h"
#include "nsWeakPtr.h"
+#ifdef MOZ_EME
#include "mozilla/dom/MediaKeySystemAccessManager.h"
+#endif
class nsPluginArray;
class nsMimeTypeArray;
@@ -258,12 +260,14 @@ public:
// any, else null.
static already_AddRefed<nsPIDOMWindowInner> GetWindowFromGlobal(JSObject* aGlobal);
+#ifdef MOZ_EME
already_AddRefed<Promise>
RequestMediaKeySystemAccess(const nsAString& aKeySystem,
const Sequence<MediaKeySystemConfiguration>& aConfig,
ErrorResult& aRv);
private:
RefPtr<MediaKeySystemAccessManager> mMediaKeySystemAccessManager;
+#endif
public:
void NotifyVRDisplaysUpdated();
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index 4926b6c0a..eaea49b02 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4340,6 +4340,7 @@ nsDocument::SetScopeObject(nsIGlobalObject* aGlobal)
}
}
+#ifdef MOZ_EME
static void
CheckIfContainsEMEContent(nsISupports* aSupports, void* aContainsEME)
{
@@ -4363,6 +4364,7 @@ nsDocument::ContainsEMEContent()
static_cast<void*>(&containsEME));
return containsEME;
}
+#endif // MOZ_EME
static void
CheckIfContainsMSEContent(nsISupports* aSupports, void* aContainsMSE)
@@ -8390,11 +8392,13 @@ nsDocument::CanSavePresentation(nsIRequest *aNewRequest)
}
#endif // MOZ_WEBRTC
+#ifdef MOZ_EME
// Don't save presentations for documents containing EME content, so that
// CDMs reliably shutdown upon user navigation.
if (ContainsEMEContent()) {
return false;
}
+#endif
// Don't save presentations for documents containing MSE content, to
// reduce memory usage.
diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
index fc6749c9f..3725b3c18 100644
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -1267,7 +1267,9 @@ public:
js::ExpandoAndGeneration mExpandoAndGeneration;
+#ifdef MOZ_EME
bool ContainsEMEContent();
+#endif
bool ContainsMSEContent();
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp
index b0a430fe4..35ea2cd1a 100644
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4977,10 +4977,12 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
return;
}
+#ifdef MOZ_EME
if (video->ContainsRestrictedContent()) {
aError.Throw(NS_ERROR_NOT_AVAILABLE);
return;
}
+#endif
uint16_t readyState;
if (NS_SUCCEEDED(video->GetReadyState(&readyState)) &&
diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp
index e81cd20bc..1f1a545fa 100644
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -11,7 +11,9 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/AsyncEventDispatcher.h"
+#ifdef MOZ_EME
#include "mozilla/dom/MediaEncryptedEvent.h"
+#endif
#include "base/basictypes.h"
#include "nsIDOMHTMLMediaElement.h"
@@ -820,7 +822,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTM
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTextTrackManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioTrackList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVideoTrackList)
+#ifdef MOZ_EME
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeys)
+#endif
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSelectedVideoStreamTrack)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@@ -845,7 +849,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTMLE
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTextTrackManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioTrackList)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mVideoTrackList)
+#ifdef MOZ_EME
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaKeys)
+#endif
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSelectedVideoStreamTrack)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@@ -1020,12 +1026,14 @@ void HTMLMediaElement::ShutdownDecoder()
void HTMLMediaElement::AbortExistingLoads()
{
+#ifdef MOZ_EME
// If there is no existing decoder then we don't have anything to
// report. This prevents reporting the initial load from an
// empty video element as a failed EME load.
if (mDecoder) {
ReportEMETelemetry();
}
+#endif
// Abort any already-running instance of the resource selection algorithm.
mLoadWaitStatus = NOT_WAITING;
@@ -1084,7 +1092,9 @@ void HTMLMediaElement::AbortExistingLoads()
mDownloadSuspendedByCache = false;
mMediaInfo = MediaInfo();
mIsEncrypted = false;
+#ifdef MOZ_EME
mPendingEncryptedInitData.mInitDatas.Clear();
+#endif
mWaitingForKey = NOT_WAITING_FOR_KEY;
mSourcePointer = nullptr;
@@ -2681,9 +2691,11 @@ HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded,
if (!window) {
return nullptr;
}
+#ifdef MOZ_EME
if (ContainsRestrictedContent()) {
return nullptr;
}
+#endif
if (!mOutputStreams.IsEmpty() &&
aGraph != mOutputStreams[0].mStream->GetInputStream()->Graph()) {
@@ -3638,6 +3650,7 @@ void HTMLMediaElement::HiddenVideoStop()
mVideoDecodeSuspendTimer = nullptr;
}
+#ifdef MOZ_EME
void
HTMLMediaElement::ReportEMETelemetry()
{
@@ -3649,6 +3662,7 @@ HTMLMediaElement::ReportEMETelemetry()
this, mLoadedDataFired ? "true" : "false"));
}
}
+#endif
void
HTMLMediaElement::ReportTelemetry()
@@ -3997,6 +4011,7 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
ms.mFinishWhenEnded);
}
+#ifdef MOZ_EME
if (mMediaKeys) {
if (mMediaKeys->GetCDMProxy()) {
mDecoder->SetCDMProxy(mMediaKeys->GetCDMProxy());
@@ -4006,6 +4021,7 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
return NS_ERROR_FAILURE;
}
}
+#endif
MediaEventSource<void>* waitingForKeyProducer = mDecoder->WaitingForKeyEvent();
// Not every decoder will produce waitingForKey events, only add ones that can
@@ -4468,7 +4484,11 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
SetMediaInfo(*aInfo);
- mIsEncrypted = aInfo->IsEncrypted() || mPendingEncryptedInitData.IsEncrypted();
+ mIsEncrypted = aInfo->IsEncrypted()
+#ifdef MOZ_EME
+ || mPendingEncryptedInitData.IsEncrypted()
+#endif
+ ;
mTags = aTags.forget();
mLoadedDataFired = false;
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
@@ -4494,11 +4514,13 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
return;
}
+#ifdef MOZ_EME
// Dispatch a distinct 'encrypted' event for each initData we have.
for (const auto& initData : mPendingEncryptedInitData.mInitDatas) {
DispatchEncrypted(initData.mInitData, initData.mType);
}
mPendingEncryptedInitData.mInitDatas.Clear();
+#endif
}
mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal);
@@ -5431,9 +5453,12 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE
UpdateAudioChannelPlayingState();
if (aPauseElement) {
ReportTelemetry();
+#ifdef MOZ_EME
ReportEMETelemetry();
+#endif
- // For EME content, force destruction of the CDM client (and CDM
+#ifdef MOZ_EME
+ // For EME content, we may force destruction of the CDM client (and CDM
// instance if this is the last client for that CDM instance) and
// the CDM's decoder. This ensures the CDM gets reliable and prompt
// shutdown notifications, as it may have book-keeping it needs
@@ -5445,6 +5470,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE
ShutdownDecoder();
}
}
+#endif
if (mDecoder) {
mDecoder->Pause();
mDecoder->Suspend();
@@ -5495,6 +5521,17 @@ void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
bool pauseElement = ShouldElementBePaused();
SuspendOrResumeElement(pauseElement, !IsActive());
+#ifdef MOZ_EME
+ // If the owning document has become inactive we should shutdown the CDM.
+ if (!OwnerDoc()->IsCurrentActiveDocument() && mMediaKeys) {
+ mMediaKeys->Shutdown();
+ mMediaKeys = nullptr;
+ if (mDecoder) {
+ ShutdownDecoder();
+ }
+ }
+#endif
+
AddRemoveSelfReference();
}
@@ -6270,6 +6307,7 @@ HTMLMediaElement::OnVisibilityChange(Visibility aNewVisibility)
}
+#ifdef MOZ_EME
MediaKeys*
HTMLMediaElement::GetMediaKeys() const
{
@@ -6479,6 +6517,7 @@ HTMLMediaElement::GetTopLevelPrincipal()
principal = doc->NodePrincipal();
return principal.forget();
}
+#endif //MOZ_EME
void
HTMLMediaElement::CannotDecryptWaitingForKey()
diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h
index d40e9df46..b65049206 100644
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -20,7 +20,9 @@
#include "mozilla/dom/TextTrackManager.h"
#include "mozilla/WeakPtr.h"
#include "MediaDecoder.h"
+#ifdef MOZ_EME
#include "mozilla/dom/MediaKeys.h"
+#endif
#include "mozilla/StateWatching.h"
#include "nsGkAtoms.h"
#include "PrincipalChangeObserver.h"
@@ -630,6 +632,7 @@ public:
// XPCOM MozPreservesPitch() is OK
+#ifdef MOZ_EME
MediaKeys* GetMediaKeys() const;
already_AddRefed<Promise> SetMediaKeys(MediaKeys* mediaKeys,
@@ -651,6 +654,7 @@ public:
already_AddRefed<nsIPrincipal> GetTopLevelPrincipal();
bool ContainsRestrictedContent();
+#endif // MOZ_EME
void CannotDecryptWaitingForKey();
@@ -1198,7 +1202,9 @@ protected:
*/
void HiddenVideoStop();
+#ifdef MOZ_EME
void ReportEMETelemetry();
+#endif
void ReportTelemetry();
@@ -1471,8 +1477,10 @@ protected:
// Timer used to simulate video-suspend.
nsCOMPtr<nsITimer> mVideoDecodeSuspendTimer;
+#ifdef MOZ_EME
// Encrypted Media Extension media keys.
RefPtr<MediaKeys> mMediaKeys;
+#endif
// Stores the time at the start of the current 'played' range.
double mCurrentPlayRangeStart;
@@ -1627,8 +1635,10 @@ protected:
// Listens for waitingForKey events from the owned decoder.
MediaEventListener mWaitingForKeyListener;
+#ifdef MOZ_EME
// Init Data that needs to be sent in 'encrypted' events in MetadataLoaded().
EncryptionInfo mPendingEncryptedInitData;
+#endif
// True if the media's channel's download has been suspended.
Watchable<bool> mDownloadSuspendedByCache;
diff --git a/dom/media/MediaDecoderOwner.h b/dom/media/MediaDecoderOwner.h
index f884686fb..f993b4324 100644
--- a/dom/media/MediaDecoderOwner.h
+++ b/dom/media/MediaDecoderOwner.h
@@ -143,11 +143,13 @@ public:
// reference to the decoder to prevent further calls into the decoder.
virtual void NotifyXPCOMShutdown() = 0;
+#ifdef MOZ_EME
// Dispatches a "encrypted" event to the HTMLMediaElement, with the
// provided init data. Actual dispatch may be delayed until HAVE_METADATA.
// Main thread only.
virtual void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType) = 0;
+#endif
};
} // namespace mozilla
diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp
index 2093803ad..06e8b963b 100644
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -346,8 +346,12 @@ MediaFormatReader::DecoderFactory::DoCreateDecoder(TrackType aTrack)
if (!mOwner->mPlatform) {
mOwner->mPlatform = new PDMFactory();
if (mOwner->IsEncrypted()) {
+#ifdef MOZ_EME
MOZ_ASSERT(mOwner->mCDMProxy);
mOwner->mPlatform->SetCDMProxy(mOwner->mCDMProxy);
+#else
+ return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, "EME not supported");
+#endif
}
}
@@ -577,6 +581,7 @@ MediaFormatReader::InitInternal()
return NS_OK;
}
+#ifdef MOZ_EME
class DispatchKeyNeededEvent : public Runnable {
public:
DispatchKeyNeededEvent(AbstractMediaDecoder* aDecoder,
@@ -602,6 +607,7 @@ private:
nsTArray<uint8_t> mInitData;
nsString mInitDataType;
};
+#endif
void
MediaFormatReader::SetCDMProxy(CDMProxy* aProxy)
@@ -618,7 +624,11 @@ MediaFormatReader::SetCDMProxy(CDMProxy* aProxy)
bool
MediaFormatReader::IsWaitingOnCDMResource() {
MOZ_ASSERT(OnTaskQueue());
+#ifdef MOZ_EME
return IsEncrypted() && !mCDMProxy;
+#else
+ return false;
+#endif
}
RefPtr<MediaDecoderReader::MetadataPromise>
@@ -725,11 +735,13 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
UniquePtr<EncryptionInfo> crypto = mDemuxer->GetCrypto();
if (mDecoder && crypto && crypto->IsEncrypted()) {
+#ifdef MOZ_EME
// Try and dispatch 'encrypted'. Won't go if ready state still HAVE_NOTHING.
for (uint32_t i = 0; i < crypto->mInitDatas.Length(); i++) {
NS_DispatchToMainThread(
new DispatchKeyNeededEvent(mDecoder, crypto->mInitDatas[i].mInitData, crypto->mInitDatas[i].mType));
}
+#endif
mInfo.mCrypto = *crypto;
}
diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp
index 4265aed81..ac6d82411 100644
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -58,6 +58,7 @@ AppendStateToStr(SourceBufferAttributes::AppendState aState)
static Atomic<uint32_t> sStreamSourceID(0u);
+#ifdef MOZ_EME
class DispatchKeyNeededEvent : public Runnable {
public:
DispatchKeyNeededEvent(AbstractMediaDecoder* aDecoder,
@@ -83,6 +84,7 @@ private:
nsTArray<uint8_t> mInitData;
nsString mInitDataType;
};
+#endif
TrackBuffersManager::TrackBuffersManager(MediaSourceDecoder* aParentDecoder,
const nsACString& aType)
@@ -1097,12 +1099,14 @@ TrackBuffersManager::OnDemuxerInitDone(nsresult)
UniquePtr<EncryptionInfo> crypto = mInputDemuxer->GetCrypto();
if (crypto && crypto->IsEncrypted()) {
+#ifdef MOZ_EME
// Try and dispatch 'encrypted'. Won't go if ready state still HAVE_NOTHING.
for (uint32_t i = 0; i < crypto->mInitDatas.Length(); i++) {
NS_DispatchToMainThread(
new DispatchKeyNeededEvent(mParentDecoder, crypto->mInitDatas[i].mInitData,
crypto->mInitDatas[i].mType));
}
+#endif
info.mCrypto = *crypto;
// We clear our crypto init data array, so the MediaFormatReader will
// not emit an encrypted event for the same init data again.
diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp
index f61226a48..a36eda621 100644
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -379,10 +379,12 @@ AudioContext::CreateMediaElementSource(HTMLMediaElement& aMediaElement,
return nullptr;
}
+#ifdef MOZ_EME
if (aMediaElement.ContainsRestrictedContent()) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
+#endif
if (CheckClosed(aRv)) {
return nullptr;
diff --git a/dom/webidl/HTMLMediaElement.webidl b/dom/webidl/HTMLMediaElement.webidl
index 456579ec1..313686dac 100644
--- a/dom/webidl/HTMLMediaElement.webidl
+++ b/dom/webidl/HTMLMediaElement.webidl
@@ -153,6 +153,7 @@ partial interface HTMLMediaElement {
attribute EventHandler onmozinterruptend;
};
+#ifdef MOZ_EME
// Encrypted Media Extensions
partial interface HTMLMediaElement {
[Pref="media.eme.apiVisible"]
@@ -168,6 +169,7 @@ partial interface HTMLMediaElement {
[Pref="media.eme.apiVisible"]
attribute EventHandler onwaitingforkey;
};
+#endif
// This is just for testing
partial interface HTMLMediaElement {
diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl
index 56461e429..5452f3247 100644
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -348,12 +348,14 @@ partial interface Navigator {
readonly attribute LegacyMozTCPSocket mozTCPSocket;
};
+#ifdef MOZ_EME
partial interface Navigator {
[Pref="media.eme.apiVisible", NewObject]
Promise<MediaKeySystemAccess>
requestMediaKeySystemAccess(DOMString keySystem,
sequence<MediaKeySystemConfiguration> supportedConfigurations);
};
+#endif
#ifdef NIGHTLY_BUILD
partial interface Navigator {
diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build
index f24c366e8..5dc637799 100644
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -9,6 +9,7 @@ GENERATED_WEBIDL_FILES = [
]
PREPROCESSED_WEBIDL_FILES = [
+ 'HTMLMediaElement.webidl',
'Navigator.webidl',
'Node.webidl',
'Promise.webidl',
@@ -210,7 +211,6 @@ WEBIDL_FILES = [
'HTMLLIElement.webidl',
'HTMLLinkElement.webidl',
'HTMLMapElement.webidl',
- 'HTMLMediaElement.webidl',
'HTMLMenuElement.webidl',
'HTMLMenuItemElement.webidl',
'HTMLMetaElement.webidl',
diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp
index ed34f39ce..789c91f50 100644
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -7242,9 +7242,11 @@ nsLayoutUtils::SurfaceFromElement(HTMLVideoElement* aElement,
(aSurfaceFlags & SFE_PREFER_NO_PREMULTIPLY_ALPHA) == 0,
"We can't support non-premultiplied alpha for video!");
+#ifdef MOZ_EME
if (aElement->ContainsRestrictedContent()) {
return result;
}
+#endif
uint16_t readyState;
if (NS_SUCCEEDED(aElement->GetReadyState(&readyState)) &&
diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js
index 2a64297c4..9a28bd716 100644
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -627,6 +627,12 @@ pref("media.mediasource.enabled", true);
pref("media.mediadrm-widevinecdm.visible", true);
+#ifdef MOZ_EME
+// Enable EME(Encrypted media extensions?)
+pref("media.eme.enabled", false);
+pref("media.eme.apiVisible", false);
+#endif
+
// optimize images memory usage
pref("image.downscale-during-decode.enabled", true);
diff --git a/old-configure.in b/old-configure.in
index f01f8fcb0..3cb499b93 100644
--- a/old-configure.in
+++ b/old-configure.in
@@ -3002,6 +3002,35 @@ if test x"$MOZ_WIDGET_TOOLKIT" = x"gonk" -a -n "$MOZ_FMP4" -a -n "$android_versi
fi
fi
+dnl ========================================================
+dnl = EME support
+dnl ========================================================
+
+MOZ_ARG_ENABLE_STRING(eme,
+[ --enable-eme[=widevine] Enable support for Encrypted Media Extensions ],
+ MOZ_EME_ARGS=$enableval)
+
+if test "$MOZ_EME_ARGS"; then
+ if test "$MOZ_EME_ARGS" = "no"; then
+ dnl EME explicitly disabled with --disable-eme
+ MOZ_EME=
+ elif test "$MOZ_EME_ARGS" = "yes"; then
+ dnl EME explicitly enabled with --enable-eme
+ MOZ_EME=1
+ else
+ dnl EME explicitly enabled with --enable-eme=<args>
+ MOZ_EME=1
+ MOZ_EME_MODULES=`echo $MOZ_EME_ARGS | sed -e 's/,/ /g'`
+ fi
+fi
+
+AC_SUBST_SET(MOZ_EME_MODULES)
+if test -n "$MOZ_EME"; then
+ if test -z "$MOZ_FMP4"; then
+ AC_MSG_ERROR([Encrypted Media Extension support requires Fragmented MP4 support])
+ fi
+ AC_DEFINE(MOZ_EME)
+fi
dnl ========================================================
dnl = Enable media plugin support
@@ -5634,7 +5663,8 @@ AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
AC_SUBST(MOZ_VORBIS)
AC_SUBST(MOZ_TREMOR)
AC_SUBST(MOZ_FFVPX)
-AC_SUBST_LIST(FFVPX_ASFLAGS)
+AC_SUBST_LIST(FFVPX_ASFLAGS)
+AC_SUBST(MOZ_EME)
AC_SUBST(MOZ_DIRECTSHOW)
AC_SUBST(MOZ_ANDROID_OMX)
AC_SUBST(MOZ_OMX_PLUGIN)
diff --git a/toolkit/moz.configure b/toolkit/moz.configure
index 85a01e658..4717af022 100644
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -405,50 +405,8 @@ set_config('MOZ_FMP4', fmp4)
set_define('MOZ_FMP4', fmp4)
add_old_configure_assignment('MOZ_FMP4', fmp4)
-# EME Support
-# ==============================================================
-# Widevine is enabled by default in desktop browser builds.
-@depends(build_project, '--help')
-def eme_default(build_project, help):
- if build_project == 'browser':
- return 'widevine'
-
-option('--enable-eme',
- nargs='*',
- choices=('adobe','widevine',),
- default=eme_default,
- help='Enable support for Encrypted Media Extensions')
-
-@depends('--enable-eme', target)
-def enable_eme(value, target):
- # Widevine EME by default enabled on desktop Windows, MacOS and Linux,
- # x86 and x64 builds.
- if (target.kernel in ('Darwin', 'WINNT', 'Linux') and
- target.os not in ('Android', 'iOS') and
- target.cpu in ('x86', 'x86_64')):
- return value
- elif value and value.origin != 'default':
- die('%s is not supported on %s' % (value.format('--enable-eme'), target.alias))
- # Return the same type of OptionValue (Positive or Negative), with an empty tuple.
- return value.__class__(())
-
-@depends(enable_eme, fmp4)
-def eme(value, fmp4):
- enabled = bool(value)
- if value.origin == 'default':
- enabled = enabled or fmp4
- if enabled and not fmp4:
- die('Encrypted Media Extension support requires '
- 'Fragmented MP4 support')
- if enabled:
- return True
-
-@depends(enable_eme)
-def eme_modules(value):
- return value
-
-set_config('MOZ_EME_MODULES', eme_modules)
-
+# Miscellaneous
+# ==============================================================
option(name='--enable-chrome-format',
help='Select FORMAT of chrome files during packaging.',
nargs=1,
diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild
index d94f1240a..7164a8ad5 100644
--- a/toolkit/toolkit.mozbuild
+++ b/toolkit/toolkit.mozbuild
@@ -167,9 +167,13 @@ if CONFIG['ENABLE_MARIONETTE'] or CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('gonk', '
DIRS += [
'/tools/quitter',
- '/media/gmp-clearkey/0.1',
]
+if CONFIG['MOZ_EME']:
+ DIRS += [
+ '/media/gmp-clearkey/0.1',
+ ]
+
if CONFIG['ENABLE_TESTS']:
DIRS += [
'/testing/mochitest',