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

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

Issue 11144036: Update Decryptor interface to support audio decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove leftover unretained Created 8 years, 2 months 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
« no previous file with comments | « webkit/media/crypto/proxy_decryptor.h ('k') | webkit/media/crypto/proxy_decryptor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/proxy_decryptor.h" 5 #include "webkit/media/crypto/proxy_decryptor.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "media/base/audio_decoder_config.h"
12 #include "media/base/decoder_buffer.h" 13 #include "media/base/decoder_buffer.h"
13 #include "media/base/decryptor_client.h" 14 #include "media/base/decryptor_client.h"
14 #include "media/base/video_decoder_config.h" 15 #include "media/base/video_decoder_config.h"
15 #include "media/base/video_frame.h" 16 #include "media/base/video_frame.h"
16 #include "media/crypto/aes_decryptor.h" 17 #include "media/crypto/aes_decryptor.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
19 #include "webkit/media/crypto/key_systems.h" 20 #include "webkit/media/crypto/key_systems.h"
20 #include "webkit/media/crypto/ppapi_decryptor.h" 21 #include "webkit/media/crypto/ppapi_decryptor.h"
21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 146
146 void ProxyDecryptor::CancelKeyRequest(const std::string& key_system, 147 void ProxyDecryptor::CancelKeyRequest(const std::string& key_system,
147 const std::string& session_id) { 148 const std::string& session_id) {
148 DVLOG(1) << "CancelKeyRequest()"; 149 DVLOG(1) << "CancelKeyRequest()";
149 150
150 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. 151 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called.
151 decryptor_->CancelKeyRequest(key_system, session_id); 152 decryptor_->CancelKeyRequest(key_system, session_id);
152 } 153 }
153 154
154 void ProxyDecryptor::Decrypt( 155 void ProxyDecryptor::Decrypt(
156 StreamType stream_type,
155 const scoped_refptr<media::DecoderBuffer>& encrypted, 157 const scoped_refptr<media::DecoderBuffer>& encrypted,
156 const DecryptCB& decrypt_cb) { 158 const DecryptCB& decrypt_cb) {
157 DVLOG(2) << "Decrypt()"; 159 DVLOG(2) << "Decrypt()";
158 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); 160 DCHECK(decryption_message_loop_->BelongsToCurrentThread());
161 DCHECK_EQ(stream_type, kVideo); // Only support video decrypt-only for now.
159 162
160 DCHECK(!is_canceling_decrypt_); 163 DCHECK(!is_canceling_decrypt_);
161 DCHECK(!pending_buffer_to_decrypt_); 164 DCHECK(!pending_buffer_to_decrypt_);
162 DCHECK(pending_decrypt_cb_.is_null()); 165 DCHECK(pending_decrypt_cb_.is_null());
163 166
164 pending_buffer_to_decrypt_ = encrypted; 167 pending_buffer_to_decrypt_ = encrypted;
165 pending_decrypt_cb_ = decrypt_cb; 168 pending_decrypt_cb_ = decrypt_cb;
166 169
167 // This is safe as we do not replace/delete an existing decryptor at run-time. 170 // This is safe as we do not replace/delete an existing decryptor at run-time.
168 media::Decryptor* decryptor = NULL; 171 media::Decryptor* decryptor = NULL;
169 { 172 {
170 base::AutoLock auto_lock(lock_); 173 base::AutoLock auto_lock(lock_);
171 decryptor = decryptor_.get(); 174 decryptor = decryptor_.get();
172 } 175 }
173 if (!decryptor) { 176 if (!decryptor) {
174 DVLOG(1) << "Decrypt(): decryptor not initialized."; 177 DVLOG(1) << "Decrypt(): decryptor not initialized.";
175 178
176 // TODO(xhwang): The same NeedKey may be fired here and multiple times in 179 // TODO(xhwang): The same NeedKey may be fired here and multiple times in
177 // OnBufferDecrypted(). While the spec says only one NeedKey should be 180 // OnBufferDecrypted(). While the spec says only one NeedKey should be
178 // fired. Leave them as is since the spec about this may change. 181 // fired. Leave them as is since the spec about this may change.
179 FireNeedKey(client_, encrypted); 182 FireNeedKey(client_, encrypted);
180 return; 183 return;
181 } 184 }
182 185
183 DecryptPendingBuffer(); 186 DecryptPendingBuffer();
184 } 187 }
185 188
186 void ProxyDecryptor::CancelDecrypt() { 189 void ProxyDecryptor::CancelDecrypt(StreamType stream_type) {
187 DVLOG(1) << "CancelDecrypt()"; 190 DVLOG(1) << "CancelDecrypt()";
188 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); 191 DCHECK(decryption_message_loop_->BelongsToCurrentThread());
192 DCHECK_EQ(stream_type, kVideo); // Only support video decrypt-only for now.
189 193
190 if (!pending_buffer_to_decrypt_) { 194 if (!pending_buffer_to_decrypt_) {
191 DCHECK(pending_decrypt_cb_.is_null()); 195 DCHECK(pending_decrypt_cb_.is_null());
192 DCHECK(!is_waiting_for_decryptor_); 196 DCHECK(!is_waiting_for_decryptor_);
193 return; 197 return;
194 } 198 }
195 199
196 DecryptCB decrypt_cb; 200 DecryptCB decrypt_cb;
197 if (!is_waiting_for_decryptor_) { 201 if (!is_waiting_for_decryptor_) {
198 pending_buffer_to_decrypt_ = NULL; 202 pending_buffer_to_decrypt_ = NULL;
199 base::ResetAndReturn(&pending_decrypt_cb_).Run(kSuccess, NULL); 203 base::ResetAndReturn(&pending_decrypt_cb_).Run(kSuccess, NULL);
200 return; 204 return;
201 } 205 }
202 206
203 is_canceling_decrypt_ = true; 207 is_canceling_decrypt_ = true;
204 decryptor_->CancelDecrypt(); 208 decryptor_->CancelDecrypt(stream_type);
209 }
210
211 void ProxyDecryptor::InitializeAudioDecoder(
212 scoped_ptr<media::AudioDecoderConfig> config,
213 const DecoderInitCB& init_cb,
214 const KeyAddedCB& key_added_cb) {
215 NOTREACHED() << "ProxyDecryptor does not support audio decoding";
205 } 216 }
206 217
207 void ProxyDecryptor::InitializeVideoDecoder( 218 void ProxyDecryptor::InitializeVideoDecoder(
208 scoped_ptr<media::VideoDecoderConfig> config, 219 scoped_ptr<media::VideoDecoderConfig> config,
209 const DecoderInitCB& init_cb, 220 const DecoderInitCB& init_cb,
210 const KeyAddedCB& key_added_cb) { 221 const KeyAddedCB& key_added_cb) {
211 NOTREACHED() << "ProxyDecryptor does not support video decoding"; 222 NOTREACHED() << "ProxyDecryptor does not support video decoding";
212 } 223 }
213 224
225 void ProxyDecryptor::DecryptAndDecodeAudio(
226 const scoped_refptr<media::DecoderBuffer>& encrypted,
227 const AudioDecodeCB& audio_decode_cb) {
228 NOTREACHED() << "ProxyDecryptor does not support audio decoding";
229 }
230
214 void ProxyDecryptor::DecryptAndDecodeVideo( 231 void ProxyDecryptor::DecryptAndDecodeVideo(
215 const scoped_refptr<media::DecoderBuffer>& encrypted, 232 const scoped_refptr<media::DecoderBuffer>& encrypted,
216 const VideoDecodeCB& video_decode_cb) { 233 const VideoDecodeCB& video_decode_cb) {
217 NOTREACHED() << "ProxyDecryptor does not support video decoding"; 234 NOTREACHED() << "ProxyDecryptor does not support video decoding";
218 } 235 }
219 236
220 void ProxyDecryptor::CancelDecryptAndDecodeVideo() { 237 void ProxyDecryptor::ResetDecoder(StreamType stream_type) {
221 NOTREACHED() << "ProxyDecryptor does not support video decoding"; 238 NOTREACHED() << "ProxyDecryptor does not support audio/video decoding";
222 } 239 }
223 240
224 void ProxyDecryptor::StopVideoDecoder() { 241 void ProxyDecryptor::DeinitializeDecoder(StreamType stream_type) {
225 NOTREACHED() << "ProxyDecryptor does not support video decoding"; 242 NOTREACHED() << "ProxyDecryptor does not support audio/video decoding";
226 } 243 }
227 244
228 scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor( 245 scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor(
229 const std::string& key_system) { 246 const std::string& key_system) {
230 DCHECK(client_); 247 DCHECK(client_);
231 DCHECK(web_media_player_client_); 248 DCHECK(web_media_player_client_);
232 DCHECK(web_frame_); 249 DCHECK(web_frame_);
233 250
234 std::string plugin_type = GetPluginType(key_system); 251 std::string plugin_type = GetPluginType(key_system);
235 DCHECK(!plugin_type.empty()); 252 DCHECK(!plugin_type.empty());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 300 }
284 301
285 void ProxyDecryptor::DecryptPendingBuffer() { 302 void ProxyDecryptor::DecryptPendingBuffer() {
286 DVLOG(3) << "DecryptPendingBuffer()"; 303 DVLOG(3) << "DecryptPendingBuffer()";
287 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); 304 DCHECK(decryption_message_loop_->BelongsToCurrentThread());
288 DCHECK(pending_buffer_to_decrypt_); 305 DCHECK(pending_buffer_to_decrypt_);
289 DCHECK(!is_waiting_for_decryptor_); 306 DCHECK(!is_waiting_for_decryptor_);
290 307
291 is_waiting_for_decryptor_ = true; 308 is_waiting_for_decryptor_ = true;
292 decryptor_->Decrypt( 309 decryptor_->Decrypt(
310 kVideo, // Only support video decrypt-only for now.
293 pending_buffer_to_decrypt_, 311 pending_buffer_to_decrypt_,
294 base::Bind(&ProxyDecryptor::OnBufferDecrypted, base::Unretained(this))); 312 base::Bind(&ProxyDecryptor::OnBufferDecrypted, base::Unretained(this)));
295 } 313 }
296 314
297 void ProxyDecryptor::OnBufferDecrypted( 315 void ProxyDecryptor::OnBufferDecrypted(
298 media::Decryptor::Status status, 316 media::Decryptor::Status status,
299 const scoped_refptr<media::DecoderBuffer>& decrypted) { 317 const scoped_refptr<media::DecoderBuffer>& decrypted) {
300 if (!decryption_message_loop_->BelongsToCurrentThread()) { 318 if (!decryption_message_loop_->BelongsToCurrentThread()) {
301 decryption_message_loop_->PostTask(FROM_HERE, base::Bind( 319 decryption_message_loop_->PostTask(FROM_HERE, base::Bind(
302 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), 320 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 return; 352 return;
335 } 353 }
336 354
337 // TODO(xhwang): The same NeedKey may be fired multiple times here and also 355 // TODO(xhwang): The same NeedKey may be fired multiple times here and also
338 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave 356 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave
339 // them as is since the spec about this may change. 357 // them as is since the spec about this may change.
340 FireNeedKey(client_, pending_buffer_to_decrypt_); 358 FireNeedKey(client_, pending_buffer_to_decrypt_);
341 } 359 }
342 360
343 } // namespace webkit_media 361 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/crypto/proxy_decryptor.h ('k') | webkit/media/crypto/proxy_decryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698