| 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 // DecoderSelector only chooses |this| when the stream is encrypted. |
| 63 // TODO(xhwang): We may also select this decoder for clear stream if a CDM |
| 64 // is attached. Then we need to update this. See http://crbug.com/597443 |
| 65 DCHECK(config.is_encrypted()); |
| 63 DCHECK(cdm_context); | 66 DCHECK(cdm_context); |
| 64 if (!cdm_context->GetDecryptor()) { | 67 if (!cdm_context->GetDecryptor()) { |
| 65 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; | 68 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; |
| 66 base::ResetAndReturn(&init_cb_).Run(false); | 69 base::ResetAndReturn(&init_cb_).Run(false); |
| 67 return; | 70 return; |
| 68 } | 71 } |
| 69 | 72 |
| 70 decryptor_ = cdm_context->GetDecryptor(); | 73 decryptor_ = cdm_context->GetDecryptor(); |
| 71 } else { | 74 } else { |
| 72 // Reinitialization. | 75 // Reinitialization (i.e. upon a config change). The new config can be |
| 76 // encrypted or clear. |
| 73 decryptor_->DeinitializeDecoder(Decryptor::kVideo); | 77 decryptor_->DeinitializeDecoder(Decryptor::kVideo); |
| 74 } | 78 } |
| 75 | 79 |
| 76 state_ = kPendingDecoderInit; | 80 state_ = kPendingDecoderInit; |
| 77 decryptor_->InitializeVideoDecoder( | 81 decryptor_->InitializeVideoDecoder( |
| 78 config_, BindToCurrentLoop(base::Bind( | 82 config_, BindToCurrentLoop(base::Bind( |
| 79 &DecryptingVideoDecoder::FinishInitialization, weak_this_))); | 83 &DecryptingVideoDecoder::FinishInitialization, weak_this_))); |
| 80 } | 84 } |
| 81 | 85 |
| 82 void DecryptingVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 86 void DecryptingVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 313 } |
| 310 | 314 |
| 311 void DecryptingVideoDecoder::DoReset() { | 315 void DecryptingVideoDecoder::DoReset() { |
| 312 DCHECK(init_cb_.is_null()); | 316 DCHECK(init_cb_.is_null()); |
| 313 DCHECK(decode_cb_.is_null()); | 317 DCHECK(decode_cb_.is_null()); |
| 314 state_ = kIdle; | 318 state_ = kIdle; |
| 315 base::ResetAndReturn(&reset_cb_).Run(); | 319 base::ResetAndReturn(&reset_cb_).Run(); |
| 316 } | 320 } |
| 317 | 321 |
| 318 } // namespace media | 322 } // namespace media |
| OLD | NEW |