Shaka Packager SDK
Loading...
Searching...
No Matches
protection_system_specific_info.h
1// Copyright 2016 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#ifndef PACKAGER_MEDIA_BASE_PROTECTION_SYSTEM_SPECIFIC_INFO_H_
8#define PACKAGER_MEDIA_BASE_PROTECTION_SYSTEM_SPECIFIC_INFO_H_
9
10#include <cstddef>
11#include <cstdint>
12#include <memory>
13#include <vector>
14
15#include <absl/log/check.h>
16
17
18namespace shaka {
19namespace media {
20
22 std::vector<uint8_t> system_id;
23 std::vector<uint8_t> psshs;
24
28 static bool ParseBoxes(const uint8_t* data,
29 size_t data_size,
30 std::vector<ProtectionSystemSpecificInfo>* pssh_boxes);
31};
32
34 public:
35 PsshBoxBuilder() = default;
36 ~PsshBoxBuilder() = default;
37
40 static std::unique_ptr<PsshBoxBuilder> ParseFromBox(const uint8_t* data,
41 size_t data_size);
42
44 std::vector<uint8_t> CreateBox() const;
45
46 uint8_t pssh_box_version() const { return version_; }
47 const std::vector<uint8_t>& system_id() const { return system_id_; }
48 const std::vector<std::vector<uint8_t>>& key_ids() const { return key_ids_; }
49 const std::vector<uint8_t>& pssh_data() const { return pssh_data_; }
50
51 void set_pssh_box_version(uint8_t version) {
52 DCHECK_LT(version, 2);
53 version_ = version;
54 }
55 void set_system_id(const uint8_t* system_id, size_t system_id_size) {
56 DCHECK_EQ(16u, system_id_size);
57 system_id_.assign(system_id, system_id + system_id_size);
58 }
59 void add_key_id(const std::vector<uint8_t>& key_id) {
60 key_ids_.push_back(key_id);
61 }
62 void clear_key_ids() { key_ids_.clear(); }
63 void set_pssh_data(const std::vector<uint8_t>& pssh_data) {
64 pssh_data_ = pssh_data;
65 }
66
67 private:
68 PsshBoxBuilder(const PsshBoxBuilder&) = delete;
69 PsshBoxBuilder& operator=(const PsshBoxBuilder&) = delete;
70
71 uint8_t version_ = 0;
72 std::vector<uint8_t> system_id_;
73 std::vector<std::vector<uint8_t>> key_ids_;
74 std::vector<uint8_t> pssh_data_;
75};
76
77} // namespace media
78} // namespace shaka
79
80#endif // PACKAGER_MEDIA_BASE_PROTECTION_SYSTEM_SPECIFIC_INFO_H_
std::vector< uint8_t > CreateBox() const
Creates a PSSH box for the current data.
static std::unique_ptr< PsshBoxBuilder > ParseFromBox(const uint8_t *data, size_t data_size)
All the methods that are virtual are virtual for mocking.
static bool ParseBoxes(const uint8_t *data, size_t data_size, std::vector< ProtectionSystemSpecificInfo > *pssh_boxes)