Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: media/filters/test_video_frame_scheduler.cc

Issue 237353007: Refactor VideoRendererImpl to use VideoFrameScheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "base/bind.h"
8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "media/base/video_frame.h"
11
12 namespace media {
13
14 TestVideoFrameScheduler::ScheduledFrame::ScheduledFrame(
15 const scoped_refptr<VideoFrame> frame,
16 base::TimeTicks wall_ticks,
17 const DoneCB& done_cb)
18 : frame(frame), wall_ticks(wall_ticks), done_cb(done_cb) {
19 }
20
21 TestVideoFrameScheduler::ScheduledFrame::~ScheduledFrame() {
22 }
23
24 TestVideoFrameScheduler::TestVideoFrameScheduler() {
25 }
26
27 TestVideoFrameScheduler::~TestVideoFrameScheduler() {
28 }
29
30 void TestVideoFrameScheduler::ScheduleVideoFrame(
31 const scoped_refptr<VideoFrame>& frame,
32 base::TimeTicks wall_ticks,
33 const DoneCB& done_cb) {
34 scheduled_frames_.push_back(ScheduledFrame(frame, wall_ticks, done_cb));
35 }
36
37 void TestVideoFrameScheduler::Reset() {
38 scheduled_frames_.clear();
39 }
40
41 void TestVideoFrameScheduler::DisplayFramesUpTo(base::TimeTicks wall_ticks) {
42 RunDoneCBForFramesUpTo(wall_ticks, DISPLAYED);
43 }
44
45 void TestVideoFrameScheduler::DropFramesUpTo(base::TimeTicks wall_ticks) {
46 RunDoneCBForFramesUpTo(wall_ticks, DROPPED);
47 }
48
49 void TestVideoFrameScheduler::RunDoneCBForFramesUpTo(base::TimeTicks wall_ticks,
50 Reason reason) {
51 std::vector<ScheduledFrame> done_frames;
52 std::vector<ScheduledFrame> remaining_frames;
53
54 for (size_t i = 0; i < scheduled_frames_.size(); ++i) {
55 if (scheduled_frames_[i].wall_ticks <= wall_ticks) {
56 done_frames.push_back(scheduled_frames_[i]);
57 } else {
58 remaining_frames.push_back(scheduled_frames_[i]);
59 }
60 }
61
62 scheduled_frames_.swap(remaining_frames);
63
64 for (size_t i = 0; i < done_frames.size(); ++i) {
65 done_frames[i].done_cb.Run(done_frames[i].frame, reason);
xhwang 2014/04/25 05:44:47 You #include "base/message_loop/message_loop_proxy
66 }
67 }
68
69 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698