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

Unified Diff: media/base/key_systems.cc

Issue 1005903003: Implement robustness strings in requestMediaKeySystemAccess(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 db12a13919196536d6de8b0dc1ff7ca7deea26ed..68e3c10490ae82d101b772bafb0b1ff08d622a2a 100644
--- a/media/base/key_systems.cc
+++ b/media/base/key_systems.cc
@@ -75,6 +75,23 @@ static NamedCodec kCodecStrings[] = {
#endif // defined(USE_PROPRIETARY_CODECS)
};
+static EmeRequirementSupport ConvertSessionTypeSupport(
ddorwin 2015/03/13 19:24:47 Should we just eliminate EmeSessionTypeSupport?
sandersd (OOO until July 31) 2015/03/13 20:11:56 Probably. I really don't want to have an INVALID E
ddorwin 2015/03/16 23:25:07 Acknowledged. We also have PERMISSION_PREFERRED,
+ EmeSessionTypeSupport support) {
+ switch (support) {
+ case EME_SESSION_TYPE_INVALID:
+ NOTREACHED();
+ return EME_REQUIREMENT_NOT_SUPPORTED;
+ case EME_SESSION_TYPE_NOT_SUPPORTED:
+ return EME_REQUIREMENT_NOT_SUPPORTED;
+ case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION:
+ return EME_REQUIREMENT_SUPPORTED_WITH_PERMISSION;
+ case EME_SESSION_TYPE_SUPPORTED:
+ return EME_REQUIREMENT_SUPPORTED;
+ }
+ NOTREACHED();
+ return EME_REQUIREMENT_NOT_SUPPORTED;
+}
+
static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) {
KeySystemInfo info;
info.key_system = kClearKeyKeySystem;
@@ -189,23 +206,24 @@ class KeySystems {
std::string GetPepperType(const std::string& concrete_key_system);
#endif
- bool IsPersistentLicenseSessionSupported(
+ EmeRequirementSupport GetRobustnessRequirementSupport(
const std::string& key_system,
- bool is_permission_granted);
+ EmeMediaType media_type,
+ EmeRobustness robustness);
- bool IsPersistentReleaseMessageSessionSupported(
- const std::string& key_system,
- bool is_permission_granted);
+ EmeRequirementSupport GetPersistentLicenseSessionSupport(
+ const std::string& key_system);
+
+ EmeRequirementSupport GetPersistentReleaseMessageSessionSupport(
+ const std::string& key_system);
- bool IsPersistentStateRequirementSupported(
+ EmeRequirementSupport GetPersistentStateRequirementSupport(
const std::string& key_system,
- EmeFeatureRequirement requirement,
- bool is_permission_granted);
+ EmeFeatureRequirement requirement);
- bool IsDistinctiveIdentifierRequirementSupported(
+ EmeRequirementSupport GetDistinctiveIdentifierRequirementSupport(
const std::string& key_system,
- EmeFeatureRequirement requirement,
- bool is_permission_granted);
+ EmeFeatureRequirement requirement);
void AddContainerMask(const std::string& container, uint32 mask);
void AddCodecMask(const std::string& codec, uint32 mask);
@@ -392,34 +410,18 @@ void KeySystems::AddConcreteSupportedKeySystems(
for (const KeySystemInfo& info : concrete_key_systems) {
DCHECK(!info.key_system.empty());
- DCHECK_NE(info.persistent_license_support, EME_SESSION_TYPE_INVALID);
- DCHECK_NE(info.persistent_release_message_support,
- EME_SESSION_TYPE_INVALID);
- // TODO(sandersd): Add REQUESTABLE and REQUESTABLE_WITH_PERMISSION for
- // persistent_state_support once we can block access per-CDM-instance
- // (http://crbug.com/457482).
- DCHECK(info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED ||
- info.persistent_state_support == EME_FEATURE_ALWAYS_ENABLED);
-// TODO(sandersd): Allow REQUESTABLE_WITH_PERMISSION for all key systems on
-// all platforms once we have proper enforcement (http://crbug.com/457482).
-// On Chrome OS, an ID will not be used without permission, but we cannot
-// currently prevent the CDM from requesting the permission again when no
-// there was no initial prompt. Thus, we block "not-allowed" below.
-#if defined(OS_CHROMEOS)
- DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED ||
- (info.distinctive_identifier_support ==
- EME_FEATURE_REQUESTABLE_WITH_PERMISSION &&
- info.key_system == kWidevineKeySystem) ||
- info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED);
-#else
- DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED ||
- info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED);
-#endif
+ DCHECK(info.max_audio_robustness != EmeRobustness::INVALID);
+ DCHECK(info.max_video_robustness != EmeRobustness::INVALID);
+ DCHECK(info.persistent_license_support != EME_SESSION_TYPE_INVALID);
+ DCHECK(info.persistent_release_message_support != EME_SESSION_TYPE_INVALID);
+ DCHECK(info.persistent_state_support != EME_FEATURE_INVALID);
ddorwin 2015/03/13 19:24:47 Note: We've only addressed the TODO for desktop. D
sandersd (OOO until July 31) 2015/03/13 20:11:56 Done.
+ DCHECK(info.distinctive_identifier_support != EME_FEATURE_INVALID);
+ // Distinctive identifiers cannot be requestable without permission.
+ DCHECK(info.distinctive_identifier_support != EME_FEATURE_REQUESTABLE);
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(info.persistent_license_support == EME_SESSION_TYPE_NOT_SUPPORTED);
+ DCHECK(info.persistent_release_message_support ==
+ EME_SESSION_TYPE_NOT_SUPPORTED);
}
DCHECK(!IsSupportedKeySystem(info.key_system))
<< "Key system '" << info.key_system << "' already registered";
@@ -618,132 +620,147 @@ std::string KeySystems::GetPepperType(const std::string& concrete_key_system) {
}
#endif
-bool KeySystems::IsPersistentLicenseSessionSupported(
+EmeRequirementSupport KeySystems::GetRobustnessRequirementSupport(
const std::string& key_system,
- bool is_permission_granted) {
+ EmeMediaType media_type,
+ EmeRobustness robustness) {
DCHECK(thread_checker_.CalledOnValidThread());
+ if (robustness == EmeRobustness::INVALID)
+ return EME_REQUIREMENT_NOT_SUPPORTED;
+ if (robustness == EmeRobustness::EMPTY)
+ return EME_REQUIREMENT_SUPPORTED;
+
KeySystemInfoMap::const_iterator key_system_iter =
concrete_key_system_map_.find(key_system);
if (key_system_iter == concrete_key_system_map_.end()) {
NOTREACHED();
- return false;
+ return EME_REQUIREMENT_NOT_SUPPORTED;
}
- switch (key_system_iter->second.persistent_license_support) {
- case EME_SESSION_TYPE_INVALID:
- NOTREACHED();
- return false;
- case EME_SESSION_TYPE_NOT_SUPPORTED:
- return false;
- case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION:
- return is_permission_granted;
- case EME_SESSION_TYPE_SUPPORTED:
- return true;
+ EmeRobustness max_robustness = EmeRobustness::INVALID;
+ switch (media_type) {
+ case EmeMediaType::AUDIO:
+ max_robustness = key_system_iter->second.max_audio_robustness;
+ break;
+ case EmeMediaType::VIDEO:
+ max_robustness = key_system_iter->second.max_video_robustness;
+ break;
}
- NOTREACHED();
- return false;
+#if defined(OS_CHROMEOS)
+ if (key_system == kWidevineKeySystem) {
+ // CrOS Widevine supports L1 when remote attestation succeeds, but the
+ // encrypted media permission is required to do so. Even when not strictly
+ // requred, we prefer to support L1 for video because it allows hardware
+ // acceleration to be used.
+ // TODO(sandersd): Only recommend permission when hardware acceleration is
+ // available for the specific codecs requested.
+ EmeRequirementSupport recommendation =
+ (media_type == EmeMediaType::VIDEO)
+ ? EME_REQUIREMENT_SUPPORTED_PERMISSION_RECOMMENDED
+ : EME_REQUIREMENT_SUPPORTED;
+ return (robustness <= max_robustness)
+ ? recommendation
+ : EME_REQUIREMENT_SUPPORTED_WITH_PERMISSION;
+ }
+#endif // defined(OS_CHROMEOS)
+
+ return (robustness <= max_robustness)
+ ? EME_REQUIREMENT_SUPPORTED
+ : EME_REQUIREMENT_NOT_SUPPORTED;
}
-bool KeySystems::IsPersistentReleaseMessageSessionSupported(
- const std::string& key_system,
- bool is_permission_granted) {
+EmeRequirementSupport KeySystems::GetPersistentLicenseSessionSupport(
+ const std::string& key_system) {
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()) {
NOTREACHED();
- return false;
+ return EME_REQUIREMENT_NOT_SUPPORTED;
}
+ return ConvertSessionTypeSupport(
+ key_system_iter->second.persistent_license_support);
+}
- switch (key_system_iter->second.persistent_release_message_support) {
- case EME_SESSION_TYPE_INVALID:
- NOTREACHED();
- return false;
- case EME_SESSION_TYPE_NOT_SUPPORTED:
- return false;
- case EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION:
- return is_permission_granted;
- case EME_SESSION_TYPE_SUPPORTED:
- return true;
- }
+EmeRequirementSupport KeySystems::GetPersistentReleaseMessageSessionSupport(
+ const std::string& key_system) {
+ DCHECK(thread_checker_.CalledOnValidThread());
- NOTREACHED();
- return false;
+ KeySystemInfoMap::const_iterator key_system_iter =
+ concrete_key_system_map_.find(key_system);
+ if (key_system_iter == concrete_key_system_map_.end()) {
+ NOTREACHED();
+ return EME_REQUIREMENT_NOT_SUPPORTED;
+ }
+ return ConvertSessionTypeSupport(
+ key_system_iter->second.persistent_release_message_support);
}
-bool KeySystems::IsPersistentStateRequirementSupported(
+EmeRequirementSupport KeySystems::GetPersistentStateRequirementSupport(
const std::string& key_system,
- EmeFeatureRequirement requirement,
- bool is_permission_granted) {
+ EmeFeatureRequirement 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()) {
NOTREACHED();
- return false;
+ return EME_REQUIREMENT_NOT_SUPPORTED;
}
- switch (key_system_iter->second.persistent_state_support) {
- case EME_FEATURE_INVALID:
- NOTREACHED();
- return false;
- case EME_FEATURE_NOT_SUPPORTED:
- return requirement != EME_FEATURE_REQUIRED;
- case EME_FEATURE_REQUESTABLE_WITH_PERMISSION:
- return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted;
- case EME_FEATURE_REQUESTABLE:
- return true;
- case EME_FEATURE_ALWAYS_ENABLED:
- // Persistent state does not require user permission, but the session
- // types that use it might.
- return requirement != EME_FEATURE_NOT_ALLOWED;
+ EmeFeatureSupport support = key_system_iter->second.persistent_state_support;
+ if (support == EME_FEATURE_NOT_SUPPORTED &&
+ requirement == EME_FEATURE_REQUIRED) {
+ return EME_REQUIREMENT_NOT_SUPPORTED;
+ }
+ if (support == EME_FEATURE_ALWAYS_ENABLED &&
+ requirement == EME_FEATURE_NOT_ALLOWED) {
+ return EME_REQUIREMENT_NOT_SUPPORTED;
}
- NOTREACHED();
- return false;
+ // Permission is required only if the feature requires it; permission may
+ // still be required for individual persistent session types. Permission
+ // for optional requirements will be handled when they are resolved to
+ // a specific value.
+ if (support == EME_FEATURE_REQUESTABLE_WITH_PERMISSION &&
+ requirement == EME_FEATURE_REQUIRED) {
+ return EME_REQUIREMENT_SUPPORTED_WITH_PERMISSION;
+ }
+ return EME_REQUIREMENT_SUPPORTED;
}
-bool KeySystems::IsDistinctiveIdentifierRequirementSupported(
+EmeRequirementSupport KeySystems::GetDistinctiveIdentifierRequirementSupport(
const std::string& key_system,
- EmeFeatureRequirement requirement,
- bool is_permission_granted) {
+ EmeFeatureRequirement 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()) {
NOTREACHED();
- return false;
+ return EME_REQUIREMENT_NOT_SUPPORTED;
}
- switch (key_system_iter->second.distinctive_identifier_support) {
- case EME_FEATURE_INVALID:
- NOTREACHED();
- return false;
- case EME_FEATURE_NOT_SUPPORTED:
- return requirement != EME_FEATURE_REQUIRED;
- case EME_FEATURE_REQUESTABLE_WITH_PERMISSION:
- // TODO(sandersd): Remove this hack once crbug.com/457482 and
- // crbug.com/460616 are addressed.
- // We cannot currently enforce "not-allowed", so don't allow it.
- // Note: Removing this check will expose crbug.com/460616.
- if (requirement == EME_FEATURE_NOT_ALLOWED)
- return false;
- return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted;
- case EME_FEATURE_REQUESTABLE:
- NOTREACHED();
- return true;
- case EME_FEATURE_ALWAYS_ENABLED:
- // Distinctive identifiers always require user permission.
- return (requirement != EME_FEATURE_NOT_ALLOWED) && is_permission_granted;
+ EmeFeatureSupport support =
+ key_system_iter->second.distinctive_identifier_support;
+ if (support == EME_FEATURE_NOT_SUPPORTED &&
+ requirement == EME_FEATURE_REQUIRED) {
+ return EME_REQUIREMENT_NOT_SUPPORTED;
+ }
+ if (support == EME_FEATURE_ALWAYS_ENABLED &&
+ requirement == EME_FEATURE_NOT_ALLOWED) {
+ return EME_REQUIREMENT_NOT_SUPPORTED;
}
- NOTREACHED();
- return false;
+ // Permission is always required, but permission for optional requirements
+ // will be handled when they are resolved to a specific value.
+ if (requirement == EME_FEATURE_REQUIRED) {
+ return EME_REQUIREMENT_SUPPORTED_WITH_PERMISSION;
+ }
+ return EME_REQUIREMENT_SUPPORTED;
}
void KeySystems::AddContainerMask(const std::string& container, uint32 mask) {
@@ -848,34 +865,38 @@ std::string GetPepperType(const std::string& concrete_key_system) {
}
#endif
-bool IsPersistentLicenseSessionSupported(
+EmeRequirementSupport GetRobustnessRequirementSupport(
const std::string& key_system,
- bool is_permission_granted) {
- return KeySystems::GetInstance().IsPersistentLicenseSessionSupported(
- key_system, is_permission_granted);
+ EmeMediaType media_type,
+ EmeRobustness robustness) {
+ return KeySystems::GetInstance().GetRobustnessRequirementSupport(
+ key_system, media_type, robustness);
}
-bool IsPersistentReleaseMessageSessionSupported(
- const std::string& key_system,
- bool is_permission_granted) {
- return KeySystems::GetInstance().IsPersistentReleaseMessageSessionSupported(
- key_system, is_permission_granted);
+EmeRequirementSupport GetPersistentLicenseSessionSupport(
+ const std::string& key_system) {
+ return KeySystems::GetInstance().GetPersistentLicenseSessionSupport(
+ key_system);
+}
+
+EmeRequirementSupport GetPersistentReleaseMessageSessionSupport(
+ const std::string& key_system) {
+ return KeySystems::GetInstance().GetPersistentReleaseMessageSessionSupport(
+ key_system);
}
-bool IsPersistentStateRequirementSupported(
+EmeRequirementSupport GetPersistentStateRequirementSupport(
const std::string& key_system,
- EmeFeatureRequirement requirement,
- bool is_permission_granted) {
- return KeySystems::GetInstance().IsPersistentStateRequirementSupported(
- key_system, requirement, is_permission_granted);
+ EmeFeatureRequirement requirement) {
+ return KeySystems::GetInstance().GetPersistentStateRequirementSupport(
+ key_system, requirement);
}
-bool IsDistinctiveIdentifierRequirementSupported(
+EmeRequirementSupport GetDistinctiveIdentifierRequirementSupport(
const std::string& key_system,
- EmeFeatureRequirement requirement,
- bool is_permission_granted) {
- return KeySystems::GetInstance().IsDistinctiveIdentifierRequirementSupported(
- key_system, requirement, is_permission_granted);
+ EmeFeatureRequirement requirement) {
+ return KeySystems::GetInstance().GetDistinctiveIdentifierRequirementSupport(
+ key_system, requirement);
}
// These two functions are for testing purpose only. The declaration in the

Powered by Google App Engine
This is Rietveld 408576698