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/mouse_cursor_monitor.h" |
18 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 19 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.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 ScreenCapturer; | 26 class ScreenCapturer; |
26 } // namespace media | 27 } // namespace media |
27 | 28 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // | Time | 68 // | Time |
68 // v | 69 // v |
69 // | 70 // |
70 // VideoScheduler would ideally schedule captures so as to saturate the slowest | 71 // VideoScheduler would ideally schedule captures so as to saturate the slowest |
71 // of the capture, encode and network processes. However, it also needs to | 72 // of the capture, encode and network processes. However, it also needs to |
72 // rate-limit captures to avoid overloading the host system, either by consuming | 73 // rate-limit captures to avoid overloading the host system, either by consuming |
73 // too much CPU, or hogging the host's graphics subsystem. | 74 // too much CPU, or hogging the host's graphics subsystem. |
74 | 75 |
75 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, | 76 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, |
76 public webrtc::DesktopCapturer::Callback, | 77 public webrtc::DesktopCapturer::Callback, |
77 public webrtc::ScreenCapturer::MouseShapeObserver { | 78 public webrtc::MouseCursorMonitor::Callback { |
78 public: | 79 public: |
79 // Enables timestamps for generated frames. Used for testing. | 80 // Enables timestamps for generated frames. Used for testing. |
80 static void EnableTimestampsForTests(); | 81 static void EnableTimestampsForTests(); |
81 | 82 |
82 // Creates a VideoScheduler running capture, encode and network tasks on the | 83 // Creates a VideoScheduler running capture, encode and network tasks on the |
83 // supplied TaskRunners. Video and cursor shape updates will be pumped to | 84 // supplied TaskRunners. Video and cursor shape updates will be pumped to |
84 // |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 |
85 // called. |capturer| is used to capture frames. | 86 // called. |capturer| is used to capture frames. |
86 VideoScheduler( | 87 VideoScheduler( |
87 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 88 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
88 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 89 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
89 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 90 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
90 scoped_ptr<webrtc::ScreenCapturer> capturer, | 91 scoped_ptr<webrtc::ScreenCapturer> capturer, |
| 92 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor, |
91 scoped_ptr<VideoEncoder> encoder, | 93 scoped_ptr<VideoEncoder> encoder, |
92 protocol::CursorShapeStub* cursor_stub, | 94 protocol::CursorShapeStub* cursor_stub, |
93 protocol::VideoStub* video_stub); | 95 protocol::VideoStub* video_stub); |
94 | 96 |
95 // webrtc::DesktopCapturer::Callback implementation. | 97 // webrtc::DesktopCapturer::Callback implementation. |
96 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; | 98 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; |
97 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; | 99 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; |
98 | 100 |
99 // webrtc::ScreenCapturer::MouseShapeObserver implementation. | 101 // webrtc::MouseCursorMonitor::Callback implementation. |
100 virtual void OnCursorShapeChanged( | 102 virtual void OnMouseCursor( |
101 webrtc::MouseCursorShape* cursor_shape) OVERRIDE; | 103 webrtc::MouseCursor* mouse_cursor) OVERRIDE; |
| 104 virtual void OnMouseCursorPosition( |
| 105 webrtc::MouseCursorMonitor::CursorState state, |
| 106 const webrtc::DesktopVector& position) OVERRIDE; |
102 | 107 |
103 // Starts scheduling frame captures. | 108 // Starts scheduling frame captures. |
104 void Start(); | 109 void Start(); |
105 | 110 |
106 // Stop scheduling frame captures. This object cannot be re-used once | 111 // Stop scheduling frame captures. This object cannot be re-used once |
107 // it has been stopped. | 112 // it has been stopped. |
108 void Stop(); | 113 void Stop(); |
109 | 114 |
110 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures | 115 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures |
111 // only affects capture scheduling and does not stop/start the capturer. | 116 // only affects capture scheduling and does not stop/start the capturer. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 scoped_ptr<VideoPacket> packet); | 175 scoped_ptr<VideoPacket> packet); |
171 | 176 |
172 // Task runners used by this class. | 177 // Task runners used by this class. |
173 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; | 178 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
174 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; | 179 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
175 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 180 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
176 | 181 |
177 // Used to capture frames. Always accessed on the capture thread. | 182 // Used to capture frames. Always accessed on the capture thread. |
178 scoped_ptr<webrtc::ScreenCapturer> capturer_; | 183 scoped_ptr<webrtc::ScreenCapturer> capturer_; |
179 | 184 |
| 185 // Used to capture mouse cursor shapes. Always accessed on the capture thread. |
| 186 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_; |
| 187 |
180 // Used to encode captured frames. Always accessed on the encode thread. | 188 // Used to encode captured frames. Always accessed on the encode thread. |
181 scoped_ptr<VideoEncoder> encoder_; | 189 scoped_ptr<VideoEncoder> encoder_; |
182 | 190 |
183 // 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 |
184 // client. These members are always accessed on the network thread. | 192 // client. These members are always accessed on the network thread. |
185 protocol::CursorShapeStub* cursor_stub_; | 193 protocol::CursorShapeStub* cursor_stub_; |
186 protocol::VideoStub* video_stub_; | 194 protocol::VideoStub* video_stub_; |
187 | 195 |
188 // Timer used to schedule CaptureNextFrame(). | 196 // Timer used to schedule CaptureNextFrame(). |
189 scoped_ptr<base::OneShotTimer<VideoScheduler> > capture_timer_; | 197 scoped_ptr<base::OneShotTimer<VideoScheduler> > capture_timer_; |
(...skipping 21 matching lines...) Expand all Loading... |
211 | 219 |
212 // An object to schedule capturing. | 220 // An object to schedule capturing. |
213 CaptureScheduler scheduler_; | 221 CaptureScheduler scheduler_; |
214 | 222 |
215 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); | 223 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); |
216 }; | 224 }; |
217 | 225 |
218 } // namespace remoting | 226 } // namespace remoting |
219 | 227 |
220 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ | 228 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ |
OLD | NEW |