Commit 4dec0cd0 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Add KeySystems::CanUseAesDecryptor()

This allows KeySystemConfigSelectorTest to fully depend on the
FakeKeySystems. Previously KeySystemConfigSelector calls
CanUseAesDecryptor() which calls into KeySystemsImpl which makes the
test really confusing.

Bug: 727948
Change-Id: Id5536a142285034f1ec589758a171c70d3a77153
Reviewed-on: https://chromium-review.googlesource.com/1092412Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565716}
parent 57a5b8d9
...@@ -200,8 +200,6 @@ class KeySystemsImpl : public KeySystems { ...@@ -200,8 +200,6 @@ class KeySystemsImpl : public KeySystems {
std::string GetKeySystemNameForUMA(const std::string& key_system) const; std::string GetKeySystemNameForUMA(const std::string& key_system) const;
bool UseAesDecryptor(const std::string& key_system) const;
// These two functions are for testing purpose only. // These two functions are for testing purpose only.
void AddCodecMask(EmeMediaType media_type, void AddCodecMask(EmeMediaType media_type,
const std::string& codec, const std::string& codec,
...@@ -211,6 +209,8 @@ class KeySystemsImpl : public KeySystems { ...@@ -211,6 +209,8 @@ class KeySystemsImpl : public KeySystems {
// Implementation of KeySystems interface. // Implementation of KeySystems interface.
bool IsSupportedKeySystem(const std::string& key_system) const override; bool IsSupportedKeySystem(const std::string& key_system) const override;
bool CanUseAesDecryptor(const std::string& key_system) const override;
bool IsSupportedInitDataType(const std::string& key_system, bool IsSupportedInitDataType(const std::string& key_system,
EmeInitDataType init_data_type) const override; EmeInitDataType init_data_type) const override;
...@@ -531,18 +531,6 @@ std::string KeySystemsImpl::GetKeySystemNameForUMA( ...@@ -531,18 +531,6 @@ std::string KeySystemsImpl::GetKeySystemNameForUMA(
return kUnknownKeySystemNameForUMA; return kUnknownKeySystemNameForUMA;
} }
bool KeySystemsImpl::UseAesDecryptor(const std::string& key_system) const {
DCHECK(thread_checker_.CalledOnValidThread());
KeySystemPropertiesMap::const_iterator key_system_iter =
key_system_properties_map_.find(key_system);
if (key_system_iter == key_system_properties_map_.end()) {
DLOG(ERROR) << key_system << " is not a known key system";
return false;
}
return key_system_iter->second->UseAesDecryptor();
}
void KeySystemsImpl::AddCodecMask(EmeMediaType media_type, void KeySystemsImpl::AddCodecMask(EmeMediaType media_type,
const std::string& codec, const std::string& codec,
uint32_t mask) { uint32_t mask) {
...@@ -570,6 +558,18 @@ bool KeySystemsImpl::IsSupportedKeySystem(const std::string& key_system) const { ...@@ -570,6 +558,18 @@ bool KeySystemsImpl::IsSupportedKeySystem(const std::string& key_system) const {
return true; return true;
} }
bool KeySystemsImpl::CanUseAesDecryptor(const std::string& key_system) const {
DCHECK(thread_checker_.CalledOnValidThread());
KeySystemPropertiesMap::const_iterator key_system_iter =
key_system_properties_map_.find(key_system);
if (key_system_iter == key_system_properties_map_.end()) {
DLOG(ERROR) << key_system << " is not a known key system";
return false;
}
return key_system_iter->second->UseAesDecryptor();
}
EmeConfigRule KeySystemsImpl::GetContentTypeConfigRule( EmeConfigRule KeySystemsImpl::GetContentTypeConfigRule(
const std::string& key_system, const std::string& key_system,
EmeMediaType media_type, EmeMediaType media_type,
...@@ -727,7 +727,7 @@ std::string GetKeySystemNameForUMA(const std::string& key_system) { ...@@ -727,7 +727,7 @@ std::string GetKeySystemNameForUMA(const std::string& key_system) {
} }
bool CanUseAesDecryptor(const std::string& key_system) { bool CanUseAesDecryptor(const std::string& key_system) {
return KeySystemsImpl::GetInstance()->UseAesDecryptor(key_system); return KeySystemsImpl::GetInstance()->CanUseAesDecryptor(key_system);
} }
// These two functions are for testing purpose only. The declaration in the // These two functions are for testing purpose only. The declaration in the
......
...@@ -31,6 +31,9 @@ class MEDIA_EXPORT KeySystems { ...@@ -31,6 +31,9 @@ class MEDIA_EXPORT KeySystems {
// Returns whether |key_system| is a supported key system. // Returns whether |key_system| is a supported key system.
virtual bool IsSupportedKeySystem(const std::string& key_system) const = 0; virtual bool IsSupportedKeySystem(const std::string& key_system) const = 0;
// Returns whether AesDecryptor can be used for the given |key_system|.
virtual bool CanUseAesDecryptor(const std::string& key_system) const = 0;
// Returns whether |init_data_type| is supported by |key_system|. // Returns whether |init_data_type| is supported by |key_system|.
virtual bool IsSupportedInitDataType( virtual bool IsSupportedInitDataType(
const std::string& key_system, const std::string& key_system,
......
...@@ -337,8 +337,9 @@ bool KeySystemConfigSelector::IsSupportedContentType( ...@@ -337,8 +337,9 @@ bool KeySystemConfigSelector::IsSupportedContentType(
// is done primarily to validate extended codecs, but it also ensures that the // is done primarily to validate extended codecs, but it also ensures that the
// CDM cannot support codecs that Chrome does not (which could complicate the // CDM cannot support codecs that Chrome does not (which could complicate the
// robustness algorithm). // robustness algorithm).
if (!is_supported_media_type_cb_.Run(container_lower, codecs, if (!is_supported_media_type_cb_.Run(
CanUseAesDecryptor(key_system))) { container_lower, codecs,
key_systems_->CanUseAesDecryptor(key_system))) {
DVLOG(3) << "Container mime type and codecs are not supported"; DVLOG(3) << "Container mime type and codecs are not supported";
return false; return false;
} }
......
...@@ -158,9 +158,12 @@ class FakeKeySystems : public KeySystems { ...@@ -158,9 +158,12 @@ class FakeKeySystems : public KeySystems {
bool IsSupportedKeySystem(const std::string& key_system) const override { bool IsSupportedKeySystem(const std::string& key_system) const override {
// Based on EME spec, Clear Key key system is always supported. // Based on EME spec, Clear Key key system is always supported.
if (key_system == kSupportedKeySystem || key_system == kClearKeyKeySystem) return key_system == kSupportedKeySystem ||
return true; key_system == kClearKeyKeySystem;
return false; }
bool CanUseAesDecryptor(const std::string& key_system) const override {
return key_system == kClearKeyKeySystem;
} }
// TODO(sandersd): Move implementation into KeySystemConfigSelector? // TODO(sandersd): Move implementation into KeySystemConfigSelector?
......
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