summaryrefslogtreecommitdiff
path: root/dom/media/eme/CDMCaps.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-23 10:25:15 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-23 10:29:19 -0500
commit5513afc0d22151a69dbee6abe6f7655892f4b59e (patch)
tree70dcda341ed73246a981e2c13a680850824f0f50 /dom/media/eme/CDMCaps.cpp
parent38e595cb2d37cb30b094e9e79c9a73ef16baab1a (diff)
downloaduxp-eme.tar.gz
Issue #26 - Undo Bug 1290830 - Make Decryptor APIs reusable by not only GMP framework - Part 1: Reverse patch applicable hunks (Auto)eme
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;
}