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

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: ddorwin comments Created 4 years, 9 months 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 #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 kCipherModeUnencrypted,
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
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/02 23:24:05 Clarify that this makes a "no encryption" object.
dougsteed 2016/03/03 04:45:00 Done.
58 explicit EncryptionScheme(CipherMode mode);
59 EncryptionScheme(CipherMode mode, const PatternSpec& pattern);
60 ~EncryptionScheme();
61 static EncryptionScheme Unencrypted();
ddorwin 2016/03/02 23:24:05 This doesn't seem like a style-compliant name. It'
dougsteed 2016/03/03 04:45:00 I want this to be named as just returning a suitab
62
63 bool Matches(const EncryptionScheme& other) const;
64
65 bool is_encrypted() const;
66 CipherMode mode() const { return mode_; }
67 const PatternSpec& pattern() const { return pattern_; }
68
69 private:
70 CipherMode mode_;
71 PatternSpec pattern_;
72
73 // Allow copy and assignment.
74 };
75
76 } // namespace media
77
78 #endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698