OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_ENCRYPTION_SCHEME_H_ | |
6 #define MEDIA_BASE_ENCRYPTION_SCHEME_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "media/base/media_export.h" | |
11 | |
12 namespace media { | |
13 | |
14 // Specification of whether and how the stream is encrypted (in whole or part). | |
15 class MEDIA_EXPORT EncryptionScheme { | |
16 public: | |
17 // Algorithm and mode used for encryption. | |
18 enum CipherMode { | |
19 kCipherModeNone, | |
ddorwin
2016/03/01 02:17:41
If we make this kCipherModeUnencrypted, is that cl
dougsteed
2016/03/02 18:07:53
Done.
| |
20 kCipherModeAesCtr, | |
21 kCipherModeDefault = kCipherModeAesCtr, | |
22 kCipherModeAesCbc, | |
23 kCipherModeMax = kCipherModeAesCbc | |
24 }; | |
25 | |
26 // V3 of the CENC standard adds pattern encryption, through two new | |
27 // protection schemes 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC). | |
28 // The pattern applies only to the 'encrypted' part of the frame (as | |
29 // defined by the relevant subsample entries), and reduces further the | |
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 | |
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. | |
34 // Any remaining bytes are left clear. | |
35 // If either or both of encrypt_blocks or skip_blocks is 0, pattern | |
ddorwin
2016/03/01 02:17:41
Where do these values come from? Media? App? Inter
dougsteed
2016/03/02 18:07:52
In general they will come from the media, but only
| |
36 // encryption is disabled. | |
37 class PatternSpec { | |
38 public: | |
39 PatternSpec(); | |
40 PatternSpec(uint32_t encrypt_blocks, uint32_t skip_blocks); | |
41 ~PatternSpec(); | |
42 | |
43 bool Matches(const PatternSpec& other) const; | |
44 | |
45 uint32_t encrypt_blocks() const { return encrypt_blocks_; } | |
46 uint32_t skip_blocks() const { return skip_blocks_; } | |
47 | |
48 bool IsInEffect() const; | |
49 | |
50 private: | |
51 uint32_t encrypt_blocks_; | |
52 uint32_t skip_blocks_; | |
53 | |
54 // Allow copy and assignment. | |
55 }; | |
56 | |
57 EncryptionScheme(); | |
ddorwin
2016/03/01 02:17:41
// Same as CreateUnencrypted().
| |
58 explicit EncryptionScheme(bool is_encrypted); | |
ddorwin
2016/03/01 02:17:41
Does it make sense to specify `true` without passi
dougsteed
2016/03/02 18:07:53
Done.
| |
59 explicit EncryptionScheme(CipherMode mode); | |
ddorwin
2016/03/01 02:17:41
Do we need this one? Should we be explicit about r
dougsteed
2016/03/02 18:07:52
As mentioned above I think the default pattern (i.
| |
60 EncryptionScheme(CipherMode mode, const PatternSpec& pattern); | |
61 ~EncryptionScheme(); | |
62 static EncryptionScheme unencrypted(); | |
ddorwin
2016/03/01 02:17:41
CreateUnencrypted? It at least needs to use CamelC
dougsteed
2016/03/02 18:07:52
Changed it to Unencrypted.
| |
63 | |
64 void Initialize(CipherMode mode, const PatternSpec& pattern); | |
ddorwin
2016/03/01 02:17:41
Do we need this?
dougsteed
2016/03/02 18:07:52
Appears not.
| |
65 bool Matches(const EncryptionScheme& other) const; | |
66 | |
67 bool is_encrypted() const; | |
ddorwin
2016/03/01 02:17:41
This might not be a simple accessor anymore.
dougsteed
2016/03/02 18:07:52
Not sure what you mean by that. It is very simple,
| |
68 CipherMode mode() const { return mode_; } | |
69 const PatternSpec& pattern() const { return pattern_; } | |
70 | |
71 private: | |
72 CipherMode mode_; | |
73 PatternSpec pattern_; | |
74 | |
75 // Allow copy and assignment. | |
76 }; | |
77 | |
78 } // namespace media | |
79 | |
80 #endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_ | |
OLD | NEW |