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" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
81 // LocalInputMonitorWin filters out an echo of the injected input before it | 81 // LocalInputMonitorWin filters out an echo of the injected input before it |
82 // reaches |remote_input_filter_|. | 82 // reaches |remote_input_filter_|. |
83 remote_input_filter_.SetExpectLocalEcho(false); | 83 remote_input_filter_.SetExpectLocalEcho(false); |
84 #endif // defined(OS_WIN) | 84 #endif // defined(OS_WIN) |
85 } | 85 } |
86 | 86 |
87 ClientSession::~ClientSession() { | 87 ClientSession::~ClientSession() { |
88 DCHECK(CalledOnValidThread()); | 88 DCHECK(CalledOnValidThread()); |
89 DCHECK(!audio_scheduler_); | 89 DCHECK(!audio_scheduler_.get()); |
90 DCHECK(!desktop_environment_); | 90 DCHECK(!desktop_environment_); |
91 DCHECK(!input_injector_); | 91 DCHECK(!input_injector_); |
92 DCHECK(!screen_controls_); | 92 DCHECK(!screen_controls_); |
93 DCHECK(!video_scheduler_); | 93 DCHECK(!video_scheduler_.get()); |
94 | 94 |
95 connection_.reset(); | 95 connection_.reset(); |
96 } | 96 } |
97 | 97 |
98 void ClientSession::NotifyClientResolution( | 98 void ClientSession::NotifyClientResolution( |
99 const protocol::ClientResolution& resolution) { | 99 const protocol::ClientResolution& resolution) { |
100 DCHECK(CalledOnValidThread()); | 100 DCHECK(CalledOnValidThread()); |
101 | 101 |
102 // TODO(sergeyu): Move these checks to protocol layer. | 102 // TODO(sergeyu): Move these checks to protocol layer. |
103 if (!resolution.has_dips_width() || !resolution.has_dips_height() || | 103 if (!resolution.has_dips_width() || !resolution.has_dips_height() || |
(...skipping 27 matching lines...) Expand all Loading... |
131 video_scheduler_->Pause(!video_control.enable()); | 131 video_scheduler_->Pause(!video_control.enable()); |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { | 135 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { |
136 DCHECK(CalledOnValidThread()); | 136 DCHECK(CalledOnValidThread()); |
137 | 137 |
138 if (audio_control.has_enable()) { | 138 if (audio_control.has_enable()) { |
139 VLOG(1) << "Received AudioControl (enable=" | 139 VLOG(1) << "Received AudioControl (enable=" |
140 << audio_control.enable() << ")"; | 140 << audio_control.enable() << ")"; |
141 if (audio_scheduler_) | 141 if (audio_scheduler_.get()) |
142 audio_scheduler_->Pause(!audio_control.enable()); | 142 audio_scheduler_->Pause(!audio_control.enable()); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 void ClientSession::SetCapabilities( | 146 void ClientSession::SetCapabilities( |
147 const protocol::Capabilities& capabilities) { | 147 const protocol::Capabilities& capabilities) { |
148 DCHECK(CalledOnValidThread()); | 148 DCHECK(CalledOnValidThread()); |
149 | 149 |
150 // The client should not send protocol::Capabilities if it is not supported by | 150 // The client should not send protocol::Capabilities if it is not supported by |
151 // the config channel. | 151 // the config channel. |
(...skipping 17 matching lines...) Expand all Loading... |
169 // Calculate the set of capabilities enabled by both client and host and | 169 // Calculate the set of capabilities enabled by both client and host and |
170 // pass it to the desktop environment if it is available. | 170 // pass it to the desktop environment if it is available. |
171 desktop_environment_->SetCapabilities( | 171 desktop_environment_->SetCapabilities( |
172 IntersectCapabilities(*client_capabilities_, host_capabilities_)); | 172 IntersectCapabilities(*client_capabilities_, host_capabilities_)); |
173 } | 173 } |
174 | 174 |
175 void ClientSession::OnConnectionAuthenticated( | 175 void ClientSession::OnConnectionAuthenticated( |
176 protocol::ConnectionToClient* connection) { | 176 protocol::ConnectionToClient* connection) { |
177 DCHECK(CalledOnValidThread()); | 177 DCHECK(CalledOnValidThread()); |
178 DCHECK_EQ(connection_.get(), connection); | 178 DCHECK_EQ(connection_.get(), connection); |
179 DCHECK(!audio_scheduler_); | 179 DCHECK(!audio_scheduler_.get()); |
180 DCHECK(!desktop_environment_); | 180 DCHECK(!desktop_environment_); |
181 DCHECK(!input_injector_); | 181 DCHECK(!input_injector_); |
182 DCHECK(!screen_controls_); | 182 DCHECK(!screen_controls_); |
183 DCHECK(!video_scheduler_); | 183 DCHECK(!video_scheduler_.get()); |
184 | 184 |
185 auth_input_filter_.set_enabled(true); | 185 auth_input_filter_.set_enabled(true); |
186 auth_clipboard_filter_.set_enabled(true); | 186 auth_clipboard_filter_.set_enabled(true); |
187 | 187 |
188 clipboard_echo_filter_.set_client_stub(connection_->client_stub()); | 188 clipboard_echo_filter_.set_client_stub(connection_->client_stub()); |
189 mouse_clamping_filter_.set_video_stub(connection_->video_stub()); | 189 mouse_clamping_filter_.set_video_stub(connection_->video_stub()); |
190 | 190 |
191 if (max_duration_ > base::TimeDelta()) { | 191 if (max_duration_ > base::TimeDelta()) { |
192 // TODO(simonmorris): Let Disconnect() tell the client that the | 192 // TODO(simonmorris): Let Disconnect() tell the client that the |
193 // disconnection was caused by the session exceeding its maximum duration. | 193 // disconnection was caused by the session exceeding its maximum duration. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // TODO(wez): Fix ChromotingHost::OnSessionClosed not to check our | 304 // TODO(wez): Fix ChromotingHost::OnSessionClosed not to check our |
305 // is_authenticated(), so that we can disable |auth_*_filter_| here. | 305 // is_authenticated(), so that we can disable |auth_*_filter_| here. |
306 disable_input_filter_.set_enabled(false); | 306 disable_input_filter_.set_enabled(false); |
307 disable_clipboard_filter_.set_enabled(false); | 307 disable_clipboard_filter_.set_enabled(false); |
308 | 308 |
309 // Ensure that any pressed keys or buttons are released. | 309 // Ensure that any pressed keys or buttons are released. |
310 input_tracker_.ReleaseAll(); | 310 input_tracker_.ReleaseAll(); |
311 | 311 |
312 // Stop components access the client, audio or video stubs, which are no | 312 // Stop components access the client, audio or video stubs, which are no |
313 // longer valid once ConnectionToClient calls OnConnectionClosed(). | 313 // longer valid once ConnectionToClient calls OnConnectionClosed(). |
314 if (audio_scheduler_) { | 314 if (audio_scheduler_.get()) { |
315 audio_scheduler_->Stop(); | 315 audio_scheduler_->Stop(); |
316 audio_scheduler_ = NULL; | 316 audio_scheduler_ = NULL; |
317 } | 317 } |
318 if (video_scheduler_) { | 318 if (video_scheduler_.get()) { |
319 video_scheduler_->Stop(); | 319 video_scheduler_->Stop(); |
320 video_scheduler_ = NULL; | 320 video_scheduler_ = NULL; |
321 } | 321 } |
322 | 322 |
323 client_clipboard_factory_.InvalidateWeakPtrs(); | 323 client_clipboard_factory_.InvalidateWeakPtrs(); |
324 input_injector_.reset(); | 324 input_injector_.reset(); |
325 screen_controls_.reset(); | 325 screen_controls_.reset(); |
326 desktop_environment_.reset(); | 326 desktop_environment_.reset(); |
327 | 327 |
328 // Notify the ChromotingHost that this client is disconnected. | 328 // Notify the ChromotingHost that this client is disconnected. |
329 // TODO(sergeyu): Log failure reason? | 329 // TODO(sergeyu): Log failure reason? |
330 event_handler_->OnSessionClosed(this); | 330 event_handler_->OnSessionClosed(this); |
331 } | 331 } |
332 | 332 |
333 void ClientSession::OnSequenceNumberUpdated( | 333 void ClientSession::OnSequenceNumberUpdated( |
334 protocol::ConnectionToClient* connection, int64 sequence_number) { | 334 protocol::ConnectionToClient* connection, int64 sequence_number) { |
335 DCHECK(CalledOnValidThread()); | 335 DCHECK(CalledOnValidThread()); |
336 DCHECK_EQ(connection_.get(), connection); | 336 DCHECK_EQ(connection_.get(), connection); |
337 | 337 |
338 if (video_scheduler_) | 338 if (video_scheduler_.get()) |
339 video_scheduler_->UpdateSequenceNumber(sequence_number); | 339 video_scheduler_->UpdateSequenceNumber(sequence_number); |
340 | 340 |
341 event_handler_->OnSessionSequenceNumber(this, sequence_number); | 341 event_handler_->OnSessionSequenceNumber(this, sequence_number); |
342 } | 342 } |
343 | 343 |
344 void ClientSession::OnRouteChange( | 344 void ClientSession::OnRouteChange( |
345 protocol::ConnectionToClient* connection, | 345 protocol::ConnectionToClient* connection, |
346 const std::string& channel_name, | 346 const std::string& channel_name, |
347 const protocol::TransportRoute& route) { | 347 const protocol::TransportRoute& route) { |
348 DCHECK(CalledOnValidThread()); | 348 DCHECK(CalledOnValidThread()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 return scoped_ptr<AudioEncoder>(new AudioEncoderSpeex()); | 416 return scoped_ptr<AudioEncoder>(new AudioEncoderSpeex()); |
417 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { | 417 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { |
418 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); | 418 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); |
419 } | 419 } |
420 | 420 |
421 NOTIMPLEMENTED(); | 421 NOTIMPLEMENTED(); |
422 return scoped_ptr<AudioEncoder>(NULL); | 422 return scoped_ptr<AudioEncoder>(NULL); |
423 } | 423 } |
424 | 424 |
425 } // namespace remoting | 425 } // namespace remoting |
OLD | NEW |