1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/cdm/renderer/external_clear_key_key_system_info.h"
#include <algorithm>
#include "base/containers/contains.h"
#include "base/notreached.h"
#include "media/base/eme_constants.h"
#include "media/base/key_system_names.h"
#include "media/cdm/clear_key_cdm_common.h"
namespace cdm {
ExternalClearKeyKeySystemInfo::ExternalClearKeyKeySystemInfo()
: ExternalClearKeyKeySystemInfo(
// Supports kExternalClearKeyKeySystem and all its sub key systems,
// except for the explicitly "invalid" one. See the test
// EncryptedMediaSupportedTypesExternalClearKeyTest.InvalidKeySystems.
media::kExternalClearKeyKeySystem,
// Excludes kMediaFoundationClearKeyKeySystem to treat MediaFoundation
// Clear Key key system as a separate one.
{media::kExternalClearKeyInvalidKeySystem,
#if BUILDFLAG(IS_WIN)
media::kMediaFoundationClearKeyKeySystem
#endif // BUILDFLAG(IS_WIN)
},
media::EME_CODEC_MP4_ALL | media::EME_CODEC_WEBM_ALL,
std::nullopt,
media::EmeFeatureSupport::REQUESTABLE,
media::EmeFeatureSupport::NOT_SUPPORTED) {
}
ExternalClearKeyKeySystemInfo::ExternalClearKeyKeySystemInfo(
const std::string& key_system,
std::vector<std::string> excluded_key_systems,
media::SupportedCodecs codecs,
media::EmeConfig::Rule eme_config_rule,
media::EmeFeatureSupport persistent_state_support,
media::EmeFeatureSupport distinctive_identifier_support)
: key_system_(key_system),
excluded_key_systems_(excluded_key_systems),
codecs_(codecs),
eme_config_rule_(eme_config_rule),
persistent_state_support_(persistent_state_support),
distinctive_identifier_support_(distinctive_identifier_support) {}
ExternalClearKeyKeySystemInfo::~ExternalClearKeyKeySystemInfo() = default;
std::string ExternalClearKeyKeySystemInfo::GetBaseKeySystemName() const {
return key_system_;
}
bool ExternalClearKeyKeySystemInfo::IsSupportedKeySystem(
const std::string& key_system) const {
return (key_system == key_system_ ||
media::IsSubKeySystemOf(key_system, key_system_)) &&
!base::Contains(excluded_key_systems_, key_system);
}
bool ExternalClearKeyKeySystemInfo::IsSupportedInitDataType(
media::EmeInitDataType init_data_type) const {
switch (init_data_type) {
case media::EmeInitDataType::CENC:
case media::EmeInitDataType::WEBM:
case media::EmeInitDataType::KEYIDS:
return true;
case media::EmeInitDataType::UNKNOWN:
return false;
}
NOTREACHED();
}
std::optional<media::EmeConfig>
ExternalClearKeyKeySystemInfo::GetEncryptionSchemeConfigRule(
media::EncryptionScheme encryption_scheme) const {
switch (encryption_scheme) {
case media::EncryptionScheme::kCenc:
case media::EncryptionScheme::kCbcs:
return media::EmeConfig::SupportedRule();
case media::EncryptionScheme::kUnencrypted:
break;
}
NOTREACHED();
}
media::SupportedCodecs ExternalClearKeyKeySystemInfo::GetSupportedCodecs()
const {
return codecs_;
}
// On Windows, MediaFoundation Clear Key CDM requires HW secure codecs. We
// need this method to pretent to require this for testing purposes.
media::SupportedCodecs
ExternalClearKeyKeySystemInfo::GetSupportedHwSecureCodecs() const {
return codecs_;
}
std::optional<media::EmeConfig>
ExternalClearKeyKeySystemInfo::GetRobustnessConfigRule(
const std::string& key_system,
media::EmeMediaType media_type,
const std::string& requested_robustness,
const bool* /*hw_secure_requirement*/) const {
if (eme_config_rule_.has_value()) {
return eme_config_rule_;
}
if (requested_robustness.empty()) {
return media::EmeConfig::SupportedRule();
} else {
return media::EmeConfig::UnsupportedRule();
}
}
// Persistent license sessions are faked.
std::optional<media::EmeConfig>
ExternalClearKeyKeySystemInfo::GetPersistentLicenseSessionSupport() const {
return media::EmeConfig::SupportedRule();
}
media::EmeFeatureSupport
ExternalClearKeyKeySystemInfo::GetPersistentStateSupport() const {
return persistent_state_support_;
}
media::EmeFeatureSupport
ExternalClearKeyKeySystemInfo::GetDistinctiveIdentifierSupport() const {
return distinctive_identifier_support_;
}
} // namespace cdm
|