From a7ef15b6b886dd012d3587e5be0bfbadd53cb4fa Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Tue, 12 Apr 2016 16:12:22 +1200 Subject: [PATCH] Bug 1245789 - Reject MediaKeys requests for Widevine if we don't have a platform AAC decoder. r=gerald 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 | 28 ++++++++++++++++++++++++-- dom/media/gmp/GMPParent.cpp | 5 ----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/dom/media/eme/MediaKeySystemAccess.cpp b/dom/media/eme/MediaKeySystemAccess.cpp index 5e9f36fa0154..e84ca69ee168 100644 --- a/dom/media/eme/MediaKeySystemAccess.cpp +++ b/dom/media/eme/MediaKeySystemAccess.cpp @@ -14,6 +14,7 @@ #endif #ifdef XP_WIN #include "mozilla/WindowsVersion.h" +#include "WMFDecoderModule.h" #endif #ifdef XP_MACOSX #include "nsCocoaFeatures.h" @@ -381,7 +382,15 @@ GMPDecryptsAndGeckoDecodesAAC(mozIGeckoMediaPluginService* 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 @@ -439,7 +448,11 @@ 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)"))); } @@ -491,6 +504,17 @@ GetSupportedConfig(mozIGeckoMediaPluginService* aGMPService, 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; diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index cfe95f6789f5..8ea273c15a35 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -953,11 +953,6 @@ GMPParent::ParseChromiumManifest(nsString aJSON) 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"));