Commit b78a48ba authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Add CdmCapability

This describes the capability (supported features) of a CDM. Add a new
struct for it to simplify a lot of code.

Bug: 848532
Change-Id: Iaf83bad1ebe4882e8fbc0a1786b2d9898ef9a52b
Reviewed-on: https://chromium-review.googlesource.com/1110602Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569711}
parent 7902aaa2
...@@ -172,11 +172,13 @@ bool IsCompatibleWithChrome(const base::DictionaryValue& manifest) { ...@@ -172,11 +172,13 @@ bool IsCompatibleWithChrome(const base::DictionaryValue& manifest) {
media::IsSupportedCdmHostVersion); media::IsSupportedCdmHostVersion);
} }
// Returns true and updates |supported_video_codecs| (if provided) if the // Returns true and updates |video_codecs| if the appropriate manifest entry is
// appropriate manifest entry is valid. Returns false and does not modify // valid. Returns false and does not modify |video_codecs| if the manifest entry
// |supported_video_codecs| if the manifest entry is incorrectly formatted. // is incorrectly formatted.
bool GetCodecs(const base::DictionaryValue& manifest, bool GetCodecs(const base::DictionaryValue& manifest,
std::vector<media::VideoCodec>* supported_video_codecs) { std::vector<media::VideoCodec>* video_codecs) {
DCHECK(video_codecs);
const base::Value* value = manifest.FindKey(kCdmCodecsListName); const base::Value* value = manifest.FindKey(kCdmCodecsListName);
if (!value) { if (!value) {
DLOG(WARNING) << "Widevine CDM component manifest is missing codecs."; DLOG(WARNING) << "Widevine CDM component manifest is missing codecs.";
...@@ -211,47 +213,49 @@ bool GetCodecs(const base::DictionaryValue& manifest, ...@@ -211,47 +213,49 @@ bool GetCodecs(const base::DictionaryValue& manifest,
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
} }
if (supported_video_codecs) video_codecs->swap(result);
supported_video_codecs->swap(result);
return true; return true;
} }
// Returns true and updates |supports_persistent_license| (if provided) if // Returns true and updates |session_types| if the appropriate manifest entry is
// the appropriate manifest entry is valid. Returns false if the manifest // valid. Returns false if the manifest entry is incorrectly formatted.
// entry is incorrectly formatted. bool GetSessionTypes(const base::DictionaryValue& manifest,
bool GetPersistentLicenseSupport(const base::DictionaryValue& manifest, base::flat_set<media::CdmSessionType>* session_types) {
bool* supports_persistent_license) { DCHECK(session_types);
bool result = false;
bool is_persistent_license_supported = false;
const base::Value* value = manifest.FindKey(kCdmPersistentLicenseSupportName); const base::Value* value = manifest.FindKey(kCdmPersistentLicenseSupportName);
if (value) { if (value) {
if (value->is_bool()) if (!value->is_bool())
result = value->GetBool();
else
return false; return false;
is_persistent_license_supported = value->GetBool();
} }
if (supports_persistent_license) // Temporary session is always supported.
*supports_persistent_license = result; session_types->insert(media::CdmSessionType::TEMPORARY_SESSION);
if (is_persistent_license_supported)
session_types->insert(media::CdmSessionType::PERSISTENT_LICENSE_SESSION);
return true; return true;
} }
// Returns true and updates |supported_encryption_schemes| (if provided) if // Returns true and updates |encryption_schemes| if the appropriate manifest
// the appropriate manifest entry is valid. Returns false and does not modify // entry is valid. Returns false and does not modify |encryption_schemes| if the
// |supported_encryption_schemes| if the manifest entry is incorrectly // manifest entry is incorrectly formatted. It is assumed that all CDMs support
// formatted. It is assumed that all CDMs support 'cenc', so if the manifest // 'cenc', so if the manifest entry is missing, the result will indicate support
// entry is missing, the result will indicate support for 'cenc' only. // for 'cenc' only. Incorrect types in the manifest entry will log the error and
// Incorrect types in the manifest entry will log the error and fail. // fail. Unrecognized values will be reported but otherwise ignored.
// Unrecognized values will be reported but otherwise ignored.
bool GetEncryptionSchemes( bool GetEncryptionSchemes(
const base::DictionaryValue& manifest, const base::DictionaryValue& manifest,
base::flat_set<media::EncryptionMode>* supported_encryption_schemes) { base::flat_set<media::EncryptionMode>* encryption_schemes) {
DCHECK(encryption_schemes);
const base::Value* value = const base::Value* value =
manifest.FindKey(kCdmSupportedEncryptionSchemesName); manifest.FindKey(kCdmSupportedEncryptionSchemesName);
if (!value) { if (!value) {
// No manifest entry found, so assume only 'cenc' supported for backwards // No manifest entry found, so assume only 'cenc' supported for backwards
// compatibility. // compatibility.
if (supported_encryption_schemes) encryption_schemes->insert(media::EncryptionMode::kCenc);
supported_encryption_schemes->insert(media::EncryptionMode::kCenc);
return true; return true;
} }
...@@ -286,24 +290,19 @@ bool GetEncryptionSchemes( ...@@ -286,24 +290,19 @@ bool GetEncryptionSchemes(
if (result.empty()) if (result.empty())
return false; return false;
if (supported_encryption_schemes) encryption_schemes->swap(result);
supported_encryption_schemes->swap(result);
return true; return true;
} }
// Returns true if the entries in the manifest can be parsed correctly, // Returns true if the entries in the manifest can be parsed correctly,
// false otherwise. Updates |supported_video_codecs|, // false otherwise. Updates |capability|, with the values obtained from the
// |supports_persistent_license|, and |supported_encryption_schemes|, // manifest, if they are provided. If this method returns false, |capability|
// with the values obtained from the manifest, if they are provided. // may or may not be updated.
// If this method returns false, the values may or may not be updated. bool ParseManifest(const base::DictionaryValue& manifest,
bool ParseManifest( content::CdmCapability* capability) {
const base::DictionaryValue& manifest, return GetCodecs(manifest, &capability->video_codecs) &&
std::vector<media::VideoCodec>* supported_video_codecs, GetEncryptionSchemes(manifest, &capability->encryption_schemes) &&
bool* supports_persistent_license, GetSessionTypes(manifest, &capability->session_types);
base::flat_set<media::EncryptionMode>* supported_encryption_schemes) {
return GetEncryptionSchemes(manifest, supported_encryption_schemes) &&
GetPersistentLicenseSupport(manifest, supports_persistent_license) &&
GetCodecs(manifest, supported_video_codecs);
} }
void RegisterWidevineCdmWithChrome( void RegisterWidevineCdmWithChrome(
...@@ -311,38 +310,25 @@ void RegisterWidevineCdmWithChrome( ...@@ -311,38 +310,25 @@ void RegisterWidevineCdmWithChrome(
const base::FilePath& cdm_install_dir, const base::FilePath& cdm_install_dir,
std::unique_ptr<base::DictionaryValue> manifest) { std::unique_ptr<base::DictionaryValue> manifest) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::vector<media::VideoCodec> supported_video_codecs;
bool supports_persistent_license;
base::flat_set<media::EncryptionMode> supported_encryption_schemes;
// This check must be a subset of the check in VerifyInstallation() to // This check must be a subset of the check in VerifyInstallation() to
// avoid the case where the CDM is accepted by the component updater // avoid the case where the CDM is accepted by the component updater
// but not registered. // but not registered.
if (!ParseManifest(*manifest, &supported_video_codecs, content::CdmCapability capability;
&supports_persistent_license, if (!ParseManifest(*manifest, &capability)) {
&supported_encryption_schemes)) {
VLOG(1) << "Not registering Widevine CDM due to malformed manifest."; VLOG(1) << "Not registering Widevine CDM due to malformed manifest.";
return; return;
} }
VLOG(1) << "Register Widevine CDM with Chrome"; VLOG(1) << "Register Widevine CDM with Chrome";
// Temporary session is always supported.
base::flat_set<media::CdmSessionType> supported_session_types = {
media::CdmSessionType::TEMPORARY_SESSION};
if (supports_persistent_license) {
supported_session_types.insert(
media::CdmSessionType::PERSISTENT_LICENSE_SESSION);
}
const base::FilePath cdm_path = const base::FilePath cdm_path =
GetPlatformDirectory(cdm_install_dir) GetPlatformDirectory(cdm_install_dir)
.AppendASCII(base::GetNativeLibraryName(kWidevineCdmLibraryName)); .AppendASCII(base::GetNativeLibraryName(kWidevineCdmLibraryName));
CdmRegistry::GetInstance()->RegisterCdm(
CdmRegistry::GetInstance()->RegisterCdm(content::CdmInfo( content::CdmInfo(kWidevineCdmDisplayName, kWidevineCdmGuid, cdm_version,
kWidevineCdmDisplayName, kWidevineCdmGuid, cdm_version, cdm_path, cdm_path, kWidevineCdmFileSystemId,
kWidevineCdmFileSystemId, supported_video_codecs, supported_session_types, std::move(capability), kWidevineKeySystem, false));
supported_encryption_schemes, kWidevineKeySystem, false));
} }
} // namespace } // namespace
...@@ -419,11 +405,12 @@ void WidevineCdmComponentInstallerPolicy::ComponentReady( ...@@ -419,11 +405,12 @@ void WidevineCdmComponentInstallerPolicy::ComponentReady(
bool WidevineCdmComponentInstallerPolicy::VerifyInstallation( bool WidevineCdmComponentInstallerPolicy::VerifyInstallation(
const base::DictionaryValue& manifest, const base::DictionaryValue& manifest,
const base::FilePath& install_dir) const { const base::FilePath& install_dir) const {
content::CdmCapability capability;
return IsCompatibleWithChrome(manifest) && return IsCompatibleWithChrome(manifest) &&
base::PathExists(GetPlatformDirectory(install_dir) base::PathExists(GetPlatformDirectory(install_dir)
.AppendASCII(base::GetNativeLibraryName( .AppendASCII(base::GetNativeLibraryName(
kWidevineCdmLibraryName))) && kWidevineCdmLibraryName))) &&
ParseManifest(manifest, nullptr, nullptr, nullptr); ParseManifest(manifest, &capability);
} }
// The base directory on Windows looks like: // The base directory on Windows looks like:
......
...@@ -130,11 +130,8 @@ content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; ...@@ -130,11 +130,8 @@ content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module;
#endif #endif
#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
bool IsWidevineAvailable( bool IsWidevineAvailable(base::FilePath* cdm_path,
base::FilePath* cdm_path, content::CdmCapability* capability) {
std::vector<media::VideoCodec>* codecs_supported,
bool* supports_persistent_license,
base::flat_set<media::EncryptionMode>* modes_supported) {
static enum { static enum {
NOT_CHECKED, NOT_CHECKED,
FOUND, FOUND,
...@@ -148,25 +145,27 @@ bool IsWidevineAvailable( ...@@ -148,25 +145,27 @@ bool IsWidevineAvailable(
if (widevine_cdm_file_check == FOUND) { if (widevine_cdm_file_check == FOUND) {
// Add the supported codecs as if they came from the component manifest. // Add the supported codecs as if they came from the component manifest.
// This list must match the CDM that is being bundled with Chrome. // This list must match the CDM that is being bundled with Chrome.
codecs_supported->push_back(media::VideoCodec::kCodecVP8); capability->video_codecs.push_back(media::VideoCodec::kCodecVP8);
codecs_supported->push_back(media::VideoCodec::kCodecVP9); capability->video_codecs.push_back(media::VideoCodec::kCodecVP9);
#if BUILDFLAG(USE_PROPRIETARY_CODECS) #if BUILDFLAG(USE_PROPRIETARY_CODECS)
codecs_supported->push_back(media::VideoCodec::kCodecH264); capability->video_codecs.push_back(media::VideoCodec::kCodecH264);
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
// TODO(crbug.com/767941): Push persistent-license support info here once
// we check in a new CDM that supports it on Linux.
#if defined(OS_CHROMEOS)
*supports_persistent_license = true;
#else
*supports_persistent_license = false;
#endif // defined(OS_CHROMEOS)
// Add the supported encryption schemes as if they came from the // Add the supported encryption schemes as if they came from the
// component manifest. This list must match the CDM that is being // component manifest. This list must match the CDM that is being
// bundled with Chrome. // bundled with Chrome.
modes_supported->insert(media::EncryptionMode::kCenc); capability->encryption_schemes.insert(media::EncryptionMode::kCenc);
modes_supported->insert(media::EncryptionMode::kCbcs); capability->encryption_schemes.insert(media::EncryptionMode::kCbcs);
// Temporary session is always supported.
capability->session_types.insert(
media::CdmSessionType::TEMPORARY_SESSION);
#if defined(OS_CHROMEOS)
// TODO(crbug.com/767941): Push persistent-license support info here once
// we check in a new CDM that supports it on Linux.
capability->session_types.insert(
media::CdmSessionType::PERSISTENT_LICENSE_SESSION);
#endif // defined(OS_CHROMEOS)
return true; return true;
} }
...@@ -532,28 +531,15 @@ void ChromeContentClient::AddContentDecryptionModules( ...@@ -532,28 +531,15 @@ void ChromeContentClient::AddContentDecryptionModules(
if (cdms) { if (cdms) {
#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
base::FilePath cdm_path; base::FilePath cdm_path;
std::vector<media::VideoCodec> video_codecs_supported; content::CdmCapability capability;
bool supports_persistent_license = false; if (IsWidevineAvailable(&cdm_path, &capability)) {
base::flat_set<media::EncryptionMode> encryption_modes_supported;
if (IsWidevineAvailable(&cdm_path, &video_codecs_supported,
&supports_persistent_license,
&encryption_modes_supported)) {
const base::Version version(WIDEVINE_CDM_VERSION_STRING); const base::Version version(WIDEVINE_CDM_VERSION_STRING);
DCHECK(version.IsValid()); DCHECK(version.IsValid());
// Temporary session is always supported. cdms->push_back(
base::flat_set<media::CdmSessionType> supported_session_types = { content::CdmInfo(kWidevineCdmDisplayName, kWidevineCdmGuid, version,
media::CdmSessionType::TEMPORARY_SESSION}; cdm_path, kWidevineCdmFileSystemId,
if (supports_persistent_license) { std::move(capability), kWidevineKeySystem, false));
supported_session_types.insert(
media::CdmSessionType::PERSISTENT_LICENSE_SESSION);
}
cdms->push_back(content::CdmInfo(
kWidevineCdmDisplayName, kWidevineCdmGuid, version, cdm_path,
kWidevineCdmFileSystemId, video_codecs_supported,
supported_session_types, encryption_modes_supported,
kWidevineKeySystem, false));
} }
#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) #endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
...@@ -571,6 +557,12 @@ void ChromeContentClient::AddContentDecryptionModules( ...@@ -571,6 +557,12 @@ void ChromeContentClient::AddContentDecryptionModules(
const char kExternalClearKeyDifferentGuidTestKeySystem[] = const char kExternalClearKeyDifferentGuidTestKeySystem[] =
"org.chromium.externalclearkey.differentguid"; "org.chromium.externalclearkey.differentguid";
// Supported codecs are hard-coded in ExternalClearKeyProperties.
content::CdmCapability capability(
{}, {media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs},
{media::CdmSessionType::TEMPORARY_SESSION,
media::CdmSessionType::PERSISTENT_LICENSE_SESSION});
// Register kExternalClearKeyDifferentGuidTestKeySystem first separately. // Register kExternalClearKeyDifferentGuidTestKeySystem first separately.
// Otherwise, it'll be treated as a sub-key-system of normal // Otherwise, it'll be treated as a sub-key-system of normal
// kExternalClearKeyKeySystem. See MultipleCdmTypes test in // kExternalClearKeyKeySystem. See MultipleCdmTypes test in
...@@ -578,21 +570,14 @@ void ChromeContentClient::AddContentDecryptionModules( ...@@ -578,21 +570,14 @@ void ChromeContentClient::AddContentDecryptionModules(
cdms->push_back(content::CdmInfo( cdms->push_back(content::CdmInfo(
media::kClearKeyCdmDisplayName, media::kClearKeyCdmDifferentGuid, media::kClearKeyCdmDisplayName, media::kClearKeyCdmDifferentGuid,
base::Version("0.1.0.0"), clear_key_cdm_path, base::Version("0.1.0.0"), clear_key_cdm_path,
media::kClearKeyCdmFileSystemId, {}, media::kClearKeyCdmFileSystemId, capability,
{media::CdmSessionType::TEMPORARY_SESSION,
media::CdmSessionType::PERSISTENT_LICENSE_SESSION},
{media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs},
kExternalClearKeyDifferentGuidTestKeySystem, false)); kExternalClearKeyDifferentGuidTestKeySystem, false));
// Supported codecs are hard-coded in ExternalClearKeyProperties. cdms->push_back(
cdms->push_back(content::CdmInfo( content::CdmInfo(media::kClearKeyCdmDisplayName,
media::kClearKeyCdmDisplayName, media::kClearKeyCdmGuid, media::kClearKeyCdmGuid, base::Version("0.1.0.0"),
base::Version("0.1.0.0"), clear_key_cdm_path, clear_key_cdm_path, media::kClearKeyCdmFileSystemId,
media::kClearKeyCdmFileSystemId, {}, capability, kExternalClearKeyKeySystem, true));
{media::CdmSessionType::TEMPORARY_SESSION,
media::CdmSessionType::PERSISTENT_LICENSE_SESSION},
{media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs},
kExternalClearKeyKeySystem, true));
} }
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
} }
......
...@@ -48,13 +48,13 @@ bool StlEquals(const Container a, std::initializer_list<T> b) { ...@@ -48,13 +48,13 @@ bool StlEquals(const Container a, std::initializer_list<T> b) {
} while (false) } while (false)
#define EXPECT_VIDEO_CODECS(...) \ #define EXPECT_VIDEO_CODECS(...) \
EXPECT_STL_EQ(cdm.supported_video_codecs, __VA_ARGS__) EXPECT_STL_EQ(cdm.capability.video_codecs, __VA_ARGS__)
#define EXPECT_ENCRYPTION_SCHEMES(...) \ #define EXPECT_ENCRYPTION_SCHEMES(...) \
EXPECT_STL_EQ(cdm.supported_encryption_schemes, __VA_ARGS__) EXPECT_STL_EQ(cdm.capability.encryption_schemes, __VA_ARGS__)
#define EXPECT_SESSION_TYPES(...) \ #define EXPECT_SESSION_TYPES(...) \
EXPECT_STL_EQ(cdm.supported_session_types, __VA_ARGS__) EXPECT_STL_EQ(cdm.capability.session_types, __VA_ARGS__)
} // namespace } // namespace
...@@ -66,21 +66,19 @@ class CdmRegistryImplTest : public testing::Test { ...@@ -66,21 +66,19 @@ class CdmRegistryImplTest : public testing::Test {
~CdmRegistryImplTest() override {} ~CdmRegistryImplTest() override {}
protected: protected:
void Register( void Register(const std::string& name,
const std::string& name, const std::string& version,
const std::string& version, const std::string& path,
const std::string& path, const std::vector<VideoCodec>& video_codecs,
const std::vector<VideoCodec>& supported_video_codecs, const base::flat_set<CdmSessionType>& session_types,
const base::flat_set<CdmSessionType>& supported_session_types, const base::flat_set<EncryptionMode>& encryption_schemes,
const base::flat_set<EncryptionMode>& supported_encryption_schemes, std::string supported_key_system,
std::string supported_key_system, bool supports_sub_key_systems = false) {
bool supports_sub_key_systems = false) {
cdm_registry_.RegisterCdm( cdm_registry_.RegisterCdm(
CdmInfo(name, kTestCdmGuid, base::Version(version), CdmInfo(name, kTestCdmGuid, base::Version(version),
base::FilePath::FromUTF8Unsafe(path), kTestFileSystemId, base::FilePath::FromUTF8Unsafe(path), kTestFileSystemId,
supported_video_codecs, supported_session_types, CdmCapability(video_codecs, encryption_schemes, session_types),
supported_encryption_schemes, supported_key_system, supported_key_system, supports_sub_key_systems));
supports_sub_key_systems));
} }
bool IsRegistered(const std::string& name, const std::string& version) { bool IsRegistered(const std::string& name, const std::string& version) {
......
...@@ -107,9 +107,9 @@ void KeySystemSupportImpl::IsKeySystemSupported( ...@@ -107,9 +107,9 @@ void KeySystemSupportImpl::IsKeySystemSupported(
// Supported codecs and encryption schemes. // Supported codecs and encryption schemes.
auto capability = media::mojom::KeySystemCapability::New(); auto capability = media::mojom::KeySystemCapability::New();
capability->video_codecs = cdm_info->supported_video_codecs; capability->video_codecs = cdm_info->capability.video_codecs;
capability->encryption_schemes = capability->encryption_schemes =
SetToVector(cdm_info->supported_encryption_schemes); SetToVector(cdm_info->capability.encryption_schemes);
if (base::FeatureList::IsEnabled(media::kHardwareSecureDecryption)) { if (base::FeatureList::IsEnabled(media::kHardwareSecureDecryption)) {
capability->hw_secure_video_codecs = capability->hw_secure_video_codecs =
...@@ -120,7 +120,7 @@ void KeySystemSupportImpl::IsKeySystemSupported( ...@@ -120,7 +120,7 @@ void KeySystemSupportImpl::IsKeySystemSupported(
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
capability->session_types = SetToVector(cdm_info->supported_session_types); capability->session_types = SetToVector(cdm_info->capability.session_types);
std::move(callback).Run(true, std::move(capability)); std::move(callback).Run(true, std::move(capability));
} }
......
...@@ -63,18 +63,17 @@ class KeySystemSupportTest : public testing::Test { ...@@ -63,18 +63,17 @@ class KeySystemSupportTest : public testing::Test {
// Registers |key_system| with supported capabilities. All other values for // Registers |key_system| with supported capabilities. All other values for
// CdmInfo have some default value as they're not returned by // CdmInfo have some default value as they're not returned by
// IsKeySystemSupported(). // IsKeySystemSupported().
void Register( void Register(const std::string& key_system,
const std::string& key_system, const std::vector<VideoCodec>& video_codecs,
const std::vector<VideoCodec>& supported_video_codecs, const base::flat_set<CdmSessionType>& session_types,
const base::flat_set<CdmSessionType>& supported_session_types, const base::flat_set<EncryptionMode>& encryption_schemes) {
const base::flat_set<EncryptionMode>& supported_encryption_schemes) {
DVLOG(1) << __func__; DVLOG(1) << __func__;
CdmRegistry::GetInstance()->RegisterCdm( CdmRegistry::GetInstance()->RegisterCdm(
CdmInfo(key_system, kTestCdmGuid, base::Version(kVersion), CdmInfo(key_system, kTestCdmGuid, base::Version(kVersion),
base::FilePath::FromUTF8Unsafe(kTestPath), kTestFileSystemId, base::FilePath::FromUTF8Unsafe(kTestPath), kTestFileSystemId,
supported_video_codecs, supported_session_types, CdmCapability(video_codecs, encryption_schemes, session_types),
supported_encryption_schemes, key_system, false)); key_system, false));
} }
// Determines if |key_system| is registered. If it is, updates |codecs_| // Determines if |key_system| is registered. If it is, updates |codecs_|
......
...@@ -9,29 +9,38 @@ ...@@ -9,29 +9,38 @@
namespace content { namespace content {
CdmInfo::CdmInfo( CdmCapability::CdmCapability() = default;
const std::string& name,
const std::string& guid, CdmCapability::CdmCapability(
const base::Version& version, std::vector<media::VideoCodec> video_codecs,
const base::FilePath& path, base::flat_set<media::EncryptionMode> encryption_schemes,
const std::string& file_system_id, base::flat_set<media::CdmSessionType> session_types)
const std::vector<media::VideoCodec>& supported_video_codecs, : video_codecs(std::move(video_codecs)),
const base::flat_set<media::CdmSessionType>& supported_session_types, encryption_schemes(std::move(encryption_schemes)),
const base::flat_set<media::EncryptionMode>& supported_encryption_schemes, session_types(std::move(session_types)) {}
const std::string& supported_key_system,
bool supports_sub_key_systems) CdmCapability::CdmCapability(const CdmCapability& other) = default;
CdmCapability::~CdmCapability() = default;
CdmInfo::CdmInfo(const std::string& name,
const std::string& guid,
const base::Version& version,
const base::FilePath& path,
const std::string& file_system_id,
CdmCapability capability,
const std::string& supported_key_system,
bool supports_sub_key_systems)
: name(name), : name(name),
guid(guid), guid(guid),
version(version), version(version),
path(path), path(path),
file_system_id(file_system_id), file_system_id(file_system_id),
supported_video_codecs(supported_video_codecs), capability(std::move(capability)),
supported_session_types(supported_session_types),
supported_encryption_schemes(supported_encryption_schemes),
supported_key_system(supported_key_system), supported_key_system(supported_key_system),
supports_sub_key_systems(supports_sub_key_systems) { supports_sub_key_systems(supports_sub_key_systems) {
DCHECK(base::IsValidGUID(guid)); DCHECK(base::IsValidGUID(guid));
DCHECK(!supported_encryption_schemes.empty()); DCHECK(!capability.encryption_schemes.empty());
} }
CdmInfo::CdmInfo(const CdmInfo& other) = default; CdmInfo::CdmInfo(const CdmInfo& other) = default;
......
...@@ -20,19 +20,39 @@ ...@@ -20,19 +20,39 @@
namespace content { namespace content {
// Capabilites supported by a Content Decryption Module.
struct CONTENT_EXPORT CdmCapability {
CdmCapability();
CdmCapability(std::vector<media::VideoCodec> video_codecs,
base::flat_set<media::EncryptionMode> encryption_schemes,
base::flat_set<media::CdmSessionType> session_types);
CdmCapability(const CdmCapability& other);
~CdmCapability();
// List of video codecs supported by the CDM (e.g. vp8). This is the set of
// codecs that can be decrypted and decoded by the CDM. As this is generic,
// not all profiles or levels of the specified codecs may actually be
// supported.
// TODO(crbug.com/796725) Find a way to include profiles and levels.
std::vector<media::VideoCodec> video_codecs;
// List of encryption schemes supported by the CDM (e.g. cenc).
base::flat_set<media::EncryptionMode> encryption_schemes;
// List of session types supported by the CDM.
base::flat_set<media::CdmSessionType> session_types;
};
// Represents a Content Decryption Module implementation and its capabilities. // Represents a Content Decryption Module implementation and its capabilities.
struct CONTENT_EXPORT CdmInfo { struct CONTENT_EXPORT CdmInfo {
CdmInfo( CdmInfo(const std::string& name,
const std::string& name, const std::string& guid,
const std::string& guid, const base::Version& version,
const base::Version& version, const base::FilePath& path,
const base::FilePath& path, const std::string& file_system_id,
const std::string& file_system_id, CdmCapability capability,
const std::vector<media::VideoCodec>& supported_video_codecs, const std::string& supported_key_system,
const base::flat_set<media::CdmSessionType>& supported_session_types, bool supports_sub_key_systems);
const base::flat_set<media::EncryptionMode>& supported_encryption_schemes,
const std::string& supported_key_system,
bool supports_sub_key_systems);
CdmInfo(const CdmInfo& other); CdmInfo(const CdmInfo& other);
~CdmInfo(); ~CdmInfo();
...@@ -54,18 +74,8 @@ struct CONTENT_EXPORT CdmInfo { ...@@ -54,18 +74,8 @@ struct CONTENT_EXPORT CdmInfo {
// digits(0-9), or "._-". // digits(0-9), or "._-".
std::string file_system_id; std::string file_system_id;
// List of video codecs supported by the CDM (e.g. vp8). This is the set of // CDM capability, e.g. video codecs, encryption schemes and session types.
// codecs that can be decrypted and decoded by the CDM. As this is generic, CdmCapability capability;
// not all profiles or levels of the specified codecs may actually be
// supported.
// TODO(crbug.com/796725) Find a way to include profiles and levels.
std::vector<media::VideoCodec> supported_video_codecs;
// List of session types supported by the CDM.
base::flat_set<media::CdmSessionType> supported_session_types;
// List of encryption schemes supported by the CDM (e.g. cenc).
base::flat_set<media::EncryptionMode> supported_encryption_schemes;
// The key system supported by this CDM. // The key system supported by this CDM.
std::string supported_key_system; std::string supported_key_system;
......
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