| 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/video_renderer_base.h" | 5 #include "media/filters/video_renderer_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 void VideoRendererBase::FrameReady(VideoDecoder::Status status, | 335 void VideoRendererBase::FrameReady(VideoDecoder::Status status, |
| 336 const scoped_refptr<VideoFrame>& frame) { | 336 const scoped_refptr<VideoFrame>& frame) { |
| 337 base::AutoLock auto_lock(lock_); | 337 base::AutoLock auto_lock(lock_); |
| 338 DCHECK_NE(state_, kUninitialized); | 338 DCHECK_NE(state_, kUninitialized); |
| 339 | 339 |
| 340 CHECK(pending_read_); | 340 CHECK(pending_read_); |
| 341 pending_read_ = false; | 341 pending_read_ = false; |
| 342 | 342 |
| 343 if (status != VideoDecoder::kOk) { | 343 if (status != VideoDecoder::kOk) { |
| 344 DCHECK(!frame); | 344 DCHECK(!frame.get()); |
| 345 PipelineStatus error = PIPELINE_ERROR_DECODE; | 345 PipelineStatus error = PIPELINE_ERROR_DECODE; |
| 346 if (status == VideoDecoder::kDecryptError) | 346 if (status == VideoDecoder::kDecryptError) |
| 347 error = PIPELINE_ERROR_DECRYPT; | 347 error = PIPELINE_ERROR_DECRYPT; |
| 348 | 348 |
| 349 if (!preroll_cb_.is_null()) { | 349 if (!preroll_cb_.is_null()) { |
| 350 base::ResetAndReturn(&preroll_cb_).Run(error); | 350 base::ResetAndReturn(&preroll_cb_).Run(error); |
| 351 return; | 351 return; |
| 352 } | 352 } |
| 353 | 353 |
| 354 error_cb_.Run(error); | 354 error_cb_.Run(error); |
| 355 return; | 355 return; |
| 356 } | 356 } |
| 357 | 357 |
| 358 // Already-queued Decoder ReadCB's can fire after various state transitions | 358 // Already-queued Decoder ReadCB's can fire after various state transitions |
| 359 // have happened; in that case just drop those frames immediately. | 359 // have happened; in that case just drop those frames immediately. |
| 360 if (state_ == kStopped || state_ == kError || state_ == kFlushed || | 360 if (state_ == kStopped || state_ == kError || state_ == kFlushed || |
| 361 state_ == kFlushingDecoder) | 361 state_ == kFlushingDecoder) |
| 362 return; | 362 return; |
| 363 | 363 |
| 364 if (state_ == kFlushing) { | 364 if (state_ == kFlushing) { |
| 365 AttemptFlush_Locked(); | 365 AttemptFlush_Locked(); |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 | 368 |
| 369 if (!frame) { | 369 if (!frame.get()) { |
| 370 // Abort preroll early for a NULL frame because we won't get more frames. | 370 // Abort preroll early for a NULL frame because we won't get more frames. |
| 371 // A new preroll will be requested after this one completes so there is no | 371 // A new preroll will be requested after this one completes so there is no |
| 372 // point trying to collect more frames. | 372 // point trying to collect more frames. |
| 373 if (state_ == kPrerolling) | 373 if (state_ == kPrerolling) |
| 374 TransitionToPrerolled_Locked(); | 374 TransitionToPrerolled_Locked(); |
| 375 | 375 |
| 376 return; | 376 return; |
| 377 } | 377 } |
| 378 | 378 |
| 379 if (frame->IsEndOfStream()) { | 379 if (frame->IsEndOfStream()) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // Because we might remain in the prerolled state for an undetermined amount | 530 // Because we might remain in the prerolled state for an undetermined amount |
| 531 // of time (e.g., we seeked while paused), we'll paint the first prerolled | 531 // of time (e.g., we seeked while paused), we'll paint the first prerolled |
| 532 // frame. | 532 // frame. |
| 533 if (!ready_frames_.empty()) | 533 if (!ready_frames_.empty()) |
| 534 PaintNextReadyFrame_Locked(); | 534 PaintNextReadyFrame_Locked(); |
| 535 | 535 |
| 536 base::ResetAndReturn(&preroll_cb_).Run(PIPELINE_OK); | 536 base::ResetAndReturn(&preroll_cb_).Run(PIPELINE_OK); |
| 537 } | 537 } |
| 538 | 538 |
| 539 } // namespace media | 539 } // namespace media |
| OLD | NEW |