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();
33 : system_id_(system_id), box_version_(box_version) {}
35 PsshGenerator::~PsshGenerator() =
default;
38 const std::vector<std::vector<uint8_t>>& key_ids,
40 base::Optional<std::vector<uint8_t>> pssh_data =
41 GeneratePsshDataFromKeyIds(key_ids);
43 return Status(error::ENCRYPTION_FAILURE,
44 "Fail to generate PSSH data from multiple Key IDs.");
46 info->system_id = system_id_;
48 CreatePsshBox(system_id_, box_version_, key_ids, pssh_data.value());
53 const std::vector<uint8_t>& key_id,
54 const std::vector<uint8_t>& key,
56 base::Optional<std::vector<uint8_t>> pssh_data =
57 GeneratePsshDataFromKeyIdAndKey(key_id, key);
59 return Status(error::ENCRYPTION_FAILURE,
60 "Fail to generate PSSH data from Key ID and Key.");
62 info->system_id = system_id_;
64 CreatePsshBox(system_id_, box_version_, {key_id}, pssh_data.value());