зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1766646 - Vendor libwebrtc from c06fe8b04e
Upstream commit: https://webrtc.googlesource.com/src/+/c06fe8b04eab3b272d66f78d9bccbcfdd3d621ae WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 11/inf convert rtc_base/network and collateral. This also remove last usage of system_wrappers/field_trials in p2p/...Yay! Bug: webrtc:10335 Change-Id: Ie8507b1f52bf7f3067e9b4bf8c81a825e4644fda Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256640 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Jonas Oreland <jonaso@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36357}
This commit is contained in:
Родитель
1f08eae644
Коммит
fe2d5434a6
|
@ -12609,3 +12609,6 @@ e5a73f5b88
|
|||
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src MOZ_LIBWEBRTC_COMMIT=mjfdev bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
|
||||
# base of lastest vendoring
|
||||
342c511007
|
||||
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src MOZ_LIBWEBRTC_COMMIT=mjfdev bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
|
||||
# base of lastest vendoring
|
||||
c06fe8b04e
|
||||
|
|
|
@ -8418,3 +8418,5 @@ libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwe
|
|||
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-07-12T22:05:21.332987.
|
||||
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src --commit mjfdev libwebrtc
|
||||
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-07-12T22:06:25.177098.
|
||||
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src --commit mjfdev libwebrtc
|
||||
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-07-12T22:07:03.874881.
|
||||
|
|
|
@ -918,6 +918,7 @@ if (!build_with_chromium) {
|
|||
"../rtc_base:rtc_base_approved",
|
||||
"../rtc_base:socket_address",
|
||||
"../rtc_base:threading",
|
||||
"../test:scoped_key_value_config",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
]
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "rtc_base/ssl_adapter.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
using stunprober::AsyncCallback;
|
||||
using stunprober::StunProber;
|
||||
|
@ -123,12 +124,13 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
rtc::InitializeSSL();
|
||||
rtc::InitRandom(rtc::Time32());
|
||||
webrtc::test::ScopedKeyValueConfig field_trials;
|
||||
rtc::PhysicalSocketServer socket_server;
|
||||
rtc::AutoSocketServerThread thread(&socket_server);
|
||||
auto socket_factory =
|
||||
std::make_unique<rtc::BasicPacketSocketFactory>(&socket_server);
|
||||
std::unique_ptr<rtc::BasicNetworkManager> network_manager(
|
||||
new rtc::BasicNetworkManager(&socket_server));
|
||||
new rtc::BasicNetworkManager(&socket_server, &field_trials));
|
||||
rtc::NetworkManager::NetworkList networks;
|
||||
network_manager->GetNetworks(&networks);
|
||||
auto prober = std::make_unique<StunProber>(socket_factory.get(),
|
||||
|
|
|
@ -115,6 +115,7 @@ rtc_library("rtc_p2p") {
|
|||
"../rtc_base:threading",
|
||||
"../rtc_base/containers:flat_map",
|
||||
"../rtc_base/experiments:field_trial_parser",
|
||||
"../rtc_base/memory:always_valid_pointer",
|
||||
"../rtc_base/system:no_unique_address",
|
||||
|
||||
# Needed by pseudo_tcp, which should move to a separate target.
|
||||
|
@ -127,7 +128,6 @@ rtc_library("rtc_p2p") {
|
|||
"../rtc_base/task_utils:to_queued_task",
|
||||
"../rtc_base/third_party/base64",
|
||||
"../rtc_base/third_party/sigslot",
|
||||
"../system_wrappers:field_trial",
|
||||
"../system_wrappers:metrics",
|
||||
]
|
||||
absl_deps = [
|
||||
|
@ -166,6 +166,7 @@ if (rtc_include_tests) {
|
|||
"../rtc_base",
|
||||
"../rtc_base:net_helpers",
|
||||
"../rtc_base:threading",
|
||||
"../test:scoped_key_value_config",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -260,7 +261,6 @@ if (rtc_include_tests) {
|
|||
"../rtc_base/network:sent_packet",
|
||||
"../rtc_base/third_party/sigslot",
|
||||
"../system_wrappers:metrics",
|
||||
"../test:field_trial",
|
||||
"../test:rtc_expect_death",
|
||||
"../test:scoped_key_value_config",
|
||||
"../test:test_support",
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "p2p/base/udp_port.h"
|
||||
#include "rtc_base/net_helpers.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
namespace rtc {
|
||||
class SocketFactory;
|
||||
|
@ -36,10 +37,11 @@ class TestUDPPort : public UDPPort {
|
|||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool emit_localhost_for_anyaddress) {
|
||||
bool emit_localhost_for_anyaddress,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials) {
|
||||
TestUDPPort* port =
|
||||
new TestUDPPort(thread, factory, network, min_port, max_port, username,
|
||||
password, emit_localhost_for_anyaddress);
|
||||
password, emit_localhost_for_anyaddress, field_trials);
|
||||
if (!port->Init()) {
|
||||
delete port;
|
||||
port = nullptr;
|
||||
|
@ -55,7 +57,8 @@ class TestUDPPort : public UDPPort {
|
|||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool emit_localhost_for_anyaddress)
|
||||
bool emit_localhost_for_anyaddress,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: UDPPort(thread,
|
||||
factory,
|
||||
network,
|
||||
|
@ -63,7 +66,8 @@ class TestUDPPort : public UDPPort {
|
|||
max_port,
|
||||
username,
|
||||
password,
|
||||
emit_localhost_for_anyaddress) {}
|
||||
emit_localhost_for_anyaddress,
|
||||
field_trials) {}
|
||||
};
|
||||
|
||||
// A FakePortAllocatorSession can be used with either a real or fake socket
|
||||
|
@ -77,7 +81,8 @@ class FakePortAllocatorSession : public PortAllocatorSession {
|
|||
const std::string& content_name,
|
||||
int component,
|
||||
const std::string& ice_ufrag,
|
||||
const std::string& ice_pwd)
|
||||
const std::string& ice_pwd,
|
||||
const webrtc::WebRtcKeyValueConfig& field_trials)
|
||||
: PortAllocatorSession(content_name,
|
||||
component,
|
||||
ice_ufrag,
|
||||
|
@ -96,7 +101,8 @@ class FakePortAllocatorSession : public PortAllocatorSession {
|
|||
port_(),
|
||||
port_config_count_(0),
|
||||
stun_servers_(allocator->stun_servers()),
|
||||
turn_servers_(allocator->turn_servers()) {
|
||||
turn_servers_(allocator->turn_servers()),
|
||||
field_trials_(field_trials) {
|
||||
ipv4_network_.AddIP(rtc::IPAddress(INADDR_LOOPBACK));
|
||||
ipv6_network_.AddIP(rtc::IPAddress(in6addr_loopback));
|
||||
}
|
||||
|
@ -112,7 +118,8 @@ class FakePortAllocatorSession : public PortAllocatorSession {
|
|||
? ipv6_network_
|
||||
: ipv4_network_;
|
||||
port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, 0, 0,
|
||||
username(), password(), false));
|
||||
username(), password(), false,
|
||||
&field_trials_));
|
||||
RTC_DCHECK(port_);
|
||||
port_->SubscribePortDestroyed(
|
||||
[this](PortInterface* port) { OnPortDestroyed(port); });
|
||||
|
@ -200,6 +207,7 @@ class FakePortAllocatorSession : public PortAllocatorSession {
|
|||
uint32_t candidate_filter_ = CF_ALL;
|
||||
int transport_info_update_count_ = 0;
|
||||
bool running_ = false;
|
||||
const webrtc::WebRtcKeyValueConfig& field_trials_;
|
||||
};
|
||||
|
||||
class FakePortAllocator : public cricket::PortAllocator {
|
||||
|
@ -231,7 +239,7 @@ class FakePortAllocator : public cricket::PortAllocator {
|
|||
const std::string& ice_pwd) override {
|
||||
return new FakePortAllocatorSession(this, network_thread_, factory_,
|
||||
content_name, component, ice_ufrag,
|
||||
ice_pwd);
|
||||
ice_pwd, field_trials_);
|
||||
}
|
||||
|
||||
bool initialized() const { return initialized_; }
|
||||
|
@ -245,6 +253,7 @@ class FakePortAllocator : public cricket::PortAllocator {
|
|||
}
|
||||
|
||||
private:
|
||||
webrtc::test::ScopedKeyValueConfig field_trials_;
|
||||
rtc::Thread* network_thread_;
|
||||
rtc::PacketSocketFactory* factory_;
|
||||
std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_;
|
||||
|
|
|
@ -110,7 +110,8 @@ Port::Port(rtc::Thread* thread,
|
|||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
const std::string& username_fragment,
|
||||
const std::string& password)
|
||||
const std::string& password,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: thread_(thread),
|
||||
factory_(factory),
|
||||
type_(type),
|
||||
|
@ -127,7 +128,8 @@ Port::Port(rtc::Thread* thread,
|
|||
ice_role_(ICEROLE_UNKNOWN),
|
||||
tiebreaker_(0),
|
||||
shared_socket_(true),
|
||||
weak_factory_(this) {
|
||||
weak_factory_(this),
|
||||
field_trials_(field_trials) {
|
||||
RTC_DCHECK(factory_ != NULL);
|
||||
Construct();
|
||||
}
|
||||
|
@ -139,7 +141,8 @@ Port::Port(rtc::Thread* thread,
|
|||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username_fragment,
|
||||
const std::string& password)
|
||||
const std::string& password,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: thread_(thread),
|
||||
factory_(factory),
|
||||
type_(type),
|
||||
|
@ -156,7 +159,8 @@ Port::Port(rtc::Thread* thread,
|
|||
ice_role_(ICEROLE_UNKNOWN),
|
||||
tiebreaker_(0),
|
||||
shared_socket_(false),
|
||||
weak_factory_(this) {
|
||||
weak_factory_(this),
|
||||
field_trials_(field_trials) {
|
||||
RTC_DCHECK(factory_ != NULL);
|
||||
Construct();
|
||||
}
|
||||
|
@ -171,7 +175,7 @@ void Port::Construct() {
|
|||
password_ = rtc::CreateRandomString(ICE_PWD_LENGTH);
|
||||
}
|
||||
network_->SignalTypeChanged.connect(this, &Port::OnNetworkTypeChanged);
|
||||
network_cost_ = network_->GetCost();
|
||||
network_cost_ = network_->GetCost(*field_trials_);
|
||||
|
||||
thread_->PostDelayed(RTC_FROM_HERE, timeout_delay_, this,
|
||||
MSG_DESTROY_IF_DEAD);
|
||||
|
@ -880,7 +884,7 @@ std::string Port::ToString() const {
|
|||
|
||||
// TODO(honghaiz): Make the network cost configurable from user setting.
|
||||
void Port::UpdateNetworkCost() {
|
||||
uint16_t new_cost = network_->GetCost();
|
||||
uint16_t new_cost = network_->GetCost(*field_trials_);
|
||||
if (network_cost_ == new_cost) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
#include "api/candidate.h"
|
||||
#include "api/packet_socket_factory.h"
|
||||
#include "api/rtc_error.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/transport/stun.h"
|
||||
#include "api/webrtc_key_value_config.h"
|
||||
#include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h"
|
||||
#include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h"
|
||||
#include "logging/rtc_event_log/ice_logger.h"
|
||||
|
@ -35,6 +37,7 @@
|
|||
#include "rtc_base/async_packet_socket.h"
|
||||
#include "rtc_base/callback_list.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/memory/always_valid_pointer.h"
|
||||
#include "rtc_base/net_helper.h"
|
||||
#include "rtc_base/network.h"
|
||||
#include "rtc_base/proxy_info.h"
|
||||
|
@ -185,7 +188,8 @@ class Port : public PortInterface,
|
|||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
const std::string& username_fragment,
|
||||
const std::string& password);
|
||||
const std::string& password,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr);
|
||||
Port(rtc::Thread* thread,
|
||||
const std::string& type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
|
@ -193,7 +197,8 @@ class Port : public PortInterface,
|
|||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username_fragment,
|
||||
const std::string& password);
|
||||
const std::string& password,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr);
|
||||
~Port() override;
|
||||
|
||||
// Note that the port type does NOT uniquely identify different subclasses of
|
||||
|
@ -494,6 +499,9 @@ class Port : public PortInterface,
|
|||
MdnsNameRegistrationStatus::kNotStarted;
|
||||
|
||||
rtc::WeakPtrFactory<Port> weak_factory_;
|
||||
webrtc::AlwaysValidPointer<const webrtc::WebRtcKeyValueConfig,
|
||||
webrtc::FieldTrialBasedConfig>
|
||||
field_trials_;
|
||||
|
||||
bool MaybeObfuscateAddress(Candidate* c,
|
||||
const std::string& type,
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "rtc_base/time_utils.h"
|
||||
#include "rtc_base/virtual_socket_server.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
using rtc::AsyncListenSocket;
|
||||
using rtc::AsyncPacketSocket;
|
||||
|
@ -519,7 +520,8 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||
std::unique_ptr<UDPPort> CreateUdpPort(const SocketAddress& addr,
|
||||
PacketSocketFactory* socket_factory) {
|
||||
return UDPPort::Create(&main_, socket_factory, MakeNetwork(addr), 0, 0,
|
||||
username_, password_, true, absl::nullopt);
|
||||
username_, password_, true, absl::nullopt,
|
||||
&field_trials_);
|
||||
}
|
||||
std::unique_ptr<TCPPort> CreateTcpPort(const SocketAddress& addr) {
|
||||
return CreateTcpPort(addr, &socket_factory_);
|
||||
|
@ -527,14 +529,15 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||
std::unique_ptr<TCPPort> CreateTcpPort(const SocketAddress& addr,
|
||||
PacketSocketFactory* socket_factory) {
|
||||
return TCPPort::Create(&main_, socket_factory, MakeNetwork(addr), 0, 0,
|
||||
username_, password_, true);
|
||||
username_, password_, true, &field_trials_);
|
||||
}
|
||||
std::unique_ptr<StunPort> CreateStunPort(const SocketAddress& addr,
|
||||
rtc::PacketSocketFactory* factory) {
|
||||
ServerAddresses stun_servers;
|
||||
stun_servers.insert(kStunAddr);
|
||||
return StunPort::Create(&main_, factory, MakeNetwork(addr), 0, 0, username_,
|
||||
password_, stun_servers, absl::nullopt);
|
||||
password_, stun_servers, absl::nullopt,
|
||||
&field_trials_);
|
||||
}
|
||||
std::unique_ptr<Port> CreateRelayPort(const SocketAddress& addr,
|
||||
ProtocolType int_proto,
|
||||
|
@ -567,6 +570,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||
args.password = password_;
|
||||
args.server_address = &server_address;
|
||||
args.config = &config;
|
||||
args.field_trials = &field_trials_;
|
||||
|
||||
return TurnPort::Create(args, 0, 0);
|
||||
}
|
||||
|
@ -832,6 +836,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||
std::string password_;
|
||||
bool role_conflict_;
|
||||
int ports_destroyed_;
|
||||
webrtc::test::ScopedKeyValueConfig field_trials_;
|
||||
};
|
||||
|
||||
void PortTest::TestConnectivity(const char* name1,
|
||||
|
|
|
@ -157,8 +157,15 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
|||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool emit_local_for_anyaddress)
|
||||
: Port(thread, LOCAL_PORT_TYPE, factory, network, username, password),
|
||||
bool emit_local_for_anyaddress,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: Port(thread,
|
||||
LOCAL_PORT_TYPE,
|
||||
factory,
|
||||
network,
|
||||
username,
|
||||
password,
|
||||
field_trials),
|
||||
requests_(thread),
|
||||
socket_(socket),
|
||||
error_(0),
|
||||
|
@ -174,7 +181,8 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
|||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool emit_local_for_anyaddress)
|
||||
bool emit_local_for_anyaddress,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: Port(thread,
|
||||
LOCAL_PORT_TYPE,
|
||||
factory,
|
||||
|
@ -182,7 +190,8 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
|||
min_port,
|
||||
max_port,
|
||||
username,
|
||||
password),
|
||||
password,
|
||||
field_trials),
|
||||
requests_(thread),
|
||||
socket_(nullptr),
|
||||
error_(0),
|
||||
|
@ -605,11 +614,12 @@ std::unique_ptr<StunPort> StunPort::Create(
|
|||
const std::string& username,
|
||||
const std::string& password,
|
||||
const ServerAddresses& servers,
|
||||
absl::optional<int> stun_keepalive_interval) {
|
||||
absl::optional<int> stun_keepalive_interval,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials) {
|
||||
// Using `new` to access a non-public constructor.
|
||||
auto port =
|
||||
absl::WrapUnique(new StunPort(thread, factory, network, min_port,
|
||||
max_port, username, password, servers));
|
||||
auto port = absl::WrapUnique(new StunPort(thread, factory, network, min_port,
|
||||
max_port, username, password,
|
||||
servers, field_trials));
|
||||
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
||||
if (!port->Init()) {
|
||||
return nullptr;
|
||||
|
@ -624,7 +634,8 @@ StunPort::StunPort(rtc::Thread* thread,
|
|||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const ServerAddresses& servers)
|
||||
const ServerAddresses& servers,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: UDPPort(thread,
|
||||
factory,
|
||||
network,
|
||||
|
@ -632,7 +643,8 @@ StunPort::StunPort(rtc::Thread* thread,
|
|||
max_port,
|
||||
username,
|
||||
password,
|
||||
false) {
|
||||
false,
|
||||
field_trials) {
|
||||
// UDPPort will set these to local udp, updating these to STUN.
|
||||
set_type(STUN_PORT_TYPE);
|
||||
set_server_addresses(servers);
|
||||
|
|
|
@ -40,11 +40,12 @@ class UDPPort : public Port {
|
|||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool emit_local_for_anyaddress,
|
||||
absl::optional<int> stun_keepalive_interval) {
|
||||
absl::optional<int> stun_keepalive_interval,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) {
|
||||
// Using `new` to access a non-public constructor.
|
||||
auto port =
|
||||
absl::WrapUnique(new UDPPort(thread, factory, network, socket, username,
|
||||
password, emit_local_for_anyaddress));
|
||||
auto port = absl::WrapUnique(
|
||||
new UDPPort(thread, factory, network, socket, username, password,
|
||||
emit_local_for_anyaddress, field_trials));
|
||||
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
||||
if (!port->Init()) {
|
||||
return nullptr;
|
||||
|
@ -61,11 +62,12 @@ class UDPPort : public Port {
|
|||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool emit_local_for_anyaddress,
|
||||
absl::optional<int> stun_keepalive_interval) {
|
||||
absl::optional<int> stun_keepalive_interval,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) {
|
||||
// Using `new` to access a non-public constructor.
|
||||
auto port = absl::WrapUnique(new UDPPort(thread, factory, network, min_port,
|
||||
max_port, username, password,
|
||||
emit_local_for_anyaddress));
|
||||
auto port = absl::WrapUnique(
|
||||
new UDPPort(thread, factory, network, min_port, max_port, username,
|
||||
password, emit_local_for_anyaddress, field_trials));
|
||||
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
||||
if (!port->Init()) {
|
||||
return nullptr;
|
||||
|
@ -124,7 +126,8 @@ class UDPPort : public Port {
|
|||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool emit_local_for_anyaddress);
|
||||
bool emit_local_for_anyaddress,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials);
|
||||
|
||||
UDPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
|
@ -132,7 +135,8 @@ class UDPPort : public Port {
|
|||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool emit_local_for_anyaddress);
|
||||
bool emit_local_for_anyaddress,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials);
|
||||
|
||||
bool Init();
|
||||
|
||||
|
@ -270,7 +274,8 @@ class StunPort : public UDPPort {
|
|||
const std::string& username,
|
||||
const std::string& password,
|
||||
const ServerAddresses& servers,
|
||||
absl::optional<int> stun_keepalive_interval);
|
||||
absl::optional<int> stun_keepalive_interval,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials);
|
||||
|
||||
void PrepareAddress() override;
|
||||
|
||||
|
@ -282,7 +287,8 @@ class StunPort : public UDPPort {
|
|||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const ServerAddresses& servers);
|
||||
const ServerAddresses& servers,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials);
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "rtc_base/ssl_adapter.h"
|
||||
#include "rtc_base/virtual_socket_server.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
using cricket::ServerAddresses;
|
||||
using rtc::SocketAddress;
|
||||
|
@ -77,7 +78,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> {
|
|||
stun_port_ = cricket::StunPort::Create(
|
||||
rtc::Thread::Current(), &socket_factory_, &network_, 0, 0,
|
||||
rtc::CreateRandomString(16), rtc::CreateRandomString(22), stun_servers,
|
||||
absl::nullopt);
|
||||
absl::nullopt, &field_trials_);
|
||||
stun_port_->set_stun_keepalive_delay(stun_keepalive_delay_);
|
||||
// If `stun_keepalive_lifetime_` is negative, let the stun port
|
||||
// choose its lifetime from the network type.
|
||||
|
@ -104,7 +105,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> {
|
|||
stun_port_ = cricket::UDPPort::Create(
|
||||
rtc::Thread::Current(), &socket_factory_, &network_, socket_.get(),
|
||||
rtc::CreateRandomString(16), rtc::CreateRandomString(22), false,
|
||||
absl::nullopt);
|
||||
absl::nullopt, &field_trials_);
|
||||
ASSERT_TRUE(stun_port_ != NULL);
|
||||
ServerAddresses stun_servers;
|
||||
stun_servers.insert(server_addr);
|
||||
|
@ -175,6 +176,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> {
|
|||
|
||||
protected:
|
||||
cricket::IceCandidateErrorEvent error_event_;
|
||||
webrtc::test::ScopedKeyValueConfig field_trials_;
|
||||
};
|
||||
|
||||
class StunPortTestWithRealClock : public StunPortTestBase {};
|
||||
|
|
|
@ -91,7 +91,8 @@ TCPPort::TCPPort(rtc::Thread* thread,
|
|||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool allow_listen)
|
||||
bool allow_listen,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: Port(thread,
|
||||
LOCAL_PORT_TYPE,
|
||||
factory,
|
||||
|
@ -99,7 +100,8 @@ TCPPort::TCPPort(rtc::Thread* thread,
|
|||
min_port,
|
||||
max_port,
|
||||
username,
|
||||
password),
|
||||
password,
|
||||
field_trials),
|
||||
allow_listen_(allow_listen),
|
||||
error_(0) {
|
||||
// TODO(mallinath) - Set preference value as per RFC 6544.
|
||||
|
|
|
@ -34,18 +34,20 @@ class TCPConnection;
|
|||
// call this TCPPort::OnReadPacket (3 arg) to dispatch to a connection.
|
||||
class TCPPort : public Port {
|
||||
public:
|
||||
static std::unique_ptr<TCPPort> Create(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool allow_listen) {
|
||||
static std::unique_ptr<TCPPort> Create(
|
||||
rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool allow_listen,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) {
|
||||
// Using `new` to access a non-public constructor.
|
||||
return absl::WrapUnique(new TCPPort(thread, factory, network, min_port,
|
||||
max_port, username, password,
|
||||
allow_listen));
|
||||
allow_listen, field_trials));
|
||||
}
|
||||
~TCPPort() override;
|
||||
|
||||
|
@ -71,7 +73,8 @@ class TCPPort : public Port {
|
|||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
bool allow_listen);
|
||||
bool allow_listen,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials);
|
||||
|
||||
// Handles sending using the local TCP socket.
|
||||
int SendTo(const void* data,
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "rtc_base/time_utils.h"
|
||||
#include "rtc_base/virtual_socket_server.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
using cricket::Connection;
|
||||
using cricket::ICE_PWD_LENGTH;
|
||||
|
@ -82,12 +83,13 @@ class TCPPortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||
std::unique_ptr<TCPPort> CreateTCPPort(const SocketAddress& addr) {
|
||||
return std::unique_ptr<TCPPort>(
|
||||
TCPPort::Create(&main_, &socket_factory_, MakeNetwork(addr), 0, 0,
|
||||
username_, password_, true));
|
||||
username_, password_, true, &field_trials_));
|
||||
}
|
||||
|
||||
std::unique_ptr<TCPPort> CreateTCPPort(const rtc::Network* network) {
|
||||
return std::unique_ptr<TCPPort>(TCPPort::Create(
|
||||
&main_, &socket_factory_, network, 0, 0, username_, password_, true));
|
||||
return std::unique_ptr<TCPPort>(
|
||||
TCPPort::Create(&main_, &socket_factory_, network, 0, 0, username_,
|
||||
password_, true, &field_trials_));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -100,6 +102,7 @@ class TCPPortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||
rtc::BasicPacketSocketFactory socket_factory_;
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
webrtc::test::ScopedKeyValueConfig field_trials_;
|
||||
};
|
||||
|
||||
TEST_F(TCPPortTest, TestTCPPortWithLocalhostAddress) {
|
||||
|
|
|
@ -227,7 +227,13 @@ TurnPort::TurnPort(rtc::Thread* thread,
|
|||
webrtc::TurnCustomizer* customizer,
|
||||
rtc::SSLCertificateVerifier* tls_cert_verifier,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: Port(thread, RELAY_PORT_TYPE, factory, network, username, password),
|
||||
: Port(thread,
|
||||
RELAY_PORT_TYPE,
|
||||
factory,
|
||||
network,
|
||||
username,
|
||||
password,
|
||||
field_trials),
|
||||
server_address_(server_address),
|
||||
tls_alpn_protocols_(tls_alpn_protocols),
|
||||
tls_elliptic_curves_(tls_elliptic_curves),
|
||||
|
@ -268,7 +274,8 @@ TurnPort::TurnPort(rtc::Thread* thread,
|
|||
min_port,
|
||||
max_port,
|
||||
username,
|
||||
password),
|
||||
password,
|
||||
field_trials),
|
||||
server_address_(server_address),
|
||||
tls_alpn_protocols_(tls_alpn_protocols),
|
||||
tls_elliptic_curves_(tls_elliptic_curves),
|
||||
|
|
|
@ -375,9 +375,9 @@ class TurnPortTest : public ::testing::Test,
|
|||
void CreateUdpPort() { CreateUdpPort(kLocalAddr2); }
|
||||
|
||||
void CreateUdpPort(const SocketAddress& address) {
|
||||
udp_port_ =
|
||||
UDPPort::Create(&main_, &socket_factory_, MakeNetwork(address), 0, 0,
|
||||
kIceUfrag2, kIcePwd2, false, absl::nullopt);
|
||||
udp_port_ = UDPPort::Create(&main_, &socket_factory_, MakeNetwork(address),
|
||||
0, 0, kIceUfrag2, kIcePwd2, false,
|
||||
absl::nullopt, &field_trials_);
|
||||
// UDP port will be controlled.
|
||||
udp_port_->SetIceRole(ICEROLE_CONTROLLED);
|
||||
udp_port_->SignalPortComplete.connect(this,
|
||||
|
|
|
@ -756,11 +756,13 @@ std::vector<const rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
|||
if (rtc::IPIsLinkLocal(network->GetBestIP())) {
|
||||
continue;
|
||||
}
|
||||
lowest_cost = std::min<uint16_t>(lowest_cost, network->GetCost());
|
||||
lowest_cost = std::min<uint16_t>(
|
||||
lowest_cost, network->GetCost(*allocator()->field_trials()));
|
||||
}
|
||||
NetworkFilter costly_filter(
|
||||
[lowest_cost](const rtc::Network* network) {
|
||||
return network->GetCost() > lowest_cost + rtc::kNetworkCostLow;
|
||||
[lowest_cost, this](const rtc::Network* network) {
|
||||
return network->GetCost(*allocator()->field_trials()) >
|
||||
lowest_cost + rtc::kNetworkCostLow;
|
||||
},
|
||||
"costly");
|
||||
FilterNetworks(&networks, costly_filter);
|
||||
|
@ -1449,14 +1451,16 @@ void AllocationSequence::CreateUDPPorts() {
|
|||
session_->network_thread(), session_->socket_factory(), network_,
|
||||
udp_socket_.get(), session_->username(), session_->password(),
|
||||
emit_local_candidate_for_anyaddress,
|
||||
session_->allocator()->stun_candidate_keepalive_interval());
|
||||
session_->allocator()->stun_candidate_keepalive_interval(),
|
||||
session_->allocator()->field_trials());
|
||||
} else {
|
||||
port = UDPPort::Create(
|
||||
session_->network_thread(), session_->socket_factory(), network_,
|
||||
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
||||
session_->username(), session_->password(),
|
||||
emit_local_candidate_for_anyaddress,
|
||||
session_->allocator()->stun_candidate_keepalive_interval());
|
||||
session_->allocator()->stun_candidate_keepalive_interval(),
|
||||
session_->allocator()->field_trials());
|
||||
}
|
||||
|
||||
if (port) {
|
||||
|
@ -1492,7 +1496,8 @@ void AllocationSequence::CreateTCPPorts() {
|
|||
session_->network_thread(), session_->socket_factory(), network_,
|
||||
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
||||
session_->username(), session_->password(),
|
||||
session_->allocator()->allow_tcp_listen());
|
||||
session_->allocator()->allow_tcp_listen(),
|
||||
session_->allocator()->field_trials());
|
||||
if (port) {
|
||||
session_->AddAllocatedPort(port.release(), this);
|
||||
// Since TCPPort is not created using shared socket, `port` will not be
|
||||
|
@ -1520,7 +1525,8 @@ void AllocationSequence::CreateStunPorts() {
|
|||
session_->network_thread(), session_->socket_factory(), network_,
|
||||
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
||||
session_->username(), session_->password(), config_->StunServers(),
|
||||
session_->allocator()->stun_candidate_keepalive_interval());
|
||||
session_->allocator()->stun_candidate_keepalive_interval(),
|
||||
session_->allocator()->field_trials());
|
||||
if (port) {
|
||||
session_->AddAllocatedPort(port.release(), this);
|
||||
// Since StunPort is not created using shared socket, `port` will not be
|
||||
|
|
|
@ -146,7 +146,7 @@ ConnectionContext::ConnectionContext(
|
|||
// If network_monitor_factory_ is non-null, it will be used to create a
|
||||
// network monitor while on the network thread.
|
||||
default_network_manager_ = std::make_unique<rtc::BasicNetworkManager>(
|
||||
network_monitor_factory_.get(), socket_factory);
|
||||
network_monitor_factory_.get(), socket_factory, &trials());
|
||||
|
||||
default_socket_factory_ =
|
||||
std::make_unique<rtc::BasicPacketSocketFactory>(socket_factory);
|
||||
|
|
|
@ -949,9 +949,12 @@ rtc_library("rtc_base") {
|
|||
"../api:refcountedbase",
|
||||
"../api:scoped_refptr",
|
||||
"../api:sequence_checker",
|
||||
"../api:webrtc_key_value_config",
|
||||
"../api/numerics",
|
||||
"../api/task_queue",
|
||||
"../api/transport:field_trial_based_config",
|
||||
"../system_wrappers:field_trial",
|
||||
"memory:always_valid_pointer",
|
||||
"network:sent_packet",
|
||||
"synchronization:mutex",
|
||||
"system:file_wrapper",
|
||||
|
@ -1233,6 +1236,8 @@ rtc_library("rtc_base_tests_utils") {
|
|||
":threading",
|
||||
"../api/units:time_delta",
|
||||
"../api/units:timestamp",
|
||||
"../test:scoped_key_value_config",
|
||||
"memory:always_valid_pointer",
|
||||
"memory:fifo_buffer",
|
||||
"synchronization:mutex",
|
||||
"task_utils:to_queued_task",
|
||||
|
@ -1550,6 +1555,7 @@ if (rtc_include_tests) {
|
|||
"../test:field_trial",
|
||||
"../test:fileutils",
|
||||
"../test:rtc_expect_death",
|
||||
"../test:scoped_key_value_config",
|
||||
"../test:test_main",
|
||||
"../test:test_support",
|
||||
"memory:fifo_buffer",
|
||||
|
|
|
@ -41,6 +41,10 @@ class AlwaysValidPointer {
|
|||
Interface* operator->() { return pointer_; }
|
||||
Interface& operator*() { return *pointer_; }
|
||||
|
||||
Interface* get() const { return pointer_; }
|
||||
Interface* operator->() const { return pointer_; }
|
||||
Interface& operator*() const { return *pointer_; }
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Interface> owned_instance_;
|
||||
Interface* const pointer_;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "rtc_base/thread.h"
|
||||
#include "rtc_base/virtual_socket_server.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
namespace rtc {
|
||||
namespace {
|
||||
|
@ -219,8 +220,9 @@ bool TestConnectivity(const SocketAddress& src, const IPAddress& dst) {
|
|||
}
|
||||
|
||||
void TestPhysicalInternal(const SocketAddress& int_addr) {
|
||||
webrtc::test::ScopedKeyValueConfig field_trials;
|
||||
PhysicalSocketServer socket_server;
|
||||
BasicNetworkManager network_manager(nullptr, &socket_server);
|
||||
BasicNetworkManager network_manager(nullptr, &socket_server, &field_trials);
|
||||
network_manager.StartUpdating();
|
||||
// Process pending messages so the network list is updated.
|
||||
Thread::Current()->ProcessMessages(0);
|
||||
|
|
|
@ -29,8 +29,10 @@
|
|||
#include "absl/algorithm/container.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/memory/always_valid_pointer.h"
|
||||
#include "rtc_base/network_monitor.h"
|
||||
#include "rtc_base/socket.h" // includes something that makes windows happy
|
||||
#include "rtc_base/string_encode.h"
|
||||
|
@ -38,7 +40,6 @@
|
|||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "rtc_base/task_utils/to_queued_task.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace rtc {
|
||||
namespace {
|
||||
|
@ -280,10 +281,13 @@ webrtc::MdnsResponderInterface* NetworkManager::GetMdnsResponder() const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NetworkManagerBase::NetworkManagerBase()
|
||||
NetworkManagerBase::NetworkManagerBase(
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: enumeration_permission_(NetworkManager::ENUMERATION_ALLOWED),
|
||||
signal_network_preference_change_(webrtc::field_trial::IsEnabled(
|
||||
"WebRTC-SignalNetworkPreferenceChange")) {}
|
||||
signal_network_preference_change_(
|
||||
field_trials
|
||||
? field_trials->IsEnabled("WebRTC-SignalNetworkPreferenceChange")
|
||||
: false) {}
|
||||
|
||||
NetworkManagerBase::~NetworkManagerBase() {
|
||||
for (const auto& kv : networks_map_) {
|
||||
|
@ -508,25 +512,17 @@ bool NetworkManagerBase::IsVpnMacAddress(
|
|||
return false;
|
||||
}
|
||||
|
||||
BasicNetworkManager::BasicNetworkManager()
|
||||
: BasicNetworkManager(nullptr, nullptr) {}
|
||||
|
||||
BasicNetworkManager::BasicNetworkManager(SocketFactory* socket_factory)
|
||||
: BasicNetworkManager(nullptr, socket_factory) {}
|
||||
|
||||
BasicNetworkManager::BasicNetworkManager(
|
||||
NetworkMonitorFactory* network_monitor_factory)
|
||||
: BasicNetworkManager(network_monitor_factory, nullptr) {}
|
||||
|
||||
BasicNetworkManager::BasicNetworkManager(
|
||||
NetworkMonitorFactory* network_monitor_factory,
|
||||
SocketFactory* socket_factory)
|
||||
: network_monitor_factory_(network_monitor_factory),
|
||||
SocketFactory* socket_factory,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials)
|
||||
: field_trials_(field_trials),
|
||||
network_monitor_factory_(network_monitor_factory),
|
||||
socket_factory_(socket_factory),
|
||||
allow_mac_based_ipv6_(
|
||||
webrtc::field_trial::IsEnabled("WebRTC-AllowMACBasedIPv6")),
|
||||
field_trials_->IsEnabled("WebRTC-AllowMACBasedIPv6")),
|
||||
bind_using_ifname_(
|
||||
!webrtc::field_trial::IsDisabled("WebRTC-BindUsingInterfaceName")) {}
|
||||
!field_trials_->IsDisabled("WebRTC-BindUsingInterfaceName")) {}
|
||||
|
||||
BasicNetworkManager::~BasicNetworkManager() {
|
||||
if (task_safety_flag_) {
|
||||
|
@ -936,7 +932,8 @@ void BasicNetworkManager::StartNetworkMonitor() {
|
|||
return;
|
||||
}
|
||||
if (!network_monitor_) {
|
||||
network_monitor_.reset(network_monitor_factory_->CreateNetworkMonitor());
|
||||
network_monitor_.reset(
|
||||
network_monitor_factory_->CreateNetworkMonitor(*field_trials_));
|
||||
if (!network_monitor_) {
|
||||
return;
|
||||
}
|
||||
|
@ -1057,24 +1054,6 @@ NetworkBindingResult BasicNetworkManager::BindSocketToNetwork(
|
|||
return network_monitor_->BindSocketToNetwork(socket_fd, address, if_name);
|
||||
}
|
||||
|
||||
Network::Network(absl::string_view name,
|
||||
absl::string_view desc,
|
||||
const IPAddress& prefix,
|
||||
int prefix_length)
|
||||
: name_(name),
|
||||
description_(desc),
|
||||
prefix_(prefix),
|
||||
prefix_length_(prefix_length),
|
||||
key_(MakeNetworkKey(name, prefix, prefix_length)),
|
||||
scope_id_(0),
|
||||
ignored_(false),
|
||||
type_(ADAPTER_TYPE_UNKNOWN),
|
||||
preference_(0),
|
||||
use_differentiated_cellular_costs_(webrtc::field_trial::IsEnabled(
|
||||
"WebRTC-UseDifferentiatedCellularCosts")),
|
||||
add_network_cost_to_vpn_(
|
||||
webrtc::field_trial::IsEnabled("WebRTC-AddNetworkCostToVpn")) {}
|
||||
|
||||
Network::Network(absl::string_view name,
|
||||
absl::string_view desc,
|
||||
const IPAddress& prefix,
|
||||
|
@ -1088,11 +1067,7 @@ Network::Network(absl::string_view name,
|
|||
scope_id_(0),
|
||||
ignored_(false),
|
||||
type_(type),
|
||||
preference_(0),
|
||||
use_differentiated_cellular_costs_(webrtc::field_trial::IsEnabled(
|
||||
"WebRTC-UseDifferentiatedCellularCosts")),
|
||||
add_network_cost_to_vpn_(
|
||||
webrtc::field_trial::IsEnabled("WebRTC-AddNetworkCostToVpn")) {}
|
||||
preference_(0) {}
|
||||
|
||||
Network::Network(const Network&) = default;
|
||||
|
||||
|
@ -1162,11 +1137,23 @@ webrtc::MdnsResponderInterface* Network::GetMdnsResponder() const {
|
|||
return mdns_responder_provider_->GetMdnsResponder();
|
||||
}
|
||||
|
||||
uint16_t Network::GetCost() const {
|
||||
uint16_t Network::GetCost(
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials) const {
|
||||
return GetCost(
|
||||
*webrtc::AlwaysValidPointer<const webrtc::WebRtcKeyValueConfig,
|
||||
webrtc::FieldTrialBasedConfig>(field_trials));
|
||||
}
|
||||
|
||||
uint16_t Network::GetCost(
|
||||
const webrtc::WebRtcKeyValueConfig& field_trials) const {
|
||||
AdapterType type = IsVpn() ? underlying_type_for_vpn_ : type_;
|
||||
const bool use_differentiated_cellular_costs =
|
||||
field_trials.IsEnabled("WebRTC-UseDifferentiatedCellularCosts");
|
||||
const bool add_network_cost_to_vpn =
|
||||
field_trials.IsEnabled("WebRTC-AddNetworkCostToVpn");
|
||||
return ComputeNetworkCostByType(type, IsVpn(),
|
||||
use_differentiated_cellular_costs_,
|
||||
add_network_cost_to_vpn_);
|
||||
use_differentiated_cellular_costs,
|
||||
add_network_cost_to_vpn);
|
||||
}
|
||||
|
||||
// This is the inverse of ComputeNetworkCostByType().
|
||||
|
|
|
@ -22,8 +22,11 @@
|
|||
#include "absl/strings/string_view.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/sequence_checker.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/webrtc_key_value_config.h"
|
||||
#include "rtc_base/ip_address.h"
|
||||
#include "rtc_base/mdns_responder_interface.h"
|
||||
#include "rtc_base/memory/always_valid_pointer.h"
|
||||
#include "rtc_base/network_monitor.h"
|
||||
#include "rtc_base/network_monitor_factory.h"
|
||||
#include "rtc_base/socket_factory.h"
|
||||
|
@ -205,7 +208,8 @@ class RTC_EXPORT NetworkManager : public DefaultLocalAddressProvider,
|
|||
// Base class for NetworkManager implementations.
|
||||
class RTC_EXPORT NetworkManagerBase : public NetworkManager {
|
||||
public:
|
||||
NetworkManagerBase();
|
||||
NetworkManagerBase(
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr);
|
||||
~NetworkManagerBase() override;
|
||||
|
||||
void GetNetworks(NetworkList* networks) const override;
|
||||
|
@ -273,15 +277,28 @@ class RTC_EXPORT BasicNetworkManager : public NetworkManagerBase,
|
|||
public NetworkBinderInterface,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
// This version is used by chromium.
|
||||
ABSL_DEPRECATED(
|
||||
"Use the version with socket_factory, see bugs.webrtc.org/13145")
|
||||
BasicNetworkManager();
|
||||
explicit BasicNetworkManager(SocketFactory* socket_factory);
|
||||
ABSL_DEPRECATED(
|
||||
"Use the version with socket_factory, see bugs.webrtc.org/13145")
|
||||
explicit BasicNetworkManager(NetworkMonitorFactory* network_monitor_factory);
|
||||
BasicNetworkManager(NetworkMonitorFactory* network_monitor_factory,
|
||||
SocketFactory* socket_factory);
|
||||
explicit BasicNetworkManager(
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr)
|
||||
: BasicNetworkManager(
|
||||
/* network_monitor_factory= */ nullptr,
|
||||
/* socket_factory= */ nullptr,
|
||||
field_trials) {}
|
||||
|
||||
// This is used by lots of downstream code.
|
||||
BasicNetworkManager(
|
||||
SocketFactory* socket_factory,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr)
|
||||
: BasicNetworkManager(/* network_monitor_factory= */ nullptr,
|
||||
socket_factory,
|
||||
field_trials) {}
|
||||
|
||||
BasicNetworkManager(
|
||||
NetworkMonitorFactory* network_monitor_factory,
|
||||
SocketFactory* socket_factory,
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr);
|
||||
~BasicNetworkManager() override;
|
||||
|
||||
void StartUpdating() override;
|
||||
|
@ -354,6 +371,10 @@ class RTC_EXPORT BasicNetworkManager : public NetworkManagerBase,
|
|||
Thread* thread_ = nullptr;
|
||||
bool sent_first_update_ = true;
|
||||
int start_count_ = 0;
|
||||
// Chromium create BasicNetworkManager() w/o field trials.
|
||||
webrtc::AlwaysValidPointer<const webrtc::WebRtcKeyValueConfig,
|
||||
webrtc::FieldTrialBasedConfig>
|
||||
field_trials_;
|
||||
std::vector<std::string> network_ignore_list_;
|
||||
NetworkMonitorFactory* const network_monitor_factory_;
|
||||
SocketFactory* const socket_factory_;
|
||||
|
@ -372,13 +393,19 @@ class RTC_EXPORT Network {
|
|||
Network(absl::string_view name,
|
||||
absl::string_view description,
|
||||
const IPAddress& prefix,
|
||||
int prefix_length);
|
||||
int prefix_length)
|
||||
: Network(name,
|
||||
description,
|
||||
prefix,
|
||||
prefix_length,
|
||||
rtc::ADAPTER_TYPE_UNKNOWN) {}
|
||||
|
||||
Network(absl::string_view name,
|
||||
absl::string_view description,
|
||||
const IPAddress& prefix,
|
||||
int prefix_length,
|
||||
AdapterType type);
|
||||
|
||||
Network(const Network&);
|
||||
~Network();
|
||||
|
||||
|
@ -515,7 +542,16 @@ class RTC_EXPORT Network {
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t GetCost() const;
|
||||
// Note: This function is called "rarely".
|
||||
// Twice per Network in BasicPortAllocator if
|
||||
// PORTALLOCATOR_DISABLE_COSTLY_NETWORKS. Once in Port::Construct() (and when
|
||||
// Port::OnNetworkTypeChanged is called).
|
||||
ABSL_DEPRECATED(
|
||||
"Use the version with field trials, see bugs.webrtc.org/webrtc:10335")
|
||||
uint16_t GetCost(
|
||||
const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) const;
|
||||
uint16_t GetCost(const webrtc::WebRtcKeyValueConfig& field_trials) const;
|
||||
|
||||
// A unique id assigned by the network manager, which may be signaled
|
||||
// to the remote side in the candidate.
|
||||
uint16_t id() const { return id_; }
|
||||
|
@ -567,8 +603,6 @@ class RTC_EXPORT Network {
|
|||
int preference_;
|
||||
bool active_ = true;
|
||||
uint16_t id_ = 0;
|
||||
bool use_differentiated_cellular_costs_ = false;
|
||||
bool add_network_cost_to_vpn_ = false;
|
||||
NetworkPreference network_preference_ = NetworkPreference::NEUTRAL;
|
||||
|
||||
friend class NetworkManager;
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
#ifndef RTC_BASE_NETWORK_MONITOR_FACTORY_H_
|
||||
#define RTC_BASE_NETWORK_MONITOR_FACTORY_H_
|
||||
|
||||
namespace webrtc {
|
||||
class WebRtcKeyValueConfig;
|
||||
} // namespace webrtc
|
||||
|
||||
namespace rtc {
|
||||
|
||||
// Forward declaring this so it's not part of the API surface; it's only
|
||||
|
@ -24,7 +28,8 @@ class NetworkMonitorInterface;
|
|||
*/
|
||||
class NetworkMonitorFactory {
|
||||
public:
|
||||
virtual NetworkMonitorInterface* CreateNetworkMonitor() = 0;
|
||||
virtual NetworkMonitorInterface* CreateNetworkMonitor(
|
||||
const webrtc::WebRtcKeyValueConfig& field_trials) = 0;
|
||||
|
||||
virtual ~NetworkMonitorFactory();
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "rtc_base/logging.h" // For RTC_LOG_GLE
|
||||
#endif
|
||||
#include "test/field_trial.h"
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
using ::testing::Contains;
|
||||
using ::testing::Not;
|
||||
|
@ -121,7 +122,8 @@ class FakeNetworkMonitor : public NetworkMonitorInterface {
|
|||
class FakeNetworkMonitorFactory : public NetworkMonitorFactory {
|
||||
public:
|
||||
FakeNetworkMonitorFactory() {}
|
||||
NetworkMonitorInterface* CreateNetworkMonitor() override {
|
||||
NetworkMonitorInterface* CreateNetworkMonitor(
|
||||
const webrtc::WebRtcKeyValueConfig& field_trials) override {
|
||||
return new FakeNetworkMonitor();
|
||||
}
|
||||
};
|
||||
|
@ -309,14 +311,18 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||
#endif // defined(WEBRTC_POSIX)
|
||||
|
||||
protected:
|
||||
webrtc::test::ScopedKeyValueConfig field_trials_;
|
||||
bool callback_called_;
|
||||
};
|
||||
|
||||
class TestBasicNetworkManager : public BasicNetworkManager {
|
||||
public:
|
||||
TestBasicNetworkManager(NetworkMonitorFactory* network_monitor_factory,
|
||||
SocketFactory* socket_factory)
|
||||
: BasicNetworkManager(network_monitor_factory, socket_factory) {}
|
||||
SocketFactory* socket_factory,
|
||||
const webrtc::WebRtcKeyValueConfig& field_trials)
|
||||
: BasicNetworkManager(network_monitor_factory,
|
||||
socket_factory,
|
||||
&field_trials) {}
|
||||
using BasicNetworkManager::QueryDefaultLocalAddress;
|
||||
using BasicNetworkManager::set_default_local_addresses;
|
||||
};
|
||||
|
@ -404,7 +410,7 @@ TEST_F(NetworkTest, DISABLED_TestCreateNetworks) {
|
|||
// ALLOWED.
|
||||
TEST_F(NetworkTest, TestUpdateNetworks) {
|
||||
PhysicalSocketServer socket_server;
|
||||
BasicNetworkManager manager(nullptr, &socket_server);
|
||||
BasicNetworkManager manager(nullptr, &socket_server, &field_trials_);
|
||||
manager.SignalNetworksChanged.connect(static_cast<NetworkTest*>(this),
|
||||
&NetworkTest::OnNetworksChanged);
|
||||
EXPECT_EQ(NetworkManager::ENUMERATION_ALLOWED,
|
||||
|
@ -798,7 +804,7 @@ TEST_F(NetworkTest, IPv6NetworksPreferredOverIPv4) {
|
|||
// to be preference-ordered by name. For example, "eth0" before "eth1".
|
||||
TEST_F(NetworkTest, NetworksSortedByInterfaceName) {
|
||||
PhysicalSocketServer socket_server;
|
||||
BasicNetworkManager manager(&socket_server);
|
||||
BasicNetworkManager manager(&socket_server, &field_trials_);
|
||||
Network* eth0 = new Network("test_eth0", "Test Network Adapter 1",
|
||||
IPAddress(0x65432100U), 24);
|
||||
eth0->AddIP(IPAddress(0x65432100U));
|
||||
|
@ -896,7 +902,8 @@ TEST_F(NetworkTest, TestGetAdapterTypeFromNetworkMonitor) {
|
|||
std::string ipv6_address = "1000:2000:3000:4000:0:0:0:1";
|
||||
std::string ipv6_mask = "FFFF:FFFF:FFFF:FFFF::";
|
||||
PhysicalSocketServer socket_server;
|
||||
BasicNetworkManager manager_without_monitor(nullptr, &socket_server);
|
||||
BasicNetworkManager manager_without_monitor(nullptr, &socket_server,
|
||||
&field_trials_);
|
||||
manager_without_monitor.StartUpdating();
|
||||
// A network created without a network monitor will get UNKNOWN type.
|
||||
ifaddrs* addr_list = InstallIpv6Network(if_name, ipv6_address, ipv6_mask,
|
||||
|
@ -906,7 +913,8 @@ TEST_F(NetworkTest, TestGetAdapterTypeFromNetworkMonitor) {
|
|||
|
||||
// With the fake network monitor the type should be correctly determined.
|
||||
FakeNetworkMonitorFactory factory;
|
||||
BasicNetworkManager manager_with_monitor(&factory, &socket_server);
|
||||
BasicNetworkManager manager_with_monitor(&factory, &socket_server,
|
||||
&field_trials_);
|
||||
manager_with_monitor.StartUpdating();
|
||||
// Add the same ipv6 address as before but it has the right network type
|
||||
// detected by the network monitor now.
|
||||
|
@ -1004,7 +1012,7 @@ TEST_F(NetworkTest, TestNetworkMonitorIsAdapterAvailable) {
|
|||
// Sanity check that both interfaces are included by default.
|
||||
FakeNetworkMonitorFactory factory;
|
||||
PhysicalSocketServer socket_server;
|
||||
BasicNetworkManager manager(&factory, &socket_server);
|
||||
BasicNetworkManager manager(&factory, &socket_server, &field_trials_);
|
||||
manager.StartUpdating();
|
||||
CallConvertIfAddrs(manager, list, /*include_ignored=*/false, &result);
|
||||
EXPECT_EQ(2u, result.size());
|
||||
|
@ -1151,7 +1159,7 @@ TEST_F(NetworkTest, TestIPv6Selection) {
|
|||
TEST_F(NetworkTest, TestNetworkMonitoring) {
|
||||
FakeNetworkMonitorFactory factory;
|
||||
PhysicalSocketServer socket_server;
|
||||
BasicNetworkManager manager(&factory, &socket_server);
|
||||
BasicNetworkManager manager(&factory, &socket_server, &field_trials_);
|
||||
manager.SignalNetworksChanged.connect(static_cast<NetworkTest*>(this),
|
||||
&NetworkTest::OnNetworksChanged);
|
||||
manager.StartUpdating();
|
||||
|
@ -1182,7 +1190,7 @@ TEST_F(NetworkTest, MAYBE_DefaultLocalAddress) {
|
|||
IPAddress ip;
|
||||
FakeNetworkMonitorFactory factory;
|
||||
PhysicalSocketServer socket_server;
|
||||
TestBasicNetworkManager manager(&factory, &socket_server);
|
||||
TestBasicNetworkManager manager(&factory, &socket_server, field_trials_);
|
||||
manager.SignalNetworksChanged.connect(static_cast<NetworkTest*>(this),
|
||||
&NetworkTest::OnNetworksChanged);
|
||||
manager.StartUpdating();
|
||||
|
@ -1358,7 +1366,7 @@ TEST_F(NetworkTest, WebRTC_BindUsingInterfaceName) {
|
|||
// Sanity check that both interfaces are included by default.
|
||||
FakeNetworkMonitorFactory factory;
|
||||
PhysicalSocketServer socket_server;
|
||||
BasicNetworkManager manager(&factory, &socket_server);
|
||||
BasicNetworkManager manager(&factory, &socket_server, &field_trials_);
|
||||
manager.StartUpdating();
|
||||
CallConvertIfAddrs(manager, list, /*include_ignored=*/false, &result);
|
||||
EXPECT_EQ(2u, result.size());
|
||||
|
@ -1390,6 +1398,7 @@ TEST_F(NetworkTest, WebRTC_BindUsingInterfaceName) {
|
|||
TEST_F(NetworkTest, NetworkCostVpn_Default) {
|
||||
IPAddress ip1;
|
||||
EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1));
|
||||
webrtc::test::ScopedKeyValueConfig field_trials;
|
||||
|
||||
Network* net1 = new Network("em1", "em1", TruncateIP(ip1, 64), 64);
|
||||
net1->set_type(ADAPTER_TYPE_VPN);
|
||||
|
@ -1398,13 +1407,13 @@ TEST_F(NetworkTest, NetworkCostVpn_Default) {
|
|||
Network* net2 = new Network("em1", "em1", TruncateIP(ip1, 64), 64);
|
||||
net2->set_type(ADAPTER_TYPE_ETHERNET);
|
||||
|
||||
EXPECT_EQ(net1->GetCost(), net2->GetCost());
|
||||
EXPECT_EQ(net1->GetCost(field_trials), net2->GetCost(field_trials));
|
||||
delete net1;
|
||||
delete net2;
|
||||
}
|
||||
|
||||
TEST_F(NetworkTest, NetworkCostVpn_VpnMoreExpensive) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
webrtc::test::ScopedKeyValueConfig field_trials(
|
||||
"WebRTC-AddNetworkCostToVpn/Enabled/");
|
||||
|
||||
IPAddress ip1;
|
||||
|
@ -1417,13 +1426,13 @@ TEST_F(NetworkTest, NetworkCostVpn_VpnMoreExpensive) {
|
|||
Network* net2 = new Network("em1", "em1", TruncateIP(ip1, 64), 64);
|
||||
net2->set_type(ADAPTER_TYPE_ETHERNET);
|
||||
|
||||
EXPECT_GT(net1->GetCost(), net2->GetCost());
|
||||
EXPECT_GT(net1->GetCost(field_trials), net2->GetCost(field_trials));
|
||||
delete net1;
|
||||
delete net2;
|
||||
}
|
||||
|
||||
TEST_F(NetworkTest, GuessAdapterFromNetworkCost) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
webrtc::test::ScopedKeyValueConfig field_trials(
|
||||
"WebRTC-AddNetworkCostToVpn/Enabled/"
|
||||
"WebRTC-UseDifferentiatedCellularCosts/Enabled/");
|
||||
|
||||
|
@ -1435,7 +1444,8 @@ TEST_F(NetworkTest, GuessAdapterFromNetworkCost) {
|
|||
continue;
|
||||
Network net1("em1", "em1", TruncateIP(ip1, 64), 64);
|
||||
net1.set_type(type);
|
||||
auto [guess, vpn] = Network::GuessAdapterFromNetworkCost(net1.GetCost());
|
||||
auto [guess, vpn] =
|
||||
Network::GuessAdapterFromNetworkCost(net1.GetCost(field_trials));
|
||||
EXPECT_FALSE(vpn);
|
||||
if (type == rtc::ADAPTER_TYPE_LOOPBACK) {
|
||||
EXPECT_EQ(guess, rtc::ADAPTER_TYPE_ETHERNET);
|
||||
|
@ -1451,7 +1461,8 @@ TEST_F(NetworkTest, GuessAdapterFromNetworkCost) {
|
|||
Network net1("em1", "em1", TruncateIP(ip1, 64), 64);
|
||||
net1.set_type(rtc::ADAPTER_TYPE_VPN);
|
||||
net1.set_underlying_type_for_vpn(type);
|
||||
auto [guess, vpn] = Network::GuessAdapterFromNetworkCost(net1.GetCost());
|
||||
auto [guess, vpn] =
|
||||
Network::GuessAdapterFromNetworkCost(net1.GetCost(field_trials));
|
||||
EXPECT_TRUE(vpn);
|
||||
if (type == rtc::ADAPTER_TYPE_LOOPBACK) {
|
||||
EXPECT_EQ(guess, rtc::ADAPTER_TYPE_ETHERNET);
|
||||
|
|
|
@ -1587,6 +1587,7 @@ if (is_ios || is_mac) {
|
|||
":network_monitor_objc",
|
||||
":network_monitor_observer",
|
||||
"../api:sequence_checker",
|
||||
"../api:webrtc_key_value_config",
|
||||
"../rtc_base",
|
||||
"../rtc_base:threading",
|
||||
"../rtc_base/task_utils:pending_task_safety_flag",
|
||||
|
|
|
@ -582,6 +582,7 @@ if (current_os == "linux" || is_android) {
|
|||
"../../api:libjingle_peerconnection_api",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api:sequence_checker",
|
||||
"../../api:webrtc_key_value_config",
|
||||
"../../rtc_base",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:ip_address",
|
||||
|
|
|
@ -577,7 +577,8 @@ AndroidNetworkMonitorFactory::AndroidNetworkMonitorFactory(
|
|||
AndroidNetworkMonitorFactory::~AndroidNetworkMonitorFactory() = default;
|
||||
|
||||
rtc::NetworkMonitorInterface*
|
||||
AndroidNetworkMonitorFactory::CreateNetworkMonitor() {
|
||||
AndroidNetworkMonitorFactory::CreateNetworkMonitor(
|
||||
const WebRtcKeyValueConfig& field_trials) {
|
||||
return new AndroidNetworkMonitor(AttachCurrentThreadIfNeeded(),
|
||||
j_application_context_);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/webrtc_key_value_config.h"
|
||||
#include "rtc_base/network_monitor.h"
|
||||
#include "rtc_base/network_monitor_factory.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
|
@ -165,7 +166,8 @@ class AndroidNetworkMonitorFactory : public rtc::NetworkMonitorFactory {
|
|||
|
||||
~AndroidNetworkMonitorFactory() override;
|
||||
|
||||
rtc::NetworkMonitorInterface* CreateNetworkMonitor() override;
|
||||
rtc::NetworkMonitorInterface* CreateNetworkMonitor(
|
||||
const WebRtcKeyValueConfig& field_trials) override;
|
||||
|
||||
private:
|
||||
ScopedJavaGlobalRef<jobject> j_application_context_;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/sequence_checker.h"
|
||||
#include "api/webrtc_key_value_config.h"
|
||||
#include "rtc_base/network_monitor.h"
|
||||
#include "rtc_base/network_monitor_factory.h"
|
||||
#include "rtc_base/string_utils.h"
|
||||
|
@ -31,7 +32,8 @@ class ObjCNetworkMonitorFactory : public rtc::NetworkMonitorFactory {
|
|||
ObjCNetworkMonitorFactory() = default;
|
||||
~ObjCNetworkMonitorFactory() override = default;
|
||||
|
||||
rtc::NetworkMonitorInterface* CreateNetworkMonitor() override;
|
||||
rtc::NetworkMonitorInterface* CreateNetworkMonitor(
|
||||
const WebRtcKeyValueConfig& field_trials) override;
|
||||
};
|
||||
|
||||
class ObjCNetworkMonitor : public rtc::NetworkMonitorInterface,
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
namespace webrtc {
|
||||
|
||||
rtc::NetworkMonitorInterface* ObjCNetworkMonitorFactory::CreateNetworkMonitor() {
|
||||
rtc::NetworkMonitorInterface* ObjCNetworkMonitorFactory::CreateNetworkMonitor(
|
||||
const WebRtcKeyValueConfig& field_trials) {
|
||||
return new ObjCNetworkMonitor();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ rtc_library("emulated_network") {
|
|||
"../../api:sequence_checker",
|
||||
"../../api:simulated_network_api",
|
||||
"../../api:time_controller",
|
||||
"../../api:webrtc_key_value_config",
|
||||
"../../api/numerics",
|
||||
"../../api/test/network_emulation",
|
||||
"../../api/transport:stun_types",
|
||||
|
@ -67,11 +68,13 @@ rtc_library("emulated_network") {
|
|||
"../../rtc_base:stringutils",
|
||||
"../../rtc_base:task_queue_for_test",
|
||||
"../../rtc_base:threading",
|
||||
"../../rtc_base/memory:always_valid_pointer",
|
||||
"../../rtc_base/synchronization:mutex",
|
||||
"../../rtc_base/task_utils:pending_task_safety_flag",
|
||||
"../../rtc_base/task_utils:repeating_task",
|
||||
"../../rtc_base/task_utils:to_queued_task",
|
||||
"../../system_wrappers",
|
||||
"../../test:scoped_key_value_config",
|
||||
"../scenario:column_printer",
|
||||
"../time_controller",
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче