| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // | 69 // |
| 70 // VideoScheduler would ideally schedule captures so as to saturate the slowest | 70 // VideoScheduler would ideally schedule captures so as to saturate the slowest |
| 71 // 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 |
| 72 // 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 |
| 73 // too much CPU, or hogging the host's graphics subsystem. | 73 // too much CPU, or hogging the host's graphics subsystem. |
| 74 | 74 |
| 75 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, | 75 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, |
| 76 public webrtc::DesktopCapturer::Callback, | 76 public webrtc::DesktopCapturer::Callback, |
| 77 public webrtc::ScreenCapturer::MouseShapeObserver { | 77 public webrtc::ScreenCapturer::MouseShapeObserver { |
| 78 public: | 78 public: |
| 79 // Enables timestamps for generated frames. Used for testing. |
| 80 static void EnableTimestampsForTests(); |
| 81 |
| 79 // Creates a VideoScheduler running capture, encode and network tasks on the | 82 // Creates a VideoScheduler running capture, encode and network tasks on the |
| 80 // supplied TaskRunners. Video and cursor shape updates will be pumped to | 83 // supplied TaskRunners. Video and cursor shape updates will be pumped to |
| 81 // |video_stub| and |client_stub|, which must remain valid until Stop() is | 84 // |video_stub| and |client_stub|, which must remain valid until Stop() is |
| 82 // called. |capturer| is used to capture frames. | 85 // called. |capturer| is used to capture frames. |
| 83 VideoScheduler( | 86 VideoScheduler( |
| 84 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 87 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 85 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 88 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
| 86 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 89 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 87 scoped_ptr<webrtc::ScreenCapturer> capturer, | 90 scoped_ptr<webrtc::ScreenCapturer> capturer, |
| 88 scoped_ptr<VideoEncoder> encoder, | 91 scoped_ptr<VideoEncoder> encoder, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // Callback for |video_stub_| called after a keep-alive packet is sent. | 156 // Callback for |video_stub_| called after a keep-alive packet is sent. |
| 154 void OnKeepAlivePacketSent(); | 157 void OnKeepAlivePacketSent(); |
| 155 | 158 |
| 156 // Send updated cursor shape to client. | 159 // Send updated cursor shape to client. |
| 157 void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape); | 160 void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape); |
| 158 | 161 |
| 159 // Encoder thread ----------------------------------------------------------- | 162 // Encoder thread ----------------------------------------------------------- |
| 160 | 163 |
| 161 // Encode a frame, passing generated VideoPackets to SendVideoPacket(). | 164 // Encode a frame, passing generated VideoPackets to SendVideoPacket(). |
| 162 void EncodeFrame(scoped_ptr<webrtc::DesktopFrame> frame, | 165 void EncodeFrame(scoped_ptr<webrtc::DesktopFrame> frame, |
| 163 int64 sequence_number); | 166 int64 sequence_number, |
| 167 base::TimeTicks timestamp); |
| 164 | 168 |
| 165 void EncodedDataAvailableCallback(int64 sequence_number, | 169 void EncodedDataAvailableCallback(int64 sequence_number, |
| 166 scoped_ptr<VideoPacket> packet); | 170 scoped_ptr<VideoPacket> packet); |
| 167 | 171 |
| 168 // Task runners used by this class. | 172 // Task runners used by this class. |
| 169 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; | 173 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| 170 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; | 174 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
| 171 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 175 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 172 | 176 |
| 173 // Used to capture frames. Always accessed on the capture thread. | 177 // Used to capture frames. Always accessed on the capture thread. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 211 |
| 208 // An object to schedule capturing. | 212 // An object to schedule capturing. |
| 209 CaptureScheduler scheduler_; | 213 CaptureScheduler scheduler_; |
| 210 | 214 |
| 211 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); | 215 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); |
| 212 }; | 216 }; |
| 213 | 217 |
| 214 } // namespace remoting | 218 } // namespace remoting |
| 215 | 219 |
| 216 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ | 220 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ |
| OLD | NEW |