Chromium Code Reviews| 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 // Window for averaging statistics on encode and capture time. | |
| 16 // This constant controls how many recorded instances are averaged. | |
|
Wez
2011/10/25 00:05:37
Please word this more clearly. Intuitively one wo
Alpha Left Google
2011/10/31 18:47:24
Done.
| |
| 17 const int kStatisticsWindow = 3; | |
|
Wez
2011/10/25 00:05:37
Why average over three previous samples? Why not
Alpha Left Google
2011/10/31 18:47:24
My intention is to have a relatively steady frame
| |
| 18 | |
| 19 // The hard limit is 20fps or 50ms per recording cycle. | |
| 20 const int64 kMinimumRecordingDelay = 50; | |
|
Wez
2011/10/25 00:05:37
This still seems unnecessarily low, given that thi
Alpha Left Google
2011/10/31 18:47:24
You have a different opinion than Sergey here, he
Wez
2011/10/31 22:05:53
Sorry, I meant that this value would lead to a low
| |
| 21 | |
| 22 // Controls how much CPU time we can use for encode and capture. | |
| 23 // This is capped at 50%. | |
|
Wez
2011/10/25 00:05:37
I'd suggest rewording to comment to something desc
Alpha Left Google
2011/10/31 18:47:24
Yes it's a ratio across all corres already.
| |
| 24 const double kRecordingCpuConsumption = 0.5; | |
| 25 | |
| 26 } // namespace | |
| 27 | |
| 28 namespace remoting { | |
| 29 | |
| 30 CaptureScheduler::CaptureScheduler() | |
| 31 : num_of_processors_(base::SysInfo::NumberOfProcessors()), | |
|
Wez
2011/10/25 00:05:37
nit: This means we don't cope properly with dynami
Alpha Left Google
2011/10/31 18:47:24
Done.
| |
| 32 capture_time_(kStatisticsWindow), | |
| 33 encode_time_(kStatisticsWindow) { | |
| 34 DCHECK(num_of_processors_); | |
| 35 } | |
| 36 | |
| 37 CaptureScheduler::~CaptureScheduler() { | |
| 38 } | |
| 39 | |
| 40 base::TimeDelta CaptureScheduler::NextCaptureDelay() { | |
| 41 // The algorithm only uses CPU time spent in capture, encode and | |
|
Wez
2011/10/25 00:05:37
typo: "... capture, encode and..." -> "... capture
| |
| 42 // number of processors to determine next capture time. | |
|
Wez
2011/10/25 00:05:37
nit: processors -> cores?
nit: "determine next cap
Alpha Left Google
2011/10/31 18:47:24
I think we should follow the naming of base::SysIn
| |
| 43 // We want to make sure time spent in capture and encode doesn't | |
| 44 // exceed a predefined value, i.e. kRecordingCpuConsumption. | |
|
Wez
2011/10/25 00:05:37
nit: This comment seems to reiterate the basic fun
Alpha Left Google
2011/10/31 18:47:24
Done.
| |
| 45 double delay = | |
| 46 (capture_time_.Average() + encode_time_.Average()) / | |
|
Wez
2011/10/25 00:05:38
Note that the encode time will vary considerably d
| |
| 47 kRecordingCpuConsumption / num_of_processors_; | |
|
Wez
2011/10/25 00:05:38
It's clearer to write this formula as:
delay =
Alpha Left Google
2011/10/31 18:47:24
Done.
| |
| 48 | |
| 49 if (delay < kMinimumRecordingDelay) | |
| 50 return base::TimeDelta::FromMilliseconds(kMinimumRecordingDelay); | |
| 51 return base::TimeDelta::FromMilliseconds(delay); | |
| 52 } | |
| 53 | |
| 54 void CaptureScheduler::RecordCaptureTime(base::TimeDelta capture_time) { | |
| 55 capture_time_.Record(capture_time.InMilliseconds()); | |
| 56 } | |
| 57 | |
| 58 void CaptureScheduler::RecordEncodeTime(base::TimeDelta encode_time) { | |
| 59 encode_time_.Record(encode_time.InMilliseconds()); | |
| 60 } | |
| 61 | |
| 62 } // namespace remoting | |
| OLD | NEW |