Index: media/base/key_systems.cc |
diff --git a/media/base/key_systems.cc b/media/base/key_systems.cc |
index d4f43872218af86e85aeead326aa8a6528447457..28051985744341ea94846eb15ab6c6da1e4ca4bd 100644 |
--- a/media/base/key_systems.cc |
+++ b/media/base/key_systems.cc |
@@ -98,6 +98,10 @@ static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { |
info.supported_codecs |= EME_CODEC_MP4_ALL; |
#endif // defined(USE_PROPRIETARY_CODECS) |
+ info.persistent_state_requirement = EME_REQUIREMENT_NOT_ALLOWED; |
+ info.distinctive_identifier_requirement = EME_REQUIREMENT_NOT_ALLOWED; |
+ info.supported_session_types = EME_SESSION_TYPE_TEMPORARY; |
+ |
info.use_aes_decryptor = true; |
concrete_key_systems->push_back(info); |
@@ -131,6 +135,18 @@ class KeySystems { |
std::string GetPepperType(const std::string& concrete_key_system); |
#endif |
+ bool IsSupportedDistinctiveIdentifierRequirement( |
+ const std::string& key_system, |
+ EmeRequirement requirement); |
+ |
+ bool IsSupportedPersistentStateRequirement( |
+ const std::string& key_system, |
+ EmeRequirement requirement); |
+ |
+ bool IsSupportedSessionType( |
+ const std::string& key_system, |
+ EmeSessionType session_Type); |
+ |
void AddContainerMask(const std::string& container, uint32 mask); |
void AddCodecMask(const std::string& codec, uint32 mask); |
@@ -142,32 +158,9 @@ class KeySystems { |
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, |
-#endif |
- SupportedInitDataTypes supported_init_data_types, |
- SupportedCodecs supported_codecs, |
- const std::string& parent_key_system); |
- |
friend struct base::DefaultLazyInstanceTraits<KeySystems>; |
- struct KeySystemProperties { |
- KeySystemProperties() |
- : use_aes_decryptor(false), supported_codecs(EME_CODEC_NONE) {} |
- |
- bool use_aes_decryptor; |
-#if defined(ENABLE_PEPPER_CDMS) |
- std::string pepper_type; |
-#endif |
- SupportedInitDataTypes supported_init_data_types; |
- SupportedCodecs supported_codecs; |
- }; |
- |
- typedef base::hash_map<std::string, KeySystemProperties> |
- KeySystemPropertiesMap; |
+ typedef base::hash_map<std::string, KeySystemInfo> KeySystemInfoMap; |
typedef base::hash_map<std::string, std::string> ParentKeySystemMap; |
typedef base::hash_map<std::string, SupportedCodecs> ContainerCodecsMap; |
typedef base::hash_map<std::string, EmeCodec> CodecsMap; |
@@ -202,7 +195,7 @@ class KeySystems { |
SupportedCodecs key_system_supported_codecs) const; |
// Map from key system string to capabilities. |
- KeySystemPropertiesMap concrete_key_system_map_; |
+ KeySystemInfoMap concrete_key_system_map_; |
// Map from parent key system to the concrete key system that should be used |
// to represent its capabilities. |
@@ -337,52 +330,32 @@ void KeySystems::AddConcreteSupportedKeySystems( |
DCHECK(concrete_key_system_map_.empty()); |
DCHECK(parent_key_system_map_.empty()); |
- 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, |
+ for (const KeySystemInfo& info : concrete_key_systems) { |
+ DCHECK(!info.key_system.empty()) << "Missing key system name"; |
ddorwin
2015/02/17 22:34:58
nit: The << part is probably unnecessary for this
sandersd (OOO until July 31)
2015/02/18 23:41:17
Done.
sandersd (OOO until July 31)
2015/02/18 23:41:17
Done.
|
+ DCHECK(!IsConcreteSupportedKeySystem(info.key_system)) |
ddorwin
2015/02/17 22:34:58
I believe this needs to change after https://coder
sandersd (OOO until July 31)
2015/02/18 23:41:17
Done.
|
+ << "Key system '" << info.key_system << "' already registered"; |
+ DCHECK(!parent_key_system_map_.count(info.key_system)) |
+ << "'" << info.key_system << "' is already registered as a parent"; |
#if defined(ENABLE_PEPPER_CDMS) |
- key_system_info.pepper_type, |
+ DCHECK_EQ(info.use_aes_decryptor, info.pepper_type.empty()); |
#endif |
- key_system_info.supported_init_data_types, |
- key_system_info.supported_codecs, |
- key_system_info.parent_key_system); |
- } |
-} |
- |
-void KeySystems::AddConcreteSupportedKeySystem( |
- const std::string& concrete_key_system, |
- bool use_aes_decryptor, |
-#if defined(ENABLE_PEPPER_CDMS) |
- const std::string& pepper_type, |
-#endif |
- SupportedInitDataTypes supported_init_data_types, |
- SupportedCodecs supported_codecs, |
- const std::string& parent_key_system) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
- DCHECK(!IsConcreteSupportedKeySystem(concrete_key_system)) |
- << "Key system '" << concrete_key_system << "' already registered"; |
- DCHECK(!parent_key_system_map_.count(concrete_key_system)) |
- << "'" << concrete_key_system << " is already registered as a parent"; |
- KeySystemProperties properties; |
- properties.use_aes_decryptor = use_aes_decryptor; |
-#if defined(ENABLE_PEPPER_CDMS) |
- DCHECK_EQ(use_aes_decryptor, pepper_type.empty()); |
- properties.pepper_type = pepper_type; |
-#endif |
- |
- properties.supported_init_data_types = supported_init_data_types; |
- properties.supported_codecs = supported_codecs; |
- |
- 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_.count(parent_key_system)) |
- << "Parent '" << parent_key_system << "' already registered"; |
- parent_key_system_map_[parent_key_system] = concrete_key_system; |
+ if (info.supported_session_types == EME_SESSION_TYPE_NONE) { |
+ NOTREACHED() << "Key system '" << info.key_system << "' does not support" |
ddorwin
2015/02/17 22:34:58
nit: The issue is really that no session types wer
sandersd (OOO until July 31)
2015/02/18 23:41:18
Done.
|
+ << "any session types"; |
+ continue; |
+ } |
+ |
ddorwin
2015/02/17 22:34:58
We can DCHECK that the persistent session types ar
sandersd (OOO until July 31)
2015/02/18 23:41:17
Done.
|
+ concrete_key_system_map_[info.key_system] = info; |
+ |
+ if (!info.parent_key_system.empty()) { |
+ DCHECK(!IsConcreteSupportedKeySystem(info.parent_key_system)) |
+ << "Parent '" << info.parent_key_system << "' " |
+ << "already registered concrete"; |
+ DCHECK(!parent_key_system_map_.count(info.parent_key_system)) |
+ << "Parent '" << info.parent_key_system << "' already registered"; |
+ parent_key_system_map_[info.parent_key_system] = info.key_system; |
+ } |
} |
} |
@@ -459,15 +432,15 @@ bool KeySystems::IsSupportedKeySystemWithInitDataType( |
const std::string& concrete_key_system = GetConcreteKeySystemName(key_system); |
// Locate |concrete_key_system|. |
- KeySystemPropertiesMap::const_iterator key_system_iter = |
+ KeySystemInfoMap::const_iterator key_system_iter = |
concrete_key_system_map_.find(concrete_key_system); |
if (key_system_iter == concrete_key_system_map_.end()) |
return false; |
// Check |init_data_type| and |key_system| x |init_data_type|. |
- const KeySystemProperties& properties = key_system_iter->second; |
+ const KeySystemInfo& info = key_system_iter->second; |
EmeInitDataType eme_init_data_type = GetInitDataTypeForName(init_data_type); |
- return (properties.supported_init_data_types & eme_init_data_type) != 0; |
+ return (info.supported_init_data_types & eme_init_data_type) != 0; |
} |
// TODO(sandersd): Reorganize to be more similar to |
@@ -489,7 +462,7 @@ bool KeySystems::IsSupportedKeySystemWithMediaMimeType( |
key_systems_support_uma_.ReportKeySystemQuery(key_system, has_type); |
// Check key system support. |
- KeySystemPropertiesMap::const_iterator key_system_iter = |
+ KeySystemInfoMap::const_iterator key_system_iter = |
concrete_key_system_map_.find(concrete_key_system); |
if (key_system_iter == concrete_key_system_map_.end()) |
return false; |
@@ -534,7 +507,7 @@ std::string KeySystems::GetKeySystemNameForUMA( |
bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- KeySystemPropertiesMap::const_iterator key_system_iter = |
+ KeySystemInfoMap::const_iterator key_system_iter = |
concrete_key_system_map_.find(concrete_key_system); |
if (key_system_iter == concrete_key_system_map_.end()) { |
DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
@@ -548,7 +521,7 @@ bool KeySystems::UseAesDecryptor(const std::string& concrete_key_system) { |
std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- KeySystemPropertiesMap::const_iterator key_system_iter = |
+ KeySystemInfoMap::const_iterator key_system_iter = |
concrete_key_system_map_.find(concrete_key_system); |
if (key_system_iter == concrete_key_system_map_.end()) { |
DLOG(FATAL) << concrete_key_system << " is not a known concrete system"; |
@@ -561,6 +534,51 @@ std::string KeySystems::GetPepperType(const std::string& concrete_key_system) { |
} |
#endif |
+bool KeySystems::IsSupportedDistinctiveIdentifierRequirement( |
+ const std::string& key_system, |
+ EmeRequirement requirement) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ KeySystemInfoMap::const_iterator key_system_iter = |
+ concrete_key_system_map_.find(key_system); |
+ if (key_system_iter == concrete_key_system_map_.end()) |
+ return false; |
+ EmeRequirement requirement_mask = |
ddorwin
2015/02/17 22:34:58
An enum cannot be a mask. You must use an int. If
sandersd (OOO until July 31)
2015/02/18 23:41:18
Acknowledged.
|
+ key_system_iter->second.distinctive_identifier_requirement; |
+ |
+ return (requirement & requirement_mask) != 0; |
+} |
+ |
+bool KeySystems::IsSupportedPersistentStateRequirement( |
+ const std::string& key_system, |
+ EmeRequirement requirement) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ KeySystemInfoMap::const_iterator key_system_iter = |
+ concrete_key_system_map_.find(key_system); |
+ if (key_system_iter == concrete_key_system_map_.end()) |
+ return false; |
+ EmeRequirement requirement_mask = |
ddorwin
2015/02/17 22:34:57
ditto
sandersd (OOO until July 31)
2015/02/18 23:41:17
Acknowledged.
|
+ key_system_iter->second.persistent_state_requirement; |
+ |
+ return (requirement & requirement_mask) != 0; |
+} |
+ |
+bool KeySystems::IsSupportedSessionType( |
+ const std::string& key_system, |
+ EmeSessionType session_type) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ KeySystemInfoMap::const_iterator key_system_iter = |
+ concrete_key_system_map_.find(key_system); |
+ if (key_system_iter == concrete_key_system_map_.end()) |
+ return false; |
+ SupportedSessionTypes session_type_mask = |
ddorwin
2015/02/17 22:34:58
This one is okay.
sandersd (OOO until July 31)
2015/02/18 23:41:17
Acknowledged.
|
+ key_system_iter->second.supported_session_types; |
+ |
+ return (session_type & session_type_mask) != 0; |
+} |
+ |
void KeySystems::AddContainerMask(const std::string& container, uint32 mask) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
DCHECK(!container_to_codec_mask_map_.count(container)); |
@@ -651,14 +669,34 @@ std::string GetPepperType(const std::string& concrete_key_system) { |
} |
#endif |
+bool IsSupportedDistinctiveIdentifierRequirement( |
+ const std::string& key_system, |
+ EmeRequirement requirement) { |
+ return KeySystems::GetInstance().IsSupportedDistinctiveIdentifierRequirement( |
+ key_system, requirement); |
+} |
+ |
+bool IsSupportedPersistentStateRequirement( |
+ const std::string& key_system, |
+ EmeRequirement requirement) { |
+ return KeySystems::GetInstance().IsSupportedPersistentStateRequirement( |
+ key_system, requirement); |
+} |
+ |
+bool IsSupportedSessionType( |
+ const std::string& key_system, |
+ EmeSessionType session_type) { |
+ return KeySystems::GetInstance().IsSupportedSessionType( |
+ key_system, session_type); |
+} |
+ |
// These two functions are for testing purpose only. The declaration in the |
// header file is guarded by "#if defined(UNIT_TEST)" so that they can be used |
// by tests but not non-test code. However, this .cc file is compiled as part of |
// "media" where "UNIT_TEST" is not defined. So we need to specify |
// "MEDIA_EXPORT" here again so that they are visible to tests. |
-MEDIA_EXPORT void AddContainerMask(const std::string& container, |
- uint32 mask) { |
+MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
KeySystems::GetInstance().AddContainerMask(container, mask); |
} |