Chromium Code Reviews| 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 #include "media/filters/decrypting_video_decoder.h" | 5 #include "media/filters/decrypting_video_decoder.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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 const OutputCB& output_cb) { | 45 const OutputCB& output_cb) { |
| 46 DVLOG(2) << __func__ << ": " << config.AsHumanReadableString(); | 46 DVLOG(2) << __func__ << ": " << config.AsHumanReadableString(); |
| 47 | 47 |
| 48 DCHECK(task_runner_->BelongsToCurrentThread()); | 48 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 49 DCHECK(state_ == kUninitialized || | 49 DCHECK(state_ == kUninitialized || |
| 50 state_ == kIdle || | 50 state_ == kIdle || |
| 51 state_ == kDecodeFinished) << state_; | 51 state_ == kDecodeFinished) << state_; |
| 52 DCHECK(decode_cb_.is_null()); | 52 DCHECK(decode_cb_.is_null()); |
| 53 DCHECK(reset_cb_.is_null()); | 53 DCHECK(reset_cb_.is_null()); |
| 54 DCHECK(config.IsValidConfig()); | 54 DCHECK(config.IsValidConfig()); |
| 55 DCHECK(config.is_encrypted()); | |
| 56 | 55 |
| 57 init_cb_ = BindToCurrentLoop(init_cb); | 56 init_cb_ = BindToCurrentLoop(init_cb); |
| 58 output_cb_ = BindToCurrentLoop(output_cb); | 57 output_cb_ = BindToCurrentLoop(output_cb); |
| 59 weak_this_ = weak_factory_.GetWeakPtr(); | 58 weak_this_ = weak_factory_.GetWeakPtr(); |
| 60 config_ = config; | 59 config_ = config; |
| 61 | 60 |
| 62 if (state_ == kUninitialized) { | 61 if (state_ == kUninitialized) { |
| 62 DCHECK(config.is_encrypted()); | |
|
ddorwin
2016/12/05 23:53:04
Comment/TODO
| |
| 63 DCHECK(cdm_context); | 63 DCHECK(cdm_context); |
| 64 if (!cdm_context->GetDecryptor()) { | 64 if (!cdm_context->GetDecryptor()) { |
| 65 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; | 65 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; |
| 66 base::ResetAndReturn(&init_cb_).Run(false); | 66 base::ResetAndReturn(&init_cb_).Run(false); |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 | 69 |
| 70 decryptor_ = cdm_context->GetDecryptor(); | 70 decryptor_ = cdm_context->GetDecryptor(); |
| 71 } else { | 71 } else { |
| 72 // Reinitialization. | 72 // Reinitialization. |config| can be encrypted or clear. |
|
ddorwin
2016/12/05 23:53:04
Note that this is a separate thought. (Context: Ea
xhwang
2016/12/16 20:12:28
Done.
| |
| 73 decryptor_->DeinitializeDecoder(Decryptor::kVideo); | 73 decryptor_->DeinitializeDecoder(Decryptor::kVideo); |
| 74 } | 74 } |
| 75 | 75 |
| 76 state_ = kPendingDecoderInit; | 76 state_ = kPendingDecoderInit; |
| 77 decryptor_->InitializeVideoDecoder( | 77 decryptor_->InitializeVideoDecoder( |
| 78 config_, BindToCurrentLoop(base::Bind( | 78 config_, BindToCurrentLoop(base::Bind( |
| 79 &DecryptingVideoDecoder::FinishInitialization, weak_this_))); | 79 &DecryptingVideoDecoder::FinishInitialization, weak_this_))); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void DecryptingVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 82 void DecryptingVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 } | 309 } |
| 310 | 310 |
| 311 void DecryptingVideoDecoder::DoReset() { | 311 void DecryptingVideoDecoder::DoReset() { |
| 312 DCHECK(init_cb_.is_null()); | 312 DCHECK(init_cb_.is_null()); |
| 313 DCHECK(decode_cb_.is_null()); | 313 DCHECK(decode_cb_.is_null()); |
| 314 state_ = kIdle; | 314 state_ = kIdle; |
| 315 base::ResetAndReturn(&reset_cb_).Run(); | 315 base::ResetAndReturn(&reset_cb_).Run(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace media | 318 } // namespace media |
| OLD | NEW |