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

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: pretty much done 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..596f38c5c655cceeda402e18f56d9fe497171f09
--- /dev/null
+++ b/media/filters/test_video_frame_scheduler.cc
@@ -0,0 +1,74 @@
+// 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() : should_reset_(true) {
+}
+
+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() {
+ 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!
+ 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
+
+ std::vector<ScheduledFrame> frames_to_reset;
+ frames_to_reset.swap(scheduled_frames_);
+
+ for (size_t i = 0; i < frames_to_reset.size(); ++i) {
+ frames_to_reset[i].done_cb.Run(frames_to_reset[i].frame, RESET);
+ }
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
+}
+
+void TestVideoFrameScheduler::DisplayFrames(base::TimeTicks wall_ticks) {
+ RunDoneCBForFrames(wall_ticks, DISPLAYED);
+}
+
+void TestVideoFrameScheduler::DropFrames(base::TimeTicks wall_ticks) {
+ RunDoneCBForFrames(wall_ticks, DROPPED);
+}
+
+void TestVideoFrameScheduler::RunDoneCBForFrames(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]);
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
+ }
+ }
xhwang 2014/04/24 18:48:44 nit: If the frames are sorted we don't have to go
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698