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

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: ddorwin comments 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..c64a6e7fe0dd1e3e1c96d65f633b539707ad897f
--- /dev/null
+++ b/media/base/encryption_scheme.h
@@ -0,0 +1,78 @@
+// 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 {
+ kCipherModeUnencrypted,
+ 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
+ // 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/02 23:24:05 Clarify that this makes a "no encryption" object.
dougsteed 2016/03/03 04:45:00 Done.
+ explicit EncryptionScheme(CipherMode mode);
+ EncryptionScheme(CipherMode mode, const PatternSpec& pattern);
+ ~EncryptionScheme();
+ 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
+
+ bool Matches(const EncryptionScheme& other) const;
+
+ bool is_encrypted() const;
+ 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