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

Side by Side Diff: remoting/client/software_video_renderer.cc

Issue 850983002: Implement video frame acknowledgements in the chromoting protocol. (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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/client/software_video_renderer.h" 5 #include "remoting/client/software_video_renderer.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 decode_task_runner_->PostTask( 334 decode_task_runner_->PostTask(
335 FROM_HERE, base::Bind(&SoftwareVideoRenderer::Core::OnSessionConfig, 335 FROM_HERE, base::Bind(&SoftwareVideoRenderer::Core::OnSessionConfig,
336 base::Unretained(core_.get()), config)); 336 base::Unretained(core_.get()), config));
337 } 337 }
338 338
339 ChromotingStats* SoftwareVideoRenderer::GetStats() { 339 ChromotingStats* SoftwareVideoRenderer::GetStats() {
340 DCHECK(CalledOnValidThread()); 340 DCHECK(CalledOnValidThread());
341 return &stats_; 341 return &stats_;
342 } 342 }
343 343
344 void SoftwareVideoRenderer::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, 344 void SoftwareVideoRenderer::ProcessVideoPacket(
345 const base::Closure& done) { 345 scoped_ptr<VideoPacket> packet,
346 const ProgressCallback& progress_callback) {
346 DCHECK(CalledOnValidThread()); 347 DCHECK(CalledOnValidThread());
347 348
348 // If the video packet is empty then drop it. Empty packets are used to 349 // If the video packet is empty then drop it. Empty packets are used to
349 // maintain activity on the network. 350 // maintain activity on the network.
350 if (!packet->has_data() || packet->data().size() == 0) { 351 if (!packet->has_data() || packet->data().size() == 0) {
351 done.Run(); 352 progress_callback.Run(PacketProgress::DONE);
352 return; 353 return;
353 } 354 }
354 355
355 // Add one frame to the counter. 356 // Add one frame to the counter.
356 stats_.video_frame_rate()->Record(1); 357 stats_.video_frame_rate()->Record(1);
357 358
358 // Record other statistics received from host. 359 // Record other statistics received from host.
359 stats_.video_bandwidth()->Record(packet->data().size()); 360 stats_.video_bandwidth()->Record(packet->data().size());
360 if (packet->has_capture_time_ms()) 361 if (packet->has_capture_time_ms())
361 stats_.video_capture_ms()->Record(packet->capture_time_ms()); 362 stats_.video_capture_ms()->Record(packet->capture_time_ms());
362 if (packet->has_encode_time_ms()) 363 if (packet->has_encode_time_ms())
363 stats_.video_encode_ms()->Record(packet->encode_time_ms()); 364 stats_.video_encode_ms()->Record(packet->encode_time_ms());
364 if (packet->has_latest_event_timestamp() && 365 if (packet->has_latest_event_timestamp() &&
365 packet->latest_event_timestamp() > latest_event_timestamp_) { 366 packet->latest_event_timestamp() > latest_event_timestamp_) {
366 latest_event_timestamp_ = packet->latest_event_timestamp(); 367 latest_event_timestamp_ = packet->latest_event_timestamp();
367 base::TimeDelta round_trip_latency = 368 base::TimeDelta round_trip_latency =
368 base::Time::Now() - 369 base::Time::Now() -
369 base::Time::FromInternalValue(packet->latest_event_timestamp()); 370 base::Time::FromInternalValue(packet->latest_event_timestamp());
370 stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds()); 371 stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds());
371 } 372 }
372 373
373 // Measure the latency between the last packet being received and presented. 374 // Measure the latency between the last packet being received and presented.
374 base::Time decode_start = base::Time::Now(); 375 base::Time decode_start = base::Time::Now();
375 376
376 base::Closure decode_done = base::Bind(&SoftwareVideoRenderer::OnPacketDone, 377 base::Closure decode_done = base::Bind(&SoftwareVideoRenderer::OnPacketDone,
377 weak_factory_.GetWeakPtr(), 378 weak_factory_.GetWeakPtr(),
378 decode_start, done); 379 decode_start, progress_callback);
Wez 2015/02/03 00:54:32 nit: Note that because you're binding this via a W
Sergey Ulanov 2015/02/09 19:14:54 Yes. These are not like Pepper callbacks that are
379 380
380 decode_task_runner_->PostTask(FROM_HERE, base::Bind( 381 decode_task_runner_->PostTask(FROM_HERE, base::Bind(
381 &SoftwareVideoRenderer::Core::DecodePacket, 382 &SoftwareVideoRenderer::Core::DecodePacket,
382 base::Unretained(core_.get()), base::Passed(&packet), decode_done)); 383 base::Unretained(core_.get()), base::Passed(&packet), decode_done));
383 } 384 }
384 385
385 void SoftwareVideoRenderer::DrawBuffer(webrtc::DesktopFrame* buffer) { 386 void SoftwareVideoRenderer::DrawBuffer(webrtc::DesktopFrame* buffer) {
386 decode_task_runner_->PostTask( 387 decode_task_runner_->PostTask(
387 FROM_HERE, base::Bind(&SoftwareVideoRenderer::Core::DrawBuffer, 388 FROM_HERE, base::Bind(&SoftwareVideoRenderer::Core::DrawBuffer,
388 base::Unretained(core_.get()), buffer)); 389 base::Unretained(core_.get()), buffer));
(...skipping 15 matching lines...) Expand all
404 405
405 void SoftwareVideoRenderer::SetOutputSizeAndClip( 406 void SoftwareVideoRenderer::SetOutputSizeAndClip(
406 const webrtc::DesktopSize& view_size, 407 const webrtc::DesktopSize& view_size,
407 const webrtc::DesktopRect& clip_area) { 408 const webrtc::DesktopRect& clip_area) {
408 decode_task_runner_->PostTask( 409 decode_task_runner_->PostTask(
409 FROM_HERE, 410 FROM_HERE,
410 base::Bind(&SoftwareVideoRenderer::Core::SetOutputSizeAndClip, 411 base::Bind(&SoftwareVideoRenderer::Core::SetOutputSizeAndClip,
411 base::Unretained(core_.get()), view_size, clip_area)); 412 base::Unretained(core_.get()), view_size, clip_area));
412 } 413 }
413 414
414 void SoftwareVideoRenderer::OnPacketDone(base::Time decode_start, 415 void SoftwareVideoRenderer::OnPacketDone(
415 const base::Closure& done) { 416 base::Time decode_start,
417 const ProgressCallback& progress_callback) {
416 DCHECK(CalledOnValidThread()); 418 DCHECK(CalledOnValidThread());
417 419
418 // Record the latency between the packet being received and presented. 420 // Record the latency between the packet being received and presented.
419 stats_.video_decode_ms()->Record( 421 stats_.video_decode_ms()->Record(
420 (base::Time::Now() - decode_start).InMilliseconds()); 422 (base::Time::Now() - decode_start).InMilliseconds());
421 423
422 done.Run(); 424 progress_callback.Run(PacketProgress::DONE);
423 } 425 }
424 426
425 } // namespace remoting 427 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698