Bug 1403804 - P1 - Remove PGMPDecryptor.ipdl and its related code from code base. r=cpearce

MozReview-Commit-ID: 4mxdcvnRl3W

--HG--
extra : rebase_source : 4c047fa94448bdde302f4b325f786f1d1b904388
This commit is contained in:
James Cheng 2017-09-28 11:40:30 +08:00
Родитель 2baa51b8c6
Коммит bd88dbe2fe
17 изменённых файлов: 8 добавлений и 1422 удалений

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

@ -9,7 +9,6 @@
#include "GMPLoader.h"
#include "GMPVideoDecoderChild.h"
#include "GMPVideoEncoderChild.h"
#include "GMPDecryptorChild.h"
#include "GMPVideoHost.h"
#include "nsDebugImpl.h"
#include "nsIFile.h"

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

@ -5,7 +5,6 @@
#include "GMPContentChild.h"
#include "GMPChild.h"
#include "GMPDecryptorChild.h"
#include "GMPVideoDecoderChild.h"
#include "GMPVideoEncoderChild.h"
#include "ChromiumCDMChild.h"
@ -50,21 +49,6 @@ GMPContentChild::ProcessingError(Result aCode, const char* aReason)
mGMPChild->ProcessingError(aCode, aReason);
}
PGMPDecryptorChild*
GMPContentChild::AllocPGMPDecryptorChild()
{
GMPDecryptorChild* actor = new GMPDecryptorChild(this);
actor->AddRef();
return actor;
}
bool
GMPContentChild::DeallocPGMPDecryptorChild(PGMPDecryptorChild* aActor)
{
static_cast<GMPDecryptorChild*>(aActor)->Release();
return true;
}
PGMPVideoDecoderChild*
GMPContentChild::AllocPGMPVideoDecoderChild(const uint32_t& aDecryptorId)
{
@ -110,22 +94,6 @@ GMPContentChild::DeallocPChromiumCDMChild(PChromiumCDMChild* aActor)
return true;
}
mozilla::ipc::IPCResult
GMPContentChild::RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor)
{
GMPDecryptorChild* child = static_cast<GMPDecryptorChild*>(aActor);
void* ptr = nullptr;
GMPErr err = mGMPChild->GetAPI(GMP_API_DECRYPTOR, nullptr, &ptr, child->DecryptorId());
if (err != GMPNoErr || !ptr) {
NS_WARNING("GMPGetAPI call failed trying to construct decryptor.");
return IPC_FAIL_NO_REASON(this);
}
child->Init(static_cast<GMPDecryptor*>(ptr));
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPContentChild::RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor,
const uint32_t& aDecryptorId)
@ -183,12 +151,6 @@ void
GMPContentChild::CloseActive()
{
// Invalidate and remove any remaining API objects.
const ManagedContainer<PGMPDecryptorChild>& decryptors =
ManagedPGMPDecryptorChild();
for (auto iter = decryptors.ConstIter(); !iter.Done(); iter.Next()) {
iter.Get()->GetKey()->SendShutdown();
}
const ManagedContainer<PGMPVideoDecoderChild>& videoDecoders =
ManagedPGMPVideoDecoderChild();
for (auto iter = videoDecoders.ConstIter(); !iter.Done(); iter.Next()) {
@ -210,8 +172,7 @@ GMPContentChild::CloseActive()
bool
GMPContentChild::IsUsed()
{
return !ManagedPGMPDecryptorChild().IsEmpty() ||
!ManagedPGMPVideoDecoderChild().IsEmpty() ||
return !ManagedPGMPVideoDecoderChild().IsEmpty() ||
!ManagedPGMPVideoEncoderChild().IsEmpty() ||
!ManagedPChromiumCDMChild().IsEmpty();
}

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

@ -23,15 +23,11 @@ public:
MessageLoop* GMPMessageLoop();
mozilla::ipc::IPCResult RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor) override;
mozilla::ipc::IPCResult RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor, const uint32_t& aDecryptorId) override;
mozilla::ipc::IPCResult RecvPGMPVideoEncoderConstructor(PGMPVideoEncoderChild* aActor) override;
mozilla::ipc::IPCResult RecvPChromiumCDMConstructor(
PChromiumCDMChild* aActor) override;
PGMPDecryptorChild* AllocPGMPDecryptorChild() override;
bool DeallocPGMPDecryptorChild(PGMPDecryptorChild* aActor) override;
PGMPVideoDecoderChild* AllocPGMPVideoDecoderChild(const uint32_t& aDecryptorId) override;
bool DeallocPGMPVideoDecoderChild(PGMPVideoDecoderChild* aActor) override;

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

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GMPContentParent.h"
#include "GMPDecryptorParent.h"
#include "GMPParent.h"
#include "GMPServiceChild.h"
#include "GMPVideoDecoderParent.h"
@ -67,8 +66,9 @@ private:
void
GMPContentParent::ActorDestroy(ActorDestroyReason aWhy)
{
MOZ_ASSERT(mDecryptors.IsEmpty() && mVideoDecoders.IsEmpty() &&
mVideoEncoders.IsEmpty() && mChromiumCDMs.IsEmpty());
MOZ_ASSERT(mVideoDecoders.IsEmpty() &&
mVideoEncoders.IsEmpty() &&
mChromiumCDMs.IsEmpty());
NS_DispatchToCurrentThread(new ReleaseGMPContentParent(this));
}
@ -107,15 +107,6 @@ GMPContentParent::VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder)
CloseIfUnused();
}
void
GMPContentParent::DecryptorDestroyed(GMPDecryptorParent* aSession)
{
MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread());
MOZ_ALWAYS_TRUE(mDecryptors.RemoveElement(aSession));
CloseIfUnused();
}
void
GMPContentParent::AddCloseBlocker()
{
@ -134,8 +125,9 @@ GMPContentParent::RemoveCloseBlocker()
void
GMPContentParent::CloseIfUnused()
{
if (mDecryptors.IsEmpty() && mVideoDecoders.IsEmpty() &&
mVideoEncoders.IsEmpty() && mChromiumCDMs.IsEmpty() &&
if (mVideoDecoders.IsEmpty() &&
mVideoEncoders.IsEmpty() &&
mChromiumCDMs.IsEmpty() &&
mCloseBlockerCount == 0) {
RefPtr<GMPContentParent> toClose;
if (mParent) {
@ -151,23 +143,6 @@ GMPContentParent::CloseIfUnused()
}
}
nsresult
GMPContentParent::GetGMPDecryptor(GMPDecryptorParent** aGMPDP)
{
PGMPDecryptorParent* pdp = SendPGMPDecryptorConstructor();
if (!pdp) {
return NS_ERROR_FAILURE;
}
GMPDecryptorParent* dp = static_cast<GMPDecryptorParent*>(pdp);
// This addref corresponds to the Proxy pointer the consumer is returned.
// It's dropped by calling Close() on the interface.
NS_ADDREF(dp);
mDecryptors.AppendElement(dp);
*aGMPDP = dp;
return NS_OK;
}
nsCOMPtr<nsISerialEventTarget>
GMPContentParent::GMPEventTarget()
{
@ -292,21 +267,5 @@ GMPContentParent::DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor)
return true;
}
PGMPDecryptorParent*
GMPContentParent::AllocPGMPDecryptorParent()
{
GMPDecryptorParent* ksp = new GMPDecryptorParent(this);
NS_ADDREF(ksp);
return ksp;
}
bool
GMPContentParent::DeallocPGMPDecryptorParent(PGMPDecryptorParent* aActor)
{
GMPDecryptorParent* ksp = static_cast<GMPDecryptorParent*>(aActor);
NS_RELEASE(ksp);
return true;
}
} // namespace gmp
} // namespace mozilla

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

