| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This class chooses a capture interval so as to limit CPU usage to not exceed | 5 // This class chooses a capture interval so as to limit CPU usage to not exceed |
| 6 // a specified %age. It bases this on the CPU usage of recent capture and encode | 6 // a specified %age. It bases this on the CPU usage of recent capture and encode |
| 7 // operations, and on the number of available CPUs. | 7 // operations, and on the number of available CPUs. |
| 8 | 8 |
| 9 #ifndef REMOTING_HOST_CAPTURE_SCHEDULER_H_ | 9 #ifndef REMOTING_HOST_CAPTURE_SCHEDULER_H_ |
| 10 #define REMOTING_HOST_CAPTURE_SCHEDULER_H_ | 10 #define REMOTING_HOST_CAPTURE_SCHEDULER_H_ |
| 11 | 11 |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "remoting/base/running_average.h" | 13 #include "remoting/base/running_average.h" |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 | 16 |
| 17 class CaptureScheduler { | 17 class CaptureScheduler { |
| 18 public: | 18 public: |
| 19 CaptureScheduler(); | 19 CaptureScheduler(); |
| 20 ~CaptureScheduler(); | 20 ~CaptureScheduler(); |
| 21 | 21 |
| 22 // Returns the time to wait after initiating a capture before triggering | 22 // Returns the time to wait after initiating a capture before triggering |
| 23 // the next. | 23 // the next. |
| 24 base::TimeDelta NextCaptureDelay(); | 24 base::TimeDelta NextCaptureDelay(); |
| 25 | 25 |
| 26 // Records time spent on capturing and encoding. | 26 // Records time spent on capturing and encoding. |
| 27 void RecordCaptureTime(base::TimeDelta capture_time); | 27 void RecordCaptureTime(base::TimeDelta capture_time); |
| 28 void RecordEncodeTime(base::TimeDelta encode_time); | 28 void RecordEncodeTime(base::TimeDelta encode_time); |
| 29 | 29 |
| 30 // Sets minimum interval between frames. |
| 31 void set_minimum_interval(base::TimeDelta minimum_interval) { |
| 32 minimum_interval_ = minimum_interval; |
| 33 } |
| 34 |
| 30 // Overrides the number of processors for testing. | 35 // Overrides the number of processors for testing. |
| 31 void SetNumOfProcessorsForTest(int num_of_processors); | 36 void SetNumOfProcessorsForTest(int num_of_processors); |
| 32 | 37 |
| 33 private: | 38 private: |
| 39 base::TimeDelta minimum_interval_; |
| 34 int num_of_processors_; | 40 int num_of_processors_; |
| 35 RunningAverage capture_time_; | 41 RunningAverage capture_time_; |
| 36 RunningAverage encode_time_; | 42 RunningAverage encode_time_; |
| 37 | 43 |
| 38 DISALLOW_COPY_AND_ASSIGN(CaptureScheduler); | 44 DISALLOW_COPY_AND_ASSIGN(CaptureScheduler); |
| 39 }; | 45 }; |
| 40 | 46 |
| 41 } // namespace remoting | 47 } // namespace remoting |
| 42 | 48 |
| 43 #endif // REMOTING_HOST_CAPTURE_SCHEDULER_H_ | 49 #endif // REMOTING_HOST_CAPTURE_SCHEDULER_H_ |
| OLD | NEW |