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

Unified Diff: remoting/host/capture_scheduler.h

Issue 872433005: Move capture scheduling logic from VideoScheduler to CaptureScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « no previous file | remoting/host/capture_scheduler.cc » ('j') | remoting/host/capture_scheduler.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/capture_scheduler.h
diff --git a/remoting/host/capture_scheduler.h b/remoting/host/capture_scheduler.h
index 9dbecdad3d14720167cf321977f45c46afa4a618..610b35ba490b9cb1ef4b5bcedbde46bd6d28c624 100644
--- a/remoting/host/capture_scheduler.h
+++ b/remoting/host/capture_scheduler.h
@@ -9,38 +9,83 @@
#ifndef REMOTING_HOST_CAPTURE_SCHEDULER_H_
#define REMOTING_HOST_CAPTURE_SCHEDULER_H_
+#include "base/callback.h"
+#include "base/threading/non_thread_safe.h"
+#include "base/time/tick_clock.h"
#include "base/time/time.h"
+#include "base/timer/timer.h"
#include "remoting/base/running_average.h"
namespace remoting {
-class CaptureScheduler {
+// CaptureScheduler is used by the VideoScheduler to scheduler frame capturer,
Wez 2015/02/02 21:40:49 s/scheduler/schedule
Sergey Ulanov 2015/02/03 23:49:52 Done.
+// taking into account capture delay, encoder delay, network bandwidth, etc.
+class CaptureScheduler : public base::NonThreadSafe {
public:
- CaptureScheduler();
+ explicit CaptureScheduler(const base::Closure& capture_closure);
Wez 2015/02/02 21:40:48 Suggest adding a comment to explain that |capture_
Sergey Ulanov 2015/02/03 23:49:52 Done.
~CaptureScheduler();
- // Returns the time to wait after initiating a capture before triggering
- // the next.
- base::TimeDelta NextCaptureDelay();
+ // Starts the scheduler.
+ void Start();
- // Records time spent on capturing and encoding.
- void RecordCaptureTime(base::TimeDelta capture_time);
- void RecordEncodeTime(base::TimeDelta encode_time);
+ // Pauses or unpauses the stream.
+ void Pause(bool pause);
+
+ // Notifies the scheduler that a capture has been completed.
+ void OnCaptureCompleted();
+
+ // Notifies the scheduler than a frame has been encoded.
Wez 2015/02/02 21:40:48 s/than/that
Sergey Ulanov 2015/02/03 23:49:52 Done.
+ void OnFrameEncoded(base::TimeDelta encode_time);
+
+ // Notifies the scheduler than a frame has been sent.
Wez 2015/02/02 21:40:48 s/than/that
Sergey Ulanov 2015/02/03 23:49:52 Done.
+ void OnFrameSent();
// Sets minimum interval between frames.
void set_minimum_interval(base::TimeDelta minimum_interval) {
minimum_interval_ = minimum_interval;
}
- // Overrides the number of processors for testing.
- void SetNumOfProcessorsForTest(int num_of_processors);
+ // Helper functions for tests.
+ void set_tick_clock_for_tests(scoped_ptr<base::TickClock> tick_clock) {
Wez 2015/02/02 21:40:48 nit: Should these be SetTickClockForTest and simil
Sergey Ulanov 2015/02/03 23:49:52 Done.
+ tick_clock_ = tick_clock.Pass();
+ }
+ void set_timer_for_tests(scoped_ptr<base::Timer> timer) {
+ capture_timer_ = timer.Pass();
+ }
+ void set_num_of_processors_for_tests(int num_of_processors) {
+ num_of_processors_ = num_of_processors;
+ }
private:
+ // Schedules |capture_timer_| to call CaptureNextFrame() at appropriate time.
+ // Doesn't do anything if next frame cannot be captured yet (e.g. because
+ // there are too many frames being processed).
+ void ScheduleNextCapture();
+
+ // Called by |capture_timer_|. Calls |capture_closure_| to start capturing a
+ // new frame.
+ void CaptureNextFrame();
+
+ base::Closure capture_closure_;
+
+ scoped_ptr<base::TickClock> tick_clock_;
+
+ // Timer used to schedule CaptureNextFrame().
+ scoped_ptr<base::Timer> capture_timer_;
+
+ // Minimum interval between frames.
Wez 2015/02/02 21:40:48 How is this set and what's it used for?
Sergey Ulanov 2015/02/03 23:49:52 Removed it.
base::TimeDelta minimum_interval_;
+
int num_of_processors_;
+
RunningAverage capture_time_;
RunningAverage encode_time_;
+ int pending_frames_;
Wez 2015/02/02 21:40:48 What does it mean for a frame to be "pending" - fr
Sergey Ulanov 2015/02/03 23:49:52 Done.
+ bool capture_pending_;
+ base::TimeTicks last_capture_started_time_;
+ bool is_paused_;
+
DISALLOW_COPY_AND_ASSIGN(CaptureScheduler);
};
« no previous file with comments | « no previous file | remoting/host/capture_scheduler.cc » ('j') | remoting/host/capture_scheduler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698