Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: remoting/host/video_scheduler.h

Issue 12047101: Move screen capturers from remoting/capturer to media/video/capturer/screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/sas_injector_win.cc ('k') | remoting/host/video_scheduler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 13 #include "base/time.h"
14 #include "base/timer.h" 14 #include "base/timer.h"
15 #include "remoting/capturer/video_frame_capturer.h" 15 #include "media/video/capture/screen/screen_capturer.h"
16 #include "remoting/codec/video_encoder.h" 16 #include "remoting/codec/video_encoder.h"
17 #include "remoting/host/capture_scheduler.h" 17 #include "remoting/host/capture_scheduler.h"
18 #include "remoting/proto/video.pb.h" 18 #include "remoting/proto/video.pb.h"
19 #include "third_party/skia/include/core/SkSize.h" 19 #include "third_party/skia/include/core/SkSize.h"
20 20
21 namespace base { 21 namespace base {
22 class SingleThreadTaskRunner; 22 class SingleThreadTaskRunner;
23 } // namespace base 23 } // namespace base
24 24
25 namespace media {
26 class ScreenCaptureData;
27 class ScreenCapturer;
28 } // namespace media
29
25 namespace remoting { 30 namespace remoting {
26 31
27 class CaptureData;
28 class CursorShapeInfo; 32 class CursorShapeInfo;
29 class VideoFrameCapturer;
30 33
31 namespace protocol { 34 namespace protocol {
32 class CursorShapeInfo; 35 class CursorShapeInfo;
33 class CursorShapeStub; 36 class CursorShapeStub;
34 class VideoStub; 37 class VideoStub;
35 } // namespace protocol 38 } // namespace protocol
36 39
37 // Class responsible for scheduling frame captures from a VideoFrameCapturer, 40 // Class responsible for scheduling frame captures from a media::ScreenCapturer,
38 // delivering them to a VideoEncoder to encode, and finally passing the encoded 41 // delivering them to a VideoEncoder to encode, and finally passing the encoded
39 // video packets to the specified VideoStub to send on the network. 42 // video packets to the specified VideoStub to send on the network.
40 // 43 //
41 // THREADING 44 // THREADING
42 // 45 //
43 // This class is supplied TaskRunners to use for capture, encode and network 46 // This class is supplied TaskRunners to use for capture, encode and network
44 // operations. Capture, encode and network transmission tasks are interleaved 47 // operations. Capture, encode and network transmission tasks are interleaved
45 // as illustrated below: 48 // as illustrated below:
46 // 49 //
47 // | CAPTURE ENCODE NETWORK 50 // | CAPTURE ENCODE NETWORK
(...skipping 16 matching lines...) Expand all
64 // | ............ 67 // | ............
65 // | Time 68 // | Time
66 // v 69 // v
67 // 70 //
68 // VideoScheduler would ideally schedule captures so as to saturate the slowest 71 // VideoScheduler would ideally schedule captures so as to saturate the slowest
69 // of the capture, encode and network processes. However, it also needs to 72 // of the capture, encode and network processes. However, it also needs to
70 // 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
71 // too much CPU, or hogging the host's graphics subsystem. 74 // too much CPU, or hogging the host's graphics subsystem.
72 75
73 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, 76 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>,
74 public VideoFrameCapturer::Delegate { 77 public media::ScreenCapturer::Delegate {
75 public: 78 public:
76 // Creates a VideoScheduler running capture, encode and network tasks on the 79 // Creates a VideoScheduler running capture, encode and network tasks on the
77 // supplied TaskRunners. Video and cursor shape updates will be pumped to 80 // supplied TaskRunners. Video and cursor shape updates will be pumped to
78 // |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
79 // called. |capturer| is used to capture frames. 82 // called. |capturer| is used to capture frames.
80 static scoped_refptr<VideoScheduler> Create( 83 static scoped_refptr<VideoScheduler> Create(
81 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, 84 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
82 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, 85 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
83 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 86 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
84 scoped_ptr<VideoFrameCapturer> capturer, 87 scoped_ptr<media::ScreenCapturer> capturer,
85 scoped_ptr<VideoEncoder> encoder, 88 scoped_ptr<VideoEncoder> encoder,
86 protocol::CursorShapeStub* cursor_stub, 89 protocol::CursorShapeStub* cursor_stub,
87 protocol::VideoStub* video_stub); 90 protocol::VideoStub* video_stub);
88 91
89 // VideoFrameCapturer::Delegate implementation. 92 // media::ScreenCapturer::Delegate implementation.
90 virtual void OnCaptureCompleted( 93 virtual void OnCaptureCompleted(
91 scoped_refptr<CaptureData> capture_data) OVERRIDE; 94 scoped_refptr<media::ScreenCaptureData> capture_data) OVERRIDE;
92 virtual void OnCursorShapeChanged( 95 virtual void OnCursorShapeChanged(
93 scoped_ptr<MouseCursorShape> cursor_shape) OVERRIDE; 96 scoped_ptr<media::MouseCursorShape> cursor_shape) OVERRIDE;
94 97
95 // Stop scheduling frame captures. This object cannot be re-used once 98 // Stop scheduling frame captures. This object cannot be re-used once
96 // it has been stopped. 99 // it has been stopped.
97 void Stop(); 100 void Stop();
98 101
99 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures 102 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures
100 // only affects capture scheduling and does not stop/start the capturer. 103 // only affects capture scheduling and does not stop/start the capturer.
101 void Pause(bool pause); 104 void Pause(bool pause);
102 105
103 // Updates the sequence number embedded in VideoPackets. 106 // Updates the sequence number embedded in VideoPackets.
104 // Sequence numbers are used for performance measurements. 107 // Sequence numbers are used for performance measurements.
105 void UpdateSequenceNumber(int64 sequence_number); 108 void UpdateSequenceNumber(int64 sequence_number);
106 109
107 private: 110 private:
108 friend class base::RefCountedThreadSafe<VideoScheduler>; 111 friend class base::RefCountedThreadSafe<VideoScheduler>;
109 112
110 VideoScheduler( 113 VideoScheduler(
111 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, 114 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
112 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, 115 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
113 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 116 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
114 scoped_ptr<VideoFrameCapturer> capturer, 117 scoped_ptr<media::ScreenCapturer> capturer,
115 scoped_ptr<VideoEncoder> encoder, 118 scoped_ptr<VideoEncoder> encoder,
116 protocol::CursorShapeStub* cursor_stub, 119 protocol::CursorShapeStub* cursor_stub,
117 protocol::VideoStub* video_stub); 120 protocol::VideoStub* video_stub);
118 virtual ~VideoScheduler(); 121 virtual ~VideoScheduler();
119 122
120 // Capturer thread ---------------------------------------------------------- 123 // Capturer thread ----------------------------------------------------------
121 124
122 // Starts the capturer on the capture thread. 125 // Starts the capturer on the capture thread.
123 void StartOnCaptureThread(); 126 void StartOnCaptureThread();
124 127
(...skipping 17 matching lines...) Expand all
142 145
143 // Callback passed to |video_stub_| for the last packet in each frame, to 146 // Callback passed to |video_stub_| for the last packet in each frame, to
144 // rate-limit frame captures to network throughput. 147 // rate-limit frame captures to network throughput.
145 void VideoFrameSentCallback(); 148 void VideoFrameSentCallback();
146 149
147 // Send updated cursor shape to client. 150 // Send updated cursor shape to client.
148 void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape); 151 void SendCursorShape(scoped_ptr<protocol::CursorShapeInfo> cursor_shape);
149 152
150 // Posted to the network thread to delete |capturer| on the thread that 153 // Posted to the network thread to delete |capturer| on the thread that
151 // created it. 154 // created it.
152 void StopOnNetworkThread(scoped_ptr<VideoFrameCapturer> capturer); 155 void StopOnNetworkThread(scoped_ptr<media::ScreenCapturer> capturer);
153 156
154 // Encoder thread ----------------------------------------------------------- 157 // Encoder thread -----------------------------------------------------------
155 158
156 // Encode a frame, passing generated VideoPackets to SendVideoPacket(). 159 // Encode a frame, passing generated VideoPackets to SendVideoPacket().
157 void EncodeFrame(scoped_refptr<CaptureData> capture_data); 160 void EncodeFrame(scoped_refptr<media::ScreenCaptureData> capture_data);
158 161
159 void EncodedDataAvailableCallback(scoped_ptr<VideoPacket> packet); 162 void EncodedDataAvailableCallback(scoped_ptr<VideoPacket> packet);
160 163
161 // Used to synchronize capture and encode thread teardown, notifying the 164 // Used to synchronize capture and encode thread teardown, notifying the
162 // network thread when done. 165 // network thread when done.
163 void StopOnEncodeThread(scoped_ptr<VideoFrameCapturer> capturer); 166 void StopOnEncodeThread(scoped_ptr<media::ScreenCapturer> capturer);
164 167
165 // Task runners used by this class. 168 // Task runners used by this class.
166 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; 169 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
167 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; 170 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
168 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 171 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
169 172
170 // Used to capture frames. Always accessed on the capture thread. 173 // Used to capture frames. Always accessed on the capture thread.
171 scoped_ptr<VideoFrameCapturer> capturer_; 174 scoped_ptr<media::ScreenCapturer> capturer_;
172 175
173 // Used to encode captured frames. Always accessed on the encode thread. 176 // Used to encode captured frames. Always accessed on the encode thread.
174 scoped_ptr<VideoEncoder> encoder_; 177 scoped_ptr<VideoEncoder> encoder_;
175 178
176 // Interfaces through which video frames and cursor shapes are passed to the 179 // Interfaces through which video frames and cursor shapes are passed to the
177 // client. These members are always accessed on the network thread. 180 // client. These members are always accessed on the network thread.
178 protocol::CursorShapeStub* cursor_stub_; 181 protocol::CursorShapeStub* cursor_stub_;
179 protocol::VideoStub* video_stub_; 182 protocol::VideoStub* video_stub_;
180 183
181 // Timer used to schedule CaptureNextFrame(). 184 // Timer used to schedule CaptureNextFrame().
(...skipping 13 matching lines...) Expand all
195 198
196 // An object to schedule capturing. 199 // An object to schedule capturing.
197 CaptureScheduler scheduler_; 200 CaptureScheduler scheduler_;
198 201
199 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); 202 DISALLOW_COPY_AND_ASSIGN(VideoScheduler);
200 }; 203 };
201 204
202 } // namespace remoting 205 } // namespace remoting
203 206
204 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ 207 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_
OLDNEW
« no previous file with comments | « remoting/host/sas_injector_win.cc ('k') | remoting/host/video_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698