Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: trunk/src/content/renderer/media/crypto/key_systems_info.cc

Issue 23708020: Revert 222074 "Refactor KeySystems code to call a function to po..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: trunk/src/content/renderer/media/crypto/key_systems_info.cc
===================================================================
--- trunk/src/content/renderer/media/crypto/key_systems_info.cc (revision 222090)
+++ trunk/src/content/renderer/media/crypto/key_systems_info.cc (working copy)
@@ -5,6 +5,7 @@
#include "content/renderer/media/crypto/key_systems_info.h"
#include "base/logging.h"
+#include "content/renderer/media/crypto/key_systems.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
@@ -25,36 +26,41 @@
static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
-static const char kAudioWebM[] = "audio/webm";
-static const char kVideoWebM[] = "video/webm";
-static const char kVorbis[] = "vorbis";
-static const char kVorbisVP8[] = "vorbis,vp8,vp8.0";
+#if defined(ENABLE_PEPPER_CDMS)
+static const char kExternalClearKeyKeySystem[] =
+ "org.chromium.externalclearkey";
+#elif defined(OS_ANDROID)
+static const uint8 kEmptyUuid[16] =
+ { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+static const uint8 kWidevineUuid[16] =
+ { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
+ 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
+#endif
-static const char kAudioMp4[] = "audio/mp4";
-static const char kVideoMp4[] = "video/mp4";
-static const char kMp4a[] = "mp4a";
-static const char kAvc1[] = "avc1";
-static const char kMp4aAvc1[] = "mp4a,avc1";
-
#if defined(WIDEVINE_CDM_AVAILABLE)
-enum SupportedCodecs {
- WEBM_VP8_AND_VORBIS = 1 << 0,
-#if defined(USE_PROPRIETARY_CODECS)
- MP4_AAC = 1 << 1,
- MP4_AVC1 = 1 << 2,
-#endif // defined(USE_PROPRIETARY_CODECS)
-};
-static void AddWidevineForTypes(
- SupportedCodecs supported_codecs,
- std::vector<KeySystemInfo>* concrete_key_systems) {
- static const char kWidevineParentKeySystem[] = "com.widevine";
-#if defined(OS_ANDROID)
- static const uint8 kWidevineUuid[16] = {
- 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
- 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
+#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)
+
+static void RegisterWidevine() {
#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
Version glibc_version(gnu_get_libc_version());
DCHECK(glibc_version.IsValid());
@@ -62,113 +68,74 @@
return;
#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
- KeySystemInfo info(kWidevineKeySystem);
-
- if (supported_codecs & WEBM_VP8_AND_VORBIS) {
- info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
- info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
- }
-
-#if defined(USE_PROPRIETARY_CODECS)
- if (supported_codecs & MP4_AAC)
- info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a));
-
- if (supported_codecs & MP4_AVC1) {
- const char* video_codecs = (supported_codecs & MP4_AAC) ? kMp4aAvc1 : kAvc1;
- info.supported_types.push_back(std::make_pair(kVideoMp4, video_codecs));
- }
-#endif // defined(USE_PROPRIETARY_CODECS)
-
- info.parent_key_system = kWidevineParentKeySystem;
-
+ AddConcreteSupportedKeySystem(
+ kWidevineKeySystem,
+ false,
#if defined(ENABLE_PEPPER_CDMS)
- info.pepper_type = kWidevineCdmPluginMimeType;
+ kWidevineCdmPluginMimeType,
#elif defined(OS_ANDROID)
- info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid));
+ kWidevineUuid,
#endif // defined(ENABLE_PEPPER_CDMS)
-
- concrete_key_systems->push_back(info);
+ "com.widevine");
+#if !defined(OS_ANDROID)
+ AddSupportedType(kWidevineKeySystem, "video/webm", "vorbis,vp8,vp8.0");
+ AddSupportedType(kWidevineKeySystem, "audio/webm", "vorbis");
+#endif // !defined(OS_ANDROID)
+#if defined(USE_PROPRIETARY_CODECS) && \
+ defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
+ AddSupportedType(kWidevineKeySystem, "video/mp4", kWidevineVideoMp4Codecs);
+ AddSupportedType(kWidevineKeySystem, "audio/mp4", kWidevineAudioMp4Codecs);
+#endif // defined(USE_PROPRIETARY_CODECS) &&
+ // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
}
+#endif // WIDEVINE_CDM_AVAILABLE
-#if defined(ENABLE_PEPPER_CDMS)
-// Supported types are determined at compile time.
-static void AddPepperBasedWidevine(
- std::vector<KeySystemInfo>* concrete_key_systems) {
- SupportedCodecs supported_codecs = WEBM_VP8_AND_VORBIS;
-#if defined(USE_PROPRIETARY_CODECS)
-#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
- supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AAC);
-#endif
-#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
- supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1);
-#endif
-#endif // defined(USE_PROPRIETARY_CODECS)
-
- AddWidevineForTypes(supported_codecs, concrete_key_systems);
-}
+static void RegisterClearKey() {
+ // Clear Key.
+ AddConcreteSupportedKeySystem(
+ kClearKeyKeySystem,
+ true,
+#if defined(ENABLE_PEPPER_CDMS)
+ std::string(),
#elif defined(OS_ANDROID)
-static void AddAndroidWidevine(
- std::vector<KeySystemInfo>* concrete_key_systems) {
- SupportedCodecs supported_codecs = MP4_AAC | MP4_AVC1;
- AddWidevineForTypes(supported_codecs, concrete_key_systems);
-}
+ kEmptyUuid,
#endif // defined(ENABLE_PEPPER_CDMS)
-#endif // defined(WIDEVINE_CDM_AVAILABLE)
-
-static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) {
- KeySystemInfo info(kClearKeyKeySystem);
-
- info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
- info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
+ std::string());
+ AddSupportedType(kClearKeyKeySystem, "video/webm", "vorbis,vp8,vp8.0");
+ AddSupportedType(kClearKeyKeySystem, "audio/webm", "vorbis");
#if defined(USE_PROPRIETARY_CODECS)
- info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a));
- info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1));
+ AddSupportedType(kClearKeyKeySystem, "video/mp4", "avc1,mp4a");
+ AddSupportedType(kClearKeyKeySystem, "audio/mp4", "mp4a");
#endif // defined(USE_PROPRIETARY_CODECS)
-
- info.use_aes_decryptor = true;
-
- concrete_key_systems->push_back(info);
}
#if defined(ENABLE_PEPPER_CDMS)
-// External Clear Key (used for testing).
-static void AddExternalClearKey(
- std::vector<KeySystemInfo>* concrete_key_systems) {
- static const char kExternalClearKeyKeySystem[] =
- "org.chromium.externalclearkey";
- static const char kExternalClearKeyPepperType[] =
- "application/x-ppapi-clearkey-cdm";
-
- KeySystemInfo info(kExternalClearKeyKeySystem);
-
- info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
- info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
+static void RegisterExternalClearKey() {
+ // External Clear Key (used for testing).
+ AddConcreteSupportedKeySystem(kExternalClearKeyKeySystem, false,
+ "application/x-ppapi-clearkey-cdm",
+ std::string());
+ AddSupportedType(kExternalClearKeyKeySystem,
+ "video/webm", "vorbis,vp8,vp8.0");
+ AddSupportedType(kExternalClearKeyKeySystem, "audio/webm", "vorbis");
#if defined(USE_PROPRIETARY_CODECS)
- info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a));
- info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1));
+ AddSupportedType(kExternalClearKeyKeySystem, "video/mp4", "avc1,mp4a");
+ AddSupportedType(kExternalClearKeyKeySystem, "audio/mp4", "mp4a");
#endif // defined(USE_PROPRIETARY_CODECS)
-
- info.pepper_type = kExternalClearKeyPepperType;
-
- concrete_key_systems->push_back(info);
}
#endif // defined(ENABLE_PEPPER_CDMS)
-void AddKeySystems(std::vector<KeySystemInfo>* key_systems_info) {
- AddClearKey(key_systems_info);
+void RegisterKeySystems() {
+ RegisterClearKey();
#if defined(ENABLE_PEPPER_CDMS)
- AddExternalClearKey(key_systems_info);
+ RegisterExternalClearKey();
#endif
#if defined(WIDEVINE_CDM_AVAILABLE)
-#if defined(ENABLE_PEPPER_CDMS)
- AddPepperBasedWidevine(key_systems_info);
-#elif defined(OS_ANDROID)
- AddAndroidWidevine(key_systems_info);
+ RegisterWidevine();
#endif
-#endif
}
bool IsCanPlayTypeSuppressed(const std::string& key_system) {

Powered by Google App Engine
This is Rietveld 408576698