| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
| 9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
| 10 #include "media/base/filter_host.h" | 10 #include "media/base/filter_host.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 if (state_ == kFlushing) { | 352 if (state_ == kFlushing) { |
| 353 AttemptFlush_Locked(); | 353 AttemptFlush_Locked(); |
| 354 return; | 354 return; |
| 355 } | 355 } |
| 356 | 356 |
| 357 if (state_ == kError || state_ == kStopped) { | 357 if (state_ == kError || state_ == kStopped) { |
| 358 DoStopOrError_Locked(); | 358 DoStopOrError_Locked(); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 void VideoRendererBase::FrameReady(scoped_refptr<VideoFrame> frame) { | 362 void VideoRendererBase::FrameReady(VideoDecoder::DecoderStatus status, |
| 363 scoped_refptr<VideoFrame> frame) { |
| 363 base::AutoLock auto_lock(lock_); | 364 base::AutoLock auto_lock(lock_); |
| 364 DCHECK_NE(state_, kUninitialized); | 365 DCHECK_NE(state_, kUninitialized); |
| 365 | 366 |
| 366 CHECK(pending_read_); | 367 CHECK(pending_read_); |
| 367 pending_read_ = false; | 368 pending_read_ = false; |
| 368 | 369 |
| 370 if (status == VideoDecoder::kDecodeError) { |
| 371 DCHECK(!frame); |
| 372 host()->SetError(PIPELINE_ERROR_DECODE); |
| 373 return; |
| 374 } |
| 375 |
| 376 if (status == VideoDecoder::kDecryptError) { |
| 377 DCHECK(!frame); |
| 378 host()->SetError(PIPELINE_ERROR_DECRYPT); |
| 379 return; |
| 380 } |
| 381 |
| 382 DCHECK_EQ(status, VideoDecoder::kOk); |
| 383 |
| 369 // Already-queued Decoder ReadCB's can fire after various state transitions | 384 // Already-queued Decoder ReadCB's can fire after various state transitions |
| 370 // have happened; in that case just drop those frames immediately. | 385 // have happened; in that case just drop those frames immediately. |
| 371 if (state_ == kStopped || state_ == kError || state_ == kFlushed || | 386 if (state_ == kStopped || state_ == kError || state_ == kFlushed || |
| 372 state_ == kFlushingDecoder) | 387 state_ == kFlushingDecoder) |
| 373 return; | 388 return; |
| 374 | 389 |
| 375 if (state_ == kFlushing) { | 390 if (state_ == kFlushing) { |
| 376 AttemptFlush_Locked(); | 391 AttemptFlush_Locked(); |
| 377 return; | 392 return; |
| 378 } | 393 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 468 |
| 454 void VideoRendererBase::AttemptRead_Locked() { | 469 void VideoRendererBase::AttemptRead_Locked() { |
| 455 lock_.AssertAcquired(); | 470 lock_.AssertAcquired(); |
| 456 DCHECK_NE(kEnded, state_); | 471 DCHECK_NE(kEnded, state_); |
| 457 | 472 |
| 458 if (pending_read_ || | 473 if (pending_read_ || |
| 459 NumFrames_Locked() == limits::kMaxVideoFrames || | 474 NumFrames_Locked() == limits::kMaxVideoFrames || |
| 460 (!ready_frames_.empty() && ready_frames_.back()->IsEndOfStream()) || | 475 (!ready_frames_.empty() && ready_frames_.back()->IsEndOfStream()) || |
| 461 state_ == kFlushingDecoder || | 476 state_ == kFlushingDecoder || |
| 462 state_ == kFlushing) { | 477 state_ == kFlushing) { |
| 463 return; | 478 return; |
| 464 } | 479 } |
| 465 | 480 |
| 466 pending_read_ = true; | 481 pending_read_ = true; |
| 467 decoder_->Read(base::Bind(&VideoRendererBase::FrameReady, this)); | 482 decoder_->Read(base::Bind(&VideoRendererBase::FrameReady, this)); |
| 468 } | 483 } |
| 469 | 484 |
| 470 void VideoRendererBase::OnDecoderFlushDone() { | 485 void VideoRendererBase::OnDecoderFlushDone() { |
| 471 base::AutoLock auto_lock(lock_); | 486 base::AutoLock auto_lock(lock_); |
| 472 DCHECK_EQ(kFlushingDecoder, state_); | 487 DCHECK_EQ(kFlushingDecoder, state_); |
| 473 DCHECK(!pending_read_); | 488 DCHECK(!pending_read_); |
| 474 | 489 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 535 |
| 521 int VideoRendererBase::NumFrames_Locked() const { | 536 int VideoRendererBase::NumFrames_Locked() const { |
| 522 lock_.AssertAcquired(); | 537 lock_.AssertAcquired(); |
| 523 int outstanding_frames = | 538 int outstanding_frames = |
| 524 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + | 539 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + |
| 525 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); | 540 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); |
| 526 return ready_frames_.size() + outstanding_frames; | 541 return ready_frames_.size() + outstanding_frames; |
| 527 } | 542 } |
| 528 | 543 |
| 529 } // namespace media | 544 } // namespace media |
| OLD | NEW |