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