| 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 16 matching lines...) Expand all Loading... |
| 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_); |
| 139 DCHECK(!video_frame_pump_); | 120 DCHECK(!video_stream_); |
| 140 | 121 |
| 141 connection_.reset(); | 122 connection_.reset(); |
| 142 } | 123 } |
| 143 | 124 |
| 144 void ClientSession::NotifyClientResolution( | 125 void ClientSession::NotifyClientResolution( |
| 145 const protocol::ClientResolution& resolution) { | 126 const protocol::ClientResolution& resolution) { |
| 146 DCHECK(CalledOnValidThread()); | 127 DCHECK(CalledOnValidThread()); |
| 147 | 128 |
| 148 // TODO(sergeyu): Move these checks to protocol layer. | 129 // TODO(sergeyu): Move these checks to protocol layer. |
| 149 if (!resolution.has_dips_width() || !resolution.has_dips_height() || | 130 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()), | 145 webrtc::DesktopSize(resolution.dips_width(), resolution.dips_height()), |
| 165 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); | 146 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); |
| 166 | 147 |
| 167 // Try to match the client's resolution. | 148 // Try to match the client's resolution. |
| 168 screen_controls_->SetScreenResolution(client_resolution); | 149 screen_controls_->SetScreenResolution(client_resolution); |
| 169 } | 150 } |
| 170 | 151 |
| 171 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 152 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| 172 DCHECK(CalledOnValidThread()); | 153 DCHECK(CalledOnValidThread()); |
| 173 | 154 |
| 174 // Note that |video_frame_pump_| may be null, depending upon whether | 155 // Note that |video_stream_| may be null, depending upon whether |
| 175 // extensions choose to wrap or "steal" the video capturer or encoder. | 156 // extensions choose to wrap or "steal" the video capturer or encoder. |
| 176 if (video_control.has_enable()) { | 157 if (video_control.has_enable()) { |
| 177 VLOG(1) << "Received VideoControl (enable=" | 158 VLOG(1) << "Received VideoControl (enable=" |
| 178 << video_control.enable() << ")"; | 159 << video_control.enable() << ")"; |
| 179 pause_video_ = !video_control.enable(); | 160 pause_video_ = !video_control.enable(); |
| 180 if (video_frame_pump_) | 161 if (video_stream_) |
| 181 video_frame_pump_->Pause(pause_video_); | 162 video_stream_->Pause(pause_video_); |
| 182 } | 163 } |
| 183 if (video_control.has_lossless_encode()) { | 164 if (video_control.has_lossless_encode()) { |
| 184 VLOG(1) << "Received VideoControl (lossless_encode=" | 165 VLOG(1) << "Received VideoControl (lossless_encode=" |
| 185 << video_control.lossless_encode() << ")"; | 166 << video_control.lossless_encode() << ")"; |
| 186 lossless_video_encode_ = video_control.lossless_encode(); | 167 lossless_video_encode_ = video_control.lossless_encode(); |
| 187 if (video_frame_pump_) | 168 if (video_stream_) |
| 188 video_frame_pump_->SetLosslessEncode(lossless_video_encode_); | 169 video_stream_->SetLosslessEncode(lossless_video_encode_); |
| 189 } | 170 } |
| 190 if (video_control.has_lossless_color()) { | 171 if (video_control.has_lossless_color()) { |
| 191 VLOG(1) << "Received VideoControl (lossless_color=" | 172 VLOG(1) << "Received VideoControl (lossless_color=" |
| 192 << video_control.lossless_color() << ")"; | 173 << video_control.lossless_color() << ")"; |
| 193 lossless_video_color_ = video_control.lossless_color(); | 174 lossless_video_color_ = video_control.lossless_color(); |
| 194 if (video_frame_pump_) | 175 if (video_stream_) |
| 195 video_frame_pump_->SetLosslessColor(lossless_video_color_); | 176 video_stream_->SetLosslessColor(lossless_video_color_); |
| 196 } | 177 } |
| 197 } | 178 } |
| 198 | 179 |
| 199 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { | 180 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { |
| 200 DCHECK(CalledOnValidThread()); | 181 DCHECK(CalledOnValidThread()); |
| 201 | 182 |
| 202 if (audio_control.has_enable()) { | 183 if (audio_control.has_enable()) { |
| 203 VLOG(1) << "Received AudioControl (enable=" | 184 VLOG(1) << "Received AudioControl (enable=" |
| 204 << audio_control.enable() << ")"; | 185 << audio_control.enable() << ")"; |
| 205 if (audio_pump_) | 186 if (audio_pump_) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 259 } |
| 279 | 260 |
| 280 void ClientSession::OnConnectionAuthenticated( | 261 void ClientSession::OnConnectionAuthenticated( |
| 281 protocol::ConnectionToClient* connection) { | 262 protocol::ConnectionToClient* connection) { |
| 282 DCHECK(CalledOnValidThread()); | 263 DCHECK(CalledOnValidThread()); |
| 283 DCHECK_EQ(connection_.get(), connection); | 264 DCHECK_EQ(connection_.get(), connection); |
| 284 DCHECK(!audio_pump_); | 265 DCHECK(!audio_pump_); |
| 285 DCHECK(!desktop_environment_); | 266 DCHECK(!desktop_environment_); |
| 286 DCHECK(!input_injector_); | 267 DCHECK(!input_injector_); |
| 287 DCHECK(!screen_controls_); | 268 DCHECK(!screen_controls_); |
| 288 DCHECK(!video_frame_pump_); | 269 DCHECK(!video_stream_); |
| 289 | 270 |
| 290 is_authenticated_ = true; | 271 is_authenticated_ = true; |
| 291 | 272 |
| 292 if (max_duration_ > base::TimeDelta()) { | 273 if (max_duration_ > base::TimeDelta()) { |
| 293 max_duration_timer_.Start( | 274 max_duration_timer_.Start( |
| 294 FROM_HERE, max_duration_, | 275 FROM_HERE, max_duration_, |
| 295 base::Bind(&ClientSession::DisconnectSession, base::Unretained(this), | 276 base::Bind(&ClientSession::DisconnectSession, base::Unretained(this), |
| 296 protocol::MAX_SESSION_LENGTH)); | 277 protocol::MAX_SESSION_LENGTH)); |
| 297 } | 278 } |
| 298 | 279 |
| 299 // Notify EventHandler. | 280 // Notify EventHandler. |
| 300 event_handler_->OnSessionAuthenticated(this); | 281 event_handler_->OnSessionAuthenticated(this); |
| 301 | 282 |
| 302 // Create the desktop environment. Drop the connection if it could not be | 283 // Create the desktop environment. Drop the connection if it could not be |
| 303 // created for any reason (for instance the curtain could not initialize). | 284 // created for any reason (for instance the curtain could not initialize). |
| 304 desktop_environment_ = | 285 desktop_environment_ = |
| 305 desktop_environment_factory_->Create(weak_factory_.GetWeakPtr()); | 286 desktop_environment_factory_->Create(weak_factory_.GetWeakPtr()); |
| 306 if (!desktop_environment_) { | 287 if (!desktop_environment_) { |
| 307 DisconnectSession(protocol::HOST_CONFIGURATION_ERROR); | 288 DisconnectSession(protocol::HOST_CONFIGURATION_ERROR); |
| 308 return; | 289 return; |
| 309 } | 290 } |
| 310 | 291 |
| 311 // Connect host stub. | 292 // Connect host stub. |
| 312 connection_->set_host_stub(this); | 293 connection_->set_host_stub(this); |
| 313 | 294 |
| 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. | 295 // Collate the set of capabilities to offer the client, if it supports them. |
| 318 host_capabilities_ = desktop_environment_->GetCapabilities(); | 296 host_capabilities_ = desktop_environment_->GetCapabilities(); |
| 319 if (!host_capabilities_.empty()) | 297 if (!host_capabilities_.empty()) |
| 320 host_capabilities_.append(" "); | 298 host_capabilities_.append(" "); |
| 321 host_capabilities_.append(extension_manager_->GetCapabilities()); | 299 host_capabilities_.append(extension_manager_->GetCapabilities()); |
| 322 | 300 |
| 323 // Create the object that controls the screen resolution. | 301 // Create the object that controls the screen resolution. |
| 324 screen_controls_ = desktop_environment_->CreateScreenControls(); | 302 screen_controls_ = desktop_environment_->CreateScreenControls(); |
| 325 | 303 |
| 326 // Create the event executor. | 304 // 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. | 363 // If the client never authenticated then the session failed. |
| 386 if (!is_authenticated_) | 364 if (!is_authenticated_) |
| 387 event_handler_->OnSessionAuthenticationFailed(this); | 365 event_handler_->OnSessionAuthenticationFailed(this); |
| 388 | 366 |
| 389 // Ensure that any pressed keys or buttons are released. | 367 // Ensure that any pressed keys or buttons are released. |
| 390 input_tracker_.ReleaseAll(); | 368 input_tracker_.ReleaseAll(); |
| 391 | 369 |
| 392 // Stop components access the client, audio or video stubs, which are no | 370 // Stop components access the client, audio or video stubs, which are no |
| 393 // longer valid once ConnectionToClient calls OnConnectionClosed(). | 371 // longer valid once ConnectionToClient calls OnConnectionClosed(). |
| 394 audio_pump_.reset(); | 372 audio_pump_.reset(); |
| 395 video_frame_pump_.reset(); | 373 video_stream_.reset(); |
| 396 mouse_shape_pump_.reset(); | 374 mouse_shape_pump_.reset(); |
| 397 client_clipboard_factory_.InvalidateWeakPtrs(); | 375 client_clipboard_factory_.InvalidateWeakPtrs(); |
| 398 input_injector_.reset(); | 376 input_injector_.reset(); |
| 399 screen_controls_.reset(); | 377 screen_controls_.reset(); |
| 400 desktop_environment_.reset(); | 378 desktop_environment_.reset(); |
| 401 | 379 |
| 402 // Notify the ChromotingHost that this client is disconnected. | 380 // Notify the ChromotingHost that this client is disconnected. |
| 403 event_handler_->OnSessionClosed(this); | 381 event_handler_->OnSessionClosed(this); |
| 404 } | 382 } |
| 405 | 383 |
| 384 void ClientSession::OnCreateVideoEncoder(scoped_ptr<VideoEncoder>* encoder) { |
| 385 DCHECK(CalledOnValidThread()); |
| 386 extension_manager_->OnCreateVideoEncoder(encoder); |
| 387 } |
| 388 |
| 406 void ClientSession::OnInputEventReceived( | 389 void ClientSession::OnInputEventReceived( |
| 407 protocol::ConnectionToClient* connection, | 390 protocol::ConnectionToClient* connection, |
| 408 int64_t event_timestamp) { | 391 int64_t event_timestamp) { |
| 409 DCHECK(CalledOnValidThread()); | 392 DCHECK(CalledOnValidThread()); |
| 410 DCHECK_EQ(connection_.get(), connection); | 393 DCHECK_EQ(connection_.get(), connection); |
| 411 | 394 |
| 412 if (video_frame_pump_.get()) | 395 if (video_stream_.get()) |
| 413 video_frame_pump_->OnInputEventReceived(event_timestamp); | 396 video_stream_->OnInputEventReceived(event_timestamp); |
| 414 } | 397 } |
| 415 | 398 |
| 416 void ClientSession::OnRouteChange( | 399 void ClientSession::OnRouteChange( |
| 417 protocol::ConnectionToClient* connection, | 400 protocol::ConnectionToClient* connection, |
| 418 const std::string& channel_name, | 401 const std::string& channel_name, |
| 419 const protocol::TransportRoute& route) { | 402 const protocol::TransportRoute& route) { |
| 420 DCHECK(CalledOnValidThread()); | 403 DCHECK(CalledOnValidThread()); |
| 421 DCHECK_EQ(connection_.get(), connection); | 404 DCHECK_EQ(connection_.get(), connection); |
| 422 event_handler_->OnSessionRouteChange(this, channel_name, route); | 405 event_handler_->OnSessionRouteChange(this, channel_name, route); |
| 423 } | 406 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 448 if (disable_inputs) | 431 if (disable_inputs) |
| 449 input_tracker_.ReleaseAll(); | 432 input_tracker_.ReleaseAll(); |
| 450 | 433 |
| 451 disable_input_filter_.set_enabled(!disable_inputs); | 434 disable_input_filter_.set_enabled(!disable_inputs); |
| 452 disable_clipboard_filter_.set_enabled(!disable_inputs); | 435 disable_clipboard_filter_.set_enabled(!disable_inputs); |
| 453 } | 436 } |
| 454 | 437 |
| 455 void ClientSession::ResetVideoPipeline() { | 438 void ClientSession::ResetVideoPipeline() { |
| 456 DCHECK(CalledOnValidThread()); | 439 DCHECK(CalledOnValidThread()); |
| 457 | 440 |
| 441 video_stream_.reset(); |
| 458 mouse_shape_pump_.reset(); | 442 mouse_shape_pump_.reset(); |
| 459 connection_->set_video_feedback_stub(nullptr); | |
| 460 video_frame_pump_.reset(); | |
| 461 | 443 |
| 462 // Create VideoEncoder and DesktopCapturer to match the session's video | 444 // Create VideoEncoder and DesktopCapturer to match the session's video |
| 463 // channel configuration. | 445 // channel configuration. |
| 464 scoped_ptr<webrtc::DesktopCapturer> video_capturer = | 446 scoped_ptr<webrtc::DesktopCapturer> video_capturer = |
| 465 desktop_environment_->CreateVideoCapturer(); | 447 desktop_environment_->CreateVideoCapturer(); |
| 466 extension_manager_->OnCreateVideoCapturer(&video_capturer); | 448 extension_manager_->OnCreateVideoCapturer(&video_capturer); |
| 467 scoped_ptr<VideoEncoder> video_encoder = | |
| 468 CreateVideoEncoder(connection_->session()->config()); | |
| 469 extension_manager_->OnCreateVideoEncoder(&video_encoder); | |
| 470 | 449 |
| 471 // Don't start the VideoFramePump if either capturer or encoder are missing. | 450 // Don't start the video stream if the extension took ownership of the |
| 472 if (!video_capturer || !video_encoder) | 451 // capturer. |
| 452 if (!video_capturer) |
| 473 return; | 453 return; |
| 474 | 454 |
| 475 // Create MouseShapePump to send mouse cursor shape. | 455 // Create MouseShapePump to send mouse cursor shape. |
| 476 mouse_shape_pump_.reset( | 456 mouse_shape_pump_.reset( |
| 477 new MouseShapePump(video_capture_task_runner_, | 457 new MouseShapePump(video_capture_task_runner_, |
| 478 desktop_environment_->CreateMouseCursorMonitor(), | 458 desktop_environment_->CreateMouseCursorMonitor(), |
| 479 connection_->client_stub())); | 459 connection_->client_stub())); |
| 480 | 460 |
| 481 // Create a VideoFramePump to pump frames from the capturer to the client.' | 461 // Create a VideoStream to pump frames from the capturer to the client. |
| 482 // | 462 |
| 483 // TODO(sergeyu): Move DesktopCapturerProxy creation to DesktopEnvironment. | 463 // TODO(sergeyu): Move DesktopCapturerProxy creation to DesktopEnvironment. |
| 484 // When using IpcDesktopCapturer the capture thread is not useful. | 464 // When using IpcDesktopCapturer the capture thread is not useful. |
| 485 scoped_ptr<DesktopCapturerProxy> capturer_proxy(new DesktopCapturerProxy( | 465 scoped_ptr<webrtc::DesktopCapturer> capturer_proxy(new DesktopCapturerProxy( |
| 486 video_capture_task_runner_, video_capturer.Pass())); | 466 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 | 467 |
| 491 // Apply video-control parameters to the new scheduler. | 468 video_stream_ = connection_->StartVideoStream(capturer_proxy.Pass()); |
| 492 video_frame_pump_->SetLosslessEncode(lossless_video_encode_); | 469 video_stream_->SetSizeCallback( |
| 493 video_frame_pump_->SetLosslessColor(lossless_video_color_); | 470 base::Bind(&ClientSession::OnScreenSizeChanged, base::Unretained(this))); |
| 471 |
| 472 // Apply video-control parameters to the new stream. |
| 473 video_stream_->SetLosslessEncode(lossless_video_encode_); |
| 474 video_stream_->SetLosslessColor(lossless_video_color_); |
| 494 | 475 |
| 495 // Pause capturing if necessary. | 476 // Pause capturing if necessary. |
| 496 video_frame_pump_->Pause(pause_video_); | 477 video_stream_->Pause(pause_video_); |
| 497 | |
| 498 connection_->set_video_feedback_stub( | |
| 499 video_frame_pump_->video_feedback_stub()); | |
| 500 } | 478 } |
| 501 | 479 |
| 502 void ClientSession::SetGnubbyAuthHandlerForTesting( | 480 void ClientSession::SetGnubbyAuthHandlerForTesting( |
| 503 GnubbyAuthHandler* gnubby_auth_handler) { | 481 GnubbyAuthHandler* gnubby_auth_handler) { |
| 504 DCHECK(CalledOnValidThread()); | 482 DCHECK(CalledOnValidThread()); |
| 505 gnubby_auth_handler_.reset(gnubby_auth_handler); | 483 gnubby_auth_handler_.reset(gnubby_auth_handler); |
| 506 } | 484 } |
| 507 | 485 |
| 508 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 486 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
| 509 DCHECK(CalledOnValidThread()); | 487 DCHECK(CalledOnValidThread()); |
| 510 | 488 |
| 511 return make_scoped_ptr( | 489 return make_scoped_ptr( |
| 512 new protocol::ClipboardThreadProxy(client_clipboard_factory_.GetWeakPtr(), | 490 new protocol::ClipboardThreadProxy(client_clipboard_factory_.GetWeakPtr(), |
| 513 base::ThreadTaskRunnerHandle::Get())); | 491 base::ThreadTaskRunnerHandle::Get())); |
| 514 } | 492 } |
| 515 | 493 |
| 494 void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size) { |
| 495 DCHECK(CalledOnValidThread()); |
| 496 mouse_clamping_filter_.set_input_size(size); |
| 497 mouse_clamping_filter_.set_output_size(size); |
| 498 } |
| 499 |
| 516 } // namespace remoting | 500 } // namespace remoting |
| OLD | NEW |