| 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/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "remoting/base/capabilities.h" | 14 #include "remoting/base/capabilities.h" |
| 15 #include "remoting/base/constants.h" |
| 15 #include "remoting/base/logging.h" | 16 #include "remoting/base/logging.h" |
| 16 #include "remoting/codec/audio_encoder.h" | 17 #include "remoting/codec/audio_encoder.h" |
| 17 #include "remoting/codec/audio_encoder_opus.h" | 18 #include "remoting/codec/audio_encoder_opus.h" |
| 18 #include "remoting/codec/audio_encoder_verbatim.h" | 19 #include "remoting/codec/audio_encoder_verbatim.h" |
| 19 #include "remoting/host/audio_capturer.h" | 20 #include "remoting/host/audio_capturer.h" |
| 20 #include "remoting/host/audio_pump.h" | 21 #include "remoting/host/audio_pump.h" |
| 21 #include "remoting/host/desktop_environment.h" | 22 #include "remoting/host/desktop_environment.h" |
| 22 #include "remoting/host/host_extension_session.h" | 23 #include "remoting/host/host_extension_session.h" |
| 23 #include "remoting/host/input_injector.h" | 24 #include "remoting/host/input_injector.h" |
| 24 #include "remoting/host/mouse_shape_pump.h" | 25 #include "remoting/host/mouse_shape_pump.h" |
| 25 #include "remoting/host/screen_controls.h" | 26 #include "remoting/host/screen_controls.h" |
| 26 #include "remoting/host/screen_resolution.h" | 27 #include "remoting/host/screen_resolution.h" |
| 27 #include "remoting/proto/control.pb.h" | 28 #include "remoting/proto/control.pb.h" |
| 28 #include "remoting/proto/event.pb.h" | 29 #include "remoting/proto/event.pb.h" |
| 29 #include "remoting/protocol/client_stub.h" | 30 #include "remoting/protocol/client_stub.h" |
| 30 #include "remoting/protocol/clipboard_thread_proxy.h" | 31 #include "remoting/protocol/clipboard_thread_proxy.h" |
| 31 #include "remoting/protocol/pairing_registry.h" | 32 #include "remoting/protocol/pairing_registry.h" |
| 32 #include "remoting/protocol/session.h" | 33 #include "remoting/protocol/session.h" |
| 33 #include "remoting/protocol/session_config.h" | 34 #include "remoting/protocol/session_config.h" |
| 34 #include "remoting/protocol/video_frame_pump.h" | 35 #include "remoting/protocol/video_frame_pump.h" |
| 35 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" | 36 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
| 36 | 37 |
| 37 // Default DPI to assume for old clients that use notifyClientDimensions. | |
| 38 const int kDefaultDPI = 96; | |
| 39 | |
| 40 namespace remoting { | 38 namespace remoting { |
| 41 | 39 |
| 42 namespace { | 40 namespace { |
| 43 | 41 |
| 44 // Name of command-line flag to disable use of I444 by default. | 42 // Name of command-line flag to disable use of I444 by default. |
| 45 const char kDisableI444SwitchName[] = "disable-i444"; | 43 const char kDisableI444SwitchName[] = "disable-i444"; |
| 46 | 44 |
| 47 scoped_ptr<AudioEncoder> CreateAudioEncoder( | 45 scoped_ptr<AudioEncoder> CreateAudioEncoder( |
| 48 const protocol::SessionConfig& config) { | 46 const protocol::SessionConfig& config) { |
| 49 const protocol::ChannelConfig& audio_config = config.audio_config(); | 47 const protocol::ChannelConfig& audio_config = config.audio_config(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 124 |
| 127 VLOG(1) << "Received ClientResolution (dips_width=" | 125 VLOG(1) << "Received ClientResolution (dips_width=" |
| 128 << resolution.dips_width() << ", dips_height=" | 126 << resolution.dips_width() << ", dips_height=" |
| 129 << resolution.dips_height() << ")"; | 127 << resolution.dips_height() << ")"; |
| 130 | 128 |
| 131 if (!screen_controls_) | 129 if (!screen_controls_) |
| 132 return; | 130 return; |
| 133 | 131 |
| 134 ScreenResolution client_resolution( | 132 ScreenResolution client_resolution( |
| 135 webrtc::DesktopSize(resolution.dips_width(), resolution.dips_height()), | 133 webrtc::DesktopSize(resolution.dips_width(), resolution.dips_height()), |
| 136 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); | 134 webrtc::DesktopVector(kDefaultDpi, kDefaultDpi)); |
| 137 | 135 |
| 138 // Try to match the client's resolution. | 136 // Try to match the client's resolution. |
| 139 screen_controls_->SetScreenResolution(client_resolution); | 137 screen_controls_->SetScreenResolution(client_resolution); |
| 140 } | 138 } |
| 141 | 139 |
| 142 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 140 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| 143 DCHECK(CalledOnValidThread()); | 141 DCHECK(CalledOnValidThread()); |
| 144 | 142 |
| 145 // Note that |video_stream_| may be null, depending upon whether | 143 // Note that |video_stream_| may be null, depending upon whether |
| 146 // extensions choose to wrap or "steal" the video capturer or encoder. | 144 // extensions choose to wrap or "steal" the video capturer or encoder. |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 } | 449 } |
| 452 | 450 |
| 453 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 451 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
| 454 DCHECK(CalledOnValidThread()); | 452 DCHECK(CalledOnValidThread()); |
| 455 | 453 |
| 456 return make_scoped_ptr( | 454 return make_scoped_ptr( |
| 457 new protocol::ClipboardThreadProxy(client_clipboard_factory_.GetWeakPtr(), | 455 new protocol::ClipboardThreadProxy(client_clipboard_factory_.GetWeakPtr(), |
| 458 base::ThreadTaskRunnerHandle::Get())); | 456 base::ThreadTaskRunnerHandle::Get())); |
| 459 } | 457 } |
| 460 | 458 |
| 461 void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size) { | 459 void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size, |
| 460 const webrtc::DesktopVector& dpi) { |
| 462 DCHECK(CalledOnValidThread()); | 461 DCHECK(CalledOnValidThread()); |
| 462 |
| 463 mouse_clamping_filter_.set_input_size(size); | 463 mouse_clamping_filter_.set_input_size(size); |
| 464 mouse_clamping_filter_.set_output_size(size); | 464 mouse_clamping_filter_.set_output_size(size); |
| 465 |
| 466 if (connection_->session()->config().protocol() == |
| 467 protocol::SessionConfig::Protocol::WEBRTC) { |
| 468 protocol::VideoLayout layout; |
| 469 protocol::VideoTrackLayout* video_track = layout.add_video_track(); |
| 470 video_track->set_position_x(0); |
| 471 video_track->set_position_y(0); |
| 472 video_track->set_width(size.width() * kDefaultDpi / dpi.x()); |
| 473 video_track->set_height(size.height() * kDefaultDpi / dpi.y()); |
| 474 video_track->set_x_dpi(dpi.x()); |
| 475 video_track->set_y_dpi(dpi.y()); |
| 476 connection_->client_stub()->SetVideoLayout(layout); |
| 477 } |
| 465 } | 478 } |
| 466 | 479 |
| 467 } // namespace remoting | 480 } // namespace remoting |
| OLD | NEW |