Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "media/filters/test_video_frame_scheduler.h" | |
| 6 | |
| 7 #include "media/base/video_frame.h" | |
| 8 | |
| 9 namespace media { | |
| 10 | |
| 11 TestVideoFrameScheduler::ScheduledFrame::ScheduledFrame( | |
| 12 const scoped_refptr<VideoFrame> frame, | |
| 13 base::TimeTicks wall_ticks, | |
| 14 const DoneCB& done_cb) | |
| 15 : frame(frame), wall_ticks(wall_ticks), done_cb(done_cb) { | |
| 16 } | |
| 17 | |
| 18 TestVideoFrameScheduler::ScheduledFrame::~ScheduledFrame() { | |
| 19 } | |
| 20 | |
| 21 TestVideoFrameScheduler::TestVideoFrameScheduler() : should_reset_(true) { | |
| 22 } | |
| 23 | |
| 24 TestVideoFrameScheduler::~TestVideoFrameScheduler() { | |
| 25 } | |
| 26 | |
| 27 void TestVideoFrameScheduler::ScheduleVideoFrame( | |
| 28 const scoped_refptr<VideoFrame>& frame, | |
| 29 base::TimeTicks wall_ticks, | |
| 30 const DoneCB& done_cb) { | |
| 31 scheduled_frames_.push_back(ScheduledFrame(frame, wall_ticks, done_cb)); | |
| 32 } | |
| 33 | |
| 34 void TestVideoFrameScheduler::Reset() { | |
| 35 if (!should_reset_) | |
|
acolwell GONE FROM CHROMIUM
2014/04/24 16:43:59
Why? It seems like this could result in a violatio
scherkus (not reviewing)
2014/04/25 02:04:47
No longer applicable!
| |
| 36 return; | |
|
xhwang
2014/04/24 18:48:44
The API says Reset() should "Causes the scheduler
scherkus (not reviewing)
2014/04/25 02:04:47
Ditto -- Reset() has been reworked
| |
| 37 | |
| 38 std::vector<ScheduledFrame> frames_to_reset; | |
| 39 frames_to_reset.swap(scheduled_frames_); | |
| 40 | |
| 41 for (size_t i = 0; i < frames_to_reset.size(); ++i) { | |
| 42 frames_to_reset[i].done_cb.Run(frames_to_reset[i].frame, RESET); | |
| 43 } | |
|
xhwang
2014/04/24 18:48:44
Can we just use:
RunDoneCBForFrames(TimeDelta::Ma
scherkus (not reviewing)
2014/04/25 02:04:47
not anymore now that we have a contract for reentr
| |
| 44 } | |
| 45 | |
| 46 void TestVideoFrameScheduler::DisplayFrames(base::TimeTicks wall_ticks) { | |
| 47 RunDoneCBForFrames(wall_ticks, DISPLAYED); | |
| 48 } | |
| 49 | |
| 50 void TestVideoFrameScheduler::DropFrames(base::TimeTicks wall_ticks) { | |
| 51 RunDoneCBForFrames(wall_ticks, DROPPED); | |
| 52 } | |
| 53 | |
| 54 void TestVideoFrameScheduler::RunDoneCBForFrames(base::TimeTicks wall_ticks, | |
| 55 Reason reason) { | |
| 56 std::vector<ScheduledFrame> done_frames; | |
| 57 std::vector<ScheduledFrame> remaining_frames; | |
| 58 | |
| 59 for (size_t i = 0; i < scheduled_frames_.size(); ++i) { | |
| 60 if (scheduled_frames_[i].wall_ticks <= wall_ticks) { | |
| 61 done_frames.push_back(scheduled_frames_[i]); | |
| 62 } else { | |
| 63 remaining_frames.push_back(scheduled_frames_[i]); | |
|
acolwell GONE FROM CHROMIUM
2014/04/24 16:43:59
You have to do this because you aren't using a pri
scherkus (not reviewing)
2014/04/25 02:04:47
a scheduler doesn't *have* to use a priority queue
| |
| 64 } | |
| 65 } | |
|
xhwang
2014/04/24 18:48:44
nit: If the frames are sorted we don't have to go
| |
| 66 | |
| 67 scheduled_frames_.swap(remaining_frames); | |
| 68 | |
| 69 for (size_t i = 0; i < done_frames.size(); ++i) { | |
| 70 done_frames[i].done_cb.Run(done_frames[i].frame, reason); | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 } // namespace media | |
| OLD | NEW |