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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // 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 |
74 // too much CPU, or hogging the host's graphics subsystem. | 74 // too much CPU, or hogging the host's graphics subsystem. |
75 | 75 |
76 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, | 76 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, |
77 public media::ScreenCapturer::Delegate { | 77 public media::ScreenCapturer::Delegate { |
78 public: | 78 public: |
79 // Creates a VideoScheduler running capture, encode and network tasks on the | 79 // Creates a VideoScheduler running capture, encode and network tasks on the |
80 // supplied TaskRunners. Video and cursor shape updates will be pumped to | 80 // supplied TaskRunners. Video and cursor shape updates will be pumped to |
81 // |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 |
82 // called. |capturer| is used to capture frames. | 82 // called. |capturer| is used to capture frames. |
83 static scoped_refptr<VideoScheduler> Create( | 83 VideoScheduler( |
84 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 84 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
85 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 85 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
86 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 86 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
87 scoped_ptr<media::ScreenCapturer> capturer, | 87 scoped_ptr<media::ScreenCapturer> capturer, |
88 scoped_ptr<VideoEncoder> encoder, | 88 scoped_ptr<VideoEncoder> encoder, |
89 protocol::CursorShapeStub* cursor_stub, | 89 protocol::CursorShapeStub* cursor_stub, |
90 protocol::VideoStub* video_stub); | 90 protocol::VideoStub* video_stub); |
91 | 91 |
92 // media::ScreenCapturer::Delegate implementation. | 92 // media::ScreenCapturer::Delegate implementation. |
93 virtual void OnCaptureCompleted( | 93 virtual void OnCaptureCompleted( |
94 scoped_refptr<media::ScreenCaptureData> capture_data) OVERRIDE; | 94 scoped_refptr<media::ScreenCaptureData> capture_data) OVERRIDE; |
95 virtual void OnCursorShapeChanged( | 95 virtual void OnCursorShapeChanged( |
96 scoped_ptr<media::MouseCursorShape> cursor_shape) OVERRIDE; | 96 scoped_ptr<media::MouseCursorShape> cursor_shape) OVERRIDE; |
97 | 97 |
| 98 // Starts scheduling frame captures. |
| 99 void Start(); |
| 100 |
98 // Stop scheduling frame captures. This object cannot be re-used once | 101 // Stop scheduling frame captures. This object cannot be re-used once |
99 // it has been stopped. | 102 // it has been stopped. |
100 void Stop(); | 103 void Stop(); |
101 | 104 |
102 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures | 105 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures |
103 // only affects capture scheduling and does not stop/start the capturer. | 106 // only affects capture scheduling and does not stop/start the capturer. |
104 void Pause(bool pause); | 107 void Pause(bool pause); |
105 | 108 |
106 // Updates the sequence number embedded in VideoPackets. | 109 // Updates the sequence number embedded in VideoPackets. |
107 // Sequence numbers are used for performance measurements. | 110 // Sequence numbers are used for performance measurements. |
108 void UpdateSequenceNumber(int64 sequence_number); | 111 void UpdateSequenceNumber(int64 sequence_number); |
109 | 112 |
110 private: | 113 private: |
111 friend class base::RefCountedThreadSafe<VideoScheduler>; | 114 friend class base::RefCountedThreadSafe<VideoScheduler>; |
112 | |
113 VideoScheduler( | |
114 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | |
115 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | |
116 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | |
117 scoped_ptr<media::ScreenCapturer> capturer, | |
118 scoped_ptr<VideoEncoder> encoder, | |
119 protocol::CursorShapeStub* cursor_stub, | |
120 protocol::VideoStub* video_stub); | |
121 virtual ~VideoScheduler(); | 115 virtual ~VideoScheduler(); |
122 | 116 |
123 // Capturer thread ---------------------------------------------------------- | 117 // Capturer thread ---------------------------------------------------------- |
124 | 118 |
125 // Starts the capturer on the capture thread. | 119 // Starts the capturer on the capture thread. |
126 void StartOnCaptureThread(); | 120 void StartOnCaptureThread(); |
127 | 121 |
128 // Stops scheduling frame captures on the capture thread, and posts | 122 // Stops scheduling frame captures on the capture thread, and posts |
129 // StopOnEncodeThread() to the network thread when done. | 123 // StopOnEncodeThread() to the network thread when done. |
130 void StopOnCaptureThread(); | 124 void StopOnCaptureThread(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 188 |
195 // An object to schedule capturing. | 189 // An object to schedule capturing. |
196 CaptureScheduler scheduler_; | 190 CaptureScheduler scheduler_; |
197 | 191 |
198 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); | 192 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); |
199 }; | 193 }; |
200 | 194 |
201 } // namespace remoting | 195 } // namespace remoting |
202 | 196 |
203 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ | 197 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ |
OLD | NEW |