7 #include "packager/media/base/pssh_generator.h" 13 std::vector<uint8_t> CreatePsshBox(
14 const std::vector<uint8_t>& system_id,
16 const std::vector<std::vector<uint8_t>>& key_ids,
17 const std::vector<uint8_t>& pssh_data) {
18 PsshBoxBuilder pssh_builder;
19 pssh_builder.set_pssh_data(pssh_data);
20 for (
const std::vector<uint8_t>& key_id : key_ids) {
21 pssh_builder.add_key_id(key_id);
23 pssh_builder.set_pssh_box_version(version);
24 pssh_builder.set_system_id(system_id.data(), system_id.size());
26 return pssh_builder.CreateBox();
31 PsshGenerator::PsshGenerator() {}
33 PsshGenerator::~PsshGenerator() {}
36 const std::vector<std::vector<uint8_t>>& key_ids,
38 base::Optional<std::vector<uint8_t>> pssh_data =
39 GeneratePsshDataFromKeyIds(key_ids);
41 return Status(error::ENCRYPTION_FAILURE,
42 "Fail to generate PSSH data from multiple Key IDs.");
44 info->system_id = SystemId();
46 CreatePsshBox(SystemId(), PsshBoxVersion(), key_ids, pssh_data.value());
51 const std::vector<uint8_t>& key_id,
52 const std::vector<uint8_t>& key,
54 base::Optional<std::vector<uint8_t>> pssh_data =
55 GeneratePsshDataFromKeyIdAndKey(key_id, key);
57 return Status(error::ENCRYPTION_FAILURE,
58 "Fail to generate PSSH data from Key ID and Key.");
60 info->system_id = SystemId();
62 CreatePsshBox(SystemId(), PsshBoxVersion(), {key_id}, pssh_data.value());
All the methods that are virtual are virtual for mocking.