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 <cstdint>
11#include <memory>
12#include <vector>
13
14#include <absl/log/check.h>
15#include <absl/log/log.h>
16
17#include <packager/crypto_params.h>
18
19namespace shaka {
20namespace media {
21
23 std::vector<uint8_t> system_id;
24 std::vector<uint8_t> psshs;
25
29 static bool ParseBoxes(const uint8_t* data,
30 size_t data_size,
31 std::vector<ProtectionSystemSpecificInfo>* pssh_boxes);
32};
33
35 public:
36 PsshBoxBuilder() = default;
37 ~PsshBoxBuilder() = default;
38
41 static std::unique_ptr<PsshBoxBuilder> ParseFromBox(const uint8_t* data,
42 size_t data_size);
43
45 std::vector<uint8_t> CreateBox() const;
46
47 uint8_t pssh_box_version() const { return version_; }
48 const std::vector<uint8_t>& system_id() const { return system_id_; }
49 const std::vector<std::vector<uint8_t>>& key_ids() const { return key_ids_; }
50 const std::vector<uint8_t>& pssh_data() const { return pssh_data_; }
51
52 void set_pssh_box_version(uint8_t version) {
53 DCHECK_LT(version, 2);
54 version_ = version;
55 }
56 void set_system_id(const uint8_t* system_id, size_t system_id_size) {
57 DCHECK_EQ(16u, system_id_size);
58 system_id_.assign(system_id, system_id + system_id_size);
59 }
60 void add_key_id(const std::vector<uint8_t>& key_id) {
61 key_ids_.push_back(key_id);
62 }
63 void clear_key_ids() { key_ids_.clear(); }
64 void set_pssh_data(const std::vector<uint8_t>& pssh_data) {
65 pssh_data_ = pssh_data;
66 }
67
68 private:
69 PsshBoxBuilder(const PsshBoxBuilder&) = delete;
70 PsshBoxBuilder& operator=(const PsshBoxBuilder&) = delete;
71
72 uint8_t version_ = 0;
73 std::vector<uint8_t> system_id_;
74 std::vector<std::vector<uint8_t>> key_ids_;
75 std::vector<uint8_t> pssh_data_;
76};
77
78} // namespace media
79} // namespace shaka
80
81#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)