diff --git a/connections/implementation/mediums/webrtc/BUILD b/connections/implementation/mediums/webrtc/BUILD index c1d34862..916d5de8 100644 --- a/connections/implementation/mediums/webrtc/BUILD +++ b/connections/implementation/mediums/webrtc/BUILD @@ -93,8 +93,7 @@ cc_library( hdrs = ["webrtc.h"], deps = [ "//internal/platform:base", - "//internal/platform/implementation:comm", - "//internal/platform/implementation:platform", + "//internal/platform/implementation:webrtc_platform", # "//third_party/webrtc/files/stable/webrtc/api:libjingle_peerconnection_api", "//third_party/webrtc/files/stable/webrtc/rtc_base:network_constants", "@com_google_absl//absl/strings:string_view", diff --git a/connections/implementation/mediums/webrtc/webrtc.h b/connections/implementation/mediums/webrtc/webrtc.h index adccaa55..27055b4d 100644 --- a/connections/implementation/mediums/webrtc/webrtc.h +++ b/connections/implementation/mediums/webrtc/webrtc.h @@ -23,8 +23,8 @@ #include "absl/strings/string_view.h" #include "internal/platform/byte_array.h" #include "internal/platform/feature_flags.h" -#include "internal/platform/implementation/platform.h" #include "internal/platform/implementation/webrtc.h" +#include "internal/platform/implementation/webrtc_platform.h" #include "webrtc/api/peer_connection_interface.h" #include "webrtc/rtc_base/network_constants.h" @@ -66,7 +66,8 @@ class WebRtcSignalingMessenger { class WebRtcMedium { public: - WebRtcMedium() : impl_(api::ImplementationPlatform::CreateWebRtcMedium()) {} + WebRtcMedium() + : impl_(api::WebRtcImplementationPlatform::CreateWebRtcMedium()) {} virtual ~WebRtcMedium() = default; WebRtcMedium(WebRtcMedium&&) = default; WebRtcMedium& operator=(WebRtcMedium&&) = delete; @@ -75,9 +76,7 @@ class WebRtcMedium { // For example, en_US locale resolves to "US". std::string GetDefaultCountryCode() { return impl_->GetDefaultCountryCode(); } - void SetNonCellular(bool non_cellular) { - non_cellular_ = non_cellular; - } + void SetNonCellular(bool non_cellular) { non_cellular_ = non_cellular; } // Creates and returns a new webrtc::PeerConnectionInterface object via // |callback|. @@ -86,7 +85,8 @@ class WebRtcMedium { api::WebRtcMedium::PeerConnectionCallback callback) { if (FeatureFlags::GetInstance() .GetFlags() - .support_web_rtc_non_cellular_medium && non_cellular_) { + .support_web_rtc_non_cellular_medium && + non_cellular_) { std::optional options; options->network_ignore_mask |= webrtc::ADAPTER_TYPE_CELLULAR; impl_->CreatePeerConnection(options, observer, std::move(callback)); diff --git a/internal/platform/BUILD b/internal/platform/BUILD index e293cc42..76beadde 100644 --- a/internal/platform/BUILD +++ b/internal/platform/BUILD @@ -299,7 +299,7 @@ cc_library( ":logging", ":types", "//internal/account", - "//internal/platform/implementation:comm", + "//internal/platform/implementation:webrtc_platform", "//internal/proto:messaging_cc_grpc_proto", "//internal/proto:tachyon_cc_proto", "//internal/rpc:utils", @@ -411,6 +411,7 @@ cc_library( ":uuid", "//internal/base", "//internal/platform/implementation:comm", + "//internal/platform/implementation:webrtc_platform", "//internal/platform/implementation:wifi_utils", "//internal/test", "@com_google_absl//absl/base:core_headers", diff --git a/internal/platform/implementation/BUILD b/internal/platform/implementation/BUILD index d6188d88..65ed9747 100644 --- a/internal/platform/implementation/BUILD +++ b/internal/platform/implementation/BUILD @@ -90,6 +90,7 @@ cc_library( cc_library( name = "webrtc_platform", hdrs = [ + "webrtc.h", "webrtc_platform.h", ], compatible_with = ["//buildenv/target:non_prod"], @@ -97,7 +98,6 @@ cc_library( "//:__subpackages__", ], deps = [ - ":comm", "//connections/implementation/proto:offline_wire_formats_cc_proto", "//internal/platform:base", # "//third_party/webrtc/files/stable/webrtc/api:libjingle_peerconnection_api", @@ -120,7 +120,6 @@ cc_library( "http_loader.h", "psk_info.h", "upgrade_address_info.h", - "webrtc.h", "wifi.h", "wifi_direct.h", "wifi_hotspot.h", @@ -136,15 +135,12 @@ cc_library( "//third_party/nearby/presence/implementation:__subpackages__", ], deps = [ - "//connections/implementation/proto:offline_wire_formats_cc_proto", "//internal/platform:base", "//internal/platform:cancellation_flag", "//internal/platform:mac_address", "//internal/platform:uuid", "//internal/proto:credential_cc_proto", "//internal/proto:local_credential_cc_proto", - # "//third_party/webrtc/files/stable/webrtc/api:create_peerconnection_factory", # buildcleaner: keep - # "//third_party/webrtc/files/stable/webrtc/api:peer_connection_interface", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/functional:any_invocable", diff --git a/internal/platform/implementation/apple/BUILD b/internal/platform/implementation/apple/BUILD index 6e4b01d9..7c48f36b 100644 --- a/internal/platform/implementation/apple/BUILD +++ b/internal/platform/implementation/apple/BUILD @@ -54,11 +54,24 @@ objc_library( objc_library( name = "apple_webrtc", srcs = [ + "webrtc.mm", "webrtc_platform.mm", ], + hdrs = [ + "webrtc.h", + ], deps = [ - ":apple", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "//third_party/apple_frameworks:Foundation", + "//internal/platform:logging", + "//internal/platform:tachyon_express_signaling_messenger", + "//internal/platform:types", "//internal/platform/implementation:webrtc_platform", + "//internal/proto:tachyon_cc_proto", + # "//third_party/webrtc/files/stable/webrtc/api:create_modular_peer_connection_factory", + # "//third_party/webrtc/files/stable/webrtc/api:peer_connection_interface", + "//third_party/webrtc/files/stable/webrtc/api/task_queue:default_task_queue_factory", ], ) @@ -72,7 +85,6 @@ objc_library( "preferences_manager.mm", "scheduled_executor.mm", "timer.mm", - "webrtc.mm", "wifi_hotspot.mm", "wifi_lan.mm", ], @@ -81,7 +93,6 @@ objc_library( "device_info.h", "preferences_manager.h", "timer.h", - "webrtc.h", "wifi.h", "wifi_hotspot.h", "wifi_lan.h", @@ -122,10 +133,6 @@ objc_library( "//internal/platform:tachyon_express_signaling_messenger", "//internal/platform:types", "//internal/proto:tachyon_cc_proto", - "//third_party/webrtc/files/stable/webrtc/api/task_queue:default_task_queue_factory", - # "//third_party/webrtc/files/stable/webrtc/api:create_modular_peer_connection_factory", - # "//third_party/webrtc/files/stable/webrtc/api:peer_connection_interface", - "//third_party/webrtc/files/stable/webrtc/rtc_base:checks", "//internal/platform:base", "//internal/platform/implementation:comm", "//internal/platform/implementation:platform", diff --git a/internal/platform/implementation/g3/BUILD b/internal/platform/implementation/g3/BUILD index 4fee0569..b50a8ea8 100644 --- a/internal/platform/implementation/g3/BUILD +++ b/internal/platform/implementation/g3/BUILD @@ -112,6 +112,7 @@ cc_library( "//internal/platform:types", "//internal/platform:uuid", "//internal/platform/implementation:comm", + "//internal/platform/implementation:webrtc_platform", "//internal/platform/implementation:wifi_utils", "//internal/proto:credential_cc_proto", # "//third_party/webrtc/files/stable/webrtc/api:create_modular_peer_connection_factory", @@ -177,6 +178,7 @@ cc_library( testonly = True, srcs = [ "platform.cc", + "webrtc_platform.cc", ], defines = ["NO_WEBRTC"], visibility = [ @@ -208,14 +210,16 @@ cc_library( "//internal/platform/implementation:comm", "//internal/platform/implementation:platform", "//internal/platform/implementation:types", + "//internal/platform/implementation:webrtc_platform", "//internal/platform/implementation/shared:count_down_latch", "//internal/platform/implementation/shared:file", + "//third_party/gloop/thread", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", - "@com_google_nisaba//nisaba/port:thread_pool", ], + alwayslink = 1, ) cc_library( diff --git a/internal/platform/implementation/g3/platform.cc b/internal/platform/implementation/g3/platform.cc index 02c5afda..dfa62fae 100644 --- a/internal/platform/implementation/g3/platform.cc +++ b/internal/platform/implementation/g3/platform.cc @@ -14,7 +14,6 @@ #include "internal/platform/implementation/platform.h" -#include #include #include #include @@ -25,6 +24,7 @@ #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" +#include "third_party/gloop/thread/thread.h" #include "internal/base/file_path.h" #include "internal/base/files.h" #include "internal/platform/implementation/app_lifecycle_monitor.h" @@ -55,11 +55,6 @@ #include "internal/platform/logging.h" #include "internal/platform/os_name.h" #include "internal/platform/payload_id.h" -#include "thread/thread.h" -#ifndef NO_WEBRTC -#include "internal/platform/implementation/g3/webrtc.h" -#include "internal/platform/implementation/webrtc.h" -#endif #include "internal/platform/implementation/g3/atomic_boolean.h" #include "internal/platform/implementation/g3/atomic_reference.h" #include "internal/platform/implementation/g3/ble.h" @@ -80,7 +75,6 @@ #include "internal/platform/implementation/g3/wifi_lan.h" #include "internal/platform/implementation/shared/file.h" #include "internal/platform/implementation/wifi.h" -#include "internal/platform/medium_environment.h" namespace nearby { namespace api { @@ -219,16 +213,6 @@ ImplementationPlatform::CreateWifiDirectMedium() { return std::make_unique(); } -#ifndef NO_WEBRTC -std::unique_ptr ImplementationPlatform::CreateWebRtcMedium() { - if (MediumEnvironment::Instance().GetEnvironmentConfig().webrtc_enabled) { - return std::make_unique(); - } else { - return nullptr; - } -} -#endif - std::unique_ptr ImplementationPlatform::CreateAppLifecycleMonitor( std::function diff --git a/internal/platform/implementation/g3/webrtc_platform.cc b/internal/platform/implementation/g3/webrtc_platform.cc new file mode 100644 index 00000000..5c42f5ee --- /dev/null +++ b/internal/platform/implementation/g3/webrtc_platform.cc @@ -0,0 +1,34 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/platform/implementation/webrtc_platform.h" + +#include + +#include "internal/platform/implementation/g3/webrtc.h" +#include "internal/platform/implementation/webrtc.h" +#include "internal/platform/medium_environment.h" + +namespace nearby::api { + +std::unique_ptr +WebRtcImplementationPlatform::CreateWebRtcMedium() { + if (MediumEnvironment::Instance().GetEnvironmentConfig().webrtc_enabled) { + return std::make_unique(); + } else { + return nullptr; + } +} + +} // namespace nearby::api diff --git a/internal/platform/implementation/platform.h b/internal/platform/implementation/platform.h index 8cce972e..44ee1851 100644 --- a/internal/platform/implementation/platform.h +++ b/internal/platform/implementation/platform.h @@ -43,9 +43,6 @@ #include "internal/platform/implementation/scheduled_executor.h" #include "internal/platform/implementation/submittable_executor.h" #include "internal/platform/implementation/timer.h" -#ifndef NO_WEBRTC -#include "internal/platform/implementation/webrtc.h" -#endif #include "internal/platform/implementation/wifi.h" #include "internal/platform/implementation/wifi_direct.h" #include "internal/platform/implementation/wifi_hotspot.h" @@ -134,9 +131,6 @@ class ImplementationPlatform { static std::unique_ptr CreateWifiHotspotMedium(); static std::unique_ptr CreateWifiDirectMedium(); static std::unique_ptr CreateTimer(); -#ifndef NO_WEBRTC - static std::unique_ptr CreateWebRtcMedium(); -#endif #if defined(NEARBY_CHROMIUM) static std::unique_ptr CreateAppLifecycleMonitor( diff --git a/internal/platform/implementation/webrtc.h b/internal/platform/implementation/webrtc.h index 57bd14d7..c9022e28 100644 --- a/internal/platform/implementation/webrtc.h +++ b/internal/platform/implementation/webrtc.h @@ -15,8 +15,6 @@ #ifndef PLATFORM_API_WEBRTC_H_ #define PLATFORM_API_WEBRTC_H_ -#ifndef NO_WEBRTC - #include #include #include @@ -26,6 +24,7 @@ #include "connections/implementation/proto/offline_wire_formats.pb.h" #include "internal/platform/byte_array.h" #include "webrtc/api/peer_connection_interface.h" +#include "webrtc/api/scoped_refptr.h" namespace nearby { namespace api { @@ -78,6 +77,4 @@ class WebRtcMedium { } // namespace api } // namespace nearby -#endif - #endif // PLATFORM_API_WEBRTC_H_ diff --git a/internal/platform/implementation/windows/BUILD b/internal/platform/implementation/windows/BUILD index 077a83b7..7cc639f6 100644 --- a/internal/platform/implementation/windows/BUILD +++ b/internal/platform/implementation/windows/BUILD @@ -321,6 +321,9 @@ cc_library( "-DNO_INTEL_PIE", "-D_WIN32_WINNT=_WIN32_WINNT_WIN10 -DWINVER=_WIN32_WINNT_WIN10", ], + linkopts = [ + "iphlpapi.lib", + ], tags = ["windows"], visibility = [ "//chrome/chromeos/assistant/data_migration/lib:__pkg__", diff --git a/internal/platform/implementation/windows/platform.cc b/internal/platform/implementation/windows/platform.cc index 4d896be9..20004c26 100644 --- a/internal/platform/implementation/windows/platform.cc +++ b/internal/platform/implementation/windows/platform.cc @@ -259,10 +259,6 @@ ImplementationPlatform::CreateWifiDirectMedium() { return std::make_unique(); } -std::unique_ptr ImplementationPlatform::CreateWebRtcMedium() { - return nullptr; -} - std::unique_ptr ImplementationPlatform::CreateAppLifecycleMonitor( std::function diff --git a/internal/platform/medium_environment.cc b/internal/platform/medium_environment.cc index 3f1617b0..b0e9b98c 100644 --- a/internal/platform/medium_environment.cc +++ b/internal/platform/medium_environment.cc @@ -103,10 +103,8 @@ void MediumEnvironment::Reset() { bluetooth_adapters_.clear(); bluetooth_mediums_.clear(); ble_mediums_.clear(); -#ifndef NO_WEBRTC webrtc_signaling_message_callback_.clear(); webrtc_signaling_complete_callback_.clear(); -#endif wifi_lan_mediums_.clear(); awdl_mediums_.clear(); { @@ -675,7 +673,6 @@ MediumEnvironment::GetBleMediumStatus(const api::ble::BleMedium& medium) { return result; } -#ifndef NO_WEBRTC void MediumEnvironment::RegisterWebRtcSignalingMessenger( absl::string_view self_id, OnSignalingMessageCallback message_callback, OnSignalingCompleteCallback complete_callback) { @@ -733,7 +730,7 @@ void MediumEnvironment::SendWebRtcSignalingComplete(absl::string_view peer_id, item->second(success); }); } -#endif + void MediumEnvironment::SetUseValidPeerConnection( bool use_valid_peer_connection) { use_valid_peer_connection_ = use_valid_peer_connection; diff --git a/internal/platform/medium_environment.h b/internal/platform/medium_environment.h index 3a345a5a..8a4d7e14 100644 --- a/internal/platform/medium_environment.h +++ b/internal/platform/medium_environment.h @@ -37,9 +37,7 @@ #include "internal/platform/runnable.h" #include "internal/platform/uuid.h" #include "internal/test/fake_clock.h" -#ifndef NO_WEBRTC #include "internal/platform/implementation/webrtc.h" -#endif #include "internal/platform/byte_array.h" #include "internal/platform/feature_flags.h" #include "internal/platform/implementation/wifi_direct.h" @@ -80,12 +78,10 @@ class MediumEnvironment { using BluetoothDiscoveryCallback = api::BluetoothClassicMedium::DiscoveryCallback; using BleScanCallback = api::ble::BleMedium::ScanningCallback; -#ifndef NO_WEBRTC using OnSignalingMessageCallback = api::WebRtcSignalingMessenger::OnSignalingMessageCallback; using OnSignalingCompleteCallback = api::WebRtcSignalingMessenger::OnSignalingCompleteCallback; -#endif using WifiLanDiscoveredServiceCallback = api::WifiLanMedium::DiscoveredServiceCallback; using AwdlDiscoveredServiceCallback = @@ -164,7 +160,6 @@ class MediumEnvironment { api::BluetoothDevice* FindBluetoothDevice(MacAddress mac_address); EnvironmentConfig GetEnvironmentConfig(); -#ifndef NO_WEBRTC // Registers |message_callback| to receive messages sent to device with id // |self_id|, and |complete_callback| to notify when signaling is complete. void RegisterWebRtcSignalingMessenger( @@ -181,7 +176,6 @@ class MediumEnvironment { // Simulates sending an "signaling complete" signal to the WebRTC medium. void SendWebRtcSignalingComplete(absl::string_view peer_id, bool success); -#endif // Used to set if WebRtcMedium should use a valid peer connection or nullptr // in tests. void SetUseValidPeerConnection(bool use_valid_peer_connection); @@ -497,7 +491,6 @@ class MediumEnvironment { absl::flat_hash_map ble_mediums_; absl::flat_hash_map devices_pairing_contexts_; -#ifndef NO_WEBRTC // Maps peer id to callback for receiving signaling messages. absl::flat_hash_map webrtc_signaling_message_callback_; @@ -505,7 +498,6 @@ class MediumEnvironment { // Maps peer id to callback for signaling complete events. absl::flat_hash_map webrtc_signaling_complete_callback_; -#endif absl::flat_hash_map wifi_lan_mediums_;