Bug 1121332. Part 2 - expose media key status from CDMCaps. r=cpearce a=lmandel
--- a/dom/media/eme/CDMCaps.cpp
+++ b/dom/media/eme/CDMCaps.cpp
@@ -166,20 +166,20 @@ CDMCaps::AutoLock::CanDecryptAudio()
bool
CDMCaps::AutoLock::CanDecryptVideo()
{
return mData.HasCap(GMP_EME_CAP_DECRYPT_VIDEO);
}
void
-CDMCaps::AutoLock::GetUsableKeysForSession(const nsAString& aSessionId,
- nsTArray<CencKeyId>& aOutKeyIds)
+CDMCaps::AutoLock::GetKeyStatusesForSession(const nsAString& aSessionId,
+ nsTArray<KeyStatus>& aOutKeyStatuses)
{
for (size_t i = 0; i < mData.mKeyStatuses.Length(); i++) {
const auto& key = mData.mKeyStatuses[i];
- if (key.mSessionId.Equals(aSessionId) && key.mStatus == kGMPUsable) {
- aOutKeyIds.AppendElement(key.mId);
+ if (key.mSessionId.Equals(aSessionId)) {
+ aOutKeyStatuses.AppendElement(key);
}
}
}
} // namespace mozilla
--- a/dom/media/eme/CDMCaps.h
+++ b/dom/media/eme/CDMCaps.h
@@ -20,16 +20,39 @@ namespace mozilla {
// CDM capabilities; what keys a CDMProxy can use, and whether it can decrypt, or
// decrypt-and-decode on a per stream basis. Must be locked to access state.
class CDMCaps {
public:
CDMCaps();
~CDMCaps();
+ struct KeyStatus {
+ KeyStatus(const CencKeyId& aId,
+ const nsString& aSessionId,
+ GMPMediaKeyStatus aStatus)
+ : mId(aId)
+ , mSessionId(aSessionId)
+ , mStatus(aStatus)
+ {}
+ KeyStatus(const KeyStatus& aOther)
+ : mId(aOther.mId)
+ , mSessionId(aOther.mSessionId)
+ , mStatus(aOther.mStatus)
+ {}
+ bool operator==(const KeyStatus& aOther) const {
+ return mId == aOther.mId &&
+ mSessionId == aOther.mSessionId;
+ };
+
+ CencKeyId mId;
+ nsString mSessionId;
+ GMPMediaKeyStatus mStatus;
+ };
+
// Locks the CDMCaps. It must be locked to access its shared state.
// Threadsafe when locked.
class MOZ_STACK_CLASS AutoLock {
public:
explicit AutoLock(CDMCaps& aKeyCaps);
~AutoLock();
// Returns true if the capabilities of the CDM are known, i.e. they have
@@ -37,18 +60,18 @@ public:
bool AreCapsKnown();
bool IsKeyUsable(const CencKeyId& aKeyId);
// Returns true if key status changed,
// i.e. the key status changed from usable to expired.
bool SetKeyStatus(const CencKeyId& aKeyId, const nsString& aSessionId, GMPMediaKeyStatus aStatus);
- void GetUsableKeysForSession(const nsAString& aSessionId,
- nsTArray<CencKeyId>& aOutKeyIds);
+ void GetKeyStatusesForSession(const nsAString& aSessionId,
+ nsTArray<KeyStatus>& aOutKeyStatuses);
// Sets the capabilities of the CDM. aCaps is the logical OR of the
// GMP_EME_CAP_* flags from gmp-decryption.h.
void SetCaps(uint64_t aCaps);
bool CanDecryptAndDecodeAudio();
bool CanDecryptAndDecodeVideo();
@@ -77,38 +100,16 @@ private:
, mListener(aListener)
{}
CencKeyId mKeyId;
nsRefPtr<SamplesWaitingForKey> mListener;
};
Monitor mMonitor;
- struct KeyStatus {
- KeyStatus(const CencKeyId& aId,
- const nsString& aSessionId,
- GMPMediaKeyStatus aStatus)
- : mId(aId)
- , mSessionId(aSessionId)
- , mStatus(aStatus)
- {}
- KeyStatus(const KeyStatus& aOther)
- : mId(aOther.mId)
- , mSessionId(aOther.mSessionId)
- , mStatus(aOther.mStatus)
- {}
- bool operator==(const KeyStatus& aOther) const {
- return mId == aOther.mId &&
- mSessionId == aOther.mSessionId;
- };
-
- CencKeyId mId;
- nsString mSessionId;
- GMPMediaKeyStatus mStatus;
- };
nsTArray<KeyStatus> mKeyStatuses;
nsTArray<WaitForKeys> mWaitForKeys;
nsTArray<nsRefPtr<nsIRunnable>> mWaitForCaps;
uint64_t mCaps;
// It is not safe to copy this object.