| 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/protocol/connection_to_host.h" | 5 #include "remoting/protocol/connection_to_host.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" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 void ConnectionToHost::Connect(SignalStrategy* signal_strategy, | 51 void ConnectionToHost::Connect(SignalStrategy* signal_strategy, |
| 52 scoped_ptr<TransportFactory> transport_factory, | 52 scoped_ptr<TransportFactory> transport_factory, |
| 53 scoped_ptr<Authenticator> authenticator, | 53 scoped_ptr<Authenticator> authenticator, |
| 54 const std::string& host_jid, | 54 const std::string& host_jid, |
| 55 HostEventCallback* event_callback) { | 55 HostEventCallback* event_callback) { |
| 56 DCHECK(client_stub_); | 56 DCHECK(client_stub_); |
| 57 DCHECK(clipboard_stub_); | 57 DCHECK(clipboard_stub_); |
| 58 DCHECK(monitored_video_stub_); | 58 DCHECK(monitored_video_stub_); |
| 59 | 59 |
| 60 // Initialize default |candidate_config_| if set_candidate_config() wasn't |
| 61 // called. |
| 62 if (!candidate_config_) { |
| 63 candidate_config_ = CandidateSessionConfig::CreateDefault(); |
| 64 if (!audio_stub_) { |
| 65 candidate_config_->DisableAudioChannel(); |
| 66 } |
| 67 candidate_config_->EnableVideoCodec(ChannelConfig::CODEC_VP9); |
| 68 } |
| 69 |
| 60 signal_strategy_ = signal_strategy; | 70 signal_strategy_ = signal_strategy; |
| 61 event_callback_ = event_callback; | 71 event_callback_ = event_callback; |
| 62 authenticator_ = authenticator.Pass(); | 72 authenticator_ = authenticator.Pass(); |
| 63 | 73 |
| 64 // Save jid of the host. The actual connection is created later after | 74 // Save jid of the host. The actual connection is created later after |
| 65 // |signal_strategy_| is connected. | 75 // |signal_strategy_| is connected. |
| 66 host_jid_ = host_jid; | 76 host_jid_ = host_jid; |
| 67 | 77 |
| 68 signal_strategy_->AddListener(this); | 78 signal_strategy_->AddListener(this); |
| 69 signal_strategy_->Connect(); | 79 signal_strategy_->Connect(); |
| 70 | 80 |
| 71 session_manager_.reset(new JingleSessionManager(transport_factory.Pass())); | 81 session_manager_.reset(new JingleSessionManager(transport_factory.Pass())); |
| 72 session_manager_->Init(signal_strategy_, this); | 82 session_manager_->Init(signal_strategy_, this); |
| 73 | 83 |
| 74 SetState(CONNECTING, OK); | 84 SetState(CONNECTING, OK); |
| 75 } | 85 } |
| 76 | 86 |
| 87 void ConnectionToHost::set_candidate_config( |
| 88 scoped_ptr<CandidateSessionConfig> config) { |
| 89 DCHECK_EQ(state_, INITIALIZING); |
| 90 |
| 91 candidate_config_ = config.Pass(); |
| 92 } |
| 93 |
| 94 |
| 77 const SessionConfig& ConnectionToHost::config() { | 95 const SessionConfig& ConnectionToHost::config() { |
| 78 return session_->config(); | 96 return session_->config(); |
| 79 } | 97 } |
| 80 | 98 |
| 81 ClipboardStub* ConnectionToHost::clipboard_forwarder() { | 99 ClipboardStub* ConnectionToHost::clipboard_forwarder() { |
| 82 return &clipboard_forwarder_; | 100 return &clipboard_forwarder_; |
| 83 } | 101 } |
| 84 | 102 |
| 85 HostStub* ConnectionToHost::host_stub() { | 103 HostStub* ConnectionToHost::host_stub() { |
| 86 // TODO(wez): Add a HostFilter class, equivalent to input filter. | 104 // TODO(wez): Add a HostFilter class, equivalent to input filter. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 146 |
| 129 bool ConnectionToHost::OnSignalStrategyIncomingStanza( | 147 bool ConnectionToHost::OnSignalStrategyIncomingStanza( |
| 130 const buzz::XmlElement* stanza) { | 148 const buzz::XmlElement* stanza) { |
| 131 return false; | 149 return false; |
| 132 } | 150 } |
| 133 | 151 |
| 134 void ConnectionToHost::OnSessionManagerReady() { | 152 void ConnectionToHost::OnSessionManagerReady() { |
| 135 DCHECK(CalledOnValidThread()); | 153 DCHECK(CalledOnValidThread()); |
| 136 | 154 |
| 137 // After SessionManager is initialized we can try to connect to the host. | 155 // After SessionManager is initialized we can try to connect to the host. |
| 138 scoped_ptr<CandidateSessionConfig> candidate_config = | |
| 139 CandidateSessionConfig::CreateDefault(); | |
| 140 if (!audio_stub_) { | |
| 141 candidate_config->DisableAudioChannel(); | |
| 142 } | |
| 143 candidate_config->EnableVideoCodec(ChannelConfig::CODEC_VP9); | |
| 144 | |
| 145 session_ = session_manager_->Connect( | 156 session_ = session_manager_->Connect( |
| 146 host_jid_, authenticator_.Pass(), candidate_config.Pass()); | 157 host_jid_, authenticator_.Pass(), candidate_config_.Pass()); |
| 147 session_->SetEventHandler(this); | 158 session_->SetEventHandler(this); |
| 148 } | 159 } |
| 149 | 160 |
| 150 void ConnectionToHost::OnIncomingSession( | 161 void ConnectionToHost::OnIncomingSession( |
| 151 Session* session, | 162 Session* session, |
| 152 SessionManager::IncomingSessionResponse* response) { | 163 SessionManager::IncomingSessionResponse* response) { |
| 153 DCHECK(CalledOnValidThread()); | 164 DCHECK(CalledOnValidThread()); |
| 154 // Client always rejects incoming sessions. | 165 // Client always rejects incoming sessions. |
| 155 *response = SessionManager::DECLINE; | 166 *response = SessionManager::DECLINE; |
| 156 } | 167 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 299 |
| 289 if (state != state_) { | 300 if (state != state_) { |
| 290 state_ = state; | 301 state_ = state; |
| 291 error_ = error; | 302 error_ = error; |
| 292 event_callback_->OnConnectionState(state_, error_); | 303 event_callback_->OnConnectionState(state_, error_); |
| 293 } | 304 } |
| 294 } | 305 } |
| 295 | 306 |
| 296 } // namespace protocol | 307 } // namespace protocol |
| 297 } // namespace remoting | 308 } // namespace remoting |
| OLD | NEW |