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..503647b627fc0022d389107129f67ec0667b482f |
--- /dev/null |
+++ b/media/base/encryption_scheme.h |
@@ -0,0 +1,82 @@ |
+// 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> |
+ |
+#include "media/base/media_export.h" |
+ |
+namespace media { |
+ |
+// Specification of whether and how the stream is encrypted (in whole or part). |
+class MEDIA_EXPORT EncryptionScheme { |
+ public: |
+ // Algorithm and mode used for encryption. kCipherModeUnencrypted indicates |
+ // no encryption. |
+ enum CipherMode { |
+ kCipherModeUnencrypted, |
+ kCipherModeAesCtr, |
+ kCipherModeAesCbc, |
+ kCipherModeMax = kCipherModeAesCbc |
+ }; |
+ |
+ // CENC 3rd Edition adds pattern encryption, through two new protection |
+ // schemes: 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC). |
+ // The pattern applies independently to each '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 of encrypt_blocks or skip_blocks is 0, pattern encryption is |
+ // disabled. |
+ class Pattern { |
+ public: |
+ Pattern(); |
+ Pattern(uint32_t encrypt_blocks, uint32_t skip_blocks); |
+ ~Pattern(); |
+ |
+ bool Matches(const Pattern& other) const; |
+ |
+ uint32_t encrypt_blocks() const { return encrypt_blocks_; } |
+ uint32_t skip_blocks() const { return skip_blocks_; } |
+ |
+ bool IsInEffect() const; |
+ |
+ private: |
+ uint32_t encrypt_blocks_ = 0; |
+ uint32_t skip_blocks_ = 0; |
+ |
+ // Allow copy and assignment. |
+ }; |
+ |
+ // The default constructor makes an instance that indicates no encryption. |
+ EncryptionScheme(); |
+ |
+ // This constructor allows specification of the cipher mode with no pattern. |
ddorwin
2016/03/04 20:24:36
Now that we have the medi_util helpers, how much d
dougsteed
2016/03/07 17:49:13
Done.
xhwang
2016/03/07 18:39:52
This is not done yet...
dougsteed
2016/03/07 21:12:40
Done.
|
+ explicit EncryptionScheme(CipherMode mode); |
+ |
+ // This constructor allows specification of the cipher mode and the pattern. |
+ EncryptionScheme(CipherMode mode, const Pattern& pattern); |
+ ~EncryptionScheme(); |
+ |
+ bool Matches(const EncryptionScheme& other) const; |
+ |
+ bool is_encrypted() const { return mode_ != kCipherModeUnencrypted; } |
+ CipherMode mode() const { return mode_; } |
+ const Pattern& pattern() const { return pattern_; } |
+ |
+ private: |
+ CipherMode mode_ = kCipherModeUnencrypted; |
+ Pattern pattern_; |
+ |
+ // Allow copy and assignment. |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_ |