| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 5 #ifndef MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
| 6 #define MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 6 #define MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "media/base/cdm_context.h" |
| 16 #include "media/base/decryptor.h" | 17 #include "media/base/decryptor.h" |
| 17 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
| 18 #include "media/base/media_keys.h" | 19 #include "media/base/media_keys.h" |
| 19 | 20 |
| 20 namespace crypto { | 21 namespace crypto { |
| 21 class SymmetricKey; | 22 class SymmetricKey; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace media { | 25 namespace media { |
| 25 | 26 |
| 26 // Decrypts an AES encrypted buffer into an unencrypted buffer. The AES | 27 // Decrypts an AES encrypted buffer into an unencrypted buffer. The AES |
| 27 // encryption must be CTR with a key size of 128bits. | 28 // encryption must be CTR with a key size of 128bits. |
| 28 class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor { | 29 class MEDIA_EXPORT AesDecryptor : public MediaKeys, |
| 30 public CdmContext, |
| 31 public Decryptor { |
| 29 public: | 32 public: |
| 30 AesDecryptor(const SessionMessageCB& session_message_cb, | 33 AesDecryptor(const SessionMessageCB& session_message_cb, |
| 31 const SessionClosedCB& session_closed_cb, | 34 const SessionClosedCB& session_closed_cb, |
| 32 const SessionKeysChangeCB& session_keys_change_cb); | 35 const SessionKeysChangeCB& session_keys_change_cb); |
| 33 ~AesDecryptor() override; | 36 ~AesDecryptor() override; |
| 34 | 37 |
| 35 // MediaKeys implementation. | 38 // MediaKeys implementation. |
| 36 void SetServerCertificate(const uint8* certificate_data, | 39 void SetServerCertificate(const uint8* certificate_data, |
| 37 int certificate_data_length, | 40 int certificate_data_length, |
| 38 scoped_ptr<SimpleCdmPromise> promise) override; | 41 scoped_ptr<SimpleCdmPromise> promise) override; |
| 39 void CreateSession(const std::string& init_data_type, | 42 void CreateSession(const std::string& init_data_type, |
| 40 const uint8* init_data, | 43 const uint8* init_data, |
| 41 int init_data_length, | 44 int init_data_length, |
| 42 SessionType session_type, | 45 SessionType session_type, |
| 43 scoped_ptr<NewSessionCdmPromise> promise) override; | 46 scoped_ptr<NewSessionCdmPromise> promise) override; |
| 44 void LoadSession(const std::string& web_session_id, | 47 void LoadSession(const std::string& web_session_id, |
| 45 scoped_ptr<NewSessionCdmPromise> promise) override; | 48 scoped_ptr<NewSessionCdmPromise> promise) override; |
| 46 void UpdateSession(const std::string& web_session_id, | 49 void UpdateSession(const std::string& web_session_id, |
| 47 const uint8* response, | 50 const uint8* response, |
| 48 int response_length, | 51 int response_length, |
| 49 scoped_ptr<SimpleCdmPromise> promise) override; | 52 scoped_ptr<SimpleCdmPromise> promise) override; |
| 50 void CloseSession(const std::string& web_session_id, | 53 void CloseSession(const std::string& web_session_id, |
| 51 scoped_ptr<SimpleCdmPromise> promise) override; | 54 scoped_ptr<SimpleCdmPromise> promise) override; |
| 52 void RemoveSession(const std::string& web_session_id, | 55 void RemoveSession(const std::string& web_session_id, |
| 53 scoped_ptr<SimpleCdmPromise> promise) override; | 56 scoped_ptr<SimpleCdmPromise> promise) override; |
| 54 void GetUsableKeyIds(const std::string& web_session_id, | 57 void GetUsableKeyIds(const std::string& web_session_id, |
| 55 scoped_ptr<KeyIdsPromise> promise) override; | 58 scoped_ptr<KeyIdsPromise> promise) override; |
| 59 CdmContext* GetCdmContext() override; |
| 60 |
| 61 // CdmContext implementation. |
| 56 Decryptor* GetDecryptor() override; | 62 Decryptor* GetDecryptor() override; |
| 57 #if defined(ENABLE_BROWSER_CDMS) | 63 #if defined(ENABLE_BROWSER_CDMS) |
| 58 virtual int GetCdmId() const override; | 64 virtual int GetCdmId() const override; |
| 59 #endif // defined(ENABLE_BROWSER_CDMS) | 65 #endif // defined(ENABLE_BROWSER_CDMS) |
| 60 | 66 |
| 61 // Decryptor implementation. | 67 // Decryptor implementation. |
| 62 void RegisterNewKeyCB(StreamType stream_type, | 68 void RegisterNewKeyCB(StreamType stream_type, |
| 63 const NewKeyCB& key_added_cb) override; | 69 const NewKeyCB& key_added_cb) override; |
| 64 void Decrypt(StreamType stream_type, | 70 void Decrypt(StreamType stream_type, |
| 65 const scoped_refptr<DecoderBuffer>& encrypted, | 71 const scoped_refptr<DecoderBuffer>& encrypted, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the | 153 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the |
| 148 // main thread but called on the media thread. | 154 // main thread but called on the media thread. |
| 149 mutable base::Lock new_key_cb_lock_; | 155 mutable base::Lock new_key_cb_lock_; |
| 150 | 156 |
| 151 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); | 157 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); |
| 152 }; | 158 }; |
| 153 | 159 |
| 154 } // namespace media | 160 } // namespace media |
| 155 | 161 |
| 156 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 162 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
| OLD | NEW |