| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderers/video_renderer_impl.h" | 5 #include "media/renderers/video_renderer_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // We may have removed all frames above and have reached end of stream. | 397 // We may have removed all frames above and have reached end of stream. |
| 398 MaybeFireEndedCallback_Locked(time_progressing_); | 398 MaybeFireEndedCallback_Locked(time_progressing_); |
| 399 | 399 |
| 400 // Paint the first frame if possible and necessary. PaintSingleFrame() will | 400 // Paint the first frame if possible and necessary. PaintSingleFrame() will |
| 401 // ignore repeated calls for the same frame. Paint ahead of HAVE_ENOUGH_DATA | 401 // ignore repeated calls for the same frame. Paint ahead of HAVE_ENOUGH_DATA |
| 402 // to ensure the user sees the frame as early as possible. | 402 // to ensure the user sees the frame as early as possible. |
| 403 if (!sink_started_ && algorithm_->frames_queued()) { | 403 if (!sink_started_ && algorithm_->frames_queued()) { |
| 404 // We want to paint the first frame under two conditions: Either (1) we have | 404 // We want to paint the first frame under two conditions: Either (1) we have |
| 405 // enough frames to know it's definitely the first frame or (2) there may be | 405 // enough frames to know it's definitely the first frame or (2) there may be |
| 406 // no more frames coming (sometimes unless we paint one of them). | 406 // no more frames coming (sometimes unless we paint one of them). |
| 407 // |
| 408 // For the first condition, we need at least two frames or the first frame |
| 409 // must have a timestamp >= |start_timestamp_|, since otherwise we may be |
| 410 // prerolling frames before the actual start time that will be dropped. |
| 407 if (algorithm_->frames_queued() > 1 || received_end_of_stream_ || | 411 if (algorithm_->frames_queued() > 1 || received_end_of_stream_ || |
| 412 algorithm_->first_frame()->timestamp() >= start_timestamp_ || |
| 408 low_delay_ || !video_frame_stream_->CanReadWithoutStalling()) { | 413 low_delay_ || !video_frame_stream_->CanReadWithoutStalling()) { |
| 409 scoped_refptr<VideoFrame> frame = algorithm_->first_frame(); | 414 scoped_refptr<VideoFrame> frame = algorithm_->first_frame(); |
| 410 CheckForMetadataChanges(frame->format(), frame->natural_size()); | 415 CheckForMetadataChanges(frame->format(), frame->natural_size()); |
| 411 sink_->PaintSingleFrame(frame); | 416 sink_->PaintSingleFrame(frame); |
| 412 } | 417 } |
| 413 } | 418 } |
| 414 | 419 |
| 415 // Signal buffering state if we've met our conditions. | 420 // Signal buffering state if we've met our conditions. |
| 416 if (buffering_state_ == BUFFERING_HAVE_NOTHING && HaveEnoughData_Locked()) | 421 if (buffering_state_ == BUFFERING_HAVE_NOTHING && HaveEnoughData_Locked()) |
| 417 TransitionToHaveEnough_Locked(); | 422 TransitionToHaveEnough_Locked(); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 | 688 |
| 684 void VideoRendererImpl::AttemptReadAndCheckForMetadataChanges( | 689 void VideoRendererImpl::AttemptReadAndCheckForMetadataChanges( |
| 685 VideoPixelFormat pixel_format, | 690 VideoPixelFormat pixel_format, |
| 686 const gfx::Size& natural_size) { | 691 const gfx::Size& natural_size) { |
| 687 base::AutoLock auto_lock(lock_); | 692 base::AutoLock auto_lock(lock_); |
| 688 CheckForMetadataChanges(pixel_format, natural_size); | 693 CheckForMetadataChanges(pixel_format, natural_size); |
| 689 AttemptRead_Locked(); | 694 AttemptRead_Locked(); |
| 690 } | 695 } |
| 691 | 696 |
| 692 } // namespace media | 697 } // namespace media |
| OLD | NEW |