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" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "remoting/codec/video_encoder.h" | 15 #include "remoting/codec/video_encoder.h" |
16 #include "remoting/proto/video.pb.h" | 16 #include "remoting/proto/video.pb.h" |
| 17 #include "remoting/protocol/video_stub.h" |
17 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" | 18 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
18 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" | 19 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
22 } // namespace base | 23 } // namespace base |
23 | 24 |
24 namespace media { | 25 namespace media { |
25 class DesktopCapturer; | 26 class DesktopCapturer; |
26 } // namespace media | 27 } // namespace media |
27 | 28 |
28 namespace remoting { | 29 namespace remoting { |
29 | 30 |
30 class CaptureScheduler; | 31 class CaptureScheduler; |
31 class CursorShapeInfo; | 32 class CursorShapeInfo; |
32 | 33 |
33 namespace protocol { | 34 namespace protocol { |
34 class CursorShapeInfo; | 35 class CursorShapeInfo; |
35 class CursorShapeStub; | 36 class CursorShapeStub; |
36 class VideoStub; | |
37 } // namespace protocol | 37 } // namespace protocol |
38 | 38 |
39 // Class responsible for scheduling frame captures from a | 39 // Class responsible for scheduling frame captures from a |
40 // webrtc::DesktopCapturer, delivering them to a VideoEncoder to encode, and | 40 // webrtc::DesktopCapturer, delivering them to a VideoEncoder to encode, and |
41 // finally passing the encoded video packets to the specified VideoStub to send | 41 // finally passing the encoded video packets to the specified VideoStub to send |
42 // on the network. | 42 // on the network. |
43 // | 43 // |
44 // THREADING | 44 // THREADING |
45 // | 45 // |
46 // This class is supplied TaskRunners to use for capture, encode and network | 46 // This class is supplied TaskRunners to use for capture, encode and network |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // webrtc::DesktopCapturer::Callback implementation. | 123 // webrtc::DesktopCapturer::Callback implementation. |
124 webrtc::SharedMemory* CreateSharedMemory(size_t size) override; | 124 webrtc::SharedMemory* CreateSharedMemory(size_t size) override; |
125 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; | 125 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; |
126 | 126 |
127 // webrtc::MouseCursorMonitor::Callback implementation. | 127 // webrtc::MouseCursorMonitor::Callback implementation. |
128 void OnMouseCursor(webrtc::MouseCursor* mouse_cursor) override; | 128 void OnMouseCursor(webrtc::MouseCursor* mouse_cursor) override; |
129 void OnMouseCursorPosition(webrtc::MouseCursorMonitor::CursorState state, | 129 void OnMouseCursorPosition(webrtc::MouseCursorMonitor::CursorState state, |
130 const webrtc::DesktopVector& position) override; | 130 const webrtc::DesktopVector& position) override; |
131 | 131 |
132 // Starts the capturer on the capture thread. | 132 // Starts the capturer on the capture thread. |
133 void StartOnCaptureThread(); | 133 void StartOnCaptureThread(bool acks_supported); |
134 | 134 |
135 // Stops scheduling frame captures on the capture thread. | 135 // Stops scheduling frame captures on the capture thread. |
136 void StopOnCaptureThread(); | 136 void StopOnCaptureThread(); |
137 | 137 |
138 // Starts the next frame capture, unless there are already too many pending. | 138 // Starts the next frame capture, unless there are already too many pending. |
139 void CaptureNextFrame(); | 139 void CaptureNextFrame(); |
140 | 140 |
141 // Called when a frame has been encoded. | 141 // Called when a frame has been encoded. |
142 void ProcessFrameEncodedOnCaptureThread(base::TimeDelta encode_time); | 142 void ProcessFrameEncodedOnCaptureThread(base::TimeDelta encode_time); |
143 | 143 |
144 // Called when a frame has been sent to the client. | 144 // Called when a frame has been sent to the client. |
145 void ProcessFrameSentOnCaptureThread(); | 145 void ProcessFrameSentOnCaptureThread(); |
146 | 146 |
| 147 // Called when a frame has been sent to the client. |
| 148 void ProcessFrameAckOnCaptureThread(); |
| 149 |
147 // Network thread ----------------------------------------------------------- | 150 // Network thread ----------------------------------------------------------- |
148 | 151 |
149 // Send |packet| to the client, unless we are in the process of stopping. | 152 // Send |packet| to the client, unless we are in the process of stopping. |
150 void SendVideoPacket(scoped_ptr<VideoPacket> packet); | 153 void SendVideoPacket(scoped_ptr<VideoPacket> packet); |
151 | 154 |
152 // Callback passed to |video_stub_| for the last packet in each frame, to | 155 // Callback passed to |video_stub_|, to |
153 // rate-limit frame captures to network throughput. | 156 // rate-limit frame captures to network throughput. |
154 void OnVideoPacketSent(); | 157 void OnVideoPacketProgress(protocol::VideoStub::PacketProgress progress); |
155 | 158 |
156 // Called by |keep_alive_timer_|. | 159 // Called by |keep_alive_timer_|. |
157 void SendKeepAlivePacket(); | 160 void SendKeepAlivePacket(); |
158 | 161 |
159 // Callback for |video_stub_| called after a keep-alive packet is sent. | 162 // Callback for |video_stub_| called after a keep-alive packet is sent. |
160 void OnKeepAlivePacketSent(); | 163 void OnKeepAlivePacketProgress(protocol::VideoStub::PacketProgress progress); |
161 | 164 |
162 // Send updated cursor shape to client. | 165 // Send updated cursor shape to client. |
163 void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape); | 166 void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape); |
164 | 167 |
165 // Encoder thread ----------------------------------------------------------- | 168 // Encoder thread ----------------------------------------------------------- |
166 | 169 |
167 // Encode a frame, passing generated VideoPackets to SendVideoPacket(). | 170 // Encode a frame, passing generated VideoPackets to SendVideoPacket(). |
168 void EncodeFrame(scoped_ptr<webrtc::DesktopFrame> frame, | 171 void EncodeFrame(scoped_ptr<webrtc::DesktopFrame> frame, |
169 int64 latest_event_timestamp, | 172 int64 latest_event_timestamp, |
170 base::TimeTicks timestamp); | 173 base::TimeTicks timestamp); |
(...skipping 28 matching lines...) Expand all Loading... |
199 int64 latest_event_timestamp_; | 202 int64 latest_event_timestamp_; |
200 | 203 |
201 scoped_ptr<CaptureScheduler> capture_scheduler_; | 204 scoped_ptr<CaptureScheduler> capture_scheduler_; |
202 | 205 |
203 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); | 206 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); |
204 }; | 207 }; |
205 | 208 |
206 } // namespace remoting | 209 } // namespace remoting |
207 | 210 |
208 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ | 211 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ |
OLD | NEW |