| 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 18 matching lines...) Expand all Loading... |
| 29 set_decryptor_ready_cb_(set_decryptor_ready_cb), | 29 set_decryptor_ready_cb_(set_decryptor_ready_cb), |
| 30 decryptor_(NULL), | 30 decryptor_(NULL), |
| 31 key_added_while_decode_pending_(false), | 31 key_added_while_decode_pending_(false), |
| 32 trace_id_(0), | 32 trace_id_(0), |
| 33 weak_factory_(this) {} | 33 weak_factory_(this) {} |
| 34 | 34 |
| 35 std::string DecryptingVideoDecoder::GetDisplayName() const { | 35 std::string DecryptingVideoDecoder::GetDisplayName() const { |
| 36 return kDecoderName; | 36 return kDecoderName; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config, | 39 void DecryptingVideoDecoder::Initialize( |
| 40 bool /* low_delay */, | 40 const VideoDecoderConfig& config, |
| 41 const PipelineStatusCB& status_cb, | 41 bool /* low_delay */, |
| 42 const OutputCB& output_cb) { | 42 const PipelineStatusCB& status_cb, |
| 43 const OutputCB& output_cb, |
| 44 const base::Closure& waiting_for_encryption_key_cb) { |
| 43 DVLOG(2) << "Initialize()"; | 45 DVLOG(2) << "Initialize()"; |
| 44 DCHECK(task_runner_->BelongsToCurrentThread()); | 46 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 45 DCHECK(state_ == kUninitialized || | 47 DCHECK(state_ == kUninitialized || |
| 46 state_ == kIdle || | 48 state_ == kIdle || |
| 47 state_ == kDecodeFinished) << state_; | 49 state_ == kDecodeFinished) << state_; |
| 48 DCHECK(decode_cb_.is_null()); | 50 DCHECK(decode_cb_.is_null()); |
| 49 DCHECK(reset_cb_.is_null()); | 51 DCHECK(reset_cb_.is_null()); |
| 50 DCHECK(config.IsValidConfig()); | 52 DCHECK(config.IsValidConfig()); |
| 51 DCHECK(config.is_encrypted()); | 53 DCHECK(config.is_encrypted()); |
| 52 | 54 |
| 53 init_cb_ = BindToCurrentLoop(status_cb); | 55 init_cb_ = BindToCurrentLoop(status_cb); |
| 54 output_cb_ = BindToCurrentLoop(output_cb); | 56 output_cb_ = BindToCurrentLoop(output_cb); |
| 57 waiting_for_encryption_key_cb_ = waiting_for_encryption_key_cb; |
| 55 weak_this_ = weak_factory_.GetWeakPtr(); | 58 weak_this_ = weak_factory_.GetWeakPtr(); |
| 56 config_ = config; | 59 config_ = config; |
| 57 | 60 |
| 58 if (state_ == kUninitialized) { | 61 if (state_ == kUninitialized) { |
| 59 state_ = kDecryptorRequested; | 62 state_ = kDecryptorRequested; |
| 60 set_decryptor_ready_cb_.Run(BindToCurrentLoop(base::Bind( | 63 set_decryptor_ready_cb_.Run(BindToCurrentLoop(base::Bind( |
| 61 &DecryptingVideoDecoder::SetDecryptor, weak_this_))); | 64 &DecryptingVideoDecoder::SetDecryptor, weak_this_))); |
| 62 return; | 65 return; |
| 63 } | 66 } |
| 64 | 67 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // pending buffer again when new key is added to the decryptor. | 266 // pending buffer again when new key is added to the decryptor. |
| 264 pending_buffer_to_decode_ = scoped_pending_buffer_to_decode; | 267 pending_buffer_to_decode_ = scoped_pending_buffer_to_decode; |
| 265 | 268 |
| 266 if (need_to_try_again_if_nokey_is_returned) { | 269 if (need_to_try_again_if_nokey_is_returned) { |
| 267 // The |state_| is still kPendingDecode. | 270 // The |state_| is still kPendingDecode. |
| 268 DecodePendingBuffer(); | 271 DecodePendingBuffer(); |
| 269 return; | 272 return; |
| 270 } | 273 } |
| 271 | 274 |
| 272 state_ = kWaitingForKey; | 275 state_ = kWaitingForKey; |
| 276 waiting_for_encryption_key_cb_.Run(); |
| 273 return; | 277 return; |
| 274 } | 278 } |
| 275 | 279 |
| 276 if (status == Decryptor::kNeedMoreData) { | 280 if (status == Decryptor::kNeedMoreData) { |
| 277 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; | 281 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; |
| 278 state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished | 282 state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished |
| 279 : kIdle; | 283 : kIdle; |
| 280 base::ResetAndReturn(&decode_cb_).Run(kOk); | 284 base::ResetAndReturn(&decode_cb_).Run(kOk); |
| 281 return; | 285 return; |
| 282 } | 286 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 318 } |
| 315 | 319 |
| 316 void DecryptingVideoDecoder::DoReset() { | 320 void DecryptingVideoDecoder::DoReset() { |
| 317 DCHECK(init_cb_.is_null()); | 321 DCHECK(init_cb_.is_null()); |
| 318 DCHECK(decode_cb_.is_null()); | 322 DCHECK(decode_cb_.is_null()); |
| 319 state_ = kIdle; | 323 state_ = kIdle; |
| 320 base::ResetAndReturn(&reset_cb_).Run(); | 324 base::ResetAndReturn(&reset_cb_).Run(); |
| 321 } | 325 } |
| 322 | 326 |
| 323 } // namespace media | 327 } // namespace media |
| OLD | NEW |