| 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/host/client_session.h" | 5 #include "remoting/host/client_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "remoting/base/capabilities.h" | 10 #include "remoting/base/capabilities.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 auth_input_filter_(&disable_input_filter_), | 60 auth_input_filter_(&disable_input_filter_), |
| 61 auth_clipboard_filter_(&disable_clipboard_filter_), | 61 auth_clipboard_filter_(&disable_clipboard_filter_), |
| 62 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), | 62 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
| 63 max_duration_(max_duration), | 63 max_duration_(max_duration), |
| 64 audio_task_runner_(audio_task_runner), | 64 audio_task_runner_(audio_task_runner), |
| 65 input_task_runner_(input_task_runner), | 65 input_task_runner_(input_task_runner), |
| 66 video_capture_task_runner_(video_capture_task_runner), | 66 video_capture_task_runner_(video_capture_task_runner), |
| 67 video_encode_task_runner_(video_encode_task_runner), | 67 video_encode_task_runner_(video_encode_task_runner), |
| 68 network_task_runner_(network_task_runner), | 68 network_task_runner_(network_task_runner), |
| 69 ui_task_runner_(ui_task_runner), | 69 ui_task_runner_(ui_task_runner), |
| 70 pairing_registry_(pairing_registry) { | 70 pairing_registry_(pairing_registry), |
| 71 enable_cast_(false) { |
| 71 connection_->SetEventHandler(this); | 72 connection_->SetEventHandler(this); |
| 72 | 73 |
| 73 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be | 74 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
| 74 // set before channels are connected. Make it possible to set stubs | 75 // set before channels are connected. Make it possible to set stubs |
| 75 // later and set them only when connection is authenticated. | 76 // later and set them only when connection is authenticated. |
| 76 connection_->set_clipboard_stub(&auth_clipboard_filter_); | 77 connection_->set_clipboard_stub(&auth_clipboard_filter_); |
| 77 connection_->set_host_stub(this); | 78 connection_->set_host_stub(this); |
| 78 connection_->set_input_stub(&auth_input_filter_); | 79 connection_->set_input_stub(&auth_input_filter_); |
| 79 | 80 |
| 80 // |auth_*_filter_|'s states reflect whether the session is authenticated. | 81 // |auth_*_filter_|'s states reflect whether the session is authenticated. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 webrtc::DesktopSize(resolution.dips_width(), resolution.dips_height()), | 142 webrtc::DesktopSize(resolution.dips_width(), resolution.dips_height()), |
| 142 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); | 143 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); |
| 143 | 144 |
| 144 // Try to match the client's resolution. | 145 // Try to match the client's resolution. |
| 145 screen_controls_->SetScreenResolution(client_resolution); | 146 screen_controls_->SetScreenResolution(client_resolution); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 149 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| 149 DCHECK(CalledOnValidThread()); | 150 DCHECK(CalledOnValidThread()); |
| 150 | 151 |
| 152 // If cast is enabled, do nothing. |
| 153 if (enable_cast_) { |
| 154 return; |
| 155 } |
| 156 |
| 151 if (video_control.has_enable()) { | 157 if (video_control.has_enable()) { |
| 152 VLOG(1) << "Received VideoControl (enable=" | 158 VLOG(1) << "Received VideoControl (enable=" |
| 153 << video_control.enable() << ")"; | 159 << video_control.enable() << ")"; |
| 154 video_scheduler_->Pause(!video_control.enable()); | 160 video_scheduler_->Pause(!video_control.enable()); |
| 155 } | 161 } |
| 156 if (video_control.has_lossless_encode()) { | 162 if (video_control.has_lossless_encode()) { |
| 157 VLOG(1) << "Received VideoControl (lossless_encode=" | 163 VLOG(1) << "Received VideoControl (lossless_encode=" |
| 158 << video_control.lossless_encode() << ")"; | 164 << video_control.lossless_encode() << ")"; |
| 159 video_scheduler_->SetLosslessEncode(video_control.lossless_encode()); | 165 video_scheduler_->SetLosslessEncode(video_control.lossless_encode()); |
| 160 } | 166 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 309 |
| 304 desktop_environment_->SetCapabilities(*client_capabilities_); | 310 desktop_environment_->SetCapabilities(*client_capabilities_); |
| 305 } | 311 } |
| 306 | 312 |
| 307 // Create the object that controls the screen resolution. | 313 // Create the object that controls the screen resolution. |
| 308 screen_controls_ = desktop_environment_->CreateScreenControls(); | 314 screen_controls_ = desktop_environment_->CreateScreenControls(); |
| 309 | 315 |
| 310 // Create the event executor. | 316 // Create the event executor. |
| 311 input_injector_ = desktop_environment_->CreateInputInjector(); | 317 input_injector_ = desktop_environment_->CreateInputInjector(); |
| 312 | 318 |
| 319 // Create the screen capturer. |
| 320 // TODO(aiguha): Implement dynamic sharing of the screen capturer between |
| 321 // VideoScheduler and the CastExtension/CastVideoCapturer. |
| 322 screen_capturer_ = desktop_environment_->CreateVideoCapturer(); |
| 323 |
| 313 // Connect the host clipboard and input stubs. | 324 // Connect the host clipboard and input stubs. |
| 314 host_input_filter_.set_input_stub(input_injector_.get()); | 325 host_input_filter_.set_input_stub(input_injector_.get()); |
| 315 clipboard_echo_filter_.set_host_stub(input_injector_.get()); | 326 clipboard_echo_filter_.set_host_stub(input_injector_.get()); |
| 316 | 327 |
| 317 // Create a VideoEncoder based on the session's video channel configuration. | 328 // Create a VideoEncoder based on the session's video channel configuration. |
| 318 scoped_ptr<VideoEncoder> video_encoder = | 329 scoped_ptr<VideoEncoder> video_encoder = |
| 319 CreateVideoEncoder(connection_->session()->config()); | 330 CreateVideoEncoder(connection_->session()->config()); |
| 320 | 331 |
| 321 // Create a VideoScheduler to pump frames from the capturer to the client. | 332 // Create a VideoScheduler to pump frames from the capturer to the client. |
| 322 video_scheduler_ = new VideoScheduler( | 333 // If cast mode is enabled, do not create it since screen capturer sharing |
| 334 // has not yet been implemented. |
| 335 if (!enable_cast_) { |
| 336 video_scheduler_ = new VideoScheduler( |
| 323 video_capture_task_runner_, | 337 video_capture_task_runner_, |
| 324 video_encode_task_runner_, | 338 video_encode_task_runner_, |
| 325 network_task_runner_, | 339 network_task_runner_, |
| 326 desktop_environment_->CreateVideoCapturer(), | 340 screen_capturer_.Pass(), |
| 327 video_encoder.Pass(), | 341 video_encoder.Pass(), |
| 328 connection_->client_stub(), | 342 connection_->client_stub(), |
| 329 &mouse_clamping_filter_); | 343 &mouse_clamping_filter_); |
| 330 | 344 } |
| 331 // Create an AudioScheduler if audio is enabled, to pump audio samples. | 345 // Create an AudioScheduler if audio is enabled, to pump audio samples. |
| 332 if (connection_->session()->config().is_audio_enabled()) { | 346 if (connection_->session()->config().is_audio_enabled()) { |
| 333 scoped_ptr<AudioEncoder> audio_encoder = | 347 scoped_ptr<AudioEncoder> audio_encoder = |
| 334 CreateAudioEncoder(connection_->session()->config()); | 348 CreateAudioEncoder(connection_->session()->config()); |
| 335 audio_scheduler_ = new AudioScheduler( | 349 audio_scheduler_ = new AudioScheduler( |
| 336 audio_task_runner_, | 350 audio_task_runner_, |
| 337 network_task_runner_, | 351 network_task_runner_, |
| 338 desktop_environment_->CreateAudioCapturer(), | 352 desktop_environment_->CreateAudioCapturer(), |
| 339 audio_encoder.Pass(), | 353 audio_encoder.Pass(), |
| 340 connection_->audio_stub()); | 354 connection_->audio_stub()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 356 | 370 |
| 357 protocol::Capabilities capabilities; | 371 protocol::Capabilities capabilities; |
| 358 capabilities.set_capabilities(host_capabilities_); | 372 capabilities.set_capabilities(host_capabilities_); |
| 359 connection_->client_stub()->SetCapabilities(capabilities); | 373 connection_->client_stub()->SetCapabilities(capabilities); |
| 360 } | 374 } |
| 361 | 375 |
| 362 // Start the event executor. | 376 // Start the event executor. |
| 363 input_injector_->Start(CreateClipboardProxy()); | 377 input_injector_->Start(CreateClipboardProxy()); |
| 364 SetDisableInputs(false); | 378 SetDisableInputs(false); |
| 365 | 379 |
| 366 // Start capturing the screen. | 380 // Start capturing the screen, if cast is not enabled. |
| 367 video_scheduler_->Start(); | 381 if (!enable_cast_) { |
| 382 video_scheduler_->Start(); |
| 383 } |
| 368 | 384 |
| 369 // Start recording audio. | 385 // Start recording audio. |
| 370 if (connection_->session()->config().is_audio_enabled()) | 386 if (connection_->session()->config().is_audio_enabled()) |
| 371 audio_scheduler_->Start(); | 387 audio_scheduler_->Start(); |
| 372 | 388 |
| 373 // Notify the event handler that all our channels are now connected. | 389 // Notify the event handler that all our channels are now connected. |
| 374 event_handler_->OnSessionChannelsConnected(this); | 390 event_handler_->OnSessionChannelsConnected(this); |
| 375 } | 391 } |
| 376 | 392 |
| 377 void ClientSession::OnConnectionClosed( | 393 void ClientSession::OnConnectionClosed( |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); | 522 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); |
| 507 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { | 523 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { |
| 508 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); | 524 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); |
| 509 } | 525 } |
| 510 | 526 |
| 511 NOTREACHED(); | 527 NOTREACHED(); |
| 512 return scoped_ptr<AudioEncoder>(); | 528 return scoped_ptr<AudioEncoder>(); |
| 513 } | 529 } |
| 514 | 530 |
| 515 } // namespace remoting | 531 } // namespace remoting |
| OLD | NEW |