Bug 1314530 Part3 - Instantiate MediaDrmCDMProxy if it is widevine on fennec. r=cpearce

MozReview-Commit-ID: AhNBaO5LPwe

--HG--
extra : rebase_source : bd481396058d28521b2cbbd0fca8296d32768a86
This commit is contained in:
James Cheng 2016-11-07 14:03:44 +08:00
Родитель d1f91996e4
Коммит 06a62c3bad
2 изменённых файлов: 30 добавлений и 5 удалений

Просмотреть файл

@ -15,6 +15,9 @@
#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"
@ -325,6 +328,28 @@ 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)
{
@ -334,11 +359,7 @@ MediaKeys::Init(ErrorResult& aRv)
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());

Просмотреть файл

@ -133,6 +133,10 @@ public:
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);