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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "remoting/base/capabilities.h" | 9 #include "remoting/base/capabilities.h" |
10 #include "remoting/client/audio_decode_scheduler.h" | 10 #include "remoting/client/audio_decode_scheduler.h" |
11 #include "remoting/client/audio_player.h" | 11 #include "remoting/client/audio_player.h" |
12 #include "remoting/client/client_context.h" | 12 #include "remoting/client/client_context.h" |
13 #include "remoting/client/client_user_interface.h" | 13 #include "remoting/client/client_user_interface.h" |
14 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
15 #include "remoting/protocol/connection_to_host.h" | 15 #include "remoting/protocol/connection_to_host.h" |
16 #include "remoting/protocol/host_stub.h" | 16 #include "remoting/protocol/host_stub.h" |
17 #include "remoting/protocol/ice_connection_to_host.h" | 17 #include "remoting/protocol/ice_connection_to_host.h" |
18 #include "remoting/protocol/ice_transport.h" | |
19 #include "remoting/protocol/jingle_session_manager.h" | 18 #include "remoting/protocol/jingle_session_manager.h" |
20 #include "remoting/protocol/session_config.h" | 19 #include "remoting/protocol/session_config.h" |
21 #include "remoting/protocol/transport_context.h" | 20 #include "remoting/protocol/transport_context.h" |
22 #include "remoting/protocol/video_renderer.h" | 21 #include "remoting/protocol/video_renderer.h" |
| 22 #include "remoting/protocol/webrtc_connection_to_host.h" |
23 | 23 |
24 namespace remoting { | 24 namespace remoting { |
25 | 25 |
26 ChromotingClient::ChromotingClient(ClientContext* client_context, | 26 ChromotingClient::ChromotingClient(ClientContext* client_context, |
27 ClientUserInterface* user_interface, | 27 ClientUserInterface* user_interface, |
28 protocol::VideoRenderer* video_renderer, | 28 protocol::VideoRenderer* video_renderer, |
29 scoped_ptr<AudioPlayer> audio_player) | 29 scoped_ptr<AudioPlayer> audio_player) |
30 : user_interface_(user_interface), | 30 : user_interface_(user_interface), video_renderer_(video_renderer) { |
31 video_renderer_(video_renderer), | |
32 connection_(new protocol::IceConnectionToHost()) { | |
33 DCHECK(client_context->main_task_runner()->BelongsToCurrentThread()); | 31 DCHECK(client_context->main_task_runner()->BelongsToCurrentThread()); |
34 if (audio_player) { | 32 if (audio_player) { |
35 audio_decode_scheduler_.reset(new AudioDecodeScheduler( | 33 audio_decode_scheduler_.reset(new AudioDecodeScheduler( |
36 client_context->main_task_runner(), | 34 client_context->main_task_runner(), |
37 client_context->audio_decode_task_runner(), std::move(audio_player))); | 35 client_context->audio_decode_task_runner(), std::move(audio_player))); |
38 } | 36 } |
39 } | 37 } |
40 | 38 |
41 ChromotingClient::~ChromotingClient() { | 39 ChromotingClient::~ChromotingClient() { |
42 if (signal_strategy_) | 40 if (signal_strategy_) |
(...skipping 15 matching lines...) Expand all Loading... |
58 scoped_ptr<protocol::Authenticator> authenticator, | 56 scoped_ptr<protocol::Authenticator> authenticator, |
59 scoped_refptr<protocol::TransportContext> transport_context, | 57 scoped_refptr<protocol::TransportContext> transport_context, |
60 const std::string& host_jid, | 58 const std::string& host_jid, |
61 const std::string& capabilities) { | 59 const std::string& capabilities) { |
62 DCHECK(thread_checker_.CalledOnValidThread()); | 60 DCHECK(thread_checker_.CalledOnValidThread()); |
63 DCHECK(!session_manager_); // Start must be called more than once. | 61 DCHECK(!session_manager_); // Start must be called more than once. |
64 | 62 |
65 host_jid_ = host_jid; | 63 host_jid_ = host_jid; |
66 local_capabilities_ = capabilities; | 64 local_capabilities_ = capabilities; |
67 | 65 |
| 66 if (!protocol_config_) |
| 67 protocol_config_ = protocol::CandidateSessionConfig::CreateDefault(); |
| 68 if (!audio_decode_scheduler_) |
| 69 protocol_config_->DisableAudioChannel(); |
| 70 |
| 71 if (!connection_) { |
| 72 if (protocol_config_->webrtc_supported()) { |
| 73 DCHECK(!protocol_config_->ice_supported()); |
| 74 #if defined(OS_NACL) |
| 75 LOG(FATAL) << "WebRTC is not supported in webapp."; |
| 76 #else // defined(OS_NACL) |
| 77 connection_.reset(new protocol::WebrtcConnectionToHost()); |
| 78 #endif // !defined(OS_NACL) |
| 79 } else { |
| 80 DCHECK(protocol_config_->ice_supported()); |
| 81 connection_.reset(new protocol::IceConnectionToHost()); |
| 82 } |
| 83 } |
68 connection_->set_client_stub(this); | 84 connection_->set_client_stub(this); |
69 connection_->set_clipboard_stub(this); | 85 connection_->set_clipboard_stub(this); |
70 connection_->set_video_renderer(video_renderer_); | 86 connection_->set_video_renderer(video_renderer_); |
71 connection_->set_audio_stub(audio_decode_scheduler_.get()); | 87 connection_->set_audio_stub(audio_decode_scheduler_.get()); |
72 | 88 |
73 session_manager_.reset(new protocol::JingleSessionManager(signal_strategy)); | 89 session_manager_.reset(new protocol::JingleSessionManager(signal_strategy)); |
74 | |
75 if (!protocol_config_) | |
76 protocol_config_ = protocol::CandidateSessionConfig::CreateDefault(); | |
77 if (!audio_decode_scheduler_) | |
78 protocol_config_->DisableAudioChannel(); | |
79 session_manager_->set_protocol_config(std::move(protocol_config_)); | 90 session_manager_->set_protocol_config(std::move(protocol_config_)); |
80 | 91 |
81 authenticator_ = std::move(authenticator); | 92 authenticator_ = std::move(authenticator); |
82 transport_context_ = transport_context; | 93 transport_context_ = transport_context; |
83 | 94 |
84 signal_strategy_ = signal_strategy; | 95 signal_strategy_ = signal_strategy; |
85 signal_strategy_->AddListener(this); | 96 signal_strategy_->AddListener(this); |
86 | 97 |
87 switch (signal_strategy_->GetState()) { | 98 switch (signal_strategy_->GetState()) { |
88 case SignalStrategy::CONNECTING: | 99 case SignalStrategy::CONNECTING: |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 229 |
219 // Negotiate capabilities with the host. | 230 // Negotiate capabilities with the host. |
220 VLOG(1) << "Client capabilities: " << local_capabilities_; | 231 VLOG(1) << "Client capabilities: " << local_capabilities_; |
221 | 232 |
222 protocol::Capabilities capabilities; | 233 protocol::Capabilities capabilities; |
223 capabilities.set_capabilities(local_capabilities_); | 234 capabilities.set_capabilities(local_capabilities_); |
224 connection_->host_stub()->SetCapabilities(capabilities); | 235 connection_->host_stub()->SetCapabilities(capabilities); |
225 } | 236 } |
226 | 237 |
227 } // namespace remoting | 238 } // namespace remoting |
OLD | NEW |