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

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

Issue 1472873005: Add VideoStream interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_video_pump
Patch Set: Created 5 years 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/protocol/protocol_mock_objects.cc ('k') | remoting/protocol/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 2015 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_PROTOCOL_VIDEO_FRAME_PUMP_H_ 5 #ifndef REMOTING_PROTOCOL_VIDEO_FRAME_PUMP_H_
6 #define REMOTING_PROTOCOL_VIDEO_FRAME_PUMP_H_ 6 #define REMOTING_PROTOCOL_VIDEO_FRAME_PUMP_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
12 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
13 #include "base/time/time.h" 12 #include "base/time/time.h"
14 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
15 #include "remoting/codec/video_encoder.h" 14 #include "remoting/codec/video_encoder.h"
16 #include "remoting/proto/video.pb.h" 15 #include "remoting/proto/video.pb.h"
17 #include "remoting/protocol/capture_scheduler.h" 16 #include "remoting/protocol/capture_scheduler.h"
17 #include "remoting/protocol/video_stream.h"
18 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 18 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.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 remoting { 24 namespace remoting {
25 namespace protocol { 25 namespace protocol {
26 26
27 class VideoFeedbackStub; 27 class VideoFeedbackStub;
(...skipping 28 matching lines...) Expand all
56 // | . . 56 // | . .
57 // | . . 57 // | . .
58 // | ............ 58 // | ............
59 // | Time 59 // | Time
60 // v 60 // v
61 // 61 //
62 // VideoFramePump would ideally schedule captures so as to saturate the slowest 62 // VideoFramePump would ideally schedule captures so as to saturate the slowest
63 // of the capture, encode and network processes. However, it also needs to 63 // of the capture, encode and network processes. However, it also needs to
64 // rate-limit captures to avoid overloading the host system, either by consuming 64 // rate-limit captures to avoid overloading the host system, either by consuming
65 // too much CPU, or hogging the host's graphics subsystem. 65 // too much CPU, or hogging the host's graphics subsystem.
66 class VideoFramePump : public webrtc::DesktopCapturer::Callback { 66 class VideoFramePump : public VideoStream,
67 public webrtc::DesktopCapturer::Callback {
67 public: 68 public:
68 // Enables timestamps for generated frames. Used for testing. 69 // Enables timestamps for generated frames. Used for testing.
69 static void EnableTimestampsForTests(); 70 static void EnableTimestampsForTests();
70 71
71 // Creates a VideoFramePump running capture, encode and network tasks on the 72 // Creates a VideoFramePump running capture, encode and network tasks on the
72 // supplied TaskRunners. Video will be pumped to |video_stub|, which must 73 // supplied TaskRunners. Video will be pumped to |video_stub|, which must
73 // outlive the pump.. 74 // outlive the pump..
74 VideoFramePump( 75 VideoFramePump(
75 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, 76 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
76 scoped_ptr<webrtc::DesktopCapturer> capturer, 77 scoped_ptr<webrtc::DesktopCapturer> capturer,
77 scoped_ptr<VideoEncoder> encoder, 78 scoped_ptr<VideoEncoder> encoder,
78 protocol::VideoStub* video_stub); 79 protocol::VideoStub* video_stub);
79 ~VideoFramePump() override; 80 ~VideoFramePump() override;
80 81
81 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures 82 // VideoStream interface.
82 // only affects capture scheduling and does not stop/start the capturer. 83 void Pause(bool pause) override;
83 void Pause(bool pause); 84 void OnInputEventReceived(int64_t event_timestamp) override;
84 85 void SetLosslessEncode(bool want_lossless) override;
85 // Called whenever input event is received. 86 void SetLosslessColor(bool want_lossless) override;
86 void OnInputEventReceived(int64_t event_timestamp); 87 void SetSizeCallback(const SizeCallback& size_callback) override;
87
88 // Sets whether the video encoder should be requested to encode losslessly,
89 // or to use a lossless color space (typically requiring higher bandwidth).
90 void SetLosslessEncode(bool want_lossless);
91 void SetLosslessColor(bool want_lossless);
92 88
93 protocol::VideoFeedbackStub* video_feedback_stub() { 89 protocol::VideoFeedbackStub* video_feedback_stub() {
94 return &capture_scheduler_; 90 return &capture_scheduler_;
95 } 91 }
96 92
97 private: 93 private:
98 struct FrameTimestamps { 94 struct FrameTimestamps {
99 FrameTimestamps(); 95 FrameTimestamps();
100 ~FrameTimestamps(); 96 ~FrameTimestamps();
101 97
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 155
160 // Capturer used to capture the screen. 156 // Capturer used to capture the screen.
161 scoped_ptr<webrtc::DesktopCapturer> capturer_; 157 scoped_ptr<webrtc::DesktopCapturer> capturer_;
162 158
163 // Used to encode captured frames. Always accessed on the encode thread. 159 // Used to encode captured frames. Always accessed on the encode thread.
164 scoped_ptr<VideoEncoder> encoder_; 160 scoped_ptr<VideoEncoder> encoder_;
165 161
166 // Interface through which video frames are passed to the client. 162 // Interface through which video frames are passed to the client.
167 protocol::VideoStub* video_stub_; 163 protocol::VideoStub* video_stub_;
168 164
165 SizeCallback size_callback_;
166 webrtc::DesktopSize frame_size_;
167
169 // Timer used to ensure that we send empty keep-alive frames to the client 168 // Timer used to ensure that we send empty keep-alive frames to the client
170 // even when the video stream is paused or encoder is busy. 169 // even when the video stream is paused or encoder is busy.
171 base::Timer keep_alive_timer_; 170 base::Timer keep_alive_timer_;
172 171
173 // CaptureScheduler calls CaptureNextFrame() whenever a new frame needs to be 172 // CaptureScheduler calls CaptureNextFrame() whenever a new frame needs to be
174 // captured. 173 // captured.
175 CaptureScheduler capture_scheduler_; 174 CaptureScheduler capture_scheduler_;
176 175
177 // Timestamps for the frame to be captured next. 176 // Timestamps for the frame to be captured next.
178 scoped_ptr<FrameTimestamps> next_frame_timestamps_; 177 scoped_ptr<FrameTimestamps> next_frame_timestamps_;
179 178
180 // Timestamps for the frame that's being captured. 179 // Timestamps for the frame that's being captured.
181 scoped_ptr<FrameTimestamps> captured_frame_timestamps_; 180 scoped_ptr<FrameTimestamps> captured_frame_timestamps_;
182 181
183 bool send_pending_ = false; 182 bool send_pending_ = false;
184 183
185 ScopedVector<PacketWithTimestamps> pending_packets_; 184 ScopedVector<PacketWithTimestamps> pending_packets_;
186 185
187 base::ThreadChecker thread_checker_; 186 base::ThreadChecker thread_checker_;
188 187
189 base::WeakPtrFactory<VideoFramePump> weak_factory_; 188 base::WeakPtrFactory<VideoFramePump> weak_factory_;
190 189
191 DISALLOW_COPY_AND_ASSIGN(VideoFramePump); 190 DISALLOW_COPY_AND_ASSIGN(VideoFramePump);
192 }; 191 };
193 192
194 } // namespace protocol 193 } // namespace protocol
195 } // namespace remoting 194 } // namespace remoting
196 195
197 #endif // REMOTING_PROTOCOL_VIDEO_FRAME_PUMP_H_ 196 #endif // REMOTING_PROTOCOL_VIDEO_FRAME_PUMP_H_
OLDNEW
« no previous file with comments | « remoting/protocol/protocol_mock_objects.cc ('k') | remoting/protocol/video_frame_pump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698