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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 state_ = kPendingDemuxerRead; | 228 state_ = kPendingDemuxerRead; |
| 229 ReadFromDemuxerStream(); | 229 ReadFromDemuxerStream(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void DecryptingVideoDecoder::ReadFromDemuxerStream() { | 232 void DecryptingVideoDecoder::ReadFromDemuxerStream() { |
| 233 DCHECK(message_loop_->BelongsToCurrentThread()); | 233 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 234 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; | 234 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; |
| 235 DCHECK(!read_cb_.is_null()); | 235 DCHECK(!read_cb_.is_null()); |
| 236 | 236 |
| 237 demuxer_stream_->Read( | 237 demuxer_stream_->Read( |
| 238 base::Bind(&DecryptingVideoDecoder::DecryptAndDecodeBuffer, this)); | 238 base::Bind(&DecryptingVideoDecoder::DoDecryptAndDecodeBuffer, this)); |
| 239 } | |
| 240 | |
| 241 void DecryptingVideoDecoder::DecryptAndDecodeBuffer( | |
| 242 DemuxerStream::Status status, | |
| 243 const scoped_refptr<DecoderBuffer>& buffer) { | |
| 244 // In theory, we don't need to force post the task here, because we do a | |
|
scherkus (not reviewing)
2012/11/19 19:11:16
xhwang: ditto
| |
| 245 // force task post in DeliverFrame(). Therefore, even if | |
| 246 // demuxer_stream_->Read() execute the read callback on the same execution | |
| 247 // stack we are still fine. But it looks like a force post task makes the | |
| 248 // logic more understandable and manageable, so why not? | |
| 249 message_loop_->PostTask(FROM_HERE, base::Bind( | |
| 250 &DecryptingVideoDecoder::DoDecryptAndDecodeBuffer, this, status, buffer)); | |
| 251 } | 239 } |
| 252 | 240 |
| 253 void DecryptingVideoDecoder::DoDecryptAndDecodeBuffer( | 241 void DecryptingVideoDecoder::DoDecryptAndDecodeBuffer( |
| 254 DemuxerStream::Status status, | 242 DemuxerStream::Status status, |
| 255 const scoped_refptr<DecoderBuffer>& buffer) { | 243 const scoped_refptr<DecoderBuffer>& buffer) { |
| 244 if (!message_loop_->BelongsToCurrentThread()) { | |
| 245 message_loop_->PostTask(FROM_HERE, base::Bind( | |
| 246 &DecryptingVideoDecoder::DoDecryptAndDecodeBuffer, this, | |
| 247 status, buffer)); | |
| 248 return; | |
| 249 } | |
| 250 | |
| 256 DVLOG(3) << "DoDecryptAndDecodeBuffer()"; | 251 DVLOG(3) << "DoDecryptAndDecodeBuffer()"; |
| 257 DCHECK(message_loop_->BelongsToCurrentThread()); | |
| 258 | 252 |
| 259 if (state_ == kStopped) | 253 if (state_ == kStopped) |
| 260 return; | 254 return; |
| 261 | 255 |
| 262 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; | 256 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; |
| 263 DCHECK(!read_cb_.is_null()); | 257 DCHECK(!read_cb_.is_null()); |
| 264 DCHECK_EQ(buffer != NULL, status == DemuxerStream::kOk) << status; | 258 DCHECK_EQ(buffer != NULL, status == DemuxerStream::kOk) << status; |
| 265 | 259 |
| 266 if (!reset_cb_.is_null()) { | 260 if (!reset_cb_.is_null()) { |
| 267 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 261 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 } | 409 } |
| 416 | 410 |
| 417 void DecryptingVideoDecoder::DoReset() { | 411 void DecryptingVideoDecoder::DoReset() { |
| 418 DCHECK(init_cb_.is_null()); | 412 DCHECK(init_cb_.is_null()); |
| 419 DCHECK(read_cb_.is_null()); | 413 DCHECK(read_cb_.is_null()); |
| 420 state_ = kIdle; | 414 state_ = kIdle; |
| 421 base::ResetAndReturn(&reset_cb_).Run(); | 415 base::ResetAndReturn(&reset_cb_).Run(); |
| 422 } | 416 } |
| 423 | 417 |
| 424 } // namespace media | 418 } // namespace media |
| OLD | NEW |