Index: chromecast/public/media/decoder_config.h |
diff --git a/chromecast/public/media/decoder_config.h b/chromecast/public/media/decoder_config.h |
index e2cf78dcbc6118608f4295c31ae9ff9e939c23ab..a8cc65fbbc98af326c4b489613e0499a1a9e4f4e 100644 |
--- a/chromecast/public/media/decoder_config.h |
+++ b/chromecast/public/media/decoder_config.h |
@@ -87,7 +87,82 @@ enum VideoProfile { |
kVideoProfileMax = kVP9ProfileAny, |
}; |
-// TODO(erickung): Remove constructor once CMA backend implementation does't |
+// 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.
|
+enum CipherMode { |
+ kCipherModeUnknown, |
+ kCipherModeAesCtr, |
+ kCipherModeAesCbc |
+}; |
+ |
+// Specification of whether and how the stream is encrypted (in whole or part). |
+struct EncryptionScheme { |
+ // V3 of the CENC standard will add pattern encryption, through two new |
+ // 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() {} |
+ uint32_t encrypt_blocks; |
+ uint32_t skip_blocks; |
+ }; |
+ |
+ EncryptionScheme(); |
+ EncryptionScheme(bool is_encrypted); |
+ EncryptionScheme(CipherMode mode); |
+ EncryptionScheme(CipherMode mode, const PatternSpec& pattern); |
+ EncryptionScheme(bool is_encrypted, CipherMode, const PatternSpec& pattern); |
+ ~EncryptionScheme() {} |
+ 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
|
+ CipherMode mode; |
+ PatternSpec pattern; |
+}; |
+ |
+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
|
+ : 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::EncryptionScheme() |
+ : is_encrypted(false), mode(kCipherModeUnknown), pattern() { |
+} |
+ |
+inline EncryptionScheme::EncryptionScheme(bool is_encrypted) |
+ : is_encrypted(is_encrypted), |
+ mode(is_encrypted ? kCipherModeAesCtr : kCipherModeUnknown), |
+ pattern() { |
+} |
+ |
+inline EncryptionScheme::EncryptionScheme(CipherMode mode) |
+ : is_encrypted(true), mode(mode), pattern() { |
+} |
+ |
+inline EncryptionScheme::EncryptionScheme(CipherMode mode, |
+ const PatternSpec& pattern) |
+ : is_encrypted(true), mode(mode), pattern(pattern) { |
+} |
+ |
+inline EncryptionScheme::EncryptionScheme( |
+ bool is_encrypted, |
+ CipherMode mode, |
+ const PatternSpec& pattern) |
+ : is_encrypted(is_encrypted), mode(mode), pattern(pattern) { |
+} |
+ |
+ |
+// 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 { |
@@ -108,8 +183,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() |
@@ -119,7 +194,7 @@ inline AudioConfig::AudioConfig() |
bytes_per_channel(0), |
channel_number(0), |
samples_per_second(0), |
- is_encrypted(false) { |
+ encryption_scheme(false) { |
} |
inline AudioConfig::~AudioConfig() { |
@@ -144,8 +219,8 @@ 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() |
@@ -153,7 +228,7 @@ inline VideoConfig::VideoConfig() |
codec(kVideoCodecUnknown), |
profile(kVideoProfileUnknown), |
additional_config(nullptr), |
- is_encrypted(false) { |
+ encryption_scheme(false) { |
} |
inline VideoConfig::~VideoConfig() { |