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

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

Issue 1490613005: media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 kH264ScalableHigh, 80 kH264ScalableHigh,
81 kH264Stereohigh, 81 kH264Stereohigh,
82 kH264MultiviewHigh, 82 kH264MultiviewHigh,
83 kVP8ProfileAny, 83 kVP8ProfileAny,
84 kVP9ProfileAny, 84 kVP9ProfileAny,
85 85
86 kVideoProfileMin = kVideoProfileUnknown, 86 kVideoProfileMin = kVideoProfileUnknown,
87 kVideoProfileMax = kVP9ProfileAny, 87 kVideoProfileMax = kVP9ProfileAny,
88 }; 88 };
89 89
90 // TODO(erickung): Remove constructor once CMA backend implementation does't 90 // Algorithm and mode that was used to encrypt the stream.
ddorwin 2015/12/10 18:36:00 Similar comments as in encryption_scheme.h.
dougsteed 2015/12/14 21:19:01 Done.
91 enum CipherMode {
92 kCipherModeUnknown,
93 kCipherModeAesCtr,
94 kCipherModeAesCbc
95 };
96
97 // Specification of whether and how the stream is encrypted (in whole or part).
98 struct EncryptionScheme {
99 // V3 of the CENC standard will add pattern encryption, through two new
100 // protection schemes 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC).
101 // The pattern applies only to the 'encrypted' part of the frame (as
102 // defined by the relevant subsample entries), and reduces further the
103 // actual encryption applied through a repeating pattern of (encrypt:skip)
104 // 16 byte blocks. For example, in a (1:9) pattern, the first block is
105 // encrypted, and the next nine are skipped. This pattern is applied
106 // repeatedly until the end of the last 16-byte block in the subsample.
107 // Any remaining bytes are left clear.
108 // If either or both of encrypt_blocks or skip_blocks is 0, pattern
109 // encryption is disabled.
110 struct PatternSpec {
111 PatternSpec();
112 PatternSpec(uint32_t encrypt_blocks, uint32_t skip_blocks);
113 ~PatternSpec() {}
114 uint32_t encrypt_blocks;
115 uint32_t skip_blocks;
116 };
117
118 EncryptionScheme();
119 EncryptionScheme(bool is_encrypted);
120 EncryptionScheme(CipherMode mode);
121 EncryptionScheme(CipherMode mode, const PatternSpec& pattern);
122 EncryptionScheme(bool is_encrypted, CipherMode, const PatternSpec& pattern);
123 ~EncryptionScheme() {}
124 bool is_encrypted;
ddorwin 2015/12/10 18:36:00 Public members make things more interesting (and d
dougsteed 2015/12/14 21:19:01 This is the house style for the chromecast media A
125 CipherMode mode;
126 PatternSpec pattern;
127 };
128
129 inline EncryptionScheme::PatternSpec::PatternSpec()
ddorwin 2015/12/10 18:36:00 Why are constructors and destructors inlined here?
dougsteed 2015/12/14 21:19:01 I'm following the existing style for the chromecas
130 : encrypt_blocks(0), skip_blocks(0) {
131 }
132
133 inline EncryptionScheme::PatternSpec::PatternSpec(uint32_t encrypt_blocks,
134 uint32_t skip_blocks)
135 : encrypt_blocks(encrypt_blocks), skip_blocks(skip_blocks) {
136 }
137
138 inline EncryptionScheme::EncryptionScheme()
139 : is_encrypted(false), mode(kCipherModeUnknown), pattern() {
140 }
141
142 inline EncryptionScheme::EncryptionScheme(bool is_encrypted)
143 : is_encrypted(is_encrypted),
144 mode(is_encrypted ? kCipherModeAesCtr : kCipherModeUnknown),
145 pattern() {
146 }
147
148 inline EncryptionScheme::EncryptionScheme(CipherMode mode)
149 : is_encrypted(true), mode(mode), pattern() {
150 }
151
152 inline EncryptionScheme::EncryptionScheme(CipherMode mode,
153 const PatternSpec& pattern)
154 : is_encrypted(true), mode(mode), pattern(pattern) {
155 }
156
157 inline EncryptionScheme::EncryptionScheme(
158 bool is_encrypted,
159 CipherMode mode,
160 const PatternSpec& pattern)
161 : is_encrypted(is_encrypted), mode(mode), pattern(pattern) {
162 }
163
164
165 // TODO(erickung): Remove constructor once CMA backend implementation doesn't
91 // create a new object to reset the configuration and use IsValidConfig() to 166 // create a new object to reset the configuration and use IsValidConfig() to
92 // determine if the configuration is still valid or not. 167 // determine if the configuration is still valid or not.
93 struct AudioConfig { 168 struct AudioConfig {
94 AudioConfig(); 169 AudioConfig();
95 ~AudioConfig(); 170 ~AudioConfig();
96 171
97 // Stream id. 172 // Stream id.
98 StreamId id; 173 StreamId id;
99 // Audio codec. 174 // Audio codec.
100 AudioCodec codec; 175 AudioCodec codec;
101 // The format of each audio sample. 176 // The format of each audio sample.
102 SampleFormat sample_format; 177 SampleFormat sample_format;
103 // Number of bytes in each channel. 178 // Number of bytes in each channel.
104 int bytes_per_channel; 179 int bytes_per_channel;
105 // Number of channels in this audio stream. 180 // Number of channels in this audio stream.
106 int channel_number; 181 int channel_number;
107 // Number of audio samples per second. 182 // Number of audio samples per second.
108 int samples_per_second; 183 int samples_per_second;
109 // Extra data buffer for certain codec initialization. 184 // Extra data buffer for certain codec initialization.
110 std::vector<uint8_t> extra_data; 185 std::vector<uint8_t> extra_data;
111 // content is encrypted or not. 186 // Encryption scheme (if any) used for the content.
112 bool is_encrypted; 187 EncryptionScheme encryption_scheme;
113 }; 188 };
114 189
115 inline AudioConfig::AudioConfig() 190 inline AudioConfig::AudioConfig()
116 : id(kPrimary), 191 : id(kPrimary),
117 codec(kAudioCodecUnknown), 192 codec(kAudioCodecUnknown),
118 sample_format(kUnknownSampleFormat), 193 sample_format(kUnknownSampleFormat),
119 bytes_per_channel(0), 194 bytes_per_channel(0),
120 channel_number(0), 195 channel_number(0),
121 samples_per_second(0), 196 samples_per_second(0),
122 is_encrypted(false) { 197 encryption_scheme(false) {
123 } 198 }
124 199
125 inline AudioConfig::~AudioConfig() { 200 inline AudioConfig::~AudioConfig() {
126 } 201 }
127 202
128 // TODO(erickung): Remove constructor once CMA backend implementation does't 203 // TODO(erickung): Remove constructor once CMA backend implementation does't
129 // create a new object to reset the configuration and use IsValidConfig() to 204 // create a new object to reset the configuration and use IsValidConfig() to
130 // determine if the configuration is still valid or not. 205 // determine if the configuration is still valid or not.
131 struct VideoConfig { 206 struct VideoConfig {
132 VideoConfig(); 207 VideoConfig();
133 ~VideoConfig(); 208 ~VideoConfig();
134 209
135 // Stream Id. 210 // Stream Id.
136 StreamId id; 211 StreamId id;
137 // Video codec. 212 // Video codec.
138 VideoCodec codec; 213 VideoCodec codec;
139 // Video codec profile. 214 // Video codec profile.
140 VideoProfile profile; 215 VideoProfile profile;
141 // Additional video config for the video stream if available. Consumers of 216 // Additional video config for the video stream if available. Consumers of
142 // this structure should make an explicit copy of |additional_config| if it 217 // this structure should make an explicit copy of |additional_config| if it
143 // will be used after SetConfig() finishes. 218 // will be used after SetConfig() finishes.
144 VideoConfig* additional_config; 219 VideoConfig* additional_config;
145 // Extra data buffer for certain codec initialization. 220 // Extra data buffer for certain codec initialization.
146 std::vector<uint8_t> extra_data; 221 std::vector<uint8_t> extra_data;
147 // content is encrypted or not. 222 // Encryption scheme (if any) used for the content.
148 bool is_encrypted; 223 EncryptionScheme encryption_scheme;
149 }; 224 };
150 225
151 inline VideoConfig::VideoConfig() 226 inline VideoConfig::VideoConfig()
152 : id(kPrimary), 227 : id(kPrimary),
153 codec(kVideoCodecUnknown), 228 codec(kVideoCodecUnknown),
154 profile(kVideoProfileUnknown), 229 profile(kVideoProfileUnknown),
155 additional_config(nullptr), 230 additional_config(nullptr),
156 is_encrypted(false) { 231 encryption_scheme(false) {
157 } 232 }
158 233
159 inline VideoConfig::~VideoConfig() { 234 inline VideoConfig::~VideoConfig() {
160 } 235 }
161 236
162 // TODO(erickung): Remove following two inline IsValidConfig() functions. These 237 // TODO(erickung): Remove following two inline IsValidConfig() functions. These
163 // are to keep existing CMA backend implementation consistent until the clean up 238 // are to keep existing CMA backend implementation consistent until the clean up
164 // is done. These SHOULD NOT be used in New CMA backend implementation. 239 // is done. These SHOULD NOT be used in New CMA backend implementation.
165 inline bool IsValidConfig(const AudioConfig& config) { 240 inline bool IsValidConfig(const AudioConfig& config) {
166 return config.codec >= kAudioCodecMin && 241 return config.codec >= kAudioCodecMin &&
(...skipping 12 matching lines...) Expand all
179 inline bool IsValidConfig(const VideoConfig& config) { 254 inline bool IsValidConfig(const VideoConfig& config) {
180 return config.codec >= kVideoCodecMin && 255 return config.codec >= kVideoCodecMin &&
181 config.codec <= kVideoCodecMax && 256 config.codec <= kVideoCodecMax &&
182 config.codec != kVideoCodecUnknown; 257 config.codec != kVideoCodecUnknown;
183 } 258 }
184 259
185 } // namespace media 260 } // namespace media
186 } // namespace chromecast 261 } // namespace chromecast
187 262
188 #endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ 263 #endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698