Bug 1307248 - Replace uses of CompareUTF8toUTF16(kEMEKeySystem*) with Is*KeySystem(). r=jwwang

MozReview-Commit-ID: BTTacIyYfGZ

--HG--
extra : rebase_source : 4c3146ce7ca597c33871e8fb76b1c86d93c24ef7
This commit is contained in:
Chris Pearce 2016-10-04 09:48:28 +13:00
parent 5215e69245
commit b2629e2eec
3 changed files with 14 additions and 15 deletions

View File

@ -153,13 +153,13 @@ IsWidevineKeySystem(const nsAString& aKeySystem)
nsString
KeySystemToGMPName(const nsAString& aKeySystem)
{
if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
if (IsPrimetimeKeySystem(aKeySystem)) {
return NS_LITERAL_STRING("gmp-eme-adobe");
}
if (!CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem)) {
if (IsClearkeyKeySystem(aKeySystem)) {
return NS_LITERAL_STRING("gmp-clearkey");
}
if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem)) {
if (IsWidevineKeySystem(aKeySystem)) {
return NS_LITERAL_STRING("gmp-widevinecdm");
}
MOZ_ASSERT(false, "We should only call this for known GMPs");
@ -169,11 +169,11 @@ KeySystemToGMPName(const nsAString& aKeySystem)
CDMType
ToCDMTypeTelemetryEnum(const nsString& aKeySystem)
{
if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem)) {
if (IsWidevineKeySystem(aKeySystem)) {
return CDMType::eWidevine;
} else if (!CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem)) {
} else if (IsClearkeyKeySystem(aKeySystem)) {
return CDMType::eClearKey;
} else if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
} else if (IsPrimetimeKeySystem(aKeySystem)) {
return CDMType::ePrimetime;
}
return CDMType::eUnknown;

View File

@ -191,7 +191,7 @@ MediaKeySystemAccess::IsGMPPresentOnDisk(const nsAString& aKeySystem,
bool isPresent = true;
#if XP_WIN
if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
if (IsPrimetimeKeySystem(aKeySystem)) {
if (!AdobePluginDLLExists(aVersion)) {
NS_WARNING("Adobe EME plugin disappeared from disk!");
aOutMessage = NS_LITERAL_CSTRING("Adobe DLL was expected to be on disk but was not");
@ -276,12 +276,12 @@ MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
return MediaKeySystemStatus::Error;
}
if (!CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem)) {
if (IsClearkeyKeySystem(aKeySystem)) {
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
if (Preferences::GetBool("media.gmp-eme-adobe.visible", false)) {
if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
if (IsPrimetimeKeySystem(aKeySystem)) {
if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
return MediaKeySystemStatus::Cdm_disabled;
@ -298,7 +298,7 @@ MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
}
if (Preferences::GetBool("media.gmp-widevinecdm.visible", false)) {
if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem)) {
if (IsWidevineKeySystem(aKeySystem)) {
#ifdef XP_WIN
// Win Vista and later only.
if (!IsVistaOrLater()) {
@ -563,7 +563,7 @@ CanDecryptAndDecode(mozIGeckoMediaPluginService* aGMPService,
// the Adobe GMP's unencrypted AAC decoding path being used to
// decode content decrypted by the Widevine CDM.
if (codec == GMP_CODEC_AAC &&
!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem) &&
IsWidevineKeySystem(aKeySystem) &&
!WMFDecoderModule::HasAAC()) {
if (aDiagnostics) {
aDiagnostics->SetKeySystemIssue(
@ -1130,7 +1130,7 @@ GetSupportedConfig(mozIGeckoMediaPluginService* aGMPService,
#if 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 (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem.mKeySystem) &&
if (IsWidevineKeySystem(aKeySystem.mKeySystem) &&
(aCandidate.mAudioCapabilities.IsEmpty() ||
aCandidate.mVideoCapabilities.IsEmpty()) &&
!WMFDecoderModule::HasAAC()) {

View File

@ -142,8 +142,7 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
if ((status == MediaKeySystemStatus::Cdm_not_installed ||
status == MediaKeySystemStatus::Cdm_insufficient_version) &&
(!CompareUTF8toUTF16(kEMEKeySystemPrimetime, keySystem) ||
!CompareUTF8toUTF16(kEMEKeySystemWidevine, keySystem))) {
(IsPrimetimeKeySystem(keySystem) || IsWidevineKeySystem(keySystem))) {
// These are cases which could be resolved by downloading a new(er) CDM.
// When we send the status to chrome, chrome's GMPProvider will attempt to
// download or update the CDM. In AwaitInstall() we add listeners to wait
@ -154,7 +153,7 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
if (aType == RequestType::Initial &&
AwaitInstall(aPromise, aKeySystem, aConfigs)) {
// Notify chrome that we're going to wait for the CDM to download/update.
// Note: If we're re-trying, we don't re-send the notificaiton,
// Note: If we're re-trying, we don't re-send the notification,
// as chrome is already displaying the "we can't play, updating"
// notification.
MediaKeySystemAccess::NotifyObservers(mWindow, keySystem, status);