diff options
author | tommyw@chromium.org <tommyw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-02 08:44:10 +0000 |
---|---|---|
committer | tommyw@chromium.org <tommyw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-02 08:44:10 +0000 |
commit | 066a63dcc61c35fff06c06144ee7c304d4388e39 (patch) | |
tree | 291a85a4cecd691d389286ad04dbba7585c5580c | |
parent | 6c27212db100893c6d953784bdd0c755b93b8500 (diff) | |
download | chromium_src-066a63dcc61c35fff06c06144ee7c304d4388e39.zip chromium_src-066a63dcc61c35fff06c06144ee7c304d4388e39.tar.gz chromium_src-066a63dcc61c35fff06c06144ee7c304d4388e39.tar.bz2 |
Revert 191795 "Move key system constants to separate file."
> Move key system constants to separate file.
>
> As a result, in order to override key systems/plugin mapping, only constant table in a separate file has to be replaced.
>
> BUG=179769
> TEST=content_unittests
>
> Review URL: https://chromiumcodereview.appspot.com/12882003
TBR=kjyoun@google.com
Review URL: https://codereview.chromium.org/13463002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191801 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/media/crypto/key_systems.cc | 129 | ||||
-rw-r--r-- | webkit/media/crypto/key_systems_info.cc | 121 | ||||
-rw-r--r-- | webkit/media/crypto/key_systems_info.h | 49 | ||||
-rw-r--r-- | webkit/media/webkit_media.gypi | 9 |
4 files changed, 125 insertions, 183 deletions
diff --git a/webkit/media/crypto/key_systems.cc b/webkit/media/crypto/key_systems.cc index b9c79d0..4a841fc 100644 --- a/webkit/media/crypto/key_systems.cc +++ b/webkit/media/crypto/key_systems.cc @@ -12,7 +12,14 @@ #include "net/base/mime_util.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" -#include "webkit/media/crypto/key_systems_info.h" + +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. + +#if defined(WIDEVINE_CDM_AVAILABLE) && \ + defined(OS_LINUX) && !defined(OS_CHROMEOS) +#include <gnu/libc-version.h> +#include "base/version.h" +#endif namespace webkit_media { @@ -22,6 +29,93 @@ static std::string ToASCIIOrEmpty(const WebKit::WebString& string) { return IsStringASCII(string) ? UTF16ToASCII(string) : std::string(); } +static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; +static const char kExternalClearKeyKeySystem[] = + "org.chromium.externalclearkey"; + +struct MediaFormatAndKeySystem { + const char* mime_type; + const char* codecs_list; + const char* key_system; +}; + +struct KeySystemPluginTypePair { + const char* key_system; + const char* plugin_type; +}; + +// TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303. +static const char kWidevineBaseKeySystem[] = "com.widevine"; + + +#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) +// The supported codecs depend on what the CDM provides. +static const char kWidevineVideoMp4Codecs[] = +#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \ + defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) + "avc1,mp4a"; +#elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) + "avc1"; +#else + ""; // No codec strings are supported. +#endif + +static const char kWidevineAudioMp4Codecs[] = +#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) + "mp4a"; +#else + ""; // No codec strings are supported. +#endif +#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) + +// Specifies the container and codec combinations supported by individual +// key systems. Each line is a container-codecs combination and the key system +// that supports it. Multiple codecs can be listed. In all cases, the container +// without a codec is also supported. +// This list is converted at runtime into individual container-codec-key system +// entries in KeySystems::key_system_map_. +static const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { + // Clear Key. + { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, + { "audio/webm", "vorbis", kClearKeyKeySystem }, +#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) + { "video/mp4", "avc1,mp4a", kClearKeyKeySystem }, + { "audio/mp4", "mp4a", kClearKeyKeySystem }, +#endif + + // External Clear Key (used for testing). + { "video/webm", "vorbis,vp8,vp8.0", kExternalClearKeyKeySystem }, + { "audio/webm", "vorbis", kExternalClearKeyKeySystem }, +#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) + { "video/mp4", "avc1,mp4a", kExternalClearKeyKeySystem }, + { "audio/mp4", "mp4a", kExternalClearKeyKeySystem }, +#endif + +#if defined(WIDEVINE_CDM_AVAILABLE) + // Widevine. + { "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem }, + { "audio/webm", "vorbis", kWidevineKeySystem }, + { "video/webm", "vorbis,vp8,vp8.0", kWidevineBaseKeySystem }, + { "audio/webm", "vorbis", kWidevineBaseKeySystem }, +#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) +#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) + { "video/mp4", kWidevineVideoMp4Codecs, kWidevineKeySystem }, + { "video/mp4", kWidevineVideoMp4Codecs, kWidevineBaseKeySystem }, + { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineKeySystem }, + { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineBaseKeySystem }, +#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) +#endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) +#endif // WIDEVINE_CDM_AVAILABLE +}; + +static const KeySystemPluginTypePair kKeySystemToPluginTypeMapping[] = { + // TODO(xhwang): Update this with the real plugin name. + { kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm" }, +#if defined(WIDEVINE_CDM_AVAILABLE) + { kWidevineKeySystem, kWidevineCdmPluginMimeType } +#endif // WIDEVINE_CDM_AVAILABLE +}; + class KeySystems { public: bool IsSupportedKeySystem(const std::string& key_system); @@ -54,7 +148,9 @@ static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER; KeySystems::KeySystems() { // Initialize the supported media type/key system combinations. - for (int i = 0; i < kNumSupportedFormatKeySystemCombinations; ++i) { + for (size_t i = 0; + i < arraysize(kSupportedFormatKeySystemCombinations); + ++i) { const MediaFormatAndKeySystem& combination = kSupportedFormatKeySystemCombinations[i]; std::vector<std::string> mime_type_codecs; @@ -85,6 +181,18 @@ KeySystems::KeySystems() { } } +static inline bool IsSystemCompatible(const std::string& key_system) { +#if defined(WIDEVINE_CDM_AVAILABLE) && \ + defined(OS_LINUX) && !defined(OS_CHROMEOS) + if (key_system == kWidevineKeySystem) { + Version glibc_version(gnu_get_libc_version()); + DCHECK(glibc_version.IsValid()); + return !glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION); + } +#endif + return true; +} + bool KeySystems::IsSupportedKeySystem(const std::string& key_system) { bool is_supported = key_system_map_.find(key_system) != key_system_map_.end(); return is_supported && IsSystemCompatible(key_system); @@ -136,20 +244,31 @@ bool IsSupportedKeySystemWithMediaMimeType( mime_type, codecs, key_system); } +template<typename T> // T is a stringish type. +static std::string KeySystemNameForUMAGeneric(const T& key_system) { + if (key_system == kClearKeyKeySystem) + return "ClearKey"; +#if defined(WIDEVINE_CDM_AVAILABLE) + if (key_system == kWidevineKeySystem) + return "Widevine"; +#endif // WIDEVINE_CDM_AVAILABLE + return "Unknown"; +} + std::string KeySystemNameForUMA(const std::string& key_system) { return KeySystemNameForUMAGeneric(key_system); } std::string KeySystemNameForUMA(const WebKit::WebString& key_system) { - return KeySystemNameForUMAGeneric(std::string(key_system.utf8().data())); + return KeySystemNameForUMAGeneric(key_system); } bool CanUseAesDecryptor(const std::string& key_system) { - return CanUseBuiltInAesDecryptor(key_system); + return key_system == kClearKeyKeySystem; } std::string GetPluginType(const std::string& key_system) { - for (int i = 0; i < kNumKeySystemToPluginTypeMapping; ++i) { + for (size_t i = 0; i < arraysize(kKeySystemToPluginTypeMapping); ++i) { if (kKeySystemToPluginTypeMapping[i].key_system == key_system) return kKeySystemToPluginTypeMapping[i].plugin_type; } diff --git a/webkit/media/crypto/key_systems_info.cc b/webkit/media/crypto/key_systems_info.cc deleted file mode 100644 index 27508f9..0000000 --- a/webkit/media/crypto/key_systems_info.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/media/crypto/key_systems_info.h" - -#include "base/basictypes.h" - -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. - -#if defined(WIDEVINE_CDM_AVAILABLE) && \ - defined(OS_LINUX) && !defined(OS_CHROMEOS) -#include <gnu/libc-version.h> -#include "base/version.h" -#endif - -namespace webkit_media { - -static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; - -static const char kExternalClearKeyKeySystem[] = - "org.chromium.externalclearkey"; - -// TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303. -static const char kWidevineBaseKeySystem[] = "com.widevine"; - -#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) -// The supported codecs depend on what the CDM provides. -static const char kWidevineVideoMp4Codecs[] = -#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \ - defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) - "avc1,mp4a"; -#elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) - "avc1"; -#else - ""; // No codec strings are supported. -#endif - -static const char kWidevineAudioMp4Codecs[] = -#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) - "mp4a"; -#else - ""; // No codec strings are supported. -#endif -#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) - -const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { - // Clear Key. - { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, - { "audio/webm", "vorbis", kClearKeyKeySystem }, -#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) - { "video/mp4", "avc1,mp4a", kClearKeyKeySystem }, - { "audio/mp4", "mp4a", kClearKeyKeySystem }, -#endif - - // External Clear Key (used for testing). - { "video/webm", "vorbis,vp8,vp8.0", kExternalClearKeyKeySystem }, - { "audio/webm", "vorbis", kExternalClearKeyKeySystem }, -#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) - { "video/mp4", "avc1,mp4a", kExternalClearKeyKeySystem }, - { "audio/mp4", "mp4a", kExternalClearKeyKeySystem }, -#endif - -#if defined(WIDEVINE_CDM_AVAILABLE) - // Widevine. - { "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem }, - { "audio/webm", "vorbis", kWidevineKeySystem }, - { "video/webm", "vorbis,vp8,vp8.0", kWidevineBaseKeySystem }, - { "audio/webm", "vorbis", kWidevineBaseKeySystem }, -#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) -#if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) - { "video/mp4", kWidevineVideoMp4Codecs, kWidevineKeySystem }, - { "video/mp4", kWidevineVideoMp4Codecs, kWidevineBaseKeySystem }, - { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineKeySystem }, - { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineBaseKeySystem }, -#endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) -#endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) -#endif // WIDEVINE_CDM_AVAILABLE -}; - -const int kNumSupportedFormatKeySystemCombinations = - arraysize(kSupportedFormatKeySystemCombinations); - -const KeySystemPluginTypePair kKeySystemToPluginTypeMapping[] = { - // TODO(xhwang): Update this with the real plugin name. - { kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm"}, -#if defined(WIDEVINE_CDM_AVAILABLE) - { kWidevineKeySystem, kWidevineCdmPluginMimeType} -#endif // WIDEVINE_CDM_AVAILABLE -}; - -const int kNumKeySystemToPluginTypeMapping = - arraysize(kKeySystemToPluginTypeMapping); - -bool IsSystemCompatible(const std::string& key_system) { -#if defined(WIDEVINE_CDM_AVAILABLE) && \ - defined(OS_LINUX) && !defined(OS_CHROMEOS) - if (key_system == kWidevineKeySystem) { - Version glibc_version(gnu_get_libc_version()); - DCHECK(glibc_version.IsValid()); - return !glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION); - } -#endif - return true; -} - -std::string KeySystemNameForUMAGeneric(const std::string& key_system) { - if (key_system == kClearKeyKeySystem) - return "ClearKey"; -#if defined(WIDEVINE_CDM_AVAILABLE) - if (key_system == kWidevineKeySystem) - return "Widevine"; -#endif // WIDEVINE_CDM_AVAILABLE - return "Unknown"; -} - -bool CanUseBuiltInAesDecryptor(const std::string& key_system) { - return key_system == kClearKeyKeySystem; -} - -} // namespace webkit_media diff --git a/webkit/media/crypto/key_systems_info.h b/webkit/media/crypto/key_systems_info.h deleted file mode 100644 index f02abaf..0000000 --- a/webkit/media/crypto/key_systems_info.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_MEDIA_CRYPTO_KEY_SYSTEMS_INFO_H_ -#define WEBKIT_MEDIA_CRYPTO_KEY_SYSTEMS_INFO_H_ - -#include <string> - -namespace webkit_media { - -struct MediaFormatAndKeySystem { - const char* mime_type; - const char* codecs_list; - const char* key_system; -}; - -struct KeySystemPluginTypePair { - const char* key_system; - const char* plugin_type; -}; - -// Specifies the container and codec combinations supported by individual -// key systems. Each line is a container-codecs combination and the key system -// that supports it. Multiple codecs can be listed. In all cases, the container -// without a codec is also supported. -// This list is converted at runtime into individual container-codec-key system -// entries in KeySystems::key_system_map_. -extern const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[]; -extern const int kNumSupportedFormatKeySystemCombinations; - -// There should be one entry for each key system. -extern const KeySystemPluginTypePair kKeySystemToPluginTypeMapping[]; -extern const int kNumKeySystemToPluginTypeMapping; - -// Returns whether |key_system| is compatible with the user's system. -bool IsSystemCompatible(const std::string& key_system); - -// Returns the name that UMA will use for the given |key_system|. -// This function can be called frequently. Hence this function should be -// implemented not to impact performance. -std::string KeySystemNameForUMAGeneric(const std::string& key_system); - -// Returns whether built-in AesDecryptor can be used for the given |key_system|. -bool CanUseBuiltInAesDecryptor(const std::string& key_system); - -} // namespace webkit_media - -#endif // WEBKIT_MEDIA_CRYPTO_KEY_SYSTEMS_INFO_H_ diff --git a/webkit/media/webkit_media.gypi b/webkit/media/webkit_media.gypi index 19e6e23..827a11a 100644 --- a/webkit/media/webkit_media.gypi +++ b/webkit/media/webkit_media.gypi @@ -29,7 +29,7 @@ 'type': 'static_library', 'variables': { 'enable_wexit_time_destructors': 1, }, 'include_dirs': [ - '<(SHARED_INTERMEDIATE_DIR)', # Needed by key_systems_info.cc. + '<(SHARED_INTERMEDIATE_DIR)', # Needed by key_systems.cc. ], 'dependencies': [ '<(DEPTH)/base/base.gyp:base', @@ -68,8 +68,6 @@ 'cache_util.h', 'crypto/key_systems.cc', 'crypto/key_systems.h', - 'crypto/key_systems_info.cc', - 'crypto/key_systems_info.h', 'crypto/ppapi_decryptor.cc', 'crypto/ppapi_decryptor.h', 'crypto/proxy_decryptor.cc', @@ -127,11 +125,6 @@ ['exclude', '^android/'], ], }], - ['google_tv == 1', { - 'sources!': [ - 'crypto/key_systems_info.cc', - ], - }], ], # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. 'msvs_disabled_warnings': [ 4267, ], |