Use const rtc::Network* in ports and port allocator
No-try: True Bug: webrtc:13869 Change-Id: I6004fa96278263d0d25a1446d7bb8de41a563433 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256682 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Reviewed-by: Jonas Oreland <jonaso@google.com> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36353}
This commit is contained in:
parent
af3406ed99
commit
e0c6bdf071
@ -31,7 +31,7 @@ class TestUDPPort : public UDPPort {
|
||||
public:
|
||||
static TestUDPPort* Create(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
@ -50,7 +50,7 @@ class TestUDPPort : public UDPPort {
|
||||
protected:
|
||||
TestUDPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
|
||||
@ -108,7 +108,7 @@ std::string Port::ComputeFoundation(const std::string& type,
|
||||
Port::Port(rtc::Thread* thread,
|
||||
const std::string& type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
const std::string& username_fragment,
|
||||
const std::string& password)
|
||||
: thread_(thread),
|
||||
@ -135,7 +135,7 @@ Port::Port(rtc::Thread* thread,
|
||||
Port::Port(rtc::Thread* thread,
|
||||
const std::string& type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username_fragment,
|
||||
@ -203,7 +203,7 @@ Port::~Port() {
|
||||
const std::string& Port::Type() const {
|
||||
return type_;
|
||||
}
|
||||
rtc::Network* Port::Network() const {
|
||||
const rtc::Network* Port::Network() const {
|
||||
return network_;
|
||||
}
|
||||
|
||||
|
||||
@ -183,13 +183,13 @@ class Port : public PortInterface,
|
||||
Port(rtc::Thread* thread,
|
||||
const std::string& type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
const std::string& username_fragment,
|
||||
const std::string& password);
|
||||
Port(rtc::Thread* thread,
|
||||
const std::string& type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username_fragment,
|
||||
@ -202,7 +202,7 @@ class Port : public PortInterface,
|
||||
// conflit in the value of the 2-tuple, make sure that the implementation that
|
||||
// relies on this 2-tuple for RTTI is properly changed.
|
||||
const std::string& Type() const override;
|
||||
rtc::Network* Network() const override;
|
||||
const rtc::Network* Network() const override;
|
||||
|
||||
// Methods to set/get ICE role and tiebreaker values.
|
||||
IceRole GetIceRole() const override;
|
||||
@ -457,7 +457,7 @@ class Port : public PortInterface,
|
||||
rtc::PacketSocketFactory* const factory_;
|
||||
std::string type_;
|
||||
bool send_retransmit_count_attribute_;
|
||||
rtc::Network* network_;
|
||||
const rtc::Network* network_;
|
||||
uint16_t min_port_;
|
||||
uint16_t max_port_;
|
||||
std::string content_name_;
|
||||
|
||||
@ -49,7 +49,7 @@ class PortInterface {
|
||||
virtual ~PortInterface();
|
||||
|
||||
virtual const std::string& Type() const = 0;
|
||||
virtual rtc::Network* Network() const = 0;
|
||||
virtual const rtc::Network* Network() const = 0;
|
||||
|
||||
// Methods to set/get ICE role and tiebreaker values.
|
||||
virtual void SetIceRole(IceRole role) = 0;
|
||||
|
||||
@ -136,7 +136,7 @@ class TestPort : public Port {
|
||||
TestPort(rtc::Thread* thread,
|
||||
const std::string& type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username_fragment,
|
||||
@ -786,7 +786,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
||||
return port;
|
||||
}
|
||||
// Overload to create a test port given an rtc::Network directly.
|
||||
std::unique_ptr<TestPort> CreateTestPort(rtc::Network* network,
|
||||
std::unique_ptr<TestPort> CreateTestPort(const rtc::Network* network,
|
||||
const std::string& username,
|
||||
const std::string& password) {
|
||||
auto port = std::make_unique<TestPort>(&main_, "test", &socket_factory_,
|
||||
@ -2106,7 +2106,7 @@ TEST_F(PortTest, TestNetworkInfoAttribute) {
|
||||
rport->SetIceTiebreaker(kTiebreaker2);
|
||||
|
||||
uint16_t lnetwork_id = 9;
|
||||
lport->Network()->set_id(lnetwork_id);
|
||||
test_network->set_id(lnetwork_id);
|
||||
// Send a fake ping from lport to rport.
|
||||
lport->PrepareAddress();
|
||||
rport->PrepareAddress();
|
||||
@ -2127,7 +2127,7 @@ TEST_F(PortTest, TestNetworkInfoAttribute) {
|
||||
// Send a fake ping from rport to lport.
|
||||
test_network->set_type(rtc::ADAPTER_TYPE_CELLULAR);
|
||||
uint16_t rnetwork_id = 8;
|
||||
rport->Network()->set_id(rnetwork_id);
|
||||
test_network->set_id(rnetwork_id);
|
||||
Connection* rconn =
|
||||
rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE);
|
||||
rconn->Ping(0);
|
||||
|
||||
@ -153,7 +153,7 @@ bool UDPPort::AddressResolver::GetResolvedAddress(
|
||||
|
||||
UDPPort::UDPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
@ -169,7 +169,7 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
||||
|
||||
UDPPort::UDPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
@ -599,7 +599,7 @@ bool UDPPort::HasCandidateWithAddress(const rtc::SocketAddress& addr) const {
|
||||
std::unique_ptr<StunPort> StunPort::Create(
|
||||
rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
@ -619,7 +619,7 @@ std::unique_ptr<StunPort> StunPort::Create(
|
||||
|
||||
StunPort::StunPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
|
||||
@ -35,7 +35,7 @@ class UDPPort : public Port {
|
||||
static std::unique_ptr<UDPPort> Create(
|
||||
rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
@ -55,7 +55,7 @@ class UDPPort : public Port {
|
||||
static std::unique_ptr<UDPPort> Create(
|
||||
rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
@ -119,7 +119,7 @@ class UDPPort : public Port {
|
||||
protected:
|
||||
UDPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
@ -128,7 +128,7 @@ class UDPPort : public Port {
|
||||
|
||||
UDPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
@ -264,7 +264,7 @@ class StunPort : public UDPPort {
|
||||
static std::unique_ptr<StunPort> Create(
|
||||
rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
@ -277,7 +277,7 @@ class StunPort : public UDPPort {
|
||||
protected:
|
||||
StunPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
|
||||
@ -86,7 +86,7 @@ namespace cricket {
|
||||
|
||||
TCPPort::TCPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
|
||||
@ -36,7 +36,7 @@ class TCPPort : public Port {
|
||||
public:
|
||||
static std::unique_ptr<TCPPort> Create(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
@ -66,7 +66,7 @@ class TCPPort : public Port {
|
||||
protected:
|
||||
TCPPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
|
||||
@ -85,7 +85,7 @@ class TCPPortTest : public ::testing::Test, public sigslot::has_slots<> {
|
||||
username_, password_, true));
|
||||
}
|
||||
|
||||
std::unique_ptr<TCPPort> CreateTCPPort(rtc::Network* network) {
|
||||
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));
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ class TurnEntry : public sigslot::has_slots<> {
|
||||
|
||||
TurnPort::TurnPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
@ -248,7 +248,7 @@ TurnPort::TurnPort(rtc::Thread* thread,
|
||||
|
||||
TurnPort::TurnPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
|
||||
@ -205,7 +205,7 @@ class TurnPort : public Port {
|
||||
protected:
|
||||
TurnPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
@ -220,7 +220,7 @@ class TurnPort : public Port {
|
||||
|
||||
TurnPort(rtc::Thread* thread,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
uint16_t max_port,
|
||||
const std::string& username,
|
||||
|
||||
@ -277,7 +277,7 @@ class TurnPortTest : public ::testing::Test,
|
||||
password, server_address);
|
||||
}
|
||||
|
||||
bool CreateTurnPortWithNetwork(rtc::Network* network,
|
||||
bool CreateTurnPortWithNetwork(const rtc::Network* network,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const ProtocolAddress& server_address) {
|
||||
@ -288,7 +288,7 @@ class TurnPortTest : public ::testing::Test,
|
||||
// Version of CreateTurnPort that takes all possible parameters; all other
|
||||
// helper methods call this, such that "SetIceRole" and "ConnectSignals" (and
|
||||
// possibly other things in the future) only happen in one place.
|
||||
bool CreateTurnPortWithAllParams(rtc::Network* network,
|
||||
bool CreateTurnPortWithAllParams(const rtc::Network* network,
|
||||
const std::string& username,
|
||||
const std::string& password,
|
||||
const ProtocolAddress& server_address) {
|
||||
|
||||
@ -88,16 +88,18 @@ int ComparePort(const cricket::Port* a, const cricket::Port* b) {
|
||||
}
|
||||
|
||||
struct NetworkFilter {
|
||||
using Predicate = std::function<bool(rtc::Network*)>;
|
||||
using Predicate = std::function<bool(const rtc::Network*)>;
|
||||
NetworkFilter(Predicate pred, const std::string& description)
|
||||
: predRemain([pred](rtc::Network* network) { return !pred(network); }),
|
||||
: predRemain(
|
||||
[pred](const rtc::Network* network) { return !pred(network); }),
|
||||
description(description) {}
|
||||
Predicate predRemain;
|
||||
const std::string description;
|
||||
};
|
||||
|
||||
using NetworkList = rtc::NetworkManager::NetworkList;
|
||||
void FilterNetworks(NetworkList* networks, NetworkFilter filter) {
|
||||
void FilterNetworks(std::vector<const rtc::Network*>* networks,
|
||||
NetworkFilter filter) {
|
||||
auto start_to_remove =
|
||||
std::partition(networks->begin(), networks->end(), filter.predRemain);
|
||||
if (start_to_remove == networks->end()) {
|
||||
@ -432,11 +434,11 @@ bool BasicPortAllocatorSession::IsStopped() const {
|
||||
return state_ == SessionState::STOPPED;
|
||||
}
|
||||
|
||||
std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() {
|
||||
std::vector<const rtc::Network*>
|
||||
BasicPortAllocatorSession::GetFailedNetworks() {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
|
||||
std::vector<rtc::Network*> networks = GetNetworks();
|
||||
|
||||
std::vector<const rtc::Network*> networks = GetNetworks();
|
||||
// A network interface may have both IPv4 and IPv6 networks. Only if
|
||||
// neither of the networks has any connections, the network interface
|
||||
// is considered failed and need to be regathered on.
|
||||
@ -450,7 +452,7 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() {
|
||||
|
||||
networks.erase(
|
||||
std::remove_if(networks.begin(), networks.end(),
|
||||
[networks_with_connection](rtc::Network* network) {
|
||||
[networks_with_connection](const rtc::Network* network) {
|
||||
// If a network does not have any connection, it is
|
||||
// considered failed.
|
||||
return networks_with_connection.find(network->name()) !=
|
||||
@ -464,7 +466,7 @@ void BasicPortAllocatorSession::RegatherOnFailedNetworks() {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
|
||||
// Find the list of networks that have no connection.
|
||||
std::vector<rtc::Network*> failed_networks = GetFailedNetworks();
|
||||
std::vector<const rtc::Network*> failed_networks = GetFailedNetworks();
|
||||
if (failed_networks.empty()) {
|
||||
return;
|
||||
}
|
||||
@ -487,7 +489,7 @@ void BasicPortAllocatorSession::RegatherOnFailedNetworks() {
|
||||
}
|
||||
|
||||
void BasicPortAllocatorSession::Regather(
|
||||
const std::vector<rtc::Network*>& networks,
|
||||
const std::vector<const rtc::Network*>& networks,
|
||||
bool disable_equivalent_phases,
|
||||
IceRegatheringReason reason) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
@ -696,9 +698,9 @@ void BasicPortAllocatorSession::OnAllocate(int allocation_epoch) {
|
||||
allocation_started_ = true;
|
||||
}
|
||||
|
||||
std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
||||
std::vector<const rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
std::vector<rtc::Network*> networks;
|
||||
std::vector<const rtc::Network*> networks;
|
||||
rtc::NetworkManager* network_manager = allocator_->network_manager();
|
||||
RTC_DCHECK(network_manager != nullptr);
|
||||
// If the network permission state is BLOCKED, we just act as if the flag has
|
||||
@ -712,35 +714,41 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
||||
// traffic by OS is also used here to avoid any local or public IP leakage
|
||||
// during stun process.
|
||||
if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) {
|
||||
network_manager->GetAnyAddressNetworks(&networks);
|
||||
networks = network_manager->GetAnyAddressNetworks();
|
||||
} else {
|
||||
network_manager->GetNetworks(&networks);
|
||||
networks = network_manager->GetNetworks();
|
||||
// If network enumeration fails, use the ANY address as a fallback, so we
|
||||
// can at least try gathering candidates using the default route chosen by
|
||||
// the OS. Or, if the PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS flag is
|
||||
// set, we'll use ANY address candidates either way.
|
||||
if (networks.empty() || flags() & PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS) {
|
||||
network_manager->GetAnyAddressNetworks(&networks);
|
||||
if (networks.empty() ||
|
||||
(flags() & PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS)) {
|
||||
std::vector<const rtc::Network*> any_address_networks =
|
||||
network_manager->GetAnyAddressNetworks();
|
||||
networks.insert(networks.end(), any_address_networks.begin(),
|
||||
any_address_networks.end());
|
||||
}
|
||||
}
|
||||
// Filter out link-local networks if needed.
|
||||
if (flags() & PORTALLOCATOR_DISABLE_LINK_LOCAL_NETWORKS) {
|
||||
NetworkFilter link_local_filter(
|
||||
[](rtc::Network* network) { return IPIsLinkLocal(network->prefix()); },
|
||||
[](const rtc::Network* network) {
|
||||
return IPIsLinkLocal(network->prefix());
|
||||
},
|
||||
"link-local");
|
||||
FilterNetworks(&networks, link_local_filter);
|
||||
}
|
||||
// Do some more filtering, depending on the network ignore mask and "disable
|
||||
// costly networks" flag.
|
||||
NetworkFilter ignored_filter(
|
||||
[this](rtc::Network* network) {
|
||||
[this](const rtc::Network* network) {
|
||||
return allocator_->GetNetworkIgnoreMask() & network->type();
|
||||
},
|
||||
"ignored");
|
||||
FilterNetworks(&networks, ignored_filter);
|
||||
if (flags() & PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) {
|
||||
uint16_t lowest_cost = rtc::kNetworkCostMax;
|
||||
for (rtc::Network* network : networks) {
|
||||
for (const rtc::Network* network : networks) {
|
||||
// Don't determine the lowest cost from a link-local network.
|
||||
// On iOS, a device connected to the computer will get a link-local
|
||||
// network for communicating with the computer, however this network can't
|
||||
@ -751,7 +759,7 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
||||
lowest_cost = std::min<uint16_t>(lowest_cost, network->GetCost());
|
||||
}
|
||||
NetworkFilter costly_filter(
|
||||
[lowest_cost](rtc::Network* network) {
|
||||
[lowest_cost](const rtc::Network* network) {
|
||||
return network->GetCost() > lowest_cost + rtc::kNetworkCostLow;
|
||||
},
|
||||
"costly");
|
||||
@ -786,7 +794,7 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
||||
void BasicPortAllocatorSession::DoAllocate(bool disable_equivalent) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
bool done_signal_needed = false;
|
||||
std::vector<rtc::Network*> networks = GetNetworks();
|
||||
std::vector<const rtc::Network*> networks = GetNetworks();
|
||||
if (networks.empty()) {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< "Machine has no networks; no ports will be allocated";
|
||||
@ -853,8 +861,8 @@ void BasicPortAllocatorSession::DoAllocate(bool disable_equivalent) {
|
||||
|
||||
void BasicPortAllocatorSession::OnNetworksChanged() {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
std::vector<rtc::Network*> networks = GetNetworks();
|
||||
std::vector<rtc::Network*> failed_networks;
|
||||
std::vector<const rtc::Network*> networks = GetNetworks();
|
||||
std::vector<const rtc::Network*> failed_networks;
|
||||
for (AllocationSequence* sequence : sequences_) {
|
||||
// Mark the sequence as "network failed" if its network is not in
|
||||
// `networks`.
|
||||
@ -887,7 +895,7 @@ void BasicPortAllocatorSession::OnNetworksChanged() {
|
||||
}
|
||||
|
||||
void BasicPortAllocatorSession::DisableEquivalentPhases(
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
PortConfiguration* config,
|
||||
uint32_t* flags) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
@ -1200,7 +1208,7 @@ BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort(
|
||||
|
||||
std::vector<BasicPortAllocatorSession::PortData*>
|
||||
BasicPortAllocatorSession::GetUnprunedPorts(
|
||||
const std::vector<rtc::Network*>& networks) {
|
||||
const std::vector<const rtc::Network*>& networks) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
std::vector<PortData*> unpruned_ports;
|
||||
for (PortData& port : ports_) {
|
||||
@ -1247,7 +1255,7 @@ void BasicPortAllocator::SetVpnList(
|
||||
|
||||
AllocationSequence::AllocationSequence(
|
||||
BasicPortAllocatorSession* session,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
PortConfiguration* config,
|
||||
uint32_t flags,
|
||||
std::function<void()> port_allocation_complete_callback)
|
||||
@ -1289,7 +1297,7 @@ void AllocationSequence::OnNetworkFailed() {
|
||||
Stop();
|
||||
}
|
||||
|
||||
void AllocationSequence::DisableEquivalentPhases(rtc::Network* network,
|
||||
void AllocationSequence::DisableEquivalentPhases(const rtc::Network* network,
|
||||
PortConfiguration* config,
|
||||
uint32_t* flags) {
|
||||
if (network_failed_) {
|
||||
|
||||
@ -236,7 +236,7 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession {
|
||||
void DoAllocate(bool disable_equivalent_phases);
|
||||
void OnNetworksChanged();
|
||||
void OnAllocationSequenceObjectsCreated();
|
||||
void DisableEquivalentPhases(rtc::Network* network,
|
||||
void DisableEquivalentPhases(const rtc::Network* network,
|
||||
PortConfiguration* config,
|
||||
uint32_t* flags);
|
||||
void AddAllocatedPort(Port* port, AllocationSequence* seq);
|
||||
@ -249,9 +249,9 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession {
|
||||
void MaybeSignalCandidatesAllocationDone();
|
||||
void OnPortAllocationComplete();
|
||||
PortData* FindPort(Port* port);
|
||||
std::vector<rtc::Network*> GetNetworks();
|
||||
std::vector<rtc::Network*> GetFailedNetworks();
|
||||
void Regather(const std::vector<rtc::Network*>& networks,
|
||||
std::vector<const rtc::Network*> GetNetworks();
|
||||
std::vector<const rtc::Network*> GetFailedNetworks();
|
||||
void Regather(const std::vector<const rtc::Network*>& networks,
|
||||
bool disable_equivalent_phases,
|
||||
IceRegatheringReason reason);
|
||||
|
||||
@ -259,7 +259,7 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession {
|
||||
bool CandidatePairable(const Candidate& c, const Port* port) const;
|
||||
|
||||
std::vector<PortData*> GetUnprunedPorts(
|
||||
const std::vector<rtc::Network*>& networks);
|
||||
const std::vector<const rtc::Network*>& networks);
|
||||
// Prunes ports and signal the remote side to remove the candidates that
|
||||
// were previously signaled from these ports.
|
||||
void PrunePortsAndRemoveCandidates(
|
||||
@ -352,7 +352,7 @@ class AllocationSequence : public sigslot::has_slots<> {
|
||||
// event to trigger signal. This can also be achieved by starting a timer in
|
||||
// BPAS, but this is less deterministic.
|
||||
AllocationSequence(BasicPortAllocatorSession* session,
|
||||
rtc::Network* network,
|
||||
const rtc::Network* network,
|
||||
PortConfiguration* config,
|
||||
uint32_t flags,
|
||||
std::function<void()> port_allocation_complete_callback);
|
||||
@ -361,14 +361,14 @@ class AllocationSequence : public sigslot::has_slots<> {
|
||||
void OnNetworkFailed();
|
||||
|
||||
State state() const { return state_; }
|
||||
rtc::Network* network() const { return network_; }
|
||||
const rtc::Network* network() const { return network_; }
|
||||
|
||||
bool network_failed() const { return network_failed_; }
|
||||
void set_network_failed() { network_failed_ = true; }
|
||||
|
||||
// Disables the phases for a new sequence that this one already covers for an
|
||||
// equivalent network setup.
|
||||
void DisableEquivalentPhases(rtc::Network* network,
|
||||
void DisableEquivalentPhases(const rtc::Network* network,
|
||||
PortConfiguration* config,
|
||||
uint32_t* flags);
|
||||
|
||||
@ -401,7 +401,7 @@ class AllocationSequence : public sigslot::has_slots<> {
|
||||
|
||||
BasicPortAllocatorSession* session_;
|
||||
bool network_failed_ = false;
|
||||
rtc::Network* network_;
|
||||
const rtc::Network* network_;
|
||||
// Compared with the new best IP in DisableEquivalentPhases.
|
||||
rtc::IPAddress previous_best_ip_;
|
||||
PortConfiguration* config_;
|
||||
|
||||
@ -38,7 +38,7 @@ struct RelayServerConfig;
|
||||
struct CreateRelayPortArgs {
|
||||
rtc::Thread* network_thread;
|
||||
rtc::PacketSocketFactory* socket_factory;
|
||||
rtc::Network* network;
|
||||
const rtc::Network* network;
|
||||
const ProtocolAddress* server_address;
|
||||
const RelayServerConfig* config;
|
||||
std::string username;
|
||||
|
||||
@ -228,7 +228,7 @@ void TestPhysicalInternal(const SocketAddress& int_addr) {
|
||||
std::vector<Network*> networks;
|
||||
network_manager.GetNetworks(&networks);
|
||||
networks.erase(std::remove_if(networks.begin(), networks.end(),
|
||||
[](rtc::Network* network) {
|
||||
[](const rtc::Network* network) {
|
||||
return rtc::kDefaultNetworkIgnoreMask &
|
||||
network->type();
|
||||
}),
|
||||
|
||||
@ -149,6 +149,15 @@ class RTC_EXPORT NetworkManager : public DefaultLocalAddressProvider,
|
||||
// It makes sure that repeated calls return the same object for a
|
||||
// given network, so that quality is tracked appropriately. Does not
|
||||
// include ignored networks.
|
||||
virtual std::vector<const Network*> GetNetworks() const {
|
||||
std::vector<Network*> networks;
|
||||
std::vector<const Network*> const_networks;
|
||||
GetNetworks(&networks);
|
||||
const_networks.insert(const_networks.begin(), networks.begin(),
|
||||
networks.end());
|
||||
return const_networks;
|
||||
}
|
||||
// TODO(bugs.webrtc.org/13869): Delete this overload.
|
||||
virtual void GetNetworks(NetworkList* networks) const = 0;
|
||||
|
||||
// Returns the current permission state of GetNetworks().
|
||||
@ -163,6 +172,15 @@ class RTC_EXPORT NetworkManager : public DefaultLocalAddressProvider,
|
||||
// can optionally be called after GetNetworks.
|
||||
//
|
||||
// TODO(guoweis): remove this body when chromium implements this.
|
||||
virtual std::vector<const Network*> GetAnyAddressNetworks() {
|
||||
std::vector<Network*> networks;
|
||||
std::vector<const Network*> const_networks;
|
||||
GetAnyAddressNetworks(&networks);
|
||||
const_networks.insert(const_networks.begin(), networks.begin(),
|
||||
networks.end());
|
||||
return const_networks;
|
||||
}
|
||||
// TODO(bugs.webrtc.org/13869): Delete this overload.
|
||||
virtual void GetAnyAddressNetworks(NetworkList* networks) {}
|
||||
|
||||
// Dumps the current list of networks in the network manager.
|
||||
@ -365,12 +383,14 @@ class RTC_EXPORT Network {
|
||||
~Network();
|
||||
|
||||
// This signal is fired whenever type() or underlying_type_for_vpn() changes.
|
||||
sigslot::signal1<const Network*> SignalTypeChanged;
|
||||
// Mutable, to support connecting on the const Network passed to cricket::Port
|
||||
// constructor.
|
||||
mutable sigslot::signal1<const Network*> SignalTypeChanged;
|
||||
|
||||
// This signal is fired whenever network preference changes.
|
||||
sigslot::signal1<const Network*> SignalNetworkPreferenceChanged;
|
||||
|
||||
const DefaultLocalAddressProvider* default_local_address_provider() {
|
||||
const DefaultLocalAddressProvider* default_local_address_provider() const {
|
||||
return default_local_address_provider_;
|
||||
}
|
||||
void set_default_local_address_provider(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user