Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/client/chromoting_client.h" | 5 #include "remoting/client/chromoting_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "remoting/client/chromoting_view.h" | 8 #include "remoting/client/chromoting_view.h" |
| 9 #include "remoting/client/client_context.h" | 9 #include "remoting/client/client_context.h" |
| 10 #include "remoting/client/rectangle_update_decoder.h" | 10 #include "remoting/client/rectangle_update_decoder.h" |
| 11 #include "remoting/protocol/authentication_method.h" | 11 #include "remoting/protocol/authentication_method.h" |
| 12 #include "remoting/protocol/connection_to_host.h" | 12 #include "remoting/protocol/connection_to_host.h" |
| 13 #include "remoting/protocol/negotiating_authenticator.h" | 13 #include "remoting/protocol/negotiating_authenticator.h" |
| 14 #include "remoting/protocol/v1_authenticator.h" | 14 #include "remoting/protocol/v1_authenticator.h" |
| 15 #include "remoting/protocol/session_config.h" | 15 #include "remoting/protocol/session_config.h" |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 | 18 |
| 19 using protocol::AuthenticationMethod; | 19 using protocol::AuthenticationMethod; |
| 20 | 20 |
| 21 ChromotingClient::QueuedVideoPacket::QueuedVideoPacket( | 21 ChromotingClient::QueuedVideoPacket::QueuedVideoPacket( |
| 22 const VideoPacket* packet, const base::Closure& done) | 22 scoped_ptr<VideoPacket> packet, const base::Closure& done) |
| 23 : packet(packet), done(done) { | 23 : packet(packet.release()), done(done) { |
|
Alpha Left Google
2012/03/26 20:29:18
This line seems odd to me, can we use different va
Sergey Ulanov
2012/03/26 20:42:13
done(done) was here before.
We need to release()
| |
| 24 } | 24 } |
| 25 | 25 |
| 26 ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() { | 26 ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 ChromotingClient::ChromotingClient(const ClientConfig& config, | 29 ChromotingClient::ChromotingClient(const ClientConfig& config, |
| 30 ClientContext* context, | 30 ClientContext* context, |
| 31 protocol::ConnectionToHost* connection, | 31 protocol::ConnectionToHost* connection, |
| 32 ChromotingView* view, | 32 ChromotingView* view, |
| 33 RectangleUpdateDecoder* rectangle_decoder, | 33 RectangleUpdateDecoder* rectangle_decoder, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 if (!client_done_.is_null()) { | 96 if (!client_done_.is_null()) { |
| 97 message_loop()->PostTask(FROM_HERE, client_done_); | 97 message_loop()->PostTask(FROM_HERE, client_done_); |
| 98 client_done_.Reset(); | 98 client_done_.Reset(); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 ChromotingStats* ChromotingClient::GetStats() { | 102 ChromotingStats* ChromotingClient::GetStats() { |
| 103 return &stats_; | 103 return &stats_; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ChromotingClient::ProcessVideoPacket(const VideoPacket* packet, | 106 void ChromotingClient::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, |
| 107 const base::Closure& done) { | 107 const base::Closure& done) { |
| 108 DCHECK(message_loop()->BelongsToCurrentThread()); | 108 DCHECK(message_loop()->BelongsToCurrentThread()); |
| 109 | 109 |
| 110 // If the video packet is empty then drop it. Empty packets are used to | 110 // If the video packet is empty then drop it. Empty packets are used to |
| 111 // maintain activity on the network. | 111 // maintain activity on the network. |
| 112 if (!packet->has_data() || packet->data().size() == 0) { | 112 if (!packet->has_data() || packet->data().size() == 0) { |
| 113 done.Run(); | 113 done.Run(); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Add one frame to the counter. | 117 // Add one frame to the counter. |
| 118 stats_.video_frame_rate()->Record(1); | 118 stats_.video_frame_rate()->Record(1); |
| 119 | 119 |
| 120 // Record other statistics received from host. | 120 // Record other statistics received from host. |
| 121 stats_.video_bandwidth()->Record(packet->data().size()); | 121 stats_.video_bandwidth()->Record(packet->data().size()); |
| 122 if (packet->has_capture_time_ms()) | 122 if (packet->has_capture_time_ms()) |
| 123 stats_.video_capture_ms()->Record(packet->capture_time_ms()); | 123 stats_.video_capture_ms()->Record(packet->capture_time_ms()); |
| 124 if (packet->has_encode_time_ms()) | 124 if (packet->has_encode_time_ms()) |
| 125 stats_.video_encode_ms()->Record(packet->encode_time_ms()); | 125 stats_.video_encode_ms()->Record(packet->encode_time_ms()); |
| 126 if (packet->has_client_sequence_number() && | 126 if (packet->has_client_sequence_number() && |
| 127 packet->client_sequence_number() > last_sequence_number_) { | 127 packet->client_sequence_number() > last_sequence_number_) { |
| 128 last_sequence_number_ = packet->client_sequence_number(); | 128 last_sequence_number_ = packet->client_sequence_number(); |
| 129 base::TimeDelta round_trip_latency = | 129 base::TimeDelta round_trip_latency = |
| 130 base::Time::Now() - | 130 base::Time::Now() - |
| 131 base::Time::FromInternalValue(packet->client_sequence_number()); | 131 base::Time::FromInternalValue(packet->client_sequence_number()); |
| 132 stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds()); | 132 stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 received_packets_.push_back(QueuedVideoPacket(packet, done)); | 135 received_packets_.push_back(QueuedVideoPacket(packet.Pass(), done)); |
| 136 if (!packet_being_processed_) | 136 if (!packet_being_processed_) |
| 137 DispatchPacket(); | 137 DispatchPacket(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 int ChromotingClient::GetPendingPackets() { | 140 int ChromotingClient::GetPendingPackets() { |
| 141 return received_packets_.size(); | 141 return received_packets_.size(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void ChromotingClient::DispatchPacket() { | 144 void ChromotingClient::DispatchPacket() { |
| 145 DCHECK(message_loop()->BelongsToCurrentThread()); | 145 DCHECK(message_loop()->BelongsToCurrentThread()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 thread_proxy_.PostTask(FROM_HERE, base::Bind( | 208 thread_proxy_.PostTask(FROM_HERE, base::Bind( |
| 209 &ChromotingClient::Initialize, base::Unretained(this))); | 209 &ChromotingClient::Initialize, base::Unretained(this))); |
| 210 return; | 210 return; |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Initialize the decoder. | 213 // Initialize the decoder. |
| 214 rectangle_decoder_->Initialize(connection_->config()); | 214 rectangle_decoder_->Initialize(connection_->config()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace remoting | 217 } // namespace remoting |
| OLD | NEW |