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

Unified Diff: media/base/key_systems.cc

Issue 923283002: Implement checks for distinctiveIdentifier and persistentState in requestMediaKeySystemAccess(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cast Widevine config Created 5 years, 10 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: media/base/key_systems.cc
diff --git a/media/base/key_systems.cc b/media/base/key_systems.cc
index b1c7e05a81b726899f84d9dc249d877cc853bad8..8b2e9008ce3b2b10b8e79ae42316fd2fe5fd3bd9 100644
--- a/media/base/key_systems.cc
+++ b/media/base/key_systems.cc
@@ -74,7 +74,8 @@ static NamedCodec kCodecStrings[] = {
};
static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) {
- KeySystemInfo info(kClearKeyKeySystem);
+ KeySystemInfo info;
+ info.key_system = kClearKeyKeySystem;
// On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec:
// http://developer.android.com/guide/appendix/media-formats.html
@@ -98,6 +99,11 @@ static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) {
info.supported_codecs |= EME_CODEC_MP4_ALL;
#endif // defined(USE_PROPRIETARY_CODECS)
+ info.persistent_license_support = EME_SESSION_TYPE_NOT_SUPPORTED;
+ info.persistent_release_message_support = EME_SESSION_TYPE_NOT_SUPPORTED;
+ info.persistent_state_support = EME_FEATURE_NOT_SUPPORTED;
+ info.distinctive_identifier_support = EME_FEATURE_NOT_SUPPORTED;
+
info.use_aes_decryptor = true;
concrete_key_systems->push_back(info);
@@ -131,6 +137,24 @@ class KeySystems {
std::string GetPepperType(const std::string& concrete_key_system);
#endif
+ bool IsPersistentLicenseSupported(
ddorwin 2015/02/19 01:41:34 ditto from the .h file.
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
+ const std::string& key_system,
+ bool permission_granted);
+
+ bool IsPersistentReleaseMessageSupported(
+ const std::string& key_system,
+ bool permission_granted);
+
+ bool IsPersistentStateSupported(
+ const std::string& key_system,
+ EmeFeatureRequirement requirement,
+ bool permission_granted);
+
+ bool IsDistinctiveIdentifierSupported(
+ const std::string& key_system,
+ EmeFeatureRequirement requirement,
+ bool permission_granted);
+
void AddContainerMask(const std::string& container, uint32 mask);
void AddCodecMask(const std::string& codec, uint32 mask);
@@ -142,32 +166,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 +203,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 +338,42 @@ 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());
+ DCHECK_NE(info.persistent_license_support,
+ EME_SESSION_TYPE_SUPPORT_NOT_DECLARED);
+ DCHECK_NE(info.persistent_release_message_support,
+ EME_SESSION_TYPE_SUPPORT_NOT_DECLARED);
+ DCHECK_NE(info.persistent_state_support,
+ EME_FEATURE_SUPPORT_NOT_DECLARED);
+ DCHECK_NE(info.distinctive_identifier_support,
+ EME_FEATURE_SUPPORT_NOT_DECLARED);
+ DCHECK_NE(info.distinctive_identifier_support,
+ EME_FEATURE_SUPPORTED);
ddorwin 2015/02/19 01:41:33 also != EME_FEATURE_ALWAYS_AVAILABLE. That would n
sandersd (OOO until July 31) 2015/02/19 21:08:34 I've just added a comment for now.
+ if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) {
+ DCHECK_EQ(info.persistent_license_support,
+ EME_SESSION_TYPE_NOT_SUPPORTED);
+ DCHECK_EQ(info.persistent_release_message_support,
+ EME_SESSION_TYPE_NOT_SUPPORTED);
+ }
+ DCHECK(!IsConcreteSupportedKeySystem(info.key_system))
ddorwin 2015/02/19 01:41:34 IsSupportedKeySystem
sandersd (OOO until July 31) 2015/02/19 21:08:34 Why do we have both? They are identical.
ddorwin 2015/02/19 23:03:57 Once prefixed is removed, "concrete" won't be a th
sandersd (OOO until July 31) 2015/02/20 00:17:12 Acknowledged.
+ << "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
+ concrete_key_system_map_[info.key_system] = info;
- 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.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;
+ }
}
}
@@ -456,15 +447,15 @@ bool KeySystems::IsSupportedKeySystemWithInitDataType(
DCHECK(thread_checker_.CalledOnValidThread());
// Locate |key_system|. Only concrete key systems are supported in unprefixed.
- KeySystemPropertiesMap::const_iterator key_system_iter =
+ KeySystemInfoMap::const_iterator key_system_iter =
concrete_key_system_map_.find(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
@@ -490,7 +481,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;
@@ -535,7 +526,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";
@@ -549,7 +540,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";
@@ -562,6 +553,101 @@ std::string KeySystems::GetPepperType(const std::string& concrete_key_system) {
}
#endif
+bool KeySystems::IsPersistentLicenseSupported(
+ const std::string& key_system,
+ bool permission_granted) {
+ 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())
ddorwin 2015/02/19 01:41:33 Should this be a DCHECK instead? Should these be c
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
+ return false;
+ EmeSessionTypeSupport support =
+ key_system_iter->second.persistent_license_support;
+
+ EmeSessionTypeSupport requirement =
+ permission_granted ? EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION
+ : EME_SESSION_TYPE_SUPPORTED;
+ return support >= requirement;
ddorwin 2015/02/19 01:41:33 It's not obvious from the enum definitions that th
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
+}
+
+bool KeySystems::IsPersistentReleaseMessageSupported(
+ const std::string& key_system,
+ bool permission_granted) {
+ 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;
+ EmeSessionTypeSupport support =
+ key_system_iter->second.persistent_release_message_support;
+
+ EmeSessionTypeSupport permission_requirement =
+ permission_granted ? EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION
+ : EME_SESSION_TYPE_SUPPORTED;
+ return support >= permission_requirement;
+}
+
+bool KeySystems::IsPersistentStateSupported(
+ const std::string& key_system,
+ EmeFeatureRequirement requirement,
+ bool permission_granted) {
+ 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;
+ EmeFeatureSupport support = key_system_iter->second.persistent_state_support;
+
+ EmeFeatureSupport permission_requirement =
ddorwin 2015/02/19 04:23:41 This should only be in the specific case at line 6
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
+ permission_granted ? EME_FEATURE_SUPPORTED_WITH_PERMISSION
+ : EME_FEATURE_SUPPORTED;
+
+ switch (requirement) {
+ case EME_FEATURE_NOT_ALLOWED:
+ return support < EME_FEATURE_ALWAYS_AVAILABLE;
ddorwin 2015/02/19 01:41:34 USED makes more sense here (see earlier comment)
ddorwin 2015/02/19 04:23:41 This logic is only valid if we can enforce that CD
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
+ case EME_FEATURE_OPTIONAL:
+ return true;
+ case EME_FEATURE_REQUIRED:
+ return support >= permission_requirement;
ddorwin 2015/02/19 04:23:41 ditto with line 571, though this case would end up
sandersd (OOO until July 31) 2015/02/19 21:08:34 Done.
+ }
+
+ NOTREACHED();
+ return false;
+}
+
+bool KeySystems::IsDistinctiveIdentifierSupported(
+ const std::string& key_system,
+ EmeFeatureRequirement requirement,
+ bool permission_granted) {
+ 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;
+ EmeFeatureSupport support =
+ key_system_iter->second.distinctive_identifier_support;
+
+ EmeFeatureSupport permission_requirement =
+ permission_granted ? EME_FEATURE_SUPPORTED_WITH_PERMISSION
ddorwin 2015/02/19 04:23:41 See below.
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
+ : EME_FEATURE_SUPPORTED;
+
+ switch (requirement) {
+ case EME_FEATURE_NOT_ALLOWED:
+ return support < EME_FEATURE_ALWAYS_AVAILABLE;
ddorwin 2015/02/19 04:23:41 ditto with line 610 (and especially important here
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
+ case EME_FEATURE_OPTIONAL:
+ return true;
+ case EME_FEATURE_REQUIRED:
+ return support >= permission_requirement;
ddorwin 2015/02/19 04:23:42 Per the comment at line 352, some of the values ar
sandersd (OOO until July 31) 2015/02/19 21:08:35 Done.
+ }
+
+ NOTREACHED();
+ return false;
+}
+
void KeySystems::AddContainerMask(const std::string& container, uint32 mask) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!container_to_codec_mask_map_.count(container));
@@ -652,14 +738,43 @@ std::string GetPepperType(const std::string& concrete_key_system) {
}
#endif
+bool IsPersistentLicenseSupported(
+ const std::string& key_system,
+ bool permission_granted) {
+ return KeySystems::GetInstance().IsPersistentLicenseSupported(
+ key_system, permission_granted);
+}
+
+bool IsPersistentReleaseMessageSupported(
+ const std::string& key_system,
+ bool permission_granted) {
+ return KeySystems::GetInstance().IsPersistentReleaseMessageSupported(
+ key_system, permission_granted);
+}
+
+bool IsPersistentStateSupported(
+ const std::string& key_system,
+ EmeFeatureRequirement requirement,
+ bool permission_granted) {
+ return KeySystems::GetInstance().IsPersistentStateSupported(
+ key_system, requirement, permission_granted);
+}
+
+bool IsDistinctiveIdentifierSupported(
+ const std::string& key_system,
+ EmeFeatureRequirement requirement,
+ bool permission_granted) {
+ return KeySystems::GetInstance().IsDistinctiveIdentifierSupported(
+ key_system, requirement, permission_granted);
+}
+
// 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);
}

Powered by Google App Engine
This is Rietveld 408576698