OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "remoting/host/capture_scheduler.h" | |
6 | |
7 #include <algorithm> | |
8 | |
9 #include "base/logging.h" | |
10 #include "base/sys_info.h" | |
11 #include "base/time.h" | |
12 | |
13 namespace { | |
14 | |
15 // Number of samples to average the most recent capture and encode time. | |
Wez
2011/10/31 22:05:53
nit: You need "over" at the end of the sentence. :
| |
16 const int kStatisticsWindow = 3; | |
17 | |
18 // The hard limit is 20fps or 50ms per recording cycle. | |
19 const int64 kMinimumRecordingDelay = 50; | |
20 | |
21 // Controls how much CPU time we can use for encode and capture. | |
22 // Range of this value is between 0 to 1. | |
Wez
2011/10/31 22:05:53
This comment still doesn't make it clear whether t
| |
23 const double kRecordingCpuConsumption = 0.5; | |
24 | |
25 } // namespace | |
26 | |
27 namespace remoting { | |
28 | |
29 // Number of processors is read when this class is constructed so it doesn't | |
30 // change dynamically. | |
Wez
2011/10/31 22:05:53
Is the comment to address my nit? If so then plea
| |
31 CaptureScheduler::CaptureScheduler() | |
32 : num_of_processors_(base::SysInfo::NumberOfProcessors()), | |
33 capture_time_(kStatisticsWindow), | |
34 encode_time_(kStatisticsWindow) { | |
35 DCHECK(num_of_processors_); | |
36 } | |
37 | |
38 CaptureScheduler::~CaptureScheduler() { | |
39 } | |
40 | |
41 base::TimeDelta CaptureScheduler::NextCaptureDelay() { | |
42 // The algorithm only uses CPU time spent in capture and encode, | |
43 // and number of processors to determine the next capture interval. | |
Wez
2011/10/31 22:05:53
Could this comment indicate the intended behaviour
| |
44 double delay = | |
45 (capture_time_.Average() + encode_time_.Average()) / | |
46 (kRecordingCpuConsumption * num_of_processors_); | |
47 | |
48 if (delay < kMinimumRecordingDelay) | |
49 return base::TimeDelta::FromMilliseconds(kMinimumRecordingDelay); | |
50 return base::TimeDelta::FromMilliseconds(delay); | |
51 } | |
52 | |
53 void CaptureScheduler::RecordCaptureTime(base::TimeDelta capture_time) { | |
54 capture_time_.Record(capture_time.InMilliseconds()); | |
55 } | |
56 | |
57 void CaptureScheduler::RecordEncodeTime(base::TimeDelta encode_time) { | |
58 encode_time_.Record(encode_time.InMilliseconds()); | |
59 } | |
60 | |
61 } // namespace remoting | |
OLD | NEW |