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

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

Issue 893353002: Rename VideoScheduler->VideoFramePipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scheduler_cleanup
Patch Set: Created 5 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
« no previous file with comments | « remoting/host/client_session_unittest.cc ('k') | remoting/host/video_frame_pump.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 2015 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_FRAME_PUMP_H_
6 #define REMOTING_HOST_VIDEO_SCHEDULER_H_ 6 #define REMOTING_HOST_VIDEO_FRAME_PUMP_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/proto/video.pb.h" 16 #include "remoting/proto/video.pb.h"
17 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 17 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
18 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" 18 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
19 19
20 namespace base { 20 namespace base {
21 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
22 } // namespace base 22 } // namespace base
23 23
24 namespace media { 24 namespace media {
25 class DesktopCapturer; 25 class DesktopCapturer;
26 } // namespace media 26 } // namespace media
27 27
28 namespace remoting { 28 namespace remoting {
29 29
30 class CaptureScheduler; 30 class CaptureScheduler;
31 class CursorShapeInfo;
32 31
33 namespace protocol { 32 namespace protocol {
34 class CursorShapeInfo; 33 class CursorShapeInfo;
35 class CursorShapeStub; 34 class CursorShapeStub;
36 class VideoStub; 35 class VideoStub;
37 } // namespace protocol 36 } // namespace protocol
38 37
39 // Class responsible for scheduling frame captures from a 38 // Class responsible for scheduling frame captures from a
40 // webrtc::DesktopCapturer, delivering them to a VideoEncoder to encode, and 39 // webrtc::DesktopCapturer, delivering them to a VideoEncoder to encode, and
41 // finally passing the encoded video packets to the specified VideoStub to send 40 // finally passing the encoded video packets to the specified VideoStub to send
(...skipping 19 matching lines...) Expand all
61 // | ............. ............ .......... 60 // | ............. ............ ..........
62 // | . Capture . . . . Send . 61 // | . Capture . . . . Send .
63 // | ............. . . .......... 62 // | ............. . . ..........
64 // | . Encode . 63 // | . Encode .
65 // | . . 64 // | . .
66 // | . . 65 // | . .
67 // | ............ 66 // | ............
68 // | Time 67 // | Time
69 // v 68 // v
70 // 69 //
71 // VideoScheduler would ideally schedule captures so as to saturate the slowest 70 // VideoFramePump would ideally schedule captures so as to saturate the slowest
72 // 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
73 // 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
74 // too much CPU, or hogging the host's graphics subsystem. 73 // too much CPU, or hogging the host's graphics subsystem.
75 // 74 //
76 // TODO(sergeyu): Rename this class to VideoFramePipe. 75 // TODO(sergeyu): Rename this class to VideoFramePump.
77 class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, 76 class VideoFramePump : public base::RefCountedThreadSafe<VideoFramePump>,
78 public webrtc::DesktopCapturer::Callback, 77 public webrtc::DesktopCapturer::Callback,
79 public webrtc::MouseCursorMonitor::Callback { 78 public webrtc::MouseCursorMonitor::Callback {
80 public: 79 public:
81 // Enables timestamps for generated frames. Used for testing. 80 // Enables timestamps for generated frames. Used for testing.
82 static void EnableTimestampsForTests(); 81 static void EnableTimestampsForTests();
83 82
84 // Creates a VideoScheduler running capture, encode and network tasks on the 83 // Creates a VideoFramePump running capture, encode and network tasks on the
85 // supplied TaskRunners. Video and cursor shape updates will be pumped to 84 // supplied TaskRunners. Video and cursor shape updates will be pumped to
86 // |video_stub| and |client_stub|, which must remain valid until Stop() is 85 // |video_stub| and |client_stub|, which must remain valid until Stop() is
87 // called. |capturer| is used to capture frames. 86 // called. |capturer| is used to capture frames.
88 VideoScheduler( 87 VideoFramePump(
89 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, 88 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
90 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, 89 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
91 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 90 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
92 scoped_ptr<webrtc::DesktopCapturer> capturer, 91 scoped_ptr<webrtc::DesktopCapturer> capturer,
93 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor, 92 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor,
94 scoped_ptr<VideoEncoder> encoder, 93 scoped_ptr<VideoEncoder> encoder,
95 protocol::CursorShapeStub* cursor_stub, 94 protocol::CursorShapeStub* cursor_stub,
96 protocol::VideoStub* video_stub); 95 protocol::VideoStub* video_stub);
97 96
98 // Starts scheduling frame captures. 97 // Starts scheduling frame captures.
(...skipping 10 matching lines...) Expand all
109 // Updates event timestamp from the last event received from the client. This 108 // Updates event timestamp from the last event received from the client. This
110 // value is sent back to the client for roundtrip latency estimates. 109 // value is sent back to the client for roundtrip latency estimates.
111 void SetLatestEventTimestamp(int64 latest_event_timestamp); 110 void SetLatestEventTimestamp(int64 latest_event_timestamp);
112 111
113 // Sets whether the video encoder should be requested to encode losslessly, 112 // Sets whether the video encoder should be requested to encode losslessly,
114 // or to use a lossless color space (typically requiring higher bandwidth). 113 // or to use a lossless color space (typically requiring higher bandwidth).
115 void SetLosslessEncode(bool want_lossless); 114 void SetLosslessEncode(bool want_lossless);
116 void SetLosslessColor(bool want_lossless); 115 void SetLosslessColor(bool want_lossless);
117 116
118 private: 117 private:
119 friend class base::RefCountedThreadSafe<VideoScheduler>; 118 friend class base::RefCountedThreadSafe<VideoFramePump>;
120 ~VideoScheduler() override; 119 ~VideoFramePump() override;
121 120
122 // Capturer thread ---------------------------------------------------------- 121 // Capturer thread ----------------------------------------------------------
123 122
124 // TODO(sergeyu): Move all methods that run on the capture thread to a 123 // TODO(sergeyu): Move all methods that run on the capture thread to a
125 // separate class and make VideoScheduler not ref-counted. 124 // separate class and make VideoFramePump not ref-counted.
126 125
127 // webrtc::DesktopCapturer::Callback implementation. 126 // webrtc::DesktopCapturer::Callback implementation.
128 webrtc::SharedMemory* CreateSharedMemory(size_t size) override; 127 webrtc::SharedMemory* CreateSharedMemory(size_t size) override;
129 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; 128 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override;
130 129
131 // webrtc::MouseCursorMonitor::Callback implementation. 130 // webrtc::MouseCursorMonitor::Callback implementation.
132 void OnMouseCursor(webrtc::MouseCursor* mouse_cursor) override; 131 void OnMouseCursor(webrtc::MouseCursor* mouse_cursor) override;
133 void OnMouseCursorPosition(webrtc::MouseCursorMonitor::CursorState state, 132 void OnMouseCursorPosition(webrtc::MouseCursorMonitor::CursorState state,
134 const webrtc::DesktopVector& position) override; 133 const webrtc::DesktopVector& position) override;
135 134
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // Used to encode captured frames. Always accessed on the encode thread. 181 // Used to encode captured frames. Always accessed on the encode thread.
183 scoped_ptr<VideoEncoder> encoder_; 182 scoped_ptr<VideoEncoder> encoder_;
184 183
185 // Interfaces through which video frames and cursor shapes are passed to the 184 // Interfaces through which video frames and cursor shapes are passed to the
186 // client. These members are always accessed on the network thread. 185 // client. These members are always accessed on the network thread.
187 protocol::CursorShapeStub* cursor_stub_; 186 protocol::CursorShapeStub* cursor_stub_;
188 protocol::VideoStub* video_stub_; 187 protocol::VideoStub* video_stub_;
189 188
190 // Timer used to ensure that we send empty keep-alive frames to the client 189 // Timer used to ensure that we send empty keep-alive frames to the client
191 // even when the video stream is paused or encoder is busy. 190 // even when the video stream is paused or encoder is busy.
192 scoped_ptr<base::DelayTimer<VideoScheduler> > keep_alive_timer_; 191 scoped_ptr<base::DelayTimer<VideoFramePump> > keep_alive_timer_;
193 192
194 // Number updated by the caller to trace performance. 193 // Number updated by the caller to trace performance.
195 int64 latest_event_timestamp_; 194 int64 latest_event_timestamp_;
196 195
197 scoped_ptr<CaptureScheduler> capture_scheduler_; 196 scoped_ptr<CaptureScheduler> capture_scheduler_;
198 197
199 DISALLOW_COPY_AND_ASSIGN(VideoScheduler); 198 DISALLOW_COPY_AND_ASSIGN(VideoFramePump);
200 }; 199 };
201 200
202 } // namespace remoting 201 } // namespace remoting
203 202
204 #endif // REMOTING_HOST_VIDEO_SCHEDULER_H_ 203 #endif // REMOTING_HOST_VIDEO_FRAME_PUMP_H_
OLDNEW
« no previous file with comments | « remoting/host/client_session_unittest.cc ('k') | remoting/host/video_frame_pump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698