Chromium Code Reviews| Index: chromecast/public/media/decoder_config.h |
| diff --git a/chromecast/public/media/decoder_config.h b/chromecast/public/media/decoder_config.h |
| index 261b3f1fa575667196ef681dedec74f7bacdb49b..fb60fcd458a729c529677d263804f1be610fa4fc 100644 |
| --- a/chromecast/public/media/decoder_config.h |
| +++ b/chromecast/public/media/decoder_config.h |
| @@ -93,13 +93,94 @@ enum VideoProfile { |
| kVideoProfileMax = kDolbyVisionNonCompatible_BL_EL_MD, |
| }; |
| -// TODO(erickung): Remove constructor once CMA backend implementation does't |
| +// Specification of whether and how the stream is encrypted (in whole or part). |
| +struct EncryptionScheme { |
|
xhwang
2016/03/03 22:33:00
Is there any reason you need to duplication this i
halliwell
2016/03/03 22:56:44
Yep, we ship just this directory (chromecast/publi
dougsteed
2016/03/04 19:07:29
Not sure what you mean by "not the same". As far a
xhwang
2016/03/04 20:00:48
Yeah, I was talking about struct/class and unencry
dougsteed
2016/03/07 17:49:13
I eliminated the unencrypted/Unencrypted distincti
|
| + // Algorithm and mode that was used to encrypt the stream. |
| + enum CipherMode { |
| + kCipherModeUnencrypted, |
| + kCipherModeAesCtr, |
| + kCipherModeAesCbc |
| + }; |
| + |
| + // CENC 3d Edition adds pattern encryption, through two new |
|
ddorwin
2016/03/03 18:38:04
3rd
dougsteed
2016/03/04 19:07:29
aargh. Done.
|
| + // protection schemes 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC). |
| + // The pattern applies only to the 'encrypted' part of the frame (as |
| + // defined by the relevant subsample entries), and reduces further the |
| + // actual encryption applied through a repeating pattern of (encrypt:skip) |
| + // 16 byte blocks. For example, in a (1:9) pattern, the first block is |
| + // encrypted, and the next nine are skipped. This pattern is applied |
| + // repeatedly until the end of the last 16-byte block in the subsample. |
| + // Any remaining bytes are left clear. |
| + // If either or both of encrypt_blocks or skip_blocks is 0, pattern |
| + // encryption is disabled. |
| + struct PatternSpec { |
| + PatternSpec(); |
| + PatternSpec(uint32_t encrypt_blocks, uint32_t skip_blocks); |
| + ~PatternSpec(); |
| + bool IsInEffect() const; |
| + |
| + uint32_t encrypt_blocks; |
| + uint32_t skip_blocks; |
| + }; |
| + |
| + EncryptionScheme(); |
| + explicit EncryptionScheme(CipherMode mode); |
| + EncryptionScheme(CipherMode mode, const PatternSpec& pattern); |
| + ~EncryptionScheme(); |
| + static EncryptionScheme unencrypted(); |
| + bool is_encrypted() const; |
| + |
| + CipherMode mode; |
| + PatternSpec pattern; |
| +}; |
| + |
| +inline EncryptionScheme::PatternSpec::PatternSpec() |
| + : encrypt_blocks(0), skip_blocks(0) { |
| +} |
| + |
| +inline EncryptionScheme::PatternSpec::PatternSpec(uint32_t encrypt_blocks, |
| + uint32_t skip_blocks) |
| + : encrypt_blocks(encrypt_blocks), skip_blocks(skip_blocks) { |
| +} |
| + |
| +inline EncryptionScheme::PatternSpec::~PatternSpec() {} |
| + |
| +inline bool EncryptionScheme::PatternSpec::IsInEffect() const { |
| + return encrypt_blocks != 0 && skip_blocks != 0; |
| +} |
| + |
| +inline EncryptionScheme::EncryptionScheme() |
| + : mode(kCipherModeUnencrypted), pattern() { |
| +} |
| + |
| +inline EncryptionScheme::EncryptionScheme(CipherMode mode) |
| + : mode(mode), pattern() { |
| +} |
| + |
| +inline EncryptionScheme::EncryptionScheme(CipherMode mode, |
| + const PatternSpec& pattern) |
| + : mode(mode), pattern(pattern) { |
| +} |
| + |
| +inline EncryptionScheme::~EncryptionScheme() {} |
| + |
| +inline EncryptionScheme EncryptionScheme::unencrypted() { |
| + return EncryptionScheme(kCipherModeUnencrypted); |
| +} |
| + |
| +inline bool EncryptionScheme::is_encrypted() const { |
| + return mode != kCipherModeUnencrypted; |
| +} |
| + |
| +// TODO(erickung): Remove constructor once CMA backend implementation doesn't |
| // create a new object to reset the configuration and use IsValidConfig() to |
| // determine if the configuration is still valid or not. |
| struct AudioConfig { |
| AudioConfig(); |
| ~AudioConfig(); |
| + bool is_encrypted() const; |
| + |
| // Stream id. |
| StreamId id; |
| // Audio codec. |
| @@ -114,8 +195,8 @@ struct AudioConfig { |
| int samples_per_second; |
| // Extra data buffer for certain codec initialization. |
| std::vector<uint8_t> extra_data; |
| - // content is encrypted or not. |
| - bool is_encrypted; |
| + // Encryption scheme (if any) used for the content. |
| + EncryptionScheme encryption_scheme; |
| }; |
| inline AudioConfig::AudioConfig() |
| @@ -124,13 +205,16 @@ inline AudioConfig::AudioConfig() |
| sample_format(kUnknownSampleFormat), |
| bytes_per_channel(0), |
| channel_number(0), |
| - samples_per_second(0), |
| - is_encrypted(false) { |
| + samples_per_second(0) { |
| } |
| inline AudioConfig::~AudioConfig() { |
| } |
| +inline bool AudioConfig::is_encrypted() const { |
| + return encryption_scheme.is_encrypted(); |
| +} |
|
xhwang
2016/03/03 22:33:00
nit: you can implement this in line 182 directly.
dougsteed
2016/03/04 19:07:29
Done.
|
| + |
| // TODO(erickung): Remove constructor once CMA backend implementation does't |
| // create a new object to reset the configuration and use IsValidConfig() to |
| // determine if the configuration is still valid or not. |
| @@ -138,6 +222,8 @@ struct VideoConfig { |
| VideoConfig(); |
| ~VideoConfig(); |
| + bool is_encrypted() const; |
| + |
| // Stream Id. |
| StreamId id; |
| // Video codec. |
| @@ -150,21 +236,24 @@ struct VideoConfig { |
| VideoConfig* additional_config; |
| // Extra data buffer for certain codec initialization. |
| std::vector<uint8_t> extra_data; |
| - // content is encrypted or not. |
| - bool is_encrypted; |
| + // Encryption scheme (if any) used for the content. |
| + EncryptionScheme encryption_scheme; |
| }; |
| inline VideoConfig::VideoConfig() |
| : id(kPrimary), |
| codec(kVideoCodecUnknown), |
| profile(kVideoProfileUnknown), |
| - additional_config(nullptr), |
| - is_encrypted(false) { |
| + additional_config(nullptr) { |
| } |
| inline VideoConfig::~VideoConfig() { |
| } |
| +inline bool VideoConfig::is_encrypted() const { |
| + return encryption_scheme.is_encrypted(); |
| +} |
|
xhwang
2016/03/03 22:33:00
ditto
dougsteed
2016/03/04 19:07:29
Done.
|
| + |
| // TODO(erickung): Remove following two inline IsValidConfig() functions. These |
| // are to keep existing CMA backend implementation consistent until the clean up |
| // is done. These SHOULD NOT be used in New CMA backend implementation. |