| 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/proto/audio.pb.h" |
| 11 #include "remoting/protocol/authentication_method.h" | 12 #include "remoting/protocol/authentication_method.h" |
| 12 #include "remoting/protocol/connection_to_host.h" | 13 #include "remoting/protocol/connection_to_host.h" |
| 13 #include "remoting/protocol/negotiating_authenticator.h" | 14 #include "remoting/protocol/negotiating_authenticator.h" |
| 14 #include "remoting/protocol/session_config.h" | 15 #include "remoting/protocol/session_config.h" |
| 15 #include "remoting/protocol/transport.h" | 16 #include "remoting/protocol/transport.h" |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 | 19 |
| 19 using protocol::AuthenticationMethod; | 20 using protocol::AuthenticationMethod; |
| 20 | 21 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 scoped_ptr<protocol::Authenticator> authenticator( | 54 scoped_ptr<protocol::Authenticator> authenticator( |
| 54 protocol::NegotiatingAuthenticator::CreateForClient( | 55 protocol::NegotiatingAuthenticator::CreateForClient( |
| 55 config_.authentication_tag, | 56 config_.authentication_tag, |
| 56 config_.shared_secret, config_.authentication_methods)); | 57 config_.shared_secret, config_.authentication_methods)); |
| 57 | 58 |
| 58 // Create a WeakPtr to ourself for to use for all posted tasks. | 59 // Create a WeakPtr to ourself for to use for all posted tasks. |
| 59 weak_ptr_ = weak_factory_.GetWeakPtr(); | 60 weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 60 | 61 |
| 61 connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid, | 62 connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid, |
| 62 config_.host_public_key, transport_factory.Pass(), | 63 config_.host_public_key, transport_factory.Pass(), |
| 63 authenticator.Pass(), this, this, this, this); | 64 authenticator.Pass(), this, this, this, this, this); |
| 64 | 65 |
| 65 view_->Initialize(); | 66 view_->Initialize(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void ChromotingClient::Stop(const base::Closure& shutdown_task) { | 69 void ChromotingClient::Stop(const base::Closure& shutdown_task) { |
| 69 DCHECK(task_runner_->BelongsToCurrentThread()); | 70 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 70 | 71 |
| 71 // Drop all pending packets. | 72 // Drop all pending packets. |
| 72 while(!received_packets_.empty()) { | 73 while(!received_packets_.empty()) { |
| 73 delete received_packets_.front().packet; | 74 delete received_packets_.front().packet; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 received_packets_.push_back(QueuedVideoPacket(packet.Pass(), done)); | 134 received_packets_.push_back(QueuedVideoPacket(packet.Pass(), done)); |
| 134 if (!packet_being_processed_) | 135 if (!packet_being_processed_) |
| 135 DispatchPacket(); | 136 DispatchPacket(); |
| 136 } | 137 } |
| 137 | 138 |
| 138 int ChromotingClient::GetPendingPackets() { | 139 int ChromotingClient::GetPendingPackets() { |
| 139 DCHECK(task_runner_->BelongsToCurrentThread()); | 140 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 140 return received_packets_.size(); | 141 return received_packets_.size(); |
| 141 } | 142 } |
| 142 | 143 |
| 144 void ChromotingClient::ProcessAudioPacket(scoped_ptr<AudioPacket> packet, |
| 145 const base::Closure& done) { |
| 146 // TODO(kxing): Playback audio. |
| 147 done.Run(); |
| 148 } |
| 149 |
| 143 void ChromotingClient::DispatchPacket() { | 150 void ChromotingClient::DispatchPacket() { |
| 144 DCHECK(task_runner_->BelongsToCurrentThread()); | 151 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 145 CHECK(!packet_being_processed_); | 152 CHECK(!packet_being_processed_); |
| 146 | 153 |
| 147 if (received_packets_.empty()) { | 154 if (received_packets_.empty()) { |
| 148 // Nothing to do! | 155 // Nothing to do! |
| 149 return; | 156 return; |
| 150 } | 157 } |
| 151 | 158 |
| 152 scoped_ptr<VideoPacket> packet(received_packets_.front().packet); | 159 scoped_ptr<VideoPacket> packet(received_packets_.front().packet); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 208 } |
| 202 | 209 |
| 203 void ChromotingClient::Initialize() { | 210 void ChromotingClient::Initialize() { |
| 204 DCHECK(task_runner_->BelongsToCurrentThread()); | 211 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 205 | 212 |
| 206 // Initialize the decoder. | 213 // Initialize the decoder. |
| 207 rectangle_decoder_->Initialize(connection_->config()); | 214 rectangle_decoder_->Initialize(connection_->config()); |
| 208 } | 215 } |
| 209 | 216 |
| 210 } // namespace remoting | 217 } // namespace remoting |
| OLD | NEW |