Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: webkit/media/crypto/ppapi_decryptor.cc

Issue 11189082: Update PluginInstance for audio support for content decryption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "webkit/media/crypto/ppapi_decryptor.h" 5 #include "webkit/media/crypto/ppapi_decryptor.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 18 matching lines...) Expand all
29 cdm_plugin_(plugin_instance), 29 cdm_plugin_(plugin_instance),
30 render_loop_proxy_(base::MessageLoopProxy::current()), 30 render_loop_proxy_(base::MessageLoopProxy::current()),
31 weak_ptr_factory_(this), 31 weak_ptr_factory_(this),
32 weak_this_(weak_ptr_factory_.GetWeakPtr()) { 32 weak_this_(weak_ptr_factory_.GetWeakPtr()) {
33 DCHECK(client_); 33 DCHECK(client_);
34 DCHECK(cdm_plugin_); 34 DCHECK(cdm_plugin_);
35 cdm_plugin_->set_decrypt_client(client); 35 cdm_plugin_->set_decrypt_client(client);
36 } 36 }
37 37
38 PpapiDecryptor::~PpapiDecryptor() { 38 PpapiDecryptor::~PpapiDecryptor() {
39 cdm_plugin_->set_decrypt_client(NULL);
39 } 40 }
40 41
41 bool PpapiDecryptor::GenerateKeyRequest(const std::string& key_system, 42 bool PpapiDecryptor::GenerateKeyRequest(const std::string& key_system,
42 const uint8* init_data, 43 const uint8* init_data,
43 int init_data_length) { 44 int init_data_length) {
44 DVLOG(2) << "GenerateKeyRequest()"; 45 DVLOG(2) << "GenerateKeyRequest()";
45 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 46 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
46 DCHECK(cdm_plugin_); 47 DCHECK(cdm_plugin_);
47 48
48 // TODO(xhwang): Finalize the data type for |init_data| to avoid unnecessary 49 // TODO(xhwang): Finalize the data type for |init_data| to avoid unnecessary
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const scoped_refptr<media::DecoderBuffer>& encrypted, 99 const scoped_refptr<media::DecoderBuffer>& encrypted,
99 const DecryptCB& decrypt_cb) { 100 const DecryptCB& decrypt_cb) {
100 if (!render_loop_proxy_->BelongsToCurrentThread()) { 101 if (!render_loop_proxy_->BelongsToCurrentThread()) {
101 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( 102 render_loop_proxy_->PostTask(FROM_HERE, base::Bind(
102 &PpapiDecryptor::Decrypt, weak_this_, 103 &PpapiDecryptor::Decrypt, weak_this_,
103 stream_type, encrypted, decrypt_cb)); 104 stream_type, encrypted, decrypt_cb));
104 return; 105 return;
105 } 106 }
106 107
107 DVLOG(3) << "Decrypt() - stream_type: " << stream_type; 108 DVLOG(3) << "Decrypt() - stream_type: " << stream_type;
108 if (!cdm_plugin_->Decrypt(encrypted, decrypt_cb)) 109 if (!cdm_plugin_->Decrypt(stream_type, encrypted, decrypt_cb))
109 decrypt_cb.Run(kError, NULL); 110 decrypt_cb.Run(kError, NULL);
110 } 111 }
111 112
112 void PpapiDecryptor::CancelDecrypt(StreamType stream_type) { 113 void PpapiDecryptor::CancelDecrypt(StreamType stream_type) {
113 DVLOG(1) << "CancelDecrypt() - stream_type: " << stream_type; 114 DVLOG(1) << "CancelDecrypt() - stream_type: " << stream_type;
114 // TODO(xhwang): Implement CancelDecrypt() in PluginInstance and call it here. 115 cdm_plugin_->CancelDecrypt(stream_type);
115 } 116 }
116 117
117 void PpapiDecryptor::InitializeAudioDecoder( 118 void PpapiDecryptor::InitializeAudioDecoder(
118 scoped_ptr<media::AudioDecoderConfig> config, 119 scoped_ptr<media::AudioDecoderConfig> config,
119 const DecoderInitCB& init_cb, 120 const DecoderInitCB& init_cb,
120 const KeyAddedCB& key_added_cb) { 121 const KeyAddedCB& key_added_cb) {
121 if (!render_loop_proxy_->BelongsToCurrentThread()) { 122 if (!render_loop_proxy_->BelongsToCurrentThread()) {
122 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( 123 render_loop_proxy_->PostTask(FROM_HERE, base::Bind(
123 &PpapiDecryptor::InitializeAudioDecoder, weak_this_, 124 &PpapiDecryptor::InitializeAudioDecoder, weak_this_,
124 base::Passed(&config), init_cb, key_added_cb)); 125 base::Passed(&config), init_cb, key_added_cb));
125 return; 126 return;
126 } 127 }
127 128
128 DVLOG(2) << "InitializeAudioDecoder()"; 129 DVLOG(2) << "InitializeAudioDecoder()";
129 DCHECK(config->is_encrypted()); 130 DCHECK(config->is_encrypted());
130 DCHECK(config->IsValidConfig()); 131 DCHECK(config->IsValidConfig());
131 132
132 audio_decoder_init_cb_ = init_cb; 133 audio_decoder_init_cb_ = init_cb;
133 // TODO(xhwang): Implement InitializeAudioDecoder() in PluginInstance and call
134 // it here.
135 NOTIMPLEMENTED();
136 #if 0
137 if (!cdm_plugin_->InitializeAudioDecoder(*config, base::Bind( 134 if (!cdm_plugin_->InitializeAudioDecoder(*config, base::Bind(
138 &PpapiDecryptor::OnDecoderInitialized, weak_this_, 135 &PpapiDecryptor::OnDecoderInitialized, weak_this_,
139 kAudio, key_added_cb))) { 136 kAudio, key_added_cb))) {
140 #endif
141 base::ResetAndReturn(&audio_decoder_init_cb_).Run(false); 137 base::ResetAndReturn(&audio_decoder_init_cb_).Run(false);
142 #if 0
143 return; 138 return;
144 } 139 }
145 #endif
146 } 140 }
147 141
148 void PpapiDecryptor::InitializeVideoDecoder( 142 void PpapiDecryptor::InitializeVideoDecoder(
149 scoped_ptr<media::VideoDecoderConfig> config, 143 scoped_ptr<media::VideoDecoderConfig> config,
150 const DecoderInitCB& init_cb, 144 const DecoderInitCB& init_cb,
151 const KeyAddedCB& key_added_cb) { 145 const KeyAddedCB& key_added_cb) {
152 if (!render_loop_proxy_->BelongsToCurrentThread()) { 146 if (!render_loop_proxy_->BelongsToCurrentThread()) {
153 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( 147 render_loop_proxy_->PostTask(FROM_HERE, base::Bind(
154 &PpapiDecryptor::InitializeVideoDecoder, weak_this_, 148 &PpapiDecryptor::InitializeVideoDecoder, weak_this_,
155 base::Passed(&config), init_cb, key_added_cb)); 149 base::Passed(&config), init_cb, key_added_cb));
(...skipping 17 matching lines...) Expand all
173 const scoped_refptr<media::DecoderBuffer>& encrypted, 167 const scoped_refptr<media::DecoderBuffer>& encrypted,
174 const AudioDecodeCB& audio_decode_cb) { 168 const AudioDecodeCB& audio_decode_cb) {
175 if (!render_loop_proxy_->BelongsToCurrentThread()) { 169 if (!render_loop_proxy_->BelongsToCurrentThread()) {
176 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( 170 render_loop_proxy_->PostTask(FROM_HERE, base::Bind(
177 &PpapiDecryptor::DecryptAndDecodeAudio, weak_this_, 171 &PpapiDecryptor::DecryptAndDecodeAudio, weak_this_,
178 encrypted, audio_decode_cb)); 172 encrypted, audio_decode_cb));
179 return; 173 return;
180 } 174 }
181 175
182 DVLOG(1) << "DecryptAndDecodeAudio()"; 176 DVLOG(1) << "DecryptAndDecodeAudio()";
183 NOTIMPLEMENTED();
184 // TODO(xhwang): Enable this once PluginInstance is updated.
185 #if 0
186 if (!cdm_plugin_->DecryptAndDecodeAudio(encrypted, audio_decode_cb)) 177 if (!cdm_plugin_->DecryptAndDecodeAudio(encrypted, audio_decode_cb))
187 #endif
188 audio_decode_cb.Run(kError, AudioBuffers()); 178 audio_decode_cb.Run(kError, AudioBuffers());
189 } 179 }
190 180
191 void PpapiDecryptor::DecryptAndDecodeVideo( 181 void PpapiDecryptor::DecryptAndDecodeVideo(
192 const scoped_refptr<media::DecoderBuffer>& encrypted, 182 const scoped_refptr<media::DecoderBuffer>& encrypted,
193 const VideoDecodeCB& video_decode_cb) { 183 const VideoDecodeCB& video_decode_cb) {
194 if (!render_loop_proxy_->BelongsToCurrentThread()) { 184 if (!render_loop_proxy_->BelongsToCurrentThread()) {
195 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( 185 render_loop_proxy_->PostTask(FROM_HERE, base::Bind(
196 &PpapiDecryptor::DecryptAndDecodeVideo, weak_this_, 186 &PpapiDecryptor::DecryptAndDecodeVideo, weak_this_,
197 encrypted, video_decode_cb)); 187 encrypted, video_decode_cb));
198 return; 188 return;
199 } 189 }
200 190
201 DVLOG(3) << "DecryptAndDecodeVideo()"; 191 DVLOG(3) << "DecryptAndDecodeVideo()";
202 if (!cdm_plugin_->DecryptAndDecode(encrypted, video_decode_cb)) 192 if (!cdm_plugin_->DecryptAndDecodeVideo(encrypted, video_decode_cb))
203 video_decode_cb.Run(kError, NULL); 193 video_decode_cb.Run(kError, NULL);
204 } 194 }
205 195
206 void PpapiDecryptor::ResetDecoder(StreamType stream_type) { 196 void PpapiDecryptor::ResetDecoder(StreamType stream_type) {
207 if (!render_loop_proxy_->BelongsToCurrentThread()) { 197 if (!render_loop_proxy_->BelongsToCurrentThread()) {
208 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( 198 render_loop_proxy_->PostTask(FROM_HERE, base::Bind(
209 &PpapiDecryptor::ResetDecoder, weak_this_, stream_type)); 199 &PpapiDecryptor::ResetDecoder, weak_this_, stream_type));
210 return; 200 return;
211 } 201 }
212 202
213 DVLOG(2) << "ResetDecoder() - stream_type: " << stream_type; 203 DVLOG(2) << "ResetDecoder() - stream_type: " << stream_type;
214 // TODO(xhwang): Support stream type in PluginInstance. 204 cdm_plugin_->ResetDecoder(stream_type);
215 cdm_plugin_->ResetDecoder();
216 } 205 }
217 206
218 void PpapiDecryptor::DeinitializeDecoder(StreamType stream_type) { 207 void PpapiDecryptor::DeinitializeDecoder(StreamType stream_type) {
219 if (!render_loop_proxy_->BelongsToCurrentThread()) { 208 if (!render_loop_proxy_->BelongsToCurrentThread()) {
220 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( 209 render_loop_proxy_->PostTask(FROM_HERE, base::Bind(
221 &PpapiDecryptor::DeinitializeDecoder, weak_this_, stream_type)); 210 &PpapiDecryptor::DeinitializeDecoder, weak_this_, stream_type));
222 return; 211 return;
223 } 212 }
224 DVLOG(2) << "DeinitializeDecoder() - stream_type: " << stream_type; 213 DVLOG(2) << "DeinitializeDecoder() - stream_type: " << stream_type;
225 // TODO(xhwang): Support stream type in PluginInstance. 214 cdm_plugin_->DeinitializeDecoder(stream_type);
226 cdm_plugin_->DeinitializeDecoder();
227 } 215 }
228 216
229 void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system, 217 void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system,
230 const std::string& session_id) { 218 const std::string& session_id) {
231 DVLOG(1) << "Failed to call plugin."; 219 DVLOG(1) << "Failed to call plugin.";
232 client_->KeyError(key_system, session_id, kUnknownError, 0); 220 client_->KeyError(key_system, session_id, kUnknownError, 0);
233 } 221 }
234 222
235 void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type, 223 void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type,
236 const KeyAddedCB& key_added_cb, 224 const KeyAddedCB& key_added_cb,
(...skipping 16 matching lines...) Expand all
253 video_key_added_cb_ = key_added_cb; 241 video_key_added_cb_ = key_added_cb;
254 base::ResetAndReturn(&video_decoder_init_cb_).Run(success); 242 base::ResetAndReturn(&video_decoder_init_cb_).Run(success);
255 break; 243 break;
256 244
257 default: 245 default:
258 NOTREACHED(); 246 NOTREACHED();
259 } 247 }
260 } 248 }
261 249
262 } // namespace webkit_media 250 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/crypto/ppapi/content_decryption_module.h ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698