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