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 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/containers/scoped_ptr_hash_map.h" | 13 #include "base/containers/scoped_ptr_hash_map.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
16 #include "media/base/cdm_context.h" | 17 #include "media/base/cdm_context.h" |
17 #include "media/base/decryptor.h" | 18 #include "media/base/decryptor.h" |
18 #include "media/base/media_export.h" | 19 #include "media/base/media_export.h" |
19 #include "media/base/media_keys.h" | 20 #include "media/base/media_keys.h" |
(...skipping 12 matching lines...) Expand all Loading... |
32 public CdmContext, | 33 public CdmContext, |
33 public Decryptor { | 34 public Decryptor { |
34 public: | 35 public: |
35 AesDecryptor(const GURL& security_origin, | 36 AesDecryptor(const GURL& security_origin, |
36 const SessionMessageCB& session_message_cb, | 37 const SessionMessageCB& session_message_cb, |
37 const SessionClosedCB& session_closed_cb, | 38 const SessionClosedCB& session_closed_cb, |
38 const SessionKeysChangeCB& session_keys_change_cb); | 39 const SessionKeysChangeCB& session_keys_change_cb); |
39 ~AesDecryptor() override; | 40 ~AesDecryptor() override; |
40 | 41 |
41 // MediaKeys implementation. | 42 // MediaKeys implementation. |
42 void SetServerCertificate(const uint8* certificate_data, | 43 void SetServerCertificate(const std::vector<uint8_t>& certificate, |
43 int certificate_data_length, | |
44 scoped_ptr<SimpleCdmPromise> promise) override; | 44 scoped_ptr<SimpleCdmPromise> promise) override; |
45 void CreateSessionAndGenerateRequest( | 45 void CreateSessionAndGenerateRequest( |
46 SessionType session_type, | 46 SessionType session_type, |
47 EmeInitDataType init_data_type, | 47 EmeInitDataType init_data_type, |
48 const uint8* init_data, | 48 const std::vector<uint8_t>& init_data, |
49 int init_data_length, | |
50 scoped_ptr<NewSessionCdmPromise> promise) override; | 49 scoped_ptr<NewSessionCdmPromise> promise) override; |
51 void LoadSession(SessionType session_type, | 50 void LoadSession(SessionType session_type, |
52 const std::string& session_id, | 51 const std::string& session_id, |
53 scoped_ptr<NewSessionCdmPromise> promise) override; | 52 scoped_ptr<NewSessionCdmPromise> promise) override; |
54 void UpdateSession(const std::string& session_id, | 53 void UpdateSession(const std::string& session_id, |
55 const uint8* response, | 54 const std::vector<uint8_t>& response, |
56 int response_length, | |
57 scoped_ptr<SimpleCdmPromise> promise) override; | 55 scoped_ptr<SimpleCdmPromise> promise) override; |
58 void CloseSession(const std::string& session_id, | 56 void CloseSession(const std::string& session_id, |
59 scoped_ptr<SimpleCdmPromise> promise) override; | 57 scoped_ptr<SimpleCdmPromise> promise) override; |
60 void RemoveSession(const std::string& session_id, | 58 void RemoveSession(const std::string& session_id, |
61 scoped_ptr<SimpleCdmPromise> promise) override; | 59 scoped_ptr<SimpleCdmPromise> promise) override; |
62 CdmContext* GetCdmContext() override; | 60 CdmContext* GetCdmContext() override; |
63 | 61 |
64 // CdmContext implementation. | 62 // CdmContext implementation. |
65 Decryptor* GetDecryptor() override; | 63 Decryptor* GetDecryptor() override; |
66 int GetCdmId() const override; | 64 int GetCdmId() const override; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // protect |key_map_|, the only member variable that is shared between | 140 // protect |key_map_|, the only member variable that is shared between |
143 // Decrypt() and other methods. | 141 // Decrypt() and other methods. |
144 KeyIdToSessionKeysMap key_map_; // Protected by |key_map_lock_|. | 142 KeyIdToSessionKeysMap key_map_; // Protected by |key_map_lock_|. |
145 mutable base::Lock key_map_lock_; // Protects the |key_map_|. | 143 mutable base::Lock key_map_lock_; // Protects the |key_map_|. |
146 | 144 |
147 // Keeps track of current valid sessions. | 145 // Keeps track of current valid sessions. |
148 std::set<std::string> valid_sessions_; | 146 std::set<std::string> valid_sessions_; |
149 | 147 |
150 // Make session ID unique per renderer by making it static. Session | 148 // Make session ID unique per renderer by making it static. Session |
151 // IDs seen by the app will be "1", "2", etc. | 149 // IDs seen by the app will be "1", "2", etc. |
152 static uint32 next_session_id_; | 150 static uint32_t next_session_id_; |
153 | 151 |
154 NewKeyCB new_audio_key_cb_; | 152 NewKeyCB new_audio_key_cb_; |
155 NewKeyCB new_video_key_cb_; | 153 NewKeyCB new_video_key_cb_; |
156 | 154 |
157 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the | 155 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the |
158 // main thread but called on the media thread. | 156 // main thread but called on the media thread. |
159 mutable base::Lock new_key_cb_lock_; | 157 mutable base::Lock new_key_cb_lock_; |
160 | 158 |
161 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); | 159 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); |
162 }; | 160 }; |
163 | 161 |
164 } // namespace media | 162 } // namespace media |
165 | 163 |
166 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 164 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
OLD | NEW |