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

Unified Diff: remoting/protocol/host_video_dispatcher.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/protocol/host_video_dispatcher.cc
diff --git a/remoting/protocol/host_video_dispatcher.cc b/remoting/protocol/host_video_dispatcher.cc
index b9a12c0294f28ac8e95d65ca52c8e6c000e8334f..f4209624f4d0a658b72c108c947849f6c65889fe 100644
--- a/remoting/protocol/host_video_dispatcher.cc
+++ b/remoting/protocol/host_video_dispatcher.cc
@@ -5,16 +5,26 @@
#include "remoting/protocol/host_video_dispatcher.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "net/socket/stream_socket.h"
#include "remoting/base/constants.h"
-#include "remoting/proto/video.pb.h"
+#include "remoting/protocol/errors.h"
#include "remoting/protocol/message_serialization.h"
namespace remoting {
namespace protocol {
+HostVideoDispatcher::PendingFrame::PendingFrame(int frame_id,
+ const base::Closure& done)
+ : frame_id(frame_id), done(done) {
+}
+
HostVideoDispatcher::HostVideoDispatcher()
- : ChannelDispatcherBase(kVideoChannelName) {
+ : ChannelDispatcherBase(kVideoChannelName),
+ frame_id_(0),
+ parser_(
+ base::Bind(&HostVideoDispatcher::OnVideoAck, base::Unretained(this)),
+ reader()) {
}
HostVideoDispatcher::~HostVideoDispatcher() {
@@ -22,7 +32,35 @@ HostVideoDispatcher::~HostVideoDispatcher() {
void HostVideoDispatcher::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
const base::Closure& done) {
- writer()->Write(SerializeAndFrameMessage(*packet), done);
+ // For older clients that don't send explicit video Ack message call |done| as
+ // soon as the frame is pushed to the channel.
+ if (channel_config().version < kVideoWithAckStreamVersion) {
+ writer()->Write(SerializeAndFrameMessage(*packet), done);
+ return;
+ }
+
+ pending_frames_.push_back(PendingFrame(frame_id_, done));
+ packet->set_frame_id(frame_id_);
+ frame_id_++;
+ writer()->Write(SerializeAndFrameMessage(*packet), base::Closure());
+}
+
+bool HostVideoDispatcher::SupportsAcks() {
+ return channel_config().version >= kVideoWithAckStreamVersion;
+}
+
+void HostVideoDispatcher::OnVideoAck(scoped_ptr<VideoAck> ack,
+ const base::Closure& done) {
Wez 2015/01/21 01:35:40 Need some kind of comment and bug # reference in h
Sergey Ulanov 2015/01/29 01:33:29 Done.
+ base::ScopedClosureRunner done_runner(done);
+
+ if (pending_frames_.empty() ||
+ pending_frames_.front().frame_id != ack->frame_id()) {
+ NotifyError(INCOMPATIBLE_PROTOCOL);
+ return;
+ }
+
+ pending_frames_.front().done.Run();
Wez 2015/01/21 01:35:40 Are you guaranteed that the callback won't delete
Sergey Ulanov 2015/01/29 01:33:29 Done.
+ pending_frames_.pop_front();
}
} // namespace protocol

Powered by Google App Engine
This is Rietveld 408576698