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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 #include "remoting/host/single_window_desktop_environment.h" | 73 #include "remoting/host/single_window_desktop_environment.h" |
74 #include "remoting/host/switches.h" | 74 #include "remoting/host/switches.h" |
75 #include "remoting/host/third_party_auth_config.h" | 75 #include "remoting/host/third_party_auth_config.h" |
76 #include "remoting/host/token_validator_factory_impl.h" | 76 #include "remoting/host/token_validator_factory_impl.h" |
77 #include "remoting/host/usage_stats_consent.h" | 77 #include "remoting/host/usage_stats_consent.h" |
78 #include "remoting/host/username.h" | 78 #include "remoting/host/username.h" |
79 #include "remoting/host/video_frame_recorder_host_extension.h" | 79 #include "remoting/host/video_frame_recorder_host_extension.h" |
80 #include "remoting/protocol/authenticator.h" | 80 #include "remoting/protocol/authenticator.h" |
81 #include "remoting/protocol/channel_authenticator.h" | 81 #include "remoting/protocol/channel_authenticator.h" |
82 #include "remoting/protocol/chromium_port_allocator.h" | 82 #include "remoting/protocol/chromium_port_allocator.h" |
83 #include "remoting/protocol/ice_transport.h" | |
84 #include "remoting/protocol/jingle_session_manager.h" | 83 #include "remoting/protocol/jingle_session_manager.h" |
85 #include "remoting/protocol/me2me_host_authenticator_factory.h" | 84 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
86 #include "remoting/protocol/network_settings.h" | 85 #include "remoting/protocol/network_settings.h" |
87 #include "remoting/protocol/pairing_registry.h" | 86 #include "remoting/protocol/pairing_registry.h" |
88 #include "remoting/protocol/port_range.h" | 87 #include "remoting/protocol/port_range.h" |
89 #include "remoting/protocol/token_validator.h" | 88 #include "remoting/protocol/token_validator.h" |
90 #include "remoting/protocol/transport_context.h" | 89 #include "remoting/protocol/transport_context.h" |
91 #include "remoting/protocol/webrtc_transport.h" | |
92 #include "remoting/signaling/push_notification_subscriber.h" | 90 #include "remoting/signaling/push_notification_subscriber.h" |
93 #include "remoting/signaling/xmpp_signal_strategy.h" | 91 #include "remoting/signaling/xmpp_signal_strategy.h" |
94 #include "third_party/webrtc/base/scoped_ref_ptr.h" | 92 #include "third_party/webrtc/base/scoped_ref_ptr.h" |
95 | 93 |
96 #if defined(OS_POSIX) | 94 #if defined(OS_POSIX) |
97 #include <signal.h> | 95 #include <signal.h> |
98 #include <sys/types.h> | 96 #include <sys/types.h> |
99 #include <unistd.h> | 97 #include <unistd.h> |
100 #include "base/file_descriptor_posix.h" | 98 #include "base/file_descriptor_posix.h" |
101 #include "remoting/host/pam_authorization_factory_posix.h" | 99 #include "remoting/host/pam_authorization_factory_posix.h" |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 remoting::AudioCapturerLinux::InitializePipeReader( | 876 remoting::AudioCapturerLinux::InitializePipeReader( |
879 context_->audio_task_runner(), audio_pipe_name); | 877 context_->audio_task_runner(), audio_pipe_name); |
880 } | 878 } |
881 | 879 |
882 base::FilePath gnubby_socket_name = base::CommandLine::ForCurrentProcess()-> | 880 base::FilePath gnubby_socket_name = base::CommandLine::ForCurrentProcess()-> |
883 GetSwitchValuePath(kAuthSocknameSwitchName); | 881 GetSwitchValuePath(kAuthSocknameSwitchName); |
884 if (!gnubby_socket_name.empty()) | 882 if (!gnubby_socket_name.empty()) |
885 remoting::GnubbyAuthHandler::SetGnubbySocketName(gnubby_socket_name); | 883 remoting::GnubbyAuthHandler::SetGnubbySocketName(gnubby_socket_name); |
886 #endif // defined(OS_LINUX) | 884 #endif // defined(OS_LINUX) |
887 | 885 |
| 886 #if defined(NDEBUG) |
| 887 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { |
| 888 LOG(ERROR) << "WebRTC is enabled only in debug builds."; |
| 889 ShutdownHost(kUsageExitCode); |
| 890 return; |
| 891 } |
| 892 #endif // defined(NDEBUG) |
| 893 |
888 // Create a desktop environment factory appropriate to the build type & | 894 // Create a desktop environment factory appropriate to the build type & |
889 // platform. | 895 // platform. |
890 #if defined(OS_WIN) | 896 #if defined(OS_WIN) |
891 IpcDesktopEnvironmentFactory* desktop_environment_factory = | 897 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
892 new IpcDesktopEnvironmentFactory( | 898 new IpcDesktopEnvironmentFactory( |
893 context_->audio_task_runner(), | 899 context_->audio_task_runner(), |
894 context_->network_task_runner(), | 900 context_->network_task_runner(), |
895 context_->video_capture_task_runner(), | 901 context_->video_capture_task_runner(), |
896 context_->network_task_runner(), | 902 context_->network_task_runner(), |
897 daemon_channel_.get()); | 903 daemon_channel_.get()); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 network_settings.port_range.min_port = NetworkSettings::kDefaultMinPort; | 1506 network_settings.port_range.min_port = NetworkSettings::kDefaultMinPort; |
1501 network_settings.port_range.max_port = NetworkSettings::kDefaultMaxPort; | 1507 network_settings.port_range.max_port = NetworkSettings::kDefaultMaxPort; |
1502 } | 1508 } |
1503 | 1509 |
1504 scoped_refptr<protocol::TransportContext> transport_context = | 1510 scoped_refptr<protocol::TransportContext> transport_context = |
1505 new protocol::TransportContext( | 1511 new protocol::TransportContext( |
1506 signal_strategy_.get(), | 1512 signal_strategy_.get(), |
1507 make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory( | 1513 make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory( |
1508 context_->url_request_context_getter())), | 1514 context_->url_request_context_getter())), |
1509 network_settings, protocol::TransportRole::SERVER); | 1515 network_settings, protocol::TransportRole::SERVER); |
1510 scoped_ptr<protocol::TransportFactory> transport_factory; | |
1511 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { | |
1512 #if !defined(NDEBUG) | |
1513 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | |
1514 | 1516 |
1515 // The network thread is also used as worker thread for webrtc. | |
1516 // | |
1517 // TODO(sergeyu): Figure out if we would benefit from using a separate | |
1518 // thread as a worker thread. | |
1519 transport_factory.reset(new protocol::WebrtcTransportFactory( | |
1520 jingle_glue::JingleThreadWrapper::current(), transport_context)); | |
1521 #else // !defined(NDEBUG) | |
1522 LOG(ERROR) << "WebRTC is enabled only in debug builds."; | |
1523 ShutdownHost(kUsageExitCode); | |
1524 return; | |
1525 #endif // defined(NDEBUG) | |
1526 } else { | |
1527 transport_factory.reset( | |
1528 new protocol::IceTransportFactory(transport_context)); | |
1529 } | |
1530 scoped_ptr<protocol::SessionManager> session_manager( | 1517 scoped_ptr<protocol::SessionManager> session_manager( |
1531 new protocol::JingleSessionManager(std::move(transport_factory), | 1518 new protocol::JingleSessionManager(signal_strategy_.get())); |
1532 signal_strategy_.get())); | |
1533 | 1519 |
1534 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = | 1520 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = |
1535 protocol::CandidateSessionConfig::CreateDefault(); | 1521 protocol::CandidateSessionConfig::CreateDefault(); |
1536 if (!desktop_environment_factory_->SupportsAudioCapture()) | 1522 if (!desktop_environment_factory_->SupportsAudioCapture()) |
1537 protocol_config->DisableAudioChannel(); | 1523 protocol_config->DisableAudioChannel(); |
1538 if (enable_vp9_) | 1524 if (enable_vp9_) |
1539 protocol_config->set_vp9_experiment_enabled(true); | 1525 protocol_config->set_vp9_experiment_enabled(true); |
1540 #if !defined(NDEBUG) | 1526 #if !defined(NDEBUG) |
1541 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { | 1527 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { |
1542 protocol_config->set_webrtc_supported(true); | 1528 protocol_config->set_webrtc_supported(true); |
1543 } | 1529 } |
1544 #endif // !defined(NDEBUG) | 1530 #endif // !defined(NDEBUG) |
1545 session_manager->set_protocol_config(std::move(protocol_config)); | 1531 session_manager->set_protocol_config(std::move(protocol_config)); |
1546 | 1532 |
1547 host_.reset(new ChromotingHost( | 1533 host_.reset(new ChromotingHost( |
1548 desktop_environment_factory_.get(), std::move(session_manager), | 1534 desktop_environment_factory_.get(), std::move(session_manager), |
1549 context_->audio_task_runner(), context_->input_task_runner(), | 1535 transport_context, context_->audio_task_runner(), |
1550 context_->video_capture_task_runner(), | 1536 context_->input_task_runner(), context_->video_capture_task_runner(), |
1551 context_->video_encode_task_runner(), context_->network_task_runner(), | 1537 context_->video_encode_task_runner(), context_->network_task_runner(), |
1552 context_->ui_task_runner())); | 1538 context_->ui_task_runner())); |
1553 | 1539 |
1554 if (frame_recorder_buffer_size_ > 0) { | 1540 if (frame_recorder_buffer_size_ > 0) { |
1555 scoped_ptr<VideoFrameRecorderHostExtension> frame_recorder_extension( | 1541 scoped_ptr<VideoFrameRecorderHostExtension> frame_recorder_extension( |
1556 new VideoFrameRecorderHostExtension()); | 1542 new VideoFrameRecorderHostExtension()); |
1557 frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_); | 1543 frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_); |
1558 host_->AddExtension(std::move(frame_recorder_extension)); | 1544 host_->AddExtension(std::move(frame_recorder_extension)); |
1559 } | 1545 } |
1560 | 1546 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); | 1738 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); |
1753 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); | 1739 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); |
1754 | 1740 |
1755 // Run the main (also UI) message loop until the host no longer needs it. | 1741 // Run the main (also UI) message loop until the host no longer needs it. |
1756 message_loop.Run(); | 1742 message_loop.Run(); |
1757 | 1743 |
1758 return exit_code; | 1744 return exit_code; |
1759 } | 1745 } |
1760 | 1746 |
1761 } // namespace remoting | 1747 } // namespace remoting |
OLD | NEW |