7#include <packager/media/base/pssh_generator.h>
13#include <packager/media/base/protection_system_specific_info.h>
14#include <packager/status.h>
20std::vector<uint8_t> CreatePsshBox(
21 const std::vector<uint8_t>& system_id,
23 const std::vector<std::vector<uint8_t>>& key_ids,
24 const std::vector<uint8_t>& pssh_data) {
25 PsshBoxBuilder pssh_builder;
26 pssh_builder.set_pssh_data(pssh_data);
27 for (
const std::vector<uint8_t>& key_id : key_ids) {
28 pssh_builder.add_key_id(key_id);
30 pssh_builder.set_pssh_box_version(version);
31 pssh_builder.set_system_id(system_id.data(), system_id.size());
33 return pssh_builder.CreateBox();
40 : system_id_(system_id), box_version_(box_version) {}
42PsshGenerator::~PsshGenerator() =
default;
45 const std::vector<std::vector<uint8_t>>& key_ids,
47 std::optional<std::vector<uint8_t>> pssh_data =
48 GeneratePsshDataFromKeyIds(key_ids);
50 return Status(error::ENCRYPTION_FAILURE,
51 "Fail to generate PSSH data from multiple Key IDs.");
53 info->system_id = system_id_;
55 CreatePsshBox(system_id_, box_version_, key_ids, pssh_data.value());
60 const std::vector<uint8_t>& key_id,
61 const std::vector<uint8_t>& key,
63 std::optional<std::vector<uint8_t>> pssh_data =
64 GeneratePsshDataFromKeyIdAndKey(key_id, key);
66 return Status(error::ENCRYPTION_FAILURE,
67 "Fail to generate PSSH data from Key ID and Key.");
69 info->system_id = system_id_;
71 CreatePsshBox(system_id_, box_version_, {key_id}, pssh_data.value());
All the methods that are virtual are virtual for mocking.