OLD | NEW |
---|---|
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 MEDIA_BASE_ENCRYPTION_SCHEME_H_ | 5 #ifndef MEDIA_BASE_ENCRYPTION_SCHEME_H_ |
6 #define MEDIA_BASE_ENCRYPTION_SCHEME_H_ | 6 #define MEDIA_BASE_ENCRYPTION_SCHEME_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 // CENC 3rd Edition adds pattern encryption, through two new protection | 26 // CENC 3rd Edition adds pattern encryption, through two new protection |
27 // schemes: 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC). | 27 // schemes: 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC). |
28 // The pattern applies independently to each 'encrypted' part of the frame (as | 28 // The pattern applies independently to each 'encrypted' part of the frame (as |
29 // defined by the relevant subsample entries), and reduces further the | 29 // defined by the relevant subsample entries), and reduces further the |
30 // actual encryption applied through a repeating pattern of (encrypt:skip) | 30 // actual encryption applied through a repeating pattern of (encrypt:skip) |
31 // 16 byte blocks. For example, in a (1:9) pattern, the first block is | 31 // 16 byte blocks. For example, in a (1:9) pattern, the first block is |
32 // encrypted, and the next nine are skipped. This pattern is applied | 32 // encrypted, and the next nine are skipped. This pattern is applied |
33 // repeatedly until the end of the last 16-byte block in the subsample. | 33 // repeatedly until the end of the last 16-byte block in the subsample. |
34 // Any remaining bytes are left clear. | 34 // Any remaining bytes are left clear. |
35 // If either of encrypt_blocks or skip_blocks is 0, pattern encryption is | 35 // If either of encrypt_blocks or skip_blocks is 0, pattern encryption is |
36 // disabled. | 36 // disabled. |
xhwang
2016/06/15 05:29:05
Could please add some comment about the relation b
| |
37 class MEDIA_EXPORT Pattern { | 37 class MEDIA_EXPORT Pattern { |
38 public: | 38 public: |
39 Pattern(); | 39 Pattern(); |
40 Pattern(uint32_t encrypt_blocks, uint32_t skip_blocks); | 40 Pattern(uint32_t encrypt_blocks, uint32_t skip_blocks); |
41 ~Pattern(); | 41 ~Pattern(); |
42 | 42 |
43 bool Matches(const Pattern& other) const; | 43 bool Matches(const Pattern& other) const; |
44 | 44 |
45 uint32_t encrypt_blocks() const { return encrypt_blocks_; } | 45 uint8_t encrypt_blocks() const { return encrypt_blocks_; } |
46 uint32_t skip_blocks() const { return skip_blocks_; } | 46 uint8_t skip_blocks() const { return skip_blocks_; } |
47 | 47 |
48 bool IsInEffect() const; | 48 bool IsInEffect() const; |
49 | 49 |
50 private: | 50 private: |
51 uint32_t encrypt_blocks_ = 0; | 51 uint8_t encrypt_blocks_ = 0; |
52 uint32_t skip_blocks_ = 0; | 52 uint8_t skip_blocks_ = 0; |
xhwang
2016/06/15 05:29:05
OOC why do we make this change?
Also, the constru
dougsteed
2016/06/15 17:57:38
Actually, I need to clean this up. I think now tha
| |
53 | 53 |
54 // Allow copy and assignment. | 54 // Allow copy and assignment. |
55 }; | 55 }; |
56 | 56 |
57 // The default constructor makes an instance that indicates no encryption. | 57 // The default constructor makes an instance that indicates no encryption. |
58 EncryptionScheme(); | 58 EncryptionScheme(); |
59 | 59 |
60 // This constructor allows specification of the cipher mode and the pattern. | 60 // This constructor allows specification of the cipher mode and the pattern. |
61 EncryptionScheme(CipherMode mode, const Pattern& pattern); | 61 EncryptionScheme(CipherMode mode, const Pattern& pattern); |
62 ~EncryptionScheme(); | 62 ~EncryptionScheme(); |
63 | 63 |
64 bool Matches(const EncryptionScheme& other) const; | 64 bool Matches(const EncryptionScheme& other) const; |
65 | 65 |
66 bool is_encrypted() const { return mode_ != CIPHER_MODE_UNENCRYPTED; } | 66 bool is_encrypted() const { return mode_ != CIPHER_MODE_UNENCRYPTED; } |
67 CipherMode mode() const { return mode_; } | 67 CipherMode mode() const { return mode_; } |
68 const Pattern& pattern() const { return pattern_; } | 68 const Pattern& pattern() const { return pattern_; } |
69 | 69 |
70 private: | 70 private: |
71 CipherMode mode_ = CIPHER_MODE_UNENCRYPTED; | 71 CipherMode mode_ = CIPHER_MODE_UNENCRYPTED; |
72 Pattern pattern_; | 72 Pattern pattern_; |
73 | 73 |
74 // Allow copy and assignment. | 74 // Allow copy and assignment. |
75 }; | 75 }; |
76 | 76 |
77 } // namespace media | 77 } // namespace media |
78 | 78 |
79 #endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_ | 79 #endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_ |
OLD | NEW |