mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Internal change
PiperOrigin-RevId: 365062363
This commit is contained in:
@@ -511,6 +511,15 @@ bool MediumEnvironment::GetUseValidPeerConnection() {
|
||||
return use_valid_peer_connection_;
|
||||
}
|
||||
|
||||
void MediumEnvironment::SetPeerConnectionLatency(
|
||||
absl::Duration peer_connection_latency) {
|
||||
peer_connection_latency_ = peer_connection_latency;
|
||||
}
|
||||
|
||||
absl::Duration MediumEnvironment::GetPeerConnectionLatency() {
|
||||
return peer_connection_latency_;
|
||||
}
|
||||
|
||||
void MediumEnvironment::RegisterWifiLanMedium(api::WifiLanMedium& medium) {
|
||||
if (!enabled_) return;
|
||||
RunOnMediumEnvironmentThread([this, &medium]() {
|
||||
|
||||
@@ -153,6 +153,11 @@ class MediumEnvironment {
|
||||
|
||||
bool GetUseValidPeerConnection();
|
||||
|
||||
// Used to set latency when creating the peer connection in tests.
|
||||
void SetPeerConnectionLatency(absl::Duration peer_connection_latency);
|
||||
|
||||
absl::Duration GetPeerConnectionLatency();
|
||||
|
||||
// Adds medium-related info to allow for scanning/advertising to work.
|
||||
// This provides acccess to this medium from other mediums, when protocol
|
||||
// expects they should communicate.
|
||||
@@ -319,6 +324,7 @@ class MediumEnvironment {
|
||||
wifi_lan_mediums_;
|
||||
|
||||
bool use_valid_peer_connection_ = true;
|
||||
absl::Duration peer_connection_latency_ = absl::ZeroDuration();
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -48,6 +48,8 @@ void WebRtcSignalingMessenger::StopReceivingMessages() {
|
||||
env.UnregisterWebRtcSignalingMessenger(self_id_);
|
||||
}
|
||||
|
||||
WebRtcMedium::~WebRtcMedium() { single_thread_executor_.Shutdown(); }
|
||||
|
||||
const std::string WebRtcMedium::GetDefaultCountryCode() {
|
||||
return "US";
|
||||
}
|
||||
@@ -72,9 +74,17 @@ void WebRtcMedium::CreatePeerConnection(
|
||||
webrtc::CreateDefaultTaskQueueFactory();
|
||||
factory_dependencies.signaling_thread = signaling_thread.release();
|
||||
|
||||
callback(webrtc::CreateModularPeerConnectionFactory(
|
||||
std::move(factory_dependencies))
|
||||
->CreatePeerConnection(rtc_config, std::move(dependencies)));
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection =
|
||||
webrtc::CreateModularPeerConnectionFactory(
|
||||
std::move(factory_dependencies))
|
||||
->CreatePeerConnection(rtc_config, std::move(dependencies));
|
||||
|
||||
single_thread_executor_.Execute(
|
||||
[&env, callback = std::move(callback),
|
||||
peer_connection = std::move(peer_connection)]() {
|
||||
absl::SleepFor(env.GetPeerConnectionLatency());
|
||||
callback(peer_connection);
|
||||
});
|
||||
}
|
||||
|
||||
std::unique_ptr<api::WebRtcSignalingMessenger>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "platform/api/webrtc.h"
|
||||
#include "platform/impl/g3/single_thread_executor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "webrtc/api/peer_connection_interface.h"
|
||||
|
||||
@@ -54,7 +55,7 @@ class WebRtcMedium : public api::WebRtcMedium {
|
||||
using PeerConnectionCallback = api::WebRtcMedium::PeerConnectionCallback;
|
||||
|
||||
WebRtcMedium() = default;
|
||||
~WebRtcMedium() override = default;
|
||||
~WebRtcMedium() override;
|
||||
|
||||
const std::string GetDefaultCountryCode() override;
|
||||
|
||||
@@ -69,6 +70,8 @@ class WebRtcMedium : public api::WebRtcMedium {
|
||||
const connections::LocationHint& location_hint) override;
|
||||
|
||||
private:
|
||||
// Executor for handling calls to create a peer connection.
|
||||
SingleThreadExecutor single_thread_executor_;
|
||||
};
|
||||
|
||||
} // namespace g3
|
||||
|
||||
Reference in New Issue
Block a user