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