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_CDM_AES_DECRYPTOR_H_ | 5 #ifndef MEDIA_CDM_AES_DECRYPTOR_H_ |
6 #define MEDIA_CDM_AES_DECRYPTOR_H_ | 6 #define MEDIA_CDM_AES_DECRYPTOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
| 13 #include <unordered_map> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/containers/scoped_ptr_hash_map.h" | |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "media/base/cdm_context.h" | 19 #include "media/base/cdm_context.h" |
20 #include "media/base/content_decryption_module.h" | 20 #include "media/base/content_decryption_module.h" |
21 #include "media/base/decryptor.h" | 21 #include "media/base/decryptor.h" |
22 #include "media/base/media_export.h" | 22 #include "media/base/media_export.h" |
23 | 23 |
24 class GURL; | 24 class GURL; |
25 | 25 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 DISALLOW_COPY_AND_ASSIGN(DecryptionKey); | 106 DISALLOW_COPY_AND_ASSIGN(DecryptionKey); |
107 }; | 107 }; |
108 | 108 |
109 // Keep track of the keys for a key ID. If multiple sessions specify keys | 109 // Keep track of the keys for a key ID. If multiple sessions specify keys |
110 // for the same key ID, then the last key inserted is used. The structure is | 110 // for the same key ID, then the last key inserted is used. The structure is |
111 // optimized so that Decrypt() has fast access, at the cost of slow deletion | 111 // optimized so that Decrypt() has fast access, at the cost of slow deletion |
112 // of keys when a session is released. | 112 // of keys when a session is released. |
113 class SessionIdDecryptionKeyMap; | 113 class SessionIdDecryptionKeyMap; |
114 | 114 |
115 // Key ID <-> SessionIdDecryptionKeyMap map. | 115 // Key ID <-> SessionIdDecryptionKeyMap map. |
116 typedef base::ScopedPtrHashMap<std::string, | 116 using KeyIdToSessionKeysMap = |
117 std::unique_ptr<SessionIdDecryptionKeyMap>> | 117 std::unordered_map<std::string, |
118 KeyIdToSessionKeysMap; | 118 std::unique_ptr<SessionIdDecryptionKeyMap>>; |
119 | 119 |
120 ~AesDecryptor() override; | 120 ~AesDecryptor() override; |
121 | 121 |
122 // Creates a DecryptionKey using |key_string| and associates it with |key_id|. | 122 // Creates a DecryptionKey using |key_string| and associates it with |key_id|. |
123 // Returns true if successful. | 123 // Returns true if successful. |
124 bool AddDecryptionKey(const std::string& session_id, | 124 bool AddDecryptionKey(const std::string& session_id, |
125 const std::string& key_id, | 125 const std::string& key_id, |
126 const std::string& key_string); | 126 const std::string& key_string); |
127 | 127 |
128 // Gets a DecryptionKey associated with |key_id|. The AesDecryptor still owns | 128 // Gets a DecryptionKey associated with |key_id|. The AesDecryptor still owns |
(...skipping 30 matching lines...) Expand all Loading... |
159 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the | 159 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the |
160 // main thread but called on the media thread. | 160 // main thread but called on the media thread. |
161 mutable base::Lock new_key_cb_lock_; | 161 mutable base::Lock new_key_cb_lock_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); | 163 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); |
164 }; | 164 }; |
165 | 165 |
166 } // namespace media | 166 } // namespace media |
167 | 167 |
168 #endif // MEDIA_CDM_AES_DECRYPTOR_H_ | 168 #endif // MEDIA_CDM_AES_DECRYPTOR_H_ |
OLD | NEW |