Index: media/base/encryption_scheme.h |
diff --git a/media/base/encryption_scheme.h b/media/base/encryption_scheme.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e74dd4b8dd60f21288675337d72f9406e27a08d3 |
--- /dev/null |
+++ b/media/base/encryption_scheme.h |
@@ -0,0 +1,81 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_BASE_ENCRYPTION_SCHEME_H_ |
+#define MEDIA_BASE_ENCRYPTION_SCHEME_H_ |
+ |
+#include <stdint.h> |
+ |
+namespace media { |
+ |
+// Algorithm and mode that was used to encrypt the stream. |
+enum CipherMode { |
ddorwin
2015/12/10 18:36:01
Should this be a member of the class?
dougsteed
2015/12/14 21:19:01
Done.
|
+ kCipherModeUnknown, |
+ kCipherModeAesCtr, |
+ kCipherModeAesCbc, |
+ kCipherModeMax = kCipherModeAesCbc |
ddorwin
2015/12/10 18:36:01
Do we need Max?
dougsteed
2015/12/14 21:19:02
Yes, needed for IPC ParamTraits.
|
+}; |
+ |
+// Specification of whether and how the stream is encrypted (in whole or part). |
+class EncryptionScheme { |
+ public: |
+ // V3 of the CENC standard will add pattern encryption, through two new |
ddorwin
2015/12/10 18:36:01
s/will add/adds/ to avoid comment rot?
dougsteed
2015/12/14 21:19:01
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 |
ddorwin
2015/12/10 18:36:01
Where does this apply? Is this a rule for this cla
dougsteed
2015/12/14 21:19:01
I am trying to model the concept of CENCv3, where
|
+ // encryption is disabled. |
+ class PatternSpec { |
+ public: |
+ PatternSpec(); |
+ PatternSpec(uint32_t encrypt_blocks, uint32_t skip_blocks); |
+ ~PatternSpec() {} |
ddorwin
2015/12/10 18:36:01
Do not inline.
dougsteed
2015/12/14 21:19:01
Done.
|
+ |
+ void Initialize(uint32_t encrypt_blocks, uint32_t skip_blocks); |
ddorwin
2015/12/10 18:36:01
Why do we need this and the matching constructor?
dougsteed
2015/12/14 21:19:01
Done.
|
+ bool Matches(const PatternSpec& other) const; |
+ |
+ uint32_t encrypt_blocks() const { return encrypt_blocks_; } |
ddorwin
2015/12/10 18:36:01
DCHECK in_effect()? Will need to move to .cc file.
dougsteed
2015/12/14 21:19:01
No. As mentioned above I still want to access the
|
+ uint32_t skip_blocks() const { return skip_blocks_; } |
+ |
+ bool in_effect() const { return encrypt_blocks_ != 0 || skip_blocks_ != 0; } |
ddorwin
2015/12/10 18:36:01
It's unclear whether this is a "simple accessor" (
dougsteed
2015/12/14 21:19:01
Done.
|
+ |
+ private: |
+ uint32_t encrypt_blocks_; |
ddorwin
2015/12/10 18:36:01
Can these be const?
(I guess not as long as we hav
dougsteed
2015/12/14 21:19:01
No, because want to have copy and assign. Latter r
|
+ uint32_t skip_blocks_; |
+ }; |
+ |
+ EncryptionScheme(); |
ddorwin
2015/12/10 18:36:01
As above, these constructors would be better as Cr
dougsteed
2015/12/14 21:19:01
Reduced the number of constructors. Hopefully it i
|
+ EncryptionScheme(bool is_encrypted); |
ddorwin
2015/12/10 18:36:01
explicit
ddorwin
2015/12/10 18:36:01
Do we need this one? Wouldn't the ones above and b
dougsteed
2015/12/14 21:19:01
Ouch. This caused a lot of extra files to need to
|
+ explicit EncryptionScheme(CipherMode mode); |
+ EncryptionScheme(CipherMode mode, const PatternSpec& pattern); |
+ EncryptionScheme(bool is_encrypted, |
ddorwin
2015/12/10 18:36:01
Why do we need this one? Why would you ever pass f
dougsteed
2015/12/14 21:19:01
Done.
|
+ CipherMode mode, |
+ const PatternSpec& pattern); |
+ ~EncryptionScheme() {} |
ddorwin
2015/12/10 18:36:01
Do not inline.
dougsteed
2015/12/14 21:19:01
Done.
|
+ |
+ void Initialize(bool is_encrypted, |
+ CipherMode mode, |
+ const PatternSpec& pattern); |
+ bool Matches(const EncryptionScheme& other) const; |
+ |
+ bool is_encrypted() const { return is_encrypted_; } |
+ CipherMode mode() const { return mode_; } |
+ const PatternSpec& pattern() const { return pattern_; } |
+ |
+ private: |
ddorwin
2015/12/10 18:36:01
Same question about const members.
dougsteed
2015/12/14 21:19:01
Same answer about copy and assign.
|
+ bool is_encrypted_; |
ddorwin
2015/12/10 18:36:01
Do we need this? We could rename kCipherModeUnknow
xhwang
2015/12/10 20:03:38
It's a bit odd that you have an EncryptionScheme w
dougsteed
2015/12/14 21:19:01
Done.
dougsteed
2015/12/14 21:19:01
I tried this and it doesn't work (at least not wit
|
+ CipherMode mode_; |
+ PatternSpec pattern_; |
+ |
+ // Allow copy and assignment. |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_ |