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/host/capture_scheduler.h" | 16 #include "remoting/host/capture_scheduler.h" |
17 #include "remoting/proto/video.pb.h" | 17 #include "remoting/proto/video.pb.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 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
23 } // namespace base | 23 } // namespace base |
24 | 24 |
25 namespace media { | 25 namespace media { |
26 class ScreenCapturer; | 26 class DesktopCapturer; |
27 } // namespace media | 27 } // namespace media |
28 | 28 |
29 namespace remoting { | 29 namespace remoting { |
30 | 30 |
31 class CursorShapeInfo; | 31 class CursorShapeInfo; |
32 | 32 |
33 namespace protocol { | 33 namespace protocol { |
34 class CursorShapeInfo; | 34 class CursorShapeInfo; |
35 class CursorShapeStub; | 35 class CursorShapeStub; |
36 class VideoStub; | 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::ScreenCapturer, 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 |
47 // operations. Capture, encode and network transmission tasks are interleaved | 47 // operations. Capture, encode and network transmission tasks are interleaved |
48 // as illustrated below: | 48 // as illustrated below: |
49 // | 49 // |
50 // | CAPTURE ENCODE NETWORK | 50 // | CAPTURE ENCODE NETWORK |
(...skipping 30 matching lines...) Expand all Loading... |
81 static void EnableTimestampsForTests(); | 81 static void EnableTimestampsForTests(); |
82 | 82 |
83 // Creates a VideoScheduler running capture, encode and network tasks on the | 83 // Creates a VideoScheduler running capture, encode and network tasks on the |
84 // supplied TaskRunners. Video and cursor shape updates will be pumped to | 84 // supplied TaskRunners. Video and cursor shape updates will be pumped to |
85 // |video_stub| and |client_stub|, which must remain valid until Stop() is | 85 // |video_stub| and |client_stub|, which must remain valid until Stop() is |
86 // called. |capturer| is used to capture frames. | 86 // called. |capturer| is used to capture frames. |
87 VideoScheduler( | 87 VideoScheduler( |
88 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 88 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
89 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 89 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
90 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 90 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
91 scoped_ptr<webrtc::ScreenCapturer> capturer, | 91 scoped_ptr<webrtc::DesktopCapturer> capturer, |
92 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor, | 92 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor, |
93 scoped_ptr<VideoEncoder> encoder, | 93 scoped_ptr<VideoEncoder> encoder, |
94 protocol::CursorShapeStub* cursor_stub, | 94 protocol::CursorShapeStub* cursor_stub, |
95 protocol::VideoStub* video_stub); | 95 protocol::VideoStub* video_stub); |
96 | 96 |
97 // webrtc::DesktopCapturer::Callback implementation. | 97 // webrtc::DesktopCapturer::Callback implementation. |
98 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; | 98 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; |
99 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; | 99 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; |
100 | 100 |
101 // webrtc::MouseCursorMonitor::Callback implementation. | 101 // webrtc::MouseCursorMonitor::Callback implementation. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 void EncodedDataAvailableCallback(int64 sequence_number, | 174 void EncodedDataAvailableCallback(int64 sequence_number, |
175 scoped_ptr<VideoPacket> packet); | 175 scoped_ptr<VideoPacket> packet); |
176 | 176 |
177 // Task runners used by this class. | 177 // Task runners used by this class. |
178 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; | 178 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
179 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; | 179 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
180 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 180 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
181 | 181 |
182 // Used to capture frames. Always accessed on the capture thread. | 182 // Used to capture frames. Always accessed on the capture thread. |
183 scoped_ptr<webrtc::ScreenCapturer> capturer_; | 183 scoped_ptr<webrtc::DesktopCapturer> capturer_; |
184 | 184 |
185 // Used to capture mouse cursor shapes. Always accessed on the capture thread. | 185 // Used to capture mouse cursor shapes. Always accessed on the capture thread. |
186 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_; | 186 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_; |
187 | 187 |
188 // Used to encode captured frames. Always accessed on the encode thread. | 188 // Used to encode captured frames. Always accessed on the encode thread. |
189 scoped_ptr<VideoEncoder> encoder_; | 189 scoped_ptr<VideoEncoder> encoder_; |
190 | 190 |
191 // Interfaces through which video frames and cursor shapes are passed to the | 191 // Interfaces through which video frames and cursor shapes are passed to the |
192 // client. These members are always accessed on the network thread. | 192 // client. These members are always accessed on the network thread. |
193 protocol::CursorShapeStub* cursor_stub_; | 193 protocol::CursorShapeStub* cursor_stub_; |
(...skipping 25 matching lines...) Expand all Loading... |
219 | 219 |
220 // An object to schedule capturing. | 220 // An object to schedule capturing. |
221 CaptureScheduler scheduler_; | 221 CaptureScheduler scheduler_; |
222 | 222 |
223 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); | 223 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); |
224 }; | 224 }; |
225 | 225 |
226 } // namespace remoting | 226 } // namespace remoting |
227 | 227 |
228 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ | 228 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ |
OLD | NEW |