summaryrefslogtreecommitdiff
path: root/dom/media/eme/CDMCaps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/eme/CDMCaps.cpp')
-rw-r--r--dom/media/eme/CDMCaps.cpp36
1 files changed, 15 insertions, 21 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;
}