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 // This file implements a standalone host process for Me2Me. | 5 // This file implements a standalone host process for Me2Me. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 #include "remoting/host/ipc_constants.h" | 58 #include "remoting/host/ipc_constants.h" |
59 #include "remoting/host/ipc_desktop_environment.h" | 59 #include "remoting/host/ipc_desktop_environment.h" |
60 #include "remoting/host/ipc_host_event_logger.h" | 60 #include "remoting/host/ipc_host_event_logger.h" |
61 #include "remoting/host/json_host_config.h" | 61 #include "remoting/host/json_host_config.h" |
62 #include "remoting/host/logging.h" | 62 #include "remoting/host/logging.h" |
63 #include "remoting/host/me2me_desktop_environment.h" | 63 #include "remoting/host/me2me_desktop_environment.h" |
64 #include "remoting/host/pairing_registry_delegate.h" | 64 #include "remoting/host/pairing_registry_delegate.h" |
65 #include "remoting/host/policy_hack/policy_watcher.h" | 65 #include "remoting/host/policy_hack/policy_watcher.h" |
66 #include "remoting/host/session_manager_factory.h" | 66 #include "remoting/host/session_manager_factory.h" |
67 #include "remoting/host/signaling_connector.h" | 67 #include "remoting/host/signaling_connector.h" |
68 #include "remoting/host/single_window_desktop_environment.h" | |
68 #include "remoting/host/token_validator_factory_impl.h" | 69 #include "remoting/host/token_validator_factory_impl.h" |
69 #include "remoting/host/usage_stats_consent.h" | 70 #include "remoting/host/usage_stats_consent.h" |
70 #include "remoting/host/username.h" | 71 #include "remoting/host/username.h" |
71 #include "remoting/host/video_frame_recorder_host_extension.h" | 72 #include "remoting/host/video_frame_recorder_host_extension.h" |
72 #include "remoting/protocol/me2me_host_authenticator_factory.h" | 73 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
73 #include "remoting/protocol/network_settings.h" | 74 #include "remoting/protocol/network_settings.h" |
74 #include "remoting/protocol/pairing_registry.h" | 75 #include "remoting/protocol/pairing_registry.h" |
75 #include "remoting/protocol/token_validator.h" | 76 #include "remoting/protocol/token_validator.h" |
76 #include "remoting/signaling/xmpp_signal_strategy.h" | 77 #include "remoting/signaling/xmpp_signal_strategy.h" |
77 | 78 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 // Command line switch used to enable VP9 encoding. | 127 // Command line switch used to enable VP9 encoding. |
127 const char kEnableVp9SwitchName[] = "enable-vp9"; | 128 const char kEnableVp9SwitchName[] = "enable-vp9"; |
128 | 129 |
129 // Command line switch used to enable and configure the frame-recorder. | 130 // Command line switch used to enable and configure the frame-recorder. |
130 const char kFrameRecorderBufferKbName[] = "frame-recorder-buffer-kb"; | 131 const char kFrameRecorderBufferKbName[] = "frame-recorder-buffer-kb"; |
131 | 132 |
132 // Value used for --host-config option to indicate that the path must be read | 133 // Value used for --host-config option to indicate that the path must be read |
133 // from stdin. | 134 // from stdin. |
134 const char kStdinConfigPath[] = "-"; | 135 const char kStdinConfigPath[] = "-"; |
135 | 136 |
137 const char kWindowIdSwitchName[] = "window-id"; | |
138 | |
136 } // namespace | 139 } // namespace |
137 | 140 |
138 namespace remoting { | 141 namespace remoting { |
139 | 142 |
140 class HostProcess | 143 class HostProcess |
141 : public ConfigWatcher::Delegate, | 144 : public ConfigWatcher::Delegate, |
142 public HeartbeatSender::Listener, | 145 public HeartbeatSender::Listener, |
143 public HostChangeNotificationListener::Listener, | 146 public HostChangeNotificationListener::Listener, |
144 public IPC::Listener, | 147 public IPC::Listener, |
145 public base::RefCountedThreadSafe<HostProcess> { | 148 public base::RefCountedThreadSafe<HostProcess> { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 bool allow_relay_; | 305 bool allow_relay_; |
303 int min_udp_port_; | 306 int min_udp_port_; |
304 int max_udp_port_; | 307 int max_udp_port_; |
305 std::string talkgadget_prefix_; | 308 std::string talkgadget_prefix_; |
306 bool allow_pairing_; | 309 bool allow_pairing_; |
307 | 310 |
308 bool curtain_required_; | 311 bool curtain_required_; |
309 ThirdPartyAuthConfig third_party_auth_config_; | 312 ThirdPartyAuthConfig third_party_auth_config_; |
310 bool enable_gnubby_auth_; | 313 bool enable_gnubby_auth_; |
311 | 314 |
315 // Boolean to change flow, where ncessary, if we're | |
316 // capturing a window instead of the entire desktop. | |
317 bool enable_window_capture_; | |
318 | |
319 // Used to specify which window to stream, if enabled. | |
320 webrtc::WindowId window_id_; | |
321 | |
312 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; | 322 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; |
313 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 323 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
314 scoped_ptr<SignalingConnector> signaling_connector_; | 324 scoped_ptr<SignalingConnector> signaling_connector_; |
315 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 325 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
316 scoped_ptr<HostStatusSender> host_status_sender_; | 326 scoped_ptr<HostStatusSender> host_status_sender_; |
317 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; | 327 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; |
318 scoped_ptr<HostStatusLogger> host_status_logger_; | 328 scoped_ptr<HostStatusLogger> host_status_logger_; |
319 scoped_ptr<HostEventLogger> host_event_logger_; | 329 scoped_ptr<HostEventLogger> host_event_logger_; |
320 | 330 |
321 scoped_ptr<ChromotingHost> host_; | 331 scoped_ptr<ChromotingHost> host_; |
(...skipping 19 matching lines...) Expand all Loading... | |
341 enable_vp9_(false), | 351 enable_vp9_(false), |
342 frame_recorder_buffer_size_(0), | 352 frame_recorder_buffer_size_(0), |
343 host_username_match_required_(false), | 353 host_username_match_required_(false), |
344 allow_nat_traversal_(true), | 354 allow_nat_traversal_(true), |
345 allow_relay_(true), | 355 allow_relay_(true), |
346 min_udp_port_(0), | 356 min_udp_port_(0), |
347 max_udp_port_(0), | 357 max_udp_port_(0), |
348 allow_pairing_(true), | 358 allow_pairing_(true), |
349 curtain_required_(false), | 359 curtain_required_(false), |
350 enable_gnubby_auth_(false), | 360 enable_gnubby_auth_(false), |
361 enable_window_capture_(false), | |
362 window_id_(0), | |
351 #if defined(REMOTING_MULTI_PROCESS) | 363 #if defined(REMOTING_MULTI_PROCESS) |
352 desktop_session_connector_(NULL), | 364 desktop_session_connector_(NULL), |
353 #endif // defined(REMOTING_MULTI_PROCESS) | 365 #endif // defined(REMOTING_MULTI_PROCESS) |
354 self_(this), | 366 self_(this), |
355 exit_code_out_(exit_code_out), | 367 exit_code_out_(exit_code_out), |
356 signal_parent_(false) { | 368 signal_parent_(false) { |
357 StartOnUiThread(); | 369 StartOnUiThread(); |
358 } | 370 } |
359 | 371 |
360 HostProcess::~HostProcess() { | 372 HostProcess::~HostProcess() { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 if (!xmpp_server_valid) { | 459 if (!xmpp_server_valid) { |
448 LOG(ERROR) << "Invalid XMPP server: " << | 460 LOG(ERROR) << "Invalid XMPP server: " << |
449 service_urls->xmpp_server_address(); | 461 service_urls->xmpp_server_address(); |
450 return false; | 462 return false; |
451 } | 463 } |
452 xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls(); | 464 xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls(); |
453 directory_bot_jid_ = service_urls->directory_bot_jid(); | 465 directory_bot_jid_ = service_urls->directory_bot_jid(); |
454 | 466 |
455 signal_parent_ = cmd_line->HasSwitch(kSignalParentSwitchName); | 467 signal_parent_ = cmd_line->HasSwitch(kSignalParentSwitchName); |
456 | 468 |
469 enable_window_capture_ = cmd_line->HasSwitch(kWindowIdSwitchName); | |
470 if (enable_window_capture_) { | |
471 | |
472 #if defined(OS_LINUX) || defined(OS_WIN) | |
473 LOG(WARNING) << "Window capturing is not fully supported on Linux or Windows."; | |
Sergey Ulanov
2014/08/13 22:06:22
this still needs to be indented 4 spaces, i.e.
#i
ronakvora do not use
2014/08/13 22:17:01
Done.
| |
474 #endif // defined(OS_LINUX) || defined(OS_WIN) | |
475 | |
476 // uint32_t is large enough to hold window IDs on all platforms. | |
477 uint32_t window_id; | |
478 if (base::StringToUint( | |
479 cmd_line->GetSwitchValueASCII(kWindowIdSwitchName), | |
480 &window_id)) { | |
481 window_id_ = static_cast<webrtc::WindowId>(window_id); | |
482 } else { | |
483 LOG(ERROR) << "Window with window id: " << window_id_ | |
484 << " not found. Shutting down host."; | |
485 return false; | |
486 } | |
487 } | |
457 return true; | 488 return true; |
458 } | 489 } |
459 | 490 |
460 void HostProcess::OnConfigUpdated( | 491 void HostProcess::OnConfigUpdated( |
461 const std::string& serialized_config) { | 492 const std::string& serialized_config) { |
462 if (!context_->network_task_runner()->BelongsToCurrentThread()) { | 493 if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
463 context_->network_task_runner()->PostTask(FROM_HERE, | 494 context_->network_task_runner()->PostTask(FROM_HERE, |
464 base::Bind(&HostProcess::OnConfigUpdated, this, serialized_config)); | 495 base::Bind(&HostProcess::OnConfigUpdated, this, serialized_config)); |
465 return; | 496 return; |
466 } | 497 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 #if defined(OS_WIN) | 708 #if defined(OS_WIN) |
678 IpcDesktopEnvironmentFactory* desktop_environment_factory = | 709 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
679 new IpcDesktopEnvironmentFactory( | 710 new IpcDesktopEnvironmentFactory( |
680 context_->audio_task_runner(), | 711 context_->audio_task_runner(), |
681 context_->network_task_runner(), | 712 context_->network_task_runner(), |
682 context_->video_capture_task_runner(), | 713 context_->video_capture_task_runner(), |
683 context_->network_task_runner(), | 714 context_->network_task_runner(), |
684 daemon_channel_.get()); | 715 daemon_channel_.get()); |
685 desktop_session_connector_ = desktop_environment_factory; | 716 desktop_session_connector_ = desktop_environment_factory; |
686 #else // !defined(OS_WIN) | 717 #else // !defined(OS_WIN) |
687 DesktopEnvironmentFactory* desktop_environment_factory = | 718 DesktopEnvironmentFactory* desktop_environment_factory; |
719 if (enable_window_capture_) { | |
720 desktop_environment_factory = | |
721 new SingleWindowDesktopEnvironmentFactory( | |
722 context_->network_task_runner(), | |
723 context_->input_task_runner(), | |
724 context_->ui_task_runner(), | |
725 window_id_); | |
726 } else { | |
727 desktop_environment_factory = | |
688 new Me2MeDesktopEnvironmentFactory( | 728 new Me2MeDesktopEnvironmentFactory( |
689 context_->network_task_runner(), | 729 context_->network_task_runner(), |
690 context_->input_task_runner(), | 730 context_->input_task_runner(), |
691 context_->ui_task_runner()); | 731 context_->ui_task_runner()); |
732 } | |
692 #endif // !defined(OS_WIN) | 733 #endif // !defined(OS_WIN) |
693 | 734 |
694 desktop_environment_factory_.reset(desktop_environment_factory); | 735 desktop_environment_factory_.reset(desktop_environment_factory); |
695 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); | 736 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); |
696 | 737 |
697 context_->network_task_runner()->PostTask( | 738 context_->network_task_runner()->PostTask( |
698 FROM_HERE, | 739 FROM_HERE, |
699 base::Bind(&HostProcess::StartOnNetworkThread, this)); | 740 base::Bind(&HostProcess::StartOnNetworkThread, this)); |
700 } | 741 } |
701 | 742 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1402 int exit_code = kSuccessExitCode; | 1443 int exit_code = kSuccessExitCode; |
1403 new HostProcess(context.Pass(), &exit_code); | 1444 new HostProcess(context.Pass(), &exit_code); |
1404 | 1445 |
1405 // Run the main (also UI) message loop until the host no longer needs it. | 1446 // Run the main (also UI) message loop until the host no longer needs it. |
1406 message_loop.Run(); | 1447 message_loop.Run(); |
1407 | 1448 |
1408 return exit_code; | 1449 return exit_code; |
1409 } | 1450 } |
1410 | 1451 |
1411 } // namespace remoting | 1452 } // namespace remoting |
OLD | NEW |