Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: chromecast/public/media/decoder_config.h

Issue 1786733004: Revert of media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ 5 #ifndef CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_
6 #define CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ 6 #define CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 kVP9ProfileAny, 86 kVP9ProfileAny,
87 kDolbyVisionCompatible_EL_MD, 87 kDolbyVisionCompatible_EL_MD,
88 kDolbyVisionCompatible_BL_EL_MD, 88 kDolbyVisionCompatible_BL_EL_MD,
89 kDolbyVisionNonCompatible_BL_MD, 89 kDolbyVisionNonCompatible_BL_MD,
90 kDolbyVisionNonCompatible_BL_EL_MD, 90 kDolbyVisionNonCompatible_BL_EL_MD,
91 91
92 kVideoProfileMin = kVideoProfileUnknown, 92 kVideoProfileMin = kVideoProfileUnknown,
93 kVideoProfileMax = kDolbyVisionNonCompatible_BL_EL_MD, 93 kVideoProfileMax = kDolbyVisionNonCompatible_BL_EL_MD,
94 }; 94 };
95 95
96 // Specification of whether and how the stream is encrypted (in whole or part). 96 // TODO(erickung): Remove constructor once CMA backend implementation does't
97 struct EncryptionScheme {
98 // Algorithm and mode that was used to encrypt the stream.
99 enum CipherMode {
100 CIPHER_MODE_UNENCRYPTED,
101 CIPHER_MODE_AES_CTR,
102 CIPHER_MODE_AES_CBC
103 };
104
105 // CENC 3rd Edition adds pattern encryption, through two new protection
106 // schemes: 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC).
107 // The pattern applies independently to each 'encrypted' part of the frame (as
108 // defined by the relevant subsample entries), and reduces further the
109 // actual encryption applied through a repeating pattern of (encrypt:skip)
110 // 16 byte blocks. For example, in a (1:9) pattern, the first block is
111 // encrypted, and the next nine are skipped. This pattern is applied
112 // repeatedly until the end of the last 16-byte block in the subsample.
113 // Any remaining bytes are left clear.
114 // If either of encrypt_blocks or skip_blocks is 0, pattern encryption is
115 // disabled.
116 struct Pattern {
117 Pattern() {}
118 Pattern(uint32_t encrypt_blocks, uint32_t skip_blocks);
119 ~Pattern() {}
120 bool IsInEffect() const;
121
122 uint32_t encrypt_blocks = 0;
123 uint32_t skip_blocks = 0;
124 };
125
126 EncryptionScheme() {}
127 EncryptionScheme(CipherMode mode, const Pattern& pattern);
128 ~EncryptionScheme() {}
129 bool is_encrypted() const { return mode != CIPHER_MODE_UNENCRYPTED; }
130
131 CipherMode mode = CIPHER_MODE_UNENCRYPTED;
132 Pattern pattern;
133 };
134
135 inline EncryptionScheme::Pattern::Pattern(uint32_t encrypt_blocks,
136 uint32_t skip_blocks)
137 : encrypt_blocks(encrypt_blocks), skip_blocks(skip_blocks) {
138 }
139
140 inline bool EncryptionScheme::Pattern::IsInEffect() const {
141 return encrypt_blocks != 0 && skip_blocks != 0;
142 }
143
144 inline EncryptionScheme::EncryptionScheme(CipherMode mode,
145 const Pattern& pattern)
146 : mode(mode), pattern(pattern) {
147 }
148
149 inline EncryptionScheme Unencrypted() {
150 return EncryptionScheme();
151 }
152
153 inline EncryptionScheme AesCtrEncryptionScheme() {
154 return EncryptionScheme(EncryptionScheme::CIPHER_MODE_AES_CTR,
155 EncryptionScheme::Pattern());
156 }
157
158
159 // TODO(erickung): Remove constructor once CMA backend implementation doesn't
160 // create a new object to reset the configuration and use IsValidConfig() to 97 // create a new object to reset the configuration and use IsValidConfig() to
161 // determine if the configuration is still valid or not. 98 // determine if the configuration is still valid or not.
162 struct AudioConfig { 99 struct AudioConfig {
163 AudioConfig(); 100 AudioConfig();
164 ~AudioConfig(); 101 ~AudioConfig();
165 102
166 bool is_encrypted() const { return encryption_scheme.is_encrypted(); }
167
168 // Stream id. 103 // Stream id.
169 StreamId id; 104 StreamId id;
170 // Audio codec. 105 // Audio codec.
171 AudioCodec codec; 106 AudioCodec codec;
172 // The format of each audio sample. 107 // The format of each audio sample.
173 SampleFormat sample_format; 108 SampleFormat sample_format;
174 // Number of bytes in each channel. 109 // Number of bytes in each channel.
175 int bytes_per_channel; 110 int bytes_per_channel;
176 // Number of channels in this audio stream. 111 // Number of channels in this audio stream.
177 int channel_number; 112 int channel_number;
178 // Number of audio samples per second. 113 // Number of audio samples per second.
179 int samples_per_second; 114 int samples_per_second;
180 // Extra data buffer for certain codec initialization. 115 // Extra data buffer for certain codec initialization.
181 std::vector<uint8_t> extra_data; 116 std::vector<uint8_t> extra_data;
182 // Encryption scheme (if any) used for the content. 117 // content is encrypted or not.
183 EncryptionScheme encryption_scheme; 118 bool is_encrypted;
184 }; 119 };
185 120
186 inline AudioConfig::AudioConfig() 121 inline AudioConfig::AudioConfig()
187 : id(kPrimary), 122 : id(kPrimary),
188 codec(kAudioCodecUnknown), 123 codec(kAudioCodecUnknown),
189 sample_format(kUnknownSampleFormat), 124 sample_format(kUnknownSampleFormat),
190 bytes_per_channel(0), 125 bytes_per_channel(0),
191 channel_number(0), 126 channel_number(0),
192 samples_per_second(0) { 127 samples_per_second(0),
128 is_encrypted(false) {
193 } 129 }
194 130
195 inline AudioConfig::~AudioConfig() { 131 inline AudioConfig::~AudioConfig() {
196 } 132 }
197 133
198 // TODO(erickung): Remove constructor once CMA backend implementation does't 134 // TODO(erickung): Remove constructor once CMA backend implementation does't
199 // create a new object to reset the configuration and use IsValidConfig() to 135 // create a new object to reset the configuration and use IsValidConfig() to
200 // determine if the configuration is still valid or not. 136 // determine if the configuration is still valid or not.
201 struct VideoConfig { 137 struct VideoConfig {
202 VideoConfig(); 138 VideoConfig();
203 ~VideoConfig(); 139 ~VideoConfig();
204 140
205 bool is_encrypted() const { return encryption_scheme.is_encrypted(); }
206
207 // Stream Id. 141 // Stream Id.
208 StreamId id; 142 StreamId id;
209 // Video codec. 143 // Video codec.
210 VideoCodec codec; 144 VideoCodec codec;
211 // Video codec profile. 145 // Video codec profile.
212 VideoProfile profile; 146 VideoProfile profile;
213 // Additional video config for the video stream if available. Consumers of 147 // Additional video config for the video stream if available. Consumers of
214 // this structure should make an explicit copy of |additional_config| if it 148 // this structure should make an explicit copy of |additional_config| if it
215 // will be used after SetConfig() finishes. 149 // will be used after SetConfig() finishes.
216 VideoConfig* additional_config; 150 VideoConfig* additional_config;
217 // Extra data buffer for certain codec initialization. 151 // Extra data buffer for certain codec initialization.
218 std::vector<uint8_t> extra_data; 152 std::vector<uint8_t> extra_data;
219 // Encryption scheme (if any) used for the content. 153 // content is encrypted or not.
220 EncryptionScheme encryption_scheme; 154 bool is_encrypted;
221 }; 155 };
222 156
223 inline VideoConfig::VideoConfig() 157 inline VideoConfig::VideoConfig()
224 : id(kPrimary), 158 : id(kPrimary),
225 codec(kVideoCodecUnknown), 159 codec(kVideoCodecUnknown),
226 profile(kVideoProfileUnknown), 160 profile(kVideoProfileUnknown),
227 additional_config(nullptr) { 161 additional_config(nullptr),
162 is_encrypted(false) {
228 } 163 }
229 164
230 inline VideoConfig::~VideoConfig() { 165 inline VideoConfig::~VideoConfig() {
231 } 166 }
232 167
233 // TODO(erickung): Remove following two inline IsValidConfig() functions. These 168 // TODO(erickung): Remove following two inline IsValidConfig() functions. These
234 // are to keep existing CMA backend implementation consistent until the clean up 169 // are to keep existing CMA backend implementation consistent until the clean up
235 // is done. These SHOULD NOT be used in New CMA backend implementation. 170 // is done. These SHOULD NOT be used in New CMA backend implementation.
236 inline bool IsValidConfig(const AudioConfig& config) { 171 inline bool IsValidConfig(const AudioConfig& config) {
237 return config.codec >= kAudioCodecMin && 172 return config.codec >= kAudioCodecMin &&
(...skipping 12 matching lines...) Expand all
250 inline bool IsValidConfig(const VideoConfig& config) { 185 inline bool IsValidConfig(const VideoConfig& config) {
251 return config.codec >= kVideoCodecMin && 186 return config.codec >= kVideoCodecMin &&
252 config.codec <= kVideoCodecMax && 187 config.codec <= kVideoCodecMax &&
253 config.codec != kVideoCodecUnknown; 188 config.codec != kVideoCodecUnknown;
254 } 189 }
255 190
256 } // namespace media 191 } // namespace media
257 } // namespace chromecast 192 } // namespace chromecast
258 193
259 #endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ 194 #endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_
OLDNEW
« no previous file with comments | « chromecast/media/media.gyp ('k') | content/common/gpu/media/video_encode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698