| 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 WEBKIT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 5 #ifndef WEBKIT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| 6 #define WEBKIT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 6 #define WEBKIT_RENDERER_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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // This class should always be created & destroyed on the main renderer thread. | 31 // This class should always be created & destroyed on the main renderer thread. |
| 32 class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { | 32 class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { |
| 33 public: | 33 public: |
| 34 static scoped_ptr<webkit_media::PpapiDecryptor> Create( | 34 static scoped_ptr<webkit_media::PpapiDecryptor> Create( |
| 35 // TODO(ddorwin): Remove after updating the delegate. | 35 // TODO(ddorwin): Remove after updating the delegate. |
| 36 const std::string& key_system, | 36 const std::string& key_system, |
| 37 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, | 37 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, |
| 38 const media::KeyAddedCB& key_added_cb, | 38 const media::KeyAddedCB& key_added_cb, |
| 39 const media::KeyErrorCB& key_error_cb, | 39 const media::KeyErrorCB& key_error_cb, |
| 40 const media::KeyMessageCB& key_message_cb, | 40 const media::KeyMessageCB& key_message_cb, |
| 41 const media::NeedKeyCB& need_key_cb, | |
| 42 const base::Closure& destroy_plugin_cb); | 41 const base::Closure& destroy_plugin_cb); |
| 43 | 42 |
| 44 virtual ~PpapiDecryptor(); | 43 virtual ~PpapiDecryptor(); |
| 45 | 44 |
| 46 // media::MediaKeys implementation. | 45 // media::MediaKeys implementation. |
| 47 virtual bool GenerateKeyRequest(const std::string& type, | 46 virtual bool GenerateKeyRequest(const std::string& type, |
| 48 const uint8* init_data, | 47 const uint8* init_data, |
| 49 int init_data_length) OVERRIDE; | 48 int init_data_length) OVERRIDE; |
| 50 virtual void AddKey(const uint8* key, int key_length, | 49 virtual void AddKey(const uint8* key, int key_length, |
| 51 const uint8* init_data, int init_data_length, | 50 const uint8* init_data, int init_data_length, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 73 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; | 72 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; |
| 74 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; | 73 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; |
| 75 | 74 |
| 76 private: | 75 private: |
| 77 PpapiDecryptor( | 76 PpapiDecryptor( |
| 78 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, | 77 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, |
| 79 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate, | 78 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate, |
| 80 const media::KeyAddedCB& key_added_cb, | 79 const media::KeyAddedCB& key_added_cb, |
| 81 const media::KeyErrorCB& key_error_cb, | 80 const media::KeyErrorCB& key_error_cb, |
| 82 const media::KeyMessageCB& key_message_cb, | 81 const media::KeyMessageCB& key_message_cb, |
| 83 const media::NeedKeyCB& need_key_cb, | |
| 84 const base::Closure& destroy_plugin_cb); | 82 const base::Closure& destroy_plugin_cb); |
| 85 | 83 |
| 86 void ReportFailureToCallPlugin(const std::string& session_id); | 84 void ReportFailureToCallPlugin(const std::string& session_id); |
| 87 | 85 |
| 88 void OnDecoderInitialized(StreamType stream_type, bool success); | 86 void OnDecoderInitialized(StreamType stream_type, bool success); |
| 89 | 87 |
| 90 // Callbacks for |plugin_cdm_delegate_| to fire key events. | 88 // Callbacks for |plugin_cdm_delegate_| to fire key events. |
| 91 void KeyAdded(const std::string& session_id); | 89 void KeyAdded(const std::string& session_id); |
| 92 void KeyError(const std::string& session_id, | 90 void KeyError(const std::string& session_id, |
| 93 media::MediaKeys::KeyError error_code, | 91 media::MediaKeys::KeyError error_code, |
| 94 int system_code); | 92 int system_code); |
| 95 void KeyMessage(const std::string& session_id, | 93 void KeyMessage(const std::string& session_id, |
| 96 const std::string& message, | 94 const std::string& message, |
| 97 const std::string& default_url); | 95 const std::string& default_url); |
| 98 void NeedKey(const std::string& session_id, | |
| 99 const std::string& type, | |
| 100 scoped_ptr<uint8[]> init_data, int init_data_size); | |
| 101 | 96 |
| 102 // Hold a reference of the plugin instance to make sure the plugin outlives | 97 // Hold a reference of the plugin instance to make sure the plugin outlives |
| 103 // the |plugin_cdm_delegate_|. This is needed because |plugin_cdm_delegate_| | 98 // the |plugin_cdm_delegate_|. This is needed because |plugin_cdm_delegate_| |
| 104 // is owned by the |plugin_instance_|. | 99 // is owned by the |plugin_instance_|. |
| 105 scoped_refptr<webkit::ppapi::PluginInstance> plugin_instance_; | 100 scoped_refptr<webkit::ppapi::PluginInstance> plugin_instance_; |
| 106 | 101 |
| 107 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate_; | 102 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate_; |
| 108 | 103 |
| 109 // Callbacks for firing key events. | 104 // Callbacks for firing key events. |
| 110 media::KeyAddedCB key_added_cb_; | 105 media::KeyAddedCB key_added_cb_; |
| 111 media::KeyErrorCB key_error_cb_; | 106 media::KeyErrorCB key_error_cb_; |
| 112 media::KeyMessageCB key_message_cb_; | 107 media::KeyMessageCB key_message_cb_; |
| 113 media::NeedKeyCB need_key_cb_; | |
| 114 | 108 |
| 115 // Called to destroy the helper plugin when this class no longer needs it. | 109 // Called to destroy the helper plugin when this class no longer needs it. |
| 116 base::Closure destroy_plugin_cb_; | 110 base::Closure destroy_plugin_cb_; |
| 117 | 111 |
| 118 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; | 112 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; |
| 119 | 113 |
| 120 DecoderInitCB audio_decoder_init_cb_; | 114 DecoderInitCB audio_decoder_init_cb_; |
| 121 DecoderInitCB video_decoder_init_cb_; | 115 DecoderInitCB video_decoder_init_cb_; |
| 122 NewKeyCB new_audio_key_cb_; | 116 NewKeyCB new_audio_key_cb_; |
| 123 NewKeyCB new_video_key_cb_; | 117 NewKeyCB new_video_key_cb_; |
| 124 | 118 |
| 125 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; | 119 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; |
| 126 base::WeakPtr<PpapiDecryptor> weak_this_; | 120 base::WeakPtr<PpapiDecryptor> weak_this_; |
| 127 | 121 |
| 128 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); | 122 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); |
| 129 }; | 123 }; |
| 130 | 124 |
| 131 } // namespace webkit_media | 125 } // namespace webkit_media |
| 132 | 126 |
| 133 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 127 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| OLD | NEW |