| 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_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "remoting/capturer/video_frame_capturer.h" | 10 #include "remoting/capturer/video_frame_capturer.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, | 34 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 35 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 36 scoped_ptr<protocol::ConnectionToClient> connection, | 36 scoped_ptr<protocol::ConnectionToClient> connection, |
| 37 DesktopEnvironmentFactory* desktop_environment_factory, | 37 DesktopEnvironmentFactory* desktop_environment_factory, |
| 38 const base::TimeDelta& max_duration) | 38 const base::TimeDelta& max_duration) |
| 39 : event_handler_(event_handler), | 39 : event_handler_(event_handler), |
| 40 connection_(connection.Pass()), | 40 connection_(connection.Pass()), |
| 41 connection_factory_(connection_.get()), | 41 connection_factory_(connection_.get()), |
| 42 desktop_environment_(desktop_environment_factory->Create()), | 42 desktop_environment_(desktop_environment_factory->Create()), |
| 43 client_jid_(connection_->session()->jid()), | 43 client_jid_(connection_->session()->jid()), |
| 44 input_tracker_(&host_input_filter_), | 44 host_clipboard_stub_(desktop_environment_->event_executor()), |
| 45 host_input_stub_(desktop_environment_->event_executor()), |
| 46 input_tracker_(host_input_stub_), |
| 45 remote_input_filter_(&input_tracker_), | 47 remote_input_filter_(&input_tracker_), |
| 46 mouse_clamping_filter_(&remote_input_filter_, connection_->video_stub()), | 48 mouse_clamping_filter_(desktop_environment_->video_capturer(), |
| 47 disable_input_filter_(mouse_clamping_filter_.input_filter()), | 49 &remote_input_filter_), |
| 50 disable_input_filter_(&mouse_clamping_filter_), |
| 48 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), | 51 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), |
| 49 auth_input_filter_(&disable_input_filter_), | 52 auth_input_filter_(&disable_input_filter_), |
| 50 auth_clipboard_filter_(&disable_clipboard_filter_), | 53 auth_clipboard_filter_(&disable_clipboard_filter_), |
| 51 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), | 54 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
| 52 max_duration_(max_duration), | 55 max_duration_(max_duration), |
| 53 audio_task_runner_(audio_task_runner), | 56 audio_task_runner_(audio_task_runner), |
| 54 video_capture_task_runner_(video_capture_task_runner), | 57 video_capture_task_runner_(video_capture_task_runner), |
| 55 video_encode_task_runner_(video_encode_task_runner), | 58 video_encode_task_runner_(video_encode_task_runner), |
| 56 network_task_runner_(network_task_runner), | 59 network_task_runner_(network_task_runner), |
| 57 active_recorders_(0) { | 60 active_recorders_(0) { |
| 58 connection_->SetEventHandler(this); | 61 connection_->SetEventHandler(this); |
| 59 | 62 |
| 60 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be | 63 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
| 61 // set before channels are connected. Make it possible to set stubs | 64 // set before channels are connected. Make it possible to set stubs |
| 62 // later and set them only when connection is authenticated. | 65 // later and set them only when connection is authenticated. |
| 63 connection_->set_clipboard_stub(&auth_clipboard_filter_); | 66 connection_->set_clipboard_stub(&auth_clipboard_filter_); |
| 64 connection_->set_host_stub(this); | 67 connection_->set_host_stub(this); |
| 65 connection_->set_input_stub(&auth_input_filter_); | 68 connection_->set_input_stub(&auth_input_filter_); |
| 69 clipboard_echo_filter_.set_host_stub(host_clipboard_stub_); |
| 66 | 70 |
| 67 // |auth_*_filter_|'s states reflect whether the session is authenticated. | 71 // |auth_*_filter_|'s states reflect whether the session is authenticated. |
| 68 auth_input_filter_.set_enabled(false); | 72 auth_input_filter_.set_enabled(false); |
| 69 auth_clipboard_filter_.set_enabled(false); | 73 auth_clipboard_filter_.set_enabled(false); |
| 70 } | 74 } |
| 71 | 75 |
| 72 void ClientSession::NotifyClientDimensions( | 76 void ClientSession::NotifyClientDimensions( |
| 73 const protocol::ClientDimensions& dimensions) { | 77 const protocol::ClientDimensions& dimensions) { |
| 74 if (dimensions.has_width() && dimensions.has_height()) { | 78 if (dimensions.has_width() && dimensions.has_height()) { |
| 75 VLOG(1) << "Received ClientDimensions (width=" | 79 VLOG(1) << "Received ClientDimensions (width=" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 this, &ClientSession::Disconnect); | 120 this, &ClientSession::Disconnect); |
| 117 } | 121 } |
| 118 | 122 |
| 119 event_handler_->OnSessionAuthenticated(this); | 123 event_handler_->OnSessionAuthenticated(this); |
| 120 } | 124 } |
| 121 | 125 |
| 122 void ClientSession::OnConnectionChannelsConnected( | 126 void ClientSession::OnConnectionChannelsConnected( |
| 123 protocol::ConnectionToClient* connection) { | 127 protocol::ConnectionToClient* connection) { |
| 124 DCHECK(CalledOnValidThread()); | 128 DCHECK(CalledOnValidThread()); |
| 125 DCHECK_EQ(connection_.get(), connection); | 129 DCHECK_EQ(connection_.get(), connection); |
| 126 | |
| 127 // Connect the host clipboard and input stubs. | |
| 128 host_input_filter_.set_input_stub(desktop_environment_->event_executor()); | |
| 129 clipboard_echo_filter_.set_host_stub(desktop_environment_->event_executor()); | |
| 130 | |
| 131 SetDisableInputs(false); | 130 SetDisableInputs(false); |
| 132 | 131 |
| 133 // Let the desktop environment notify us of local clipboard changes. | 132 // Let the desktop environment notify us of local clipboard changes. |
| 134 desktop_environment_->Start( | 133 desktop_environment_->Start( |
| 135 CreateClipboardProxy(), | 134 CreateClipboardProxy(), |
| 136 client_jid(), | 135 client_jid(), |
| 137 base::Bind(&protocol::ConnectionToClient::Disconnect, | 136 base::Bind(&protocol::ConnectionToClient::Disconnect, |
| 138 connection_factory_.GetWeakPtr())); | 137 connection_factory_.GetWeakPtr())); |
| 139 | 138 |
| 140 // Create a VideoEncoder based on the session's video channel configuration. | 139 // Create a VideoEncoder based on the session's video channel configuration. |
| 141 scoped_ptr<VideoEncoder> video_encoder = | 140 scoped_ptr<VideoEncoder> video_encoder = |
| 142 CreateVideoEncoder(connection_->session()->config()); | 141 CreateVideoEncoder(connection_->session()->config()); |
| 143 | 142 |
| 144 // Create a VideoScheduler to pump frames from the capturer to the client. | 143 // Create a VideoScheduler to pump frames from the capturer to the client. |
| 145 video_scheduler_ = VideoScheduler::Create( | 144 video_scheduler_ = VideoScheduler::Create( |
| 146 video_capture_task_runner_, | 145 video_capture_task_runner_, |
| 147 video_encode_task_runner_, | 146 video_encode_task_runner_, |
| 148 network_task_runner_, | 147 network_task_runner_, |
| 149 desktop_environment_->video_capturer(), | 148 desktop_environment_->video_capturer(), |
| 150 video_encoder.Pass(), | 149 video_encoder.Pass(), |
| 151 connection_->client_stub(), | 150 connection_->client_stub(), |
| 152 &mouse_clamping_filter_); | 151 connection_->video_stub()); |
| 153 ++active_recorders_; | 152 ++active_recorders_; |
| 154 | 153 |
| 155 // Create an AudioScheduler if audio is enabled, to pump audio samples. | 154 // Create an AudioScheduler if audio is enabled, to pump audio samples. |
| 156 if (connection_->session()->config().is_audio_enabled()) { | 155 if (connection_->session()->config().is_audio_enabled()) { |
| 157 scoped_ptr<AudioEncoder> audio_encoder = | 156 scoped_ptr<AudioEncoder> audio_encoder = |
| 158 CreateAudioEncoder(connection_->session()->config()); | 157 CreateAudioEncoder(connection_->session()->config()); |
| 159 audio_scheduler_ = AudioScheduler::Create( | 158 audio_scheduler_ = AudioScheduler::Create( |
| 160 audio_task_runner_, | 159 audio_task_runner_, |
| 161 network_task_runner_, | 160 network_task_runner_, |
| 162 desktop_environment_->audio_capturer(), | 161 desktop_environment_->audio_capturer(), |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 NOTIMPLEMENTED(); | 336 NOTIMPLEMENTED(); |
| 338 return scoped_ptr<AudioEncoder>(NULL); | 337 return scoped_ptr<AudioEncoder>(NULL); |
| 339 } | 338 } |
| 340 | 339 |
| 341 // static | 340 // static |
| 342 void ClientSessionTraits::Destruct(const ClientSession* client) { | 341 void ClientSessionTraits::Destruct(const ClientSession* client) { |
| 343 client->network_task_runner_->DeleteSoon(FROM_HERE, client); | 342 client->network_task_runner_->DeleteSoon(FROM_HERE, client); |
| 344 } | 343 } |
| 345 | 344 |
| 346 } // namespace remoting | 345 } // namespace remoting |
| OLD | NEW |