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/event_executor.h" |
| 22 #include "remoting/host/session_controller.h" |
22 #include "remoting/host/video_scheduler.h" | 23 #include "remoting/host/video_scheduler.h" |
23 #include "remoting/proto/control.pb.h" | 24 #include "remoting/proto/control.pb.h" |
24 #include "remoting/proto/event.pb.h" | 25 #include "remoting/proto/event.pb.h" |
25 #include "remoting/protocol/client_stub.h" | 26 #include "remoting/protocol/client_stub.h" |
26 #include "remoting/protocol/clipboard_thread_proxy.h" | 27 #include "remoting/protocol/clipboard_thread_proxy.h" |
27 | 28 |
28 namespace remoting { | 29 namespace remoting { |
29 | 30 |
30 namespace { | 31 namespace { |
31 // Default DPI to assume for old clients that use notifyClientDimensions. | 32 // Default DPI to assume for old clients that use notifyClientDimensions. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 remote_input_filter_.SetExpectLocalEcho(false); | 88 remote_input_filter_.SetExpectLocalEcho(false); |
88 #endif // defined(OS_WIN) | 89 #endif // defined(OS_WIN) |
89 } | 90 } |
90 | 91 |
91 void ClientSession::NotifyClientResolution( | 92 void ClientSession::NotifyClientResolution( |
92 const protocol::ClientResolution& resolution) { | 93 const protocol::ClientResolution& resolution) { |
93 if (resolution.has_dips_width() && resolution.has_dips_height()) { | 94 if (resolution.has_dips_width() && resolution.has_dips_height()) { |
94 VLOG(1) << "Received ClientResolution (dips_width=" | 95 VLOG(1) << "Received ClientResolution (dips_width=" |
95 << resolution.dips_width() << ", dips_height=" | 96 << resolution.dips_width() << ", dips_height=" |
96 << resolution.dips_height() << ")"; | 97 << resolution.dips_height() << ")"; |
97 event_handler_->OnClientResolutionChanged( | 98 session_controller_->OnClientResolutionChanged( |
98 this, | 99 SkIPoint::Make(kDefaultDPI, kDefaultDPI), |
99 SkISize::Make(resolution.dips_width(), resolution.dips_height()), | 100 SkISize::Make(resolution.dips_width(), resolution.dips_height())); |
100 SkIPoint::Make(kDefaultDPI, kDefaultDPI)); | |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 104 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
105 if (video_control.has_enable()) { | 105 if (video_control.has_enable()) { |
106 VLOG(1) << "Received VideoControl (enable=" | 106 VLOG(1) << "Received VideoControl (enable=" |
107 << video_control.enable() << ")"; | 107 << video_control.enable() << ")"; |
108 if (video_scheduler_) | 108 if (video_scheduler_) |
109 video_scheduler_->Pause(!video_control.enable()); | 109 video_scheduler_->Pause(!video_control.enable()); |
110 } | 110 } |
(...skipping 28 matching lines...) Expand all Loading... |
139 | 139 |
140 event_handler_->OnSessionAuthenticated(this); | 140 event_handler_->OnSessionAuthenticated(this); |
141 } | 141 } |
142 | 142 |
143 void ClientSession::OnConnectionChannelsConnected( | 143 void ClientSession::OnConnectionChannelsConnected( |
144 protocol::ConnectionToClient* connection) { | 144 protocol::ConnectionToClient* connection) { |
145 DCHECK(CalledOnValidThread()); | 145 DCHECK(CalledOnValidThread()); |
146 DCHECK_EQ(connection_.get(), connection); | 146 DCHECK_EQ(connection_.get(), connection); |
147 DCHECK(!audio_scheduler_); | 147 DCHECK(!audio_scheduler_); |
148 DCHECK(!event_executor_); | 148 DCHECK(!event_executor_); |
| 149 DCHECK(!session_controller_); |
149 DCHECK(!video_scheduler_); | 150 DCHECK(!video_scheduler_); |
150 | 151 |
| 152 // Create the session controller. |
| 153 session_controller_ = desktop_environment_->CreateSessionController(); |
| 154 |
151 // Create and start the event executor. | 155 // Create and start the event executor. |
152 event_executor_ = desktop_environment_->CreateEventExecutor( | 156 event_executor_ = desktop_environment_->CreateEventExecutor( |
153 input_task_runner_, ui_task_runner_); | 157 input_task_runner_, ui_task_runner_); |
154 event_executor_->Start(CreateClipboardProxy()); | 158 event_executor_->Start(CreateClipboardProxy()); |
155 | 159 |
156 // Connect the host clipboard and input stubs. | 160 // Connect the host clipboard and input stubs. |
157 host_input_filter_.set_input_stub(event_executor_.get()); | 161 host_input_filter_.set_input_stub(event_executor_.get()); |
158 clipboard_echo_filter_.set_host_stub(event_executor_.get()); | 162 clipboard_echo_filter_.set_host_stub(event_executor_.get()); |
159 | 163 |
160 SetDisableInputs(false); | 164 SetDisableInputs(false); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 audio_scheduler_->Stop(); | 222 audio_scheduler_->Stop(); |
219 audio_scheduler_ = NULL; | 223 audio_scheduler_ = NULL; |
220 } | 224 } |
221 if (video_scheduler_) { | 225 if (video_scheduler_) { |
222 video_scheduler_->Stop(); | 226 video_scheduler_->Stop(); |
223 video_scheduler_ = NULL; | 227 video_scheduler_ = NULL; |
224 } | 228 } |
225 | 229 |
226 client_clipboard_factory_.InvalidateWeakPtrs(); | 230 client_clipboard_factory_.InvalidateWeakPtrs(); |
227 event_executor_.reset(); | 231 event_executor_.reset(); |
| 232 session_controller_.reset(); |
228 | 233 |
229 // Notify the ChromotingHost that this client is disconnected. | 234 // Notify the ChromotingHost that this client is disconnected. |
230 // TODO(sergeyu): Log failure reason? | 235 // TODO(sergeyu): Log failure reason? |
231 event_handler_->OnSessionClosed(this); | 236 event_handler_->OnSessionClosed(this); |
232 } | 237 } |
233 | 238 |
234 void ClientSession::OnSequenceNumberUpdated( | 239 void ClientSession::OnSequenceNumberUpdated( |
235 protocol::ConnectionToClient* connection, int64 sequence_number) { | 240 protocol::ConnectionToClient* connection, int64 sequence_number) { |
236 DCHECK(CalledOnValidThread()); | 241 DCHECK(CalledOnValidThread()); |
237 DCHECK_EQ(connection_.get(), connection); | 242 DCHECK_EQ(connection_.get(), connection); |
(...skipping 21 matching lines...) Expand all Loading... |
259 | 264 |
260 // This triggers OnConnectionClosed(), and the session may be destroyed | 265 // This triggers OnConnectionClosed(), and the session may be destroyed |
261 // as the result, so this call must be the last in this method. | 266 // as the result, so this call must be the last in this method. |
262 connection_->Disconnect(); | 267 connection_->Disconnect(); |
263 } | 268 } |
264 | 269 |
265 void ClientSession::Stop() { | 270 void ClientSession::Stop() { |
266 DCHECK(CalledOnValidThread()); | 271 DCHECK(CalledOnValidThread()); |
267 DCHECK(!audio_scheduler_); | 272 DCHECK(!audio_scheduler_); |
268 DCHECK(!event_executor_); | 273 DCHECK(!event_executor_); |
| 274 DCHECK(!session_controller_); |
269 DCHECK(!video_scheduler_); | 275 DCHECK(!video_scheduler_); |
270 | 276 |
271 connection_.reset(); | 277 connection_.reset(); |
272 } | 278 } |
273 | 279 |
274 void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { | 280 void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { |
275 DCHECK(CalledOnValidThread()); | 281 DCHECK(CalledOnValidThread()); |
276 remote_input_filter_.LocalMouseMoved(mouse_pos); | 282 remote_input_filter_.LocalMouseMoved(mouse_pos); |
277 } | 283 } |
278 | 284 |
279 void ClientSession::SetDisableInputs(bool disable_inputs) { | 285 void ClientSession::SetDisableInputs(bool disable_inputs) { |
280 DCHECK(CalledOnValidThread()); | 286 DCHECK(CalledOnValidThread()); |
281 | 287 |
282 if (disable_inputs) | 288 if (disable_inputs) |
283 input_tracker_.ReleaseAll(); | 289 input_tracker_.ReleaseAll(); |
284 | 290 |
285 disable_input_filter_.set_enabled(!disable_inputs); | 291 disable_input_filter_.set_enabled(!disable_inputs); |
286 disable_clipboard_filter_.set_enabled(!disable_inputs); | 292 disable_clipboard_filter_.set_enabled(!disable_inputs); |
287 } | 293 } |
288 | 294 |
289 ClientSession::~ClientSession() { | 295 ClientSession::~ClientSession() { |
290 DCHECK(CalledOnValidThread()); | 296 DCHECK(CalledOnValidThread()); |
291 DCHECK(!audio_scheduler_); | 297 DCHECK(!audio_scheduler_); |
292 DCHECK(!event_executor_); | 298 DCHECK(!event_executor_); |
| 299 DCHECK(!session_controller_); |
293 DCHECK(!video_scheduler_); | 300 DCHECK(!video_scheduler_); |
294 } | 301 } |
295 | 302 |
296 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 303 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
297 DCHECK(CalledOnValidThread()); | 304 DCHECK(CalledOnValidThread()); |
298 | 305 |
299 return scoped_ptr<protocol::ClipboardStub>( | 306 return scoped_ptr<protocol::ClipboardStub>( |
300 new protocol::ClipboardThreadProxy( | 307 new protocol::ClipboardThreadProxy( |
301 client_clipboard_factory_.GetWeakPtr(), | 308 client_clipboard_factory_.GetWeakPtr(), |
302 base::MessageLoopProxy::current())); | 309 base::MessageLoopProxy::current())); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 NOTIMPLEMENTED(); | 341 NOTIMPLEMENTED(); |
335 return scoped_ptr<AudioEncoder>(NULL); | 342 return scoped_ptr<AudioEncoder>(NULL); |
336 } | 343 } |
337 | 344 |
338 // static | 345 // static |
339 void ClientSessionTraits::Destruct(const ClientSession* client) { | 346 void ClientSessionTraits::Destruct(const ClientSession* client) { |
340 client->network_task_runner_->DeleteSoon(FROM_HERE, client); | 347 client->network_task_runner_->DeleteSoon(FROM_HERE, client); |
341 } | 348 } |
342 | 349 |
343 } // namespace remoting | 350 } // namespace remoting |
OLD | NEW |