| 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 // Creates a VideoScheduler running capture, encode and network tasks on the | 80 // Creates a VideoScheduler running capture, encode and network tasks on the |
| 80 // supplied TaskRunners. Video and cursor shape updates will be pumped to | 81 // supplied TaskRunners. Video and cursor shape updates will be pumped to |
| 81 // |video_stub| and |client_stub|, which must remain valid until Stop() is | 82 // |video_stub| and |client_stub|, which must remain valid until Stop() is |
| 82 // called. |capturer| is used to capture frames. | 83 // called. |capturer| is used to capture frames. |
| 83 VideoScheduler( | 84 VideoScheduler( |
| 84 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 85 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 85 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 86 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
| 86 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 87 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 87 scoped_ptr<webrtc::ScreenCapturer> capturer, | 88 scoped_ptr<webrtc::ScreenCapturer> capturer, |
| 89 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor, |
| 88 scoped_ptr<VideoEncoder> encoder, | 90 scoped_ptr<VideoEncoder> encoder, |
| 89 protocol::CursorShapeStub* cursor_stub, | 91 protocol::CursorShapeStub* cursor_stub, |
| 90 protocol::VideoStub* video_stub); | 92 protocol::VideoStub* video_stub); |
| 91 | 93 |
| 92 // webrtc::DesktopCapturer::Callback implementation. | 94 // webrtc::DesktopCapturer::Callback implementation. |
| 93 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; | 95 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; |
| 94 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; | 96 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; |
| 95 | 97 |
| 96 // webrtc::ScreenCapturer::MouseShapeObserver implementation. | 98 // webrtc::MouseCursorMonitor::Callback implementation. |
| 97 virtual void OnCursorShapeChanged( | 99 virtual void OnMouseCursor( |
| 98 webrtc::MouseCursorShape* cursor_shape) OVERRIDE; | 100 webrtc::MouseCursor* mouse_cursor) OVERRIDE; |
| 101 virtual void OnMouseCursorPosition( |
| 102 webrtc::MouseCursorMonitor::CursorState state, |
| 103 const webrtc::DesktopVector& position) OVERRIDE; |
| 99 | 104 |
| 100 // Starts scheduling frame captures. | 105 // Starts scheduling frame captures. |
| 101 void Start(); | 106 void Start(); |
| 102 | 107 |
| 103 // Stop scheduling frame captures. This object cannot be re-used once | 108 // Stop scheduling frame captures. This object cannot be re-used once |
| 104 // it has been stopped. | 109 // it has been stopped. |
| 105 void Stop(); | 110 void Stop(); |
| 106 | 111 |
| 107 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures | 112 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures |
| 108 // only affects capture scheduling and does not stop/start the capturer. | 113 // only affects capture scheduling and does not stop/start the capturer. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 scoped_ptr<VideoPacket> packet); | 160 scoped_ptr<VideoPacket> packet); |
| 156 | 161 |
| 157 // Task runners used by this class. | 162 // Task runners used by this class. |
| 158 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; | 163 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| 159 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; | 164 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
| 160 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 165 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 161 | 166 |
| 162 // Used to capture frames. Always accessed on the capture thread. | 167 // Used to capture frames. Always accessed on the capture thread. |
| 163 scoped_ptr<webrtc::ScreenCapturer> capturer_; | 168 scoped_ptr<webrtc::ScreenCapturer> capturer_; |
| 164 | 169 |
| 170 // Used to capture mouse cursor shapes. Always accessed on the capture thread. |
| 171 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_; |
| 172 |
| 165 // Used to encode captured frames. Always accessed on the encode thread. | 173 // Used to encode captured frames. Always accessed on the encode thread. |
| 166 scoped_ptr<VideoEncoder> encoder_; | 174 scoped_ptr<VideoEncoder> encoder_; |
| 167 | 175 |
| 168 // Interfaces through which video frames and cursor shapes are passed to the | 176 // Interfaces through which video frames and cursor shapes are passed to the |
| 169 // client. These members are always accessed on the network thread. | 177 // client. These members are always accessed on the network thread. |
| 170 protocol::CursorShapeStub* cursor_stub_; | 178 protocol::CursorShapeStub* cursor_stub_; |
| 171 protocol::VideoStub* video_stub_; | 179 protocol::VideoStub* video_stub_; |
| 172 | 180 |
| 173 // Timer used to schedule CaptureNextFrame(). | 181 // Timer used to schedule CaptureNextFrame(). |
| 174 scoped_ptr<base::OneShotTimer<VideoScheduler> > capture_timer_; | 182 scoped_ptr<base::OneShotTimer<VideoScheduler> > capture_timer_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 192 | 200 |
| 193 // An object to schedule capturing. | 201 // An object to schedule capturing. |
| 194 CaptureScheduler scheduler_; | 202 CaptureScheduler scheduler_; |
| 195 | 203 |
| 196 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); | 204 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); |
| 197 }; | 205 }; |
| 198 | 206 |
| 199 } // namespace remoting | 207 } // namespace remoting |
| 200 | 208 |
| 201 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ | 209 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ |
| OLD | NEW |