/* static */ bool GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType, const Maybe<nsCString>& aGMP) { if (aGMP.isNothing()) { return false; } if (MP4Decoder::IsH264(aMimeType)) { return HaveGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), { NS_LITERAL_CSTRING("h264"), aGMP.value()}); } if (VPXDecoder::IsVP9(aMimeType)) { return HaveGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), { NS_LITERAL_CSTRING("vp9"), aGMP.value()}); } if (VPXDecoder::IsVP8(aMimeType)) { return HaveGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), { NS_LITERAL_CSTRING("vp8"), aGMP.value()}); } if (MP4Decoder::IsAAC(aMimeType)) { return HaveGMPFor(NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER), { NS_LITERAL_CSTRING("aac"), aGMP.value()}); } return false; }
static bool GMPDecryptsAndGeckoDecodesAAC(mozIGeckoMediaPluginService* aGMPService, const nsAString& aKeySystem, const nsAString& aContentType, DecoderDoctorDiagnostics* aDiagnostics) { MOZ_ASSERT(HaveGMPFor(aGMPService, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))); MOZ_ASSERT(IsAACContentType(aContentType)); if (HaveGMPFor(aGMPService, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER), NS_LITERAL_CSTRING("aac"))) { // We do have a GMP for AAC -> Gecko itself does *not* decode AAC. return false; } #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. if (aKeySystem.EqualsLiteral("com.widevine.alpha") && !WMFDecoderModule::HasAAC()) { if (aDiagnostics) { aDiagnostics->SetKeySystemIssue( DecoderDoctorDiagnostics::eWidevineWithNoWMF); } return false; } #endif return MP4Decoder::CanHandleMediaType(aContentType, aDiagnostics); }
/* static */ bool MediaKeySystemAccess::IsKeySystemSupported(const nsAString& aKeySystem) { nsCOMPtr<mozIGeckoMediaPluginService> mps = do_GetService("@mozilla.org/gecko-media-plugin-service;1"); if (NS_WARN_IF(!mps)) { return false; } if (aKeySystem.EqualsLiteral("org.w3.clearkey") && HaveGMPFor(mps, NS_LITERAL_CSTRING("org.w3.clearkey"), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))) { return true; } #ifdef XP_WIN if ((aKeySystem.EqualsLiteral("com.adobe.access") || aKeySystem.EqualsLiteral("com.adobe.primetime")) && Preferences::GetBool("media.eme.adobe-access.enabled", false) && IsVistaOrLater() && // Win Vista and later only. HaveGMPFor(mps, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))) { return true; } #endif return false; }
static bool IsPlayableWithGMP(mozIGeckoMediaPluginService* aGMPS, const nsAString& aKeySystem, const nsAString& aContentType) { #ifdef MOZ_FMP4 nsContentTypeParser parser(aContentType); nsAutoString mimeType; nsresult rv = parser.GetType(mimeType); if (NS_FAILED(rv)) { return false; } if (!mimeType.EqualsLiteral("audio/mp4") && !mimeType.EqualsLiteral("audio/x-m4a") && !mimeType.EqualsLiteral("video/mp4")) { return false; } nsAutoString codecs; parser.GetParameter("codecs", codecs); NS_ConvertUTF16toUTF8 mimeTypeUTF8(mimeType); bool hasAAC = false; bool hasH264 = false; bool hasMP3 = false; if (!MP4Decoder::CanHandleMediaType(mimeTypeUTF8, codecs, hasAAC, hasH264, hasMP3) || hasMP3) { return false; } return (!hasAAC || !(HaveGMPFor(aGMPS, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR), NS_LITERAL_CSTRING("aac")) || // XXX remove later in bug 1147692 HaveGMPFor(aGMPS, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR_COMPAT), NS_LITERAL_CSTRING("aac")))) && (!hasH264 || !(HaveGMPFor(aGMPS, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR), NS_LITERAL_CSTRING("h264")) || // XXX remove later in bug 1147692 HaveGMPFor(aGMPS, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR_COMPAT), NS_LITERAL_CSTRING("h264")))); #else return false; #endif }
/* static */ MediaKeySystemStatus MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem, int32_t aMinCdmVersion) { MOZ_ASSERT(Preferences::GetBool("media.eme.enabled", false)); nsCOMPtr<mozIGeckoMediaPluginService> mps = do_GetService("@mozilla.org/gecko-media-plugin-service;1"); if (NS_WARN_IF(!mps)) { return MediaKeySystemStatus::Error; } if (aKeySystem.EqualsLiteral("org.w3.clearkey")) { if (!Preferences::GetBool("media.eme.clearkey.enabled", true)) { return MediaKeySystemStatus::Cdm_disabled; } if (!HaveGMPFor(mps, NS_LITERAL_CSTRING("org.w3.clearkey"), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))) { return MediaKeySystemStatus::Cdm_not_installed; } return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion); } #ifdef XP_WIN if ((aKeySystem.EqualsLiteral("com.adobe.access") || aKeySystem.EqualsLiteral("com.adobe.primetime"))) { // Win Vista and later only. if (!IsVistaOrLater()) { return MediaKeySystemStatus::Cdm_not_supported; } if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) { return MediaKeySystemStatus::Cdm_disabled; } if ((!WMFDecoderModule::HasH264() || !WMFDecoderModule::HasAAC()) || !EMEVoucherFileExists()) { // The system doesn't have the codecs that Adobe EME relies // on installed, or doesn't have a voucher for the plugin-container. // Adobe EME isn't going to work, so don't advertise that it will. return MediaKeySystemStatus::Cdm_not_supported; } if (!HaveGMPFor(mps, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR)) && // XXX to be removed later in bug 1147692 !HaveGMPFor(mps, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR_COMPAT))) { return MediaKeySystemStatus::Cdm_not_installed; } return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion); } #endif return MediaKeySystemStatus::Cdm_not_supported; }
static bool GMPDecryptsAndDecodesH264(mozIGeckoMediaPluginService* aGMPS, const nsAString& aKeySystem, DecoderDoctorDiagnostics* aDiagnostics) { MOZ_ASSERT(HaveGMPFor(aGMPS, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))); return HaveGMPFor(aGMPS, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), NS_LITERAL_CSTRING("h264")); }
/* static */ bool MediaKeySystemAccess::GetSupportedConfig(const nsAString& aKeySystem, const Sequence<MediaKeySystemConfiguration>& aConfigs, MediaKeySystemConfiguration& aOutConfig, DecoderDoctorDiagnostics* aDiagnostics) { nsCOMPtr<mozIGeckoMediaPluginService> mps = do_GetService("@mozilla.org/gecko-media-plugin-service;1"); if (NS_WARN_IF(!mps)) { return false; } if (!HaveGMPFor(mps, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))) { return false; } for (const MediaKeySystemConfiguration& config : aConfigs) { if (mozilla::dom::GetSupportedConfig( mps, aKeySystem, config, aOutConfig, aDiagnostics)) { return true; } } return false; }
// If this keysystem's CDM explicitly says it doesn't support decoding, // that means it's OK with passing the decrypted samples back to Gecko // for decoding. static bool GMPDecryptsAndGeckoDecodesH264(mozIGeckoMediaPluginService* aGMPService, const nsAString& aKeySystem, const nsAString& aContentType, DecoderDoctorDiagnostics* aDiagnostics) { MOZ_ASSERT(HaveGMPFor(aGMPService, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))); MOZ_ASSERT(IsH264ContentType(aContentType)); return !HaveGMPFor(aGMPService, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), NS_LITERAL_CSTRING("h264")) && MP4Decoder::CanHandleMediaType(aContentType, aDiagnostics); }
static bool GMPDecryptsAndDecodesH264(mozIGeckoMediaPluginService* aGMPS, const nsAString& aKeySystem) { MOZ_ASSERT(HaveGMPFor(aGMPS, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))); return HaveGMPFor(aGMPS, NS_ConvertUTF16toUTF8(aKeySystem), NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), NS_LITERAL_CSTRING("h264")) #ifdef XP_WIN // Clearkey on Windows advertises that it can decode in its GMP info // file, but uses Windows Media Foundation to decode. That's not present // on Windows XP, and on some Vista, Windows N, and KN variants without // certain services packs. So for ClearKey we must check that WMF will // work. && (!aKeySystem.EqualsLiteral("org.w3.clearkey") || WMFDecoderModule::HasH264()) #endif ; }
static bool GMPDecryptsAndGeckoDecodesAAC(mozIGeckoMediaPluginService* aGMPService, const nsAString& aKeySystem, const nsAString& aContentType) { MOZ_ASSERT(HaveGMPFor(aGMPService, 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")) #ifdef XP_WIN // Clearkey on Windows advertises that it can decode in its GMP info // file, but uses Windows Media Foundation to decode. That's not present // on Windows XP, and on some Vista, Windows N, and KN variants without // certain services packs. So don't try to use gmp-clearkey for decoding // if we don't have a decoder here. || (aKeySystem.EqualsLiteral("org.w3.clearkey") && !WMFDecoderModule::HasAAC()) #endif ) && MP4Decoder::CanHandleMediaType(aContentType); }