OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROMECAST_MEDIA_BASE_DECRYPT_CONTEXT_IMPL_H_ | 5 #ifndef CHROMECAST_MEDIA_BASE_DECRYPT_CONTEXT_IMPL_H_ |
6 #define CHROMECAST_MEDIA_BASE_DECRYPT_CONTEXT_IMPL_H_ | 6 #define CHROMECAST_MEDIA_BASE_DECRYPT_CONTEXT_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "chromecast/media/base/key_systems_common.h" | 12 #include "chromecast/media/base/key_systems_common.h" |
13 #include "chromecast/public/media/decrypt_context.h" | 13 #include "chromecast/public/media/decrypt_context.h" |
14 | 14 |
15 namespace chromecast { | 15 namespace chromecast { |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 // Base class of a decryption context: a decryption context gathers all the | 18 // Base class of a decryption context: a decryption context gathers all the |
19 // information needed to decrypt frames with a given key id. | 19 // information needed to decrypt frames with a given key id. |
20 // Each CDM should implement this and add fields needed to fully describe a | 20 // Each CDM should implement this and add fields needed to fully describe a |
21 // decryption context. | 21 // decryption context. |
22 // | |
23 class DecryptContextImpl : public DecryptContext { | 22 class DecryptContextImpl : public DecryptContext { |
24 public: | 23 public: |
25 explicit DecryptContextImpl(CastKeySystem key_system); | 24 explicit DecryptContextImpl(CastKeySystem key_system); |
26 ~DecryptContextImpl() override; | 25 ~DecryptContextImpl() override; |
27 | 26 |
28 // DecryptContext implementation: | 27 // DecryptContext implementation: |
29 CastKeySystem GetKeySystem() override; | 28 CastKeySystem GetKeySystem() override; |
30 bool Decrypt(CastDecoderBuffer* buffer, uint8_t* output) override; | 29 bool Decrypt(CastDecoderBuffer* buffer, |
| 30 std::vector<uint8_t>* output) final; |
| 31 |
| 32 // TODO(yucliu): replace DecryptContext::Decrypt with this one in next |
| 33 // public api releasing. |
| 34 // Decrypts the given buffer. Returns true/false for success/failure, |
| 35 // and places the decrypted data in |output| if successful. |
| 36 // Decrypted data in |output| has the same length as |buffer|. |
| 37 virtual bool Decrypt(CastDecoderBuffer* buffer, uint8_t* output) = 0; |
31 | 38 |
32 // Returns whether the data can be decrypted into user memory. | 39 // Returns whether the data can be decrypted into user memory. |
33 // If the key system doesn't support secure output or the app explicitly | 40 // If the key system doesn't support secure output or the app explicitly |
34 // requires non secure output, it should return true; | 41 // requires non secure output, it should return true; |
35 // If the key system doesn't allow clear content to be decrypted into user | 42 // If the key system doesn't allow clear content to be decrypted into user |
36 // memory, it should return false. | 43 // memory, it should return false. |
37 virtual bool CanDecryptToBuffer() const; | 44 virtual bool CanDecryptToBuffer() const; |
38 | 45 |
39 private: | 46 private: |
40 CastKeySystem key_system_; | 47 CastKeySystem key_system_; |
41 | 48 |
42 DISALLOW_COPY_AND_ASSIGN(DecryptContextImpl); | 49 DISALLOW_COPY_AND_ASSIGN(DecryptContextImpl); |
43 }; | 50 }; |
44 | 51 |
45 } // namespace media | 52 } // namespace media |
46 } // namespace chromecast | 53 } // namespace chromecast |
47 | 54 |
48 #endif // CHROMECAST_MEDIA_BASE_DECRYPT_CONTEXT_IMPL_H_ | 55 #endif // CHROMECAST_MEDIA_BASE_DECRYPT_CONTEXT_IMPL_H_ |
OLD | NEW |