| 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" |
| 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_scheduler.h" | 19 #include "remoting/host/audio_scheduler.h" |
| 19 #include "remoting/host/desktop_environment.h" | 20 #include "remoting/host/desktop_environment.h" |
| 20 #include "remoting/host/desktop_environment_factory.h" | |
| 21 #include "remoting/host/event_executor.h" | 21 #include "remoting/host/event_executor.h" |
| 22 #include "remoting/host/video_scheduler.h" | 22 #include "remoting/host/video_scheduler.h" |
| 23 #include "remoting/proto/control.pb.h" | 23 #include "remoting/proto/control.pb.h" |
| 24 #include "remoting/proto/event.pb.h" | 24 #include "remoting/proto/event.pb.h" |
| 25 #include "remoting/protocol/client_stub.h" | 25 #include "remoting/protocol/client_stub.h" |
| 26 #include "remoting/protocol/clipboard_thread_proxy.h" | 26 #include "remoting/protocol/clipboard_thread_proxy.h" |
| 27 | 27 |
| 28 namespace remoting { | 28 namespace remoting { |
| 29 | 29 |
| 30 ClientSession::ClientSession( | 30 ClientSession::ClientSession( |
| 31 EventHandler* event_handler, | 31 EventHandler* event_handler, |
| 32 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 32 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 33 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 33 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, | 34 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, | 35 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 36 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 37 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 36 scoped_ptr<protocol::ConnectionToClient> connection, | 38 scoped_ptr<protocol::ConnectionToClient> connection, |
| 37 DesktopEnvironmentFactory* desktop_environment_factory, | 39 DesktopEnvironmentFactory* desktop_environment_factory, |
| 38 const base::TimeDelta& max_duration) | 40 const base::TimeDelta& max_duration) |
| 39 : event_handler_(event_handler), | 41 : event_handler_(event_handler), |
| 40 connection_(connection.Pass()), | 42 connection_(connection.Pass()), |
| 41 connection_factory_(connection_.get()), | 43 connection_factory_(connection_.get()), |
| 42 desktop_environment_(desktop_environment_factory->Create()), | |
| 43 client_jid_(connection_->session()->jid()), | 44 client_jid_(connection_->session()->jid()), |
| 45 desktop_environment_(desktop_environment_factory->Create( |
| 46 client_jid_, |
| 47 base::Bind(&protocol::ConnectionToClient::Disconnect, |
| 48 connection_factory_.GetWeakPtr()))), |
| 44 input_tracker_(&host_input_filter_), | 49 input_tracker_(&host_input_filter_), |
| 45 remote_input_filter_(&input_tracker_), | 50 remote_input_filter_(&input_tracker_), |
| 46 mouse_clamping_filter_(&remote_input_filter_), | 51 mouse_clamping_filter_(&remote_input_filter_), |
| 47 disable_input_filter_(mouse_clamping_filter_.input_filter()), | 52 disable_input_filter_(mouse_clamping_filter_.input_filter()), |
| 48 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), | 53 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), |
| 49 auth_input_filter_(&disable_input_filter_), | 54 auth_input_filter_(&disable_input_filter_), |
| 50 auth_clipboard_filter_(&disable_clipboard_filter_), | 55 auth_clipboard_filter_(&disable_clipboard_filter_), |
| 51 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), | 56 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
| 52 max_duration_(max_duration), | 57 max_duration_(max_duration), |
| 53 audio_task_runner_(audio_task_runner), | 58 audio_task_runner_(audio_task_runner), |
| 59 input_task_runner_(input_task_runner), |
| 54 video_capture_task_runner_(video_capture_task_runner), | 60 video_capture_task_runner_(video_capture_task_runner), |
| 55 video_encode_task_runner_(video_encode_task_runner), | 61 video_encode_task_runner_(video_encode_task_runner), |
| 56 network_task_runner_(network_task_runner), | 62 network_task_runner_(network_task_runner), |
| 57 active_recorders_(0) { | 63 ui_task_runner_(ui_task_runner) { |
| 58 connection_->SetEventHandler(this); | 64 connection_->SetEventHandler(this); |
| 59 | 65 |
| 60 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be | 66 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
| 61 // set before channels are connected. Make it possible to set stubs | 67 // set before channels are connected. Make it possible to set stubs |
| 62 // later and set them only when connection is authenticated. | 68 // later and set them only when connection is authenticated. |
| 63 connection_->set_clipboard_stub(&auth_clipboard_filter_); | 69 connection_->set_clipboard_stub(&auth_clipboard_filter_); |
| 64 connection_->set_host_stub(this); | 70 connection_->set_host_stub(this); |
| 65 connection_->set_input_stub(&auth_input_filter_); | 71 connection_->set_input_stub(&auth_input_filter_); |
| 66 | 72 |
| 67 // |auth_*_filter_|'s states reflect whether the session is authenticated. | 73 // |auth_*_filter_|'s states reflect whether the session is authenticated. |
| 68 auth_input_filter_.set_enabled(false); | 74 auth_input_filter_.set_enabled(false); |
| 69 auth_clipboard_filter_.set_enabled(false); | 75 auth_clipboard_filter_.set_enabled(false); |
| 70 } | 76 } |
| 71 | 77 |
| 72 void ClientSession::NotifyClientDimensions( | 78 void ClientSession::NotifyClientDimensions( |
| 73 const protocol::ClientDimensions& dimensions) { | 79 const protocol::ClientDimensions& dimensions) { |
| 74 if (dimensions.has_width() && dimensions.has_height()) { | 80 if (dimensions.has_width() && dimensions.has_height()) { |
| 75 VLOG(1) << "Received ClientDimensions (width=" | 81 VLOG(1) << "Received ClientDimensions (width=" |
| 76 << dimensions.width() << ", height=" << dimensions.height() << ")"; | 82 << dimensions.width() << ", height=" << dimensions.height() << ")"; |
| 77 event_handler_->OnClientDimensionsChanged( | 83 event_handler_->OnClientDimensionsChanged( |
| 78 this, SkISize::Make(dimensions.width(), dimensions.height())); | 84 this, SkISize::Make(dimensions.width(), dimensions.height())); |
| 79 } | 85 } |
| 80 } | 86 } |
| 81 | 87 |
| 82 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 88 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| 83 if (video_control.has_enable()) { | 89 if (video_control.has_enable()) { |
| 84 VLOG(1) << "Received VideoControl (enable=" | 90 VLOG(1) << "Received VideoControl (enable=" |
| 85 << video_control.enable() << ")"; | 91 << video_control.enable() << ")"; |
| 86 if (video_scheduler_.get()) { | 92 if (video_scheduler_) |
| 87 video_scheduler_->Pause(!video_control.enable()); | 93 video_scheduler_->Pause(!video_control.enable()); |
| 88 } | |
| 89 } | 94 } |
| 90 } | 95 } |
| 91 | 96 |
| 92 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { | 97 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { |
| 93 if (audio_control.has_enable()) { | 98 if (audio_control.has_enable()) { |
| 94 VLOG(1) << "Received AudioControl (enable=" | 99 VLOG(1) << "Received AudioControl (enable=" |
| 95 << audio_control.enable() << ")"; | 100 << audio_control.enable() << ")"; |
| 96 if (audio_scheduler_.get()) { | 101 if (audio_scheduler_) |
| 97 audio_scheduler_->SetEnabled(audio_control.enable()); | 102 audio_scheduler_->Pause(!audio_control.enable()); |
| 98 } | |
| 99 } | 103 } |
| 100 } | 104 } |
| 101 | 105 |
| 102 void ClientSession::OnConnectionAuthenticated( | 106 void ClientSession::OnConnectionAuthenticated( |
| 103 protocol::ConnectionToClient* connection) { | 107 protocol::ConnectionToClient* connection) { |
| 104 DCHECK(CalledOnValidThread()); | 108 DCHECK(CalledOnValidThread()); |
| 105 DCHECK_EQ(connection_.get(), connection); | 109 DCHECK_EQ(connection_.get(), connection); |
| 106 | 110 |
| 107 auth_input_filter_.set_enabled(true); | 111 auth_input_filter_.set_enabled(true); |
| 108 auth_clipboard_filter_.set_enabled(true); | 112 auth_clipboard_filter_.set_enabled(true); |
| 109 | 113 |
| 110 clipboard_echo_filter_.set_client_stub(connection_->client_stub()); | 114 clipboard_echo_filter_.set_client_stub(connection_->client_stub()); |
| 111 mouse_clamping_filter_.set_video_stub(connection_->video_stub()); | 115 mouse_clamping_filter_.set_video_stub(connection_->video_stub()); |
| 112 | 116 |
| 113 if (max_duration_ > base::TimeDelta()) { | 117 if (max_duration_ > base::TimeDelta()) { |
| 114 // TODO(simonmorris): Let Disconnect() tell the client that the | 118 // TODO(simonmorris): Let Disconnect() tell the client that the |
| 115 // disconnection was caused by the session exceeding its maximum duration. | 119 // disconnection was caused by the session exceeding its maximum duration. |
| 116 max_duration_timer_.Start(FROM_HERE, max_duration_, | 120 max_duration_timer_.Start(FROM_HERE, max_duration_, |
| 117 this, &ClientSession::Disconnect); | 121 this, &ClientSession::Disconnect); |
| 118 } | 122 } |
| 119 | 123 |
| 120 event_handler_->OnSessionAuthenticated(this); | 124 event_handler_->OnSessionAuthenticated(this); |
| 121 } | 125 } |
| 122 | 126 |
| 123 void ClientSession::OnConnectionChannelsConnected( | 127 void ClientSession::OnConnectionChannelsConnected( |
| 124 protocol::ConnectionToClient* connection) { | 128 protocol::ConnectionToClient* connection) { |
| 125 DCHECK(CalledOnValidThread()); | 129 DCHECK(CalledOnValidThread()); |
| 126 DCHECK_EQ(connection_.get(), connection); | 130 DCHECK_EQ(connection_.get(), connection); |
| 131 DCHECK(!audio_scheduler_); |
| 132 DCHECK(!event_executor_); |
| 133 DCHECK(!video_scheduler_); |
| 134 |
| 135 // Create and start the event executor. |
| 136 event_executor_ = desktop_environment_->CreateEventExecutor( |
| 137 input_task_runner_, ui_task_runner_); |
| 138 event_executor_->Start(CreateClipboardProxy()); |
| 127 | 139 |
| 128 // Connect the host clipboard and input stubs. | 140 // Connect the host clipboard and input stubs. |
| 129 host_input_filter_.set_input_stub(desktop_environment_->event_executor()); | 141 host_input_filter_.set_input_stub(event_executor_.get()); |
| 130 clipboard_echo_filter_.set_host_stub(desktop_environment_->event_executor()); | 142 clipboard_echo_filter_.set_host_stub(event_executor_.get()); |
| 131 | 143 |
| 132 SetDisableInputs(false); | 144 SetDisableInputs(false); |
| 133 | 145 |
| 134 // Let the desktop environment notify us of local clipboard changes. | |
| 135 desktop_environment_->Start( | |
| 136 CreateClipboardProxy(), | |
| 137 client_jid(), | |
| 138 base::Bind(&protocol::ConnectionToClient::Disconnect, | |
| 139 connection_factory_.GetWeakPtr())); | |
| 140 | |
| 141 // Create a VideoEncoder based on the session's video channel configuration. | 146 // Create a VideoEncoder based on the session's video channel configuration. |
| 142 scoped_ptr<VideoEncoder> video_encoder = | 147 scoped_ptr<VideoEncoder> video_encoder = |
| 143 CreateVideoEncoder(connection_->session()->config()); | 148 CreateVideoEncoder(connection_->session()->config()); |
| 144 | 149 |
| 145 // Create a VideoScheduler to pump frames from the capturer to the client. | 150 // Create a VideoScheduler to pump frames from the capturer to the client. |
| 146 video_scheduler_ = VideoScheduler::Create( | 151 video_scheduler_ = VideoScheduler::Create( |
| 147 video_capture_task_runner_, | 152 video_capture_task_runner_, |
| 148 video_encode_task_runner_, | 153 video_encode_task_runner_, |
| 149 network_task_runner_, | 154 network_task_runner_, |
| 150 desktop_environment_->video_capturer(), | 155 desktop_environment_->CreateVideoCapturer(video_capture_task_runner_, |
| 156 video_encode_task_runner_), |
| 151 video_encoder.Pass(), | 157 video_encoder.Pass(), |
| 152 connection_->client_stub(), | 158 connection_->client_stub(), |
| 153 &mouse_clamping_filter_); | 159 &mouse_clamping_filter_); |
| 154 ++active_recorders_; | |
| 155 | 160 |
| 156 // Create an AudioScheduler if audio is enabled, to pump audio samples. | 161 // Create an AudioScheduler if audio is enabled, to pump audio samples. |
| 157 if (connection_->session()->config().is_audio_enabled()) { | 162 if (connection_->session()->config().is_audio_enabled()) { |
| 158 scoped_ptr<AudioEncoder> audio_encoder = | 163 scoped_ptr<AudioEncoder> audio_encoder = |
| 159 CreateAudioEncoder(connection_->session()->config()); | 164 CreateAudioEncoder(connection_->session()->config()); |
| 160 audio_scheduler_ = AudioScheduler::Create( | 165 audio_scheduler_ = AudioScheduler::Create( |
| 161 audio_task_runner_, | 166 audio_task_runner_, |
| 162 network_task_runner_, | 167 network_task_runner_, |
| 163 desktop_environment_->audio_capturer(), | 168 desktop_environment_->CreateAudioCapturer(audio_task_runner_), |
| 164 audio_encoder.Pass(), | 169 audio_encoder.Pass(), |
| 165 connection_->audio_stub()); | 170 connection_->audio_stub()); |
| 166 ++active_recorders_; | |
| 167 } | 171 } |
| 168 | 172 |
| 169 // Notify the event handler that all our channels are now connected. | 173 // Notify the event handler that all our channels are now connected. |
| 170 event_handler_->OnSessionChannelsConnected(this); | 174 event_handler_->OnSessionChannelsConnected(this); |
| 171 } | 175 } |
| 172 | 176 |
| 173 void ClientSession::OnConnectionClosed( | 177 void ClientSession::OnConnectionClosed( |
| 174 protocol::ConnectionToClient* connection, | 178 protocol::ConnectionToClient* connection, |
| 175 protocol::ErrorCode error) { | 179 protocol::ErrorCode error) { |
| 176 DCHECK(CalledOnValidThread()); | 180 DCHECK(CalledOnValidThread()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 187 // TODO(wez): Fix ChromotingHost::OnSessionClosed not to check our | 191 // TODO(wez): Fix ChromotingHost::OnSessionClosed not to check our |
| 188 // is_authenticated(), so that we can disable |auth_*_filter_| here. | 192 // is_authenticated(), so that we can disable |auth_*_filter_| here. |
| 189 disable_input_filter_.set_enabled(false); | 193 disable_input_filter_.set_enabled(false); |
| 190 disable_clipboard_filter_.set_enabled(false); | 194 disable_clipboard_filter_.set_enabled(false); |
| 191 | 195 |
| 192 // Ensure that any pressed keys or buttons are released. | 196 // Ensure that any pressed keys or buttons are released. |
| 193 input_tracker_.ReleaseAll(); | 197 input_tracker_.ReleaseAll(); |
| 194 | 198 |
| 195 // Stop components access the client, audio or video stubs, which are no | 199 // Stop components access the client, audio or video stubs, which are no |
| 196 // longer valid once ConnectionToClient calls OnConnectionClosed(). | 200 // longer valid once ConnectionToClient calls OnConnectionClosed(). |
| 197 if (audio_scheduler_.get()) { | 201 if (audio_scheduler_) { |
| 198 audio_scheduler_->Stop(base::Bind(&ClientSession::OnRecorderStopped, this)); | 202 audio_scheduler_->Stop(); |
| 199 audio_scheduler_ = NULL; | 203 audio_scheduler_ = NULL; |
| 200 } | 204 } |
| 201 if (video_scheduler_.get()) { | 205 if (video_scheduler_) { |
| 202 video_scheduler_->Stop(base::Bind(&ClientSession::OnRecorderStopped, this)); | 206 video_scheduler_->Stop(); |
| 203 video_scheduler_ = NULL; | 207 video_scheduler_ = NULL; |
| 204 } | 208 } |
| 209 |
| 205 client_clipboard_factory_.InvalidateWeakPtrs(); | 210 client_clipboard_factory_.InvalidateWeakPtrs(); |
| 211 event_executor_.reset(); |
| 206 | 212 |
| 207 // Notify the ChromotingHost that this client is disconnected. | 213 // Notify the ChromotingHost that this client is disconnected. |
| 208 // TODO(sergeyu): Log failure reason? | 214 // TODO(sergeyu): Log failure reason? |
| 209 event_handler_->OnSessionClosed(this); | 215 event_handler_->OnSessionClosed(this); |
| 210 } | 216 } |
| 211 | 217 |
| 212 void ClientSession::OnSequenceNumberUpdated( | 218 void ClientSession::OnSequenceNumberUpdated( |
| 213 protocol::ConnectionToClient* connection, int64 sequence_number) { | 219 protocol::ConnectionToClient* connection, int64 sequence_number) { |
| 214 DCHECK(CalledOnValidThread()); | 220 DCHECK(CalledOnValidThread()); |
| 215 DCHECK_EQ(connection_.get(), connection); | 221 DCHECK_EQ(connection_.get(), connection); |
| 216 | 222 |
| 217 if (video_scheduler_.get()) | 223 if (video_scheduler_) |
| 218 video_scheduler_->UpdateSequenceNumber(sequence_number); | 224 video_scheduler_->UpdateSequenceNumber(sequence_number); |
| 219 | 225 |
| 220 event_handler_->OnSessionSequenceNumber(this, sequence_number); | 226 event_handler_->OnSessionSequenceNumber(this, sequence_number); |
| 221 } | 227 } |
| 222 | 228 |
| 223 void ClientSession::OnRouteChange( | 229 void ClientSession::OnRouteChange( |
| 224 protocol::ConnectionToClient* connection, | 230 protocol::ConnectionToClient* connection, |
| 225 const std::string& channel_name, | 231 const std::string& channel_name, |
| 226 const protocol::TransportRoute& route) { | 232 const protocol::TransportRoute& route) { |
| 227 DCHECK(CalledOnValidThread()); | 233 DCHECK(CalledOnValidThread()); |
| 228 DCHECK_EQ(connection_.get(), connection); | 234 DCHECK_EQ(connection_.get(), connection); |
| 229 event_handler_->OnSessionRouteChange(this, channel_name, route); | 235 event_handler_->OnSessionRouteChange(this, channel_name, route); |
| 230 } | 236 } |
| 231 | 237 |
| 232 void ClientSession::Disconnect() { | 238 void ClientSession::Disconnect() { |
| 233 DCHECK(CalledOnValidThread()); | 239 DCHECK(CalledOnValidThread()); |
| 234 DCHECK(connection_.get()); | 240 DCHECK(connection_.get()); |
| 235 | 241 |
| 236 max_duration_timer_.Stop(); | 242 max_duration_timer_.Stop(); |
| 237 | 243 |
| 238 // This triggers OnConnectionClosed(), and the session may be destroyed | 244 // This triggers OnConnectionClosed(), and the session may be destroyed |
| 239 // as the result, so this call must be the last in this method. | 245 // as the result, so this call must be the last in this method. |
| 240 connection_->Disconnect(); | 246 connection_->Disconnect(); |
| 241 } | 247 } |
| 242 | 248 |
| 243 void ClientSession::Stop(const base::Closure& stopped_task) { | 249 void ClientSession::Stop() { |
| 244 DCHECK(CalledOnValidThread()); | 250 DCHECK(CalledOnValidThread()); |
| 245 DCHECK(stopped_task_.is_null()); | 251 DCHECK(!audio_scheduler_); |
| 246 DCHECK(!stopped_task.is_null()); | 252 DCHECK(!event_executor_); |
| 247 DCHECK(audio_scheduler_.get() == NULL); | 253 DCHECK(!video_scheduler_); |
| 248 DCHECK(video_scheduler_.get() == NULL); | |
| 249 | 254 |
| 250 stopped_task_ = stopped_task; | 255 connection_.reset(); |
| 251 | |
| 252 if (active_recorders_ == 0) { | |
| 253 // |stopped_task_| may tear down the signalling layer, so tear-down | |
| 254 // |connection_| before invoking it. | |
| 255 connection_.reset(); | |
| 256 stopped_task_.Run(); | |
| 257 } | |
| 258 } | 256 } |
| 259 | 257 |
| 260 void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { | 258 void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { |
| 261 DCHECK(CalledOnValidThread()); | 259 DCHECK(CalledOnValidThread()); |
| 262 remote_input_filter_.LocalMouseMoved(mouse_pos); | 260 remote_input_filter_.LocalMouseMoved(mouse_pos); |
| 263 } | 261 } |
| 264 | 262 |
| 265 void ClientSession::SetDisableInputs(bool disable_inputs) { | 263 void ClientSession::SetDisableInputs(bool disable_inputs) { |
| 266 DCHECK(CalledOnValidThread()); | 264 DCHECK(CalledOnValidThread()); |
| 267 | 265 |
| 268 if (disable_inputs) | 266 if (disable_inputs) |
| 269 input_tracker_.ReleaseAll(); | 267 input_tracker_.ReleaseAll(); |
| 270 | 268 |
| 271 disable_input_filter_.set_enabled(!disable_inputs); | 269 disable_input_filter_.set_enabled(!disable_inputs); |
| 272 disable_clipboard_filter_.set_enabled(!disable_inputs); | 270 disable_clipboard_filter_.set_enabled(!disable_inputs); |
| 273 } | 271 } |
| 274 | 272 |
| 275 ClientSession::~ClientSession() { | 273 ClientSession::~ClientSession() { |
| 276 DCHECK_EQ(active_recorders_, 0); | 274 DCHECK(CalledOnValidThread()); |
| 277 DCHECK(audio_scheduler_.get() == NULL); | 275 DCHECK(!audio_scheduler_); |
| 278 DCHECK(video_scheduler_.get() == NULL); | 276 DCHECK(!event_executor_); |
| 277 DCHECK(!video_scheduler_); |
| 279 } | 278 } |
| 280 | 279 |
| 281 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 280 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
| 282 DCHECK(CalledOnValidThread()); | 281 DCHECK(CalledOnValidThread()); |
| 283 | 282 |
| 284 return scoped_ptr<protocol::ClipboardStub>( | 283 return scoped_ptr<protocol::ClipboardStub>( |
| 285 new protocol::ClipboardThreadProxy( | 284 new protocol::ClipboardThreadProxy( |
| 286 client_clipboard_factory_.GetWeakPtr(), | 285 client_clipboard_factory_.GetWeakPtr(), |
| 287 base::MessageLoopProxy::current())); | 286 base::MessageLoopProxy::current())); |
| 288 } | 287 } |
| 289 | 288 |
| 290 void ClientSession::OnRecorderStopped() { | |
| 291 if (!network_task_runner_->BelongsToCurrentThread()) { | |
| 292 network_task_runner_->PostTask( | |
| 293 FROM_HERE, base::Bind(&ClientSession::OnRecorderStopped, this)); | |
| 294 return; | |
| 295 } | |
| 296 | |
| 297 --active_recorders_; | |
| 298 DCHECK_GE(active_recorders_, 0); | |
| 299 | |
| 300 DCHECK(!stopped_task_.is_null()); | |
| 301 if (active_recorders_ == 0) { | |
| 302 // |stopped_task_| may result in the signalling layer being torn down, so | |
| 303 // tear down the ConnectionToClient first. | |
| 304 connection_.reset(); | |
| 305 stopped_task_.Run(); | |
| 306 } | |
| 307 } | |
| 308 | |
| 309 // TODO(sergeyu): Move this to SessionManager? | 289 // TODO(sergeyu): Move this to SessionManager? |
| 310 // static | 290 // static |
| 311 scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder( | 291 scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder( |
| 312 const protocol::SessionConfig& config) { | 292 const protocol::SessionConfig& config) { |
| 313 const protocol::ChannelConfig& video_config = config.video_config(); | 293 const protocol::ChannelConfig& video_config = config.video_config(); |
| 314 | 294 |
| 315 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { | 295 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { |
| 316 return scoped_ptr<VideoEncoder>(new remoting::VideoEncoderVerbatim()); | 296 return scoped_ptr<VideoEncoder>(new remoting::VideoEncoderVerbatim()); |
| 317 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { | 297 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { |
| 318 return scoped_ptr<VideoEncoder>(new remoting::VideoEncoderVp8()); | 298 return scoped_ptr<VideoEncoder>(new remoting::VideoEncoderVp8()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 338 NOTIMPLEMENTED(); | 318 NOTIMPLEMENTED(); |
| 339 return scoped_ptr<AudioEncoder>(NULL); | 319 return scoped_ptr<AudioEncoder>(NULL); |
| 340 } | 320 } |
| 341 | 321 |
| 342 // static | 322 // static |
| 343 void ClientSessionTraits::Destruct(const ClientSession* client) { | 323 void ClientSessionTraits::Destruct(const ClientSession* client) { |
| 344 client->network_task_runner_->DeleteSoon(FROM_HERE, client); | 324 client->network_task_runner_->DeleteSoon(FROM_HERE, client); |
| 345 } | 325 } |
| 346 | 326 |
| 347 } // namespace remoting | 327 } // namespace remoting |
| OLD | NEW |