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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/test_video_frame_scheduler.cc
diff --git a/media/filters/test_video_frame_scheduler.cc b/media/filters/test_video_frame_scheduler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0c30ead3aecc0e79109364ccdcbdccffe490910c
--- /dev/null
+++ b/media/filters/test_video_frame_scheduler.cc
@@ -0,0 +1,69 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/filters/test_video_frame_scheduler.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/message_loop/message_loop_proxy.h"
+#include "media/base/video_frame.h"
+
+namespace media {
+
+TestVideoFrameScheduler::ScheduledFrame::ScheduledFrame(
+ const scoped_refptr<VideoFrame> frame,
+ base::TimeTicks wall_ticks,
+ const DoneCB& done_cb)
+ : frame(frame), wall_ticks(wall_ticks), done_cb(done_cb) {
+}
+
+TestVideoFrameScheduler::ScheduledFrame::~ScheduledFrame() {
+}
+
+TestVideoFrameScheduler::TestVideoFrameScheduler() {
+}
+
+TestVideoFrameScheduler::~TestVideoFrameScheduler() {
+}
+
+void TestVideoFrameScheduler::ScheduleVideoFrame(
+ const scoped_refptr<VideoFrame>& frame,
+ base::TimeTicks wall_ticks,
+ const DoneCB& done_cb) {
+ scheduled_frames_.push_back(ScheduledFrame(frame, wall_ticks, done_cb));
+}
+
+void TestVideoFrameScheduler::Reset() {
+ scheduled_frames_.clear();
+}
+
+void TestVideoFrameScheduler::DisplayFramesUpTo(base::TimeTicks wall_ticks) {
+ RunDoneCBForFramesUpTo(wall_ticks, DISPLAYED);
+}
+
+void TestVideoFrameScheduler::DropFramesUpTo(base::TimeTicks wall_ticks) {
+ RunDoneCBForFramesUpTo(wall_ticks, DROPPED);
+}
+
+void TestVideoFrameScheduler::RunDoneCBForFramesUpTo(base::TimeTicks wall_ticks,
+ Reason reason) {
+ std::vector<ScheduledFrame> done_frames;
+ std::vector<ScheduledFrame> remaining_frames;
+
+ for (size_t i = 0; i < scheduled_frames_.size(); ++i) {
+ if (scheduled_frames_[i].wall_ticks <= wall_ticks) {
+ done_frames.push_back(scheduled_frames_[i]);
+ } else {
+ remaining_frames.push_back(scheduled_frames_[i]);
+ }
+ }
+
+ scheduled_frames_.swap(remaining_frames);
+
+ for (size_t i = 0; i < done_frames.size(); ++i) {
+ 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
+ }
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698