Chromium Code Reviews| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "remoting/base/capabilities.h" | 12 #include "remoting/base/capabilities.h" |
| 13 #include "remoting/base/logging.h" | 13 #include "remoting/base/logging.h" |
| 14 #include "remoting/codec/audio_encoder.h" | 14 #include "remoting/codec/audio_encoder.h" |
| 15 #include "remoting/codec/audio_encoder_opus.h" | 15 #include "remoting/codec/audio_encoder_opus.h" |
| 16 #include "remoting/codec/audio_encoder_verbatim.h" | 16 #include "remoting/codec/audio_encoder_verbatim.h" |
| 17 #include "remoting/codec/video_encoder.h" | |
| 18 #include "remoting/codec/video_encoder_verbatim.h" | |
| 19 #include "remoting/codec/video_encoder_vpx.h" | |
| 20 #include "remoting/host/audio_capturer.h" | 17 #include "remoting/host/audio_capturer.h" |
| 21 #include "remoting/host/audio_pump.h" | 18 #include "remoting/host/audio_pump.h" |
| 22 #include "remoting/host/desktop_capturer_proxy.h" | 19 #include "remoting/host/desktop_capturer_proxy.h" |
| 23 #include "remoting/host/desktop_environment.h" | 20 #include "remoting/host/desktop_environment.h" |
| 24 #include "remoting/host/host_extension_session.h" | 21 #include "remoting/host/host_extension_session.h" |
| 25 #include "remoting/host/input_injector.h" | 22 #include "remoting/host/input_injector.h" |
| 26 #include "remoting/host/mouse_shape_pump.h" | 23 #include "remoting/host/mouse_shape_pump.h" |
| 27 #include "remoting/host/screen_controls.h" | 24 #include "remoting/host/screen_controls.h" |
| 28 #include "remoting/host/screen_resolution.h" | 25 #include "remoting/host/screen_resolution.h" |
| 29 #include "remoting/proto/control.pb.h" | 26 #include "remoting/proto/control.pb.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 40 // Default DPI to assume for old clients that use notifyClientDimensions. | 37 // Default DPI to assume for old clients that use notifyClientDimensions. |
| 41 const int kDefaultDPI = 96; | 38 const int kDefaultDPI = 96; |
| 42 | 39 |
| 43 namespace remoting { | 40 namespace remoting { |
| 44 | 41 |
| 45 namespace { | 42 namespace { |
| 46 | 43 |
| 47 // Name of command-line flag to disable use of I444 by default. | 44 // Name of command-line flag to disable use of I444 by default. |
| 48 const char kDisableI444SwitchName[] = "disable-i444"; | 45 const char kDisableI444SwitchName[] = "disable-i444"; |
| 49 | 46 |
| 50 scoped_ptr<VideoEncoder> CreateVideoEncoder( | |
| 51 const protocol::SessionConfig& config) { | |
| 52 const protocol::ChannelConfig& video_config = config.video_config(); | |
| 53 | |
| 54 if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { | |
| 55 return VideoEncoderVpx::CreateForVP8().Pass(); | |
| 56 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) { | |
| 57 return VideoEncoderVpx::CreateForVP9().Pass(); | |
| 58 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { | |
| 59 return make_scoped_ptr(new VideoEncoderVerbatim()); | |
| 60 } | |
| 61 | |
| 62 NOTREACHED(); | |
| 63 return nullptr; | |
| 64 } | |
| 65 | |
| 66 scoped_ptr<AudioEncoder> CreateAudioEncoder( | 47 scoped_ptr<AudioEncoder> CreateAudioEncoder( |
| 67 const protocol::SessionConfig& config) { | 48 const protocol::SessionConfig& config) { |
| 68 const protocol::ChannelConfig& audio_config = config.audio_config(); | 49 const protocol::ChannelConfig& audio_config = config.audio_config(); |
| 69 | 50 |
| 70 if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { | 51 if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { |
| 71 return make_scoped_ptr(new AudioEncoderVerbatim()); | 52 return make_scoped_ptr(new AudioEncoderVerbatim()); |
| 72 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { | 53 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { |
| 73 return make_scoped_ptr(new AudioEncoderOpus()); | 54 return make_scoped_ptr(new AudioEncoderOpus()); |
| 74 } | 55 } |
| 75 | 56 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 92 const base::TimeDelta& max_duration, | 73 const base::TimeDelta& max_duration, |
| 93 scoped_refptr<protocol::PairingRegistry> pairing_registry, | 74 scoped_refptr<protocol::PairingRegistry> pairing_registry, |
| 94 const std::vector<HostExtension*>& extensions) | 75 const std::vector<HostExtension*>& extensions) |
| 95 : event_handler_(event_handler), | 76 : event_handler_(event_handler), |
| 96 connection_(connection.Pass()), | 77 connection_(connection.Pass()), |
| 97 client_jid_(connection_->session()->jid()), | 78 client_jid_(connection_->session()->jid()), |
| 98 desktop_environment_factory_(desktop_environment_factory), | 79 desktop_environment_factory_(desktop_environment_factory), |
| 99 input_tracker_(&host_input_filter_), | 80 input_tracker_(&host_input_filter_), |
| 100 remote_input_filter_(&input_tracker_), | 81 remote_input_filter_(&input_tracker_), |
| 101 mouse_clamping_filter_(&remote_input_filter_), | 82 mouse_clamping_filter_(&remote_input_filter_), |
| 102 disable_input_filter_(mouse_clamping_filter_.input_filter()), | 83 disable_input_filter_(&mouse_clamping_filter_), |
| 103 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), | 84 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), |
| 104 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), | 85 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
| 105 max_duration_(max_duration), | 86 max_duration_(max_duration), |
| 106 audio_task_runner_(audio_task_runner), | 87 audio_task_runner_(audio_task_runner), |
| 107 input_task_runner_(input_task_runner), | 88 input_task_runner_(input_task_runner), |
| 108 video_capture_task_runner_(video_capture_task_runner), | 89 video_capture_task_runner_(video_capture_task_runner), |
| 109 video_encode_task_runner_(video_encode_task_runner), | 90 video_encode_task_runner_(video_encode_task_runner), |
| 110 network_task_runner_(network_task_runner), | 91 network_task_runner_(network_task_runner), |
| 111 ui_task_runner_(ui_task_runner), | 92 ui_task_runner_(ui_task_runner), |
| 112 pairing_registry_(pairing_registry), | 93 pairing_registry_(pairing_registry), |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 128 // reaches |remote_input_filter_|. | 109 // reaches |remote_input_filter_|. |
| 129 remote_input_filter_.SetExpectLocalEcho(false); | 110 remote_input_filter_.SetExpectLocalEcho(false); |
| 130 #endif // defined(OS_WIN) | 111 #endif // defined(OS_WIN) |
| 131 } | 112 } |
| 132 | 113 |
| 133 ClientSession::~ClientSession() { | 114 ClientSession::~ClientSession() { |
| 134 DCHECK(CalledOnValidThread()); | 115 DCHECK(CalledOnValidThread()); |
| 135 DCHECK(!audio_pump_); | 116 DCHECK(!audio_pump_); |
| 136 DCHECK(!desktop_environment_); | 117 DCHECK(!desktop_environment_); |
| 137 DCHECK(!input_injector_); | 118 DCHECK(!input_injector_); |
| 138 DCHECK(!screen_controls_); | 119 DCHECK(!screen_controls_); |
|
Jamie
2015/11/25 01:32:46
No DCHECK for video_stream_?
Sergey Ulanov
2015/11/27 22:11:34
Done.
| |
| 139 DCHECK(!video_frame_pump_); | |
| 140 | 120 |
| 141 connection_.reset(); | 121 connection_.reset(); |
| 142 } | 122 } |
| 143 | 123 |
| 144 void ClientSession::NotifyClientResolution( | 124 void ClientSession::NotifyClientResolution( |
| 145 const protocol::ClientResolution& resolution) { | 125 const protocol::ClientResolution& resolution) { |
| 146 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
| 147 | 127 |
| 148 // TODO(sergeyu): Move these checks to protocol layer. | 128 // TODO(sergeyu): Move these checks to protocol layer. |
| 149 if (!resolution.has_dips_width() || !resolution.has_dips_height() || | 129 if (!resolution.has_dips_width() || !resolution.has_dips_height() || |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 164 webrtc::DesktopSize(resolution.dips_width(), resolution.dips_height()), | 144 webrtc::DesktopSize(resolution.dips_width(), resolution.dips_height()), |
| 165 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); | 145 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); |
| 166 | 146 |
| 167 // Try to match the client's resolution. | 147 // Try to match the client's resolution. |
| 168 screen_controls_->SetScreenResolution(client_resolution); | 148 screen_controls_->SetScreenResolution(client_resolution); |
| 169 } | 149 } |
| 170 | 150 |
| 171 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 151 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| 172 DCHECK(CalledOnValidThread()); | 152 DCHECK(CalledOnValidThread()); |
| 173 | 153 |
| 174 // Note that |video_frame_pump_| may be null, depending upon whether | 154 // Note that |video_stream_| may be null, depending upon whether |
| 175 // extensions choose to wrap or "steal" the video capturer or encoder. | 155 // extensions choose to wrap or "steal" the video capturer or encoder. |
| 176 if (video_control.has_enable()) { | 156 if (video_control.has_enable()) { |
| 177 VLOG(1) << "Received VideoControl (enable=" | 157 VLOG(1) << "Received VideoControl (enable=" |
| 178 << video_control.enable() << ")"; | 158 << video_control.enable() << ")"; |
| 179 pause_video_ = !video_control.enable(); | 159 pause_video_ = !video_control.enable(); |
| 180 if (video_frame_pump_) | 160 if (video_stream_) |
| 181 video_frame_pump_->Pause(pause_video_); | 161 video_stream_->Pause(pause_video_); |
| 182 } | 162 } |
| 183 if (video_control.has_lossless_encode()) { | 163 if (video_control.has_lossless_encode()) { |
| 184 VLOG(1) << "Received VideoControl (lossless_encode=" | 164 VLOG(1) << "Received VideoControl (lossless_encode=" |
| 185 << video_control.lossless_encode() << ")"; | 165 << video_control.lossless_encode() << ")"; |
| 186 lossless_video_encode_ = video_control.lossless_encode(); | 166 lossless_video_encode_ = video_control.lossless_encode(); |
| 187 if (video_frame_pump_) | 167 if (video_stream_) |
| 188 video_frame_pump_->SetLosslessEncode(lossless_video_encode_); | 168 video_stream_->SetLosslessEncode(lossless_video_encode_); |
| 189 } | 169 } |
| 190 if (video_control.has_lossless_color()) { | 170 if (video_control.has_lossless_color()) { |
| 191 VLOG(1) << "Received VideoControl (lossless_color=" | 171 VLOG(1) << "Received VideoControl (lossless_color=" |
| 192 << video_control.lossless_color() << ")"; | 172 << video_control.lossless_color() << ")"; |
| 193 lossless_video_color_ = video_control.lossless_color(); | 173 lossless_video_color_ = video_control.lossless_color(); |
| 194 if (video_frame_pump_) | 174 if (video_stream_) |
| 195 video_frame_pump_->SetLosslessColor(lossless_video_color_); | 175 video_stream_->SetLosslessColor(lossless_video_color_); |
| 196 } | 176 } |
| 197 } | 177 } |
| 198 | 178 |
| 199 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { | 179 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { |
| 200 DCHECK(CalledOnValidThread()); | 180 DCHECK(CalledOnValidThread()); |
| 201 | 181 |
| 202 if (audio_control.has_enable()) { | 182 if (audio_control.has_enable()) { |
| 203 VLOG(1) << "Received AudioControl (enable=" | 183 VLOG(1) << "Received AudioControl (enable=" |
| 204 << audio_control.enable() << ")"; | 184 << audio_control.enable() << ")"; |
| 205 if (audio_pump_) | 185 if (audio_pump_) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 } | 258 } |
| 279 | 259 |
| 280 void ClientSession::OnConnectionAuthenticated( | 260 void ClientSession::OnConnectionAuthenticated( |
| 281 protocol::ConnectionToClient* connection) { | 261 protocol::ConnectionToClient* connection) { |
| 282 DCHECK(CalledOnValidThread()); | 262 DCHECK(CalledOnValidThread()); |
| 283 DCHECK_EQ(connection_.get(), connection); | 263 DCHECK_EQ(connection_.get(), connection); |
| 284 DCHECK(!audio_pump_); | 264 DCHECK(!audio_pump_); |
| 285 DCHECK(!desktop_environment_); | 265 DCHECK(!desktop_environment_); |
| 286 DCHECK(!input_injector_); | 266 DCHECK(!input_injector_); |
| 287 DCHECK(!screen_controls_); | 267 DCHECK(!screen_controls_); |
| 288 DCHECK(!video_frame_pump_); | 268 DCHECK(!video_stream_); |
| 289 | 269 |
| 290 is_authenticated_ = true; | 270 is_authenticated_ = true; |
| 291 | 271 |
| 292 if (max_duration_ > base::TimeDelta()) { | 272 if (max_duration_ > base::TimeDelta()) { |
| 293 max_duration_timer_.Start( | 273 max_duration_timer_.Start( |
| 294 FROM_HERE, max_duration_, | 274 FROM_HERE, max_duration_, |
| 295 base::Bind(&ClientSession::DisconnectSession, base::Unretained(this), | 275 base::Bind(&ClientSession::DisconnectSession, base::Unretained(this), |
| 296 protocol::MAX_SESSION_LENGTH)); | 276 protocol::MAX_SESSION_LENGTH)); |
| 297 } | 277 } |
| 298 | 278 |
| 299 // Notify EventHandler. | 279 // Notify EventHandler. |
| 300 event_handler_->OnSessionAuthenticated(this); | 280 event_handler_->OnSessionAuthenticated(this); |
| 301 | 281 |
| 302 // Create the desktop environment. Drop the connection if it could not be | 282 // Create the desktop environment. Drop the connection if it could not be |
| 303 // created for any reason (for instance the curtain could not initialize). | 283 // created for any reason (for instance the curtain could not initialize). |
| 304 desktop_environment_ = | 284 desktop_environment_ = |
| 305 desktop_environment_factory_->Create(weak_factory_.GetWeakPtr()); | 285 desktop_environment_factory_->Create(weak_factory_.GetWeakPtr()); |
| 306 if (!desktop_environment_) { | 286 if (!desktop_environment_) { |
| 307 DisconnectSession(protocol::HOST_CONFIGURATION_ERROR); | 287 DisconnectSession(protocol::HOST_CONFIGURATION_ERROR); |
| 308 return; | 288 return; |
| 309 } | 289 } |
| 310 | 290 |
| 311 // Connect host stub. | 291 // Connect host stub. |
| 312 connection_->set_host_stub(this); | 292 connection_->set_host_stub(this); |
| 313 | 293 |
| 314 // Connect video stub. | |
| 315 mouse_clamping_filter_.set_video_stub(connection_->video_stub()); | |
| 316 | |
| 317 // Collate the set of capabilities to offer the client, if it supports them. | 294 // Collate the set of capabilities to offer the client, if it supports them. |
| 318 host_capabilities_ = desktop_environment_->GetCapabilities(); | 295 host_capabilities_ = desktop_environment_->GetCapabilities(); |
| 319 if (!host_capabilities_.empty()) | 296 if (!host_capabilities_.empty()) |
| 320 host_capabilities_.append(" "); | 297 host_capabilities_.append(" "); |
| 321 host_capabilities_.append(extension_manager_->GetCapabilities()); | 298 host_capabilities_.append(extension_manager_->GetCapabilities()); |
| 322 | 299 |
| 323 // Create the object that controls the screen resolution. | 300 // Create the object that controls the screen resolution. |
| 324 screen_controls_ = desktop_environment_->CreateScreenControls(); | 301 screen_controls_ = desktop_environment_->CreateScreenControls(); |
| 325 | 302 |
| 326 // Create the event executor. | 303 // Create the event executor. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 // If the client never authenticated then the session failed. | 362 // If the client never authenticated then the session failed. |
| 386 if (!is_authenticated_) | 363 if (!is_authenticated_) |
| 387 event_handler_->OnSessionAuthenticationFailed(this); | 364 event_handler_->OnSessionAuthenticationFailed(this); |
| 388 | 365 |
| 389 // Ensure that any pressed keys or buttons are released. | 366 // Ensure that any pressed keys or buttons are released. |
| 390 input_tracker_.ReleaseAll(); | 367 input_tracker_.ReleaseAll(); |
| 391 | 368 |
| 392 // Stop components access the client, audio or video stubs, which are no | 369 // Stop components access the client, audio or video stubs, which are no |
| 393 // longer valid once ConnectionToClient calls OnConnectionClosed(). | 370 // longer valid once ConnectionToClient calls OnConnectionClosed(). |
| 394 audio_pump_.reset(); | 371 audio_pump_.reset(); |
| 395 video_frame_pump_.reset(); | 372 video_stream_.reset(); |
| 396 mouse_shape_pump_.reset(); | 373 mouse_shape_pump_.reset(); |
| 397 client_clipboard_factory_.InvalidateWeakPtrs(); | 374 client_clipboard_factory_.InvalidateWeakPtrs(); |
| 398 input_injector_.reset(); | 375 input_injector_.reset(); |
| 399 screen_controls_.reset(); | 376 screen_controls_.reset(); |
| 400 desktop_environment_.reset(); | 377 desktop_environment_.reset(); |
| 401 | 378 |
| 402 // Notify the ChromotingHost that this client is disconnected. | 379 // Notify the ChromotingHost that this client is disconnected. |
| 403 event_handler_->OnSessionClosed(this); | 380 event_handler_->OnSessionClosed(this); |
| 404 } | 381 } |
| 405 | 382 |
| 383 void ClientSession::OnCreateVideoEncoder(scoped_ptr<VideoEncoder>* encoder) { | |
| 384 DCHECK(CalledOnValidThread()); | |
| 385 extension_manager_->OnCreateVideoEncoder(encoder); | |
| 386 } | |
| 387 | |
| 406 void ClientSession::OnInputEventReceived( | 388 void ClientSession::OnInputEventReceived( |
| 407 protocol::ConnectionToClient* connection, | 389 protocol::ConnectionToClient* connection, |
| 408 int64_t event_timestamp) { | 390 int64_t event_timestamp) { |
| 409 DCHECK(CalledOnValidThread()); | 391 DCHECK(CalledOnValidThread()); |
| 410 DCHECK_EQ(connection_.get(), connection); | 392 DCHECK_EQ(connection_.get(), connection); |
| 411 | 393 |
| 412 if (video_frame_pump_.get()) | 394 if (video_stream_.get()) |
| 413 video_frame_pump_->OnInputEventReceived(event_timestamp); | 395 video_stream_->OnInputEventReceived(event_timestamp); |
| 414 } | 396 } |
| 415 | 397 |
| 416 void ClientSession::OnRouteChange( | 398 void ClientSession::OnRouteChange( |
| 417 protocol::ConnectionToClient* connection, | 399 protocol::ConnectionToClient* connection, |
| 418 const std::string& channel_name, | 400 const std::string& channel_name, |
| 419 const protocol::TransportRoute& route) { | 401 const protocol::TransportRoute& route) { |
| 420 DCHECK(CalledOnValidThread()); | 402 DCHECK(CalledOnValidThread()); |
| 421 DCHECK_EQ(connection_.get(), connection); | 403 DCHECK_EQ(connection_.get(), connection); |
| 422 event_handler_->OnSessionRouteChange(this, channel_name, route); | 404 event_handler_->OnSessionRouteChange(this, channel_name, route); |
| 423 } | 405 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 448 if (disable_inputs) | 430 if (disable_inputs) |
| 449 input_tracker_.ReleaseAll(); | 431 input_tracker_.ReleaseAll(); |
| 450 | 432 |
| 451 disable_input_filter_.set_enabled(!disable_inputs); | 433 disable_input_filter_.set_enabled(!disable_inputs); |
| 452 disable_clipboard_filter_.set_enabled(!disable_inputs); | 434 disable_clipboard_filter_.set_enabled(!disable_inputs); |
| 453 } | 435 } |
| 454 | 436 |
| 455 void ClientSession::ResetVideoPipeline() { | 437 void ClientSession::ResetVideoPipeline() { |
| 456 DCHECK(CalledOnValidThread()); | 438 DCHECK(CalledOnValidThread()); |
| 457 | 439 |
| 440 video_stream_.reset(); | |
| 458 mouse_shape_pump_.reset(); | 441 mouse_shape_pump_.reset(); |
| 459 connection_->set_video_feedback_stub(nullptr); | |
| 460 video_frame_pump_.reset(); | |
| 461 | 442 |
| 462 // Create VideoEncoder and DesktopCapturer to match the session's video | 443 // Create VideoEncoder and DesktopCapturer to match the session's video |
| 463 // channel configuration. | 444 // channel configuration. |
| 464 scoped_ptr<webrtc::DesktopCapturer> video_capturer = | 445 scoped_ptr<webrtc::DesktopCapturer> video_capturer = |
| 465 desktop_environment_->CreateVideoCapturer(); | 446 desktop_environment_->CreateVideoCapturer(); |
| 466 extension_manager_->OnCreateVideoCapturer(&video_capturer); | 447 extension_manager_->OnCreateVideoCapturer(&video_capturer); |
| 467 scoped_ptr<VideoEncoder> video_encoder = | |
| 468 CreateVideoEncoder(connection_->session()->config()); | |
| 469 extension_manager_->OnCreateVideoEncoder(&video_encoder); | |
| 470 | 448 |
| 471 // Don't start the VideoFramePump if either capturer or encoder are missing. | 449 // Don't start the video stream if the extension took ownership of the |
| 472 if (!video_capturer || !video_encoder) | 450 // capturer. |
| 451 if (!video_capturer) | |
| 473 return; | 452 return; |
| 474 | 453 |
| 475 // Create MouseShapePump to send mouse cursor shape. | 454 // Create MouseShapePump to send mouse cursor shape. |
| 476 mouse_shape_pump_.reset( | 455 mouse_shape_pump_.reset( |
| 477 new MouseShapePump(video_capture_task_runner_, | 456 new MouseShapePump(video_capture_task_runner_, |
| 478 desktop_environment_->CreateMouseCursorMonitor(), | 457 desktop_environment_->CreateMouseCursorMonitor(), |
| 479 connection_->client_stub())); | 458 connection_->client_stub())); |
| 480 | 459 |
| 481 // Create a VideoFramePump to pump frames from the capturer to the client.' | 460 // Create a VideoStream to pump frames from the capturer to the client. |
| 482 // | 461 |
| 483 // TODO(sergeyu): Move DesktopCapturerProxy creation to DesktopEnvironment. | 462 // TODO(sergeyu): Move DesktopCapturerProxy creation to DesktopEnvironment. |
| 484 // When using IpcDesktopCapturer the capture thread is not useful. | 463 // When using IpcDesktopCapturer the capture thread is not useful. |
| 485 scoped_ptr<DesktopCapturerProxy> capturer_proxy(new DesktopCapturerProxy( | 464 scoped_ptr<webrtc::DesktopCapturer> capturer_proxy(new DesktopCapturerProxy( |
| 486 video_capture_task_runner_, video_capturer.Pass())); | 465 video_capture_task_runner_, video_capturer.Pass())); |
| 487 video_frame_pump_.reset(new protocol::VideoFramePump( | |
| 488 video_encode_task_runner_, capturer_proxy.Pass(), video_encoder.Pass(), | |
| 489 &mouse_clamping_filter_)); | |
| 490 | 466 |
| 491 // Apply video-control parameters to the new scheduler. | 467 video_stream_ = connection_->StartVideoStream(capturer_proxy.Pass()); |
| 492 video_frame_pump_->SetLosslessEncode(lossless_video_encode_); | 468 video_stream_->SetSizeCallback( |
| 493 video_frame_pump_->SetLosslessColor(lossless_video_color_); | 469 base::Bind(&ClientSession::OnScreenSizeChanged, base::Unretained(this))); |
| 470 | |
| 471 // Apply video-control parameters to the new stream. | |
| 472 video_stream_->SetLosslessEncode(lossless_video_encode_); | |
| 473 video_stream_->SetLosslessColor(lossless_video_color_); | |
| 494 | 474 |
| 495 // Pause capturing if necessary. | 475 // Pause capturing if necessary. |
| 496 video_frame_pump_->Pause(pause_video_); | 476 video_stream_->Pause(pause_video_); |
| 497 | |
| 498 connection_->set_video_feedback_stub( | |
| 499 video_frame_pump_->video_feedback_stub()); | |
| 500 } | 477 } |
| 501 | 478 |
| 502 void ClientSession::SetGnubbyAuthHandlerForTesting( | 479 void ClientSession::SetGnubbyAuthHandlerForTesting( |
| 503 GnubbyAuthHandler* gnubby_auth_handler) { | 480 GnubbyAuthHandler* gnubby_auth_handler) { |
| 504 DCHECK(CalledOnValidThread()); | 481 DCHECK(CalledOnValidThread()); |
| 505 gnubby_auth_handler_.reset(gnubby_auth_handler); | 482 gnubby_auth_handler_.reset(gnubby_auth_handler); |
| 506 } | 483 } |
| 507 | 484 |
| 508 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 485 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
| 509 DCHECK(CalledOnValidThread()); | 486 DCHECK(CalledOnValidThread()); |
| 510 | 487 |
| 511 return make_scoped_ptr( | 488 return make_scoped_ptr( |
| 512 new protocol::ClipboardThreadProxy(client_clipboard_factory_.GetWeakPtr(), | 489 new protocol::ClipboardThreadProxy(client_clipboard_factory_.GetWeakPtr(), |
| 513 base::ThreadTaskRunnerHandle::Get())); | 490 base::ThreadTaskRunnerHandle::Get())); |
| 514 } | 491 } |
| 515 | 492 |
| 493 void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size) { | |
| 494 DCHECK(CalledOnValidThread()); | |
| 495 mouse_clamping_filter_.set_input_size(size); | |
| 496 mouse_clamping_filter_.set_output_size(size); | |
| 497 } | |
| 498 | |
| 516 } // namespace remoting | 499 } // namespace remoting |
| OLD | NEW |