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

Unified 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: mojo changes; Message->base::Pickle Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
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..2751e4745d2e30c1e1126534aa045d9a8d7e6156
--- /dev/null
+++ b/media/base/encryption_scheme.h
@@ -0,0 +1,80 @@
+// 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.
+ enum CipherMode {
+ kCipherModeNone,
ddorwin 2016/03/01 02:17:41 If we make this kCipherModeUnencrypted, is that cl
dougsteed 2016/03/02 18:07:53 Done.
+ kCipherModeAesCtr,
+ kCipherModeDefault = kCipherModeAesCtr,
+ kCipherModeAesCbc,
+ kCipherModeMax = kCipherModeAesCbc
+ };
+
+ // V3 of the CENC standard adds pattern encryption, through two new
+ // protection schemes 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC).
+ // The pattern applies only to the '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 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
+ // encryption is disabled.
+ class PatternSpec {
+ public:
+ PatternSpec();
+ PatternSpec(uint32_t encrypt_blocks, uint32_t skip_blocks);
+ ~PatternSpec();
+
+ bool Matches(const PatternSpec& 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_;
+ uint32_t skip_blocks_;
+
+ // Allow copy and assignment.
+ };
+
+ EncryptionScheme();
ddorwin 2016/03/01 02:17:41 // Same as CreateUnencrypted().
+ 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.
+ 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.
+ EncryptionScheme(CipherMode mode, const PatternSpec& pattern);
+ ~EncryptionScheme();
+ 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.
+
+ 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.
+ bool Matches(const EncryptionScheme& other) const;
+
+ 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,
+ CipherMode mode() const { return mode_; }
+ const PatternSpec& pattern() const { return pattern_; }
+
+ private:
+ CipherMode mode_;
+ PatternSpec pattern_;
+
+ // Allow copy and assignment.
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_

Powered by Google App Engine
This is Rietveld 408576698