diff options
Diffstat (limited to 'remoting/client/chromoting_client.cc')
-rw-r--r-- | remoting/client/chromoting_client.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index bf1ad39..cdfd4ab 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -154,8 +154,16 @@ void ChromotingClient::DispatchPacket() { packet_being_processed_ = true; ScopedTracer tracer("Handle video packet"); + + // Measure the latency between the last packet being received and presented. + bool last_packet = (packet->flags() & VideoPacket::LAST_PACKET) != 0; + base::Time decode_start; + if (last_packet) + decode_start = base::Time::Now(); + rectangle_decoder_->DecodePacket( - packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone)); + packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone, + last_packet, decode_start)); } void ChromotingClient::OnConnectionOpened(protocol::ConnectionToHost* conn) { @@ -194,22 +202,31 @@ void ChromotingClient::SetConnectionState(ConnectionState s) { Repaint(); } -void ChromotingClient::OnPacketDone() { +void ChromotingClient::OnPacketDone(bool last_packet, + base::Time decode_start) { if (message_loop() != MessageLoop::current()) { message_loop()->PostTask( FROM_HERE, - NewTracedMethod(this, &ChromotingClient::OnPacketDone)); + NewTracedMethod(this, &ChromotingClient::OnPacketDone, + last_packet, decode_start)); return; } TraceContext::tracer()->PrintString("Packet done"); + // Record the latency between the last packet being received and presented. + if (last_packet) { + stats_.video_decode()->Record( + (base::Time::Now() - decode_start).InMilliseconds()); + } + received_packets_.front().done->Run(); delete received_packets_.front().done; received_packets_.pop_front(); packet_being_processed_ = false; + // Process the next video packet. DispatchPacket(); } |