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

Unified Diff: remoting/host/video_scheduler.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, 11 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/video_scheduler.cc
diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc
index e2a3f945533aec44f68f2d58c1860f07494e90a5..77ee4f46f65f88477417c0b7a2e4f968392c6b39 100644
--- a/remoting/host/video_scheduler.cc
+++ b/remoting/host/video_scheduler.cc
@@ -19,16 +19,20 @@
#include "remoting/proto/video.pb.h"
#include "remoting/protocol/cursor_shape_stub.h"
#include "remoting/protocol/message_decoder.h"
-#include "remoting/protocol/video_stub.h"
+#include "remoting/protocol/video_sender.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
namespace remoting {
-// Maximum number of frames that can be processed simultaneously.
+// Maximum number of frames that can be processed simultaneously. In case the
+// video channel has Ack messages enabled the VideoSender acknowledges frames
+// only after the corresponding Ack message is received. The values are chosen
+// experimentally to maximize frame rate, while keeping round-trip latency low.
// TODO(hclam): Move this value to CaptureScheduler.
-static const int kMaxPendingFrames = 2;
+static const int kMaxPendingFrames = 4;
Wez 2015/01/21 01:35:38 kMaxPendingFrames controls the number of screen-ca
Sergey Ulanov 2015/01/29 01:33:27 Fixed it now. CaptureScheduler now separately chec
+static const int kMaxPendingFramesWithoutAcks = 2;
// Interval between empty keep-alive frames. These frames are sent only when the
// stream is paused or inactive for some other reason (e.g. when blocked on
@@ -51,7 +55,7 @@ VideoScheduler::VideoScheduler(
scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor,
scoped_ptr<VideoEncoder> encoder,
protocol::CursorShapeStub* cursor_stub,
- protocol::VideoStub* video_stub)
+ protocol::VideoSender* video_sender)
: capture_task_runner_(capture_task_runner),
encode_task_runner_(encode_task_runner),
network_task_runner_(network_task_runner),
@@ -59,7 +63,7 @@ VideoScheduler::VideoScheduler(
mouse_cursor_monitor_(mouse_cursor_monitor.Pass()),
encoder_(encoder.Pass()),
cursor_stub_(cursor_stub),
- video_stub_(video_stub),
+ video_sender_(video_sender),
pending_frames_(0),
capture_pending_(false),
did_skip_frame_(false),
@@ -70,7 +74,7 @@ VideoScheduler::VideoScheduler(
DCHECK(mouse_cursor_monitor_);
DCHECK(encoder_);
DCHECK(cursor_stub_);
- DCHECK(video_stub_);
+ DCHECK(video_sender_);
}
// Public methods --------------------------------------------------------------
@@ -156,7 +160,7 @@ void VideoScheduler::Stop() {
// Clear stubs to prevent further updates reaching the client.
cursor_stub_ = nullptr;
- video_stub_ = nullptr;
+ video_sender_ = nullptr;
keep_alive_timer_.reset();
@@ -274,10 +278,14 @@ void VideoScheduler::CaptureNextFrame() {
if (!capturer_ || is_paused_)
return;
+ int max_pending_frames = video_sender_->SupportsAcks()
+ ? kMaxPendingFrames
+ : kMaxPendingFramesWithoutAcks;
+
// Make sure we have at most two outstanding recordings. We can simply return
// if we can't make a capture now, the next capture will be started by the
// end of an encode operation.
- if (pending_frames_ >= kMaxPendingFrames || capture_pending_) {
+ if (pending_frames_ >= max_pending_frames || capture_pending_) {
did_skip_frame_ = true;
return;
}
@@ -286,7 +294,7 @@ void VideoScheduler::CaptureNextFrame() {
// At this point we are going to perform one capture so save the current time.
pending_frames_++;
- DCHECK_LE(pending_frames_, kMaxPendingFrames);
+ DCHECK_LE(pending_frames_, max_pending_frames);
// Before doing a capture schedule for the next one.
ScheduleNextCapture();
@@ -318,17 +326,17 @@ void VideoScheduler::FrameCaptureCompleted() {
void VideoScheduler::SendVideoPacket(scoped_ptr<VideoPacket> packet) {
DCHECK(network_task_runner_->BelongsToCurrentThread());
- if (!video_stub_)
+ if (!video_sender_)
return;
- video_stub_->ProcessVideoPacket(
+ video_sender_->ProcessVideoPacket(
packet.Pass(), base::Bind(&VideoScheduler::OnVideoPacketSent, this));
}
void VideoScheduler::OnVideoPacketSent() {
DCHECK(network_task_runner_->BelongsToCurrentThread());
- if (!video_stub_)
+ if (!video_sender_)
return;
keep_alive_timer_->Reset();
@@ -340,10 +348,10 @@ void VideoScheduler::OnVideoPacketSent() {
void VideoScheduler::SendKeepAlivePacket() {
DCHECK(network_task_runner_->BelongsToCurrentThread());
- if (!video_stub_)
+ if (!video_sender_)
return;
- video_stub_->ProcessVideoPacket(
+ video_sender_->ProcessVideoPacket(
make_scoped_ptr(new VideoPacket()),
base::Bind(&VideoScheduler::OnKeepAlivePacketSent, this));
}

Powered by Google App Engine
This is Rietveld 408576698