Bug 1139270 - mark kGMPOutputDownscaled keys able to decrypt. r=cpearce a=lmandel
authorJW Wang <jwwang@mozilla.com>
Wed, 04 Mar 2015 22:26:23 +1300
changeset 250290 a73d01c8d332
parent 250289 68707623b5a3
child 250291 c1eb69b107d9
push id4536
push usercpearce@mozilla.com
push date2015-03-06 21:19 +0000
treeherdermozilla-beta@a73d01c8d332 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1139270
milestone37.0
Bug 1139270 - mark kGMPOutputDownscaled keys able to decrypt. r=cpearce a=lmandel
dom/media/eme/CDMCaps.cpp
--- a/dom/media/eme/CDMCaps.cpp
+++ b/dom/media/eme/CDMCaps.cpp
@@ -76,17 +76,21 @@ CDMCaps::AutoLock::CallOnMainThreadWhenC
 }
 
 bool
 CDMCaps::AutoLock::IsKeyUsable(const CencKeyId& aKeyId)
 {
   mData.mMonitor.AssertCurrentThreadOwns();
   const auto& keys = mData.mKeyStatuses;
   for (size_t i = 0; i < keys.Length(); i++) {
-    if (keys[i].mId == aKeyId && keys[i].mStatus == kGMPUsable) {
+    if (keys[i].mId != aKeyId) {
+      continue;
+    }
+    if (keys[i].mStatus == kGMPUsable ||
+        keys[i].mStatus == kGMPOutputDownscaled) {
       return true;
     }
   }
   return false;
 }
 
 bool
 CDMCaps::AutoLock::SetKeyStatus(const CencKeyId& aKeyId,
@@ -101,22 +105,30 @@ CDMCaps::AutoLock::SetKeyStatus(const Ce
     // Return true if the element is found to notify key changes.
     return mData.mKeyStatuses.RemoveElement(key);
   }
 
   if (index != mData.mKeyStatuses.NoIndex) {
     if (mData.mKeyStatuses[index].mStatus == aStatus) {
       return false;
     }
+    auto oldStatus = mData.mKeyStatuses[index].mStatus;
     mData.mKeyStatuses[index].mStatus = aStatus;
+    if (oldStatus == kGMPUsable || oldStatus == kGMPOutputDownscaled) {
+      return true;
+    }
   } else {
     mData.mKeyStatuses.AppendElement(key);
   }
 
-  if (aStatus != kGMPUsable) {
+  // Both kGMPUsable and kGMPOutputDownscaled are treated able to decrypt.
+  // We don't need to notify when transition happens between kGMPUsable and
+  // kGMPOutputDownscaled. Only call NotifyUsable() when we are going from
+  // ![kGMPUsable|kGMPOutputDownscaled] to [kGMPUsable|kGMPOutputDownscaled]
+  if (aStatus != kGMPUsable && aStatus != kGMPOutputDownscaled) {
     return true;
   }
 
   auto& waiters = mData.mWaitForKeys;
   size_t i = 0;
   while (i < waiters.Length()) {
     auto& w = waiters[i];
     if (w.mKeyId == aKeyId) {