| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "media/base/decryptor.h" | 11 #include "media/base/decryptor.h" |
| 12 | 12 |
| 13 namespace base { |
| 14 class MessageLoopProxy; |
| 15 } |
| 16 |
| 13 namespace media { | 17 namespace media { |
| 14 class DecryptorClient; | 18 class DecryptorClient; |
| 15 } | 19 } |
| 16 | 20 |
| 17 namespace webkit { | 21 namespace webkit { |
| 18 namespace ppapi { | 22 namespace ppapi { |
| 19 class PluginInstance; | 23 class PluginInstance; |
| 20 } | 24 } |
| 21 } | 25 } |
| 22 | 26 |
| 23 namespace webkit_media { | 27 namespace webkit_media { |
| 24 | 28 |
| 29 // PpapiDecrypor implements media::Decryptor and forwards all calls to the |
| 30 // PluginInstance. |
| 31 // This class should always be created on the main renderer thread. |
| 25 class PpapiDecryptor : public media::Decryptor { | 32 class PpapiDecryptor : public media::Decryptor { |
| 26 public: | 33 public: |
| 27 PpapiDecryptor( | 34 PpapiDecryptor( |
| 28 media::DecryptorClient* client, | 35 media::DecryptorClient* client, |
| 29 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance); | 36 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance); |
| 30 virtual ~PpapiDecryptor(); | 37 virtual ~PpapiDecryptor(); |
| 31 | 38 |
| 32 // media::Decryptor implementation. | 39 // media::Decryptor implementation. |
| 33 virtual void GenerateKeyRequest(const std::string& key_system, | 40 virtual void GenerateKeyRequest(const std::string& key_system, |
| 34 const uint8* init_data, | 41 const uint8* init_data, |
| 35 int init_data_length) OVERRIDE; | 42 int init_data_length) OVERRIDE; |
| 36 virtual void AddKey(const std::string& key_system, | 43 virtual void AddKey(const std::string& key_system, |
| 37 const uint8* key, | 44 const uint8* key, |
| 38 int key_length, | 45 int key_length, |
| 39 const uint8* init_data, | 46 const uint8* init_data, |
| 40 int init_data_length, | 47 int init_data_length, |
| 41 const std::string& session_id) OVERRIDE; | 48 const std::string& session_id) OVERRIDE; |
| 42 virtual void CancelKeyRequest(const std::string& key_system, | 49 virtual void CancelKeyRequest(const std::string& key_system, |
| 43 const std::string& session_id) OVERRIDE; | 50 const std::string& session_id) OVERRIDE; |
| 44 virtual void Decrypt(const scoped_refptr<media::DecoderBuffer>& encrypted, | 51 virtual void Decrypt(const scoped_refptr<media::DecoderBuffer>& encrypted, |
| 45 const DecryptCB& decrypt_cb) OVERRIDE; | 52 const DecryptCB& decrypt_cb) OVERRIDE; |
| 46 virtual void Stop() OVERRIDE; | 53 virtual void Stop() OVERRIDE; |
| 47 | 54 |
| 48 private: | 55 private: |
| 49 // Callback for the plugin to hand back the decrypted data. | 56 void ReportFailureToCallPlugin(const std::string& key_system, |
| 50 void DataReady(const DecryptCB& decrypt_cb, const uint8* data, int data_size); | 57 const std::string& session_id); |
| 51 | 58 |
| 52 // TODO(xhwang): Need to figure out how the CDM plugin fires key events | |
| 53 // (e.g. KeyMessage). | |
| 54 media::DecryptorClient* client_; | 59 media::DecryptorClient* client_; |
| 55 scoped_refptr<webkit::ppapi::PluginInstance> cdm_plugin_; | 60 scoped_refptr<webkit::ppapi::PluginInstance> cdm_plugin_; |
| 61 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; |
| 56 | 62 |
| 57 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); | 63 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); |
| 58 }; | 64 }; |
| 59 | 65 |
| 60 } // namespace webkit_media | 66 } // namespace webkit_media |
| 61 | 67 |
| 62 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 68 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| OLD | NEW |