Bug 1314530 Part3 - Instantiate MediaDrmCDMProxy if it is widevine on fennec.
MozReview-Commit-ID: AhNBaO5LPwe
--- 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;