blob: fe8a3a9f9e094696d36400dc53cfbcd26abd7467 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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. CIPHER_MODE_UNENCRYPTED indicates
// no encryption.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.media
enum CipherMode {
CIPHER_MODE_UNENCRYPTED,
CIPHER_MODE_AES_CTR,
CIPHER_MODE_AES_CBC,
CIPHER_MODE_MAX = CIPHER_MODE_AES_CBC
};
// CENC 3rd Edition adds pattern encryption, through two new protection
// schemes: 'cens' (with AES-CTR) and 'cbcs' (with AES-CBC).
// The pattern applies independently to each '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 of encrypt_blocks or skip_blocks is 0, pattern encryption is
// disabled.
class MEDIA_EXPORT Pattern {
public:
Pattern();
Pattern(uint32_t encrypt_blocks, uint32_t skip_blocks);
~Pattern();
bool Matches(const Pattern& other) const;
uint32_t encrypt_blocks() const;
uint32_t skip_blocks() const;
bool IsInEffect() const;
private:
uint32_t encrypt_blocks_ = 0;
uint32_t skip_blocks_ = 0;
// Allow copy and assignment.
};
// The default constructor makes an instance that indicates no encryption.
EncryptionScheme();
// This constructor allows specification of the cipher mode and the pattern.
EncryptionScheme(CipherMode mode, const Pattern& pattern);
~EncryptionScheme();
bool Matches(const EncryptionScheme& other) const;
bool is_encrypted() const;
CipherMode mode() const;
const Pattern& pattern() const;
private:
CipherMode mode_ = CIPHER_MODE_UNENCRYPTED;
Pattern pattern_;
// Allow copy and assignment.
};
} // namespace media
#endif // MEDIA_BASE_ENCRYPTION_SCHEME_H_
|