7 #include <packager/media/base/widevine_pssh_generator.h>
9 #include <packager/macros/compiler.h>
10 #include <packager/macros/logging.h>
11 #include <packager/media/base/protection_system_ids.h>
12 #include <packager/media/base/widevine_pssh_data.pb.h>
18 const uint8_t kWidevinePsshBoxVersion = 0;
20 std::vector<uint8_t> StringToBytes(
const std::string&
string) {
21 return std::vector<uint8_t>(
string.begin(),
string.end());
25 WidevinePsshGenerator::WidevinePsshGenerator(FourCC protection_scheme)
26 : PsshGenerator(std::vector<uint8_t>(std::begin(kWidevineSystemId),
27 std::end(kWidevineSystemId)),
28 kWidevinePsshBoxVersion),
29 protection_scheme_(protection_scheme) {}
31 WidevinePsshGenerator::~WidevinePsshGenerator() {}
33 bool WidevinePsshGenerator::SupportMultipleKeys() {
37 std::optional<std::vector<uint8_t>>
38 WidevinePsshGenerator::GeneratePsshDataFromKeyIds(
39 const std::vector<std::vector<uint8_t>>& key_ids)
const {
40 media::WidevinePsshData widevine_pssh_data;
41 for (
const std::vector<uint8_t>& key_id : key_ids)
42 widevine_pssh_data.add_key_id(key_id.data(), key_id.size());
43 if (protection_scheme_ != FOURCC_NULL)
44 widevine_pssh_data.set_protection_scheme(protection_scheme_);
45 return StringToBytes(widevine_pssh_data.SerializeAsString());
48 std::optional<std::vector<uint8_t>>
49 WidevinePsshGenerator::GeneratePsshDataFromKeyIdAndKey(
50 const std::vector<uint8_t>& key_id,
51 const std::vector<uint8_t>& key)
const {
All the methods that are virtual are virtual for mocking.