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