OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_VIDEO_SCHEDULER_H_ | 5 #ifndef REMOTING_HOST_VIDEO_SCHEDULER_H_ |
6 #define REMOTING_HOST_VIDEO_SCHEDULER_H_ | 6 #define REMOTING_HOST_VIDEO_SCHEDULER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Called when a frame capture has been encoded & sent to the client. | 133 // Called when a frame capture has been encoded & sent to the client. |
134 void FrameCaptureCompleted(); | 134 void FrameCaptureCompleted(); |
135 | 135 |
136 // Network thread ----------------------------------------------------------- | 136 // Network thread ----------------------------------------------------------- |
137 | 137 |
138 // Send |packet| to the client, unless we are in the process of stopping. | 138 // Send |packet| to the client, unless we are in the process of stopping. |
139 void SendVideoPacket(scoped_ptr<VideoPacket> packet); | 139 void SendVideoPacket(scoped_ptr<VideoPacket> packet); |
140 | 140 |
141 // Callback passed to |video_stub_| for the last packet in each frame, to | 141 // Callback passed to |video_stub_| for the last packet in each frame, to |
142 // rate-limit frame captures to network throughput. | 142 // rate-limit frame captures to network throughput. |
143 void VideoFrameSentCallback(); | 143 void OnVideoPacketSent(); |
| 144 |
| 145 // Called by |keep_alive_timer_|. |
| 146 void SendKeepAlivePacket(); |
| 147 |
| 148 // Callback for |video_stub_| called after a keep-alive packet is sent. |
| 149 void OnKeepAlivePacketSent(); |
144 | 150 |
145 // Send updated cursor shape to client. | 151 // Send updated cursor shape to client. |
146 void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape); | 152 void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape); |
147 | 153 |
148 // Encoder thread ----------------------------------------------------------- | 154 // Encoder thread ----------------------------------------------------------- |
149 | 155 |
150 // Encode a frame, passing generated VideoPackets to SendVideoPacket(). | 156 // Encode a frame, passing generated VideoPackets to SendVideoPacket(). |
151 void EncodeFrame(scoped_ptr<webrtc::DesktopFrame> frame, | 157 void EncodeFrame(scoped_ptr<webrtc::DesktopFrame> frame, |
152 int64 sequence_number); | 158 int64 sequence_number); |
153 | 159 |
(...skipping 12 matching lines...) Expand all Loading... |
166 scoped_ptr<VideoEncoder> encoder_; | 172 scoped_ptr<VideoEncoder> encoder_; |
167 | 173 |
168 // Interfaces through which video frames and cursor shapes are passed to the | 174 // Interfaces through which video frames and cursor shapes are passed to the |
169 // client. These members are always accessed on the network thread. | 175 // client. These members are always accessed on the network thread. |
170 protocol::CursorShapeStub* cursor_stub_; | 176 protocol::CursorShapeStub* cursor_stub_; |
171 protocol::VideoStub* video_stub_; | 177 protocol::VideoStub* video_stub_; |
172 | 178 |
173 // Timer used to schedule CaptureNextFrame(). | 179 // Timer used to schedule CaptureNextFrame(). |
174 scoped_ptr<base::OneShotTimer<VideoScheduler> > capture_timer_; | 180 scoped_ptr<base::OneShotTimer<VideoScheduler> > capture_timer_; |
175 | 181 |
| 182 // Timer used to ensure that we send empty keep-alive frames to the client |
| 183 // even when the video stream is paused or encoder is busy. |
| 184 scoped_ptr<base::DelayTimer<VideoScheduler> > keep_alive_timer_; |
| 185 |
176 // The number of frames being processed, i.e. frames that we are currently | 186 // The number of frames being processed, i.e. frames that we are currently |
177 // capturing, encoding or sending. The value is capped at 2 to minimize | 187 // capturing, encoding or sending. The value is capped at 2 to minimize |
178 // latency. | 188 // latency. |
179 int pending_frames_; | 189 int pending_frames_; |
180 | 190 |
181 // Set when the capturer is capturing a frame. | 191 // Set when the capturer is capturing a frame. |
182 bool capture_pending_; | 192 bool capture_pending_; |
183 | 193 |
184 // True if the previous scheduled capture was skipped. | 194 // True if the previous scheduled capture was skipped. |
185 bool did_skip_frame_; | 195 bool did_skip_frame_; |
186 | 196 |
187 // True if capture of video frames is paused. | 197 // True if capture of video frames is paused. |
188 bool is_paused_; | 198 bool is_paused_; |
189 | 199 |
190 // This is a number updated by client to trace performance. | 200 // This is a number updated by client to trace performance. |
191 int64 sequence_number_; | 201 int64 sequence_number_; |
192 | 202 |
193 // An object to schedule capturing. | 203 // An object to schedule capturing. |
194 CaptureScheduler scheduler_; | 204 CaptureScheduler scheduler_; |
195 | 205 |
196 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); | 206 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); |
197 }; | 207 }; |
198 | 208 |
199 } // namespace remoting | 209 } // namespace remoting |
200 | 210 |
201 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ | 211 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ |
OLD | NEW |