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(
30 const uint8_t* data,
31 size_t data_size,
32 std::vector<ProtectionSystemSpecificInfo>* pssh_boxes);
33};
34
36 public:
37 PsshBoxBuilder() = default;
38 ~PsshBoxBuilder() = default;
39
42 static std::unique_ptr<PsshBoxBuilder> ParseFromBox(const uint8_t* data,
43 size_t data_size);
44
46 std::vector<uint8_t> CreateBox() const;
47
48 uint8_t pssh_box_version() const { return version_; }
49 const std::vector<uint8_t>& system_id() const { return system_id_; }
50 const std::vector<std::vector<uint8_t>>& key_ids() const { return key_ids_; }
51 const std::vector<uint8_t>& pssh_data() const { return pssh_data_; }
52
53 void set_pssh_box_version(uint8_t version) {
54 DCHECK_LT(version, 2);
55 version_ = version;
56 }
57 void set_system_id(const uint8_t* system_id, size_t system_id_size) {
58 DCHECK_EQ(16u, system_id_size);
59 system_id_.assign(system_id, system_id + system_id_size);
60 }
61 void add_key_id(const std::vector<uint8_t>& key_id) {
62 key_ids_.push_back(key_id);
63 }
64 void clear_key_ids() { key_ids_.clear(); }
65 void set_pssh_data(const std::vector<uint8_t>& pssh_data) {
66 pssh_data_ = pssh_data;
67 }
68
69 private:
70 PsshBoxBuilder(const PsshBoxBuilder&) = delete;
71 PsshBoxBuilder& operator=(const PsshBoxBuilder&) = delete;
72
73 uint8_t version_ = 0;
74 std::vector<uint8_t> system_id_;
75 std::vector<std::vector<uint8_t>> key_ids_;
76 std::vector<uint8_t> pssh_data_;
77};
78
79} // namespace media
80} // namespace shaka
81
82#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)