| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_frame_scheduler_impl.h" | 5 #include "media/filters/video_frame_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/time/default_tick_clock.h" | 10 #include "base/time/default_tick_clock.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 const scoped_refptr<VideoFrame>& frame, | 27 const scoped_refptr<VideoFrame>& frame, |
| 28 base::TimeTicks wall_ticks, | 28 base::TimeTicks wall_ticks, |
| 29 const DoneCB& done_cb) { | 29 const DoneCB& done_cb) { |
| 30 DCHECK(task_runner_->BelongsToCurrentThread()); | 30 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 31 DCHECK(!frame->end_of_stream()); | 31 DCHECK(!frame->end_of_stream()); |
| 32 pending_frames_.push(PendingFrame(frame, wall_ticks, done_cb)); | 32 pending_frames_.push(PendingFrame(frame, wall_ticks, done_cb)); |
| 33 ResetTimerIfNecessary(); | 33 ResetTimerIfNecessary(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void VideoFrameSchedulerImpl::Reset() { | 36 void VideoFrameSchedulerImpl::Reset() { |
| 37 DCHECK(task_runner_->BelongsToCurrentThread()); | 37 pending_frames_ = PendingFrameQueue(); |
| 38 while (!pending_frames_.empty()) { | 38 timer_.Stop(); |
| 39 pending_frames_.top().done_cb.Run(pending_frames_.top().frame, RESET); | |
| 40 pending_frames_.pop(); | |
| 41 } | |
| 42 } | 39 } |
| 43 | 40 |
| 44 void VideoFrameSchedulerImpl::SetTickClockForTesting( | 41 void VideoFrameSchedulerImpl::SetTickClockForTesting( |
| 45 scoped_ptr<base::TickClock> tick_clock) { | 42 scoped_ptr<base::TickClock> tick_clock) { |
| 46 tick_clock_.swap(tick_clock); | 43 tick_clock_.swap(tick_clock); |
| 47 } | 44 } |
| 48 | 45 |
| 49 void VideoFrameSchedulerImpl::ResetTimerIfNecessary() { | 46 void VideoFrameSchedulerImpl::ResetTimerIfNecessary() { |
| 50 if (pending_frames_.empty()) { | 47 if (pending_frames_.empty()) { |
| 51 DCHECK(!timer_.IsRunning()); | 48 DCHECK(!timer_.IsRunning()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 bool VideoFrameSchedulerImpl::PendingFrame::operator<( | 96 bool VideoFrameSchedulerImpl::PendingFrame::operator<( |
| 100 const PendingFrame& other) const { | 97 const PendingFrame& other) const { |
| 101 // Flip the comparison as std::priority_queue<T>::top() returns the largest | 98 // Flip the comparison as std::priority_queue<T>::top() returns the largest |
| 102 // element. | 99 // element. |
| 103 // | 100 // |
| 104 // Assume video frames with identical timestamps contain identical content. | 101 // Assume video frames with identical timestamps contain identical content. |
| 105 return wall_ticks > other.wall_ticks; | 102 return wall_ticks > other.wall_ticks; |
| 106 } | 103 } |
| 107 | 104 |
| 108 } // namespace media | 105 } // namespace media |
| OLD | NEW |