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

Unified Diff: media/filters/test_video_frame_scheduler.cc

Issue 257793004: Update VideoFrameScheduler API and add clockless and testing implementations. (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
« no previous file with comments | « media/filters/test_video_frame_scheduler.h ('k') | media/filters/video_frame_scheduler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9dba38d0759fa9996bd66e354d1c2ec7cb29c3b0
--- /dev/null
+++ b/media/filters/test_video_frame_scheduler.cc
@@ -0,0 +1,66 @@
+// 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 "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);
+ }
+}
+
+} // namespace media
« no previous file with comments | « media/filters/test_video_frame_scheduler.h ('k') | media/filters/video_frame_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698