mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Support NO_WEBRTC in platform/* except WINDOWS.
PiperOrigin-RevId: 427067819
This commit is contained in:
committed by
Copybara-Service
parent
3c9565a923
commit
bdce5dd2be
@@ -33,9 +33,10 @@
|
||||
#include "internal/platform/implementation/scheduled_executor.h"
|
||||
#include "internal/platform/implementation/server_sync.h"
|
||||
#include "internal/platform/implementation/submittable_executor.h"
|
||||
#ifndef NO_WEBRTC
|
||||
#include "internal/platform/implementation/g3/webrtc.h"
|
||||
#include "internal/platform/implementation/webrtc.h"
|
||||
#include "internal/platform/implementation/wifi.h"
|
||||
#include "internal/platform/medium_environment.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"
|
||||
@@ -47,9 +48,10 @@
|
||||
#include "internal/platform/implementation/g3/mutex.h"
|
||||
#include "internal/platform/implementation/g3/scheduled_executor.h"
|
||||
#include "internal/platform/implementation/g3/single_thread_executor.h"
|
||||
#include "internal/platform/implementation/g3/webrtc.h"
|
||||
#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 location {
|
||||
namespace nearby {
|
||||
@@ -146,6 +148,7 @@ std::unique_ptr<WifiLanMedium> ImplementationPlatform::CreateWifiLanMedium() {
|
||||
return absl::make_unique<g3::WifiLanMedium>();
|
||||
}
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
std::unique_ptr<WebRtcMedium> ImplementationPlatform::CreateWebRtcMedium() {
|
||||
if (MediumEnvironment::Instance().GetEnvironmentConfig().webrtc_enabled) {
|
||||
return absl::make_unique<g3::WebRtcMedium>();
|
||||
@@ -153,6 +156,7 @@ std::unique_ptr<WebRtcMedium> ImplementationPlatform::CreateWebRtcMedium() {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
std::unique_ptr<Mutex> ImplementationPlatform::CreateMutex(Mutex::Mode mode) {
|
||||
if (mode == Mutex::Mode::kRecursive)
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
#include "internal/platform/implementation/settable_future.h"
|
||||
#include "internal/platform/implementation/submittable_executor.h"
|
||||
#include "internal/platform/implementation/system_clock.h"
|
||||
#ifndef NO_WEBRTC
|
||||
#include "internal/platform/implementation/webrtc.h"
|
||||
#endif
|
||||
#include "internal/platform/implementation/wifi.h"
|
||||
#include "internal/platform/implementation/wifi_lan.h"
|
||||
#include "internal/platform/payload_id.h"
|
||||
@@ -101,7 +103,9 @@ class ImplementationPlatform {
|
||||
static std::unique_ptr<ServerSyncMedium> CreateServerSyncMedium();
|
||||
static std::unique_ptr<WifiMedium> CreateWifiMedium();
|
||||
static std::unique_ptr<WifiLanMedium> CreateWifiLanMedium();
|
||||
#ifndef NO_WEBRTC
|
||||
static std::unique_ptr<WebRtcMedium> CreateWebRtcMedium();
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -59,8 +59,10 @@ 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();
|
||||
use_valid_peer_connection_ = true;
|
||||
peer_connection_latency_ = absl::ZeroDuration();
|
||||
@@ -475,7 +477,7 @@ void MediumEnvironment::CallBleAcceptedConnectionCallback(
|
||||
info.accepted_connection_callback.accepted_cb(socket, service_id);
|
||||
});
|
||||
}
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
void MediumEnvironment::RegisterWebRtcSignalingMessenger(
|
||||
absl::string_view self_id, OnSignalingMessageCallback message_callback,
|
||||
OnSignalingCompleteCallback complete_callback) {
|
||||
@@ -535,7 +537,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;
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
#include "internal/platform/implementation/ble.h"
|
||||
#include "internal/platform/implementation/bluetooth_adapter.h"
|
||||
#include "internal/platform/implementation/bluetooth_classic.h"
|
||||
#ifndef NO_WEBRTC
|
||||
#include "internal/platform/implementation/webrtc.h"
|
||||
#endif
|
||||
#include "internal/platform/implementation/wifi_lan.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/feature_flags.h"
|
||||
@@ -56,10 +58,12 @@ class MediumEnvironment {
|
||||
api::BleMedium::DiscoveredPeripheralCallback;
|
||||
using BleAcceptedConnectionCallback =
|
||||
api::BleMedium::AcceptedConnectionCallback;
|
||||
#ifndef NO_WEBRTC
|
||||
using OnSignalingMessageCallback =
|
||||
api::WebRtcSignalingMessenger::OnSignalingMessageCallback;
|
||||
using OnSignalingCompleteCallback =
|
||||
api::WebRtcSignalingMessenger::OnSignalingCompleteCallback;
|
||||
#endif
|
||||
using WifiLanDiscoveredServiceCallback =
|
||||
api::WifiLanMedium::DiscoveredServiceCallback;
|
||||
|
||||
@@ -130,7 +134,7 @@ class MediumEnvironment {
|
||||
api::BluetoothDevice* FindBluetoothDevice(const std::string& mac_address);
|
||||
|
||||
const 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(
|
||||
@@ -147,7 +151,7 @@ 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);
|
||||
@@ -299,7 +303,7 @@ class MediumEnvironment {
|
||||
bluetooth_mediums_;
|
||||
|
||||
absl::flat_hash_map<api::BleMedium*, BleMediumContext> ble_mediums_;
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
// Maps peer id to callback for receiving signaling messages.
|
||||
absl::flat_hash_map<std::string, OnSignalingMessageCallback>
|
||||
webrtc_signaling_message_callback_;
|
||||
@@ -307,7 +311,7 @@ class MediumEnvironment {
|
||||
// Maps peer id to callback for signaling complete events.
|
||||
absl::flat_hash_map<std::string, OnSignalingCompleteCallback>
|
||||
webrtc_signaling_complete_callback_;
|
||||
|
||||
#endif
|
||||
absl::flat_hash_map<api::WifiLanMedium*, WifiLanMediumContext>
|
||||
wifi_lan_mediums_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user