Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: media/base/encryption_scheme.h

Issue 1490613005: media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 namespace media {
11
12 // Algorithm and mode that was used to encrypt the stream.
13 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.
14 kCipherModeUnknown,
15 kCipherModeAesCtr,
16 kCipherModeAesCbc,
17 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.
18 };
19
20 // Specification of whether and how the stream is encrypted (in whole or part).
21 class EncryptionScheme {
22 public:
23 // 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.
24 // protection schemes 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC).
25 // The pattern applies only to the 'encrypted' part of the frame (as
26 // defined by the relevant subsample entries), and reduces further the
27 // actual encryption applied through a repeating pattern of (encrypt:skip)
28 // 16 byte blocks. For example, in a (1:9) pattern, the first block is
29 // encrypted, and the next nine are skipped. This pattern is applied
30 // repeatedly until the end of the last 16-byte block in the subsample.
31 // Any remaining bytes are left clear.
32 // 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
33 // encryption is disabled.
34 class PatternSpec {
35 public:
36 PatternSpec();
37 PatternSpec(uint32_t encrypt_blocks, uint32_t skip_blocks);
38 ~PatternSpec() {}
ddorwin 2015/12/10 18:36:01 Do not inline.
dougsteed 2015/12/14 21:19:01 Done.
39
40 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.
41 bool Matches(const PatternSpec& other) const;
42
43 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
44 uint32_t skip_blocks() const { return skip_blocks_; }
45
46 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.
47
48 private:
49 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
50 uint32_t skip_blocks_;
51 };
52
53 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
54 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
55 explicit EncryptionScheme(CipherMode mode);
56 EncryptionScheme(CipherMode mode, const PatternSpec& pattern);
57 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.
58 CipherMode mode,
59 const PatternSpec& pattern);
60 ~EncryptionScheme() {}
ddorwin 2015/12/10 18:36:01 Do not inline.
dougsteed 2015/12/14 21:19:01 Done.
61
62 void Initialize(bool is_encrypted,
63 CipherMode mode,
64 const PatternSpec& pattern);
65 bool Matches(const EncryptionScheme& other) const;
66
67 bool is_encrypted() const { return is_encrypted_; }
68 CipherMode mode() const { return mode_; }
69 const PatternSpec& pattern() const { return pattern_; }
70
71 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.
72 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
73 CipherMode mode_;
74 PatternSpec pattern_;
75
76 // Allow copy and assignment.
77 };
78
79 } // namespace media
80
81 #endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698