Bug 1288320 - Define each keysystem string as specific identifier instead of placing some.keysystem everywhere. r=cpearce

MozReview-Commit-ID: 1bwPRhMOawu

--HG--
extra : amend_source : 7550352f178c0082484acdd342db05ed0dc02e23
extra : transplant_source : %96%C1%B9%8B%28%B0%96f%8AM%AA%13T%1E%3Bg%98%96%92%C1
This commit is contained in:
James Cheng 2016-07-27 16:07:46 +08:00
Родитель dde25f3864
Коммит 240e465d99
7 изменённых файлов: 35 добавлений и 30 удалений

Просмотреть файл

@ -135,13 +135,13 @@ CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aB
nsString
KeySystemToGMPName(const nsAString& aKeySystem)
{
if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
if (aKeySystem.EqualsASCII(kEMEKeySystemPrimetime)) {
return NS_LITERAL_STRING("gmp-eme-adobe");
}
if (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
if (aKeySystem.EqualsASCII(kEMEKeySystemClearkey)) {
return NS_LITERAL_STRING("gmp-clearkey");
}
if (aKeySystem.EqualsLiteral("com.widevine.alpha")) {
if (aKeySystem.EqualsASCII(kEMEKeySystemWidevine)) {
return NS_LITERAL_STRING("gmp-widevinecdm");
}
MOZ_ASSERT(false, "We should only call this for known GMPs");
@ -151,7 +151,7 @@ KeySystemToGMPName(const nsAString& aKeySystem)
bool
IsClearkeyKeySystem(const nsAString& aKeySystem)
{
return aKeySystem.EqualsLiteral("org.w3.clearkey");
return aKeySystem.EqualsASCII(kEMEKeySystemClearkey);
}
} // namespace mozilla

Просмотреть файл

@ -13,6 +13,10 @@
namespace mozilla {
static const char* const kEMEKeySystemClearkey = "org.w3.clearkey";
static const char* const kEMEKeySystemWidevine = "com.widevine.alpha";
static const char* const kEMEKeySystemPrimetime = "com.adobe.primetime";
namespace dom {
class ArrayBufferViewOrArrayBuffer;
}

Просмотреть файл

@ -191,7 +191,7 @@ MediaKeySystemAccess::IsGMPPresentOnDisk(const nsAString& aKeySystem,
bool isPresent = true;
#if XP_WIN
if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
if (aKeySystem.EqualsASCII(kEMEKeySystemPrimetime)) {
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 (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
if (aKeySystem.EqualsASCII(kEMEKeySystemClearkey)) {
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
if (Preferences::GetBool("media.gmp-eme-adobe.visible", false)) {
if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
if (aKeySystem.EqualsASCII(kEMEKeySystemPrimetime)) {
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 (aKeySystem.EqualsLiteral("com.widevine.alpha")) {
if (aKeySystem.EqualsASCII(kEMEKeySystemWidevine)) {
#ifdef XP_WIN
// Win Vista and later only.
if (!IsVistaOrLater()) {
@ -426,7 +426,7 @@ GetSupportedKeySystems()
{
KeySystemConfig clearkey;
clearkey.mKeySystem = NS_LITERAL_STRING("org.w3.clearkey");
clearkey.mKeySystem = NS_ConvertUTF8toUTF16(kEMEKeySystemClearkey);
clearkey.mInitDataTypes.AppendElement(NS_LITERAL_STRING("cenc"));
clearkey.mInitDataTypes.AppendElement(NS_LITERAL_STRING("keyids"));
clearkey.mInitDataTypes.AppendElement(NS_LITERAL_STRING("webm"));
@ -458,7 +458,7 @@ GetSupportedKeySystems()
}
{
KeySystemConfig widevine;
widevine.mKeySystem = NS_LITERAL_STRING("com.widevine.alpha");
widevine.mKeySystem = NS_ConvertUTF8toUTF16(kEMEKeySystemWidevine);
widevine.mInitDataTypes.AppendElement(NS_LITERAL_STRING("cenc"));
widevine.mInitDataTypes.AppendElement(NS_LITERAL_STRING("keyids"));
widevine.mInitDataTypes.AppendElement(NS_LITERAL_STRING("webm"));
@ -489,7 +489,7 @@ GetSupportedKeySystems()
}
{
KeySystemConfig primetime;
primetime.mKeySystem = NS_LITERAL_STRING("com.adobe.primetime");
primetime.mKeySystem = NS_ConvertUTF8toUTF16(kEMEKeySystemPrimetime);
primetime.mInitDataTypes.AppendElement(NS_LITERAL_STRING("cenc"));
primetime.mPersistentState = KeySystemFeatureSupport::Required;
primetime.mDistinctiveIdentifier = KeySystemFeatureSupport::Required;
@ -564,7 +564,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 &&
aKeySystem.EqualsLiteral("com.widevine.alpha") &&
aKeySystem.EqualsASCII(kEMEKeySystemWidevine) &&
!WMFDecoderModule::HasAAC()) {
if (aDiagnostics) {
aDiagnostics->SetKeySystemIssue(
@ -1131,7 +1131,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 (aKeySystem.mKeySystem.EqualsLiteral("com.widevine.alpha") &&
if (aKeySystem.mKeySystem.EqualsASCII(kEMEKeySystemWidevine) &&
(aCandidate.mAudioCapabilities.IsEmpty() ||
aCandidate.mVideoCapabilities.IsEmpty()) &&
!WMFDecoderModule::HasAAC()) {

Просмотреть файл

@ -142,8 +142,8 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
if ((status == MediaKeySystemStatus::Cdm_not_installed ||
status == MediaKeySystemStatus::Cdm_insufficient_version) &&
(keySystem.EqualsLiteral("com.adobe.primetime") ||
keySystem.EqualsLiteral("com.widevine.alpha"))) {
(keySystem.EqualsASCII(kEMEKeySystemPrimetime) ||
keySystem.EqualsASCII(kEMEKeySystemWidevine))) {
// 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

Просмотреть файл

@ -580,7 +580,7 @@ GMPParent::SupportsAPI(const nsCString& aAPI, const nsCString& aTag)
// 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.
if (tags[j].EqualsLiteral("org.w3.clearkey")) {
if (tags[j].Equals(kEMEKeySystemClearkey)) {
if (mCapabilities[i].mAPIName.EqualsLiteral(GMP_API_VIDEO_DECODER)) {
if (!WMFDecoderModule::HasH264()) {
continue;
@ -898,7 +898,7 @@ GMPParent::ReadGMPInfoFile(nsIFile* aFile)
// Adobe GMP doesn't work without SSE2. Check the tags to see if
// the decryptor is for the Adobe GMP, and refuse to load it if
// SSE2 isn't supported.
if (cap.mAPITags.Contains(NS_LITERAL_CSTRING("com.adobe.primetime")) &&
if (cap.mAPITags.Contains(nsCString(kEMEKeySystemPrimetime)) &&
!mozilla::supports_sse2()) {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
}
@ -953,11 +953,11 @@ GMPParent::ParseChromiumManifest(nsString aJSON)
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"));
video.mAPITags.AppendElement(nsCString(kEMEKeySystemWidevine));
mCapabilities.AppendElement(Move(video));
GMPCapability decrypt(NS_LITERAL_CSTRING(GMP_API_DECRYPTOR));
decrypt.mAPITags.AppendElement(NS_LITERAL_CSTRING("com.widevine.alpha"));
decrypt.mAPITags.AppendElement(nsCString(kEMEKeySystemWidevine));
mCapabilities.AppendElement(Move(decrypt));
MOZ_ASSERT(mName.EqualsLiteral("widevinecdm"));

Просмотреть файл

@ -12,13 +12,13 @@
#include "gmp-api/gmp-decryption.h"
#include "gmp-api/gmp-video-codec.h"
#include "gmp-api/gmp-platform.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/StaticPtr.h"
static const GMPPlatformAPI* sPlatform = nullptr;
namespace mozilla {
const char* WidevineKeySystem = "com.widevine.alpha";
StaticRefPtr<CDMWrapper> sCDMWrapper;
GMPErr GMPGetCurrentTime(GMPTimestamp* aOutTime) {
@ -110,8 +110,8 @@ WidevineAdapter::GMPGetAPI(const char* aAPIName,
auto cdm = reinterpret_cast<cdm::ContentDecryptionModule*>(
create(cdm::ContentDecryptionModule::kVersion,
WidevineKeySystem,
strlen(WidevineKeySystem),
kEMEKeySystemWidevine,
strlen(kEMEKeySystemWidevine),
&GetCdmHost,
decryptor));
if (!cdm) {

Просмотреть файл

@ -12,6 +12,7 @@
#include "MediaPrefs.h"
#include "mozIGeckoMediaPluginService.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/StaticMutex.h"
#include "gmp-audio-decode.h"
#include "gmp-video-decode.h"
@ -103,7 +104,7 @@ HasGMPFor(const nsACString& aAPI,
#ifdef XP_WIN
// gmp-clearkey uses WMF for decoding, so if we're using clearkey we must
// verify that WMF works before continuing.
if (aGMP.EqualsLiteral("org.w3.clearkey")) {
if (aGMP.Equals(kEMEKeySystemClearkey)) {
RefPtr<WMFDecoderModule> pdm(new WMFDecoderModule());
if (aCodec.EqualsLiteral("aac") &&
!pdm->SupportsMimeType(NS_LITERAL_CSTRING("audio/mp4a-latm"),
@ -143,9 +144,9 @@ struct GMPCodecs {
};
static GMPCodecs sGMPCodecs[] = {
{ "org.w3.clearkey", false, false },
{ "com.adobe.primetime", false, false },
{ "com.widevine.alpha", false, false },
{ kEMEKeySystemClearkey, false, false },
{ kEMEKeySystemWidevine, false, false },
{ kEMEKeySystemPrimetime, false, false },
};
void
@ -182,8 +183,8 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
Maybe<nsCString> rv;
if (aMimeType.EqualsLiteral("audio/mp4a-latm")) {
switch (MediaPrefs::GMPAACPreferred()) {
case 1: rv.emplace(NS_LITERAL_CSTRING("org.w3.clearkey")); break;
case 2: rv.emplace(NS_LITERAL_CSTRING("com.adobe.primetime")); break;
case 1: rv.emplace(nsCString(kEMEKeySystemClearkey)); break;
case 2: rv.emplace(nsCString(kEMEKeySystemPrimetime)); break;
default: break;
}
}
@ -191,8 +192,8 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
if (aMimeType.EqualsLiteral("video/avc") ||
aMimeType.EqualsLiteral("video/mp4")) {
switch (MediaPrefs::GMPH264Preferred()) {
case 1: rv.emplace(NS_LITERAL_CSTRING("org.w3.clearkey")); break;
case 2: rv.emplace(NS_LITERAL_CSTRING("com.adobe.primetime")); break;
case 1: rv.emplace(nsCString(kEMEKeySystemClearkey)); break;
case 2: rv.emplace(nsCString(kEMEKeySystemPrimetime)); break;
default: break;
}
}