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 #ifndef REMOTING_HOST_SCREEN_RECORDER_H_ | 5 #ifndef REMOTING_HOST_SCREEN_RECORDER_H_ |
6 #define REMOTING_HOST_SCREEN_RECORDER_H_ | 6 #define REMOTING_HOST_SCREEN_RECORDER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/timer.h" | 16 #include "base/timer.h" |
17 #include "remoting/base/encoder.h" | 17 #include "remoting/base/encoder.h" |
18 #include "remoting/host/capturer.h" | 18 #include "remoting/host/capturer.h" |
19 #include "remoting/host/recording_rate_regulator.h" | |
19 #include "remoting/proto/video.pb.h" | 20 #include "remoting/proto/video.pb.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class MessageLoopProxy; | 23 class MessageLoopProxy; |
23 } // namespace base | 24 } // namespace base |
24 | 25 |
25 namespace remoting { | 26 namespace remoting { |
26 | 27 |
27 namespace protocol { | 28 namespace protocol { |
28 class ConnectionToClient; | 29 class ConnectionToClient; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 | 86 |
86 virtual ~ScreenRecorder(); | 87 virtual ~ScreenRecorder(); |
87 | 88 |
88 // Start recording. | 89 // Start recording. |
89 void Start(); | 90 void Start(); |
90 | 91 |
91 // Stop the recording session. |done_task| is executed when recording is fully | 92 // Stop the recording session. |done_task| is executed when recording is fully |
92 // stopped. This object cannot be used again after |task| is executed. | 93 // stopped. This object cannot be used again after |task| is executed. |
93 void Stop(const base::Closure& done_task); | 94 void Stop(const base::Closure& done_task); |
94 | 95 |
95 // Set the maximum capture rate. This is denoted by number of updates | |
96 // in one second. The actual system may run in a slower rate than the maximum | |
97 // rate due to various factors, e.g. capture speed, encode speed and network | |
98 // conditions. | |
99 // This method should be called before Start() is called. | |
100 void SetMaxRate(double rate); | |
101 | |
102 // Add a connection to this recording session. | 96 // Add a connection to this recording session. |
103 void AddConnection(scoped_refptr<protocol::ConnectionToClient> connection); | 97 void AddConnection(scoped_refptr<protocol::ConnectionToClient> connection); |
104 | 98 |
105 // Remove a connection from receiving screen updates. | 99 // Remove a connection from receiving screen updates. |
106 void RemoveConnection(scoped_refptr<protocol::ConnectionToClient> connection); | 100 void RemoveConnection(scoped_refptr<protocol::ConnectionToClient> connection); |
107 | 101 |
108 // Remove all connections. | 102 // Remove all connections. |
109 void RemoveAllConnections(); | 103 void RemoveAllConnections(); |
110 | 104 |
111 // Update the sequence number for tracing performance. | 105 // Update the sequence number for tracing performance. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 // Flag that indicates recording has been started. This variable should only | 176 // Flag that indicates recording has been started. This variable should only |
183 // be used on the capture thread. | 177 // be used on the capture thread. |
184 bool is_recording_; | 178 bool is_recording_; |
185 | 179 |
186 // Per-thread flags that are set when the ScreenRecorder is | 180 // Per-thread flags that are set when the ScreenRecorder is |
187 // stopped. They must be used on the corresponding threads only. | 181 // stopped. They must be used on the corresponding threads only. |
188 bool network_stopped_; | 182 bool network_stopped_; |
189 bool encoder_stopped_; | 183 bool encoder_stopped_; |
190 | 184 |
191 // Timer that calls DoCapture. | 185 // Timer that calls DoCapture. |
192 base::RepeatingTimer<ScreenRecorder> capture_timer_; | 186 base::OneShotTimer<ScreenRecorder> capture_timer_; |
187 | |
188 // Maximum simutaneous recordings allowed. Note that this number | |
Wez
2011/10/20 00:52:15
typo: "simutaneous"
Alpha Left Google
2011/10/31 18:47:24
Done.
| |
189 // cannot exceed 2 at any time. | |
190 int max_recordings_; | |
193 | 191 |
194 // Count the number of recordings (i.e. capture or encode) happening. | 192 // Count the number of recordings (i.e. capture or encode) happening. |
195 int recordings_; | 193 int recordings_; |
196 | 194 |
197 // Set to true if we've skipped last capture because there are too | 195 // Set to true if we've skipped last capture because there are too |
198 // many pending frames. | 196 // many pending frames. |
199 int frame_skipped_; | 197 int frame_skipped_; |
200 | 198 |
201 // Number of captures to perform every second. Written on the capture thread. | |
202 double max_rate_; | |
203 | |
204 // Time when capture is started. | 199 // Time when capture is started. |
205 base::Time capture_start_time_; | 200 base::Time capture_start_time_; |
206 | 201 |
207 // Time when encode is started. | 202 // Time when encode is started. |
208 base::Time encode_start_time_; | 203 base::Time encode_start_time_; |
209 | 204 |
210 // This is a number updated by client to trace performance. | 205 // This is a number updated by client to trace performance. |
211 int64 sequence_number_; | 206 int64 sequence_number_; |
212 | 207 |
208 // An object to help throttle recording rate. | |
209 RecordingRateRegulator regulator_; | |
210 | |
213 DISALLOW_COPY_AND_ASSIGN(ScreenRecorder); | 211 DISALLOW_COPY_AND_ASSIGN(ScreenRecorder); |
214 }; | 212 }; |
215 | 213 |
216 } // namespace remoting | 214 } // namespace remoting |
217 | 215 |
218 #endif // REMOTING_HOST_SCREEN_RECORDER_H_ | 216 #endif // REMOTING_HOST_SCREEN_RECORDER_H_ |
OLD | NEW |