@ -13,7 +13,6 @@
namespace mozilla {
namespace gmp {
class GMPDecryptorParent;
class GMPParent;
class GMPVideoDecoderParent;
class GMPVideoEncoderParent;
@ -34,9 +33,6 @@ public:
nsresult GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE);
void VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder);
nsresult GetGMPDecryptor(GMPDecryptorParent** aGMPKS);
void DecryptorDestroyed(GMPDecryptorParent* aSession);
already_AddRefed<ChromiumCDMParent> GetChromiumCDM();
void ChromiumCDMDestroyed(ChromiumCDMParent* aCDM);
@ -93,9 +89,6 @@ private:
PGMPVideoEncoderParent* AllocPGMPVideoEncoderParent() override;
bool DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor) override;
PGMPDecryptorParent* AllocPGMPDecryptorParent() override;
bool DeallocPGMPDecryptorParent(PGMPDecryptorParent* aActor) override;
PChromiumCDMParent* AllocPChromiumCDMParent() override;
bool DeallocPChromiumCDMParent(PChromiumCDMParent* aActor) override;
@ -109,7 +102,6 @@ private:
nsTArray<RefPtr<GMPVideoDecoderParent>> mVideoDecoders;
nsTArray<RefPtr<GMPVideoEncoderParent>> mVideoEncoders;
nsTArray<RefPtr<GMPDecryptorParent>> mDecryptors;
nsTArray<RefPtr<ChromiumCDMParent>> mChromiumCDMs;
nsCOMPtr<nsISerialEventTarget> mGMPEventTarget;
RefPtr<GMPParent> mParent;

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

