author | James Cheng <jacheng@mozilla.com> |
Mon, 07 Nov 2016 14:03:44 +0800 | |
changeset 366628 | 971aaa1646ed6eaa1ea4e0c678cad615e143c6d6 |
parent 366627 | 13f6bd96aa7805497d31ab9d9543232a31637a38 |
child 366629 | ab0995a0dc10eba235acf5ca1eb331a58bebdfa8 |
push id | 1369 |
push user | jlorenzo@mozilla.com |
push date | Mon, 27 Feb 2017 14:59:41 +0000 |
treeherder | mozilla-release@d75a1dba431f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | cpearce |
bugs | 1314530 |
milestone | 52.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/media/eme/MediaKeys.cpp | file | annotate | diff | comparison | revisions | |
dom/media/eme/MediaKeys.h | file | annotate | diff | comparison | revisions |
--- a/dom/media/eme/MediaKeys.cpp +++ b/dom/media/eme/MediaKeys.cpp @@ -10,16 +10,19 @@ #include "mozilla/dom/MediaKeysBinding.h" #include "mozilla/dom/MediaKeyMessageEvent.h" #include "mozilla/dom/MediaKeyError.h" #include "mozilla/dom/MediaKeySession.h" #include "mozilla/dom/DOMException.h" #include "mozilla/dom/UnionTypes.h" #include "mozilla/Telemetry.h" #include "GMPCDMProxy.h" +#ifdef MOZ_WIDGET_ANDROID +#include "mozilla/MediaDrmCDMProxy.h" +#endif #include "mozilla/EMEUtils.h" #include "nsContentUtils.h" #include "nsIScriptObjectPrincipal.h" #include "nsContentTypeParser.h" #ifdef MOZ_FMP4 #include "MP4Decoder.h" #endif #ifdef XP_WIN @@ -320,30 +323,48 @@ public: EME_LOG("MediaKeysGMPCrashHelper::GetPluginCrashedEventTarget()"); return (mMediaKeys && mMediaKeys->GetParentObject()) ? do_AddRef(mMediaKeys->GetParentObject()) : nullptr; } private: WeakPtr<MediaKeys> mMediaKeys; }; +already_AddRefed<CDMProxy> +MediaKeys::CreateCDMProxy() +{ + RefPtr<CDMProxy> proxy; +#ifdef MOZ_WIDGET_ANDROID + if (IsWidevineKeySystem(mKeySystem)) { + proxy = new MediaDrmCDMProxy(this, + mKeySystem, + mConfig.mDistinctiveIdentifier == MediaKeysRequirement::Required, + mConfig.mPersistentState == MediaKeysRequirement::Required); + } else +#endif + { + proxy = new GMPCDMProxy(this, + mKeySystem, + new MediaKeysGMPCrashHelper(this), + mConfig.mDistinctiveIdentifier == MediaKeysRequirement::Required, + mConfig.mPersistentState == MediaKeysRequirement::Required); + } + return proxy.forget(); +} + already_AddRefed<DetailedPromise> MediaKeys::Init(ErrorResult& aRv) { RefPtr<DetailedPromise> promise(MakePromise(aRv, NS_LITERAL_CSTRING("MediaKeys::Init()"))); if (aRv.Failed()) { return nullptr; } - mProxy = new GMPCDMProxy(this, - mKeySystem, - new MediaKeysGMPCrashHelper(this), - mConfig.mDistinctiveIdentifier == MediaKeysRequirement::Required, - mConfig.mPersistentState == MediaKeysRequirement::Required); + mProxy = CreateCDMProxy(); // Determine principal (at creation time) of the MediaKeys object. nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(GetParentObject()); if (!sop) { promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR, NS_LITERAL_CSTRING("Couldn't get script principal in MediaKeys::Init")); return promise.forget(); }
--- a/dom/media/eme/MediaKeys.h +++ b/dom/media/eme/MediaKeys.h @@ -128,16 +128,20 @@ public: // Shutdown which is called from the script/dom side. void Terminated(); // Returns true if this MediaKeys has been bound to a media element. bool IsBoundToMediaElement() const; private: + // Instantiate CDMProxy instance. + // It could be MediaDrmCDMProxy (Widevine on Fennec) or GMPCDMProxy (the rest). + already_AddRefed<CDMProxy> CreateCDMProxy(); + // Removes promise from mPromises, and returns it. already_AddRefed<DetailedPromise> RetrievePromise(PromiseId aId); // Owning ref to proxy. The proxy has a weak reference back to the MediaKeys, // and the MediaKeys destructor clears the proxy's reference to the MediaKeys. RefPtr<CDMProxy> mProxy; RefPtr<HTMLMediaElement> mElement;