| 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 #include "content/renderer/media/cdm/ppapi_decryptor.h" | 5 #include "content/renderer/media/cdm/ppapi_decryptor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 const scoped_refptr<media::DecoderBuffer>& encrypted, | 241 const scoped_refptr<media::DecoderBuffer>& encrypted, |
| 242 const DecryptCB& decrypt_cb) { | 242 const DecryptCB& decrypt_cb) { |
| 243 if (!render_task_runner_->BelongsToCurrentThread()) { | 243 if (!render_task_runner_->BelongsToCurrentThread()) { |
| 244 render_task_runner_->PostTask( | 244 render_task_runner_->PostTask( |
| 245 FROM_HERE, | 245 FROM_HERE, |
| 246 base::Bind(&PpapiDecryptor::Decrypt, weak_ptr_factory_.GetWeakPtr(), | 246 base::Bind(&PpapiDecryptor::Decrypt, weak_ptr_factory_.GetWeakPtr(), |
| 247 stream_type, encrypted, decrypt_cb)); | 247 stream_type, encrypted, decrypt_cb)); |
| 248 return; | 248 return; |
| 249 } | 249 } |
| 250 | 250 |
| 251 // TODO(xhwang): If the buffer is not encrypted, return it directly. |
| 252 |
| 251 DVLOG(3) << __func__ << " - stream_type: " << stream_type; | 253 DVLOG(3) << __func__ << " - stream_type: " << stream_type; |
| 252 if (!CdmDelegate() || | 254 if (!CdmDelegate() || |
| 253 !CdmDelegate()->Decrypt(stream_type, encrypted, decrypt_cb)) { | 255 !CdmDelegate()->Decrypt(stream_type, encrypted, decrypt_cb)) { |
| 254 decrypt_cb.Run(kError, NULL); | 256 decrypt_cb.Run(kError, NULL); |
| 255 } | 257 } |
| 256 } | 258 } |
| 257 | 259 |
| 258 void PpapiDecryptor::CancelDecrypt(StreamType stream_type) { | 260 void PpapiDecryptor::CancelDecrypt(StreamType stream_type) { |
| 259 if (!render_task_runner_->BelongsToCurrentThread()) { | 261 if (!render_task_runner_->BelongsToCurrentThread()) { |
| 260 render_task_runner_->PostTask( | 262 render_task_runner_->PostTask( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 272 const media::AudioDecoderConfig& config, | 274 const media::AudioDecoderConfig& config, |
| 273 const DecoderInitCB& init_cb) { | 275 const DecoderInitCB& init_cb) { |
| 274 if (!render_task_runner_->BelongsToCurrentThread()) { | 276 if (!render_task_runner_->BelongsToCurrentThread()) { |
| 275 render_task_runner_->PostTask( | 277 render_task_runner_->PostTask( |
| 276 FROM_HERE, base::Bind(&PpapiDecryptor::InitializeAudioDecoder, | 278 FROM_HERE, base::Bind(&PpapiDecryptor::InitializeAudioDecoder, |
| 277 weak_ptr_factory_.GetWeakPtr(), config, init_cb)); | 279 weak_ptr_factory_.GetWeakPtr(), config, init_cb)); |
| 278 return; | 280 return; |
| 279 } | 281 } |
| 280 | 282 |
| 281 DVLOG(2) << __func__; | 283 DVLOG(2) << __func__; |
| 282 DCHECK(config.is_encrypted()); | |
| 283 DCHECK(config.IsValidConfig()); | 284 DCHECK(config.IsValidConfig()); |
| 284 | 285 |
| 285 audio_decoder_init_cb_ = init_cb; | 286 audio_decoder_init_cb_ = init_cb; |
| 286 if (!CdmDelegate() || | 287 if (!CdmDelegate() || |
| 287 !CdmDelegate()->InitializeAudioDecoder( | 288 !CdmDelegate()->InitializeAudioDecoder( |
| 288 config, base::Bind(&PpapiDecryptor::OnDecoderInitialized, | 289 config, base::Bind(&PpapiDecryptor::OnDecoderInitialized, |
| 289 weak_ptr_factory_.GetWeakPtr(), kAudio))) { | 290 weak_ptr_factory_.GetWeakPtr(), kAudio))) { |
| 290 base::ResetAndReturn(&audio_decoder_init_cb_).Run(false); | 291 base::ResetAndReturn(&audio_decoder_init_cb_).Run(false); |
| 291 return; | 292 return; |
| 292 } | 293 } |
| 293 } | 294 } |
| 294 | 295 |
| 295 void PpapiDecryptor::InitializeVideoDecoder( | 296 void PpapiDecryptor::InitializeVideoDecoder( |
| 296 const media::VideoDecoderConfig& config, | 297 const media::VideoDecoderConfig& config, |
| 297 const DecoderInitCB& init_cb) { | 298 const DecoderInitCB& init_cb) { |
| 298 if (!render_task_runner_->BelongsToCurrentThread()) { | 299 if (!render_task_runner_->BelongsToCurrentThread()) { |
| 299 render_task_runner_->PostTask( | 300 render_task_runner_->PostTask( |
| 300 FROM_HERE, base::Bind(&PpapiDecryptor::InitializeVideoDecoder, | 301 FROM_HERE, base::Bind(&PpapiDecryptor::InitializeVideoDecoder, |
| 301 weak_ptr_factory_.GetWeakPtr(), config, init_cb)); | 302 weak_ptr_factory_.GetWeakPtr(), config, init_cb)); |
| 302 return; | 303 return; |
| 303 } | 304 } |
| 304 | 305 |
| 305 DVLOG(2) << __func__; | 306 DVLOG(2) << __func__; |
| 306 DCHECK(config.is_encrypted()); | |
| 307 DCHECK(config.IsValidConfig()); | 307 DCHECK(config.IsValidConfig()); |
| 308 | 308 |
| 309 video_decoder_init_cb_ = init_cb; | 309 video_decoder_init_cb_ = init_cb; |
| 310 if (!CdmDelegate() || | 310 if (!CdmDelegate() || |
| 311 !CdmDelegate()->InitializeVideoDecoder( | 311 !CdmDelegate()->InitializeVideoDecoder( |
| 312 config, base::Bind(&PpapiDecryptor::OnDecoderInitialized, | 312 config, base::Bind(&PpapiDecryptor::OnDecoderInitialized, |
| 313 weak_ptr_factory_.GetWeakPtr(), kVideo))) { | 313 weak_ptr_factory_.GetWeakPtr(), kVideo))) { |
| 314 base::ResetAndReturn(&video_decoder_init_cb_).Run(false); | 314 base::ResetAndReturn(&video_decoder_init_cb_).Run(false); |
| 315 return; | 315 return; |
| 316 } | 316 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 base::AutoLock auto_lock(lock_); | 444 base::AutoLock auto_lock(lock_); |
| 445 had_fatal_plugin_error_ = true; | 445 had_fatal_plugin_error_ = true; |
| 446 } | 446 } |
| 447 | 447 |
| 448 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { | 448 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { |
| 449 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 449 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 450 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; | 450 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; |
| 451 } | 451 } |
| 452 | 452 |
| 453 } // namespace content | 453 } // namespace content |
| OLD | NEW |