7 #include "packager/media/base/key_source.h" 9 #include "packager/base/logging.h" 10 #include "packager/media/base/playready_pssh_generator.h" 11 #include "packager/media/base/raw_key_pssh_generator.h" 12 #include "packager/media/base/widevine_pssh_generator.h" 17 EncryptionKey::EncryptionKey() {}
19 EncryptionKey::~EncryptionKey() {}
21 KeySource::KeySource(
int protection_systems_flags) {
22 if (protection_systems_flags & COMMON_PROTECTION_SYSTEM_FLAG) {
23 pssh_generators_.emplace_back(
new RawKeyPsshGenerator());
26 if (protection_systems_flags & PLAYREADY_PROTECTION_SYSTEM_FLAG) {
27 pssh_generators_.emplace_back(
new PlayReadyPsshGenerator());
30 if (protection_systems_flags & WIDEVINE_PROTECTION_SYSTEM_FLAG) {
31 pssh_generators_.emplace_back(
new WidevinePsshGenerator());
35 KeySource::~KeySource() {}
38 EncryptionKeyMap* encryption_key_map) {
39 for (
const auto& pssh_generator : pssh_generators_) {
40 const bool support_multiple_keys = pssh_generator->SupportMultipleKeys();
41 if (support_multiple_keys) {
43 std::vector<std::vector<uint8_t>> key_ids;
44 for (
const EncryptionKeyMap::value_type& pair : *encryption_key_map) {
45 key_ids.push_back(pair.second->key_id);
47 Status status = pssh_generator->GeneratePsshFromKeyIds(key_ids, &info);
51 for (
const EncryptionKeyMap::value_type& pair : *encryption_key_map) {
52 pair.second->key_system_info.push_back(info);
55 for (
const EncryptionKeyMap::value_type& pair : *encryption_key_map) {
57 Status status = pssh_generator->GeneratePsshFromKeyIdAndKey(
58 pair.second->key_id, pair.second->key, &info);
62 pair.second->key_system_info.push_back(info);
All the methods that are virtual are virtual for mocking.