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 "media/video/capture/screen/screen_capturer.h" | 10 #include "media/video/capture/screen/screen_capturer.h" |
11 #include "remoting/codec/audio_encoder.h" | 11 #include "remoting/codec/audio_encoder.h" |
12 #include "remoting/codec/audio_encoder_opus.h" | 12 #include "remoting/codec/audio_encoder_opus.h" |
13 #include "remoting/codec/audio_encoder_speex.h" | 13 #include "remoting/codec/audio_encoder_speex.h" |
14 #include "remoting/codec/audio_encoder_verbatim.h" | 14 #include "remoting/codec/audio_encoder_verbatim.h" |
15 #include "remoting/codec/video_encoder.h" | 15 #include "remoting/codec/video_encoder.h" |
16 #include "remoting/codec/video_encoder_verbatim.h" | 16 #include "remoting/codec/video_encoder_verbatim.h" |
17 #include "remoting/codec/video_encoder_vp8.h" | 17 #include "remoting/codec/video_encoder_vp8.h" |
18 #include "remoting/host/audio_capturer.h" | 18 #include "remoting/host/audio_capturer.h" |
19 #include "remoting/host/audio_scheduler.h" | 19 #include "remoting/host/audio_scheduler.h" |
20 #include "remoting/host/desktop_environment.h" | 20 #include "remoting/host/desktop_environment.h" |
21 #include "remoting/host/event_executor.h" | 21 #include "remoting/host/input_injector.h" |
22 #include "remoting/host/screen_resolution.h" | 22 #include "remoting/host/screen_resolution.h" |
23 #include "remoting/host/session_controller.h" | 23 #include "remoting/host/session_controller.h" |
24 #include "remoting/host/video_scheduler.h" | 24 #include "remoting/host/video_scheduler.h" |
25 #include "remoting/proto/control.pb.h" | 25 #include "remoting/proto/control.pb.h" |
26 #include "remoting/proto/event.pb.h" | 26 #include "remoting/proto/event.pb.h" |
27 #include "remoting/protocol/client_stub.h" | 27 #include "remoting/protocol/client_stub.h" |
28 #include "remoting/protocol/clipboard_thread_proxy.h" | 28 #include "remoting/protocol/clipboard_thread_proxy.h" |
29 | 29 |
30 // Default DPI to assume for old clients that use notifyClientDimensions. | 30 // Default DPI to assume for old clients that use notifyClientDimensions. |
31 const int kDefaultDPI = 96; | 31 const int kDefaultDPI = 96; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
80 // LocalInputMonitorWin filters out an echo of the injected input before it | 80 // LocalInputMonitorWin filters out an echo of the injected input before it |
81 // reaches |remote_input_filter_|. | 81 // reaches |remote_input_filter_|. |
82 remote_input_filter_.SetExpectLocalEcho(false); | 82 remote_input_filter_.SetExpectLocalEcho(false); |
83 #endif // defined(OS_WIN) | 83 #endif // defined(OS_WIN) |
84 } | 84 } |
85 | 85 |
86 ClientSession::~ClientSession() { | 86 ClientSession::~ClientSession() { |
87 DCHECK(CalledOnValidThread()); | 87 DCHECK(CalledOnValidThread()); |
88 DCHECK(!audio_scheduler_); | 88 DCHECK(!audio_scheduler_); |
89 DCHECK(!event_executor_); | 89 DCHECK(!input_injector_); |
90 DCHECK(!session_controller_); | 90 DCHECK(!session_controller_); |
91 DCHECK(!video_scheduler_); | 91 DCHECK(!video_scheduler_); |
92 | 92 |
93 connection_.reset(); | 93 connection_.reset(); |
94 } | 94 } |
95 | 95 |
96 void ClientSession::NotifyClientResolution( | 96 void ClientSession::NotifyClientResolution( |
97 const protocol::ClientResolution& resolution) { | 97 const protocol::ClientResolution& resolution) { |
98 if (!resolution.has_dips_width() || !resolution.has_dips_height()) | 98 if (!resolution.has_dips_width() || !resolution.has_dips_height()) |
99 return; | 99 return; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 event_handler_->OnSessionAuthenticated(this); | 153 event_handler_->OnSessionAuthenticated(this); |
154 } | 154 } |
155 | 155 |
156 void ClientSession::OnConnectionChannelsConnected( | 156 void ClientSession::OnConnectionChannelsConnected( |
157 protocol::ConnectionToClient* connection) { | 157 protocol::ConnectionToClient* connection) { |
158 DCHECK(CalledOnValidThread()); | 158 DCHECK(CalledOnValidThread()); |
159 DCHECK_EQ(connection_.get(), connection); | 159 DCHECK_EQ(connection_.get(), connection); |
160 DCHECK(!audio_scheduler_); | 160 DCHECK(!audio_scheduler_); |
161 DCHECK(!event_executor_); | 161 DCHECK(!input_injector_); |
162 DCHECK(!session_controller_); | 162 DCHECK(!session_controller_); |
163 DCHECK(!video_scheduler_); | 163 DCHECK(!video_scheduler_); |
164 | 164 |
165 scoped_ptr<DesktopEnvironment> desktop_environment = | 165 scoped_ptr<DesktopEnvironment> desktop_environment = |
166 desktop_environment_factory_->Create( | 166 desktop_environment_factory_->Create( |
167 client_jid_, | 167 client_jid_, |
168 base::Bind(&protocol::ConnectionToClient::Disconnect, | 168 base::Bind(&protocol::ConnectionToClient::Disconnect, |
169 connection_factory_.GetWeakPtr())); | 169 connection_factory_.GetWeakPtr())); |
170 | 170 |
171 // Create the session controller. | 171 // Create the session controller. |
172 session_controller_ = desktop_environment->CreateSessionController(); | 172 session_controller_ = desktop_environment->CreateSessionController(); |
173 | 173 |
174 // Create and start the event executor. | 174 // Create and start the event executor. |
175 event_executor_ = desktop_environment->CreateEventExecutor( | 175 input_injector_ = desktop_environment->CreateInputInjector( |
176 input_task_runner_, ui_task_runner_); | 176 input_task_runner_, ui_task_runner_); |
177 event_executor_->Start(CreateClipboardProxy()); | 177 input_injector_->Start(CreateClipboardProxy()); |
178 | 178 |
179 // Connect the host clipboard and input stubs. | 179 // Connect the host clipboard and input stubs. |
180 host_input_filter_.set_input_stub(event_executor_.get()); | 180 host_input_filter_.set_input_stub(input_injector_.get()); |
181 clipboard_echo_filter_.set_host_stub(event_executor_.get()); | 181 clipboard_echo_filter_.set_host_stub(input_injector_.get()); |
182 | 182 |
183 SetDisableInputs(false); | 183 SetDisableInputs(false); |
184 | 184 |
185 // Create a VideoEncoder based on the session's video channel configuration. | 185 // Create a VideoEncoder based on the session's video channel configuration. |
186 scoped_ptr<VideoEncoder> video_encoder = | 186 scoped_ptr<VideoEncoder> video_encoder = |
187 CreateVideoEncoder(connection_->session()->config()); | 187 CreateVideoEncoder(connection_->session()->config()); |
188 | 188 |
189 // Create a VideoScheduler to pump frames from the capturer to the client. | 189 // Create a VideoScheduler to pump frames from the capturer to the client. |
190 video_scheduler_ = VideoScheduler::Create( | 190 video_scheduler_ = VideoScheduler::Create( |
191 video_capture_task_runner_, | 191 video_capture_task_runner_, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 if (audio_scheduler_) { | 240 if (audio_scheduler_) { |
241 audio_scheduler_->Stop(); | 241 audio_scheduler_->Stop(); |
242 audio_scheduler_ = NULL; | 242 audio_scheduler_ = NULL; |
243 } | 243 } |
244 if (video_scheduler_) { | 244 if (video_scheduler_) { |
245 video_scheduler_->Stop(); | 245 video_scheduler_->Stop(); |
246 video_scheduler_ = NULL; | 246 video_scheduler_ = NULL; |
247 } | 247 } |
248 | 248 |
249 client_clipboard_factory_.InvalidateWeakPtrs(); | 249 client_clipboard_factory_.InvalidateWeakPtrs(); |
250 event_executor_.reset(); | 250 input_injector_.reset(); |
251 session_controller_.reset(); | 251 session_controller_.reset(); |
252 | 252 |
253 // Notify the ChromotingHost that this client is disconnected. | 253 // Notify the ChromotingHost that this client is disconnected. |
254 // TODO(sergeyu): Log failure reason? | 254 // TODO(sergeyu): Log failure reason? |
255 event_handler_->OnSessionClosed(this); | 255 event_handler_->OnSessionClosed(this); |
256 } | 256 } |
257 | 257 |
258 void ClientSession::OnSequenceNumberUpdated( | 258 void ClientSession::OnSequenceNumberUpdated( |
259 protocol::ConnectionToClient* connection, int64 sequence_number) { | 259 protocol::ConnectionToClient* connection, int64 sequence_number) { |
260 DCHECK(CalledOnValidThread()); | 260 DCHECK(CalledOnValidThread()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 return scoped_ptr<AudioEncoder>(new AudioEncoderSpeex()); | 337 return scoped_ptr<AudioEncoder>(new AudioEncoderSpeex()); |
338 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { | 338 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { |
339 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); | 339 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); |
340 } | 340 } |
341 | 341 |
342 NOTIMPLEMENTED(); | 342 NOTIMPLEMENTED(); |
343 return scoped_ptr<AudioEncoder>(NULL); | 343 return scoped_ptr<AudioEncoder>(NULL); |
344 } | 344 } |
345 | 345 |
346 } // namespace remoting | 346 } // namespace remoting |
OLD | NEW |