Create separate WebRtc Platform.

PiperOrigin-RevId: 919283950
This commit is contained in:
Francis Tsui
2026-05-21 15:26:28 -07:00
committed by Copybara-Service
parent 765bd555e4
commit 5df1af7c61
14 changed files with 69 additions and 65 deletions
+1 -5
View File
@@ -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",
+14 -7
View File
@@ -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",
+5 -1
View File
@@ -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(
@@ -14,7 +14,6 @@
#include "internal/platform/implementation/platform.h"
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
@@ -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<g3::WifiDirectMedium>();
}
#ifndef NO_WEBRTC
std::unique_ptr<WebRtcMedium> ImplementationPlatform::CreateWebRtcMedium() {
if (MediumEnvironment::Instance().GetEnvironmentConfig().webrtc_enabled) {
return std::make_unique<g3::WebRtcMedium>();
} else {
return nullptr;
}
}
#endif
std::unique_ptr<AppLifecycleMonitor>
ImplementationPlatform::CreateAppLifecycleMonitor(
std::function<void(AppLifecycleMonitor::AppLifecycleState)>
@@ -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 <memory>
#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<WebRtcMedium>
WebRtcImplementationPlatform::CreateWebRtcMedium() {
if (MediumEnvironment::Instance().GetEnvironmentConfig().webrtc_enabled) {
return std::make_unique<g3::WebRtcMedium>();
} else {
return nullptr;
}
}
} // namespace nearby::api
@@ -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<WifiHotspotMedium> CreateWifiHotspotMedium();
static std::unique_ptr<WifiDirectMedium> CreateWifiDirectMedium();
static std::unique_ptr<Timer> CreateTimer();
#ifndef NO_WEBRTC
static std::unique_ptr<WebRtcMedium> CreateWebRtcMedium();
#endif
#if defined(NEARBY_CHROMIUM)
static std::unique_ptr<AppLifecycleMonitor> CreateAppLifecycleMonitor(
+1 -4
View File
@@ -15,8 +15,6 @@
#ifndef PLATFORM_API_WEBRTC_H_
#define PLATFORM_API_WEBRTC_H_
#ifndef NO_WEBRTC
#include <memory>
#include <optional>
#include <string>
@@ -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_
@@ -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__",
@@ -259,10 +259,6 @@ ImplementationPlatform::CreateWifiDirectMedium() {
return std::make_unique<windows::WifiDirectMedium>();
}
std::unique_ptr<WebRtcMedium> ImplementationPlatform::CreateWebRtcMedium() {
return nullptr;
}
std::unique_ptr<AppLifecycleMonitor>
ImplementationPlatform::CreateAppLifecycleMonitor(
std::function<void(AppLifecycleMonitor::AppLifecycleState)>