| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
| 23 } // namespace base | 23 } // namespace base |
| 24 | 24 |
| 25 namespace remoting { | 25 namespace remoting { |
| 26 | 26 |
| 27 class CaptureData; | 27 class CaptureData; |
| 28 class CursorShapeInfo; | 28 class CursorShapeInfo; |
| 29 class VideoFrameCapturer; | 29 class VideoFrameCapturer; |
| 30 | 30 |
| 31 namespace protocol { | 31 namespace protocol { |
| 32 class ClientStub; | |
| 33 class CursorShapeInfo; | 32 class CursorShapeInfo; |
| 33 class CursorShapeStub; |
| 34 class VideoStub; | 34 class VideoStub; |
| 35 } // namespace protocol | 35 } // namespace protocol |
| 36 | 36 |
| 37 // Class responsible for scheduling frame captures from a VideoFrameCapturer, | 37 // Class responsible for scheduling frame captures from a VideoFrameCapturer, |
| 38 // delivering them to a VideoEncoder to encode, and finally passing the encoded | 38 // delivering them to a VideoEncoder to encode, and finally passing the encoded |
| 39 // video packets to the specified VideoStub to send on the network. | 39 // video packets to the specified VideoStub to send on the network. |
| 40 // | 40 // |
| 41 // THREADING | 41 // THREADING |
| 42 // | 42 // |
| 43 // This class is supplied TaskRunners to use for capture, encode and network | 43 // This class is supplied TaskRunners to use for capture, encode and network |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // supplied TaskRunners. Video and cursor shape updates will be pumped to | 77 // supplied TaskRunners. Video and cursor shape updates will be pumped to |
| 78 // |video_stub| and |client_stub|, which must remain valid until Stop() is | 78 // |video_stub| and |client_stub|, which must remain valid until Stop() is |
| 79 // called. |capturer| is used to capture frames and must remain valid until | 79 // called. |capturer| is used to capture frames and must remain valid until |
| 80 // the |done_task| supplied to Stop() is executed. | 80 // the |done_task| supplied to Stop() is executed. |
| 81 static scoped_refptr<VideoScheduler> Create( | 81 static scoped_refptr<VideoScheduler> Create( |
| 82 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 82 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 83 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 83 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
| 84 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 84 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 85 VideoFrameCapturer* capturer, | 85 VideoFrameCapturer* capturer, |
| 86 scoped_ptr<VideoEncoder> encoder, | 86 scoped_ptr<VideoEncoder> encoder, |
| 87 protocol::ClientStub* client_stub, | 87 protocol::CursorShapeStub* cursor_stub, |
| 88 protocol::VideoStub* video_stub); | 88 protocol::VideoStub* video_stub); |
| 89 | 89 |
| 90 // VideoFrameCapturer::Delegate implementation. | 90 // VideoFrameCapturer::Delegate implementation. |
| 91 virtual void OnCaptureCompleted( | 91 virtual void OnCaptureCompleted( |
| 92 scoped_refptr<CaptureData> capture_data) OVERRIDE; | 92 scoped_refptr<CaptureData> capture_data) OVERRIDE; |
| 93 virtual void OnCursorShapeChanged( | 93 virtual void OnCursorShapeChanged( |
| 94 scoped_ptr<MouseCursorShape> cursor_shape) OVERRIDE; | 94 scoped_ptr<MouseCursorShape> cursor_shape) OVERRIDE; |
| 95 | 95 |
| 96 // Stop scheduling frame captures. |done_task| is executed on the network | 96 // Stop scheduling frame captures. |done_task| is executed on the network |
| 97 // thread when capturing has stopped. This object cannot be re-used once | 97 // thread when capturing has stopped. This object cannot be re-used once |
| (...skipping 10 matching lines...) Expand all Loading... |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 friend class base::RefCountedThreadSafe<VideoScheduler>; | 110 friend class base::RefCountedThreadSafe<VideoScheduler>; |
| 111 | 111 |
| 112 VideoScheduler( | 112 VideoScheduler( |
| 113 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 113 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 114 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 114 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
| 115 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 115 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 116 VideoFrameCapturer* capturer, | 116 VideoFrameCapturer* capturer, |
| 117 scoped_ptr<VideoEncoder> encoder, | 117 scoped_ptr<VideoEncoder> encoder, |
| 118 protocol::ClientStub* client_stub, | 118 protocol::CursorShapeStub* cursor_stub, |
| 119 protocol::VideoStub* video_stub); | 119 protocol::VideoStub* video_stub); |
| 120 virtual ~VideoScheduler(); | 120 virtual ~VideoScheduler(); |
| 121 | 121 |
| 122 // Capturer thread ---------------------------------------------------------- | 122 // Capturer thread ---------------------------------------------------------- |
| 123 | 123 |
| 124 // Starts the capturer on the capture thread. | 124 // Starts the capturer on the capture thread. |
| 125 void StartOnCaptureThread(); | 125 void StartOnCaptureThread(); |
| 126 | 126 |
| 127 // Stops scheduling frame captures on the capture thread, and posts | 127 // Stops scheduling frame captures on the capture thread, and posts |
| 128 // |done_task| to the network thread when done. | 128 // |done_task| to the network thread when done. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 166 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 167 | 167 |
| 168 // Used to capture frames. Always accessed on the capture thread. | 168 // Used to capture frames. Always accessed on the capture thread. |
| 169 VideoFrameCapturer* capturer_; | 169 VideoFrameCapturer* capturer_; |
| 170 | 170 |
| 171 // Used to encode captured frames. Always accessed on the encode thread. | 171 // Used to encode captured frames. Always accessed on the encode thread. |
| 172 scoped_ptr<VideoEncoder> encoder_; | 172 scoped_ptr<VideoEncoder> encoder_; |
| 173 | 173 |
| 174 // Interfaces through which video frames and cursor shapes are passed to the | 174 // Interfaces through which video frames and cursor shapes are passed to the |
| 175 // client. These members are always accessed on the network thread. | 175 // client. These members are always accessed on the network thread. |
| 176 protocol::ClientStub* cursor_stub_; | 176 protocol::CursorShapeStub* cursor_stub_; |
| 177 protocol::VideoStub* video_stub_; | 177 protocol::VideoStub* video_stub_; |
| 178 | 178 |
| 179 // Timer used to schedule CaptureNextFrame(). | 179 // Timer used to schedule CaptureNextFrame(). |
| 180 scoped_ptr<base::OneShotTimer<VideoScheduler> > capture_timer_; | 180 scoped_ptr<base::OneShotTimer<VideoScheduler> > capture_timer_; |
| 181 | 181 |
| 182 // Count the number of recordings (i.e. capture or encode) happening. | 182 // Count the number of recordings (i.e. capture or encode) happening. |
| 183 int pending_captures_; | 183 int pending_captures_; |
| 184 | 184 |
| 185 // True if the previous scheduled capture was skipped. | 185 // True if the previous scheduled capture was skipped. |
| 186 bool did_skip_frame_; | 186 bool did_skip_frame_; |
| 187 | 187 |
| 188 // True if capture of video frames is paused. | 188 // True if capture of video frames is paused. |
| 189 bool is_paused_; | 189 bool is_paused_; |
| 190 | 190 |
| 191 // This is a number updated by client to trace performance. | 191 // This is a number updated by client to trace performance. |
| 192 int64 sequence_number_; | 192 int64 sequence_number_; |
| 193 | 193 |
| 194 // An object to schedule capturing. | 194 // An object to schedule capturing. |
| 195 CaptureScheduler scheduler_; | 195 CaptureScheduler scheduler_; |
| 196 | 196 |
| 197 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); | 197 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 } // namespace remoting | 200 } // namespace remoting |
| 201 | 201 |
| 202 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ | 202 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ |
| OLD | NEW |