| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor { | 28 class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor { |
| 29 public: | 29 public: |
| 30 AesDecryptor(const SessionCreatedCB& session_created_cb, | 30 AesDecryptor(const SessionCreatedCB& session_created_cb, |
| 31 const SessionMessageCB& session_message_cb, | 31 const SessionMessageCB& session_message_cb, |
| 32 const SessionReadyCB& session_ready_cb, | 32 const SessionReadyCB& session_ready_cb, |
| 33 const SessionClosedCB& session_closed_cb, | 33 const SessionClosedCB& session_closed_cb, |
| 34 const SessionErrorCB& session_error_cb); | 34 const SessionErrorCB& session_error_cb); |
| 35 virtual ~AesDecryptor(); | 35 virtual ~AesDecryptor(); |
| 36 | 36 |
| 37 // MediaKeys implementation. | 37 // MediaKeys implementation. |
| 38 virtual bool CreateSession(uint32 reference_id, | 38 virtual bool CreateSession(uint32 session_id, |
| 39 const std::string& type, | 39 const std::string& type, |
| 40 const uint8* init_data, | 40 const uint8* init_data, |
| 41 int init_data_length) OVERRIDE; | 41 int init_data_length) OVERRIDE; |
| 42 virtual void UpdateSession(uint32 reference_id, | 42 virtual void UpdateSession(uint32 session_id, |
| 43 const uint8* response, | 43 const uint8* response, |
| 44 int response_length) OVERRIDE; | 44 int response_length) OVERRIDE; |
| 45 virtual void ReleaseSession(uint32 reference_id) OVERRIDE; | 45 virtual void ReleaseSession(uint32 session_id) OVERRIDE; |
| 46 virtual Decryptor* GetDecryptor() OVERRIDE; | 46 virtual Decryptor* GetDecryptor() OVERRIDE; |
| 47 | 47 |
| 48 // Decryptor implementation. | 48 // Decryptor implementation. |
| 49 virtual void RegisterNewKeyCB(StreamType stream_type, | 49 virtual void RegisterNewKeyCB(StreamType stream_type, |
| 50 const NewKeyCB& key_added_cb) OVERRIDE; | 50 const NewKeyCB& key_added_cb) OVERRIDE; |
| 51 virtual void Decrypt(StreamType stream_type, | 51 virtual void Decrypt(StreamType stream_type, |
| 52 const scoped_refptr<DecoderBuffer>& encrypted, | 52 const scoped_refptr<DecoderBuffer>& encrypted, |
| 53 const DecryptCB& decrypt_cb) OVERRIDE; | 53 const DecryptCB& decrypt_cb) OVERRIDE; |
| 54 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; | 54 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; |
| 55 virtual void InitializeAudioDecoder(const AudioDecoderConfig& config, | 55 virtual void InitializeAudioDecoder(const AudioDecoderConfig& config, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // KeyMap owns the DecryptionKey* and must delete them when they are | 108 // KeyMap owns the DecryptionKey* and must delete them when they are |
| 109 // not needed any more. | 109 // not needed any more. |
| 110 typedef base::hash_map<std::string, DecryptionKey*> KeyMap; | 110 typedef base::hash_map<std::string, DecryptionKey*> KeyMap; |
| 111 | 111 |
| 112 // Since only Decrypt() is called off the renderer thread, we only need to | 112 // Since only Decrypt() is called off the renderer thread, we only need to |
| 113 // protect |key_map_|, the only member variable that is shared between | 113 // protect |key_map_|, the only member variable that is shared between |
| 114 // Decrypt() and other methods. | 114 // Decrypt() and other methods. |
| 115 KeyMap key_map_; // Protected by the |key_map_lock_|. | 115 KeyMap key_map_; // Protected by the |key_map_lock_|. |
| 116 mutable base::Lock key_map_lock_; // Protects the |key_map_|. | 116 mutable base::Lock key_map_lock_; // Protects the |key_map_|. |
| 117 | 117 |
| 118 // Make session ID unique per renderer by making it static. | 118 // Make web session ID unique per renderer by making it static. Web session |
| 119 // TODO(xhwang): Make session ID more strictly defined if needed: | 119 // IDs seen by the app will be "1", "2", etc. |
| 120 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16739#c0 | 120 static uint32 next_web_session_id_; |
| 121 static uint32 next_session_id_; | |
| 122 | 121 |
| 123 NewKeyCB new_audio_key_cb_; | 122 NewKeyCB new_audio_key_cb_; |
| 124 NewKeyCB new_video_key_cb_; | 123 NewKeyCB new_video_key_cb_; |
| 125 | 124 |
| 126 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); | 125 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); |
| 127 }; | 126 }; |
| 128 | 127 |
| 129 } // namespace media | 128 } // namespace media |
| 130 | 129 |
| 131 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 130 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
| OLD | NEW |