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/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "jingle/glue/thread_wrapper.h" | 14 #include "jingle/glue/thread_wrapper.h" |
15 #include "remoting/base/constants.h" | 15 #include "remoting/base/constants.h" |
16 #include "remoting/base/logging.h" | 16 #include "remoting/base/logging.h" |
17 #include "remoting/host/chromoting_host_context.h" | 17 #include "remoting/host/chromoting_host_context.h" |
18 #include "remoting/host/desktop_environment.h" | 18 #include "remoting/host/desktop_environment.h" |
19 #include "remoting/host/host_config.h" | 19 #include "remoting/host/host_config.h" |
20 #include "remoting/host/input_injector.h" | 20 #include "remoting/host/input_injector.h" |
21 #include "remoting/host/video_frame_recorder.h" | |
21 #include "remoting/protocol/connection_to_client.h" | 22 #include "remoting/protocol/connection_to_client.h" |
22 #include "remoting/protocol/client_stub.h" | 23 #include "remoting/protocol/client_stub.h" |
23 #include "remoting/protocol/host_stub.h" | 24 #include "remoting/protocol/host_stub.h" |
24 #include "remoting/protocol/input_stub.h" | 25 #include "remoting/protocol/input_stub.h" |
25 #include "remoting/protocol/session_config.h" | 26 #include "remoting/protocol/session_config.h" |
26 | 27 |
27 using remoting::protocol::ConnectionToClient; | 28 using remoting::protocol::ConnectionToClient; |
28 using remoting::protocol::InputStub; | 29 using remoting::protocol::InputStub; |
29 | 30 |
30 namespace remoting { | 31 namespace remoting { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 video_encode_task_runner_(video_encode_task_runner), | 78 video_encode_task_runner_(video_encode_task_runner), |
78 network_task_runner_(network_task_runner), | 79 network_task_runner_(network_task_runner), |
79 ui_task_runner_(ui_task_runner), | 80 ui_task_runner_(ui_task_runner), |
80 signal_strategy_(signal_strategy), | 81 signal_strategy_(signal_strategy), |
81 started_(false), | 82 started_(false), |
82 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()), | 83 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()), |
83 login_backoff_(&kDefaultBackoffPolicy), | 84 login_backoff_(&kDefaultBackoffPolicy), |
84 authenticating_client_(false), | 85 authenticating_client_(false), |
85 reject_authenticating_client_(false), | 86 reject_authenticating_client_(false), |
86 enable_curtaining_(false), | 87 enable_curtaining_(false), |
88 enable_video_frame_recording_(false), | |
87 weak_factory_(this) { | 89 weak_factory_(this) { |
88 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 90 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
89 DCHECK(signal_strategy); | 91 DCHECK(signal_strategy); |
90 | 92 |
91 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 93 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
92 | 94 |
93 if (!desktop_environment_factory_->SupportsAudioCapture()) { | 95 if (!desktop_environment_factory_->SupportsAudioCapture()) { |
94 protocol_config_->DisableAudioChannel(); | 96 protocol_config_->DisableAudioChannel(); |
95 } | 97 } |
96 } | 98 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 // curtained sessions. | 167 // curtained sessions. |
166 if (enable_curtaining_) | 168 if (enable_curtaining_) |
167 DisconnectAllClients(); | 169 DisconnectAllClients(); |
168 } | 170 } |
169 | 171 |
170 void ChromotingHost::SetMaximumSessionDuration( | 172 void ChromotingHost::SetMaximumSessionDuration( |
171 const base::TimeDelta& max_session_duration) { | 173 const base::TimeDelta& max_session_duration) { |
172 max_session_duration_ = max_session_duration; | 174 max_session_duration_ = max_session_duration; |
173 } | 175 } |
174 | 176 |
177 void ChromotingHost::SetEnableVideoFrameRecording(bool enable) { | |
178 DCHECK(network_task_runner_->BelongsToCurrentThread()); | |
179 | |
180 if (enable_video_frame_recording_ == enable) | |
181 return; | |
182 | |
183 enable_video_frame_recording_ = enable; | |
184 | |
185 // Disconnect existing clients if recording is being disabled, in case | |
186 // one of them is using it. | |
187 if (!enable) { | |
Sergey Ulanov
2014/07/11 18:38:03
nit: remove {}
| |
188 DisconnectAllClients(); | |
189 } | |
190 } | |
191 | |
175 //////////////////////////////////////////////////////////////////////////// | 192 //////////////////////////////////////////////////////////////////////////// |
176 // protocol::ClientSession::EventHandler implementation. | 193 // protocol::ClientSession::EventHandler implementation. |
177 void ChromotingHost::OnSessionAuthenticating(ClientSession* client) { | 194 void ChromotingHost::OnSessionAuthenticating(ClientSession* client) { |
178 // We treat each incoming connection as a failure to authenticate, | 195 // We treat each incoming connection as a failure to authenticate, |
179 // and clear the backoff when a connection successfully | 196 // and clear the backoff when a connection successfully |
180 // authenticates. This allows the backoff to protect from parallel | 197 // authenticates. This allows the backoff to protect from parallel |
181 // connection attempts as well as sequential ones. | 198 // connection attempts as well as sequential ones. |
182 if (login_backoff_.ShouldRejectRequest()) { | 199 if (login_backoff_.ShouldRejectRequest()) { |
183 LOG(WARNING) << "Disconnecting client " << client->client_jid() << " due to" | 200 LOG(WARNING) << "Disconnecting client " << client->client_jid() << " due to" |
184 " an overload of failed login attempts."; | 201 " an overload of failed login attempts."; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 input_task_runner_, | 341 input_task_runner_, |
325 video_capture_task_runner_, | 342 video_capture_task_runner_, |
326 video_encode_task_runner_, | 343 video_encode_task_runner_, |
327 network_task_runner_, | 344 network_task_runner_, |
328 ui_task_runner_, | 345 ui_task_runner_, |
329 connection.Pass(), | 346 connection.Pass(), |
330 desktop_environment_factory_, | 347 desktop_environment_factory_, |
331 max_session_duration_, | 348 max_session_duration_, |
332 pairing_registry_); | 349 pairing_registry_); |
333 | 350 |
351 // Set a video frame recorder if recording is enabled. | |
352 if (enable_video_frame_recording_) { | |
353 client->set_video_frame_recorder( | |
354 scoped_ptr<VideoFrameRecorder>(new VideoFrameRecorder())); | |
355 } | |
356 | |
334 // Registers capabilities provided by host extensions. | 357 // Registers capabilities provided by host extensions. |
335 for (HostExtensionList::iterator extension = extensions_.begin(); | 358 for (HostExtensionList::iterator extension = extensions_.begin(); |
336 extension != extensions_.end(); ++extension) { | 359 extension != extensions_.end(); ++extension) { |
337 client->AddHostCapabilities((*extension)->GetCapabilities()); | 360 client->AddHostCapabilities((*extension)->GetCapabilities()); |
338 } | 361 } |
339 | 362 |
340 clients_.push_back(client); | 363 clients_.push_back(client); |
341 } | 364 } |
342 | 365 |
343 void ChromotingHost::set_protocol_config( | 366 void ChromotingHost::set_protocol_config( |
344 scoped_ptr<protocol::CandidateSessionConfig> config) { | 367 scoped_ptr<protocol::CandidateSessionConfig> config) { |
345 DCHECK(CalledOnValidThread()); | 368 DCHECK(CalledOnValidThread()); |
346 DCHECK(config.get()); | 369 DCHECK(config.get()); |
347 DCHECK(!started_); | 370 DCHECK(!started_); |
348 protocol_config_ = config.Pass(); | 371 protocol_config_ = config.Pass(); |
349 } | 372 } |
350 | 373 |
351 void ChromotingHost::DisconnectAllClients() { | 374 void ChromotingHost::DisconnectAllClients() { |
352 DCHECK(CalledOnValidThread()); | 375 DCHECK(CalledOnValidThread()); |
353 | 376 |
354 while (!clients_.empty()) { | 377 while (!clients_.empty()) { |
355 size_t size = clients_.size(); | 378 size_t size = clients_.size(); |
356 clients_.front()->DisconnectSession(); | 379 clients_.front()->DisconnectSession(); |
357 CHECK_EQ(clients_.size(), size - 1); | 380 CHECK_EQ(clients_.size(), size - 1); |
358 } | 381 } |
359 } | 382 } |
360 | 383 |
361 } // namespace remoting | 384 } // namespace remoting |
OLD | NEW |