Chromium Code Reviews| 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 "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "media/base/decryptor.h" | 12 #include "media/base/decryptor.h" |
| 13 #include "media/base/video_decoder_config.h" | 13 #include "media/base/video_decoder_config.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class MessageLoopProxy; | 16 class MessageLoopProxy; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace media { | |
| 20 class DecryptorClient; | |
| 21 } | |
| 22 | |
| 23 namespace webkit { | 19 namespace webkit { |
| 24 namespace ppapi { | 20 namespace ppapi { |
| 25 class ContentDecryptorDelegate; | 21 class ContentDecryptorDelegate; |
| 26 class PluginInstance; | 22 class PluginInstance; |
| 27 } | 23 } |
| 28 } | 24 } |
| 29 | 25 |
| 30 namespace webkit_media { | 26 namespace webkit_media { |
| 31 | 27 |
| 32 // PpapiDecryptor implements media::Decryptor and forwards all calls to the | 28 // PpapiDecryptor implements media::Decryptor and forwards all calls to the |
| 33 // PluginInstance. | 29 // PluginInstance. |
| 34 // This class should always be created & destroyed on the main renderer thread. | 30 // This class should always be created & destroyed on the main renderer thread. |
| 35 class PpapiDecryptor : public media::Decryptor { | 31 class PpapiDecryptor : public media::Decryptor { |
| 36 public: | 32 public: |
| 37 PpapiDecryptor( | 33 PpapiDecryptor( |
| 38 media::DecryptorClient* client, | 34 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, |
| 39 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance); | 35 const media::KeyAddedCB& key_added_cb, |
| 36 const media::KeyErrorCB& key_error_cb, | |
| 37 const media::KeyMessageCB& key_message_cb, | |
| 38 const media::NeedKeyCB& need_key_cb); | |
| 40 virtual ~PpapiDecryptor(); | 39 virtual ~PpapiDecryptor(); |
| 41 | 40 |
| 42 // media::Decryptor implementation. | 41 // media::Decryptor implementation. |
| 43 virtual bool GenerateKeyRequest(const std::string& key_system, | 42 virtual bool GenerateKeyRequest(const std::string& key_system, |
| 44 const std::string& type, | 43 const std::string& type, |
| 45 const uint8* init_data, | 44 const uint8* init_data, |
| 46 int init_data_length) OVERRIDE; | 45 int init_data_length) OVERRIDE; |
| 47 virtual void AddKey(const std::string& key_system, | 46 virtual void AddKey(const std::string& key_system, |
| 48 const uint8* key, | 47 const uint8* key, |
| 49 int key_length, | 48 int key_length, |
| 50 const uint8* init_data, | 49 const uint8* init_data, |
| 51 int init_data_length, | 50 int init_data_length, |
| 52 const std::string& session_id) OVERRIDE; | 51 const std::string& session_id) OVERRIDE; |
| 53 virtual void CancelKeyRequest(const std::string& key_system, | 52 virtual void CancelKeyRequest(const std::string& key_system, |
| 54 const std::string& session_id) OVERRIDE; | 53 const std::string& session_id) OVERRIDE; |
| 55 virtual void RegisterKeyAddedCB(StreamType stream_type, | 54 virtual void RegisterNewKeyCB(StreamType stream_type, |
| 56 const KeyAddedCB& key_added_cb) OVERRIDE; | 55 const NewKeyCB& key_added_cb) OVERRIDE; |
| 57 virtual void Decrypt(StreamType stream_type, | 56 virtual void Decrypt(StreamType stream_type, |
| 58 const scoped_refptr<media::DecoderBuffer>& encrypted, | 57 const scoped_refptr<media::DecoderBuffer>& encrypted, |
| 59 const DecryptCB& decrypt_cb) OVERRIDE; | 58 const DecryptCB& decrypt_cb) OVERRIDE; |
| 60 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; | 59 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; |
| 61 virtual void InitializeAudioDecoder( | 60 virtual void InitializeAudioDecoder( |
| 62 scoped_ptr<media::AudioDecoderConfig> config, | 61 scoped_ptr<media::AudioDecoderConfig> config, |
| 63 const DecoderInitCB& init_cb) OVERRIDE; | 62 const DecoderInitCB& init_cb) OVERRIDE; |
| 64 virtual void InitializeVideoDecoder( | 63 virtual void InitializeVideoDecoder( |
| 65 scoped_ptr<media::VideoDecoderConfig> config, | 64 scoped_ptr<media::VideoDecoderConfig> config, |
| 66 const DecoderInitCB& init_cb) OVERRIDE; | 65 const DecoderInitCB& init_cb) OVERRIDE; |
| 67 virtual void DecryptAndDecodeAudio( | 66 virtual void DecryptAndDecodeAudio( |
| 68 const scoped_refptr<media::DecoderBuffer>& encrypted, | 67 const scoped_refptr<media::DecoderBuffer>& encrypted, |
| 69 const AudioDecodeCB& audio_decode_cb) OVERRIDE; | 68 const AudioDecodeCB& audio_decode_cb) OVERRIDE; |
| 70 virtual void DecryptAndDecodeVideo( | 69 virtual void DecryptAndDecodeVideo( |
| 71 const scoped_refptr<media::DecoderBuffer>& encrypted, | 70 const scoped_refptr<media::DecoderBuffer>& encrypted, |
| 72 const VideoDecodeCB& video_decode_cb) OVERRIDE; | 71 const VideoDecodeCB& video_decode_cb) OVERRIDE; |
| 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 void ReportFailureToCallPlugin(const std::string& key_system, | 76 void ReportFailureToCallPlugin(const std::string& key_system, |
| 78 const std::string& session_id); | 77 const std::string& session_id); |
| 79 | 78 |
| 80 void OnDecoderInitialized(StreamType stream_type, bool success); | 79 void OnDecoderInitialized(StreamType stream_type, bool success); |
| 81 | 80 |
| 82 media::DecryptorClient* client_; | 81 // Callbacks for firing key events. |
|
ddorwin
2012/12/21 04:19:06
Should we mention who calls these?
xhwang
2012/12/21 05:50:07
Done.
| |
| 82 void KeyAdded(const std::string& key_system, const std::string& session_id); | |
| 83 void KeyError(const std::string& key_system, | |
| 84 const std::string& session_id, | |
| 85 media::Decryptor::KeyError error_code, | |
| 86 int system_code); | |
| 87 void KeyMessage(const std::string& key_system, | |
| 88 const std::string& session_id, | |
| 89 const std::string& message, | |
| 90 const std::string& default_url); | |
| 91 void NeedKey(const std::string& key_system, | |
| 92 const std::string& session_id, | |
| 93 const std::string& type, | |
| 94 scoped_array<uint8> init_data, int init_data_size); | |
| 83 | 95 |
| 84 // Hold a reference of the plugin instance to make sure the plugin outlives | 96 // Hold a reference of the plugin instance to make sure the plugin outlives |
| 85 // the |plugin_cdm_delegate_|. This is needed because |plugin_cdm_delegate_| | 97 // the |plugin_cdm_delegate_|. This is needed because |plugin_cdm_delegate_| |
| 86 // is owned by the |plugin_instance_|. | 98 // is owned by the |plugin_instance_|. |
| 87 scoped_refptr<webkit::ppapi::PluginInstance> plugin_instance_; | 99 scoped_refptr<webkit::ppapi::PluginInstance> plugin_instance_; |
| 88 | 100 |
| 101 // Callbacks for firing key events. | |
| 102 media::KeyAddedCB key_added_cb_; | |
| 103 media::KeyErrorCB key_error_cb_; | |
| 104 media::KeyMessageCB key_message_cb_; | |
| 105 media::NeedKeyCB need_key_cb_; | |
| 106 | |
| 89 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate_; | 107 webkit::ppapi::ContentDecryptorDelegate* plugin_cdm_delegate_; |
| 90 | 108 |
| 91 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; | 109 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; |
| 92 | 110 |
| 93 DecoderInitCB audio_decoder_init_cb_; | 111 DecoderInitCB audio_decoder_init_cb_; |
| 94 DecoderInitCB video_decoder_init_cb_; | 112 DecoderInitCB video_decoder_init_cb_; |
| 95 KeyAddedCB audio_key_added_cb_; | 113 NewKeyCB new_audio_key_cb_; |
| 96 KeyAddedCB video_key_added_cb_; | 114 NewKeyCB new_video_key_cb_; |
| 97 | 115 |
| 98 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; | 116 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; |
| 99 base::WeakPtr<PpapiDecryptor> weak_this_; | 117 base::WeakPtr<PpapiDecryptor> weak_this_; |
| 100 | 118 |
| 101 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); | 119 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); |
| 102 }; | 120 }; |
| 103 | 121 |
| 104 } // namespace webkit_media | 122 } // namespace webkit_media |
| 105 | 123 |
| 106 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 124 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
| OLD | NEW |