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

Unified Diff: media/blink/webencryptedmediaclient_impl.cc

Issue 1023863002: Create an interface for KeySystems, migrate WebEncryptedMediaClientImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@robustness
Patch Set: Move |media_type| checking into KeySystems. 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
« media/base/key_systems.cc ('K') | « media/blink/webencryptedmediaclient_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webencryptedmediaclient_impl.cc
diff --git a/media/blink/webencryptedmediaclient_impl.cc b/media/blink/webencryptedmediaclient_impl.cc
index ed364775f8c09526f73613e7731138d02657be01..06197692f81536839ad4af5196c9a279254a91a3 100644
--- a/media/blink/webencryptedmediaclient_impl.cc
+++ b/media/blink/webencryptedmediaclient_impl.cc
@@ -142,23 +142,22 @@ static EmeRobustness ConvertRobustness(const blink::WebString& robustness) {
return EmeRobustness::INVALID;
}
-static bool IsSupportedContentType(const std::string& key_system,
- const std::string& mime_type,
- const std::string& codecs) {
+static bool IsSupportedContentType(
+ const KeySystems& key_systems,
+ const std::string& key_system,
+ EmeMediaType media_type,
+ const std::string& container_mime_type,
+ const std::string& codecs) {
// TODO(sandersd): Move contentType parsing from Blink to here so that invalid
// parameters can be rejected. http://crbug.com/417561
- // TODO(sandersd): Pass in the media type (audio or video) and check that the
- // container type matches. http://crbug.com/457384
- std::string container = base::StringToLowerASCII(mime_type);
+ std::string container_lower = base::StringToLowerASCII(container_mime_type);
// Check that |codecs| are supported by the CDM. This check does not handle
// extended codecs, so extended codec information is stripped.
- // TODO(sandersd): Reject codecs that do not match the media type.
- // http://crbug.com/457386
std::vector<std::string> codec_vector;
net::ParseCodecString(codecs, &codec_vector, true);
- if (!IsSupportedKeySystemWithMediaMimeType(container, codec_vector,
- key_system)) {
+ if (!key_systems.IsSupportedCodecCombination(
+ key_system, media_type, container_lower, codec_vector)) {
return false;
}
@@ -174,13 +173,14 @@ static bool IsSupportedContentType(const std::string& key_system,
}
static bool GetSupportedCapabilities(
+ const KeySystems& key_systems,
const std::string& key_system,
+ EmeMediaType media_type,
const blink::WebVector<blink::WebMediaKeySystemMediaCapability>&
capabilities,
- EmeMediaType media_type,
+ ConfigState* config_state,
std::vector<blink::WebMediaKeySystemMediaCapability>*
- media_type_capabilities,
- ConfigState* config_state) {
+ media_type_capabilities) {
// From
// https://w3c.github.io/encrypted-media/#get-supported-capabilities-for-media-type
// 1. Let accumulated capabilities be partial configuration.
@@ -201,7 +201,7 @@ static bool GetSupportedCapabilities(
// 3.4-3.11. (Implemented by IsSupportedContentType().)
if (!base::IsStringASCII(capability.mimeType) ||
!base::IsStringASCII(capability.codecs) ||
- !IsSupportedContentType(key_system,
+ !IsSupportedContentType(key_systems, key_system, media_type,
base::UTF16ToASCII(capability.mimeType),
base::UTF16ToASCII(capability.codecs))) {
continue;
@@ -211,7 +211,7 @@ static bool GetSupportedCapabilities(
// 3.12.1. If robustness is an unrecognized value or not supported by
// implementation, continue to the next iteration. String
// comparison is case-sensitive.
- EmeConfigRule robustness_rule = GetRobustnessConfigRule(
+ EmeConfigRule robustness_rule = key_systems.GetRobustnessConfigRule(
key_system, media_type, ConvertRobustness(capability.robustness));
if (!config_state->IsRuleSupported(robustness_rule))
continue;
@@ -259,6 +259,7 @@ static EmeFeatureRequirement ConvertRequirement(
}
static ConfigurationSupport GetSupportedConfiguration(
+ const KeySystems& key_systems,
const std::string& key_system,
const blink::WebMediaKeySystemConfiguration& candidate,
bool was_permission_requested,
@@ -330,7 +331,7 @@ static ConfigurationSupport GetSupportedConfiguration(
// null.
// We also reject OPTIONAL when distinctive identifiers are ALWAYS_ENABLED and
// permission has already been denied. This would happen anyway at step 11.
- EmeConfigRule di_rule = GetDistinctiveIdentifierConfigRule(
+ EmeConfigRule di_rule = key_systems.GetDistinctiveIdentifierConfigRule(
key_system, ConvertRequirement(candidate.distinctiveIdentifier));
if (!config_state.IsRuleSupported(di_rule)) {
DVLOG(2) << "Rejecting requested configuration because "
@@ -351,7 +352,7 @@ static ConfigurationSupport GetSupportedConfiguration(
// - "optional": Continue.
// - "not-allowed": If the implementation requires persisting state in
// combination with accumulated configuration, return null.
- EmeConfigRule ps_rule = GetPersistentStateConfigRule(
+ EmeConfigRule ps_rule = key_systems.GetPersistentStateConfigRule(
key_system, ConvertRequirement(candidate.persistentState));
if (!config_state.IsRuleSupported(ps_rule)) {
DVLOG(2) << "Rejecting requested configuration because "
@@ -373,9 +374,9 @@ static ConfigurationSupport GetSupportedConfiguration(
// configuration.
// 7.2. If video capabilities is null, return null.
std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities;
- if (!GetSupportedCapabilities(key_system, candidate.videoCapabilities,
- EmeMediaType::VIDEO, &video_capabilities,
- &config_state)) {
+ if (!GetSupportedCapabilities(key_systems, key_system, EmeMediaType::VIDEO,
+ candidate.videoCapabilities,
+ &config_state, &video_capabilities)) {
return CONFIGURATION_NOT_SUPPORTED;
}
@@ -392,9 +393,9 @@ static ConfigurationSupport GetSupportedConfiguration(
// configuration.
// 8.2. If audio capabilities is null, return null.
std::vector<blink::WebMediaKeySystemMediaCapability> audio_capabilities;
- if (!GetSupportedCapabilities(key_system, candidate.audioCapabilities,
- EmeMediaType::AUDIO, &audio_capabilities,
- &config_state)) {
+ if (!GetSupportedCapabilities(key_systems, key_system, EmeMediaType::AUDIO,
+ candidate.audioCapabilities,
+ &config_state, &audio_capabilities)) {
return CONFIGURATION_NOT_SUPPORTED;
}
@@ -413,9 +414,11 @@ static ConfigurationSupport GetSupportedConfiguration(
if (accumulated_configuration->distinctiveIdentifier ==
blink::WebMediaKeySystemConfiguration::Requirement::Optional) {
EmeConfigRule not_allowed_rule =
- GetDistinctiveIdentifierConfigRule(key_system, EME_FEATURE_NOT_ALLOWED);
+ key_systems.GetDistinctiveIdentifierConfigRule(
+ key_system, EME_FEATURE_NOT_ALLOWED);
EmeConfigRule required_rule =
- GetDistinctiveIdentifierConfigRule(key_system, EME_FEATURE_REQUIRED);
+ key_systems.GetDistinctiveIdentifierConfigRule(
+ key_system, EME_FEATURE_REQUIRED);
bool not_allowed_supported = config_state.IsRuleSupported(not_allowed_rule);
bool required_supported = config_state.IsRuleSupported(required_rule);
if (not_allowed_supported) {
@@ -465,9 +468,11 @@ static ConfigurationSupport GetSupportedConfiguration(
if (accumulated_configuration->persistentState ==
blink::WebMediaKeySystemConfiguration::Requirement::Optional) {
EmeConfigRule not_allowed_rule =
- GetPersistentStateConfigRule(key_system, EME_FEATURE_NOT_ALLOWED);
+ key_systems.GetPersistentStateConfigRule(
+ key_system, EME_FEATURE_NOT_ALLOWED);
EmeConfigRule required_rule =
- GetPersistentStateConfigRule(key_system, EME_FEATURE_REQUIRED);
+ key_systems.GetPersistentStateConfigRule(
+ key_system, EME_FEATURE_REQUIRED);
// Now that distinctiveIdentifier has been resolved, it is too late to allow
// persistentState to affect the configuration.
bool not_allowed_supported =
@@ -510,12 +515,13 @@ static ConfigurationSupport GetSupportedConfiguration(
if (accumulated_configuration->persistentState ==
blink::WebMediaKeySystemConfiguration::Requirement::Required) {
if (config_state.IsRuleSupportedWithCurrentState(
- GetPersistentLicenseSessionConfigRule(key_system))) {
+ key_systems.GetPersistentLicenseSessionConfigRule(key_system))) {
session_types.push_back(
blink::WebEncryptedMediaSessionType::PersistentLicense);
}
if (config_state.IsRuleSupportedWithCurrentState(
- GetPersistentReleaseMessageSessionConfigRule(key_system))) {
+ key_systems.GetPersistentReleaseMessageSessionConfigRule(
+ key_system))) {
session_types.push_back(
blink::WebEncryptedMediaSessionType::PersistentReleaseMessage);
}
@@ -578,7 +584,9 @@ class WebEncryptedMediaClientImpl::Reporter {
WebEncryptedMediaClientImpl::WebEncryptedMediaClientImpl(
scoped_ptr<CdmFactory> cdm_factory,
MediaPermission* media_permission)
- : cdm_factory_(cdm_factory.Pass()), media_permission_(media_permission),
+ : key_systems_(KeySystems::GetInstance()),
+ cdm_factory_(cdm_factory.Pass()),
+ media_permission_(media_permission),
weak_factory_(this) {
DCHECK(media_permission);
}
@@ -606,7 +614,7 @@ void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess(
std::string key_system = base::UTF16ToASCII(request.keySystem());
GetReporter(key_system)->ReportRequested();
- if (!IsSupportedKeySystem(key_system)) {
+ if (!key_systems_.IsSupportedKeySystem(key_system)) {
request.requestNotSupported("Unsupported keySystem");
return;
}
@@ -639,8 +647,9 @@ void WebEncryptedMediaClientImpl::SelectSupportedConfiguration(
// new MediaKeySystemAccess object.]
blink::WebMediaKeySystemConfiguration accumulated_configuration;
ConfigurationSupport supported = GetSupportedConfiguration(
- key_system, candidate_configuration, was_permission_requested,
- is_permission_granted, &accumulated_configuration);
+ key_systems_, key_system, candidate_configuration,
+ was_permission_requested, is_permission_granted,
+ &accumulated_configuration);
switch (supported) {
case CONFIGURATION_NOT_SUPPORTED:
continue;
« media/base/key_systems.cc ('K') | « media/blink/webencryptedmediaclient_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698