Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 8 #include "media/base/buffers.h" | 8 #include "media/base/buffers.h" |
| 9 #include "media/base/filter_host.h" | 9 #include "media/base/filter_host.h" |
| 10 #include "media/base/limits.h" | 10 #include "media/base/limits.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 // frame when this is true. | 356 // frame when this is true. |
| 357 frame_available_.Signal(); | 357 frame_available_.Signal(); |
| 358 if (state_ == kFlushing) { | 358 if (state_ == kFlushing) { |
| 359 FlushBuffers_Locked(); | 359 FlushBuffers_Locked(); |
| 360 } else if (state_ == kError || state_ == kStopped) { | 360 } else if (state_ == kError || state_ == kStopped) { |
| 361 DoStopOrErrorFlush_Locked(); | 361 DoStopOrErrorFlush_Locked(); |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 | 364 |
| 365 void VideoRendererBase::ConsumeVideoFrame(scoped_refptr<VideoFrame> frame) { | 365 void VideoRendererBase::ConsumeVideoFrame(scoped_refptr<VideoFrame> frame) { |
| 366 if (frame) { | 366 DCHECK(frame); |
| 367 PipelineStatistics statistics; | 367 |
| 368 statistics.video_frames_decoded = 1; | 368 PipelineStatistics statistics; |
| 369 statistics_callback_.Run(statistics); | 369 statistics.video_frames_decoded = 1; |
| 370 } | 370 statistics_callback_.Run(statistics); |
|
acolwell GONE FROM CHROMIUM
2011/10/28 17:38:47
Do we want to include end of stream or empty frame
scherkus (not reviewing)
2011/11/01 04:18:26
Moved below -- also shouldn't the decoder incremen
| |
| 371 | 371 |
| 372 base::AutoLock auto_lock(lock_); | 372 base::AutoLock auto_lock(lock_); |
| 373 | 373 |
| 374 if (!frame) { | |
| 375 EnterErrorState_Locked(PIPELINE_ERROR_DECODE); | |
| 376 return; | |
| 377 } | |
| 378 | |
| 379 // Decoder could reach seek state before our Seek() get called. | 374 // Decoder could reach seek state before our Seek() get called. |
| 380 // We will enter kSeeking | 375 // We will enter kSeeking |
| 381 if (state_ == kFlushed) | 376 if (state_ == kFlushed) |
| 382 state_ = kSeeking; | 377 state_ = kSeeking; |
| 383 | 378 |
| 384 // Synchronous flush between filters should prevent this from happening. | 379 // Synchronous flush between filters should prevent this from happening. |
| 385 DCHECK_NE(state_, kStopped); | 380 DCHECK_NE(state_, kStopped); |
| 386 if (frame.get() && !frame->IsEndOfStream()) | 381 if (!frame->IsEndOfStream()) |
|
acolwell GONE FROM CHROMIUM
2011/10/28 17:38:47
Why don't end of stream frames decrement the pendi
scherkus (not reviewing)
2011/11/01 04:18:26
Done.
| |
| 387 --pending_reads_; | 382 --pending_reads_; |
| 388 | 383 |
| 389 DCHECK(state_ != kUninitialized && state_ != kStopped && state_ != kError); | 384 DCHECK(state_ != kUninitialized && state_ != kStopped && state_ != kError); |
| 390 | 385 |
| 391 if (state_ == kPaused || state_ == kFlushing) { | 386 if (state_ == kPaused || state_ == kFlushing) { |
| 392 // Decoder are flushing rubbish video frame, we will not display them. | 387 // Decoder are flushing rubbish video frame, we will not display them. |
| 393 if (frame.get() && !frame->IsEndOfStream()) | 388 if (!frame->IsEndOfStream()) |
| 394 frames_queue_done_.push_back(frame); | 389 frames_queue_done_.push_back(frame); |
| 395 DCHECK_LE(frames_queue_done_.size(), | 390 DCHECK_LE(frames_queue_done_.size(), |
|
acolwell GONE FROM CHROMIUM
2011/10/28 17:38:47
Remove this queue. Frame recycling must die.
scherkus (not reviewing)
2011/11/01 04:18:26
Done.
| |
| 396 static_cast<size_t>(Limits::kMaxVideoFrames)); | 391 static_cast<size_t>(Limits::kMaxVideoFrames)); |
| 397 | 392 |
| 398 // Excluding kPause here, because in pause state, we will never | 393 // Excluding kPause here, because in pause state, we will never |
| 399 // transfer out-bounding buffer. We do not flush buffer when Compositor | 394 // transfer out-bounding buffer. We do not flush buffer when Compositor |
| 400 // hold reference to our video frame either. | 395 // hold reference to our video frame either. |
| 401 if (state_ == kFlushing && pending_paint_ == false) | 396 if (state_ == kFlushing && pending_paint_ == false) |
| 402 FlushBuffers_Locked(); | 397 FlushBuffers_Locked(); |
| 403 | 398 |
| 404 return; | 399 return; |
| 405 } | 400 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 } else if (state_ == kFlushing && pending_reads_ == 0 && !pending_paint_) { | 441 } else if (state_ == kFlushing && pending_reads_ == 0 && !pending_paint_) { |
| 447 OnFlushDone_Locked(); | 442 OnFlushDone_Locked(); |
| 448 } | 443 } |
| 449 | 444 |
| 450 if (new_frame_available) { | 445 if (new_frame_available) { |
| 451 base::AutoUnlock auto_unlock(lock_); | 446 base::AutoUnlock auto_unlock(lock_); |
| 452 OnFrameAvailable(); | 447 OnFrameAvailable(); |
| 453 } | 448 } |
| 454 } | 449 } |
| 455 | 450 |
| 456 void VideoRendererBase::ReadInput(scoped_refptr<VideoFrame> frame) { | 451 void VideoRendererBase::ReadInput(scoped_refptr<VideoFrame> frame) { |
|
acolwell GONE FROM CHROMIUM
2011/10/28 17:38:47
Remove frame parameter now that we aren't doing bu
scherkus (not reviewing)
2011/11/01 04:18:26
Done.
| |
| 457 // We should never return empty frames or EOS frame. | 452 // We should never return empty frames or EOS frame. |
| 458 DCHECK(frame.get() && !frame->IsEndOfStream()); | 453 DCHECK(frame.get() && !frame->IsEndOfStream()); |
| 459 | 454 |
| 460 decoder_->ProduceVideoFrame(frame); | 455 decoder_->ProduceVideoFrame(frame); |
| 461 ++pending_reads_; | 456 ++pending_reads_; |
| 462 } | 457 } |
| 463 | 458 |
| 464 void VideoRendererBase::ScheduleRead_Locked() { | 459 void VideoRendererBase::ScheduleRead_Locked() { |
| 465 lock_.AssertAcquired(); | 460 lock_.AssertAcquired(); |
| 466 DCHECK_NE(kEnded, state_); | 461 DCHECK_NE(kEnded, state_); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 void VideoRendererBase::DoStopOrErrorFlush_Locked() { | 584 void VideoRendererBase::DoStopOrErrorFlush_Locked() { |
| 590 DCHECK(!pending_paint_); | 585 DCHECK(!pending_paint_); |
| 591 DCHECK(!pending_paint_with_last_available_); | 586 DCHECK(!pending_paint_with_last_available_); |
| 592 lock_.AssertAcquired(); | 587 lock_.AssertAcquired(); |
| 593 FlushBuffers_Locked(); | 588 FlushBuffers_Locked(); |
| 594 last_available_frame_ = NULL; | 589 last_available_frame_ = NULL; |
| 595 DCHECK_EQ(pending_reads_, 0); | 590 DCHECK_EQ(pending_reads_, 0); |
| 596 } | 591 } |
| 597 | 592 |
| 598 } // namespace media | 593 } // namespace media |
| OLD | NEW |