--- a/dom/media/eme/CDMCaps.h
+++ b/dom/media/eme/CDMCaps.h
@@ -2,17 +2,16 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 CDMCaps_h_
#define CDMCaps_h_
-#include "gmp-decryption.h"
#include "nsIThread.h"
#include "nsTArray.h"
#include "nsString.h"
#include "SamplesWaitingForKey.h"
#include "mozilla/Monitor.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus
--- a/dom/media/eme/CDMProxy.h
+++ b/dom/media/eme/CDMProxy.h
@@ -63,16 +63,18 @@ public:
mStatus.Construct(aKeyInfo.mStatus.Value());
}
}
nsTArray<uint8_t> mKeyId;
dom::Optional<dom::MediaKeyStatus> mStatus;
};
+// Time is defined as the number of milliseconds since the
+// Epoch (00:00:00 UTC, January 1, 1970).
typedef int64_t UnixTime;
// Proxies calls CDM, and proxies calls back.
// Note: Promises are passed in via a PromiseId, so that the ID can be
// passed via IPC to the CDM, which can then signal when to reject or
// resolve the promise using its PromiseId.
class CDMProxy {
protected:
--- a/dom/media/gmp/ChromiumCDMAdapter.cpp
+++ b/dom/media/gmp/ChromiumCDMAdapter.cpp
@@ -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/. */
#include "ChromiumCDMAdapter.h"
#include "content_decryption_module.h"
#include "content_decryption_module_ext.h"
#include "VideoUtils.h"
#include "gmp-api/gmp-entrypoints.h"
-#include "gmp-api/gmp-decryption.h"
#include "gmp-api/gmp-video-codec.h"
#include "gmp-api/gmp-platform.h"
#include "WidevineUtils.h"
#include "GMPLog.h"
#include "mozilla/Move.h"
#ifdef XP_WIN
#include "WinUtils.h"
--- a/dom/media/gmp/ChromiumCDMProxy.cpp
+++ b/dom/media/gmp/ChromiumCDMProxy.cpp
@@ -489,17 +489,17 @@ ChromiumCDMProxy::OnKeyStatusesChange(co
RefPtr<dom::MediaKeySession> session(mKeys->GetSession(aSessionId));
if (session) {
session->DispatchKeyStatusesChange();
}
}
void
ChromiumCDMProxy::OnExpirationChange(const nsAString& aSessionId,
- GMPTimestamp aExpiryTime)
+ UnixTime aExpiryTime)
{
MOZ_ASSERT(NS_IsMainThread());
if (mKeys.IsNull()) {
return;
}
RefPtr<dom::MediaKeySession> session(mKeys->GetSession(aSessionId));
if (session) {
// Expiry of 0 is interpreted as "never expire". See bug 1345341.
--- a/dom/media/gmp/ChromiumCDMProxy.h
+++ b/dom/media/gmp/ChromiumCDMProxy.h
@@ -66,17 +66,17 @@ public:
void OnResolveLoadSessionPromise(uint32_t aPromiseId, bool aSuccess) override;
void OnSessionMessage(const nsAString& aSessionId,
dom::MediaKeyMessageType aMessageType,
const nsTArray<uint8_t>& aMessage) override;
void OnExpirationChange(const nsAString& aSessionId,
- GMPTimestamp aExpiryTime) override;
+ UnixTime aExpiryTime) override;
void OnSessionClosed(const nsAString& aSessionId) override;
void OnSessionError(const nsAString& aSessionId,
nsresult aException,
uint32_t aSystemCode,
const nsAString& aMsg) override;
deleted file mode 100644
--- a/dom/media/gmp/GMPCDMCallbackProxy.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "GMPCDMCallbackProxy.h"
-#include "mozilla/CDMProxy.h"
-#include "nsString.h"
-#include "mozilla/dom/MediaKeys.h"
-#include "mozilla/dom/MediaKeySession.h"
-#include "mozIGeckoMediaPluginService.h"
-#include "nsContentCID.h"
-#include "nsServiceManagerUtils.h"
-#include "MainThreadUtils.h"
-#include "mozilla/EMEUtils.h"
-
-namespace mozilla {
-
-GMPCDMCallbackProxy::GMPCDMCallbackProxy(CDMProxy* aProxy,
- nsIEventTarget* aMainThread)
- : mProxy(aProxy)
- , mMainThread(aMainThread)
-{}
-
-void
-GMPCDMCallbackProxy::SetDecryptorId(uint32_t aId)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- RefPtr<CDMProxy> proxy = mProxy;
- mMainThread->Dispatch(
- NS_NewRunnableFunction("GMPCDMCallbackProxy::SetDecryptorId",
- [proxy, aId]() { proxy->OnSetDecryptorId(aId); }),
- NS_DISPATCH_NORMAL);
-}
-
-void
-GMPCDMCallbackProxy::SetSessionId(uint32_t aToken,
- const nsCString& aSessionId)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- RefPtr<CDMProxy> proxy = mProxy;
- auto sid = NS_ConvertUTF8toUTF16(aSessionId);
- mMainThread->Dispatch(
- NS_NewRunnableFunction(
- "GMPCDMCallbackProxy::SetSessionId",
- [proxy, aToken, sid]() { proxy->OnSetSessionId(aToken, sid); }),
- NS_DISPATCH_NORMAL);
-}
-
-void
-GMPCDMCallbackProxy::ResolveLoadSessionPromise(uint32_t aPromiseId,
- bool aSuccess)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- RefPtr<CDMProxy> proxy = mProxy;
- mMainThread->Dispatch(
- NS_NewRunnableFunction("GMPCDMCallbackProxy::ResolveLoadSessionPromise",
- [proxy, aPromiseId, aSuccess]() {
- proxy->OnResolveLoadSessionPromise(aPromiseId,
- aSuccess);
- }),
- NS_DISPATCH_NORMAL);
-}
-
-void
-GMPCDMCallbackProxy::ResolvePromise(uint32_t aPromiseId)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- // Note: CDMProxy proxies this from non-main threads to main thread.
- mProxy->ResolvePromise(aPromiseId);
-}
-
-void
-GMPCDMCallbackProxy::RejectPromise(uint32_t aPromiseId,
- nsresult aException,
- const nsCString& aMessage)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- RefPtr<CDMProxy> proxy = mProxy;
- mMainThread->Dispatch(
- NS_NewRunnableFunction("GMPCDMCallbackProxy::RejectPromise",
- [proxy, aPromiseId, aException, aMessage]() {
- proxy->OnRejectPromise(
- aPromiseId, aException, aMessage);
- }),
- NS_DISPATCH_NORMAL);
-}
-
-void
-GMPCDMCallbackProxy::SessionMessage(const nsCString& aSessionId,
- dom::MediaKeyMessageType aMessageType,
- const nsTArray<uint8_t>& aMessage)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- RefPtr<CDMProxy> proxy = mProxy;
- auto sid = NS_ConvertUTF8toUTF16(aSessionId);
- nsTArray<uint8_t> msg(aMessage);
- mMainThread->Dispatch(
- NS_NewRunnableFunction("GMPCDMCallbackProxy::SessionMessage",
- [proxy, sid, aMessageType, msg]() mutable {
- proxy->OnSessionMessage(sid, aMessageType, msg);
- }),
- NS_DISPATCH_NORMAL);
-}
-
-void
-GMPCDMCallbackProxy::ExpirationChange(const nsCString& aSessionId,
- GMPTimestamp aExpiryTime)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- RefPtr<CDMProxy> proxy = mProxy;
- auto sid = NS_ConvertUTF8toUTF16(aSessionId);
- mMainThread->Dispatch(
- NS_NewRunnableFunction("GMPCDMCallbackProxy::ExpirationChange",
- [proxy, sid, aExpiryTime]() {
- proxy->OnExpirationChange(sid, aExpiryTime);
- }),
- NS_DISPATCH_NORMAL);
-}
-
-void
-GMPCDMCallbackProxy::SessionClosed(const nsCString& aSessionId)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- bool keyStatusesChange = false;
- auto sid = NS_ConvertUTF8toUTF16(aSessionId);
- {
- CDMCaps::AutoLock caps(mProxy->Capabilites());
- keyStatusesChange = caps.RemoveKeysForSession(NS_ConvertUTF8toUTF16(aSessionId));
- }
- if (keyStatusesChange) {
- RefPtr<CDMProxy> proxy = mProxy;
- mMainThread->Dispatch(
- NS_NewRunnableFunction(
- "GMPCDMCallbackProxy::SessionClosed",
- [proxy, sid]() { proxy->OnKeyStatusesChange(sid); }),
- NS_DISPATCH_NORMAL);
- }
-
- RefPtr<CDMProxy> proxy = mProxy;
- mMainThread->Dispatch(
- NS_NewRunnableFunction("GMPCDMCallbackProxy::SessionClosed",
- [proxy, sid]() { proxy->OnSessionClosed(sid); }),
- NS_DISPATCH_NORMAL);
-}
-
-void
-GMPCDMCallbackProxy::SessionError(const nsCString& aSessionId,
- nsresult aException,
- uint32_t aSystemCode,
- const nsCString& aMessage)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- RefPtr<CDMProxy> proxy = mProxy;
- auto sid = NS_ConvertUTF8toUTF16(aSessionId);
- auto msg = NS_ConvertUTF8toUTF16(aMessage);
- mMainThread->Dispatch(
- NS_NewRunnableFunction("GMPCDMCallbackProxy::SessionError",
- [proxy, sid, aException, aSystemCode, msg]() {
- proxy->OnSessionError(
- sid, aException, aSystemCode, msg);
- }),
- NS_DISPATCH_NORMAL);
-}
-
-void
-GMPCDMCallbackProxy::BatchedKeyStatusChanged(const nsCString& aSessionId,
- const nsTArray<CDMKeyInfo>& aKeyInfos)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
- BatchedKeyStatusChangedInternal(aSessionId, aKeyInfos);
-}
-
-void
-GMPCDMCallbackProxy::BatchedKeyStatusChangedInternal(const nsCString& aSessionId,
- const nsTArray<CDMKeyInfo>& aKeyInfos)
-{
- bool keyStatusesChange = false;
- {
- CDMCaps::AutoLock caps(mProxy->Capabilites());
- for (size_t i = 0; i < aKeyInfos.Length(); i++) {
- keyStatusesChange |=
- caps.SetKeyStatus(aKeyInfos[i].mKeyId,
- NS_ConvertUTF8toUTF16(aSessionId),
- aKeyInfos[i].mStatus);
- }
- }
- if (keyStatusesChange) {
- RefPtr<CDMProxy> proxy = mProxy;
- auto sid = NS_ConvertUTF8toUTF16(aSessionId);
- mMainThread->Dispatch(
- NS_NewRunnableFunction(
- "GMPCDMCallbackProxy::BatchedKeyStatusChangedInternal",
- [proxy, sid]() { proxy->OnKeyStatusesChange(sid); }),
- NS_DISPATCH_NORMAL);
- }
-}
-
-void
-GMPCDMCallbackProxy::Decrypted(uint32_t aId,
- DecryptStatus aResult,
- const nsTArray<uint8_t>& aDecryptedData)
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- mProxy->OnDecrypted(aId, aResult, aDecryptedData);
-}
-
-void
-GMPCDMCallbackProxy::Terminated()
-{
- MOZ_ASSERT(mProxy->IsOnOwnerThread());
-
- RefPtr<CDMProxy> proxy = mProxy;
- mMainThread->Dispatch(
- NS_NewRunnableFunction("GMPCDMCallbackProxy::Terminated",
- [proxy]() { proxy->Terminated(); }),
- NS_DISPATCH_NORMAL);
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/dom/media/gmp/GMPCDMCallbackProxy.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 GMPCDMCallbackProxy_h_
-#define GMPCDMCallbackProxy_h_
-
-#include "mozilla/CDMProxy.h"
-#include "gmp-decryption.h"
-#include "GMPDecryptorProxy.h"
-
-namespace mozilla {
-
-// Proxies call backs from the CDM on the GMP thread back to the MediaKeys
-// object on the main thread.
-class GMPCDMCallbackProxy : public GMPDecryptorProxyCallback {
-public:
-
- void SetDecryptorId(uint32_t aId) override;
-
- void SetSessionId(uint32_t aCreateSessionToken,
- const nsCString& aSessionId) override;
-
- void ResolveLoadSessionPromise(uint32_t aPromiseId,
- bool aSuccess) override;
-
- void ResolvePromise(uint32_t aPromiseId) override;
-
- void RejectPromise(uint32_t aPromiseId,
- nsresult aException,
- const nsCString& aSessionId) override;
-
- void SessionMessage(const nsCString& aSessionId,
- dom::MediaKeyMessageType aMessageType,
- const nsTArray<uint8_t>& aMessage) override;
-
- void ExpirationChange(const nsCString& aSessionId,
- UnixTime aExpiryTime) override;
-
- void SessionClosed(const nsCString& aSessionId) override;
-
- void SessionError(const nsCString& aSessionId,
- nsresult aException,
- uint32_t aSystemCode,
- const nsCString& aMessage) override;
-
- void Decrypted(uint32_t aId,
- DecryptStatus aResult,
- const nsTArray<uint8_t>& aDecryptedData) override;
-
- void BatchedKeyStatusChanged(const nsCString& aSessionId,
- const nsTArray<CDMKeyInfo>& aKeyInfos) override;
-
- void Terminated() override;
-
- ~GMPCDMCallbackProxy() {}
-
-private:
- friend class GMPCDMProxy;
- GMPCDMCallbackProxy(CDMProxy* aProxy, nsIEventTarget* aMainThread);
-
- void BatchedKeyStatusChangedInternal(const nsCString& aSessionId,
- const nsTArray<CDMKeyInfo>& aKeyInfos);
- // Warning: Weak ref.
- CDMProxy* mProxy;
-
- const nsCOMPtr<nsIEventTarget> mMainThread;
-};
-
-} // namespace mozilla
-
-#endif // GMPCDMCallbackProxy_h_
deleted file mode 100644
--- a/dom/media/gmp/GMPDecryptorProxy.h
+++ /dev/null
@@ -1,63 +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 GMPDecryptorProxy_h_
-#define GMPDecryptorProxy_h_
-
-#include "mozilla/DecryptorProxyCallback.h"
-#include "GMPCallbackBase.h"
-#include "gmp-decryption.h"
-#include "nsString.h"
-
-namespace mozilla {
-class CryptoSample;
-} // namespace mozilla
-
-class GMPDecryptorProxyCallback : public DecryptorProxyCallback,
- public GMPCallbackBase {
-public:
- virtual ~GMPDecryptorProxyCallback() {}
-};
-
-class GMPDecryptorProxy {
-public:
- ~GMPDecryptorProxy() {}
-
- virtual uint32_t GetPluginId() const = 0;
-
- virtual nsresult Init(GMPDecryptorProxyCallback* aCallback,
- bool aDistinctiveIdentifierRequired,
- bool aPersistentStateRequired) = 0;
-
- virtual void CreateSession(uint32_t aCreateSessionToken,
- uint32_t aPromiseId,
- const nsCString& aInitDataType,
- const nsTArray<uint8_t>& aInitData,
- GMPSessionType aSessionType) = 0;
-
- virtual void LoadSession(uint32_t aPromiseId,
- const nsCString& aSessionId) = 0;
-
- virtual void UpdateSession(uint32_t aPromiseId,
- const nsCString& aSessionId,
- const nsTArray<uint8_t>& aResponse) = 0;
-
- virtual void CloseSession(uint32_t aPromiseId,
- const nsCString& aSessionId) = 0;
-
- virtual void RemoveSession(uint32_t aPromiseId,
- const nsCString& aSessionId) = 0;
-
- virtual void SetServerCertificate(uint32_t aPromiseId,
- const nsTArray<uint8_t>& aServerCert) = 0;
-
- virtual void Decrypt(uint32_t aId,
- const mozilla::CryptoSample& aCrypto,
- const nsTArray<uint8_t>& aBuffer) = 0;
-
- virtual void Close() = 0;
-};
-
-#endif // GMPDecryptorProxy_h_
deleted file mode 100644
--- a/dom/media/gmp/GMPEncryptedBufferDataImpl.cpp
+++ /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/. */
-
-#include "GMPEncryptedBufferDataImpl.h"
-#include "mozilla/gmp/GMPTypes.h"
-#include "MediaData.h"
-
-namespace mozilla {
-namespace gmp {
-
-GMPEncryptedBufferDataImpl::GMPEncryptedBufferDataImpl(const CryptoSample& aCrypto)
- : mKeyId(aCrypto.mKeyId)
- , mIV(aCrypto.mIV)
- , mClearBytes(aCrypto.mPlainSizes)
- , mCipherBytes(aCrypto.mEncryptedSizes)
- , mSessionIdList(aCrypto.mSessionIds)
-{
-}
-
-GMPEncryptedBufferDataImpl::GMPEncryptedBufferDataImpl(const GMPDecryptionData& aData)
- : mKeyId(aData.mKeyId())
- , mIV(aData.mIV())
- , mClearBytes(aData.mClearBytes())
- , mCipherBytes(aData.mCipherBytes())
- , mSessionIdList(aData.mSessionIds())
-{
- MOZ_ASSERT(mClearBytes.Length() == mCipherBytes.Length());
-}
-
-GMPEncryptedBufferDataImpl::~GMPEncryptedBufferDataImpl()
-{
-}
-
-void
-GMPEncryptedBufferDataImpl::RelinquishData(GMPDecryptionData& aData)
-{
- aData.mKeyId() = Move(mKeyId);
- aData.mIV() = Move(mIV);
- aData.mClearBytes() = Move(mClearBytes);
- aData.mCipherBytes() = Move(mCipherBytes);
- mSessionIdList.RelinquishData(aData.mSessionIds());
-}
-
-const uint8_t*
-GMPEncryptedBufferDataImpl::KeyId() const
-{
- return mKeyId.Elements();
-}
-
-uint32_t
-GMPEncryptedBufferDataImpl::KeyIdSize() const
-{
- return mKeyId.Length();
-}
-
-const uint8_t*
-GMPEncryptedBufferDataImpl::IV() const
-{
- return mIV.Elements();
-}
-
-uint32_t
-GMPEncryptedBufferDataImpl::IVSize() const
-{
- return mIV.Length();
-}
-
-const uint16_t*
-GMPEncryptedBufferDataImpl::ClearBytes() const
-{
- return mClearBytes.Elements();
-}
-
-const uint32_t*
-GMPEncryptedBufferDataImpl::CipherBytes() const
-{
- return mCipherBytes.Elements();
-}
-
-const GMPStringList*
-GMPEncryptedBufferDataImpl::SessionIds() const
-{
- return &mSessionIdList;
-}
-
-uint32_t
-GMPEncryptedBufferDataImpl::NumSubsamples() const
-{
- MOZ_ASSERT(mClearBytes.Length() == mCipherBytes.Length());
- // Return the min of the two, to ensure there's not chance of array index
- // out-of-bounds shenanigans.
- return std::min<uint32_t>(mClearBytes.Length(), mCipherBytes.Length());
-}
-
-GMPStringListImpl::GMPStringListImpl(const nsTArray<nsCString>& aStrings)
- : mStrings(aStrings)
-{
-}
-
-uint32_t
-GMPStringListImpl::Size() const
-{
- return mStrings.Length();
-}
-
-void
-GMPStringListImpl::StringAt(uint32_t aIndex,
- const char** aOutString,
- uint32_t *aOutLength) const
-{
- if (NS_WARN_IF(aIndex >= Size())) {
- return;
- }
-
- *aOutString = mStrings[aIndex].BeginReading();
- *aOutLength = mStrings[aIndex].Length();
-}
-
-void
-GMPStringListImpl::RelinquishData(nsTArray<nsCString>& aStrings)
-{
- aStrings = Move(mStrings);
-}
-
-GMPStringListImpl::~GMPStringListImpl()
-{
-}
-
-} // namespace gmp
-} // namespace mozilla
deleted file mode 100644
--- a/dom/media/gmp/GMPEncryptedBufferDataImpl.h
+++ /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/. */
-
-#ifndef GMPEncryptedBufferDataImpl_h_
-#define GMPEncryptedBufferDataImpl_h_
-
-#include "gmp-decryption.h"
-#include "nsAutoPtr.h"
-#include "nsTArray.h"
-#include "mozilla/gmp/GMPTypes.h"
-
-namespace mozilla {
-class CryptoSample;
-
-namespace gmp {
-
-class GMPStringListImpl : public GMPStringList
-{
-public:
- explicit GMPStringListImpl(const nsTArray<nsCString>& aStrings);
- uint32_t Size() const override;
- void StringAt(uint32_t aIndex,
- const char** aOutString, uint32_t *aOutLength) const override;
- virtual ~GMPStringListImpl() override;
- void RelinquishData(nsTArray<nsCString>& aStrings);
-
-private:
- nsTArray<nsCString> mStrings;
-};
-
-class GMPEncryptedBufferDataImpl : public GMPEncryptedBufferMetadata {
-public:
- explicit GMPEncryptedBufferDataImpl(const CryptoSample& aCrypto);
- explicit GMPEncryptedBufferDataImpl(const GMPDecryptionData& aData);
- virtual ~GMPEncryptedBufferDataImpl();
-
- void RelinquishData(GMPDecryptionData& aData);
-
- const uint8_t* KeyId() const override;
- uint32_t KeyIdSize() const override;
- const uint8_t* IV() const override;
- uint32_t IVSize() const override;
- uint32_t NumSubsamples() const override;
- const uint16_t* ClearBytes() const override;
- const uint32_t* CipherBytes() const override;
- const GMPStringList* SessionIds() const override;
-
-private:
- nsTArray<uint8_t> mKeyId;
- nsTArray<uint8_t> mIV;
- nsTArray<uint16_t> mClearBytes;
- nsTArray<uint32_t> mCipherBytes;
-
- GMPStringListImpl mSessionIdList;
-};
-
-class GMPBufferImpl : public GMPBuffer {
-public:
- GMPBufferImpl(uint32_t aId, const nsTArray<uint8_t>& aData)
- : mId(aId)
- , mData(aData)
- {
- }
- uint32_t Id() const override {
- return mId;
- }
- uint8_t* Data() override {
- return mData.Elements();
- }
- uint32_t Size() const override {
- return mData.Length();
- }
- void Resize(uint32_t aSize) override {
- mData.SetLength(aSize);
- }
-
- // Set metadata object to be freed when this buffer is destroyed.
- void SetMetadata(GMPEncryptedBufferDataImpl* aMetadata) {
- mMetadata = aMetadata;
- }
-
- uint32_t mId;
- nsTArray<uint8_t> mData;
- nsAutoPtr<GMPEncryptedBufferDataImpl> mMetadata;
-};
-
-} // namespace gmp
-} // namespace mozilla
-
-#endif // GMPEncryptedBufferDataImpl_h_
--- a/dom/media/gmp/GMPMessageUtils.h
+++ b/dom/media/gmp/GMPMessageUtils.h
@@ -3,83 +3,34 @@
* 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 GMPMessageUtils_h_
#define GMPMessageUtils_h_
#include "gmp-video-codec.h"
#include "gmp-video-frame-encoded.h"
-#include "gmp-decryption.h"
#include "IPCMessageUtils.h"
namespace IPC {
template <>
struct ParamTraits<GMPErr>
: public ContiguousEnumSerializer<GMPErr,
GMPNoErr,
GMPLastErr>
{};
-struct GMPDomExceptionValidator {
- static bool IsLegalValue(GMPDOMException aValue) {
- switch (aValue) {
- case kGMPNoModificationAllowedError:
- case kGMPNotFoundError:
- case kGMPNotSupportedError:
- case kGMPInvalidStateError:
- case kGMPSyntaxError:
- case kGMPInvalidModificationError:
- case kGMPInvalidAccessError:
- case kGMPSecurityError:
- case kGMPAbortError:
- case kGMPQuotaExceededError:
- case kGMPTimeoutError:
- case kGMPTypeError:
- return true;
- default:
- return false;
- }
- }
-};
-
template <>
struct ParamTraits<GMPVideoFrameType>
: public ContiguousEnumSerializer<GMPVideoFrameType,
kGMPKeyFrame,
kGMPVideoFrameInvalid>
{};
-template<>
-struct ParamTraits<GMPDOMException>
-: public EnumSerializer<GMPDOMException, GMPDomExceptionValidator>
-{};
-
-template <>
-struct ParamTraits<GMPSessionMessageType>
-: public ContiguousEnumSerializer<GMPSessionMessageType,
- kGMPLicenseRequest,
- kGMPMessageInvalid>
-{};
-
-template <>
-struct ParamTraits<GMPMediaKeyStatus>
-: public ContiguousEnumSerializer<GMPMediaKeyStatus,
- kGMPUsable,
- kGMPMediaKeyStatusInvalid>
-{};
-
-template <>
-struct ParamTraits<GMPSessionType>
-: public ContiguousEnumSerializer<GMPSessionType,
- kGMPTemporySession,
- kGMPSessionInvalid>
-{};
-
template <>
struct ParamTraits<GMPVideoCodecComplexity>
: public ContiguousEnumSerializer<GMPVideoCodecComplexity,
kGMPComplexityNormal,
kGMPComplexityInvalid>
{};
template <>
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -686,32 +686,16 @@ GMPParent::ReadGMPInfoFile(nsIFile* aFil
nsTArray<nsCString> tagTokens;
SplitAt(":", ts, tagTokens);
for (nsCString tag : tagTokens) {
cap.mAPITags.AppendElement(tag);
}
}
}
- if (cap.mAPIName.EqualsLiteral(GMP_API_DECRYPTOR)) {
- mCanDecrypt = true;
-
-#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
- if (!mozilla::SandboxInfo::Get().CanSandboxMedia()) {
- nsPrintfCString msg(
- "GMPParent::ReadGMPMetaData: Plugin \"%s\" is an EME CDM"
- " but this system can't sandbox it; not loading.",
- mDisplayName.get());
- printf_stderr("%s\n", msg.get());
- LOGD("%s", msg.get());
- return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
- }
-#endif
- }
-
mCapabilities.AppendElement(Move(cap));
}
if (mCapabilities.IsEmpty()) {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
}
return GenericPromise::CreateAndResolve(true, __func__);
--- a/dom/media/gmp/GMPTypes.ipdlh
+++ b/dom/media/gmp/GMPTypes.ipdlh
@@ -1,45 +1,35 @@
/* -*- 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/. */
using GMPBufferType from "gmp-video-codec.h";
-using GMPMediaKeyStatus from "gmp-decryption.h";
namespace mozilla {
namespace gmp {
struct NodeIdData {
nsString mOrigin;
nsString mTopLevelOrigin;
nsString mGMPName;
};
-struct GMPDecryptionData {
- uint8_t[] mKeyId;
- uint8_t[] mIV;
- uint16_t[] mClearBytes;
- uint32_t[] mCipherBytes;
- nsCString[] mSessionIds;
-};
-
struct GMPVideoEncodedFrameData
{
uint32_t mEncodedWidth;
uint32_t mEncodedHeight;
uint64_t mTimestamp; // microseconds
uint64_t mDuration; // microseconds
uint32_t mFrameType;
uint32_t mSize;
GMPBufferType mBufferType;
Shmem mBuffer;
bool mCompleteFrame;
- GMPDecryptionData mDecryptionData;
};
struct GMPPlaneData
{
int32_t mSize;
int32_t mStride;
Shmem mBuffer;
};
@@ -50,21 +40,16 @@ struct GMPVideoi420FrameData
GMPPlaneData mUPlane;
GMPPlaneData mVPlane;
int32_t mWidth;
int32_t mHeight;
uint64_t mTimestamp; // microseconds
uint64_t mDuration; // microseconds
};
-struct GMPKeyInformation {
- uint8_t[] keyId;
- GMPMediaKeyStatus status;
-};
-
struct CDMInputBuffer {
Shmem mData;
uint8_t[] mKeyId;
uint8_t[] mIV;
int64_t mTimestamp;
int64_t mDuration;
uint16_t[] mClearBytes;
uint32_t[] mCipherBytes;
--- a/dom/media/gmp/GMPVideoDecoderParent.cpp
+++ b/dom/media/gmp/GMPVideoDecoderParent.cpp
@@ -118,37 +118,25 @@ GMPVideoDecoderParent::InitDecode(const
return NS_ERROR_FAILURE;
}
mIsOpen = true;
// Async IPC, we don't have access to a return value.
return NS_OK;
}
-static nsCString
-CryptoInfo(const GMPUniquePtr<GMPVideoEncodedFrame>& aInputFrame)
-{
- const GMPEncryptedBufferMetadata* crypto = aInputFrame->GetDecryptionData();
- if (!crypto) {
- return EmptyCString();
- }
- return nsPrintfCString(" kid=%s",
- ToHexString(crypto->KeyId(), crypto->KeyIdSize()).get());
-}
-
nsresult
GMPVideoDecoderParent::Decode(GMPUniquePtr<GMPVideoEncodedFrame> aInputFrame,
bool aMissingFrames,
const nsTArray<uint8_t>& aCodecSpecificInfo,
int64_t aRenderTimeMs)
{
- LOGV(("GMPVideoDecoderParent[%p]::Decode() timestamp=%" PRId64 " keyframe=%d%s",
+ LOGV(("GMPVideoDecoderParent[%p]::Decode() timestamp=%" PRId64 " keyframe=%d",
this, aInputFrame->TimeStamp(),
- aInputFrame->FrameType() == kGMPKeyFrame,
- CryptoInfo(aInputFrame).get()));
+ aInputFrame->FrameType() == kGMPKeyFrame));
if (!mIsOpen) {
LOGE(("GMPVideoDecoderParent[%p]::Decode() ERROR; dead GMPVideoDecoder", this));
NS_WARNING("Trying to use an dead GMP video decoder");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(mPlugin->GMPEventTarget()->IsOnCurrentThread());
--- a/dom/media/gmp/GMPVideoEncodedFrameImpl.cpp
+++ b/dom/media/gmp/GMPVideoEncodedFrameImpl.cpp
@@ -2,17 +2,16 @@
/* 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 "GMPVideoEncodedFrameImpl.h"
#include "GMPVideoHost.h"
#include "mozilla/gmp/GMPTypes.h"
#include "GMPSharedMemManager.h"
-#include "GMPEncryptedBufferDataImpl.h"
namespace mozilla {
namespace gmp {
GMPVideoEncodedFrameImpl::GMPVideoEncodedFrameImpl(GMPVideoHostImpl* aHost)
: mEncodedWidth(0),
mEncodedHeight(0),
mTimeStamp(0ll),
@@ -36,42 +35,27 @@ GMPVideoEncodedFrameImpl::GMPVideoEncode
mFrameType(static_cast<GMPVideoFrameType>(aFrameData.mFrameType())),
mSize(aFrameData.mSize()),
mCompleteFrame(aFrameData.mCompleteFrame()),
mHost(aHost),
mBuffer(aFrameData.mBuffer()),
mBufferType(aFrameData.mBufferType())
{
MOZ_ASSERT(aHost);
- if (aFrameData.mDecryptionData().mKeyId().Length() > 0) {
- mCrypto = new GMPEncryptedBufferDataImpl(aFrameData.mDecryptionData());
- }
aHost->EncodedFrameCreated(this);
}
GMPVideoEncodedFrameImpl::~GMPVideoEncodedFrameImpl()
{
DestroyBuffer();
if (mHost) {
mHost->EncodedFrameDestroyed(this);
}
}
-void
-GMPVideoEncodedFrameImpl::InitCrypto(const CryptoSample& aCrypto)
-{
- mCrypto = new GMPEncryptedBufferDataImpl(aCrypto);
-}
-
-const GMPEncryptedBufferMetadata*
-GMPVideoEncodedFrameImpl::GetDecryptionData() const
-{
- return mCrypto;
-}
-
GMPVideoFrameFormat
GMPVideoEncodedFrameImpl::GetFrameFormat()
{
return kGMPEncodedVideoFrame;
}
void
GMPVideoEncodedFrameImpl::DoneWithAPI()
@@ -100,19 +84,16 @@ GMPVideoEncodedFrameImpl::RelinquishFram
aFrameData.mEncodedHeight() = mEncodedHeight;
aFrameData.mTimestamp() = mTimeStamp;
aFrameData.mDuration() = mDuration;
aFrameData.mFrameType() = mFrameType;
aFrameData.mSize() = mSize;
aFrameData.mCompleteFrame() = mCompleteFrame;
aFrameData.mBuffer() = mBuffer;
aFrameData.mBufferType() = mBufferType;
- if (mCrypto) {
- mCrypto->RelinquishData(aFrameData.mDecryptionData());
- }
// This method is called right before Shmem is sent to another process.
// We need to effectively zero out our member copy so that we don't
// try to delete Shmem we don't own later.
mBuffer = ipc::Shmem();
return true;
}
@@ -159,17 +140,16 @@ GMPVideoEncodedFrameImpl::CopyFrame(cons
mEncodedWidth = f.mEncodedWidth;
mEncodedHeight = f.mEncodedHeight;
mTimeStamp = f.mTimeStamp;
mDuration = f.mDuration;
mFrameType = f.mFrameType;
mSize = f.mSize; // already set...
mCompleteFrame = f.mCompleteFrame;
mBufferType = f.mBufferType;
- mCrypto = new GMPEncryptedBufferDataImpl(*(f.mCrypto));
// Don't copy host, that should have been set properly on object creation via host.
return GMPNoErr;
}
void
GMPVideoEncodedFrameImpl::SetEncodedWidth(uint32_t aEncodedWidth)
{
--- a/dom/media/gmp/GMPVideoEncodedFrameImpl.h
+++ b/dom/media/gmp/GMPVideoEncodedFrameImpl.h
@@ -29,39 +29,35 @@
*/
#ifndef GMPVideoEncodedFrameImpl_h_
#define GMPVideoEncodedFrameImpl_h_
#include "gmp-errors.h"
#include "gmp-video-frame.h"
#include "gmp-video-frame-encoded.h"
-#include "gmp-decryption.h"
#include "mozilla/ipc/Shmem.h"
#include "nsAutoPtr.h"
namespace mozilla {
class CryptoSample;
namespace gmp {
class GMPVideoHostImpl;
class GMPVideoEncodedFrameData;
-class GMPEncryptedBufferDataImpl;
class GMPVideoEncodedFrameImpl: public GMPVideoEncodedFrame
{
friend struct IPC::ParamTraits<mozilla::gmp::GMPVideoEncodedFrameImpl>;
public:
explicit GMPVideoEncodedFrameImpl(GMPVideoHostImpl* aHost);
GMPVideoEncodedFrameImpl(const GMPVideoEncodedFrameData& aFrameData, GMPVideoHostImpl* aHost);
virtual ~GMPVideoEncodedFrameImpl();
- void InitCrypto(const CryptoSample& aCrypto);
-
// This is called during a normal destroy sequence, which is
// when a consumer is finished or during XPCOM shutdown.
void DoneWithAPI();
// Does not attempt to release Shmem, as the Shmem has already been released.
void ActorDestroyed();
bool RelinquishFrameData(GMPVideoEncodedFrameData& aFrameData);
@@ -92,31 +88,29 @@ public:
void SetSize(uint32_t aSize) override;
uint32_t Size() override;
void SetCompleteFrame(bool aCompleteFrame) override;
bool CompleteFrame() override;
const uint8_t* Buffer() const override;
uint8_t* Buffer() override;
GMPBufferType BufferType() const override;
void SetBufferType(GMPBufferType aBufferType) override;
- const GMPEncryptedBufferMetadata* GetDecryptionData() const override;
private:
void DestroyBuffer();
uint32_t mEncodedWidth;
uint32_t mEncodedHeight;
uint64_t mTimeStamp;
uint64_t mDuration;
GMPVideoFrameType mFrameType;
uint32_t mSize;
bool mCompleteFrame;
GMPVideoHostImpl* mHost;
ipc::Shmem mBuffer;
GMPBufferType mBufferType;
- nsAutoPtr<GMPEncryptedBufferDataImpl> mCrypto;
};
} // namespace gmp
} // namespace mozilla
#endif // GMPVideoEncodedFrameImpl_h_
deleted file mode 100644
--- a/dom/media/gmp/gmp-api/gmp-decryption.h
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
-* Copyright 2013, Mozilla Foundation and contributors
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef GMP_DECRYPTION_h_
-#define GMP_DECRYPTION_h_
-
-#include "gmp-platform.h"
-
-class GMPStringList {
-public:
- virtual uint32_t Size() const = 0;
-
- virtual void StringAt(uint32_t aIndex,
- const char** aOutString, uint32_t* aOutLength) const = 0;
-
- virtual ~GMPStringList() { }
-};
-
-class GMPEncryptedBufferMetadata {
-public:
- // Key ID to identify the decryption key.
- virtual const uint8_t* KeyId() const = 0;
-
- // Size (in bytes) of |KeyId()|.
- virtual uint32_t KeyIdSize() const = 0;
-
- // Initialization vector.
- virtual const uint8_t* IV() const = 0;
-
- // Size (in bytes) of |IV|.
- virtual uint32_t IVSize() const = 0;
-
- // Number of entries returned by ClearBytes() and CipherBytes().
- virtual uint32_t NumSubsamples() const = 0;
-
- virtual const uint16_t* ClearBytes() const = 0;
-
- virtual const uint32_t* CipherBytes() const = 0;
-
- virtual ~GMPEncryptedBufferMetadata() {}
-
- // The set of MediaKeySession IDs associated with this decryption key in
- // the current stream.
- virtual const GMPStringList* SessionIds() const = 0;
-};
-
-class GMPBuffer {
-public:
- virtual uint32_t Id() const = 0;
- virtual uint8_t* Data() = 0;
- virtual uint32_t Size() const = 0;
- virtual void Resize(uint32_t aSize) = 0;
- virtual ~GMPBuffer() {}
-};
-
-// These match to the DOMException codes as per:
-// http://www.w3.org/TR/dom/#domexception
-enum GMPDOMException {
- kGMPNoModificationAllowedError = 7,
- kGMPNotFoundError = 8,
- kGMPNotSupportedError = 9,
- kGMPInvalidStateError = 11,
- kGMPSyntaxError = 12,
- kGMPInvalidModificationError = 13,
- kGMPInvalidAccessError = 15,
- kGMPSecurityError = 18,
- kGMPAbortError = 20,
- kGMPQuotaExceededError = 22,
- kGMPTimeoutError = 23,
- kGMPTypeError = 52
-};
-
-enum GMPSessionMessageType {
- kGMPLicenseRequest = 0,
- kGMPLicenseRenewal = 1,
- kGMPLicenseRelease = 2,
- kGMPIndividualizationRequest = 3,
- kGMPMessageInvalid = 4 // Must always be last.
-};
-
-enum GMPMediaKeyStatus {
- kGMPUsable = 0,
- kGMPExpired = 1,
- kGMPOutputDownscaled = 2,
- kGMPOutputRestricted = 3,
- kGMPInternalError = 4,
- kGMPUnknown = 5, // Removes key from MediaKeyStatusMap
- kGMPReleased = 6,
- kGMPStatusPending = 7,
- kGMPMediaKeyStatusInvalid = 8 // Must always be last.
-};
-
-struct GMPMediaKeyInfo {
- GMPMediaKeyInfo() {}
- GMPMediaKeyInfo(const uint8_t* aKeyId,
- uint32_t aKeyIdSize,
- GMPMediaKeyStatus aStatus)
- : keyid(aKeyId)
- , keyid_size(aKeyIdSize)
- , status(aStatus)
- {}
- const uint8_t* keyid;
- uint32_t keyid_size;
- GMPMediaKeyStatus status;
-};
-
-// Time in milliseconds, as offset from epoch, 1 Jan 1970.
-typedef int64_t GMPTimestamp;
-
-// Callbacks to be called from the CDM. Threadsafe.
-class GMPDecryptorCallback {
-public:
-
- // The GMPDecryptor should call this in response to a call to
- // GMPDecryptor::CreateSession(). The GMP host calls CreateSession() when
- // MediaKeySession.generateRequest() is called by JavaScript.
- // After CreateSession() is called, the GMPDecryptor should call
- // GMPDecryptorCallback::SetSessionId() to set the sessionId exposed to
- // JavaScript on the MediaKeySession on which the generateRequest() was
- // called. SetSessionId() must be called before
- // GMPDecryptorCallback::SessionMessage() will work.
- // aSessionId must be null terminated.
- // Note: pass the aCreateSessionToken from the CreateSession() call,
- // and then once the session has sent any messages required for the
- // license request to be sent, then resolve the aPromiseId that was passed
- // to GMPDecryptor::CreateSession().
- // Note: GMPDecryptor::LoadSession() does *not* need to call SetSessionId()
- // for GMPDecryptorCallback::SessionMessage() to work.
- virtual void SetSessionId(uint32_t aCreateSessionToken,
- const char* aSessionId,
- uint32_t aSessionIdLength) = 0;
-
- // Resolves a promise for a session loaded.
- // Resolves to false if we don't have any session data stored for the given
- // session ID.
- // Must be called before SessionMessage().
- virtual void ResolveLoadSessionPromise(uint32_t aPromiseId,
- bool aSuccess) = 0;
-
- // Called to resolve a specified promise with "undefined".
- virtual void ResolvePromise(uint32_t aPromiseId) = 0;
-
- // Called to reject a promise with a DOMException.
- // aMessage is logged to the WebConsole.
- // aMessage is optional, but if present must be null terminated.
- virtual void RejectPromise(uint32_t aPromiseId,
- GMPDOMException aException,
- const char* aMessage,
- uint32_t aMessageLength) = 0;
-
- // Called by the CDM when it has a message for a session.
- // Length parameters should not include null termination.
- // aSessionId must be null terminated.
- virtual void SessionMessage(const char* aSessionId,
- uint32_t aSessionIdLength,
- GMPSessionMessageType aMessageType,
- const uint8_t* aMessage,
- uint32_t aMessageLength) = 0;
-
- // aSessionId must be null terminated.
- virtual void ExpirationChange(const char* aSessionId,
- uint32_t aSessionIdLength,
- GMPTimestamp aExpiryTime) = 0;
-
- // Called by the GMP when a session is closed. All file IO
- // that a session requires should be complete before calling this.
- // aSessionId must be null terminated.
- virtual void SessionClosed(const char* aSessionId,
- uint32_t aSessionIdLength) = 0;
-
- // Called by the GMP when an error occurs in a session.
- // aSessionId must be null terminated.
- // aMessage is logged to the WebConsole.
- // aMessage is optional, but if present must be null terminated.
- virtual void SessionError(const char* aSessionId,
- uint32_t aSessionIdLength,
- GMPDOMException aException,
- uint32_t aSystemCode,
- const char* aMessage,
- uint32_t aMessageLength) = 0;
-
- // Notifies the status of a key. Gecko will not call into the CDM to decrypt
- // or decode content encrypted with a key unless the CDM has marked it
- // usable first. So a CDM *MUST* mark its usable keys as usable!
- virtual void KeyStatusChanged(const char* aSessionId,
- uint32_t aSessionIdLength,
- const uint8_t* aKeyId,
- uint32_t aKeyIdLength,
- GMPMediaKeyStatus aStatus) = 0;
-
- // DEPRECATED; this function has no affect.
- virtual void SetCapabilities(uint64_t aCaps) = 0;
-
- // Returns decrypted buffer to Gecko, or reports failure.
- virtual void Decrypted(GMPBuffer* aBuffer, GMPErr aResult) = 0;
-
- // To aggregate KeyStatusChanged into single callback per session id.
- virtual void BatchedKeyStatusChanged(const char* aSessionId,
- uint32_t aSessionIdLength,
- const GMPMediaKeyInfo* aKeyInfos,
- uint32_t aKeyInfosLength) = 0;
-
- virtual ~GMPDecryptorCallback() {}
-};
-
-enum GMPSessionType {
- kGMPTemporySession = 0,
- kGMPPersistentSession = 1,
- kGMPSessionInvalid = 2 // Must always be last.
-};
-
-#define GMP_API_DECRYPTOR "eme-decrypt-v9"
-
-// API exposed by plugin library to manage decryption sessions.
-// When the Host requests this by calling GMPGetAPIFunc().
-//
-// API name macro: GMP_API_DECRYPTOR
-class GMPDecryptor {
-public:
-
- // Sets the callback to use with the decryptor to return results
- // to Gecko.
- virtual void Init(GMPDecryptorCallback* aCallback,
- bool aDistinctiveIdentifierRequired,
- bool aPersistentStateRequired) = 0;
-
- // Initiates the creation of a session given |aType| and |aInitData|, and
- // the generation of a license request message.
- //
- // This corresponds to a MediaKeySession.generateRequest() call in JS.
- //
- // The GMPDecryptor must do the following, in order, upon this method
- // being called:
- //
- // 1. Generate a sessionId to expose to JS, and call
- // GMPDecryptorCallback::SetSessionId(aCreateSessionToken, sessionId...)
- // with the sessionId to be exposed to JS/EME on the MediaKeySession
- // object on which generateRequest() was called, and then
- // 2. send any messages to JS/EME required to generate a license request
- // given the supplied initData, and then
- // 3. generate a license request message, and send it to JS/EME, and then
- // 4. call GMPDecryptorCallback::ResolvePromise().
- //
- // Note: GMPDecryptorCallback::SetSessionId(aCreateSessionToken, sessionId, ...)
- // *must* be called before GMPDecryptorCallback::SendMessage(sessionId, ...)
- // will work.
- //
- // If generating the request fails, reject aPromiseId by calling
- // GMPDecryptorCallback::RejectPromise().
- virtual void CreateSession(uint32_t aCreateSessionToken,
- uint32_t aPromiseId,
- const char* aInitDataType,
- uint32_t aInitDataTypeSize,
- const uint8_t* aInitData,
- uint32_t aInitDataSize,
- GMPSessionType aSessionType) = 0;
-
- // Loads a previously loaded persistent session.
- //
- // This corresponds to a MediaKeySession.load() call in JS.
- //
- // The GMPDecryptor must do the following, in order, upon this method
- // being called:
- //
- // 1. Send any messages to JS/EME, or read from storage, whatever is
- // required to load the session, and then
- // 2. if there is no session with the given sessionId loadable, call
- // ResolveLoadSessionPromise(aPromiseId, false), otherwise
- // 2. mark the session's keys as usable, and then
- // 3. update the session's expiration, and then
- // 4. call GMPDecryptorCallback::ResolveLoadSessionPromise(aPromiseId, true).
- //
- // If loading the session fails due to error, reject aPromiseId by calling
- // GMPDecryptorCallback::RejectPromise().
- virtual void LoadSession(uint32_t aPromiseId,
- const char* aSessionId,
- uint32_t aSessionIdLength) = 0;
-
- // Updates the session with |aResponse|.
- // This corresponds to a MediaKeySession.update() call in JS.
- virtual void UpdateSession(uint32_t aPromiseId,
- const char* aSessionId,
- uint32_t aSessionIdLength,
- const uint8_t* aResponse,
- uint32_t aResponseSize) = 0;
-
- // Releases the resources (keys) for the specified session.
- // This corresponds to a MediaKeySession.close() call in JS.
- virtual void CloseSession(uint32_t aPromiseId,
- const char* aSessionId,
- uint32_t aSessionIdLength) = 0;
-
- // Removes the resources (keys) for the specified session.
- // This corresponds to a MediaKeySession.remove() call in JS.
- virtual void RemoveSession(uint32_t aPromiseId,
- const char* aSessionId,
- uint32_t aSessionIdLength) = 0;
-
- // Resolve/reject promise on completion.
- // This corresponds to a MediaKeySession.setServerCertificate() call in JS.
- virtual void SetServerCertificate(uint32_t aPromiseId,
- const uint8_t* aServerCert,
- uint32_t aServerCertSize) = 0;
-
- // Asynchronously decrypts aBuffer in place. When the decryption is
- // complete, GMPDecryptor should write the decrypted data back into the
- // same GMPBuffer object and return it to Gecko by calling Decrypted(),
- // with the GMPNoErr successcode. If decryption fails, call Decrypted()
- // with a failure code, and an error event will fire on the media element.
- // Note: When Decrypted() is called and aBuffer is passed back, aBuffer
- // is deleted. Don't forget to call Decrypted(), as otherwise aBuffer's
- // memory will leak!
- virtual void Decrypt(GMPBuffer* aBuffer,
- GMPEncryptedBufferMetadata* aMetadata) = 0;
-
- // Called when the decryption operations are complete.
- // Do not call the GMPDecryptorCallback's functions after this is called.
- virtual void DecryptingComplete() = 0;
-
- virtual ~GMPDecryptor() {}
-};
-
-#endif // GMP_DECRYPTION_h_
--- a/dom/media/gmp/gmp-api/gmp-video-frame-encoded.h
+++ b/dom/media/gmp/gmp-api/gmp-video-frame-encoded.h
@@ -30,17 +30,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GMP_VIDEO_FRAME_ENCODED_h_
#define GMP_VIDEO_FRAME_ENCODED_h_
#include <stdint.h>
-#include "gmp-decryption.h"
#include "gmp-video-frame.h"
#include "gmp-video-codec.h"
enum GMPVideoFrameType
{
kGMPKeyFrame = 0,
kGMPDeltaFrame = 1,
kGMPGoldenFrame = 2,
@@ -85,15 +84,11 @@ public:
virtual void SetSize(uint32_t aSize) = 0;
virtual uint32_t Size() = 0;
virtual void SetCompleteFrame(bool aCompleteFrame) = 0;
virtual bool CompleteFrame() = 0;
virtual const uint8_t* Buffer() const = 0;
virtual uint8_t* Buffer() = 0;
virtual GMPBufferType BufferType() const = 0;
virtual void SetBufferType(GMPBufferType aBufferType) = 0;
-
- // Get metadata describing how this frame is encrypted, or nullptr if the
- // frame is not encrypted.
- virtual const GMPEncryptedBufferMetadata* GetDecryptionData() const = 0;
};
#endif // GMP_VIDEO_FRAME_ENCODED_h_
--- a/dom/media/gmp/moz.build
+++ b/dom/media/gmp/moz.build
@@ -11,38 +11,34 @@ XPIDL_SOURCES += [
'mozIGeckoMediaPluginService.idl',
]
EXPORTS += [
'ChromiumCDMCallback.h',
'ChromiumCDMParent.h',
'ChromiumCDMProxy.h',
'DecryptJob.h',
- 'gmp-api/gmp-decryption.h',
'gmp-api/gmp-entrypoints.h',
'gmp-api/gmp-errors.h',
'gmp-api/gmp-platform.h',
'gmp-api/gmp-storage.h',
'gmp-api/gmp-video-codec.h',
'gmp-api/gmp-video-decode.h',
'gmp-api/gmp-video-encode.h',
'gmp-api/gmp-video-frame-encoded.h',
'gmp-api/gmp-video-frame-i420.h',
'gmp-api/gmp-video-frame.h',
'gmp-api/gmp-video-host.h',
'gmp-api/gmp-video-plane.h',
'GMPCallbackBase.h',
- 'GMPCDMCallbackProxy.h',
'GMPChild.h',
'GMPContentChild.h',
'GMPContentParent.h',
'GMPCrashHelper.h',
'GMPCrashHelperHolder.h',
- 'GMPDecryptorProxy.h',
- 'GMPEncryptedBufferDataImpl.h',
'GMPLoader.h',
'GMPMessageUtils.h',
'GMPParent.h',
'GMPPlatform.h',
'GMPProcessChild.h',
'GMPProcessParent.h',
'GMPService.h',
'GMPServiceChild.h',
@@ -71,24 +67,22 @@ EXPORTS += [
UNIFIED_SOURCES += [
'ChromiumCDMAdapter.cpp',
'ChromiumCDMCallbackProxy.cpp',
'ChromiumCDMChild.cpp',
'ChromiumCDMParent.cpp',
'ChromiumCDMProxy.cpp',
'DecryptJob.cpp',
- 'GMPCDMCallbackProxy.cpp',
'GMPChild.cpp',
'GMPContentChild.cpp',
'GMPContentParent.cpp',
'GMPCrashHelper.cpp',
'GMPCrashHelperHolder.cpp',
'GMPDiskStorage.cpp',
- 'GMPEncryptedBufferDataImpl.cpp',
'GMPLoader.cpp',
'GMPMemoryStorage.cpp',
'GMPParent.cpp',
'GMPPlatform.cpp',
'GMPProcessChild.cpp',
'GMPProcessParent.cpp',
'GMPService.cpp',
'GMPServiceChild.cpp',
--- a/dom/media/gmp/widevine-adapter/WidevineUtils.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineUtils.cpp
@@ -22,42 +22,16 @@ ToGMPErr(cdm::Status aStatus)
case cdm::kInitializationError: return GMPGenericErr;
case cdm::kDecryptError: return GMPCryptoErr;
case cdm::kDecodeError: return GMPDecodeErr;
case cdm::kDeferredInitialization: return GMPGenericErr;
default: return GMPGenericErr;
}
}
-void InitInputBuffer(const GMPEncryptedBufferMetadata* aCrypto,
- int64_t aTimestamp,
- const uint8_t* aData,
- size_t aDataSize,
- cdm::InputBuffer &aInputBuffer,
- nsTArray<cdm::SubsampleEntry> &aSubsamples)
-{
- if (aCrypto) {
- aInputBuffer.key_id = aCrypto->KeyId();
- aInputBuffer.key_id_size = aCrypto->KeyIdSize();
- aInputBuffer.iv = aCrypto->IV();
- aInputBuffer.iv_size = aCrypto->IVSize();
- aInputBuffer.num_subsamples = aCrypto->NumSubsamples();
- aSubsamples.SetCapacity(aInputBuffer.num_subsamples);
- const uint16_t* clear = aCrypto->ClearBytes();
- const uint32_t* cipher = aCrypto->CipherBytes();
- for (size_t i = 0; i < aCrypto->NumSubsamples(); i++) {
- aSubsamples.AppendElement(cdm::SubsampleEntry(clear[i], cipher[i]));
- }
- }
- aInputBuffer.data = aData;
- aInputBuffer.data_size = aDataSize;
- aInputBuffer.subsamples = aSubsamples.Elements();
- aInputBuffer.timestamp = aTimestamp;
-}
-
WidevineBuffer::WidevineBuffer(size_t aSize)
{
GMP_LOG("WidevineBuffer(size=%zu) created", aSize);
mBuffer.SetLength(aSize);
}
WidevineBuffer::~WidevineBuffer()
{
--- a/dom/media/gmp/widevine-adapter/WidevineUtils.h
+++ b/dom/media/gmp/widevine-adapter/WidevineUtils.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 WidevineUtils_h_
#define WidevineUtils_h_
#include "stddef.h"
#include "content_decryption_module.h"
-#include "gmp-api/gmp-decryption.h"
#include "gmp-api/gmp-platform.h"
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include "mozilla/Logging.h"
namespace mozilla {
#define ENSURE_TRUE(condition, rv) \
@@ -30,23 +29,16 @@ namespace mozilla {
GMP_LOG("ENSURE_GMP_SUCCESS FAILED %s:%d", __FILE__, __LINE__); \
return rv; \
} \
}
GMPErr
ToGMPErr(cdm::Status aStatus);
-void InitInputBuffer(const GMPEncryptedBufferMetadata* aCrypto,
- int64_t aTimestamp,
- const uint8_t* aData,
- size_t aDataSize,
- cdm::InputBuffer &aInputBuffer,
- nsTArray<cdm::SubsampleEntry> &aSubsamples);
-
namespace gmp {
class CDMShmemBuffer;
}
class WidevineBuffer;
// Base class for our cdm::Buffer implementations, so we can tell at runtime
// whether the buffer is a Shmem or non-Shmem buffer.
class CDMBuffer : public cdm::Buffer
--- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
@@ -5,17 +5,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "EMEDecoderModule.h"
#include "GMPDecoderModule.h"
#include "GMPService.h"
#include "MediaInfo.h"
#include "MediaPrefs.h"
#include "PDMFactory.h"
-#include "gmp-decryption.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/CDMProxy.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/Unused.h"
#include "nsAutoPtr.h"
#include "nsClassHashtable.h"
#include "nsServiceManagerUtils.h"
#include "DecryptThroughputLimit.h"