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