Shaka Packager SDK
Loading...
Searching...
No Matches
decrypt_config.h
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PACKAGER_MEDIA_BASE_DECRYPT_CONFIG_H_
6#define PACKAGER_MEDIA_BASE_DECRYPT_CONFIG_H_
7
8#include <cstdint>
9#include <string>
10#include <vector>
11
12#include <packager/macros/classes.h>
13#include <packager/media/base/fourccs.h>
14
15namespace shaka {
16namespace media {
17
28 SubsampleEntry() : clear_bytes(0), cipher_bytes(0) {}
29 SubsampleEntry(uint16_t clear_bytes, uint32_t cipher_bytes)
30 : clear_bytes(clear_bytes), cipher_bytes(cipher_bytes) {}
31
32 uint16_t clear_bytes;
33 uint32_t cipher_bytes;
34};
35
39 public:
41 static const size_t kDecryptionKeySize = 16;
42
49 DecryptConfig(const std::vector<uint8_t>& key_id,
50 const std::vector<uint8_t>& iv,
51 const std::vector<SubsampleEntry>& subsamples);
52
65 DecryptConfig(const std::vector<uint8_t>& key_id,
66 const std::vector<uint8_t>& iv,
67 const std::vector<SubsampleEntry>& subsamples,
68 FourCC protection_scheme,
69 uint8_t crypt_byte_block,
70 uint8_t skip_byte_block);
71
73
78 void AddSubsample(uint16_t clear_bytes, uint32_t cipher_bytes) {
79 subsamples_.emplace_back(clear_bytes, cipher_bytes);
80 }
81
83 size_t GetTotalSizeOfSubsamples() const;
84
85 const std::vector<uint8_t>& key_id() const { return key_id_; }
86 const std::vector<uint8_t>& iv() const { return iv_; }
87 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; }
88 FourCC protection_scheme() const { return protection_scheme_; }
89 uint8_t crypt_byte_block() const { return crypt_byte_block_; }
90 uint8_t skip_byte_block() const { return skip_byte_block_; }
91
92 private:
93 const std::vector<uint8_t> key_id_;
94
95 // Initialization vector.
96 const std::vector<uint8_t> iv_;
97
98 // Subsample information. May be empty for some formats, meaning entire frame
99 // (less data ignored by data_offset_) is encrypted.
100 std::vector<SubsampleEntry> subsamples_;
101
102 const FourCC protection_scheme_;
103 // For pattern-based protection schemes, like CENS and CBCS.
104 const uint8_t crypt_byte_block_;
105 const uint8_t skip_byte_block_;
106
107 DISALLOW_COPY_AND_ASSIGN(DecryptConfig);
108};
109
110} // namespace media
111} // namespace shaka
112
113#endif // PACKAGER_MEDIA_BASE_DECRYPT_CONFIG_H_
void AddSubsample(uint16_t clear_bytes, uint32_t cipher_bytes)
size_t GetTotalSizeOfSubsamples() const
static const size_t kDecryptionKeySize
Keys are always 128 bits.
All the methods that are virtual are virtual for mocking.