Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: remoting/client/chromoting_client.cc

Issue 976233003: Adding the base ChromotingInstance implementation and unittests. This class will be used by the ap… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Sergey's feedback Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/base/capabilities.h" 8 #include "remoting/base/capabilities.h"
9 #include "remoting/client/audio_decode_scheduler.h" 9 #include "remoting/client/audio_decode_scheduler.h"
10 #include "remoting/client/audio_player.h" 10 #include "remoting/client/audio_player.h"
11 #include "remoting/client/client_context.h" 11 #include "remoting/client/client_context.h"
12 #include "remoting/client/client_user_interface.h" 12 #include "remoting/client/client_user_interface.h"
13 #include "remoting/client/video_renderer.h" 13 #include "remoting/client/video_renderer.h"
14 #include "remoting/proto/audio.pb.h" 14 #include "remoting/proto/audio.pb.h"
15 #include "remoting/proto/video.pb.h" 15 #include "remoting/proto/video.pb.h"
16 #include "remoting/protocol/authentication_method.h" 16 #include "remoting/protocol/authentication_method.h"
17 #include "remoting/protocol/connection_to_host.h" 17 #include "remoting/protocol/connection_to_host.h"
18 #include "remoting/protocol/host_stub.h" 18 #include "remoting/protocol/host_stub.h"
19 #include "remoting/protocol/negotiating_client_authenticator.h" 19 #include "remoting/protocol/negotiating_client_authenticator.h"
20 #include "remoting/protocol/session_config.h" 20 #include "remoting/protocol/session_config.h"
21 #include "remoting/protocol/transport.h" 21 #include "remoting/protocol/transport.h"
22 22
23 namespace remoting { 23 namespace remoting {
24 24
25 using protocol::AuthenticationMethod; 25 using protocol::AuthenticationMethod;
26 26
27 ChromotingClient::ChromotingClient( 27 ChromotingClient::ChromotingClient(ClientContext* client_context,
28 ClientContext* client_context, 28 ClientUserInterface* user_interface,
29 ClientUserInterface* user_interface, 29 VideoRenderer* video_renderer,
30 VideoRenderer* video_renderer, 30 scoped_ptr<AudioPlayer> audio_player)
31 scoped_ptr<AudioPlayer> audio_player)
32 : task_runner_(client_context->main_task_runner()), 31 : task_runner_(client_context->main_task_runner()),
33 user_interface_(user_interface), 32 user_interface_(user_interface),
34 video_renderer_(video_renderer), 33 video_renderer_(video_renderer),
34 connection_(new protocol::ConnectionToHost()),
35 host_capabilities_received_(false) { 35 host_capabilities_received_(false) {
36 if (audio_player) { 36 if (audio_player) {
37 audio_decode_scheduler_.reset(new AudioDecodeScheduler( 37 audio_decode_scheduler_.reset(new AudioDecodeScheduler(
38 client_context->main_task_runner(), 38 client_context->main_task_runner(),
39 client_context->audio_decode_task_runner(), 39 client_context->audio_decode_task_runner(), audio_player.Pass()));
40 audio_player.Pass()));
41 } 40 }
42 } 41 }
43 42
44 ChromotingClient::~ChromotingClient() {} 43 ChromotingClient::~ChromotingClient() {
44 }
45 45
46 void ChromotingClient::SetProtocolConfigForTests( 46 void ChromotingClient::SetProtocolConfigForTests(
47 scoped_ptr<protocol::CandidateSessionConfig> config) { 47 scoped_ptr<protocol::CandidateSessionConfig> config) {
48 connection_.set_candidate_config(config.Pass()); 48 connection_->set_candidate_config(config.Pass());
49 }
50
51 void ChromotingClient::SetConnectionToHostForTests(
52 scoped_ptr<protocol::ConnectionToHost> connection_to_host) {
53 connection_ = connection_to_host.Pass();
49 } 54 }
50 55
51 void ChromotingClient::Start( 56 void ChromotingClient::Start(
52 SignalStrategy* signal_strategy, 57 SignalStrategy* signal_strategy,
53 scoped_ptr<protocol::Authenticator> authenticator, 58 scoped_ptr<protocol::Authenticator> authenticator,
54 scoped_ptr<protocol::TransportFactory> transport_factory, 59 scoped_ptr<protocol::TransportFactory> transport_factory,
55 const std::string& host_jid, 60 const std::string& host_jid,
56 const std::string& capabilities) { 61 const std::string& capabilities) {
57 DCHECK(task_runner_->BelongsToCurrentThread()); 62 DCHECK(task_runner_->BelongsToCurrentThread());
58 63
59 local_capabilities_ = capabilities; 64 local_capabilities_ = capabilities;
60 65
61 connection_.set_client_stub(this); 66 connection_->set_client_stub(this);
62 connection_.set_clipboard_stub(this); 67 connection_->set_clipboard_stub(this);
63 connection_.set_video_stub(video_renderer_->GetVideoStub()); 68 connection_->set_video_stub(video_renderer_->GetVideoStub());
64 connection_.set_audio_stub(audio_decode_scheduler_.get()); 69 connection_->set_audio_stub(audio_decode_scheduler_.get());
65 70
66 connection_.Connect(signal_strategy, transport_factory.Pass(), 71 connection_->Connect(signal_strategy, transport_factory.Pass(),
67 authenticator.Pass(), host_jid, this); 72 authenticator.Pass(), host_jid, this);
68 } 73 }
69 74
70 void ChromotingClient::SetCapabilities( 75 void ChromotingClient::SetCapabilities(
71 const protocol::Capabilities& capabilities) { 76 const protocol::Capabilities& capabilities) {
72 DCHECK(task_runner_->BelongsToCurrentThread()); 77 DCHECK(task_runner_->BelongsToCurrentThread());
73 78
74 // Only accept the first |protocol::Capabilities| message. 79 // Only accept the first |protocol::Capabilities| message.
75 if (host_capabilities_received_) { 80 if (host_capabilities_received_) {
76 LOG(WARNING) << "protocol::Capabilities has been received already."; 81 LOG(WARNING) << "protocol::Capabilities has been received already.";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const protocol::TransportRoute& route) { 145 const protocol::TransportRoute& route) {
141 VLOG(0) << "Using " << protocol::TransportRoute::GetTypeString(route.type) 146 VLOG(0) << "Using " << protocol::TransportRoute::GetTypeString(route.type)
142 << " connection for " << channel_name << " channel"; 147 << " connection for " << channel_name << " channel";
143 user_interface_->OnRouteChanged(channel_name, route); 148 user_interface_->OnRouteChanged(channel_name, route);
144 } 149 }
145 150
146 void ChromotingClient::OnAuthenticated() { 151 void ChromotingClient::OnAuthenticated() {
147 DCHECK(task_runner_->BelongsToCurrentThread()); 152 DCHECK(task_runner_->BelongsToCurrentThread());
148 153
149 // Initialize the decoder. 154 // Initialize the decoder.
150 video_renderer_->OnSessionConfig(connection_.config()); 155 video_renderer_->OnSessionConfig(connection_->config());
151 if (connection_.config().is_audio_enabled()) 156 if (connection_->config().is_audio_enabled())
152 audio_decode_scheduler_->Initialize(connection_.config()); 157 audio_decode_scheduler_->Initialize(connection_->config());
153
154 } 158 }
155 159
156 void ChromotingClient::OnChannelsConnected() { 160 void ChromotingClient::OnChannelsConnected() {
157 DCHECK(task_runner_->BelongsToCurrentThread()); 161 DCHECK(task_runner_->BelongsToCurrentThread());
158 162
159 // Negotiate capabilities with the host. 163 // Negotiate capabilities with the host.
160 VLOG(1) << "Client capabilities: " << local_capabilities_; 164 VLOG(1) << "Client capabilities: " << local_capabilities_;
161 165
162 protocol::Capabilities capabilities; 166 protocol::Capabilities capabilities;
163 capabilities.set_capabilities(local_capabilities_); 167 capabilities.set_capabilities(local_capabilities_);
164 connection_.host_stub()->SetCapabilities(capabilities); 168 connection_->host_stub()->SetCapabilities(capabilities);
165 } 169 }
166 170
167 } // namespace remoting 171 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698