@ -1,382 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "GMPDecryptorChild.h"
#include "GMPContentChild.h"
#include "GMPChild.h"
#include "base/task.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Unused.h"
#include "runnable_utils.h"
#include <ctime>
#define ON_GMP_THREAD() (mPlugin->GMPMessageLoop() == MessageLoop::current())
#define CALL_ON_GMP_THREAD(_func, ...) \
CallOnGMPThread(&GMPDecryptorChild::_func, __VA_ARGS__)
namespace mozilla {
namespace gmp {
static uint32_t sDecryptorCount = 1;
GMPDecryptorChild::GMPDecryptorChild(GMPContentChild* aPlugin)
: mSession(nullptr)
, mPlugin(aPlugin)
, mDecryptorId(sDecryptorCount++)
{
MOZ_ASSERT(mPlugin);
}
GMPDecryptorChild::~GMPDecryptorChild()
{
}
template <typename MethodType, typename... ParamType>
void
GMPDecryptorChild::CallMethod(MethodType aMethod, ParamType&&... aParams)
{
MOZ_ASSERT(ON_GMP_THREAD());
// Don't send IPC messages after tear-down.
if (mSession) {
(this->*aMethod)(Forward<ParamType>(aParams)...);
}
}
template<typename T>
struct AddConstReference {
typedef const typename RemoveReference<T>::Type& Type;
};
template<typename MethodType, typename... ParamType>
void
GMPDecryptorChild::CallOnGMPThread(MethodType aMethod, ParamType&&... aParams)
{
if (ON_GMP_THREAD()) {
// Use forwarding reference when we can.
CallMethod(aMethod, Forward<ParamType>(aParams)...);
} else {
// Use const reference when we have to.
auto m = &GMPDecryptorChild::CallMethod<
decltype(aMethod), typename AddConstReference<ParamType>::Type...>;
RefPtr<mozilla::Runnable> t =
dont_add_new_uses_of_this::NewRunnableMethod(this, m, aMethod, Forward<ParamType>(aParams)...);
mPlugin->GMPMessageLoop()->PostTask(t.forget());
}
}
void
GMPDecryptorChild::Init(GMPDecryptor* aSession)
{
MOZ_ASSERT(aSession);
mSession = aSession;
// The ID of this decryptor is the IPDL actor ID. Note it's unique inside
// the child process, but not necessarily across all gecko processes. However,
// since GMPDecryptors are segregated by node ID/origin, we shouldn't end up
// with clashes in the content process.
SendSetDecryptorId(DecryptorId());
}
void
GMPDecryptorChild::SetSessionId(uint32_t aCreateSessionToken,
const char* aSessionId,
uint32_t aSessionIdLength)
{
CALL_ON_GMP_THREAD(SendSetSessionId,
aCreateSessionToken, nsCString(aSessionId, aSessionIdLength));
}
void
GMPDecryptorChild::ResolveLoadSessionPromise(uint32_t aPromiseId,
bool aSuccess)
{
CALL_ON_GMP_THREAD(SendResolveLoadSessionPromise, aPromiseId, aSuccess);
}
void
GMPDecryptorChild::ResolvePromise(uint32_t aPromiseId)
{
CALL_ON_GMP_THREAD(SendResolvePromise, aPromiseId);
}
void
GMPDecryptorChild::RejectPromise(uint32_t aPromiseId,
GMPDOMException aException,
const char* aMessage,
uint32_t aMessageLength)
{
CALL_ON_GMP_THREAD(SendRejectPromise,
aPromiseId, aException, nsCString(aMessage, aMessageLength));
}
void
GMPDecryptorChild::SessionMessage(const char* aSessionId,
uint32_t aSessionIdLength,
GMPSessionMessageType aMessageType,
const uint8_t* aMessage,
uint32_t aMessageLength)
{
nsTArray<uint8_t> msg;
msg.AppendElements(aMessage, aMessageLength);
CALL_ON_GMP_THREAD(SendSessionMessage,
nsCString(aSessionId, aSessionIdLength),
aMessageType, Move(msg));
}
void
GMPDecryptorChild::ExpirationChange(const char* aSessionId,
uint32_t aSessionIdLength,
GMPTimestamp aExpiryTime)
{
CALL_ON_GMP_THREAD(SendExpirationChange,
nsCString(aSessionId, aSessionIdLength), aExpiryTime);
}
void
GMPDecryptorChild::SessionClosed(const char* aSessionId,
uint32_t aSessionIdLength)
{
CALL_ON_GMP_THREAD(SendSessionClosed,
nsCString(aSessionId, aSessionIdLength));
}
void
GMPDecryptorChild::SessionError(const char* aSessionId,
uint32_t aSessionIdLength,
GMPDOMException aException,
uint32_t aSystemCode,
const char* aMessage,
uint32_t aMessageLength)
{
CALL_ON_GMP_THREAD(SendSessionError,
nsCString(aSessionId, aSessionIdLength),
aException, aSystemCode,
nsCString(aMessage, aMessageLength));
}
void
GMPDecryptorChild::KeyStatusChanged(const char* aSessionId,
uint32_t aSessionIdLength,
const uint8_t* aKeyId,
uint32_t aKeyIdLength,
GMPMediaKeyStatus aStatus)
{
AutoTArray<uint8_t, 16> kid;
kid.AppendElements(aKeyId, aKeyIdLength);
nsTArray<GMPKeyInformation> keyInfos;
keyInfos.AppendElement(GMPKeyInformation(kid, aStatus));
CALL_ON_GMP_THREAD(SendBatchedKeyStatusChanged,
nsCString(aSessionId, aSessionIdLength),
keyInfos);
}
void
GMPDecryptorChild::BatchedKeyStatusChanged(const char* aSessionId,
uint32_t aSessionIdLength,
const GMPMediaKeyInfo* aKeyInfos,
uint32_t aKeyInfosLength)
{
nsTArray<GMPKeyInformation> keyInfos;
for (uint32_t i = 0; i < aKeyInfosLength; i++) {
nsTArray<uint8_t> keyId;
keyId.AppendElements(aKeyInfos[i].keyid, aKeyInfos[i].keyid_size);
keyInfos.AppendElement(GMPKeyInformation(keyId, aKeyInfos[i].status));
}
CALL_ON_GMP_THREAD(SendBatchedKeyStatusChanged,
nsCString(aSessionId, aSessionIdLength),
keyInfos);
}
void
GMPDecryptorChild::Decrypted(GMPBuffer* aBuffer, GMPErr aResult)
{
if (!ON_GMP_THREAD()) {
// We should run this whole method on the GMP thread since the buffer needs
// to be deleted after the SendDecrypted call.
mPlugin->GMPMessageLoop()->PostTask(
NewRunnableMethod<GMPBuffer*, GMPErr>("gmp::GMPDecryptorChild::Decrypted",
this,
&GMPDecryptorChild::Decrypted,
aBuffer,
aResult));
return;
}
if (!aBuffer) {
NS_WARNING("GMPDecryptorCallback passed bull GMPBuffer");
return;
}
auto buffer = static_cast<GMPBufferImpl*>(aBuffer);
if (mSession) {
SendDecrypted(buffer->mId, aResult, buffer->mData);
}
delete buffer;
}
void
GMPDecryptorChild::SetCapabilities(uint64_t aCaps)
{
// Deprecated.
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvInit(const bool& aDistinctiveIdentifierRequired,
const bool& aPersistentStateRequired)
{
if (!mSession) {
return IPC_FAIL_NO_REASON(this);
}
mSession->Init(this, aDistinctiveIdentifierRequired, aPersistentStateRequired);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvCreateSession(const uint32_t& aCreateSessionToken,
const uint32_t& aPromiseId,
const nsCString& aInitDataType,
InfallibleTArray<uint8_t>&& aInitData,
const GMPSessionType& aSessionType)
{
if (!mSession) {
return IPC_FAIL_NO_REASON(this);
}
mSession->CreateSession(aCreateSessionToken,
aPromiseId,
aInitDataType.get(),
aInitDataType.Length(),
aInitData.Elements(),
aInitData.Length(),
aSessionType);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvLoadSession(const uint32_t& aPromiseId,
const nsCString& aSessionId)
{
if (!mSession) {
return IPC_FAIL_NO_REASON(this);
}
mSession->LoadSession(aPromiseId,
aSessionId.get(),
aSessionId.Length());
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvUpdateSession(const uint32_t& aPromiseId,
const nsCString& aSessionId,
InfallibleTArray<uint8_t>&& aResponse)
{
if (!mSession) {
return IPC_FAIL_NO_REASON(this);
}
mSession->UpdateSession(aPromiseId,
aSessionId.get(),
aSessionId.Length(),
aResponse.Elements(),
aResponse.Length());
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvCloseSession(const uint32_t& aPromiseId,
const nsCString& aSessionId)
{
if (!mSession) {
return IPC_FAIL_NO_REASON(this);
}
mSession->CloseSession(aPromiseId,
aSessionId.get(),
aSessionId.Length());
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvRemoveSession(const uint32_t& aPromiseId,
const nsCString& aSessionId)
{
if (!mSession) {
return IPC_FAIL_NO_REASON(this);
}
mSession->RemoveSession(aPromiseId,
aSessionId.get(),
aSessionId.Length());
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvSetServerCertificate(const uint32_t& aPromiseId,
InfallibleTArray<uint8_t>&& aServerCert)
{
if (!mSession) {
return IPC_FAIL_NO_REASON(this);
}
mSession->SetServerCertificate(aPromiseId,
aServerCert.Elements(),
aServerCert.Length());
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvDecrypt(const uint32_t& aId,
InfallibleTArray<uint8_t>&& aBuffer,
const GMPDecryptionData& aMetadata)
{
if (!mSession) {
return IPC_FAIL_NO_REASON(this);
}
// Note: the GMPBufferImpl created here is deleted when the GMP passes
// it back in the Decrypted() callback above.
GMPBufferImpl* buffer = new GMPBufferImpl(aId, aBuffer);
// |metadata| lifetime is managed by |buffer|.
GMPEncryptedBufferDataImpl* metadata = new GMPEncryptedBufferDataImpl(aMetadata);
buffer->SetMetadata(metadata);
mSession->Decrypt(buffer, metadata);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorChild::RecvDecryptingComplete()
{
// Reset |mSession| before calling DecryptingComplete(). We should not send
// any IPC messages during tear-down.
auto session = mSession;
mSession = nullptr;
if (!session) {
return IPC_FAIL_NO_REASON(this);
}
session->DecryptingComplete();
Unused << Send__delete__(this);
return IPC_OK();
}
} // namespace gmp
} // namespace mozilla
// avoid redefined macro in unified build
#undef ON_GMP_THREAD
#undef CALL_ON_GMP_THREAD

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

@ -1,132 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef GMPDecryptorChild_h_
#define GMPDecryptorChild_h_
#include "mozilla/gmp/PGMPDecryptorChild.h"
#include "gmp-decryption.h"
#include "mozilla/gmp/GMPTypes.h"
#include "GMPEncryptedBufferDataImpl.h"
#include <string>
namespace mozilla {
namespace gmp {
class GMPContentChild;
class GMPDecryptorChild : public GMPDecryptorCallback
, public PGMPDecryptorChild
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPDecryptorChild);
explicit GMPDecryptorChild(GMPContentChild* aPlugin);
void Init(GMPDecryptor* aSession);
// GMPDecryptorCallback
void SetSessionId(uint32_t aCreateSessionToken,
const char* aSessionId,
uint32_t aSessionIdLength) override;
void ResolveLoadSessionPromise(uint32_t aPromiseId,
bool aSuccess) override;
void ResolvePromise(uint32_t aPromiseId) override;
void RejectPromise(uint32_t aPromiseId,
GMPDOMException aException,
const char* aMessage,
uint32_t aMessageLength) override;
void SessionMessage(const char* aSessionId,
uint32_t aSessionIdLength,
GMPSessionMessageType aMessageType,
const uint8_t* aMessage,
uint32_t aMessageLength) override;
void ExpirationChange(const char* aSessionId,
uint32_t aSessionIdLength,
GMPTimestamp aExpiryTime) override;
void SessionClosed(const char* aSessionId,
uint32_t aSessionIdLength) override;
void SessionError(const char* aSessionId,
uint32_t aSessionIdLength,
GMPDOMException aException,
uint32_t aSystemCode,
const char* aMessage,
uint32_t aMessageLength) override;
void KeyStatusChanged(const char* aSessionId,
uint32_t aSessionIdLength,
const uint8_t* aKeyId,
uint32_t aKeyIdLength,
GMPMediaKeyStatus aStatus) override;
void SetCapabilities(uint64_t aCaps) override;
void Decrypted(GMPBuffer* aBuffer, GMPErr aResult) override;
void BatchedKeyStatusChanged(const char* aSessionId,
uint32_t aSessionIdLength,
const GMPMediaKeyInfo* aKeyInfos,
uint32_t aKeyInfosLength) override;
uint32_t DecryptorId() const { return mDecryptorId; }
private:
~GMPDecryptorChild();
// GMPDecryptorChild
mozilla::ipc::IPCResult RecvInit(const bool& aDistinctiveIdentifierRequired,
const bool& aPersistentStateRequired) override;
mozilla::ipc::IPCResult RecvCreateSession(const uint32_t& aCreateSessionToken,
const uint32_t& aPromiseId,
const nsCString& aInitDataType,
InfallibleTArray<uint8_t>&& aInitData,
const GMPSessionType& aSessionType) override;
mozilla::ipc::IPCResult RecvLoadSession(const uint32_t& aPromiseId,
const nsCString& aSessionId) override;
mozilla::ipc::IPCResult RecvUpdateSession(const uint32_t& aPromiseId,
const nsCString& aSessionId,
InfallibleTArray<uint8_t>&& aResponse) override;
mozilla::ipc::IPCResult RecvCloseSession(const uint32_t& aPromiseId,
const nsCString& aSessionId) override;
mozilla::ipc::IPCResult RecvRemoveSession(const uint32_t& aPromiseId,
const nsCString& aSessionId) override;
mozilla::ipc::IPCResult RecvDecrypt(const uint32_t& aId,
InfallibleTArray<uint8_t>&& aBuffer,
const GMPDecryptionData& aMetadata) override;
// Resolve/reject promise on completion.
mozilla::ipc::IPCResult RecvSetServerCertificate(const uint32_t& aPromiseId,
InfallibleTArray<uint8_t>&& aServerCert) override;
mozilla::ipc::IPCResult RecvDecryptingComplete() override;
template <typename MethodType, typename... ParamType>
void CallMethod(MethodType, ParamType&&...);
template<typename MethodType, typename... ParamType>
void CallOnGMPThread(MethodType, ParamType&&...);
// GMP's GMPDecryptor implementation.
// Only call into this on the (GMP process) main thread.
GMPDecryptor* mSession;
GMPContentChild* mPlugin;
const uint32_t mDecryptorId;
};
} // namespace gmp
} // namespace mozilla
#endif // GMPDecryptorChild_h_

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

@ -1,509 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "GMPDecryptorParent.h"
#include "GMPContentParent.h"
#include "GMPUtils.h"
#include "MediaData.h"
#include "mozilla/Unused.h"
namespace mozilla {
#ifdef LOG
#undef LOG
#endif
extern LogModule* GetGMPLog();
#define LOGV(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Verbose, msg)
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
#define LOG(level, msg) MOZ_LOG(GetGMPLog(), (level), msg)
namespace gmp {
GMPDecryptorParent::GMPDecryptorParent(GMPContentParent* aPlugin)
: mIsOpen(false)
, mShuttingDown(false)
, mActorDestroyed(false)
, mPlugin(aPlugin)
, mPluginId(aPlugin->GetPluginId())
, mCallback(nullptr)
#ifdef DEBUG
, mGMPEventTarget(aPlugin->GMPEventTarget())
#endif
{
MOZ_ASSERT(mPlugin && mGMPEventTarget);
}
GMPDecryptorParent::~GMPDecryptorParent()
{
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvSetDecryptorId(const uint32_t& aId)
{
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->SetDecryptorId(aId);
return IPC_OK();
}
nsresult
GMPDecryptorParent::Init(GMPDecryptorProxyCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired)
{
LOGD(("GMPDecryptorParent[%p]::Init()", this));
if (mIsOpen) {
NS_WARNING("Trying to re-use an in-use GMP decrypter!");
return NS_ERROR_FAILURE;
}
mCallback = aCallback;
if (!SendInit(aDistinctiveIdentifierRequired, aPersistentStateRequired)) {
return NS_ERROR_FAILURE;
}
mIsOpen = true;
return NS_OK;
}
void
GMPDecryptorParent::CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,
const nsCString& aInitDataType,
const nsTArray<uint8_t>& aInitData,
GMPSessionType aSessionType)
{
LOGD(("GMPDecryptorParent[%p]::CreateSession(token=%u, promiseId=%u, aInitData='%s')",
this, aCreateSessionToken, aPromiseId, ToHexString(aInitData).get()));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return;
}
// Caller should ensure parameters passed in from JS are valid.
MOZ_ASSERT(!aInitDataType.IsEmpty() && !aInitData.IsEmpty());
Unused << SendCreateSession(aCreateSessionToken, aPromiseId, aInitDataType, aInitData, aSessionType);
}
void
GMPDecryptorParent::LoadSession(uint32_t aPromiseId,
const nsCString& aSessionId)
{
LOGD(("GMPDecryptorParent[%p]::LoadSession(sessionId='%s', promiseId=%u)",
this, aSessionId.get(), aPromiseId));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return;
}
// Caller should ensure parameters passed in from JS are valid.
MOZ_ASSERT(!aSessionId.IsEmpty());
Unused << SendLoadSession(aPromiseId, aSessionId);
}
void
GMPDecryptorParent::UpdateSession(uint32_t aPromiseId,
const nsCString& aSessionId,
const nsTArray<uint8_t>& aResponse)
{
LOGD(("GMPDecryptorParent[%p]::UpdateSession(sessionId='%s', promiseId=%u response='%s')",
this, aSessionId.get(), aPromiseId, ToHexString(aResponse).get()));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return;
}
// Caller should ensure parameters passed in from JS are valid.
MOZ_ASSERT(!aSessionId.IsEmpty() && !aResponse.IsEmpty());
Unused << SendUpdateSession(aPromiseId, aSessionId, aResponse);
}
void
GMPDecryptorParent::CloseSession(uint32_t aPromiseId,
const nsCString& aSessionId)
{
LOGD(("GMPDecryptorParent[%p]::CloseSession(sessionId='%s', promiseId=%u)",
this, aSessionId.get(), aPromiseId));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return;
}
// Caller should ensure parameters passed in from JS are valid.
MOZ_ASSERT(!aSessionId.IsEmpty());
Unused << SendCloseSession(aPromiseId, aSessionId);
}
void
GMPDecryptorParent::RemoveSession(uint32_t aPromiseId,
const nsCString& aSessionId)
{
LOGD(("GMPDecryptorParent[%p]::RemoveSession(sessionId='%s', promiseId=%u)",
this, aSessionId.get(), aPromiseId));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return;
}
// Caller should ensure parameters passed in from JS are valid.
MOZ_ASSERT(!aSessionId.IsEmpty());
Unused << SendRemoveSession(aPromiseId, aSessionId);
}
void
GMPDecryptorParent::SetServerCertificate(uint32_t aPromiseId,
const nsTArray<uint8_t>& aServerCert)
{
LOGD(("GMPDecryptorParent[%p]::SetServerCertificate(promiseId=%u)",
this, aPromiseId));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return;
}
// Caller should ensure parameters passed in from JS are valid.
MOZ_ASSERT(!aServerCert.IsEmpty());
Unused << SendSetServerCertificate(aPromiseId, aServerCert);
}
void
GMPDecryptorParent::Decrypt(uint32_t aId,
const CryptoSample& aCrypto,
const nsTArray<uint8_t>& aBuffer)
{
LOGV(("GMPDecryptorParent[%p]::Decrypt(id=%d)", this, aId));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return;
}
// Caller should ensure parameters passed in are valid.
MOZ_ASSERT(!aBuffer.IsEmpty());
if (aCrypto.mValid) {
GMPDecryptionData data(aCrypto.mKeyId,
aCrypto.mIV,
aCrypto.mPlainSizes,
aCrypto.mEncryptedSizes,
aCrypto.mSessionIds);
Unused << SendDecrypt(aId, aBuffer, data);
} else {
GMPDecryptionData data;
Unused << SendDecrypt(aId, aBuffer, data);
}
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvSetSessionId(const uint32_t& aCreateSessionId,
const nsCString& aSessionId)
{
LOGD(("GMPDecryptorParent[%p]::RecvSetSessionId(token=%u, sessionId='%s')",
this, aCreateSessionId, aSessionId.get()));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->SetSessionId(aCreateSessionId, aSessionId);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvResolveLoadSessionPromise(const uint32_t& aPromiseId,
const bool& aSuccess)
{
LOGD(("GMPDecryptorParent[%p]::RecvResolveLoadSessionPromise(promiseId=%u)",
this, aPromiseId));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->ResolveLoadSessionPromise(aPromiseId, aSuccess);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvResolvePromise(const uint32_t& aPromiseId)
{
LOGD(("GMPDecryptorParent[%p]::RecvResolvePromise(promiseId=%u)",
this, aPromiseId));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->ResolvePromise(aPromiseId);
return IPC_OK();
}
nsresult
GMPExToNsresult(GMPDOMException aDomException) {
switch (aDomException) {
case kGMPNoModificationAllowedError: return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
case kGMPNotFoundError: return NS_ERROR_DOM_NOT_FOUND_ERR;
case kGMPNotSupportedError: return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
case kGMPInvalidStateError: return NS_ERROR_DOM_INVALID_STATE_ERR;
case kGMPSyntaxError: return NS_ERROR_DOM_SYNTAX_ERR;
case kGMPInvalidModificationError: return NS_ERROR_DOM_INVALID_MODIFICATION_ERR;
case kGMPInvalidAccessError: return NS_ERROR_DOM_INVALID_ACCESS_ERR;
case kGMPSecurityError: return NS_ERROR_DOM_SECURITY_ERR;
case kGMPAbortError: return NS_ERROR_DOM_ABORT_ERR;
case kGMPQuotaExceededError: return NS_ERROR_DOM_QUOTA_EXCEEDED_ERR;
case kGMPTimeoutError: return NS_ERROR_DOM_TIMEOUT_ERR;
case kGMPTypeError: return NS_ERROR_DOM_TYPE_ERR;
default: return NS_ERROR_DOM_UNKNOWN_ERR;
}
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvRejectPromise(const uint32_t& aPromiseId,
const GMPDOMException& aException,
const nsCString& aMessage)
{
LOGD(("GMPDecryptorParent[%p]::RecvRejectPromise(promiseId=%u, exception=%d, msg='%s')",
this, aPromiseId, aException, aMessage.get()));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->RejectPromise(aPromiseId, GMPExToNsresult(aException), aMessage);
return IPC_OK();
}
static dom::MediaKeyMessageType
ToMediaKeyMessageType(GMPSessionMessageType aMessageType) {
switch (aMessageType) {
case kGMPLicenseRequest: return dom::MediaKeyMessageType::License_request;
case kGMPLicenseRenewal: return dom::MediaKeyMessageType::License_renewal;
case kGMPLicenseRelease: return dom::MediaKeyMessageType::License_release;
case kGMPIndividualizationRequest: return dom::MediaKeyMessageType::Individualization_request;
default: return dom::MediaKeyMessageType::License_request;
};
};
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvSessionMessage(const nsCString& aSessionId,
const GMPSessionMessageType& aMessageType,
nsTArray<uint8_t>&& aMessage)
{
LOGD(("GMPDecryptorParent[%p]::RecvSessionMessage(sessionId='%s', type=%d, msg='%s')",
this, aSessionId.get(), aMessageType, ToHexString(aMessage).get()));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->SessionMessage(aSessionId, ToMediaKeyMessageType(aMessageType), aMessage);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvExpirationChange(const nsCString& aSessionId,
const double& aExpiryTime)
{
LOGD(("GMPDecryptorParent[%p]::RecvExpirationChange(sessionId='%s', expiry=%lf)",
this, aSessionId.get(), aExpiryTime));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->ExpirationChange(aSessionId, aExpiryTime);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvSessionClosed(const nsCString& aSessionId)
{
LOGD(("GMPDecryptorParent[%p]::RecvSessionClosed(sessionId='%s')",
this, aSessionId.get()));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->SessionClosed(aSessionId);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvSessionError(const nsCString& aSessionId,
const GMPDOMException& aException,
const uint32_t& aSystemCode,
const nsCString& aMessage)
{
LOGD(("GMPDecryptorParent[%p]::RecvSessionError(sessionId='%s', exception=%d, sysCode=%d, msg='%s')",
this, aSessionId.get(),
aException, aSystemCode, aMessage.get()));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->SessionError(aSessionId,
GMPExToNsresult(aException),
aSystemCode,
aMessage);
return IPC_OK();
}
static dom::MediaKeyStatus
ToMediaKeyStatus(GMPMediaKeyStatus aStatus) {
switch (aStatus) {
case kGMPUsable: return dom::MediaKeyStatus::Usable;
case kGMPExpired: return dom::MediaKeyStatus::Expired;
case kGMPOutputDownscaled: return dom::MediaKeyStatus::Output_downscaled;
case kGMPOutputRestricted: return dom::MediaKeyStatus::Output_restricted;
case kGMPInternalError: return dom::MediaKeyStatus::Internal_error;
case kGMPReleased: return dom::MediaKeyStatus::Released;
case kGMPStatusPending: return dom::MediaKeyStatus::Status_pending;
default: return dom::MediaKeyStatus::Internal_error;
}
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvBatchedKeyStatusChanged(const nsCString& aSessionId,
InfallibleTArray<GMPKeyInformation>&& aKeyInfos)
{
LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(sessionId='%s', KeyInfos len='%zu')",
this, aSessionId.get(), aKeyInfos.Length()));
if (mIsOpen) {
nsTArray<CDMKeyInfo> cdmKeyInfos(aKeyInfos.Length());
for (uint32_t i = 0; i < aKeyInfos.Length(); i++) {
LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(keyId=%s, gmp-status=%d)",
this, ToHexString(aKeyInfos[i].keyId()).get(), aKeyInfos[i].status()));
// If the status is kGMPUnknown, we're going to forget(remove) that key info.
if (aKeyInfos[i].status() != kGMPUnknown) {
auto status = ToMediaKeyStatus(aKeyInfos[i].status());
cdmKeyInfos.AppendElement(CDMKeyInfo(aKeyInfos[i].keyId(),
dom::Optional<dom::MediaKeyStatus>(status)));
} else {
cdmKeyInfos.AppendElement(CDMKeyInfo(aKeyInfos[i].keyId()));
}
}
mCallback->BatchedKeyStatusChanged(aSessionId, cdmKeyInfos);
}
return IPC_OK();
}
DecryptStatus
ToDecryptStatus(GMPErr aError)
{
switch (aError) {
case GMPNoErr: return eme::Ok;
case GMPNoKeyErr: return eme::NoKeyErr;
case GMPAbortedErr: return eme::AbortedErr;
default: return eme::GenericErr;
}
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvDecrypted(const uint32_t& aId,
const GMPErr& aErr,
InfallibleTArray<uint8_t>&& aBuffer)
{
LOGV(("GMPDecryptorParent[%p]::RecvDecrypted(id=%d, err=%d)",
this, aId, aErr));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->Decrypted(aId, ToDecryptStatus(aErr), aBuffer);
return IPC_OK();
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvShutdown()
{
LOGD(("GMPDecryptorParent[%p]::RecvShutdown()", this));
Shutdown();
return IPC_OK();
}
// Note: may be called via Terminated()
void
GMPDecryptorParent::Close()
{
LOGD(("GMPDecryptorParent[%p]::Close()", this));
MOZ_ASSERT(mGMPEventTarget->IsOnCurrentThread());
// Consumer is done with us; we can shut down. No more callbacks should
// be made to mCallback. Note: do this before Shutdown()!
mCallback = nullptr;
// Let Shutdown mark us as dead so it knows if we had been alive
// In case this is the last reference
RefPtr<GMPDecryptorParent> kungfudeathgrip(this);
this->Release();
Shutdown();
}
void
GMPDecryptorParent::Shutdown()
{
LOGD(("GMPDecryptorParent[%p]::Shutdown()", this));
MOZ_ASSERT(mGMPEventTarget->IsOnCurrentThread());
if (mShuttingDown) {
return;
}
mShuttingDown = true;
// Notify client we're gone! Won't occur after Close()
if (mCallback) {
mCallback->Terminated();
mCallback = nullptr;
}
mIsOpen = false;
if (!mActorDestroyed) {
Unused << SendDecryptingComplete();
}
}
// Note: Keep this sync'd up with Shutdown
void
GMPDecryptorParent::ActorDestroy(ActorDestroyReason aWhy)
{
LOGD(("GMPDecryptorParent[%p]::ActorDestroy(reason=%d)", this, aWhy));
mIsOpen = false;
mActorDestroyed = true;
if (mCallback) {
// May call Close() (and Shutdown()) immediately or with a delay
mCallback->Terminated();
mCallback = nullptr;
}
if (mPlugin) {
mPlugin->DecryptorDestroyed(this);
mPlugin = nullptr;
}
MaybeDisconnect(aWhy == AbnormalShutdown);
}
mozilla::ipc::IPCResult
GMPDecryptorParent::Recv__delete__()
{
LOGD(("GMPDecryptorParent[%p]::Recv__delete__()", this));
if (mPlugin) {
mPlugin->DecryptorDestroyed(this);
mPlugin = nullptr;
}
return IPC_OK();
}
} // namespace gmp
} // namespace mozilla

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

@ -1,129 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef GMPDecryptorParent_h_
#define GMPDecryptorParent_h_
#include "mozilla/gmp/PGMPDecryptorParent.h"
#include "mozilla/RefPtr.h"
#include "gmp-decryption.h"
#include "GMPDecryptorProxy.h"
#include "GMPCrashHelperHolder.h"
namespace mozilla {
class CryptoSample;
namespace gmp {
class GMPContentParent;
class GMPDecryptorParent final : public GMPDecryptorProxy
, public PGMPDecryptorParent
, public GMPCrashHelperHolder
{
public:
NS_INLINE_DECL_REFCOUNTING(GMPDecryptorParent)
explicit GMPDecryptorParent(GMPContentParent *aPlugin);
// GMPDecryptorProxy
uint32_t GetPluginId() const override { return mPluginId; }
nsresult Init(GMPDecryptorProxyCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired) override;
void CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,
const nsCString& aInitDataType,
const nsTArray<uint8_t>& aInitData,
GMPSessionType aSessionType) override;
void LoadSession(uint32_t aPromiseId,
const nsCString& aSessionId) override;
void UpdateSession(uint32_t aPromiseId,
const nsCString& aSessionId,
const nsTArray<uint8_t>& aResponse) override;
void CloseSession(uint32_t aPromiseId,
const nsCString& aSessionId) override;
void RemoveSession(uint32_t aPromiseId,
const nsCString& aSessionId) override;
void SetServerCertificate(uint32_t aPromiseId,
const nsTArray<uint8_t>& aServerCert) override;
void Decrypt(uint32_t aId,
const CryptoSample& aCrypto,
const nsTArray<uint8_t>& aBuffer) override;
void Close() override;
void Shutdown();
private:
~GMPDecryptorParent();
// PGMPDecryptorParent
mozilla::ipc::IPCResult RecvSetDecryptorId(const uint32_t& aId) override;
mozilla::ipc::IPCResult RecvSetSessionId(const uint32_t& aCreateSessionToken,
const nsCString& aSessionId) override;
mozilla::ipc::IPCResult RecvResolveLoadSessionPromise(const uint32_t& aPromiseId,
const bool& aSuccess) override;
mozilla::ipc::IPCResult RecvResolvePromise(const uint32_t& aPromiseId) override;
mozilla::ipc::IPCResult RecvRejectPromise(const uint32_t& aPromiseId,
const GMPDOMException& aException,
const nsCString& aMessage) override;
mozilla::ipc::IPCResult RecvSessionMessage(const nsCString& aSessionId,
const GMPSessionMessageType& aMessageType,
nsTArray<uint8_t>&& aMessage) override;
mozilla::ipc::IPCResult RecvExpirationChange(const nsCString& aSessionId,
const double& aExpiryTime) override;
mozilla::ipc::IPCResult RecvSessionClosed(const nsCString& aSessionId) override;
mozilla::ipc::IPCResult RecvSessionError(const nsCString& aSessionId,
const GMPDOMException& aException,
const uint32_t& aSystemCode,
const nsCString& aMessage) override;
mozilla::ipc::IPCResult RecvDecrypted(const uint32_t& aId,
const GMPErr& aErr,
InfallibleTArray<uint8_t>&& aBuffer) override;
mozilla::ipc::IPCResult RecvBatchedKeyStatusChanged(const nsCString& aSessionId,
InfallibleTArray<GMPKeyInformation>&& aKeyInfos) override;
mozilla::ipc::IPCResult RecvShutdown() override;
void ActorDestroy(ActorDestroyReason aWhy) override;
mozilla::ipc::IPCResult Recv__delete__() override;
bool mIsOpen;
bool mShuttingDown;
bool mActorDestroyed;
RefPtr<GMPContentParent> mPlugin;
uint32_t mPluginId;
GMPDecryptorProxyCallback* mCallback;
#ifdef DEBUG
nsCOMPtr<nsISerialEventTarget> const mGMPEventTarget;
#endif
};
} // namespace gmp
} // namespace mozilla
#endif // GMPDecryptorChild_h_

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

@ -8,7 +8,6 @@
#include "GMPProcessParent.h"
#include "GMPServiceParent.h"
#include "GMPDecryptorParent.h"
#include "GMPVideoDecoderParent.h"
#include "GMPVideoEncoderParent.h"
#include "GMPTimerParent.h"

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

@ -21,7 +21,6 @@
#include "nsIXULAppInfo.h"
#include "nsIConsoleService.h"
#include "mozilla/Unused.h"
#include "GMPDecryptorParent.h"
#include "nsComponentManagerUtils.h"
#include "runnable_utils.h"
#include "VideoUtils.h"
@ -425,50 +424,6 @@ GeckoMediaPluginService::GetGMPVideoEncoder(GMPCrashHelper* aHelper,
return NS_OK;
}
NS_IMETHODIMP
GeckoMediaPluginService::GetGMPDecryptor(GMPCrashHelper* aHelper,
nsTArray<nsCString>* aTags,
const nsACString& aNodeId,
UniquePtr<GetGMPDecryptorCallback>&& aCallback)
{
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
if (!SandboxInfo::Get().CanSandboxMedia()) {
NS_WARNING("GeckoMediaPluginService::GetGMPDecryptor: "
"EME decryption not available without sandboxing support.");
return NS_ERROR_NOT_AVAILABLE;
}
#endif
MOZ_ASSERT(mGMPThread->EventTarget()->IsOnCurrentThread());
NS_ENSURE_ARG(aTags && aTags->Length() > 0);
NS_ENSURE_ARG(aCallback);
if (mShuttingDownOnGMPThread) {
return NS_ERROR_FAILURE;
}
GetGMPDecryptorCallback* rawCallback = aCallback.release();
RefPtr<AbstractThread> thread(GetAbstractGMPThread());
RefPtr<GMPCrashHelper> helper(aHelper);
GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_DECRYPTOR), *aTags)
->Then(thread, __func__,
[rawCallback, helper](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
RefPtr<GMPContentParent> parent = wrapper->mParent;
UniquePtr<GetGMPDecryptorCallback> callback(rawCallback);
GMPDecryptorParent* actor = nullptr;
if (parent && NS_SUCCEEDED(parent->GetGMPDecryptor(&actor))) {
actor->SetCrashHelper(helper);
}
callback->Done(actor);
},
[rawCallback] {
UniquePtr<GetGMPDecryptorCallback> callback(rawCallback);
callback->Done(nullptr);
});
return NS_OK;
}
void
GeckoMediaPluginService::ConnectCrashHelper(uint32_t aPluginId, GMPCrashHelper* aHelper)
{

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

@ -87,11 +87,6 @@ public:
const nsACString& aNodeId,
UniquePtr<GetGMPVideoEncoderCallback>&& aCallback)
override;
NS_IMETHOD GetGMPDecryptor(GMPCrashHelper* aHelper,
nsTArray<nsCString>* aTags,
const nsACString& aNodeId,
UniquePtr<GetGMPDecryptorCallback>&& aCallback)
override;
// Helper for backwards compatibility with WebRTC/tests.
NS_IMETHOD

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

@ -23,7 +23,6 @@
#include "nsNativeCharsetUtils.h"
#include "nsIConsoleService.h"
#include "mozilla/Unused.h"
#include "GMPDecryptorParent.h"
#include "nsComponentManagerUtils.h"
#include "runnable_utils.h"
#include "VideoUtils.h"
@ -1955,4 +1954,4 @@ GMPServiceParent::Create(Endpoint<PGMPServiceParent>&& aGMPService)
} // namespace gmp
} // namespace mozilla
#undef NS_DispatchToMainThread
#undef NS_DispatchToMainThread

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

@ -5,7 +5,6 @@
include protocol PGMPVideoDecoder;
include protocol PGMPVideoEncoder;
include protocol PGMPDecryptor;
include protocol PChromiumCDM;
namespace mozilla {
@ -13,13 +12,11 @@ namespace gmp {
intr protocol PGMPContent
{
manages PGMPDecryptor;
manages PGMPVideoDecoder;
manages PGMPVideoEncoder;
manages PChromiumCDM;
child:
async PGMPDecryptor();
async PGMPVideoDecoder(uint32_t aDecryptorId);
async PGMPVideoEncoder();
async PChromiumCDM();

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

@ -1,92 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
include protocol PGMPContent;
include GMPTypes;
using GMPSessionMessageType from "gmp-decryption.h";
using GMPSessionType from "gmp-decryption.h";
using GMPDOMException from "gmp-decryption.h";
using GMPErr from "gmp-errors.h";
namespace mozilla {
namespace gmp {
async protocol PGMPDecryptor
{
manager PGMPContent;
child:
async Init(bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired);
async CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,
nsCString aInitDataType,
uint8_t[] aInitData,
GMPSessionType aSessionType);
async LoadSession(uint32_t aPromiseId,
nsCString aSessionId);
async UpdateSession(uint32_t aPromiseId,
nsCString aSessionId,
uint8_t[] aResponse);
async CloseSession(uint32_t aPromiseId,
nsCString aSessionId);
async RemoveSession(uint32_t aPromiseId,
nsCString aSessionId);
async SetServerCertificate(uint32_t aPromiseId,
uint8_t[] aServerCert);
async Decrypt(uint32_t aId,
uint8_t[] aBuffer,
GMPDecryptionData aMetadata);
async DecryptingComplete();
parent:
async __delete__();
async SetDecryptorId(uint32_t aId);
async SetSessionId(uint32_t aCreateSessionToken,
nsCString aSessionId);
async ResolveLoadSessionPromise(uint32_t aPromiseId,
bool aSuccess);
async ResolvePromise(uint32_t aPromiseId);
async RejectPromise(uint32_t aPromiseId,
GMPDOMException aDOMExceptionCode,
nsCString aMessage);
async SessionMessage(nsCString aSessionId,
GMPSessionMessageType aMessageType,
uint8_t[] aMessage);
async ExpirationChange(nsCString aSessionId, double aExpiryTime);
async SessionClosed(nsCString aSessionId);
async SessionError(nsCString aSessionId,
GMPDOMException aDOMExceptionCode,
uint32_t aSystemCode,
nsCString aMessage);
async Decrypted(uint32_t aId, GMPErr aResult, uint8_t[] aBuffer);
async Shutdown();
async BatchedKeyStatusChanged(nsCString aSessionId,
GMPKeyInformation[] aKeyInfos);
};
} // namespace gmp
} // namespace mozilla

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

@ -36,8 +36,6 @@ EXPORTS += [
'GMPContentParent.h',
'GMPCrashHelper.h',
'GMPCrashHelperHolder.h',
'GMPDecryptorChild.h',
'GMPDecryptorParent.h',
'GMPDecryptorProxy.h',
'GMPEncryptedBufferDataImpl.h',
'GMPLoader.h',
@ -84,8 +82,6 @@ UNIFIED_SOURCES += [
'GMPContentParent.cpp',
'GMPCrashHelper.cpp',
'GMPCrashHelperHolder.cpp',
'GMPDecryptorChild.cpp',
'GMPDecryptorParent.cpp',
'GMPDiskStorage.cpp',
'GMPEncryptedBufferDataImpl.cpp',
'GMPLoader.cpp',
@ -122,7 +118,6 @@ IPDL_SOURCES += [
'PChromiumCDM.ipdl',
'PGMP.ipdl',
'PGMPContent.ipdl',
'PGMPDecryptor.ipdl',
'PGMPService.ipdl',
'PGMPStorage.ipdl',
'PGMPTimer.ipdl',

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

@ -123,23 +123,6 @@ interface mozIGeckoMediaPluginService : nsISupports
[optional] in ACString nodeId,
in GetGMPVideoEncoderCallback callback);
/**
* Returns a decryption session manager that supports the specified tags.
* The array of tags should at least contain a key system tag, and optionally
* other tags.
* Callable only on GMP thread.
* This is an asynchronous operation, the Done method of the callback object
* will be called on the GMP thread with the result (which might be null in
* the case of failure). This method always takes ownership of the callback
* object, but if this method returns an error then the Done method of the
* callback object will not be called at all.
*/
[noscript]
void getGMPDecryptor(in GMPCrashHelperPtr helper,
in TagArray tags,
in ACString nodeId,
in GetGMPDecryptorCallback callback);
/**
* Gets the NodeId for a (origin, urlbarOrigin) pair.
*/