OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/host/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
6 | 6 |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
11 #include "remoting/base/encoder.h" | 11 #include "remoting/base/encoder.h" |
12 #include "remoting/base/encoder_verbatim.h" | 12 #include "remoting/base/encoder_verbatim.h" |
13 #include "remoting/base/encoder_vp8.h" | 13 #include "remoting/base/encoder_vp8.h" |
14 #include "remoting/base/encoder_zlib.h" | 14 #include "remoting/base/encoder_zlib.h" |
15 #include "remoting/host/chromoting_host_context.h" | 15 #include "remoting/host/chromoting_host_context.h" |
16 #include "remoting/host/capturer.h" | 16 #include "remoting/host/capturer.h" |
17 #include "remoting/host/event_executor.h" | 17 #include "remoting/host/event_executor.h" |
18 #include "remoting/host/host_config.h" | 18 #include "remoting/host/host_config.h" |
19 #include "remoting/host/session_manager.h" | 19 #include "remoting/host/session_manager.h" |
20 #include "remoting/protocol/chromotocol_config.h" | 20 #include "remoting/protocol/session_config.h" |
21 #include "remoting/protocol/jingle_session_manager.h" | 21 #include "remoting/protocol/jingle_session_manager.h" |
22 #include "remoting/protocol/connection_to_client.h" | 22 #include "remoting/protocol/connection_to_client.h" |
23 | 23 |
24 using remoting::protocol::ConnectionToClient; | 24 using remoting::protocol::ConnectionToClient; |
25 | 25 |
26 namespace remoting { | 26 namespace remoting { |
27 | 27 |
28 ChromotingHost::ChromotingHost(ChromotingHostContext* context, | 28 ChromotingHost::ChromotingHost(ChromotingHostContext* context, |
29 MutableHostConfig* config, | 29 MutableHostConfig* config, |
30 Capturer* capturer, | 30 Capturer* capturer, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 *response = protocol::SessionManager::DECLINE; | 253 *response = protocol::SessionManager::DECLINE; |
254 return; | 254 return; |
255 } | 255 } |
256 | 256 |
257 // Check that the user has access to the host. | 257 // Check that the user has access to the host. |
258 if (!access_verifier_.VerifyPermissions(session->jid())) { | 258 if (!access_verifier_.VerifyPermissions(session->jid())) { |
259 *response = protocol::SessionManager::DECLINE; | 259 *response = protocol::SessionManager::DECLINE; |
260 return; | 260 return; |
261 } | 261 } |
262 | 262 |
263 scoped_ptr<CandidateChromotocolConfig> local_config( | 263 scoped_ptr<protocol::CandidateSessionConfig> |
264 CandidateChromotocolConfig::CreateDefault()); | 264 local_config(protocol::CandidateSessionConfig::CreateDefault()); |
265 local_config->SetInitialResolution( | 265 local_config->SetInitialResolution( |
266 ScreenResolution(capturer_->width(), capturer_->height())); | 266 protocol::ScreenResolution(capturer_->width(), capturer_->height())); |
267 // TODO(sergeyu): Respect resolution requested by the client if supported. | 267 // TODO(sergeyu): Respect resolution requested by the client if supported. |
268 ChromotocolConfig* config = | 268 protocol::SessionConfig* config = local_config->Select( |
269 local_config->Select(session->candidate_config(), | 269 session->candidate_config(), true /* force_host_resolution */); |
270 true /* force_host_resolution */); | |
271 | 270 |
272 if (!config) { | 271 if (!config) { |
273 LOG(WARNING) << "Rejecting connection from " << session->jid() | 272 LOG(WARNING) << "Rejecting connection from " << session->jid() |
274 << " because no compatible configuration has been found."; | 273 << " because no compatible configuration has been found."; |
275 *response = protocol::SessionManager::INCOMPATIBLE; | 274 *response = protocol::SessionManager::INCOMPATIBLE; |
276 return; | 275 return; |
277 } | 276 } |
278 | 277 |
279 session->set_config(config); | 278 session->set_config(config); |
280 | 279 |
281 *response = protocol::SessionManager::ACCEPT; | 280 *response = protocol::SessionManager::ACCEPT; |
282 | 281 |
283 VLOG(1) << "Client connected: " << session->jid(); | 282 VLOG(1) << "Client connected: " << session->jid(); |
284 | 283 |
285 // If we accept the connected then create a client object and set the | 284 // If we accept the connected then create a client object and set the |
286 // callback. | 285 // callback. |
287 connection_ = new ConnectionToClient(context_->main_message_loop(), this); | 286 connection_ = new ConnectionToClient(context_->main_message_loop(), this); |
288 connection_->Init(session); | 287 connection_->Init(session); |
289 } | 288 } |
290 | 289 |
291 void ChromotingHost::OnServerClosed() { | 290 void ChromotingHost::OnServerClosed() { |
292 // Don't need to do anything here. | 291 // Don't need to do anything here. |
293 } | 292 } |
294 | 293 |
295 // TODO(sergeyu): Move this to SessionManager? | 294 // TODO(sergeyu): Move this to SessionManager? |
296 Encoder* ChromotingHost::CreateEncoder(const ChromotocolConfig* config) { | 295 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) { |
297 const ChannelConfig& video_config = config->video_config(); | 296 const protocol::ChannelConfig& video_config = config->video_config(); |
298 | 297 |
299 if (video_config.codec == ChannelConfig::CODEC_VERBATIM) { | 298 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { |
300 return new remoting::EncoderVerbatim(); | 299 return new remoting::EncoderVerbatim(); |
301 } else if (video_config.codec == ChannelConfig::CODEC_ZIP) { | 300 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { |
302 return new remoting::EncoderZlib(); | 301 return new remoting::EncoderZlib(); |
303 } | 302 } |
304 // TODO(sergeyu): Enable VP8 on ARM builds. | 303 // TODO(sergeyu): Enable VP8 on ARM builds. |
305 #if !defined(ARCH_CPU_ARM_FAMILY) | 304 #if !defined(ARCH_CPU_ARM_FAMILY) |
306 else if (video_config.codec == ChannelConfig::CODEC_VP8) { | 305 else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { |
307 return new remoting::EncoderVp8(); | 306 return new remoting::EncoderVp8(); |
308 } | 307 } |
309 #endif | 308 #endif |
310 | 309 |
311 return NULL; | 310 return NULL; |
312 } | 311 } |
313 | 312 |
314 } // namespace remoting | 313 } // namespace remoting |
OLD | NEW |