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 {
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.
void AddCodecMask(EmeMediaType media_type,
const std::string& codec,
......@@ -211,6 +209,8 @@ class KeySystemsImpl : public KeySystems {
// Implementation of KeySystems interface.
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,
EmeInitDataType init_data_type) const override;
......@@ -531,18 +531,6 @@ std::string KeySystemsImpl::GetKeySystemNameForUMA(
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,
const std::string& codec,
uint32_t mask) {
......@@ -570,6 +558,18 @@ bool KeySystemsImpl::IsSupportedKeySystem(const std::string& key_system) const {
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(
const std::string& key_system,
EmeMediaType media_type,
......@@ -727,7 +727,7 @@ std::string GetKeySystemNameForUMA(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
......
......@@ -31,6 +31,9 @@ class MEDIA_EXPORT KeySystems {
// Returns whether |key_system| is a supported key system.
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|.
virtual bool IsSupportedInitDataType(
const std::string& key_system,
......
......@@ -337,8 +337,9 @@ bool KeySystemConfigSelector::IsSupportedContentType(
// 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
// robustness algorithm).
if (!is_supported_media_type_cb_.Run(container_lower, codecs,
CanUseAesDecryptor(key_system))) {
if (!is_supported_media_type_cb_.Run(
container_lower, codecs,
key_systems_->CanUseAesDecryptor(key_system))) {
DVLOG(3) << "Container mime type and codecs are not supported";
return false;
}
......
......@@ -158,9 +158,12 @@ class FakeKeySystems : public KeySystems {
bool IsSupportedKeySystem(const std::string& key_system) const override {
// Based on EME spec, Clear Key key system is always supported.
if (key_system == kSupportedKeySystem || key_system == kClearKeyKeySystem)
return true;
return false;
return key_system == kSupportedKeySystem ||
key_system == kClearKeyKeySystem;
}
bool CanUseAesDecryptor(const std::string& key_system) const override {
return key_system == kClearKeyKeySystem;
}
// 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