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

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

Issue 872433005: Move capture scheduling logic from VideoScheduler to CaptureScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 #include "remoting/host/video_scheduler.h" 5 #include "remoting/host/video_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop_proxy.h" 13 #include "base/message_loop/message_loop_proxy.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "remoting/host/capture_scheduler.h"
17 #include "remoting/proto/control.pb.h" 18 #include "remoting/proto/control.pb.h"
18 #include "remoting/proto/internal.pb.h" 19 #include "remoting/proto/internal.pb.h"
19 #include "remoting/proto/video.pb.h" 20 #include "remoting/proto/video.pb.h"
20 #include "remoting/protocol/cursor_shape_stub.h" 21 #include "remoting/protocol/cursor_shape_stub.h"
21 #include "remoting/protocol/message_decoder.h" 22 #include "remoting/protocol/message_decoder.h"
22 #include "remoting/protocol/video_stub.h" 23 #include "remoting/protocol/video_stub.h"
23 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 24 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
24 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 25 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
25 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" 26 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
26 27
27 namespace remoting { 28 namespace remoting {
28 29
29 // Maximum number of frames that can be processed simultaneously.
30 // TODO(hclam): Move this value to CaptureScheduler.
31 static const int kMaxPendingFrames = 2;
32
33 // Interval between empty keep-alive frames. These frames are sent only when the 30 // Interval between empty keep-alive frames. These frames are sent only when the
34 // stream is paused or inactive for some other reason (e.g. when blocked on 31 // stream is paused or inactive for some other reason (e.g. when blocked on
35 // capturer). To prevent PseudoTCP from resetting congestion window this value 32 // capturer). To prevent PseudoTCP from resetting congestion window this value
36 // must be smaller than the minimum RTO used in PseudoTCP, which is 250ms. 33 // must be smaller than the minimum RTO used in PseudoTCP, which is 250ms.
37 static const int kKeepAlivePacketIntervalMs = 200; 34 static const int kKeepAlivePacketIntervalMs = 200;
38 35
39 static bool g_enable_timestamps = false; 36 static bool g_enable_timestamps = false;
40 37
41 // static 38 // static
42 void VideoScheduler::EnableTimestampsForTests() { 39 void VideoScheduler::EnableTimestampsForTests() {
(...skipping 10 matching lines...) Expand all
53 protocol::CursorShapeStub* cursor_stub, 50 protocol::CursorShapeStub* cursor_stub,
54 protocol::VideoStub* video_stub) 51 protocol::VideoStub* video_stub)
55 : capture_task_runner_(capture_task_runner), 52 : capture_task_runner_(capture_task_runner),
56 encode_task_runner_(encode_task_runner), 53 encode_task_runner_(encode_task_runner),
57 network_task_runner_(network_task_runner), 54 network_task_runner_(network_task_runner),
58 capturer_(capturer.Pass()), 55 capturer_(capturer.Pass()),
59 mouse_cursor_monitor_(mouse_cursor_monitor.Pass()), 56 mouse_cursor_monitor_(mouse_cursor_monitor.Pass()),
60 encoder_(encoder.Pass()), 57 encoder_(encoder.Pass()),
61 cursor_stub_(cursor_stub), 58 cursor_stub_(cursor_stub),
62 video_stub_(video_stub), 59 video_stub_(video_stub),
63 pending_frames_(0),
64 capture_pending_(false),
65 did_skip_frame_(false),
66 is_paused_(false),
67 latest_event_timestamp_(0) { 60 latest_event_timestamp_(0) {
68 DCHECK(network_task_runner_->BelongsToCurrentThread()); 61 DCHECK(network_task_runner_->BelongsToCurrentThread());
69 DCHECK(capturer_); 62 DCHECK(capturer_);
70 DCHECK(mouse_cursor_monitor_); 63 DCHECK(mouse_cursor_monitor_);
71 DCHECK(encoder_); 64 DCHECK(encoder_);
72 DCHECK(cursor_stub_); 65 DCHECK(cursor_stub_);
73 DCHECK(video_stub_); 66 DCHECK(video_stub_);
74 } 67 }
75 68
76 // Public methods -------------------------------------------------------------- 69 // Public methods --------------------------------------------------------------
77 70
78 webrtc::SharedMemory* VideoScheduler::CreateSharedMemory(size_t size) { 71 webrtc::SharedMemory* VideoScheduler::CreateSharedMemory(size_t size) {
79 return nullptr; 72 return nullptr;
80 } 73 }
81 74
82 void VideoScheduler::OnCaptureCompleted(webrtc::DesktopFrame* frame) {
83 DCHECK(capture_task_runner_->BelongsToCurrentThread());
84
85 capture_pending_ = false;
86
87 scoped_ptr<webrtc::DesktopFrame> owned_frame(frame);
88
89 if (owned_frame) {
90 scheduler_.RecordCaptureTime(
91 base::TimeDelta::FromMilliseconds(owned_frame->capture_time_ms()));
92 }
93
94 // Even when |frame| is nullptr we still need to post it to the encode thread
95 // to make sure frames are freed in the same order they are received and
96 // that we don't start capturing frame n+2 before frame n is freed.
97 encode_task_runner_->PostTask(
98 FROM_HERE, base::Bind(&VideoScheduler::EncodeFrame, this,
99 base::Passed(&owned_frame), latest_event_timestamp_,
100 base::TimeTicks::Now()));
101
102 // If a frame was skipped, try to capture it again.
103 if (did_skip_frame_) {
104 capture_task_runner_->PostTask(
105 FROM_HERE, base::Bind(&VideoScheduler::CaptureNextFrame, this));
106 }
107 }
108
109 void VideoScheduler::OnMouseCursor(webrtc::MouseCursor* cursor) {
110 DCHECK(capture_task_runner_->BelongsToCurrentThread());
111
112 scoped_ptr<webrtc::MouseCursor> owned_cursor(cursor);
113
114 // Do nothing if the scheduler is being stopped.
115 if (!capturer_)
116 return;
117
118 scoped_ptr<protocol::CursorShapeInfo> cursor_proto(
119 new protocol::CursorShapeInfo());
120 cursor_proto->set_width(cursor->image()->size().width());
121 cursor_proto->set_height(cursor->image()->size().height());
122 cursor_proto->set_hotspot_x(cursor->hotspot().x());
123 cursor_proto->set_hotspot_y(cursor->hotspot().y());
124
125 cursor_proto->set_data(std::string());
126 uint8_t* current_row = cursor->image()->data();
127 for (int y = 0; y < cursor->image()->size().height(); ++y) {
128 cursor_proto->mutable_data()->append(
129 current_row,
130 current_row + cursor->image()->size().width() *
131 webrtc::DesktopFrame::kBytesPerPixel);
132 current_row += cursor->image()->stride();
133 }
134
135 network_task_runner_->PostTask(
136 FROM_HERE, base::Bind(&VideoScheduler::SendCursorShape, this,
137 base::Passed(&cursor_proto)));
138 }
139
140 void VideoScheduler::OnMouseCursorPosition(
141 webrtc::MouseCursorMonitor::CursorState state,
142 const webrtc::DesktopVector& position) {
143 // We're not subscribing to mouse position changes.
144 NOTREACHED();
145 }
146
147 void VideoScheduler::Start() { 75 void VideoScheduler::Start() {
148 DCHECK(network_task_runner_->BelongsToCurrentThread()); 76 DCHECK(network_task_runner_->BelongsToCurrentThread());
149 77
78 keep_alive_timer_.reset(new base::DelayTimer<VideoScheduler>(
79 FROM_HERE, base::TimeDelta::FromMilliseconds(kKeepAlivePacketIntervalMs),
80 this, &VideoScheduler::SendKeepAlivePacket));
81
150 capture_task_runner_->PostTask( 82 capture_task_runner_->PostTask(
151 FROM_HERE, base::Bind(&VideoScheduler::StartOnCaptureThread, this)); 83 FROM_HERE, base::Bind(&VideoScheduler::StartOnCaptureThread, this));
152 } 84 }
153 85
154 void VideoScheduler::Stop() { 86 void VideoScheduler::Stop() {
155 DCHECK(network_task_runner_->BelongsToCurrentThread()); 87 DCHECK(network_task_runner_->BelongsToCurrentThread());
156 88
157 // Clear stubs to prevent further updates reaching the client. 89 // Clear stubs to prevent further updates reaching the client.
158 cursor_stub_ = nullptr; 90 cursor_stub_ = nullptr;
159 video_stub_ = nullptr; 91 video_stub_ = nullptr;
160 92
161 keep_alive_timer_.reset(); 93 keep_alive_timer_.reset();
162 94
163 capture_task_runner_->PostTask( 95 capture_task_runner_->PostTask(
164 FROM_HERE, base::Bind(&VideoScheduler::StopOnCaptureThread, this)); 96 FROM_HERE, base::Bind(&VideoScheduler::StopOnCaptureThread, this));
165 } 97 }
166 98
167 void VideoScheduler::Pause(bool pause) { 99 void VideoScheduler::Pause(bool pause) {
168 if (!capture_task_runner_->BelongsToCurrentThread()) { 100 if (!capture_task_runner_->BelongsToCurrentThread()) {
169 DCHECK(network_task_runner_->BelongsToCurrentThread()); 101 DCHECK(network_task_runner_->BelongsToCurrentThread());
170 capture_task_runner_->PostTask( 102 capture_task_runner_->PostTask(
171 FROM_HERE, base::Bind(&VideoScheduler::Pause, this, pause)); 103 FROM_HERE, base::Bind(&VideoScheduler::Pause, this, pause));
172 return; 104 return;
173 } 105 }
174 106
175 if (is_paused_ != pause) { 107 if (capture_scheduler_)
176 is_paused_ = pause; 108 capture_scheduler_->Pause(pause);
177
178 // Restart captures if we're resuming and there are none scheduled.
179 if (!is_paused_ && capture_timer_ && !capture_timer_->IsRunning())
180 CaptureNextFrame();
181 }
182 } 109 }
183 110
184 void VideoScheduler::SetLatestEventTimestamp(int64 latest_event_timestamp) { 111 void VideoScheduler::SetLatestEventTimestamp(int64 latest_event_timestamp) {
185 if (!capture_task_runner_->BelongsToCurrentThread()) { 112 if (!capture_task_runner_->BelongsToCurrentThread()) {
186 DCHECK(network_task_runner_->BelongsToCurrentThread()); 113 DCHECK(network_task_runner_->BelongsToCurrentThread());
187 capture_task_runner_->PostTask( 114 capture_task_runner_->PostTask(
188 FROM_HERE, base::Bind(&VideoScheduler::SetLatestEventTimestamp, 115 FROM_HERE, base::Bind(&VideoScheduler::SetLatestEventTimestamp,
189 this, latest_event_timestamp)); 116 this, latest_event_timestamp));
190 return; 117 return;
191 } 118 }
(...skipping 29 matching lines...) Expand all
221 148
222 VideoScheduler::~VideoScheduler() { 149 VideoScheduler::~VideoScheduler() {
223 // Destroy the capturer and encoder on their respective threads. 150 // Destroy the capturer and encoder on their respective threads.
224 capture_task_runner_->DeleteSoon(FROM_HERE, capturer_.release()); 151 capture_task_runner_->DeleteSoon(FROM_HERE, capturer_.release());
225 capture_task_runner_->DeleteSoon(FROM_HERE, mouse_cursor_monitor_.release()); 152 capture_task_runner_->DeleteSoon(FROM_HERE, mouse_cursor_monitor_.release());
226 encode_task_runner_->DeleteSoon(FROM_HERE, encoder_.release()); 153 encode_task_runner_->DeleteSoon(FROM_HERE, encoder_.release());
227 } 154 }
228 155
229 // Capturer thread ------------------------------------------------------------- 156 // Capturer thread -------------------------------------------------------------
230 157
158 void VideoScheduler::OnCaptureCompleted(webrtc::DesktopFrame* frame) {
159 DCHECK(capture_task_runner_->BelongsToCurrentThread());
160
161 // Even when |frame| is nullptr we still need to post it to the encode thread
162 // to make sure frames are freed in the same order they are received and
163 // that we don't start capturing frame n+2 before frame n is freed.
164 encode_task_runner_->PostTask(
165 FROM_HERE, base::Bind(&VideoScheduler::EncodeFrame, this,
166 base::Passed(make_scoped_ptr(frame)),
167 latest_event_timestamp_, base::TimeTicks::Now()));
168
169 capture_scheduler_->OnCaptureCompleted();
170 }
171
172 void VideoScheduler::OnMouseCursor(webrtc::MouseCursor* cursor) {
173 DCHECK(capture_task_runner_->BelongsToCurrentThread());
174
175 scoped_ptr<webrtc::MouseCursor> owned_cursor(cursor);
176
177 scoped_ptr<protocol::CursorShapeInfo> cursor_proto(
178 new protocol::CursorShapeInfo());
179 cursor_proto->set_width(cursor->image()->size().width());
180 cursor_proto->set_height(cursor->image()->size().height());
181 cursor_proto->set_hotspot_x(cursor->hotspot().x());
182 cursor_proto->set_hotspot_y(cursor->hotspot().y());
183
184 cursor_proto->set_data(std::string());
185 uint8_t* current_row = cursor->image()->data();
186 for (int y = 0; y < cursor->image()->size().height(); ++y) {
187 cursor_proto->mutable_data()->append(
188 current_row,
189 current_row + cursor->image()->size().width() *
190 webrtc::DesktopFrame::kBytesPerPixel);
191 current_row += cursor->image()->stride();
192 }
193
194 network_task_runner_->PostTask(
195 FROM_HERE, base::Bind(&VideoScheduler::SendCursorShape, this,
196 base::Passed(&cursor_proto)));
197 }
198
199 void VideoScheduler::OnMouseCursorPosition(
200 webrtc::MouseCursorMonitor::CursorState state,
201 const webrtc::DesktopVector& position) {
202 // We're not subscribing to mouse position changes.
203 NOTREACHED();
204 }
205
231 void VideoScheduler::StartOnCaptureThread() { 206 void VideoScheduler::StartOnCaptureThread() {
232 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 207 DCHECK(capture_task_runner_->BelongsToCurrentThread());
233 DCHECK(!capture_timer_); 208 DCHECK(!capture_scheduler_);
234 209
235 // Start mouse cursor monitor.
236 mouse_cursor_monitor_->Init(this, webrtc::MouseCursorMonitor::SHAPE_ONLY); 210 mouse_cursor_monitor_->Init(this, webrtc::MouseCursorMonitor::SHAPE_ONLY);
237
238 // Start the capturer.
239 capturer_->Start(this); 211 capturer_->Start(this);
240 212
241 capture_timer_.reset(new base::OneShotTimer<VideoScheduler>()); 213 capture_scheduler_.reset(new CaptureScheduler(
242 keep_alive_timer_.reset(new base::DelayTimer<VideoScheduler>( 214 base::Bind(&VideoScheduler::CaptureNextFrame, this)));
243 FROM_HERE, base::TimeDelta::FromMilliseconds(kKeepAlivePacketIntervalMs), 215 capture_scheduler_->Start();
244 this, &VideoScheduler::SendKeepAlivePacket));
245
246 // Capture first frame immediately.
247 CaptureNextFrame();
248 } 216 }
249 217
250 void VideoScheduler::StopOnCaptureThread() { 218 void VideoScheduler::StopOnCaptureThread() {
251 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 219 DCHECK(capture_task_runner_->BelongsToCurrentThread());
252 220
253 // This doesn't deleted already captured frames, so encoder can keep using the 221 // This doesn't deleted already captured frames, so encoder can keep using the
254 // frames that were captured previously. 222 // frames that were captured previously.
255 capturer_.reset(); 223 capturer_.reset();
256 224
257 // |capture_timer_| must be destroyed on the thread on which it is used. 225 mouse_cursor_monitor_.reset();
258 capture_timer_.reset(); 226 capture_scheduler_.reset();
259 }
260
261 void VideoScheduler::ScheduleNextCapture() {
262 DCHECK(capture_task_runner_->BelongsToCurrentThread());
263
264 capture_timer_->Start(FROM_HERE,
265 scheduler_.NextCaptureDelay(),
266 this,
267 &VideoScheduler::CaptureNextFrame);
268 } 227 }
269 228
270 void VideoScheduler::CaptureNextFrame() { 229 void VideoScheduler::CaptureNextFrame() {
271 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 230 DCHECK(capture_task_runner_->BelongsToCurrentThread());
272 231
273 // If we are stopping (|capturer_| is nullptr), or paused, then don't capture. 232 // Capture mouse shape first and then screen content.
274 if (!capturer_ || is_paused_)
275 return;
276
277 // Make sure we have at most two outstanding recordings. We can simply return
278 // if we can't make a capture now, the next capture will be started by the
279 // end of an encode operation.
280 if (pending_frames_ >= kMaxPendingFrames || capture_pending_) {
281 did_skip_frame_ = true;
282 return;
283 }
284
285 did_skip_frame_ = false;
286
287 // At this point we are going to perform one capture so save the current time.
288 pending_frames_++;
289 DCHECK_LE(pending_frames_, kMaxPendingFrames);
290
291 // Before doing a capture schedule for the next one.
292 ScheduleNextCapture();
293
294 capture_pending_ = true;
295
296 // Capture the mouse shape.
297 mouse_cursor_monitor_->Capture(); 233 mouse_cursor_monitor_->Capture();
298
299 // And finally perform one capture.
300 capturer_->Capture(webrtc::DesktopRegion()); 234 capturer_->Capture(webrtc::DesktopRegion());
301 } 235 }
302 236
303 void VideoScheduler::FrameCaptureCompleted() { 237 void VideoScheduler::ProcessFrameEncodedOnCaptureThread(
238 base::TimeDelta encode_time) {
304 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 239 DCHECK(capture_task_runner_->BelongsToCurrentThread());
305 240
306 // Decrement the pending capture count. 241 if (capture_scheduler_)
307 pending_frames_--; 242 capture_scheduler_->OnFrameEncoded(encode_time);
308 DCHECK_GE(pending_frames_, 0); 243 }
309 244
310 // If we've skipped a frame capture because too we had too many captures 245 void VideoScheduler::ProcessFrameSentOnCaptureThread() {
311 // pending then schedule one now. 246 DCHECK(capture_task_runner_->BelongsToCurrentThread());
312 if (did_skip_frame_) 247
313 CaptureNextFrame(); 248 if (capture_scheduler_)
249 capture_scheduler_->OnFrameSent();
314 } 250 }
315 251
316 // Network thread -------------------------------------------------------------- 252 // Network thread --------------------------------------------------------------
317 253
318 void VideoScheduler::SendVideoPacket(scoped_ptr<VideoPacket> packet) { 254 void VideoScheduler::SendVideoPacket(scoped_ptr<VideoPacket> packet) {
319 DCHECK(network_task_runner_->BelongsToCurrentThread()); 255 DCHECK(network_task_runner_->BelongsToCurrentThread());
320 256
321 if (!video_stub_) 257 if (!video_stub_)
322 return; 258 return;
323 259
324 video_stub_->ProcessVideoPacket( 260 video_stub_->ProcessVideoPacket(
325 packet.Pass(), base::Bind(&VideoScheduler::OnVideoPacketSent, this)); 261 packet.Pass(), base::Bind(&VideoScheduler::OnVideoPacketSent, this));
326 } 262 }
327 263
328 void VideoScheduler::OnVideoPacketSent() { 264 void VideoScheduler::OnVideoPacketSent() {
329 DCHECK(network_task_runner_->BelongsToCurrentThread()); 265 DCHECK(network_task_runner_->BelongsToCurrentThread());
330 266
331 if (!video_stub_) 267 if (!video_stub_)
332 return; 268 return;
333 269
334 keep_alive_timer_->Reset(); 270 keep_alive_timer_->Reset();
335 271
336 capture_task_runner_->PostTask( 272 capture_task_runner_->PostTask(
337 FROM_HERE, base::Bind(&VideoScheduler::FrameCaptureCompleted, this)); 273 FROM_HERE,
274 base::Bind(&VideoScheduler::ProcessFrameSentOnCaptureThread, this));
338 } 275 }
339 276
340 void VideoScheduler::SendKeepAlivePacket() { 277 void VideoScheduler::SendKeepAlivePacket() {
341 DCHECK(network_task_runner_->BelongsToCurrentThread()); 278 DCHECK(network_task_runner_->BelongsToCurrentThread());
342 279
343 if (!video_stub_) 280 if (!video_stub_)
344 return; 281 return;
345 282
346 video_stub_->ProcessVideoPacket( 283 video_stub_->ProcessVideoPacket(
347 make_scoped_ptr(new VideoPacket()), 284 make_scoped_ptr(new VideoPacket()),
(...skipping 18 matching lines...) Expand all
366 } 303 }
367 304
368 // Encoder thread -------------------------------------------------------------- 305 // Encoder thread --------------------------------------------------------------
369 306
370 void VideoScheduler::EncodeFrame( 307 void VideoScheduler::EncodeFrame(
371 scoped_ptr<webrtc::DesktopFrame> frame, 308 scoped_ptr<webrtc::DesktopFrame> frame,
372 int64 latest_event_timestamp, 309 int64 latest_event_timestamp,
373 base::TimeTicks timestamp) { 310 base::TimeTicks timestamp) {
374 DCHECK(encode_task_runner_->BelongsToCurrentThread()); 311 DCHECK(encode_task_runner_->BelongsToCurrentThread());
375 312
313 scoped_ptr<VideoPacket> packet;
314
376 // If there is nothing to encode then send an empty packet. 315 // If there is nothing to encode then send an empty packet.
377 if (!frame || frame->updated_region().is_empty()) { 316 if (!frame || frame->updated_region().is_empty()) {
378 capture_task_runner_->DeleteSoon(FROM_HERE, frame.release()); 317 packet.reset(new VideoPacket());
379 scoped_ptr<VideoPacket> packet(new VideoPacket()); 318 } else {
380 packet->set_latest_event_timestamp(latest_event_timestamp); 319 packet = encoder_->Encode(*frame);
381 network_task_runner_->PostTask(
382 FROM_HERE,
383 base::Bind(
384 &VideoScheduler::SendVideoPacket, this, base::Passed(&packet)));
385 return;
386 } 320 }
387 321
388 scoped_ptr<VideoPacket> packet = encoder_->Encode(*frame);
389 packet->set_latest_event_timestamp(latest_event_timestamp);
390
391 if (g_enable_timestamps) { 322 if (g_enable_timestamps) {
392 packet->set_timestamp(timestamp.ToInternalValue()); 323 packet->set_timestamp(timestamp.ToInternalValue());
393 } 324 }
394 325
326 packet->set_latest_event_timestamp(latest_event_timestamp);
327
395 // Destroy the frame before sending |packet| because SendVideoPacket() may 328 // Destroy the frame before sending |packet| because SendVideoPacket() may
396 // trigger another frame to be captured, and the screen capturer expects the 329 // trigger another frame to be captured, and the screen capturer expects the
397 // old frame to be freed by then. 330 // old frame to be freed by then.
398 frame.reset(); 331 frame.reset();
399 332
400 scheduler_.RecordEncodeTime( 333 capture_task_runner_->PostTask(
401 base::TimeDelta::FromMilliseconds(packet->encode_time_ms())); 334 FROM_HERE,
335 base::Bind(&VideoScheduler::ProcessFrameEncodedOnCaptureThread, this,
336 base::TimeDelta::FromMilliseconds(packet->encode_time_ms())));
402 network_task_runner_->PostTask( 337 network_task_runner_->PostTask(
403 FROM_HERE, base::Bind(&VideoScheduler::SendVideoPacket, this, 338 FROM_HERE, base::Bind(&VideoScheduler::SendVideoPacket, this,
404 base::Passed(&packet))); 339 base::Passed(&packet)));
405 } 340 }
406 341
407 } // namespace remoting 342 } // namespace remoting
OLDNEW
« remoting/host/capture_scheduler.cc ('K') | « remoting/host/video_scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698