| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "remoting/base/capabilities.h" | 15 #include "remoting/base/capabilities.h" |
| 15 #include "remoting/base/constants.h" | 16 #include "remoting/base/constants.h" |
| 16 #include "remoting/base/logging.h" | 17 #include "remoting/base/logging.h" |
| 17 #include "remoting/codec/audio_encoder.h" | 18 #include "remoting/codec/audio_encoder.h" |
| 18 #include "remoting/codec/audio_encoder_opus.h" | 19 #include "remoting/codec/audio_encoder_opus.h" |
| 19 #include "remoting/codec/audio_encoder_verbatim.h" | 20 #include "remoting/codec/audio_encoder_verbatim.h" |
| 20 #include "remoting/host/audio_capturer.h" | 21 #include "remoting/host/audio_capturer.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 #include "remoting/protocol/video_frame_pump.h" | 36 #include "remoting/protocol/video_frame_pump.h" |
| 36 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" | 37 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
| 37 | 38 |
| 38 namespace remoting { | 39 namespace remoting { |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 // Name of command-line flag to disable use of I444 by default. | 43 // Name of command-line flag to disable use of I444 by default. |
| 43 const char kDisableI444SwitchName[] = "disable-i444"; | 44 const char kDisableI444SwitchName[] = "disable-i444"; |
| 44 | 45 |
| 45 scoped_ptr<AudioEncoder> CreateAudioEncoder( | 46 std::unique_ptr<AudioEncoder> CreateAudioEncoder( |
| 46 const protocol::SessionConfig& config) { | 47 const protocol::SessionConfig& config) { |
| 47 const protocol::ChannelConfig& audio_config = config.audio_config(); | 48 const protocol::ChannelConfig& audio_config = config.audio_config(); |
| 48 | 49 |
| 49 if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { | 50 if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { |
| 50 return make_scoped_ptr(new AudioEncoderVerbatim()); | 51 return base::WrapUnique(new AudioEncoderVerbatim()); |
| 51 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { | 52 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { |
| 52 return make_scoped_ptr(new AudioEncoderOpus()); | 53 return base::WrapUnique(new AudioEncoderOpus()); |
| 53 } | 54 } |
| 54 | 55 |
| 55 NOTREACHED(); | 56 NOTREACHED(); |
| 56 return nullptr; | 57 return nullptr; |
| 57 } | 58 } |
| 58 | 59 |
| 59 } // namespace | 60 } // namespace |
| 60 | 61 |
| 61 ClientSession::ClientSession( | 62 ClientSession::ClientSession( |
| 62 EventHandler* event_handler, | 63 EventHandler* event_handler, |
| 63 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 64 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 64 scoped_ptr<protocol::ConnectionToClient> connection, | 65 std::unique_ptr<protocol::ConnectionToClient> connection, |
| 65 DesktopEnvironmentFactory* desktop_environment_factory, | 66 DesktopEnvironmentFactory* desktop_environment_factory, |
| 66 const base::TimeDelta& max_duration, | 67 const base::TimeDelta& max_duration, |
| 67 scoped_refptr<protocol::PairingRegistry> pairing_registry, | 68 scoped_refptr<protocol::PairingRegistry> pairing_registry, |
| 68 const std::vector<HostExtension*>& extensions) | 69 const std::vector<HostExtension*>& extensions) |
| 69 : event_handler_(event_handler), | 70 : event_handler_(event_handler), |
| 70 connection_(std::move(connection)), | 71 connection_(std::move(connection)), |
| 71 client_jid_(connection_->session()->jid()), | 72 client_jid_(connection_->session()->jid()), |
| 72 desktop_environment_factory_(desktop_environment_factory), | 73 desktop_environment_factory_(desktop_environment_factory), |
| 73 input_tracker_(&host_input_filter_), | 74 input_tracker_(&host_input_filter_), |
| 74 remote_input_filter_(&input_tracker_), | 75 remote_input_filter_(&input_tracker_), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 const protocol::Capabilities& capabilities) { | 181 const protocol::Capabilities& capabilities) { |
| 181 DCHECK(CalledOnValidThread()); | 182 DCHECK(CalledOnValidThread()); |
| 182 | 183 |
| 183 // Ignore all the messages but the 1st one. | 184 // Ignore all the messages but the 1st one. |
| 184 if (client_capabilities_) { | 185 if (client_capabilities_) { |
| 185 LOG(WARNING) << "protocol::Capabilities has been received already."; | 186 LOG(WARNING) << "protocol::Capabilities has been received already."; |
| 186 return; | 187 return; |
| 187 } | 188 } |
| 188 | 189 |
| 189 // Compute the set of capabilities supported by both client and host. | 190 // Compute the set of capabilities supported by both client and host. |
| 190 client_capabilities_ = make_scoped_ptr(new std::string()); | 191 client_capabilities_ = base::WrapUnique(new std::string()); |
| 191 if (capabilities.has_capabilities()) | 192 if (capabilities.has_capabilities()) |
| 192 *client_capabilities_ = capabilities.capabilities(); | 193 *client_capabilities_ = capabilities.capabilities(); |
| 193 capabilities_ = IntersectCapabilities(*client_capabilities_, | 194 capabilities_ = IntersectCapabilities(*client_capabilities_, |
| 194 host_capabilities_); | 195 host_capabilities_); |
| 195 extension_manager_->OnNegotiatedCapabilities( | 196 extension_manager_->OnNegotiatedCapabilities( |
| 196 connection_->client_stub(), capabilities_); | 197 connection_->client_stub(), capabilities_); |
| 197 | 198 |
| 198 VLOG(1) << "Client capabilities: " << *client_capabilities_; | 199 VLOG(1) << "Client capabilities: " << *client_capabilities_; |
| 199 | 200 |
| 200 // Calculate the set of capabilities enabled by both client and host and | 201 // Calculate the set of capabilities enabled by both client and host and |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 325 |
| 325 // Apply video-control parameters to the new stream. | 326 // Apply video-control parameters to the new stream. |
| 326 video_stream_->SetLosslessEncode(lossless_video_encode_); | 327 video_stream_->SetLosslessEncode(lossless_video_encode_); |
| 327 video_stream_->SetLosslessColor(lossless_video_color_); | 328 video_stream_->SetLosslessColor(lossless_video_color_); |
| 328 | 329 |
| 329 // Pause capturing if necessary. | 330 // Pause capturing if necessary. |
| 330 video_stream_->Pause(pause_video_); | 331 video_stream_->Pause(pause_video_); |
| 331 | 332 |
| 332 // Create an AudioPump if audio is enabled, to pump audio samples. | 333 // Create an AudioPump if audio is enabled, to pump audio samples. |
| 333 if (connection_->session()->config().is_audio_enabled()) { | 334 if (connection_->session()->config().is_audio_enabled()) { |
| 334 scoped_ptr<AudioEncoder> audio_encoder = | 335 std::unique_ptr<AudioEncoder> audio_encoder = |
| 335 CreateAudioEncoder(connection_->session()->config()); | 336 CreateAudioEncoder(connection_->session()->config()); |
| 336 audio_pump_.reset(new AudioPump( | 337 audio_pump_.reset(new AudioPump( |
| 337 audio_task_runner_, desktop_environment_->CreateAudioCapturer(), | 338 audio_task_runner_, desktop_environment_->CreateAudioCapturer(), |
| 338 std::move(audio_encoder), connection_->audio_stub())); | 339 std::move(audio_encoder), connection_->audio_stub())); |
| 339 } | 340 } |
| 340 | 341 |
| 341 // Notify the event handler that all our channels are now connected. | 342 // Notify the event handler that all our channels are now connected. |
| 342 event_handler_->OnSessionChannelsConnected(this); | 343 event_handler_->OnSessionChannelsConnected(this); |
| 343 } | 344 } |
| 344 | 345 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 void ClientSession::SetDisableInputs(bool disable_inputs) { | 417 void ClientSession::SetDisableInputs(bool disable_inputs) { |
| 417 DCHECK(CalledOnValidThread()); | 418 DCHECK(CalledOnValidThread()); |
| 418 | 419 |
| 419 if (disable_inputs) | 420 if (disable_inputs) |
| 420 input_tracker_.ReleaseAll(); | 421 input_tracker_.ReleaseAll(); |
| 421 | 422 |
| 422 disable_input_filter_.set_enabled(!disable_inputs); | 423 disable_input_filter_.set_enabled(!disable_inputs); |
| 423 disable_clipboard_filter_.set_enabled(!disable_inputs); | 424 disable_clipboard_filter_.set_enabled(!disable_inputs); |
| 424 } | 425 } |
| 425 | 426 |
| 426 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 427 std::unique_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
| 427 DCHECK(CalledOnValidThread()); | 428 DCHECK(CalledOnValidThread()); |
| 428 | 429 |
| 429 return make_scoped_ptr( | 430 return base::WrapUnique( |
| 430 new protocol::ClipboardThreadProxy(client_clipboard_factory_.GetWeakPtr(), | 431 new protocol::ClipboardThreadProxy(client_clipboard_factory_.GetWeakPtr(), |
| 431 base::ThreadTaskRunnerHandle::Get())); | 432 base::ThreadTaskRunnerHandle::Get())); |
| 432 } | 433 } |
| 433 | 434 |
| 434 void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size, | 435 void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size, |
| 435 const webrtc::DesktopVector& dpi) { | 436 const webrtc::DesktopVector& dpi) { |
| 436 DCHECK(CalledOnValidThread()); | 437 DCHECK(CalledOnValidThread()); |
| 437 | 438 |
| 438 mouse_clamping_filter_.set_input_size(size); | 439 mouse_clamping_filter_.set_input_size(size); |
| 439 mouse_clamping_filter_.set_output_size(size); | 440 mouse_clamping_filter_.set_output_size(size); |
| 440 | 441 |
| 441 if (connection_->session()->config().protocol() == | 442 if (connection_->session()->config().protocol() == |
| 442 protocol::SessionConfig::Protocol::WEBRTC) { | 443 protocol::SessionConfig::Protocol::WEBRTC) { |
| 443 protocol::VideoLayout layout; | 444 protocol::VideoLayout layout; |
| 444 protocol::VideoTrackLayout* video_track = layout.add_video_track(); | 445 protocol::VideoTrackLayout* video_track = layout.add_video_track(); |
| 445 video_track->set_position_x(0); | 446 video_track->set_position_x(0); |
| 446 video_track->set_position_y(0); | 447 video_track->set_position_y(0); |
| 447 video_track->set_width(size.width() * kDefaultDpi / dpi.x()); | 448 video_track->set_width(size.width() * kDefaultDpi / dpi.x()); |
| 448 video_track->set_height(size.height() * kDefaultDpi / dpi.y()); | 449 video_track->set_height(size.height() * kDefaultDpi / dpi.y()); |
| 449 video_track->set_x_dpi(dpi.x()); | 450 video_track->set_x_dpi(dpi.x()); |
| 450 video_track->set_y_dpi(dpi.y()); | 451 video_track->set_y_dpi(dpi.y()); |
| 451 connection_->client_stub()->SetVideoLayout(layout); | 452 connection_->client_stub()->SetVideoLayout(layout); |
| 452 } | 453 } |
| 453 } | 454 } |
| 454 | 455 |
| 455 } // namespace remoting | 456 } // namespace remoting |
| OLD | NEW |