Bug 1245789 - Reject MediaKeys requests for Widevine if we don't have a platform AAC decoder. r=gerald,a=ritu
authorChris Pearce <cpearce@mozilla.com>
Tue, 12 Apr 2016 16:12:22 +1200
changeset 324042 b9a267eecc3c0986c0064f189e404395ca444e45
parent 324041 c95419cb1a3d1571a1b22d7d377d14593dbd0cb1
child 324043 71dd0336d62d611f515a0c23dade90da186a1b4a
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, ritu
bugs1245789
milestone47.0a2
Bug 1245789 - Reject MediaKeys requests for Widevine if we don't have a platform AAC decoder. r=gerald,a=ritu The Widevine CDM does not have an AAC decoder. It can however decrypt audio streams. It's our policy to not decode AAC streams decrypted by the Widevine CDM with the Adobe GMP's unencrypted decoding functionality. So reject MediaKeySystemAccess requests for Widevine if we don't have a system AAC decoder that we can use. MozReview-Commit-ID: Ltq52wT1qno
dom/media/eme/MediaKeySystemAccess.cpp
dom/media/gmp/GMPParent.cpp
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -9,16 +9,17 @@
 #include "mozilla/dom/MediaKeySystemAccessBinding.h"
 #include "mozilla/Preferences.h"
 #include "nsContentTypeParser.h"
 #ifdef MOZ_FMP4
 #include "MP4Decoder.h"
 #endif
 #ifdef XP_WIN
 #include "mozilla/WindowsVersion.h"
+#include "WMFDecoderModule.h"
 #endif
 #ifdef XP_MACOSX
 #include "nsCocoaFeatures.h"
 #endif
 #include "nsContentCID.h"
 #include "nsServiceManagerUtils.h"
 #include "mozIGeckoMediaPluginService.h"
 #include "VideoUtils.h"
@@ -376,17 +377,25 @@ GMPDecryptsAndGeckoDecodesAAC(mozIGeckoM
                         NS_ConvertUTF16toUTF8(aKeySystem),
                         NS_LITERAL_CSTRING(GMP_API_DECRYPTOR)));
   MOZ_ASSERT(IsAACContentType(aContentType));
 
   return !HaveGMPFor(aGMPService,
                      NS_ConvertUTF16toUTF8(aKeySystem),
                      NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER),
                      NS_LITERAL_CSTRING("aac")) &&
-         MP4Decoder::CanHandleMediaType(aContentType);
+#if defined(MOZ_WIDEVINE_EME) && defined(XP_WIN)
+         // Widevine CDM doesn't include an AAC decoder. So if WMF can't
+         // decode AAC, and a codec wasn't specified, be conservative
+         // and reject the MediaKeys request, since our policy is to prevent
+         //  the Adobe GMP's unencrypted AAC decoding path being used to
+         // decode content decrypted by the Widevine CDM.
+        (!aKeySystem.EqualsLiteral("com.widevine.alpha") || WMFDecoderModule::HasAAC()) &&
+#endif
+    MP4Decoder::CanHandleMediaType(aContentType);
 }
 
 static bool
 IsSupportedAudio(mozIGeckoMediaPluginService* aGMPService,
                  const nsAString& aKeySystem,
                  const nsAString& aAudioType)
 {
   return IsAACContentType(aAudioType) &&
@@ -434,17 +443,21 @@ IsSupported(mozIGeckoMediaPluginService*
 }
 
 static bool
 IsSupportedInitDataType(const nsString& aCandidate, const nsAString& aKeySystem)
 {
   // All supported keySystems can handle "cenc" initDataType.
   // ClearKey also supports "keyids" and "webm" initDataTypes.
   return aCandidate.EqualsLiteral("cenc") ||
-    (aKeySystem.EqualsLiteral("org.w3.clearkey") &&
+    ((aKeySystem.EqualsLiteral("org.w3.clearkey")
+#ifdef MOZ_WIDEVINE_EME
+    || aKeySystem.EqualsLiteral("com.widevine.alpha")
+#endif
+    ) &&
     (aCandidate.EqualsLiteral("keyids") || aCandidate.EqualsLiteral("webm)")));
 }
 
 static bool
 GetSupportedConfig(mozIGeckoMediaPluginService* aGMPService,
                    const nsAString& aKeySystem,
                    const MediaKeySystemConfiguration& aCandidate,
                    MediaKeySystemConfiguration& aOutConfig)
@@ -486,16 +499,27 @@ GetSupportedConfig(mozIGeckoMediaPluginS
     }
     if (caps.IsEmpty()) {
       return false;
     }
     config.mVideoCapabilities.Construct();
     config.mVideoCapabilities.Value().Assign(caps);
   }
 
+#if defined(MOZ_WIDEVINE_EME) && defined(XP_WIN)
+  // Widevine CDM doesn't include an AAC decoder. So if WMF can't decode AAC,
+  // and a codec wasn't specified, be conservative and reject the MediaKeys request.
+  if (aKeySystem.EqualsLiteral("com.widevine.alpha") &&
+      (!aCandidate.mAudioCapabilities.WasPassed() ||
+       !aCandidate.mVideoCapabilities.WasPassed()) &&
+     !WMFDecoderModule::HasAAC()) {
+    return false;
+  }
+#endif
+
   aOutConfig = config;
 
   return true;
 }
 
 // Backwards compatibility with legacy requestMediaKeySystemAccess with fields
 // from old MediaKeySystemOptions dictionary.
 /* static */
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -948,21 +948,16 @@ GMPParent::ParseChromiumManifest(nsStrin
                                  m.mX_cdm_host_versions.ToInteger(&ignored))) {
     return InitPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   mDisplayName = NS_ConvertUTF16toUTF8(m.mName);
   mDescription = NS_ConvertUTF16toUTF8(m.mDescription);
   mVersion = NS_ConvertUTF16toUTF8(m.mVersion);
 
-  GMPCapability audio(NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER));
-  audio.mAPITags.AppendElement(NS_LITERAL_CSTRING("aac"));
-  audio.mAPITags.AppendElement(NS_LITERAL_CSTRING("com.widevine.alpha"));
-  mCapabilities.AppendElement(Move(audio));
-
   GMPCapability video(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER));
   video.mAPITags.AppendElement(NS_LITERAL_CSTRING("h264"));
   video.mAPITags.AppendElement(NS_LITERAL_CSTRING("com.widevine.alpha"));
   mCapabilities.AppendElement(Move(video));
 
   GMPCapability decrypt(NS_LITERAL_CSTRING(GMP_API_DECRYPTOR));
   decrypt.mAPITags.AppendElement(NS_LITERAL_CSTRING("com.widevine.alpha"));
   mCapabilities.AppendElement(Move(decrypt));