Commit c31b38ef authored by rouslan@chromium.org's avatar rouslan@chromium.org

Revert 222074 "Refactor KeySystems code to call a function to po..."

Revision 222074 did not go through the commit queue. Failing
contet_unittests on win-aura:

  KeySystemsTest.ClearKey_Basic
  KeySystemsTest.ClearKey_Parent
  KeySystemsTest.ExternalClearKey_Parent
  KeySystemsTest.Widevine_Basic
  KeySystemsTest.Widevine_Parent

> Refactor KeySystems code to call a function to populate the info. (re-land r221932)
> 
> This allows KeySystems to call GetContentClient()->AddKeySystems() so we can
> move key system information to chrome/. The new ContentClient API is defined and
> called, but we still rely on key_systems_info.cc.
> 
> BUG=224793
> TEST=Existing content_unittests and content_browsertests pass.
> TBR=jam@chromium.org
> 
> Review URL: https://codereview.chromium.org/23484019

TBR=ddorwin@chromium.org

Review URL: https://codereview.chromium.org/23708020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222091 0039d316-1c4b-4281-b951-d872f2087c98
parent fa4d9193
......@@ -1300,13 +1300,6 @@ bool ChromeContentRendererClient::AllowPepperMediaStreamAPI(
return false;
}
void ChromeContentRendererClient::AddKeySystems(
std::vector<content::KeySystemInfo>* key_systems) {
// TODO(ddorwin): In the next CL, move code from
// content/renderer/media/crypto/key_systems_info.cc to chrome_key_systems.cc
// and call AddKeySystems.
}
bool ChromeContentRendererClient::ShouldReportDetailedMessageForSource(
const base::string16& source) const {
return extensions::IsSourceFromAnExtension(source);
......
......@@ -140,8 +140,6 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
const base::string16& source) const OVERRIDE;
virtual bool ShouldEnableSiteIsolationPolicy() const OVERRIDE;
virtual bool AllowPepperMediaStreamAPI(const GURL& url) OVERRIDE;
virtual void AddKeySystems(
std::vector<content::KeySystemInfo>* key_systems) OVERRIDE;
// For testing.
void SetExtensionDispatcher(extensions::Dispatcher* extension_dispatcher);
......
......@@ -40,8 +40,6 @@
'public/renderer/document_state.h',
'public/renderer/history_item_serialization.cc',
'public/renderer/history_item_serialization.h',
'public/renderer/key_system_info.cc',
'public/renderer/key_system_info.h',
'public/renderer/navigation_state.cc',
'public/renderer/navigation_state.h',
'public/renderer/pepper_plugin_instance.h',
......
......@@ -182,10 +182,6 @@ bool ContentRendererClient::AllowPepperMediaStreamAPI(const GURL& url) {
return false;
}
void ContentRendererClient::AddKeySystems(
std::vector<KeySystemInfo>* key_systems) {
}
bool ContentRendererClient::ShouldReportDetailedMessageForSource(
const base::string16& source) const {
return false;
......
......@@ -6,7 +6,6 @@
#define CONTENT_PUBLIC_RENDERER_CONTENT_RENDERER_CLIENT_H_
#include <string>
#include <vector>
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
......@@ -52,7 +51,6 @@ namespace content {
class RenderView;
class SynchronousCompositor;
struct KeySystemInfo;
struct WebPluginInfo;
// Embedder API for participating in renderer logic.
......@@ -246,10 +244,6 @@ class CONTENT_EXPORT ContentRendererClient {
// Returns true if the page at |url| can use Pepper MediaStream APIs.
virtual bool AllowPepperMediaStreamAPI(const GURL& url);
// Gives the embedder a chance to register the key system(s) it supports by
// populating |key_systems|.
virtual void AddKeySystems(std::vector<KeySystemInfo>* key_systems);
// Returns true if we should report a detailed message (including a stack
// trace) for console [logs|errors|exceptions]. |source| is the WebKit-
// reported source for the error; this can point to a page or a script,
......
// Copyright 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 "content/public/renderer/key_system_info.h"
namespace content {
KeySystemInfo::KeySystemInfo(const std::string& key_system)
: key_system(key_system),
use_aes_decryptor(false) {
}
KeySystemInfo::~KeySystemInfo() {
}
} // namespace content
// Copyright 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 CONTENT_PUBLIC_RENDERER_KEY_SYSTEM_INFO_H_
#define CONTENT_PUBLIC_RENDERER_KEY_SYSTEM_INFO_H_
#include <string>
#include <utility>
#include <vector>
#include "base/basictypes.h"
#include "content/common/content_export.h"
// Definitions:
// * Key system
// https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#key-system
// * Concrete key system
// A key system string that can be instantiated, such as
// via the MediaKeys constructor. Examples include "org.w3.clearkey" and
// "com.widevine.alpha".
// * Abstract key system
// A key system string that cannot be instantiated like a concrete key system
// but is otherwise useful, such as in discovery using isTypeSupported().
// * Parent key system
// A key system string that is one level up from the child key system. It may
// be an abstract key system.
// As an example, "com.example" is the parent of "com.example.foo".
namespace content {
// Contains information about an EME key system as well as how to instantiate
// the corresponding CDM.
struct CONTENT_EXPORT KeySystemInfo {
// Represents container-codec combinations. The second string may contain zero
// or more codecs separated by commas.
typedef std::pair<std::string, std::string> ContainerCodecsPair;
explicit KeySystemInfo(const std::string& key_system);
~KeySystemInfo();
std::string key_system;
// Specifies container and codec combinations supported by |key_system|.
// Multiple codecs may be listed for each container.
// In all cases, the container without a codec is also always supported.
std::vector<ContainerCodecsPair> supported_types;
// A hierarchical parent for |key_system|. This value can be used to check
// supported types but cannot be used to instantiate a MediaKeys object.
// Only one parent key system is currently supported per concrete key system.
std::string parent_key_system;
// The following indicate how the corresponding CDM should be instantiated.
bool use_aes_decryptor;
#if defined(ENABLE_PEPPER_CDMS)
std::string pepper_type;
#elif defined(OS_ANDROID)
std::vector<uint8> uuid;
#endif
};
} // namespace content
#endif // CONTENT_PUBLIC_RENDERER_KEY_SYSTEM_INFO_H_
......@@ -9,9 +9,6 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "content/public/common/content_client.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/key_system_info.h"
#include "content/renderer/media/crypto/key_systems_info.h"
#include "net/base/mime_util.h"
#include "third_party/WebKit/public/platform/WebCString.h"
......@@ -27,7 +24,21 @@ static std::string ToASCIIOrEmpty(const WebKit::WebString& string) {
class KeySystems {
public:
static KeySystems& GetInstance();
static KeySystems* GetInstance();
void AddConcreteSupportedKeySystem(
const std::string& key_system,
bool use_aes_decryptor,
#if defined(ENABLE_PEPPER_CDMS)
const std::string& pepper_type,
#elif defined(OS_ANDROID)
const uint8 uuid[16],
#endif
const std::string& parent_key_system);
void AddSupportedType(const std::string& key_system,
const std::string& mime_type,
const std::string& codecs_list);
bool IsConcreteSupportedKeySystem(const std::string& key_system);
......@@ -45,21 +56,6 @@ class KeySystems {
#endif
private:
void AddConcreteSupportedKeySystems(
const std::vector<KeySystemInfo>& concrete_key_systems);
void AddConcreteSupportedKeySystem(
const std::string& key_system,
bool use_aes_decryptor,
#if defined(ENABLE_PEPPER_CDMS)
const std::string& pepper_type,
#elif defined(OS_ANDROID)
const std::vector<uint8>& uuid,
#endif
const std::vector<KeySystemInfo::ContainerCodecsPair>& supported_types,
const std::string& parent_key_system);
friend struct base::DefaultLazyInstanceTraits<KeySystems>;
typedef base::hash_set<std::string> CodecSet;
......@@ -81,12 +77,7 @@ class KeySystems {
typedef std::map<std::string, std::string> ParentKeySystemMap;
KeySystems();
~KeySystems() {}
void AddSupportedType(const std::string& mime_type,
const std::string& codecs_list,
KeySystemProperties* properties);
KeySystems() {}
bool IsSupportedKeySystemWithContainerAndCodec(
const std::string& mime_type,
......@@ -105,35 +96,15 @@ class KeySystems {
static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER;
KeySystems& KeySystems::GetInstance() {
return g_key_systems.Get();
}
// Because we use a LazyInstance, the key systems info must be populated when
// the instance is lazily initiated.
KeySystems::KeySystems() {
std::vector<KeySystemInfo> key_systems_info;
GetContentClient()->renderer()->AddKeySystems(&key_systems_info);
// TODO(ddorwin): Remove in next CL after moving info to
// ChromeContentRendererClient.
AddKeySystems(&key_systems_info);
AddConcreteSupportedKeySystems(key_systems_info);
}
void KeySystems::AddConcreteSupportedKeySystems(
const std::vector<KeySystemInfo>& concrete_key_systems) {
for (size_t i = 0; i < concrete_key_systems.size(); ++i) {
const KeySystemInfo& key_system_info = concrete_key_systems[i];
AddConcreteSupportedKeySystem(key_system_info.key_system,
key_system_info.use_aes_decryptor,
#if defined(ENABLE_PEPPER_CDMS)
key_system_info.pepper_type,
#elif defined(OS_ANDROID)
key_system_info.uuid,
#endif
key_system_info.supported_types,
key_system_info.parent_key_system);
KeySystems* KeySystems::GetInstance() {
KeySystems* key_systems = &g_key_systems.Get();
// TODO(ddorwin): Call out to ContentClient to register key systems.
static bool is_registered = false;
if (!is_registered) {
is_registered = true; // Prevent reentrancy when Add*() is called.
RegisterKeySystems();
}
return key_systems;
}
void KeySystems::AddConcreteSupportedKeySystem(
......@@ -142,15 +113,11 @@ void KeySystems::AddConcreteSupportedKeySystem(
#if defined(ENABLE_PEPPER_CDMS)
const std::string& pepper_type,
#elif defined(OS_ANDROID)
const std::vector<uint8>& uuid,
const uint8 uuid[16],
#endif
const std::vector<KeySystemInfo::ContainerCodecsPair>& supported_types,
const std::string& parent_key_system) {
DCHECK(!IsConcreteSupportedKeySystem(concrete_key_system))
<< "Key system '" << concrete_key_system << "' already registered";
DCHECK(parent_key_system_map_.find(concrete_key_system) ==
parent_key_system_map_.end())
<< "'" << concrete_key_system << " is already registered as a parent";
KeySystemProperties properties;
properties.use_aes_decryptor = use_aes_decryptor;
......@@ -158,33 +125,23 @@ void KeySystems::AddConcreteSupportedKeySystem(
DCHECK_EQ(use_aes_decryptor, pepper_type.empty());
properties.pepper_type = pepper_type;
#elif defined(OS_ANDROID)
DCHECK_EQ(use_aes_decryptor, uuid.empty());
DCHECK(use_aes_decryptor || uuid.size() == 16);
properties.uuid = uuid;
// Since |uuid| can't be empty, use |use_aes_decryptor|.
if (!use_aes_decryptor)
properties.uuid.assign(uuid, uuid + 16);
#endif
for (size_t i = 0; i < supported_types.size(); ++i) {
const KeySystemInfo::ContainerCodecsPair& pair = supported_types[i];
const std::string& mime_type = pair.first;
const std::string& codecs_list = pair.second;
AddSupportedType(mime_type, codecs_list, &properties);
}
concrete_key_system_map_[concrete_key_system] = properties;
if (!parent_key_system.empty()) {
DCHECK(!IsConcreteSupportedKeySystem(parent_key_system))
<< "Parent '" << parent_key_system << "' already registered concrete";
DCHECK(parent_key_system_map_.find(parent_key_system) ==
parent_key_system_map_.end())
<< "Parent '" << parent_key_system << "' already registered";
<< "Parent '" << parent_key_system.c_str() << "' already registered.";
parent_key_system_map_[parent_key_system] = concrete_key_system;
}
}
void KeySystems::AddSupportedType(const std::string& mime_type,
const std::string& codecs_list,
KeySystemProperties* properties) {
void KeySystems::AddSupportedType(const std::string& concrete_key_system,
const std::string& mime_type,
const std::string& codecs_list) {
std::vector<std::string> mime_type_codecs;
net::ParseCodecString(codecs_list, &mime_type_codecs, false);
......@@ -192,7 +149,10 @@ void KeySystems::AddSupportedType(const std::string& mime_type,
// Support the MIME type string alone, without codec(s) specified.
codecs.insert(std::string());
MimeTypeMap& mime_types_map = properties->types;
KeySystemPropertiesMap::iterator key_system_iter =
concrete_key_system_map_.find(concrete_key_system);
DCHECK(key_system_iter != concrete_key_system_map_.end());
MimeTypeMap& mime_types_map = key_system_iter->second.types;
// mime_types_map must not be repeated for a given key system.
DCHECK(mime_types_map.find(mime_type) == mime_types_map.end());
mime_types_map[mime_type] = codecs;
......@@ -294,8 +254,34 @@ std::vector<uint8> KeySystems::GetUUID(const std::string& concrete_key_system) {
//------------------------------------------------------------------------------
void AddConcreteSupportedKeySystem(
const std::string& key_system,
bool use_aes_decryptor,
#if defined(ENABLE_PEPPER_CDMS)
const std::string& pepper_type,
#elif defined(OS_ANDROID)
const uint8 uuid[16],
#endif
const std::string& parent_key_system) {
KeySystems::GetInstance()->AddConcreteSupportedKeySystem(key_system,
use_aes_decryptor,
#if defined(ENABLE_PEPPER_CDMS)
pepper_type,
#elif defined(OS_ANDROID)
uuid,
#endif
parent_key_system);
}
void AddSupportedType(const std::string& key_system,
const std::string& mime_type,
const std::string& codecs_list) {
KeySystems::GetInstance()->AddSupportedType(key_system,
mime_type, codecs_list);
}
bool IsConcreteSupportedKeySystem(const WebKit::WebString& key_system) {
return KeySystems::GetInstance().IsConcreteSupportedKeySystem(
return KeySystems::GetInstance()->IsConcreteSupportedKeySystem(
ToASCIIOrEmpty(key_system));
}
......@@ -303,7 +289,7 @@ bool IsSupportedKeySystemWithMediaMimeType(
const std::string& mime_type,
const std::vector<std::string>& codecs,
const std::string& key_system) {
return KeySystems::GetInstance().IsSupportedKeySystemWithMediaMimeType(
return KeySystems::GetInstance()->IsSupportedKeySystemWithMediaMimeType(
mime_type, codecs, key_system);
}
......@@ -312,16 +298,16 @@ std::string KeySystemNameForUMA(const WebKit::WebString& key_system) {
}
bool CanUseAesDecryptor(const std::string& concrete_key_system) {
return KeySystems::GetInstance().UseAesDecryptor(concrete_key_system);
return KeySystems::GetInstance()->UseAesDecryptor(concrete_key_system);
}
#if defined(ENABLE_PEPPER_CDMS)
std::string GetPepperType(const std::string& concrete_key_system) {
return KeySystems::GetInstance().GetPepperType(concrete_key_system);
return KeySystems::GetInstance()->GetPepperType(concrete_key_system);
}
#elif defined(OS_ANDROID)
std::vector<uint8> GetUUID(const std::string& concrete_key_system) {
return KeySystems::GetInstance().GetUUID(concrete_key_system);
return KeySystems::GetInstance()->GetUUID(concrete_key_system);
}
#endif
......
......@@ -15,8 +15,49 @@ namespace WebKit {
class WebString;
}
// Definitions:
// * Key system
// https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#key-system
// * Concrete key system
// A key system string that can be instantiated, such as
// via the MediaKeys constructor. Examples include "org.w3.clearkey" and
// "com.widevine.alpha".
// * Abstract key system
// A key system string that cannot be instantiated like a concrete key system
// but is otherwise useful, such as in discovery using isTypeSupported().
// * Parent key system
// A key system string that is one level up from the child key system. It may
// be an abstract key system.
// As an example, "com.example" is the parent of "com.example.foo".
namespace content {
// Adds a concrete key system along with platform-specific information about how
// to instantiate it. Must be called before AddSupportedType().
// May only be called once per |concrete_key_system|.
// When not empty, |parent_key_system| will add a mapping to the
// |concrete_key_system| that can be used to check supported types.
// Only one parent key system is currently supported per concrete key system.
CONTENT_EXPORT void AddConcreteSupportedKeySystem(
const std::string& concrete_key_system,
bool use_aes_decryptor,
#if defined(ENABLE_PEPPER_CDMS)
const std::string& pepper_type,
#elif defined(OS_ANDROID)
const uint8 uuid[16],
#endif
const std::string& parent_key_system);
// Specifies the container and codec combinations supported by
// |concrete_key_system|.
// Multiple codecs can be listed. In all cases, the container
// without a codec is also supported.
// |concrete_key_system| must be a concrete supported key system previously
// added using AddConcreteSupportedKeySystem().
CONTENT_EXPORT void AddSupportedType(const std::string& concrete_key_system,
const std::string& mime_type,
const std::string& codecs_list);
// Returns whether |key_system| is a real supported key system that can be
// instantiated.
// Abstract parent |key_system| strings will return false.
......
......@@ -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 @@ namespace content {
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";
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(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
#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,112 +68,73 @@ static void AddWidevineForTypes(
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);
#endif
RegisterWidevine();
#endif
}
......
......@@ -8,8 +8,6 @@
#include <string>
#include "base/basictypes.h"
// TODO(ddorwin): Remove when AddKeySystems is removed.
#include "content/public/renderer/key_system_info.h"
namespace WebKit {
class WebString;
......@@ -18,7 +16,7 @@ class WebString;
namespace content {
// TODO(ddorwin): Move registration to ContentClient.
void AddKeySystems(std::vector<KeySystemInfo>* key_systems_info);
void RegisterKeySystems();
// Returns true if canPlayType should return an empty string for |key_system|.
bool IsCanPlayTypeSuppressed(const std::string& key_system);
......
......@@ -5,8 +5,6 @@
#include <string>
#include <vector>
#include "content/public/common/content_client.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/media/crypto/key_systems.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/platform/WebString.h"
......@@ -140,8 +138,6 @@ class KeySystemsTest : public testing::Test {
mixed_codecs_.push_back("vorbis");
mixed_codecs_.push_back("avc1");
SetRendererClientForTesting(&content_renderer_client_);
}
typedef std::vector<std::string> CodecVector;
......@@ -189,7 +185,6 @@ class KeySystemsTest : public testing::Test {
CodecVector mixed_codecs_;
ContentRendererClient content_renderer_client_;
};
TEST_F(KeySystemsTest, ClearKey_Basic) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment