diff options
-rw-r--r-- | dom/media/eme/CDMCaps.cpp | 36 | ||||
-rw-r--r-- | dom/media/eme/CDMCaps.h | 19 | ||||
-rw-r--r-- | dom/media/eme/CDMProxy.h | 4 | ||||
-rw-r--r-- | dom/media/eme/DecryptorProxyCallback.h | 9 | ||||
-rw-r--r-- | dom/media/eme/MediaKeySession.cpp | 3 | ||||
-rw-r--r-- | dom/media/eme/MediaKeyStatusMap.cpp | 24 | ||||
-rw-r--r-- | dom/media/eme/moz.build | 1 | ||||
-rw-r--r-- | dom/media/gmp/GMPCDMCallbackProxy.cpp | 15 | ||||
-rw-r--r-- | dom/media/gmp/GMPCDMCallbackProxy.h | 4 | ||||
-rw-r--r-- | dom/media/gmp/GMPCDMProxy.h | 2 | ||||
-rw-r--r-- | dom/media/gmp/GMPDecryptorParent.cpp | 30 | ||||
-rw-r--r-- | dom/media/gmp/GMPDecryptorProxy.h | 40 | ||||
-rw-r--r-- | dom/media/gtest/TestGMPCrossOrigin.cpp | 6 | ||||
-rw-r--r-- | dom/media/moz.build | 3 |
14 files changed, 102 insertions, 94 deletions
diff --git a/dom/media/eme/CDMCaps.cpp b/dom/media/eme/CDMCaps.cpp index 20ff63bad5..474ae70fc4 100644 --- a/dom/media/eme/CDMCaps.cpp +++ b/dom/media/eme/CDMCaps.cpp @@ -43,15 +43,14 @@ CDMCaps::AutoLock::~AutoLock() mData.Unlock(); } -// Keys with MediaKeyStatus::Usable, MediaKeyStatus::Output_downscaled, -// or MediaKeyStatus::Output_restricted status can be used by the CDM -// to decrypt or decrypt-and-decode samples. +// Keys with kGMPUsable, kGMPOutputDownscaled, or kGMPOutputRestricted status +// can be used by the CDM to decrypt or decrypt-and-decode samples. static bool -IsUsableStatus(dom::MediaKeyStatus aStatus) +IsUsableStatus(GMPMediaKeyStatus aStatus) { - return aStatus == dom::MediaKeyStatus::Usable || - aStatus == dom::MediaKeyStatus::Output_restricted || - aStatus == dom::MediaKeyStatus::Output_downscaled; + return aStatus == kGMPUsable || + aStatus == kGMPOutputRestricted || + aStatus == kGMPOutputDownscaled; } bool @@ -69,27 +68,24 @@ CDMCaps::AutoLock::IsKeyUsable(const CencKeyId& aKeyId) bool CDMCaps::AutoLock::SetKeyStatus(const CencKeyId& aKeyId, const nsString& aSessionId, - const dom::Optional<dom::MediaKeyStatus>& aStatus) + GMPMediaKeyStatus aStatus) { mData.mMonitor.AssertCurrentThreadOwns(); + KeyStatus key(aKeyId, aSessionId, aStatus); - if (!aStatus.WasPassed()) { - // Called from ForgetKeyStatus. + if (aStatus == kGMPUnknown) { // Return true if the element is found to notify key changes. - return mData.mKeyStatuses.RemoveElement(KeyStatus(aKeyId, - aSessionId, - dom::MediaKeyStatus::Internal_error)); + return mData.mKeyStatuses.RemoveElement(key); } - KeyStatus key(aKeyId, aSessionId, aStatus.Value()); auto index = mData.mKeyStatuses.IndexOf(key); if (index != mData.mKeyStatuses.NoIndex) { - if (mData.mKeyStatuses[index].mStatus == aStatus.Value()) { + if (mData.mKeyStatuses[index].mStatus == aStatus) { // No change. return false; } auto oldStatus = mData.mKeyStatuses[index].mStatus; - mData.mKeyStatuses[index].mStatus = aStatus.Value(); + mData.mKeyStatuses[index].mStatus = aStatus; // The old key status was one for which we can decrypt media. We don't // need to do the "notify usable" step below, as it should be impossible // for us to have anything waiting on this key to become usable, since it @@ -103,7 +99,7 @@ CDMCaps::AutoLock::SetKeyStatus(const CencKeyId& aKeyId, // Only call NotifyUsable() for a key when we are going from non-usable // to usable state. - if (!IsUsableStatus(aStatus.Value())) { + if (!IsUsableStatus(aStatus)) { return true; } @@ -159,10 +155,8 @@ CDMCaps::AutoLock::RemoveKeysForSession(const nsString& aSessionId) bool changed = false; nsTArray<KeyStatus> statuses; GetKeyStatusesForSession(aSessionId, statuses); - for (const KeyStatus& status : statuses) { - changed |= SetKeyStatus(status.mId, - aSessionId, - dom::Optional<dom::MediaKeyStatus>()); + for (const KeyStatus& keyStatus : statuses) { + changed |= SetKeyStatus(keyStatus.mId, aSessionId, kGMPUnknown); } return changed; } diff --git a/dom/media/eme/CDMCaps.h b/dom/media/eme/CDMCaps.h index 7749bdc675..87fd2fec35 100644 --- a/dom/media/eme/CDMCaps.h +++ b/dom/media/eme/CDMCaps.h @@ -7,16 +7,13 @@ #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 "nsIThread.h" +#include "nsTArray.h" #include "mozilla/Attributes.h" -#include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus -#include "mozilla/dom/BindingDeclarations.h" // For Optional +#include "SamplesWaitingForKey.h" +#include "gmp-decryption.h" namespace mozilla { @@ -30,7 +27,7 @@ public: struct KeyStatus { KeyStatus(const CencKeyId& aId, const nsString& aSessionId, - dom::MediaKeyStatus aStatus) + GMPMediaKeyStatus aStatus) : mId(aId) , mSessionId(aSessionId) , mStatus(aStatus) @@ -47,7 +44,7 @@ public: CencKeyId mId; nsString mSessionId; - dom::MediaKeyStatus mStatus; + GMPMediaKeyStatus mStatus; }; // Locks the CDMCaps. It must be locked to access its shared state. @@ -61,9 +58,7 @@ public: // Returns true if key status changed, // i.e. the key status changed from usable to expired. - bool SetKeyStatus(const CencKeyId& aKeyId, - const nsString& aSessionId, - const dom::Optional<dom::MediaKeyStatus>& aStatus); + bool SetKeyStatus(const CencKeyId& aKeyId, const nsString& aSessionId, GMPMediaKeyStatus aStatus); void GetKeyStatusesForSession(const nsAString& aSessionId, nsTArray<KeyStatus>& aOutKeyStatuses); diff --git a/dom/media/eme/CDMProxy.h b/dom/media/eme/CDMProxy.h index f3f1add43f..46df81c1dc 100644 --- a/dom/media/eme/CDMProxy.h +++ b/dom/media/eme/CDMProxy.h @@ -61,8 +61,6 @@ public: dom::Optional<dom::MediaKeyStatus> mStatus; }; -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 @@ -173,7 +171,7 @@ public: // Main thread only. virtual void OnExpirationChange(const nsAString& aSessionId, - UnixTime aExpiryTime) = 0; + int64_t aExpiryTime) = 0; // Main thread only. virtual void OnSessionClosed(const nsAString& aSessionId) = 0; diff --git a/dom/media/eme/DecryptorProxyCallback.h b/dom/media/eme/DecryptorProxyCallback.h index c1fcb49a4f..248d37c4c3 100644 --- a/dom/media/eme/DecryptorProxyCallback.h +++ b/dom/media/eme/DecryptorProxyCallback.h @@ -6,13 +6,8 @@ #ifndef DecryptorProxyCallback_h_ #define DecryptorProxyCallback_h_ -#include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus -#include "mozilla/dom/MediaKeyMessageEventBinding.h" // For MediaKeyMessageType -#include "mozilla/CDMProxy.h" - class DecryptorProxyCallback { public: - virtual ~DecryptorProxyCallback() {} virtual void SetDecryptorId(uint32_t aId) = 0; @@ -30,11 +25,11 @@ public: const nsCString& aSessionId) = 0; virtual void SessionMessage(const nsCString& aSessionId, - mozilla::dom::MediaKeyMessageType aMessageType, + GMPSessionMessageType aMessageType, const nsTArray<uint8_t>& aMessage) = 0; virtual void ExpirationChange(const nsCString& aSessionId, - mozilla::UnixTime aExpiryTime) = 0; + GMPTimestamp aExpiryTime) = 0; virtual void SessionClosed(const nsCString& aSessionId) = 0; diff --git a/dom/media/eme/MediaKeySession.cpp b/dom/media/eme/MediaKeySession.cpp index d5eff3f773..72585d272c 100644 --- a/dom/media/eme/MediaKeySession.cpp +++ b/dom/media/eme/MediaKeySession.cpp @@ -154,10 +154,9 @@ MediaKeySession::UpdateKeyStatusMap() nsAutoCString message( nsPrintfCString("MediaKeySession[%p,'%s'] key statuses change {", this, NS_ConvertUTF16toUTF8(mSessionId).get())); - using IntegerType = typename std::underlying_type<MediaKeyStatus>::type; for (const CDMCaps::KeyStatus& status : keyStatuses) { message.Append(nsPrintfCString(" (%s,%s)", ToBase64(status.mId).get(), - MediaKeyStatusValues::strings[static_cast<IntegerType>(status.mStatus)].value)); + MediaKeyStatusValues::strings[status.mStatus].value)); } message.Append(" }"); EME_LOG(message.get()); diff --git a/dom/media/eme/MediaKeyStatusMap.cpp b/dom/media/eme/MediaKeyStatusMap.cpp index 5af6ff5358..d2dbe00bb8 100644 --- a/dom/media/eme/MediaKeyStatusMap.cpp +++ b/dom/media/eme/MediaKeyStatusMap.cpp @@ -55,10 +55,10 @@ MediaKeyStatusMap::Get(JSContext* aCx, } for (const KeyStatus& status : mStatuses) { if (keyId == status.mKeyId) { - bool ok = ToJSValue(aCx, status.mStatus, aOutValue);
- if (!ok) {
- aOutRv.NoteJSContextException(aCx);
- }
+ bool ok = ToJSValue(aCx, status.mStatus, aOutValue); + if (!ok) { + aOutRv.NoteJSContextException(aCx); + } return; } } @@ -108,12 +108,26 @@ MediaKeyStatusMap::Size() const return mStatuses.Length(); } +static MediaKeyStatus +ToMediaKeyStatus(GMPMediaKeyStatus aStatus) { + switch (aStatus) { + case kGMPUsable: return MediaKeyStatus::Usable; + case kGMPExpired: return MediaKeyStatus::Expired; + case kGMPOutputDownscaled: return MediaKeyStatus::Output_downscaled; + case kGMPOutputRestricted: return MediaKeyStatus::Output_restricted; + case kGMPInternalError: return MediaKeyStatus::Internal_error; + case kGMPReleased: return MediaKeyStatus::Released; + case kGMPStatusPending: return MediaKeyStatus::Status_pending; + default: return MediaKeyStatus::Internal_error; + } +} + void MediaKeyStatusMap::Update(const nsTArray<CDMCaps::KeyStatus>& aKeys) { mStatuses.Clear(); for (const auto& key : aKeys) { - mStatuses.InsertElementSorted(KeyStatus(key.mId, key.mStatus)); + mStatuses.InsertElementSorted(KeyStatus(key.mId, ToMediaKeyStatus(key.mStatus))); } } diff --git a/dom/media/eme/moz.build b/dom/media/eme/moz.build index 47e622ae36..46c5c88e1d 100644 --- a/dom/media/eme/moz.build +++ b/dom/media/eme/moz.build @@ -18,7 +18,6 @@ EXPORTS.mozilla.dom += [ EXPORTS.mozilla += [ 'CDMCaps.h', 'CDMProxy.h', - 'DecryptorProxyCallback.h', 'DetailedPromise.h', 'EMEUtils.h', ] diff --git a/dom/media/gmp/GMPCDMCallbackProxy.cpp b/dom/media/gmp/GMPCDMCallbackProxy.cpp index 0cbc89fffa..a469407fd4 100644 --- a/dom/media/gmp/GMPCDMCallbackProxy.cpp +++ b/dom/media/gmp/GMPCDMCallbackProxy.cpp @@ -224,14 +224,25 @@ GMPCDMCallbackProxy::BatchedKeyStatusChangedInternal(const nsCString& aSessionId } } +DecryptStatus +ToDecryptStatus(GMPErr aError) +{ + switch (aError) { + case GMPNoErr: return Ok; + case GMPNoKeyErr: return NoKeyErr; + case GMPAbortedErr: return AbortedErr; + default: return GenericErr; + } +} + void GMPCDMCallbackProxy::Decrypted(uint32_t aId, - DecryptStatus aResult, + GMPErr aResult, const nsTArray<uint8_t>& aDecryptedData) { MOZ_ASSERT(mProxy->IsOnOwnerThread()); - mProxy->OnDecrypted(aId, aResult, aDecryptedData); + mProxy->OnDecrypted(aId, ToDecryptStatus(aResult), aDecryptedData); } void diff --git a/dom/media/gmp/GMPCDMCallbackProxy.h b/dom/media/gmp/GMPCDMCallbackProxy.h index 3f396f597e..daa6f07f71 100644 --- a/dom/media/gmp/GMPCDMCallbackProxy.h +++ b/dom/media/gmp/GMPCDMCallbackProxy.h @@ -33,11 +33,11 @@ public: const nsCString& aSessionId) override; void SessionMessage(const nsCString& aSessionId, - dom::MediaKeyMessageType aMessageType, + GMPSessionMessageType aMessageType, const nsTArray<uint8_t>& aMessage) override; void ExpirationChange(const nsCString& aSessionId, - UnixTime aExpiryTime) override; + GMPTimestamp aExpiryTime) override; void SessionClosed(const nsCString& aSessionId) override; diff --git a/dom/media/gmp/GMPCDMProxy.h b/dom/media/gmp/GMPCDMProxy.h index 84b59d9e43..ec3f8c14f6 100644 --- a/dom/media/gmp/GMPCDMProxy.h +++ b/dom/media/gmp/GMPCDMProxy.h @@ -238,6 +238,8 @@ private: GMPDecryptorProxy* mCDM; + CDMCaps mCapabilites; + nsAutoPtr<GMPCDMCallbackProxy> mCallback; // Decryption jobs sent to CDM, awaiting result. diff --git a/dom/media/gmp/GMPDecryptorParent.cpp b/dom/media/gmp/GMPDecryptorParent.cpp index 1f8b9a7a8e..b5595f825b 100644 --- a/dom/media/gmp/GMPDecryptorParent.cpp +++ b/dom/media/gmp/GMPDecryptorParent.cpp @@ -277,18 +277,6 @@ GMPDecryptorParent::RecvRejectPromise(const uint32_t& aPromiseId, return true; } - -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; - }; -}; - bool GMPDecryptorParent::RecvSessionMessage(const nsCString& aSessionId, const GMPSessionMessageType& aMessageType, @@ -301,7 +289,7 @@ GMPDecryptorParent::RecvSessionMessage(const nsCString& aSessionId, NS_WARNING("Trying to use a dead GMP decrypter!"); return false; } - mCallback->SessionMessage(aSessionId, ToMediaKeyMessageType(aMessageType), aMessage); + mCallback->SessionMessage(aSessionId, aMessageType, aMessage); return true; } @@ -355,20 +343,6 @@ GMPDecryptorParent::RecvSessionError(const nsCString& aSessionId, return true; } -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; - } -} - bool GMPDecryptorParent::RecvBatchedKeyStatusChanged(const nsCString& aSessionId, InfallibleTArray<GMPKeyInformation>&& aKeyInfos) @@ -418,7 +392,7 @@ GMPDecryptorParent::RecvDecrypted(const uint32_t& aId, NS_WARNING("Trying to use a dead GMP decrypter!"); return false; } - mCallback->Decrypted(aId, ToDecryptStatus(aErr), aBuffer); + mCallback->Decrypted(aId, aErr, aBuffer); return true; } diff --git a/dom/media/gmp/GMPDecryptorProxy.h b/dom/media/gmp/GMPDecryptorProxy.h index 0ef31fd92d..a0fa5c1595 100644 --- a/dom/media/gmp/GMPDecryptorProxy.h +++ b/dom/media/gmp/GMPDecryptorProxy.h @@ -6,7 +6,6 @@ #ifndef GMPDecryptorProxy_h_ #define GMPDecryptorProxy_h_ -#include "mozilla/DecryptorProxyCallback.h" #include "GMPCallbackBase.h" #include "gmp-decryption.h" #include "nsString.h" @@ -15,10 +14,43 @@ namespace mozilla { class CryptoSample; } // namespace mozilla -class GMPDecryptorProxyCallback : public DecryptorProxyCallback, - public GMPCallbackBase { +class GMPDecryptorProxyCallback : public GMPCallbackBase { public: - virtual ~GMPDecryptorProxyCallback() {} + ~GMPDecryptorProxyCallback() {} + + virtual void SetSessionId(uint32_t aCreateSessionId, + const nsCString& aSessionId) = 0; + + virtual void ResolveLoadSessionPromise(uint32_t aPromiseId, + bool aSuccess) = 0; + + virtual void ResolvePromise(uint32_t aPromiseId) = 0; + + virtual void RejectPromise(uint32_t aPromiseId, + nsresult aException, + const nsCString& aSessionId) = 0; + + virtual void SessionMessage(const nsCString& aSessionId, + GMPSessionMessageType aMessageType, + const nsTArray<uint8_t>& aMessage) = 0; + + virtual void ExpirationChange(const nsCString& aSessionId, + GMPTimestamp aExpiryTime) = 0; + + virtual void SessionClosed(const nsCString& aSessionId) = 0; + + virtual void SessionError(const nsCString& aSessionId, + nsresult aException, + uint32_t aSystemCode, + const nsCString& aMessage) = 0; + + virtual void KeyStatusChanged(const nsCString& aSessionId, + const nsTArray<uint8_t>& aKeyId, + GMPMediaKeyStatus aStatus) = 0; + + virtual void Decrypted(uint32_t aId, + GMPErr aResult, + const nsTArray<uint8_t>& aDecryptedData) = 0; }; class GMPDecryptorProxy { diff --git a/dom/media/gtest/TestGMPCrossOrigin.cpp b/dom/media/gtest/TestGMPCrossOrigin.cpp index 33ac983884..c5dc3e1198 100644 --- a/dom/media/gtest/TestGMPCrossOrigin.cpp +++ b/dom/media/gtest/TestGMPCrossOrigin.cpp @@ -22,8 +22,6 @@ #include "nsNSSComponent.h" #include "mozilla/DebugOnly.h" #include "GMPDeviceBinding.h" -#include "mozilla/dom/MediaKeyStatusMapBinding.h" // For MediaKeyStatus -#include "mozilla/dom/MediaKeyMessageEventBinding.h" // For MediaKeyMessageType #if defined(XP_WIN) #include "mozilla/WindowsVersion.h" @@ -1357,7 +1355,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback } void SessionMessage(const nsCString& aSessionId, - mozilla::dom::MediaKeyMessageType aMessageType, + GMPSessionMessageType aMessageType, const nsTArray<uint8_t>& aMessage) override { MonitorAutoLock mon(mMonitor); @@ -1394,7 +1392,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback nsresult aException, const nsCString& aSessionId) override { } void ExpirationChange(const nsCString& aSessionId, - UnixTime aExpiryTime) override {} + GMPTimestamp aExpiryTime) override {} void SessionClosed(const nsCString& aSessionId) override {} void SessionError(const nsCString& aSessionId, nsresult aException, diff --git a/dom/media/moz.build b/dom/media/moz.build index fb8788e728..b6d47f89f3 100644 --- a/dom/media/moz.build +++ b/dom/media/moz.build @@ -22,9 +22,6 @@ with Files('GetUserMedia*'): DIRS += [ 'encoder', 'flac', - 'gmp', - 'gmp-plugin', - 'gmp-plugin-openh264', 'imagecapture', 'ipc', 'mediasink', |