OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/encryption_scheme.h" | 5 #include "media/base/encryption_scheme.h" |
6 | 6 |
7 namespace media { | 7 namespace media { |
8 | 8 |
9 EncryptionScheme::Pattern::Pattern() {} | 9 EncryptionScheme::Pattern::Pattern() {} |
10 | 10 |
11 EncryptionScheme::Pattern::Pattern(uint32_t encrypt_blocks, | 11 EncryptionScheme::Pattern::Pattern(uint32_t encrypt_blocks, |
12 uint32_t skip_blocks) | 12 uint32_t skip_blocks) |
13 : encrypt_blocks_(encrypt_blocks), skip_blocks_(skip_blocks) {} | 13 : encrypt_blocks_(encrypt_blocks), skip_blocks_(skip_blocks) {} |
14 | 14 |
15 EncryptionScheme::Pattern::~Pattern() {} | 15 EncryptionScheme::Pattern::~Pattern() {} |
16 | 16 |
| 17 uint32_t EncryptionScheme::Pattern::encrypt_blocks() const { |
| 18 return encrypt_blocks_; |
| 19 } |
| 20 |
| 21 uint32_t EncryptionScheme::Pattern::skip_blocks() const { |
| 22 return skip_blocks_; |
| 23 } |
| 24 |
17 bool EncryptionScheme::Pattern::Matches(const Pattern& other) const { | 25 bool EncryptionScheme::Pattern::Matches(const Pattern& other) const { |
18 return encrypt_blocks_ == other.encrypt_blocks() && | 26 return encrypt_blocks_ == other.encrypt_blocks() && |
19 skip_blocks_ == other.skip_blocks(); | 27 skip_blocks_ == other.skip_blocks(); |
20 } | 28 } |
21 | 29 |
22 bool EncryptionScheme::Pattern::IsInEffect() const { | 30 bool EncryptionScheme::Pattern::IsInEffect() const { |
23 return encrypt_blocks_ != 0 && skip_blocks_ != 0; | 31 return encrypt_blocks_ != 0 && skip_blocks_ != 0; |
24 } | 32 } |
25 | 33 |
26 EncryptionScheme::EncryptionScheme() {} | 34 EncryptionScheme::EncryptionScheme() {} |
27 | 35 |
28 EncryptionScheme::EncryptionScheme(CipherMode mode, const Pattern& pattern) | 36 EncryptionScheme::EncryptionScheme(CipherMode mode, const Pattern& pattern) |
29 : mode_(mode), pattern_(pattern) {} | 37 : mode_(mode), pattern_(pattern) {} |
30 | 38 |
31 EncryptionScheme::~EncryptionScheme() {} | 39 EncryptionScheme::~EncryptionScheme() {} |
32 | 40 |
| 41 bool EncryptionScheme::is_encrypted() const { |
| 42 return mode_ != CIPHER_MODE_UNENCRYPTED; |
| 43 } |
| 44 |
| 45 EncryptionScheme::CipherMode EncryptionScheme::mode() const { |
| 46 return mode_; |
| 47 } |
| 48 |
| 49 const EncryptionScheme::Pattern& EncryptionScheme::pattern() const { |
| 50 return pattern_; |
| 51 } |
| 52 |
33 bool EncryptionScheme::Matches(const EncryptionScheme& other) const { | 53 bool EncryptionScheme::Matches(const EncryptionScheme& other) const { |
34 return mode_ == other.mode_ && pattern_.Matches(other.pattern_); | 54 return mode_ == other.mode_ && pattern_.Matches(other.pattern_); |
35 } | 55 } |
36 | 56 |
37 } // namespace media | 57 } // namespace media |
OLD | NEW |