Bug 1711912 - Move key system name constants into their own header. r=alwu

Move constants and fix up includes following doing so.

This is motivated by that future patches will want to use these constants in the
clear key CDM. If we don't move these constants and try to include the existing
VideoUtils in the clear key CDM this will break the build (because the clear key
CDM uses a restricted subset of the stuff we get in Gecko).

Differential Revision: https://phabricator.services.mozilla.com/D122631
This commit is contained in:
Bryce Seager van Dyk 2021-08-19 17:14:08 +00:00
Родитель 5d9f888ba9
Коммит 83332521e5
13 изменённых файлов: 59 добавлений и 33 удалений

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

@ -44,12 +44,6 @@ namespace mozilla {
class MediaContainerType;
// EME Key System String.
#define EME_KEY_SYSTEM_CLEARKEY "org.w3.clearkey"
#define EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY \
"org.mozilla.clearkey_with_protection_query"
#define EME_KEY_SYSTEM_WIDEVINE "com.widevine.alpha"
/**
* ReentrantMonitorConditionallyEnter
*

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

@ -5,6 +5,8 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DetailedPromise.h"
#include "VideoUtils.h"
#include "mozilla/dom/DOMException.h"
#include "nsPrintfCString.h"

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

@ -8,6 +8,7 @@
#include "jsfriendapi.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/UnionTypes.h"
namespace mozilla {
@ -54,15 +55,14 @@ void CopyArrayBufferViewOrArrayBufferData(
bool IsClearkeyKeySystem(const nsAString& aKeySystem) {
if (StaticPrefs::media_clearkey_test_key_systems_enabled()) {
return aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY) ||
aKeySystem.EqualsLiteral(
EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY);
return aKeySystem.EqualsLiteral(kClearKeyKeySystemName) ||
aKeySystem.EqualsLiteral(kClearKeyWithProtectionQueryKeySystemName);
}
return aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY);
return aKeySystem.EqualsLiteral(kClearKeyKeySystemName);
}
bool IsWidevineKeySystem(const nsAString& aKeySystem) {
return aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_WIDEVINE);
return aKeySystem.EqualsLiteral(kWidevineKeySystemName);
}
nsString KeySystemToGMPName(const nsAString& aKeySystem) {

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

@ -7,7 +7,6 @@
#ifndef EME_LOG_H_
#define EME_LOG_H_
#include "VideoUtils.h"
#include "mozilla/Logging.h"
#include "nsString.h"
#include "nsTArray.h"

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

@ -0,0 +1,26 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_MEDIA_EME_KEY_SYSTEM_NAMES_H_
#define DOM_MEDIA_EME_KEY_SYSTEM_NAMES_H_
// Header for key system names. Keep these separate from some of our other
// EME utils because want to use these strings in contexts where other utils
// may not build correctly. Specifically at time of writing:
// - The GMP doesn't have prefs available, so we want to avoid utils that
// touch the pref service.
// - The clear key CDM links a limited subset of what normal Fx does, so we
// need to avoid any utils that touch things like XUL.
namespace mozilla {
// EME Key System Strings.
inline constexpr char kClearKeyKeySystemName[] = "org.w3.clearkey";
inline constexpr char kClearKeyWithProtectionQueryKeySystemName[] =
"org.mozilla.clearkey_with_protection_query";
inline constexpr char kWidevineKeySystemName[] = "com.widevine.alpha";
} // namespace mozilla
#endif // DOM_MEDIA_EME_KEY_SYSTEM_NAMES_H_

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

@ -13,6 +13,7 @@
#include "GMPUtils.h"
#include "MediaContainerType.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/MediaKeySystemAccessBinding.h"
#include "mozilla/dom/MediaKeySession.h"
#include "mozilla/dom/MediaSource.h"
@ -26,7 +27,6 @@
#include "nsReadableUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsUnicharUtils.h"
#include "VideoUtils.h"
#include "WebMDecoder.h"
#ifdef XP_WIN
@ -293,10 +293,10 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
nsTArray<KeySystemConfig> keySystemConfigs;
{
const nsCString keySystem = nsLiteralCString(EME_KEY_SYSTEM_CLEARKEY);
const nsCString keySystem = nsLiteralCString(kClearKeyKeySystemName);
if (HavePluginForKeySystem(keySystem)) {
KeySystemConfig clearkey;
clearkey.mKeySystem.AssignLiteral(EME_KEY_SYSTEM_CLEARKEY);
clearkey.mKeySystem.AssignLiteral(kClearKeyKeySystemName);
clearkey.mInitDataTypes.AppendElement(u"cenc"_ns);
clearkey.mInitDataTypes.AppendElement(u"keyids"_ns);
clearkey.mInitDataTypes.AppendElement(u"webm"_ns);
@ -334,7 +334,7 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
// base clearkey system, so just clone clearkey and change the name.
KeySystemConfig clearkeyWithProtectionQuery{clearkey};
clearkeyWithProtectionQuery.mKeySystem.AssignLiteral(
EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY);
kClearKeyWithProtectionQueryKeySystemName);
keySystemConfigs.AppendElement(std::move(clearkeyWithProtectionQuery));
}
@ -342,10 +342,10 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
}
}
{
const nsCString keySystem = nsLiteralCString(EME_KEY_SYSTEM_WIDEVINE);
const nsCString keySystem = nsLiteralCString(kWidevineKeySystemName);
if (HavePluginForKeySystem(keySystem)) {
KeySystemConfig widevine;
widevine.mKeySystem.AssignLiteral(EME_KEY_SYSTEM_WIDEVINE);
widevine.mKeySystem.AssignLiteral(kWidevineKeySystemName);
widevine.mInitDataTypes.AppendElement(u"cenc"_ns);
widevine.mInitDataTypes.AppendElement(u"keyids"_ns);
widevine.mInitDataTypes.AppendElement(u"webm"_ns);
@ -398,8 +398,8 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
};
for (const auto& data : validationList) {
if (java::MediaDrmProxy::IsCryptoSchemeSupported(
EME_KEY_SYSTEM_WIDEVINE, data.mMimeType)) {
if (java::MediaDrmProxy::IsCryptoSchemeSupported(kWidevineKeySystemName,
data.mMimeType)) {
if (AndroidDecoderModule::SupportsMimeType(data.mMimeType)) {
data.mSupportType->SetCanDecryptAndDecode(data.mEMECodecType);
} else {

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

@ -6,6 +6,7 @@
#include "DecoderDoctorDiagnostics.h"
#include "MediaKeySystemAccessPermissionRequest.h"
#include "VideoUtils.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/Document.h"
#include "mozilla/DetailedPromise.h"

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

@ -20,6 +20,7 @@
#include "nsCycleCollectionParticipant.h"
#include "nsIObserver.h"
#include "nsRefPtrHashtable.h"
#include "nsTHashMap.h"
#include "nsWrapperCache.h"
namespace mozilla {

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

@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.dom += [
"KeySystemNames.h",
"MediaEncryptedEvent.h",
"MediaKeyError.h",
"MediaKeyMessageEvent.h",

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

@ -8,7 +8,6 @@
#include <utility>
#include "GMPLog.h"
#include "VideoUtils.h"
#include "WidevineUtils.h"
#include "content_decryption_module.h"
#include "content_decryption_module_ext.h"
@ -16,6 +15,7 @@
#include "gmp-api/gmp-video-codec.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/HelperMacros.h"
#include "mozilla/dom/KeySystemNames.h"
#ifdef XP_WIN
# include "WinUtils.h"
@ -103,13 +103,13 @@ GMPErr ChromiumCDMAdapter::GMPInit(const GMPPlatformAPI* aPlatformAPI) {
GMPErr ChromiumCDMAdapter::GMPGetAPI(const char* aAPIName, void* aHostAPI,
void** aPluginAPI,
const nsCString& aKeySystem) {
MOZ_ASSERT(aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_WIDEVINE) ||
aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY) ||
aKeySystem.EqualsLiteral(
EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY) ||
aKeySystem.EqualsLiteral("fake"),
"Should not get an unrecognized key system. Why didn't it get "
"blocked by MediaKeySystemAccess?");
MOZ_ASSERT(
aKeySystem.EqualsLiteral(kWidevineKeySystemName) ||
aKeySystem.EqualsLiteral(kClearKeyKeySystemName) ||
aKeySystem.EqualsLiteral(kClearKeyWithProtectionQueryKeySystemName) ||
aKeySystem.EqualsLiteral("fake"),
"Should not get an unrecognized key system. Why didn't it get "
"blocked by MediaKeySystemAccess?");
GMP_LOG_DEBUG("ChromiumCDMAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %s) this=0x%p",
aAPIName, aHostAPI, aPluginAPI, aKeySystem.get(), this);
bool isCdm10 = !strcmp(aAPIName, CHROMIUM_CDM_API);

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

@ -14,6 +14,7 @@
#include "GMPLog.h"
#include "GMPService.h"
#include "GMPUtils.h"
#include "VideoUtils.h"
#include "mozilla/dom/MediaKeyMessageEventBinding.h"
#include "mozilla/gmp/GMPTypes.h"
#include "mozilla/ScopeExit.h"

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

@ -12,6 +12,7 @@
#include "GMPTimerParent.h"
#include "MediaResult.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/WidevineCDMManifestBinding.h"
#include "mozilla/ipc/CrashReporterHost.h"
#include "mozilla/ipc/Endpoint.h"
@ -31,7 +32,6 @@
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
#include "runnable_utils.h"
#include "VideoUtils.h"
#ifdef XP_WIN
# include "WMFDecoderModule.h"
#endif
@ -539,7 +539,7 @@ bool GMPCapability::Supports(const nsTArray<GMPCapability>& aCapabilities,
// 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 (tag.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY)) {
if (tag.EqualsLiteral(kClearKeyKeySystemName)) {
if (capabilities.mAPIName.EqualsLiteral(GMP_API_VIDEO_DECODER)) {
if (!WMFDecoderModule::HasH264()) {
continue;
@ -847,9 +847,9 @@ RefPtr<GenericPromise> GMPParent::ParseChromiumManifest(
// We hard code a few of the settings because they can't be stored in the
// widevine manifest without making our API different to widevine's.
if (mDisplayName.EqualsASCII("clearkey")) {
video.mAPITags.AppendElement(nsCString{EME_KEY_SYSTEM_CLEARKEY});
video.mAPITags.AppendElement(nsCString{kClearKeyKeySystemName});
video.mAPITags.AppendElement(
nsCString{EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY});
nsCString{kClearKeyWithProtectionQueryKeySystemName});
#if XP_WIN
mLibs = nsLiteralCString(
"dxva2.dll, evr.dll, freebl3.dll, mfh264dec.dll, mfplat.dll, "
@ -858,7 +858,7 @@ RefPtr<GenericPromise> GMPParent::ParseChromiumManifest(
mLibs = "libfreeblpriv3.so, libsoftokn3.so"_ns;
#endif
} else if (mDisplayName.EqualsASCII("WidevineCdm")) {
video.mAPITags.AppendElement(nsCString{EME_KEY_SYSTEM_WIDEVINE});
video.mAPITags.AppendElement(nsCString{kWidevineKeySystemName});
#if XP_WIN
// psapi.dll added for GetMappedFileNameW, which could possibly be avoided
// in future versions, see bug 1383611 for details.

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

@ -7,6 +7,7 @@
#include <cmath>
#include "FrameStatistics.h"
#include "VideoUtils.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/Logging.h"
#include "mozilla/Telemetry.h"