| 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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 if (!frame.get()) { | 365 if (!frame.get()) { |
| 366 // Abort preroll early for a NULL frame because we won't get more frames. | 366 // Abort preroll early for a NULL frame because we won't get more frames. |
| 367 // A new preroll will be requested after this one completes so there is no | 367 // A new preroll will be requested after this one completes so there is no |
| 368 // point trying to collect more frames. | 368 // point trying to collect more frames. |
| 369 if (state_ == kPrerolling) | 369 if (state_ == kPrerolling) |
| 370 TransitionToPrerolled_Locked(); | 370 TransitionToPrerolled_Locked(); |
| 371 | 371 |
| 372 return; | 372 return; |
| 373 } | 373 } |
| 374 | 374 |
| 375 if (frame->IsEndOfStream()) { | 375 if (frame->end_of_stream()) { |
| 376 DCHECK(!received_end_of_stream_); | 376 DCHECK(!received_end_of_stream_); |
| 377 received_end_of_stream_ = true; | 377 received_end_of_stream_ = true; |
| 378 max_time_cb_.Run(get_duration_cb_.Run()); | 378 max_time_cb_.Run(get_duration_cb_.Run()); |
| 379 | 379 |
| 380 if (state_ == kPrerolling) | 380 if (state_ == kPrerolling) |
| 381 TransitionToPrerolled_Locked(); | 381 TransitionToPrerolled_Locked(); |
| 382 | 382 |
| 383 return; | 383 return; |
| 384 } | 384 } |
| 385 | 385 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 401 // Always request more decoded video if we have capacity. This serves two | 401 // Always request more decoded video if we have capacity. This serves two |
| 402 // purposes: | 402 // purposes: |
| 403 // 1) Prerolling while paused | 403 // 1) Prerolling while paused |
| 404 // 2) Keeps decoding going if video rendering thread starts falling behind | 404 // 2) Keeps decoding going if video rendering thread starts falling behind |
| 405 AttemptRead_Locked(); | 405 AttemptRead_Locked(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void VideoRendererBase::AddReadyFrame_Locked( | 408 void VideoRendererBase::AddReadyFrame_Locked( |
| 409 const scoped_refptr<VideoFrame>& frame) { | 409 const scoped_refptr<VideoFrame>& frame) { |
| 410 lock_.AssertAcquired(); | 410 lock_.AssertAcquired(); |
| 411 DCHECK(!frame->IsEndOfStream()); | 411 DCHECK(!frame->end_of_stream()); |
| 412 | 412 |
| 413 // Adjust the incoming frame if its rendering stop time is past the duration | 413 // Adjust the incoming frame if its rendering stop time is past the duration |
| 414 // of the video itself. This is typically the last frame of the video and | 414 // of the video itself. This is typically the last frame of the video and |
| 415 // occurs if the container specifies a duration that isn't a multiple of the | 415 // occurs if the container specifies a duration that isn't a multiple of the |
| 416 // frame rate. Another way for this to happen is for the container to state | 416 // frame rate. Another way for this to happen is for the container to state |
| 417 // a smaller duration than the largest packet timestamp. | 417 // a smaller duration than the largest packet timestamp. |
| 418 base::TimeDelta duration = get_duration_cb_.Run(); | 418 base::TimeDelta duration = get_duration_cb_.Run(); |
| 419 if (frame->GetTimestamp() > duration) { | 419 if (frame->GetTimestamp() > duration) { |
| 420 frame->SetTimestamp(duration); | 420 frame->SetTimestamp(duration); |
| 421 } | 421 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 statistics_cb_.Run(statistics); | 528 statistics_cb_.Run(statistics); |
| 529 | 529 |
| 530 frames_decoded_ = 0; | 530 frames_decoded_ = 0; |
| 531 frames_dropped_ = 0; | 531 frames_dropped_ = 0; |
| 532 } | 532 } |
| 533 | 533 |
| 534 frame_available_.TimedWait(wait_duration); | 534 frame_available_.TimedWait(wait_duration); |
| 535 } | 535 } |
| 536 | 536 |
| 537 } // namespace media | 537 } // namespace media |
| OLD | NEW |