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