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

Unified Diff: remoting/protocol/client_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/client_video_dispatcher.cc
diff --git a/remoting/protocol/client_video_dispatcher.cc b/remoting/protocol/client_video_dispatcher.cc
index 287bba329cab9ee428d4a87b2a5f850499f27910..1fef81c2c258f921bba88cc5c3b72aafa5dc679c 100644
--- a/remoting/protocol/client_video_dispatcher.cc
+++ b/remoting/protocol/client_video_dispatcher.cc
@@ -8,6 +8,8 @@
#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"
#include "remoting/protocol/video_stub.h"
namespace remoting {
@@ -15,13 +17,43 @@ namespace protocol {
ClientVideoDispatcher::ClientVideoDispatcher(VideoStub* video_stub)
: ChannelDispatcherBase(kVideoChannelName),
- parser_(base::Bind(&VideoStub::ProcessVideoPacket,
- base::Unretained(video_stub)),
+ video_stub_(video_stub),
+ parser_(base::Bind(&ClientVideoDispatcher::OnVideoPacket,
+ base::Unretained(this)),
reader()) {
}
ClientVideoDispatcher::~ClientVideoDispatcher() {
}
+void ClientVideoDispatcher::OnVideoPacket(scoped_ptr<VideoPacket> video_packet,
+ const base::Closure& done) {
+ base::TimeTicks now = base::TimeTicks::Now();
+
+ VideoAck ack_message;
Wez 2015/01/21 01:35:38 Is creating and copying a protobuf super cheap? Co
Sergey Ulanov 2015/01/29 01:33:28 Done.
+ ack_message.set_frame_id(video_packet->frame_id());
+
+ ack_message.set_time_to_receive_us(
+ reader()->last_message_read_delay().InMicroseconds());
Wez 2015/01/21 01:35:39 nit: This line is logically part of initializing a
Sergey Ulanov 2015/01/29 01:33:28 Done.
+
+ video_stub_->ProcessVideoPacket(
+ video_packet.Pass(),
+ base::Bind(&ClientVideoDispatcher::OnPacketProcessed,
+ base::Unretained(this), ack_message, now, done));
+}
+
+void ClientVideoDispatcher::OnPacketProcessed(VideoAck ack_message,
+ base::TimeTicks received_time,
+ const base::Closure& done) {
+ done.Run();
+
+ // Send Ack message for newer version of the protocol.
+ if (channel_config().version >= kVideoWithAckStreamVersion) {
Wez 2015/01/21 01:35:39 The stream version never changes mid-session, so I
Sergey Ulanov 2015/01/29 01:33:28 Done.
+ base::TimeDelta rendering_delay = base::TimeTicks::Now() - received_time;
+ ack_message.set_rendering_delay_us(rendering_delay.InMicroseconds());
+ writer()->Write(SerializeAndFrameMessage(ack_message), base::Closure());
+ }
+}
+
} // namespace protocol
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698