7 #include "packager/media/base/key_source.h" 9 #include "packager/base/logging.h" 10 #include "packager/media/base/fairplay_pssh_generator.h" 11 #include "packager/media/base/playready_pssh_generator.h" 12 #include "packager/media/base/raw_key_pssh_generator.h" 13 #include "packager/media/base/widevine_pssh_generator.h" 14 #include "packager/status_macros.h" 19 KeySource::KeySource(
int protection_systems_flags, FourCC protection_scheme) {
20 if (protection_systems_flags & COMMON_PROTECTION_SYSTEM_FLAG) {
21 pssh_generators_.emplace_back(
new RawKeyPsshGenerator());
24 if (protection_systems_flags & PLAYREADY_PROTECTION_SYSTEM_FLAG) {
25 pssh_generators_.emplace_back(
new PlayReadyPsshGenerator());
28 if (protection_systems_flags & WIDEVINE_PROTECTION_SYSTEM_FLAG) {
29 pssh_generators_.emplace_back(
new WidevinePsshGenerator(protection_scheme));
32 if (protection_systems_flags & FAIRPLAY_PROTECTION_SYSTEM_FLAG) {
33 pssh_generators_.emplace_back(
new FairPlayPsshGenerator());
37 KeySource::~KeySource() =
default;
40 EncryptionKeyMap* encryption_key_map) {
41 for (
const auto& pssh_generator : pssh_generators_) {
42 const bool support_multiple_keys = pssh_generator->SupportMultipleKeys();
43 if (support_multiple_keys) {
45 std::vector<std::vector<uint8_t>> key_ids;
46 for (
const EncryptionKeyMap::value_type& pair : *encryption_key_map) {
47 key_ids.push_back(pair.second->key_id);
49 RETURN_IF_ERROR(pssh_generator->GeneratePsshFromKeyIds(key_ids, &info));
50 for (
const EncryptionKeyMap::value_type& pair : *encryption_key_map) {
51 pair.second->key_system_info.push_back(info);
54 for (
const EncryptionKeyMap::value_type& pair : *encryption_key_map) {
56 RETURN_IF_ERROR(pssh_generator->GeneratePsshFromKeyIdAndKey(
57 pair.second->key_id, pair.second->key, &info));
58 pair.second->key_system_info.push_back(info);
All the methods that are virtual are virtual for mocking.