summaryrefslogtreecommitdiffstats
path: root/remoting/client/chromoting_client.cc
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/client/chromoting_client.cc')
-rw-r--r--remoting/client/chromoting_client.cc110
1 files changed, 4 insertions, 106 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index 7c05d83..3bdc7b6 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -22,14 +22,6 @@ namespace remoting {
using protocol::AuthenticationMethod;
-ChromotingClient::QueuedVideoPacket::QueuedVideoPacket(
- scoped_ptr<VideoPacket> packet, const base::Closure& done)
- : packet(packet.release()), done(done) {
-}
-
-ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() {
-}
-
ChromotingClient::ChromotingClient(
const ClientConfig& config,
ClientContext* client_context,
@@ -42,8 +34,6 @@ ChromotingClient::ChromotingClient(
connection_(connection),
user_interface_(user_interface),
rectangle_decoder_(rectangle_decoder),
- packet_being_processed_(false),
- last_sequence_number_(0),
weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
audio_decode_scheduler_.reset(new AudioDecodeScheduler(
client_context->main_task_runner(),
@@ -69,7 +59,8 @@ void ChromotingClient::Start(
connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid,
config_.host_public_key, transport_factory.Pass(),
- authenticator.Pass(), this, this, this, this,
+ authenticator.Pass(), this, this, this,
+ rectangle_decoder_,
audio_decode_scheduler_.get());
}
@@ -77,11 +68,7 @@ void ChromotingClient::Stop(const base::Closure& shutdown_task) {
DCHECK(task_runner_->BelongsToCurrentThread());
// Drop all pending packets.
- while(!received_packets_.empty()) {
- delete received_packets_.front().packet;
- received_packets_.front().done.Run();
- received_packets_.pop_front();
- }
+ rectangle_decoder_->DropAllPackets();
connection_->Disconnect(base::Bind(&ChromotingClient::OnDisconnected,
weak_ptr_, shutdown_task));
@@ -93,7 +80,7 @@ void ChromotingClient::OnDisconnected(const base::Closure& shutdown_task) {
ChromotingStats* ChromotingClient::GetStats() {
DCHECK(task_runner_->BelongsToCurrentThread());
- return &stats_;
+ return rectangle_decoder_->GetStats();
}
void ChromotingClient::InjectClipboardEvent(
@@ -107,70 +94,6 @@ void ChromotingClient::SetCursorShape(
user_interface_->GetCursorShapeStub()->SetCursorShape(cursor_shape);
}
-void ChromotingClient::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
- const base::Closure& done) {
- DCHECK(task_runner_->BelongsToCurrentThread());
-
- // If the video packet is empty then drop it. Empty packets are used to
- // maintain activity on the network.
- if (!packet->has_data() || packet->data().size() == 0) {
- done.Run();
- return;
- }
-
- // Add one frame to the counter.
- stats_.video_frame_rate()->Record(1);
-
- // Record other statistics received from host.
- stats_.video_bandwidth()->Record(packet->data().size());
- if (packet->has_capture_time_ms())
- stats_.video_capture_ms()->Record(packet->capture_time_ms());
- if (packet->has_encode_time_ms())
- stats_.video_encode_ms()->Record(packet->encode_time_ms());
- if (packet->has_client_sequence_number() &&
- packet->client_sequence_number() > last_sequence_number_) {
- last_sequence_number_ = packet->client_sequence_number();
- base::TimeDelta round_trip_latency =
- base::Time::Now() -
- base::Time::FromInternalValue(packet->client_sequence_number());
- stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds());
- }
-
- received_packets_.push_back(QueuedVideoPacket(packet.Pass(), done));
- if (!packet_being_processed_)
- DispatchPacket();
-}
-
-int ChromotingClient::GetPendingVideoPackets() {
- DCHECK(task_runner_->BelongsToCurrentThread());
- return received_packets_.size();
-}
-
-void ChromotingClient::DispatchPacket() {
- DCHECK(task_runner_->BelongsToCurrentThread());
- CHECK(!packet_being_processed_);
-
- if (received_packets_.empty()) {
- // Nothing to do!
- return;
- }
-
- scoped_ptr<VideoPacket> packet(received_packets_.front().packet);
- received_packets_.front().packet = NULL;
- packet_being_processed_ = true;
-
- // 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.Pass(),
- base::Bind(&ChromotingClient::OnPacketDone, base::Unretained(this),
- last_packet, decode_start));
-}
-
void ChromotingClient::OnConnectionState(
protocol::ConnectionToHost::State state,
protocol::ErrorCode error) {
@@ -186,31 +109,6 @@ void ChromotingClient::OnConnectionReady(bool ready) {
user_interface_->OnConnectionReady(ready);
}
-void ChromotingClient::OnPacketDone(bool last_packet,
- base::Time decode_start) {
- if (!task_runner_->BelongsToCurrentThread()) {
- task_runner_->PostTask(FROM_HERE, base::Bind(
- &ChromotingClient::OnPacketDone, base::Unretained(this),
- last_packet, decode_start));
- return;
- }
-
- // Record the latency between the final packet being received and
- // presented.
- if (last_packet) {
- stats_.video_decode_ms()->Record(
- (base::Time::Now() - decode_start).InMilliseconds());
- }
-
- received_packets_.front().done.Run();
- received_packets_.pop_front();
-
- packet_being_processed_ = false;
-
- // Process the next video packet.
- DispatchPacket();
-}
-
void ChromotingClient::Initialize() {
DCHECK(task_runner_->BelongsToCurrentThread());