| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/protocol/connection_to_host_impl.h" | 5 #include "remoting/protocol/connection_to_host_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| 11 #include "remoting/protocol/audio_reader.h" | 11 #include "remoting/protocol/audio_reader.h" |
| 12 #include "remoting/protocol/audio_stub.h" | 12 #include "remoting/protocol/audio_stub.h" |
| 13 #include "remoting/protocol/auth_util.h" | 13 #include "remoting/protocol/auth_util.h" |
| 14 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
| 15 #include "remoting/protocol/client_control_dispatcher.h" | 15 #include "remoting/protocol/client_control_dispatcher.h" |
| 16 #include "remoting/protocol/client_event_dispatcher.h" | 16 #include "remoting/protocol/client_event_dispatcher.h" |
| 17 #include "remoting/protocol/client_stub.h" | 17 #include "remoting/protocol/client_stub.h" |
| 18 #include "remoting/protocol/client_video_dispatcher.h" | 18 #include "remoting/protocol/client_video_dispatcher.h" |
| 19 #include "remoting/protocol/clipboard_stub.h" | 19 #include "remoting/protocol/clipboard_stub.h" |
| 20 #include "remoting/protocol/errors.h" | 20 #include "remoting/protocol/errors.h" |
| 21 #include "remoting/protocol/ice_transport.h" |
| 21 #include "remoting/protocol/jingle_session_manager.h" | 22 #include "remoting/protocol/jingle_session_manager.h" |
| 22 #include "remoting/protocol/transport.h" | 23 #include "remoting/protocol/transport.h" |
| 24 #include "remoting/protocol/transport_context.h" |
| 23 #include "remoting/protocol/video_stub.h" | 25 #include "remoting/protocol/video_stub.h" |
| 24 | 26 |
| 25 namespace remoting { | 27 namespace remoting { |
| 26 namespace protocol { | 28 namespace protocol { |
| 27 | 29 |
| 28 ConnectionToHostImpl::ConnectionToHostImpl() | 30 ConnectionToHostImpl::ConnectionToHostImpl() |
| 29 : event_callback_(nullptr), | 31 : event_callback_(nullptr), |
| 30 client_stub_(nullptr), | 32 client_stub_(nullptr), |
| 31 clipboard_stub_(nullptr), | 33 clipboard_stub_(nullptr), |
| 32 audio_stub_(nullptr), | 34 audio_stub_(nullptr), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 59 RETURN_STRING_LITERAL(CONNECTED); | 61 RETURN_STRING_LITERAL(CONNECTED); |
| 60 RETURN_STRING_LITERAL(CLOSED); | 62 RETURN_STRING_LITERAL(CLOSED); |
| 61 RETURN_STRING_LITERAL(FAILED); | 63 RETURN_STRING_LITERAL(FAILED); |
| 62 } | 64 } |
| 63 NOTREACHED(); | 65 NOTREACHED(); |
| 64 return nullptr; | 66 return nullptr; |
| 65 } | 67 } |
| 66 | 68 |
| 67 void ConnectionToHostImpl::Connect( | 69 void ConnectionToHostImpl::Connect( |
| 68 SignalStrategy* signal_strategy, | 70 SignalStrategy* signal_strategy, |
| 69 scoped_ptr<TransportFactory> transport_factory, | 71 scoped_refptr<TransportContext> transport_context, |
| 70 scoped_ptr<Authenticator> authenticator, | 72 scoped_ptr<Authenticator> authenticator, |
| 71 const std::string& host_jid, | 73 const std::string& host_jid, |
| 72 HostEventCallback* event_callback) { | 74 HostEventCallback* event_callback) { |
| 73 DCHECK(client_stub_); | 75 DCHECK(client_stub_); |
| 74 DCHECK(clipboard_stub_); | 76 DCHECK(clipboard_stub_); |
| 75 DCHECK(monitored_video_stub_); | 77 DCHECK(monitored_video_stub_); |
| 76 | 78 |
| 77 // Initialize default |candidate_config_| if set_candidate_config() wasn't | 79 // Initialize default |candidate_config_| if set_candidate_config() wasn't |
| 78 // called. | 80 // called. |
| 79 if (!candidate_config_) | 81 if (!candidate_config_) |
| 80 candidate_config_ = CandidateSessionConfig::CreateDefault(); | 82 candidate_config_ = CandidateSessionConfig::CreateDefault(); |
| 81 if (!audio_stub_) | 83 if (!audio_stub_) |
| 82 candidate_config_->DisableAudioChannel(); | 84 candidate_config_->DisableAudioChannel(); |
| 83 | 85 |
| 84 signal_strategy_ = signal_strategy; | 86 signal_strategy_ = signal_strategy; |
| 85 event_callback_ = event_callback; | 87 event_callback_ = event_callback; |
| 86 authenticator_ = authenticator.Pass(); | 88 authenticator_ = authenticator.Pass(); |
| 87 | 89 |
| 88 // Save jid of the host. The actual connection is created later after | 90 // Save jid of the host. The actual connection is created later after |
| 89 // |signal_strategy_| is connected. | 91 // |signal_strategy_| is connected. |
| 90 host_jid_ = host_jid; | 92 host_jid_ = host_jid; |
| 91 | 93 |
| 92 signal_strategy_->AddListener(this); | 94 signal_strategy_->AddListener(this); |
| 93 signal_strategy_->Connect(); | 95 signal_strategy_->Connect(); |
| 94 | 96 |
| 95 session_manager_.reset(new JingleSessionManager(transport_factory.Pass())); | 97 session_manager_.reset(new JingleSessionManager( |
| 98 make_scoped_ptr(new IceTransportFactory(transport_context)))); |
| 96 session_manager_->set_protocol_config(candidate_config_->Clone()); | 99 session_manager_->set_protocol_config(candidate_config_->Clone()); |
| 97 session_manager_->Init(signal_strategy_, this); | 100 session_manager_->Init(signal_strategy_, this); |
| 98 | 101 |
| 99 SetState(CONNECTING, OK); | 102 SetState(CONNECTING, OK); |
| 100 } | 103 } |
| 101 | 104 |
| 102 void ConnectionToHostImpl::set_candidate_config( | 105 void ConnectionToHostImpl::set_candidate_config( |
| 103 scoped_ptr<CandidateSessionConfig> config) { | 106 scoped_ptr<CandidateSessionConfig> config) { |
| 104 DCHECK_EQ(state_, INITIALIZING); | 107 DCHECK_EQ(state_, INITIALIZING); |
| 105 | 108 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 311 |
| 309 if (state != state_) { | 312 if (state != state_) { |
| 310 state_ = state; | 313 state_ = state; |
| 311 error_ = error; | 314 error_ = error; |
| 312 event_callback_->OnConnectionState(state_, error_); | 315 event_callback_->OnConnectionState(state_, error_); |
| 313 } | 316 } |
| 314 } | 317 } |
| 315 | 318 |
| 316 } // namespace protocol | 319 } // namespace protocol |
| 317 } // namespace remoting | 320 } // namespace remoting |
| OLD | NEW |