| 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 CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "media/base/decryptor.h" | 14 #include "media/base/decryptor.h" |
| 15 #include "media/base/media_keys.h" | 15 #include "media/base/media_keys.h" |
| 16 #include "media/base/video_decoder_config.h" | 16 #include "media/base/video_decoder_config.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class MessageLoopProxy; | 19 class MessageLoopProxy; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace webkit { | 22 namespace webkit { |
| 23 namespace ppapi { | 23 namespace ppapi { |
| 24 class ContentDecryptorDelegate; | 24 class ContentDecryptorDelegate; |
| 25 class PluginInstance; | 25 class PluginInstanceImpl; |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 | 30 |
| 31 // PpapiDecryptor implements media::Decryptor and forwards all calls to the | 31 // PpapiDecryptor implements media::Decryptor and forwards all calls to the |
| 32 // PluginInstance. | 32 // PluginInstance. |
| 33 // This class should always be created & destroyed on the main renderer thread. | 33 // This class should always be created & destroyed on the main renderer thread. |
| 34 class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { | 34 class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { |
| 35 public: | 35 public: |
| 36 static scoped_ptr<PpapiDecryptor> Create( | 36 static scoped_ptr<PpapiDecryptor> Create( |
| 37 // TODO(ddorwin): Remove after updating the delegate. | 37 // TODO(ddorwin): Remove after updating the delegate. |
| 38 const std::string& key_system, | 38 const std::string& key_system, |
| 39 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, | 39 const scoped_refptr<webkit::ppapi::PluginInstanceImpl>& plugin_instance, |
| 40 const media::KeyAddedCB& key_added_cb, | 40 const media::KeyAddedCB& key_added_cb, |
| 41 const media::KeyErrorCB& key_error_cb, | 41 const media::KeyErrorCB& key_error_cb, |
| 42 const media::KeyMessageCB& key_message_cb, | 42 const media::KeyMessageCB& key_message_cb, |
| 43 const base::Closure& destroy_plugin_cb); | 43 const base::Closure& destroy_plugin_cb); |
| 44 | 44 |
| 45 virtual ~PpapiDecryptor(); | 45 virtual ~PpapiDecryptor(); |
| 46 | 46 |
| 47 // media::MediaKeys implementation. | 47 // media::MediaKeys implementation. |
| 48 virtual bool GenerateKeyRequest(const std::string& type, | 48 virtual bool GenerateKeyRequest(const std::string& type, |
| 49 const uint8* init_data, | 49 const uint8* init_data, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 const scoped_refptr<media::DecoderBuffer>& encrypted, | 69 const scoped_refptr<media::DecoderBuffer>& encrypted, |
| 70 const AudioDecodeCB& audio_decode_cb) OVERRIDE; | 70 const AudioDecodeCB& audio_decode_cb) OVERRIDE; |
| 71 virtual void DecryptAndDecodeVideo( | 71 virtual void DecryptAndDecodeVideo( |
| 72 const scoped_refptr<media::DecoderBuffer>& encrypted, | 72 const scoped_refptr<media::DecoderBuffer>& encrypted, |
| 73 const VideoDecodeCB& video_decode_cb) OVERRIDE; | 73 const VideoDecodeCB& video_decode_cb) OVERRIDE; |
| 74 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; | 74 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; |
| 75 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; | 75 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 PpapiDecryptor( | 78 PpapiDecryptor( |
| 79 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, | 79 const scoped_refptr<webkit::ppapi::PluginInstanceImpl>& plugin_instance, |
| 80 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate, | 80 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate, |
| 81 const media::KeyAddedCB& key_added_cb, | 81 const media::KeyAddedCB& key_added_cb, |
| 82 const media::KeyErrorCB& key_error_cb, | 82 const media::KeyErrorCB& key_error_cb, |
| 83 const media::KeyMessageCB& key_message_cb, | 83 const media::KeyMessageCB& key_message_cb, |
| 84 const base::Closure& destroy_plugin_cb); | 84 const base::Closure& destroy_plugin_cb); |
| 85 | 85 |
| 86 void ReportFailureToCallPlugin(const std::string& session_id); | 86 void ReportFailureToCallPlugin(const std::string& session_id); |
| 87 | 87 |
| 88 void OnDecoderInitialized(StreamType stream_type, bool success); | 88 void OnDecoderInitialized(StreamType stream_type, bool success); |
| 89 | 89 |
| 90 // Callbacks for |plugin_cdm_delegate_| to fire key events. | 90 // Callbacks for |plugin_cdm_delegate_| to fire key events. |
| 91 void KeyAdded(const std::string& session_id); | 91 void KeyAdded(const std::string& session_id); |
| 92 void KeyError(const std::string& session_id, | 92 void KeyError(const std::string& session_id, |
| 93 media::MediaKeys::KeyError error_code, | 93 media::MediaKeys::KeyError error_code, |
| 94 int system_code); | 94 int system_code); |
| 95 void KeyMessage(const std::string& session_id, | 95 void KeyMessage(const std::string& session_id, |
| 96 const std::vector<uint8>& message, | 96 const std::vector<uint8>& message, |
| 97 const std::string& default_url); | 97 const std::string& default_url); |
| 98 | 98 |
| 99 // Hold a reference of the plugin instance to make sure the plugin outlives | 99 // Hold a reference of the plugin instance to make sure the plugin outlives |
| 100 // the |plugin_cdm_delegate_|. This is needed because |plugin_cdm_delegate_| | 100 // the |plugin_cdm_delegate_|. This is needed because |plugin_cdm_delegate_| |
| 101 // is owned by the |plugin_instance_|. | 101 // is owned by the |plugin_instance_|. |
| 102 scoped_refptr<webkit::ppapi::PluginInstance> plugin_instance_; | 102 scoped_refptr<webkit::ppapi::PluginInstanceImpl> plugin_instance_; |
| 103 | 103 |
| 104 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate_; | 104 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate_; |
| 105 | 105 |
| 106 // Callbacks for firing key events. | 106 // Callbacks for firing key events. |
| 107 media::KeyAddedCB key_added_cb_; | 107 media::KeyAddedCB key_added_cb_; |
| 108 media::KeyErrorCB key_error_cb_; | 108 media::KeyErrorCB key_error_cb_; |
| 109 media::KeyMessageCB key_message_cb_; | 109 media::KeyMessageCB key_message_cb_; |
| 110 | 110 |
| 111 // Called to destroy the helper plugin when this class no longer needs it. | 111 // Called to destroy the helper plugin when this class no longer needs it. |
| 112 base::Closure destroy_plugin_cb_; | 112 base::Closure destroy_plugin_cb_; |
| 113 | 113 |
| 114 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; | 114 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; |
| 115 | 115 |
| 116 DecoderInitCB audio_decoder_init_cb_; | 116 DecoderInitCB audio_decoder_init_cb_; |
| 117 DecoderInitCB video_decoder_init_cb_; | 117 DecoderInitCB video_decoder_init_cb_; |
| 118 NewKeyCB new_audio_key_cb_; | 118 NewKeyCB new_audio_key_cb_; |
| 119 NewKeyCB new_video_key_cb_; | 119 NewKeyCB new_video_key_cb_; |
| 120 | 120 |
| 121 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; | 121 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; |
| 122 base::WeakPtr<PpapiDecryptor> weak_this_; | 122 base::WeakPtr<PpapiDecryptor> weak_this_; |
| 123 | 123 |
| 124 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); | 124 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace content | 127 } // namespace content |
| 128 | 128 |
| 129 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 129 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| OLD | NEW |