--- a/dom/media/gmp/GMPChild.cpp
+++ b/dom/media/gmp/GMPChild.cpp
@@ -4,17 +4,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GMPChild.h"
#include "GMPContentChild.h"
#include "GMPProcessChild.h"
#include "GMPLoader.h"
#include "GMPVideoDecoderChild.h"
#include "GMPVideoEncoderChild.h"
-#include "GMPDecryptorChild.h"
#include "GMPVideoHost.h"
#include "nsDebugImpl.h"
#include "nsIFile.h"
#include "nsXULAppAPI.h"
#include "gmp-video-decode.h"
#include "gmp-video-encode.h"
#include "GMPPlatform.h"
#include "mozilla/ipc/CrashReporterClient.h"
--- a/dom/media/gmp/GMPContentChild.cpp
+++ b/dom/media/gmp/GMPContentChild.cpp
@@ -1,16 +1,15 @@
/* -*- 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 "GMPContentChild.h"
#include "GMPChild.h"
-#include "GMPDecryptorChild.h"
#include "GMPVideoDecoderChild.h"
#include "GMPVideoEncoderChild.h"
#include "ChromiumCDMChild.h"
#include "base/task.h"
#include "GMPUtils.h"
namespace mozilla {
namespace gmp {
@@ -45,31 +44,16 @@ GMPContentChild::ActorDestroy(ActorDestr
}
void
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)
{
GMPVideoDecoderChild* actor = new GMPVideoDecoderChild(this);
actor->AddRef();
return actor;
}
@@ -106,32 +90,16 @@ GMPContentChild::AllocPChromiumCDMChild(
bool
GMPContentChild::DeallocPChromiumCDMChild(PChromiumCDMChild* aActor)
{
static_cast<ChromiumCDMChild*>(aActor)->Release();
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)
{
auto vdc = static_cast<GMPVideoDecoderChild*>(aActor);
void* vd = nullptr;
GMPErr err = mGMPChild->GetAPI(GMP_API_VIDEO_DECODER, &vdc->Host(), &vd, aDecryptorId);
if (err != GMPNoErr || !vd) {
@@ -178,22 +146,16 @@ GMPContentChild::RecvPChromiumCDMConstru
return IPC_OK();
}
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()) {
iter.Get()->GetKey()->SendShutdown();
}
const ManagedContainer<PGMPVideoEncoderChild>& videoEncoders =
ManagedPGMPVideoEncoderChild();
@@ -205,16 +167,15 @@ GMPContentChild::CloseActive()
for (auto iter = cdms.ConstIter(); !iter.Done(); iter.Next()) {
iter.Get()->GetKey()->SendShutdown();
}
}
bool
GMPContentChild::IsUsed()
{
- return !ManagedPGMPDecryptorChild().IsEmpty() ||
- !ManagedPGMPVideoDecoderChild().IsEmpty() ||
+ return !ManagedPGMPVideoDecoderChild().IsEmpty() ||
!ManagedPGMPVideoEncoderChild().IsEmpty() ||
!ManagedPChromiumCDMChild().IsEmpty();
}
} // namespace gmp
} // namespace mozilla
--- a/dom/media/gmp/GMPContentChild.h
+++ b/dom/media/gmp/GMPContentChild.h
@@ -18,25 +18,21 @@ class GMPContentChild : public PGMPConte
, public GMPSharedMem
{
public:
explicit GMPContentChild(GMPChild* aChild);
virtual ~GMPContentChild();
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;
PGMPVideoEncoderChild* AllocPGMPVideoEncoderChild() override;
bool DeallocPGMPVideoEncoderChild(PGMPVideoEncoderChild* aActor) override;
PChromiumCDMChild* AllocPChromiumCDMChild() override;
bool DeallocPChromiumCDMChild(PChromiumCDMChild* aActor) override;
--- a/dom/media/gmp/GMPContentParent.cpp
+++ b/dom/media/gmp/GMPContentParent.cpp
@@ -1,15 +1,14 @@
/* -*- 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 "GMPContentParent.h"
-#include "GMPDecryptorParent.h"
#include "GMPParent.h"
#include "GMPServiceChild.h"
#include "GMPVideoDecoderParent.h"
#include "GMPVideoEncoderParent.h"
#include "ChromiumCDMParent.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/Logging.h"
#include "mozilla/Unused.h"
@@ -62,18 +61,19 @@ public:
private:
RefPtr<GMPContentParent> mToRelease;
};
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));
}
void
GMPContentParent::CheckThread()
{
MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread());
}
@@ -103,25 +103,16 @@ GMPContentParent::VideoEncoderDestroyed(
MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread());
// If the constructor fails, we'll get called before it's added
Unused << NS_WARN_IF(!mVideoEncoders.RemoveElement(aEncoder));
CloseIfUnused();
}
void
-GMPContentParent::DecryptorDestroyed(GMPDecryptorParent* aSession)
-{
- MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread());
-
- MOZ_ALWAYS_TRUE(mDecryptors.RemoveElement(aSession));
- CloseIfUnused();
-}
-
-void
GMPContentParent::AddCloseBlocker()
{
MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread());
++mCloseBlockerCount;
}
void
GMPContentParent::RemoveCloseBlocker()
@@ -129,50 +120,34 @@ GMPContentParent::RemoveCloseBlocker()
MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread());
--mCloseBlockerCount;
CloseIfUnused();
}
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) {
toClose = mParent->ForgetGMPContentParent();
} else {
toClose = this;
RefPtr<GeckoMediaPluginServiceChild> gmp(
GeckoMediaPluginServiceChild::GetSingleton());
gmp->RemoveGMPContentParent(toClose);
}
NS_DispatchToCurrentThread(NewRunnableMethod(
"gmp::GMPContentParent::Close", toClose, &GMPContentParent::Close));
}
}
-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()
{
if (!mGMPEventTarget) {
nsCOMPtr<mozIGeckoMediaPluginService> mps = do_GetService("@mozilla.org/gecko-media-plugin-service;1");
MOZ_ASSERT(mps);
if (!mps) {
return nullptr;
@@ -287,26 +262,10 @@ GMPContentParent::AllocPGMPVideoEncoderP
bool
GMPContentParent::DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor)
{
GMPVideoEncoderParent* vep = static_cast<GMPVideoEncoderParent*>(aActor);
NS_RELEASE(vep);
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
--- a/dom/media/gmp/GMPContentParent.h
+++ b/dom/media/gmp/GMPContentParent.h
@@ -8,17 +8,16 @@
#include "mozilla/gmp/PGMPContentParent.h"
#include "GMPSharedMemManager.h"
#include "nsISupportsImpl.h"
namespace mozilla {
namespace gmp {
-class GMPDecryptorParent;
class GMPParent;
class GMPVideoDecoderParent;
class GMPVideoEncoderParent;
class ChromiumCDMParent;
class GMPContentParent final : public PGMPContentParent,
public GMPSharedMem
{
@@ -29,19 +28,16 @@ public:
nsresult GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD,
uint32_t aDecryptorId);
void VideoDecoderDestroyed(GMPVideoDecoderParent* aDecoder);
nsresult GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE);
void VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder);
- nsresult GetGMPDecryptor(GMPDecryptorParent** aGMPKS);
- void DecryptorDestroyed(GMPDecryptorParent* aSession);
-
already_AddRefed<ChromiumCDMParent> GetChromiumCDM();
void ChromiumCDMDestroyed(ChromiumCDMParent* aCDM);
nsCOMPtr<nsISerialEventTarget> GMPEventTarget();
// GMPSharedMem
void CheckThread() override;
@@ -88,33 +84,29 @@ private:
void ActorDestroy(ActorDestroyReason aWhy) override;
PGMPVideoDecoderParent* AllocPGMPVideoDecoderParent(const uint32_t& aDecryptorId) override;
bool DeallocPGMPVideoDecoderParent(PGMPVideoDecoderParent* aActor) override;
PGMPVideoEncoderParent* AllocPGMPVideoEncoderParent() override;
bool DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor) override;
- PGMPDecryptorParent* AllocPGMPDecryptorParent() override;
- bool DeallocPGMPDecryptorParent(PGMPDecryptorParent* aActor) override;
-
PChromiumCDMParent* AllocPChromiumCDMParent() override;
bool DeallocPChromiumCDMParent(PChromiumCDMParent* aActor) override;
void CloseIfUnused();
// Needed because NewRunnableMethod tried to use the class that the method
// lives on to store the receiver, but PGMPContentParent isn't refcounted.
void Close()
{
PGMPContentParent::Close();
}
nsTArray<RefPtr<GMPVideoDecoderParent>> mVideoDecoders;
nsTArray<RefPtr<GMPVideoEncoderParent>> mVideoEncoders;
- nsTArray<RefPtr<GMPDecryptorParent>> mDecryptors;
nsTArray<RefPtr<ChromiumCDMParent>> mChromiumCDMs;
nsCOMPtr<nsISerialEventTarget> mGMPEventTarget;
RefPtr<GMPParent> mParent;
nsCString mDisplayName;
uint32_t mPluginId;
uint32_t mCloseBlockerCount = 0;
};
deleted file mode 100644
--- a/dom/media/gmp/GMPDecryptorChild.cpp
+++ /dev/null
@@ -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
deleted file mode 100644
--- a/dom/media/gmp/GMPDecryptorChild.h
+++ /dev/null
@@ -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_
deleted file mode 100644
--- a/dom/media/gmp/GMPDecryptorParent.cpp
+++ /dev/null
@@ -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
deleted file mode 100644
--- a/dom/media/gmp/GMPDecryptorParent.h
+++ /dev/null
@@ -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_
--- a/dom/media/gmp/GMPParent.h
+++ b/dom/media/gmp/GMPParent.h
@@ -3,17 +3,16 @@
* 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 GMPParent_h_
#define GMPParent_h_
#include "GMPProcessParent.h"
#include "GMPServiceParent.h"
-#include "GMPDecryptorParent.h"
#include "GMPVideoDecoderParent.h"
#include "GMPVideoEncoderParent.h"
#include "GMPTimerParent.h"
#include "GMPStorageParent.h"
#include "mozilla/gmp/PGMPParent.h"
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsISupports.h"
--- a/dom/media/gmp/GMPService.cpp
+++ b/dom/media/gmp/GMPService.cpp
@@ -16,17 +16,16 @@
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/SyncRunnable.h"
#include "nsXPCOMPrivate.h"
#include "mozilla/Services.h"
#include "nsNativeCharsetUtils.h"
#include "nsIXULAppInfo.h"
#include "nsIConsoleService.h"
#include "mozilla/Unused.h"
-#include "GMPDecryptorParent.h"
#include "nsComponentManagerUtils.h"
#include "runnable_utils.h"
#include "VideoUtils.h"
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
#include "mozilla/SandboxInfo.h"
#endif
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
@@ -420,60 +419,16 @@ GeckoMediaPluginService::GetGMPVideoEnco
[rawCallback] {
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
callback->Done(nullptr, nullptr);
});
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)
{
if (!aHelper) {
return;
}
MutexAutoLock lock(mMutex);
nsTArray<RefPtr<GMPCrashHelper>>* helpers;
--- a/dom/media/gmp/GMPService.h
+++ b/dom/media/gmp/GMPService.h
@@ -82,21 +82,16 @@ public:
UniquePtr<GetGMPVideoDecoderCallback>&& aCallback,
uint32_t aDecryptorId)
override;
NS_IMETHOD GetGMPVideoEncoder(GMPCrashHelper* aHelper,
nsTArray<nsCString>* aTags,
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
GetGMPVideoDecoder(GMPCrashHelper* aHelper,
nsTArray<nsCString>* aTags,
const nsACString& aNodeId,
UniquePtr<GetGMPVideoDecoderCallback>&& aCallback) override
{
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -18,17 +18,16 @@
#include "mozilla/Preferences.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/SyncRunnable.h"
#include "nsXPCOMPrivate.h"
#include "mozilla/Services.h"
#include "nsNativeCharsetUtils.h"
#include "nsIConsoleService.h"
#include "mozilla/Unused.h"
-#include "GMPDecryptorParent.h"
#include "nsComponentManagerUtils.h"
#include "runnable_utils.h"
#include "VideoUtils.h"
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
#include "mozilla/SandboxInfo.h"
#endif
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
@@ -1950,9 +1949,9 @@ GMPServiceParent::Create(Endpoint<PGMPSe
Unused << serviceParent.forget();
return true;
}
} // namespace gmp
} // namespace mozilla
-#undef NS_DispatchToMainThread
\ No newline at end of file
+#undef NS_DispatchToMainThread
--- a/dom/media/gmp/PGMPContent.ipdl
+++ b/dom/media/gmp/PGMPContent.ipdl
@@ -1,29 +1,26 @@
/* -*- 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 PGMPVideoDecoder;
include protocol PGMPVideoEncoder;
-include protocol PGMPDecryptor;
include protocol PChromiumCDM;
namespace mozilla {
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();
};
} // namespace gmp
} // namespace mozilla
deleted file mode 100644
--- a/dom/media/gmp/PGMPDecryptor.ipdl
+++ /dev/null
@@ -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
--- a/dom/media/gmp/moz.build
+++ b/dom/media/gmp/moz.build
@@ -31,18 +31,16 @@ EXPORTS += [
'gmp-api/gmp-video-plane.h',
'GMPCallbackBase.h',
'GMPCDMCallbackProxy.h',
'GMPChild.h',
'GMPContentChild.h',
'GMPContentParent.h',
'GMPCrashHelper.h',
'GMPCrashHelperHolder.h',
- 'GMPDecryptorChild.h',
- 'GMPDecryptorParent.h',
'GMPDecryptorProxy.h',
'GMPEncryptedBufferDataImpl.h',
'GMPLoader.h',
'GMPMessageUtils.h',
'GMPParent.h',
'GMPPlatform.h',
'GMPProcessChild.h',
'GMPProcessParent.h',
@@ -79,18 +77,16 @@ UNIFIED_SOURCES += [
'ChromiumCDMProxy.cpp',
'DecryptJob.cpp',
'GMPCDMCallbackProxy.cpp',
'GMPChild.cpp',
'GMPContentChild.cpp',
'GMPContentParent.cpp',
'GMPCrashHelper.cpp',
'GMPCrashHelperHolder.cpp',
- 'GMPDecryptorChild.cpp',
- 'GMPDecryptorParent.cpp',
'GMPDiskStorage.cpp',
'GMPEncryptedBufferDataImpl.cpp',
'GMPLoader.cpp',
'GMPMemoryStorage.cpp',
'GMPParent.cpp',
'GMPPlatform.cpp',
'GMPProcessChild.cpp',
'GMPProcessParent.cpp',
@@ -117,17 +113,16 @@ DIRS += [
'widevine-adapter',
]
IPDL_SOURCES += [
'GMPTypes.ipdlh',
'PChromiumCDM.ipdl',
'PGMP.ipdl',
'PGMPContent.ipdl',
- 'PGMPDecryptor.ipdl',
'PGMPService.ipdl',
'PGMPStorage.ipdl',
'PGMPTimer.ipdl',
'PGMPVideoDecoder.ipdl',
'PGMPVideoEncoder.ipdl',
]
# comment this out to use Unsafe Shmem for more performance
--- a/dom/media/gmp/mozIGeckoMediaPluginService.idl
+++ b/dom/media/gmp/mozIGeckoMediaPluginService.idl
@@ -119,33 +119,16 @@ interface mozIGeckoMediaPluginService :
*/
[noscript]
void getGMPVideoEncoder(in GMPCrashHelperPtr helper,
in TagArray tags,
[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.
*/
[noscript]
void getNodeId(in AString origin,
in AString topLevelOrigin,
in AString gmpName,
in GetNodeIdCallback callback);
};