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..0ad990c34bd8c28ecbb3b043f3a443100ee9e645 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,52 @@ 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::ProcessVideoPacket, |
+ base::Unretained(this)), |
reader()) { |
} |
ClientVideoDispatcher::~ClientVideoDispatcher() { |
} |
+void ClientVideoDispatcher::ProcessVideoPacket( |
+ scoped_ptr<VideoPacket> video_packet, |
+ const base::Closure& done) { |
+ base::TimeTicks now = base::TimeTicks::Now(); |
+ |
+ int frame_id = video_packet->frame_id(); |
+ video_stub_->ProcessVideoPacket( |
+ video_packet.Pass(), |
+ base::Bind(&ClientVideoDispatcher::OnPacketProgress, |
+ base::Unretained(this), frame_id, |
+ reader()->last_message_read_duration(), now, done)); |
+} |
+ |
+void ClientVideoDispatcher::OnPacketProgress( |
+ int frame_id, |
+ base::TimeDelta time_to_receive, |
+ base::TimeTicks received_time, |
+ const base::Closure& done, |
+ VideoStub::PacketProgress packet_progress) { |
+ // Only interested in DONE notification. |
+ if (packet_progress != VideoStub::PacketProgress::DONE) |
+ return; |
+ |
+ done.Run(); |
+ |
+ // Don't send Ack message if the host doesn't support it. |
+ if (channel_config().version <= kVideoStreamVersionNoAck) |
+ return; |
+ |
+ // Send VideoAck. |
+ VideoAck ack_message; |
+ ack_message.set_frame_id(frame_id); |
+ ack_message.set_time_to_receive_us(time_to_receive.InMicroseconds()); |
+ ack_message.set_rendering_delay_us( |
+ (base::TimeTicks::Now() - received_time).InMicroseconds()); |
+ writer()->Write(SerializeAndFrameMessage(ack_message), base::Closure()); |
+} |
+ |
} // namespace protocol |
} // namespace remoting |