Make Port constructor take a CreatePortArgs argument
Introduces a struct CreatePortArgs that is similar to the existing CreateRelayPortArgs and contains parameters that will be passed from the constructors of descendents of the Port class to the Port. This struct makes it easier to add new arguments to the port constructor without changing all inheriting classes. Rebase of https://webrtc-review.googlesource.com/c/src/+/341021 BUG=webrtc:14626 Change-Id: Id8e5c24a36149e1699e2b42c57e52002d27c86c8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/345860 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Philipp Hancke <phancke@meta.com> Cr-Commit-Position: refs/heads/main@{#42339}
This commit is contained in:
parent
87976eb7e1
commit
833ec4d123
@ -736,7 +736,9 @@ rtc_library("port_interface") {
|
|||||||
deps = [
|
deps = [
|
||||||
":transport_description",
|
":transport_description",
|
||||||
"../api:candidate",
|
"../api:candidate",
|
||||||
|
"../api:field_trials_view",
|
||||||
"../api:packet_socket_factory",
|
"../api:packet_socket_factory",
|
||||||
|
"../api/task_queue:task_queue",
|
||||||
"../rtc_base:async_packet_socket",
|
"../rtc_base:async_packet_socket",
|
||||||
"../rtc_base:callback_list",
|
"../rtc_base:callback_list",
|
||||||
"../rtc_base:socket_address",
|
"../rtc_base:socket_address",
|
||||||
|
|||||||
@ -34,18 +34,12 @@ namespace cricket {
|
|||||||
|
|
||||||
class TestUDPPort : public UDPPort {
|
class TestUDPPort : public UDPPort {
|
||||||
public:
|
public:
|
||||||
static TestUDPPort* Create(rtc::Thread* thread,
|
static TestUDPPort* Create(const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
bool emit_localhost_for_anyaddress) {
|
||||||
absl::string_view password,
|
TestUDPPort* port = new TestUDPPort(args, min_port, max_port,
|
||||||
bool emit_localhost_for_anyaddress,
|
emit_localhost_for_anyaddress);
|
||||||
const webrtc::FieldTrialsView* field_trials) {
|
|
||||||
TestUDPPort* port =
|
|
||||||
new TestUDPPort(thread, factory, network, min_port, max_port, username,
|
|
||||||
password, emit_localhost_for_anyaddress, field_trials);
|
|
||||||
if (!port->Init()) {
|
if (!port->Init()) {
|
||||||
delete port;
|
delete port;
|
||||||
port = nullptr;
|
port = nullptr;
|
||||||
@ -54,25 +48,15 @@ class TestUDPPort : public UDPPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TestUDPPort(rtc::Thread* thread,
|
TestUDPPort(const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
bool emit_localhost_for_anyaddress)
|
||||||
absl::string_view password,
|
: UDPPort(args,
|
||||||
bool emit_localhost_for_anyaddress,
|
|
||||||
const webrtc::FieldTrialsView* field_trials)
|
|
||||||
: UDPPort(thread,
|
|
||||||
webrtc::IceCandidateType::kHost,
|
webrtc::IceCandidateType::kHost,
|
||||||
factory,
|
|
||||||
network,
|
|
||||||
min_port,
|
min_port,
|
||||||
max_port,
|
max_port,
|
||||||
username,
|
emit_localhost_for_anyaddress) {}
|
||||||
password,
|
|
||||||
emit_localhost_for_anyaddress,
|
|
||||||
field_trials) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A FakePortAllocatorSession can be used with either a real or fake socket
|
// A FakePortAllocatorSession can be used with either a real or fake socket
|
||||||
@ -123,9 +107,13 @@ class FakePortAllocatorSession : public PortAllocatorSession {
|
|||||||
(rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6))
|
(rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6))
|
||||||
? ipv6_network_
|
? ipv6_network_
|
||||||
: ipv4_network_;
|
: ipv4_network_;
|
||||||
port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, 0, 0,
|
port_.reset(TestUDPPort::Create({.network_thread = network_thread_,
|
||||||
username(), password(), false,
|
.socket_factory = factory_,
|
||||||
field_trials_));
|
.network = &network,
|
||||||
|
.ice_username_fragment = username(),
|
||||||
|
.ice_password = password(),
|
||||||
|
.field_trials = field_trials_},
|
||||||
|
0, 0, false));
|
||||||
RTC_DCHECK(port_);
|
RTC_DCHECK(port_);
|
||||||
port_->SetIceTiebreaker(allocator_->ice_tiebreaker());
|
port_->SetIceTiebreaker(allocator_->ice_tiebreaker());
|
||||||
port_->SubscribePortDestroyed(
|
port_->SubscribePortDestroyed(
|
||||||
|
|||||||
@ -95,52 +95,32 @@ const char TCPTYPE_ACTIVE_STR[] = "active";
|
|||||||
const char TCPTYPE_PASSIVE_STR[] = "passive";
|
const char TCPTYPE_PASSIVE_STR[] = "passive";
|
||||||
const char TCPTYPE_SIMOPEN_STR[] = "so";
|
const char TCPTYPE_SIMOPEN_STR[] = "so";
|
||||||
|
|
||||||
Port::Port(TaskQueueBase* thread,
|
Port::Port(const PortParametersRef& args, webrtc::IceCandidateType type)
|
||||||
webrtc::IceCandidateType type,
|
: Port(args, type, 0, 0, true) {}
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
absl::string_view username_fragment,
|
|
||||||
absl::string_view password,
|
|
||||||
const webrtc::FieldTrialsView* field_trials)
|
|
||||||
: Port(thread,
|
|
||||||
type,
|
|
||||||
factory,
|
|
||||||
network,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
username_fragment,
|
|
||||||
password,
|
|
||||||
field_trials,
|
|
||||||
true) {}
|
|
||||||
|
|
||||||
Port::Port(TaskQueueBase* thread,
|
Port::Port(const PortParametersRef& args,
|
||||||
webrtc::IceCandidateType type,
|
webrtc::IceCandidateType type,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username_fragment,
|
|
||||||
absl::string_view password,
|
|
||||||
const webrtc::FieldTrialsView* field_trials,
|
|
||||||
bool shared_socket /*= false*/)
|
bool shared_socket /*= false*/)
|
||||||
: thread_(thread),
|
: thread_(args.network_thread),
|
||||||
factory_(factory),
|
factory_(args.socket_factory),
|
||||||
field_trials_(field_trials),
|
field_trials_(args.field_trials),
|
||||||
type_(type),
|
type_(type),
|
||||||
send_retransmit_count_attribute_(false),
|
send_retransmit_count_attribute_(false),
|
||||||
network_(network),
|
network_(args.network),
|
||||||
min_port_(min_port),
|
min_port_(min_port),
|
||||||
max_port_(max_port),
|
max_port_(max_port),
|
||||||
component_(ICE_CANDIDATE_COMPONENT_DEFAULT),
|
component_(ICE_CANDIDATE_COMPONENT_DEFAULT),
|
||||||
generation_(0),
|
generation_(0),
|
||||||
ice_username_fragment_(username_fragment),
|
ice_username_fragment_(args.ice_username_fragment),
|
||||||
password_(password),
|
password_(args.ice_password),
|
||||||
timeout_delay_(kPortTimeoutDelay),
|
timeout_delay_(kPortTimeoutDelay),
|
||||||
enable_port_packets_(false),
|
enable_port_packets_(false),
|
||||||
ice_role_(ICEROLE_UNKNOWN),
|
ice_role_(ICEROLE_UNKNOWN),
|
||||||
tiebreaker_(0),
|
tiebreaker_(0),
|
||||||
shared_socket_(shared_socket),
|
shared_socket_(shared_socket),
|
||||||
network_cost_(network->GetCost(*field_trials_)),
|
network_cost_(args.network->GetCost(*field_trials_)),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
RTC_DCHECK_RUN_ON(thread_);
|
RTC_DCHECK_RUN_ON(thread_);
|
||||||
RTC_DCHECK(factory_ != nullptr);
|
RTC_DCHECK(factory_ != nullptr);
|
||||||
@ -159,6 +139,42 @@ Port::Port(TaskQueueBase* thread,
|
|||||||
<< network_cost_;
|
<< network_cost_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Port::Port(TaskQueueBase* thread,
|
||||||
|
webrtc::IceCandidateType type,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
absl::string_view username_fragment,
|
||||||
|
absl::string_view password,
|
||||||
|
const webrtc::FieldTrialsView* field_trials)
|
||||||
|
: Port({.network_thread = thread,
|
||||||
|
.socket_factory = factory,
|
||||||
|
.network = network,
|
||||||
|
.ice_username_fragment = username_fragment,
|
||||||
|
.ice_password = password,
|
||||||
|
.field_trials = field_trials},
|
||||||
|
type) {}
|
||||||
|
|
||||||
|
Port::Port(TaskQueueBase* thread,
|
||||||
|
webrtc::IceCandidateType type,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
uint16_t min_port,
|
||||||
|
uint16_t max_port,
|
||||||
|
absl::string_view username_fragment,
|
||||||
|
absl::string_view password,
|
||||||
|
const webrtc::FieldTrialsView* field_trials,
|
||||||
|
bool shared_socket /*= false*/)
|
||||||
|
: Port({.network_thread = thread,
|
||||||
|
.socket_factory = factory,
|
||||||
|
.network = network,
|
||||||
|
.ice_username_fragment = username_fragment,
|
||||||
|
.ice_password = password,
|
||||||
|
.field_trials = field_trials},
|
||||||
|
type,
|
||||||
|
min_port,
|
||||||
|
max_port,
|
||||||
|
shared_socket) {}
|
||||||
|
|
||||||
Port::~Port() {
|
Port::~Port() {
|
||||||
RTC_DCHECK_RUN_ON(thread_);
|
RTC_DCHECK_RUN_ON(thread_);
|
||||||
DestroyAllConnections();
|
DestroyAllConnections();
|
||||||
|
|||||||
@ -170,25 +170,45 @@ typedef std::set<rtc::SocketAddress> ServerAddresses;
|
|||||||
// connections to similar mechanisms of the other client. Subclasses of this
|
// connections to similar mechanisms of the other client. Subclasses of this
|
||||||
// one add support for specific mechanisms like local UDP ports.
|
// one add support for specific mechanisms like local UDP ports.
|
||||||
class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
|
class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
|
||||||
|
public:
|
||||||
|
// A struct containing common arguments to creating a port. See also
|
||||||
|
// CreateRelayPortArgs.
|
||||||
|
struct PortParametersRef {
|
||||||
|
webrtc::TaskQueueBase* network_thread;
|
||||||
|
rtc::PacketSocketFactory* socket_factory;
|
||||||
|
const rtc::Network* network;
|
||||||
|
absl::string_view ice_username_fragment;
|
||||||
|
absl::string_view ice_password;
|
||||||
|
const webrtc::FieldTrialsView* field_trials;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Constructors for use only by via constructors in derived classes.
|
// Constructors for use only by via constructors in derived classes.
|
||||||
Port(webrtc::TaskQueueBase* thread,
|
Port(const PortParametersRef& args, webrtc::IceCandidateType type);
|
||||||
|
Port(const PortParametersRef& args,
|
||||||
webrtc::IceCandidateType type,
|
webrtc::IceCandidateType type,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
absl::string_view username_fragment,
|
|
||||||
absl::string_view password,
|
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr);
|
|
||||||
Port(webrtc::TaskQueueBase* thread,
|
|
||||||
webrtc::IceCandidateType type,
|
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username_fragment,
|
|
||||||
absl::string_view password,
|
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr,
|
|
||||||
bool shared_socket = false);
|
bool shared_socket = false);
|
||||||
|
[[deprecated("Pass arguments using PortParametersRef")]] Port(
|
||||||
|
webrtc::TaskQueueBase* thread,
|
||||||
|
webrtc::IceCandidateType type,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
absl::string_view username_fragment,
|
||||||
|
absl::string_view password,
|
||||||
|
const webrtc::FieldTrialsView* field_trials = nullptr);
|
||||||
|
[[deprecated("Pass arguments using PortParametersRef")]] Port(
|
||||||
|
webrtc::TaskQueueBase* thread,
|
||||||
|
webrtc::IceCandidateType type,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
uint16_t min_port,
|
||||||
|
uint16_t max_port,
|
||||||
|
absl::string_view username_fragment,
|
||||||
|
absl::string_view password,
|
||||||
|
const webrtc::FieldTrialsView* field_trials = nullptr,
|
||||||
|
bool shared_socket = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Port() override;
|
~Port() override;
|
||||||
|
|||||||
@ -19,7 +19,9 @@
|
|||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/candidate.h"
|
#include "api/candidate.h"
|
||||||
|
#include "api/field_trials_view.h"
|
||||||
#include "api/packet_socket_factory.h"
|
#include "api/packet_socket_factory.h"
|
||||||
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "p2p/base/transport_description.h"
|
#include "p2p/base/transport_description.h"
|
||||||
#include "rtc_base/async_packet_socket.h"
|
#include "rtc_base/async_packet_socket.h"
|
||||||
#include "rtc_base/callback_list.h"
|
#include "rtc_base/callback_list.h"
|
||||||
|
|||||||
@ -140,23 +140,8 @@ bool WriteStunMessage(const StunMessage& msg, ByteBufferWriter* buf) {
|
|||||||
// Stub port class for testing STUN generation and processing.
|
// Stub port class for testing STUN generation and processing.
|
||||||
class TestPort : public Port {
|
class TestPort : public Port {
|
||||||
public:
|
public:
|
||||||
TestPort(rtc::Thread* thread,
|
TestPort(const PortParametersRef& args, uint16_t min_port, uint16_t max_port)
|
||||||
rtc::PacketSocketFactory* factory,
|
: Port(args, IceCandidateType::kHost, min_port, max_port) {}
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
|
||||||
uint16_t max_port,
|
|
||||||
absl::string_view username_fragment,
|
|
||||||
absl::string_view password,
|
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr)
|
|
||||||
: Port(thread,
|
|
||||||
IceCandidateType::kHost,
|
|
||||||
factory,
|
|
||||||
network,
|
|
||||||
min_port,
|
|
||||||
max_port,
|
|
||||||
username_fragment,
|
|
||||||
password,
|
|
||||||
field_trials) {}
|
|
||||||
~TestPort() {}
|
~TestPort() {}
|
||||||
|
|
||||||
// Expose GetStunMessage so that we can test it.
|
// Expose GetStunMessage so that we can test it.
|
||||||
@ -550,9 +535,13 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
}
|
}
|
||||||
std::unique_ptr<UDPPort> CreateUdpPort(const SocketAddress& addr,
|
std::unique_ptr<UDPPort> CreateUdpPort(const SocketAddress& addr,
|
||||||
PacketSocketFactory* socket_factory) {
|
PacketSocketFactory* socket_factory) {
|
||||||
auto port = UDPPort::Create(&main_, socket_factory, MakeNetwork(addr), 0, 0,
|
auto port = UDPPort::Create({.network_thread = &main_,
|
||||||
username_, password_, true, absl::nullopt,
|
.socket_factory = socket_factory,
|
||||||
&field_trials_);
|
.network = MakeNetwork(addr),
|
||||||
|
.ice_username_fragment = username_,
|
||||||
|
.ice_password = password_,
|
||||||
|
.field_trials = &field_trials_},
|
||||||
|
0, 0, true, absl::nullopt);
|
||||||
port->SetIceTiebreaker(kTiebreakerDefault);
|
port->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
@ -562,9 +551,13 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
const SocketAddress& link_local_addr,
|
const SocketAddress& link_local_addr,
|
||||||
PacketSocketFactory* socket_factory) {
|
PacketSocketFactory* socket_factory) {
|
||||||
auto port = UDPPort::Create(
|
auto port = UDPPort::Create(
|
||||||
&main_, socket_factory,
|
{.network_thread = &main_,
|
||||||
MakeNetworkMultipleAddrs(global_addr, link_local_addr), 0, 0, username_,
|
.socket_factory = socket_factory,
|
||||||
password_, true, absl::nullopt, &field_trials_);
|
.network = MakeNetworkMultipleAddrs(global_addr, link_local_addr),
|
||||||
|
.ice_username_fragment = username_,
|
||||||
|
.ice_password = password_,
|
||||||
|
.field_trials = &field_trials_},
|
||||||
|
0, 0, true, absl::nullopt);
|
||||||
port->SetIceTiebreaker(kTiebreakerDefault);
|
port->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
@ -573,18 +566,28 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
}
|
}
|
||||||
std::unique_ptr<TCPPort> CreateTcpPort(const SocketAddress& addr,
|
std::unique_ptr<TCPPort> CreateTcpPort(const SocketAddress& addr,
|
||||||
PacketSocketFactory* socket_factory) {
|
PacketSocketFactory* socket_factory) {
|
||||||
auto port = TCPPort::Create(&main_, socket_factory, MakeNetwork(addr), 0, 0,
|
auto port = TCPPort::Create({.network_thread = &main_,
|
||||||
username_, password_, true, &field_trials_);
|
.socket_factory = socket_factory,
|
||||||
|
.network = MakeNetwork(addr),
|
||||||
|
.ice_username_fragment = username_,
|
||||||
|
.ice_password = password_,
|
||||||
|
.field_trials = &field_trials_},
|
||||||
|
0, 0, true);
|
||||||
port->SetIceTiebreaker(kTiebreakerDefault);
|
port->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
std::unique_ptr<StunPort> CreateStunPort(const SocketAddress& addr,
|
std::unique_ptr<StunPort> CreateStunPort(
|
||||||
rtc::PacketSocketFactory* factory) {
|
const SocketAddress& addr,
|
||||||
|
rtc::PacketSocketFactory* socket_factory) {
|
||||||
ServerAddresses stun_servers;
|
ServerAddresses stun_servers;
|
||||||
stun_servers.insert(kStunAddr);
|
stun_servers.insert(kStunAddr);
|
||||||
auto port = StunPort::Create(&main_, factory, MakeNetwork(addr), 0, 0,
|
auto port = StunPort::Create({.network_thread = &main_,
|
||||||
username_, password_, stun_servers,
|
.socket_factory = socket_factory,
|
||||||
absl::nullopt, &field_trials_);
|
.network = MakeNetwork(addr),
|
||||||
|
.ice_username_fragment = username_,
|
||||||
|
.ice_password = password_,
|
||||||
|
.field_trials = &field_trials_},
|
||||||
|
0, 0, stun_servers, absl::nullopt);
|
||||||
port->SetIceTiebreaker(kTiebreakerDefault);
|
port->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
@ -824,9 +827,13 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
absl::string_view username,
|
absl::string_view username,
|
||||||
absl::string_view password,
|
absl::string_view password,
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
||||||
auto port =
|
Port::PortParametersRef args = {.network_thread = &main_,
|
||||||
std::make_unique<TestPort>(&main_, &socket_factory_, MakeNetwork(addr),
|
.socket_factory = &socket_factory_,
|
||||||
0, 0, username, password, field_trials);
|
.network = MakeNetwork(addr),
|
||||||
|
.ice_username_fragment = username,
|
||||||
|
.ice_password = password,
|
||||||
|
.field_trials = field_trials};
|
||||||
|
auto port = std::make_unique<TestPort>(args, 0, 0);
|
||||||
port->SignalRoleConflict.connect(this, &PortTest::OnRoleConflict);
|
port->SignalRoleConflict.connect(this, &PortTest::OnRoleConflict);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
@ -844,8 +851,13 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
std::unique_ptr<TestPort> CreateTestPort(const rtc::Network* network,
|
std::unique_ptr<TestPort> CreateTestPort(const rtc::Network* network,
|
||||||
absl::string_view username,
|
absl::string_view username,
|
||||||
absl::string_view password) {
|
absl::string_view password) {
|
||||||
auto port = std::make_unique<TestPort>(&main_, &socket_factory_, network, 0,
|
Port::PortParametersRef args = {.network_thread = &main_,
|
||||||
0, username, password);
|
.socket_factory = &socket_factory_,
|
||||||
|
.network = network,
|
||||||
|
.ice_username_fragment = username,
|
||||||
|
.ice_password = password,
|
||||||
|
.field_trials = nullptr};
|
||||||
|
auto port = std::make_unique<TestPort>(args, 0, 0);
|
||||||
port->SignalRoleConflict.connect(this, &PortTest::OnRoleConflict);
|
port->SignalRoleConflict.connect(this, &PortTest::OnRoleConflict);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -159,18 +159,13 @@ bool UDPPort::AddressResolver::GetResolvedAddress(
|
|||||||
return it->second->result().GetResolvedAddress(family, output);
|
return it->second->result().GetResolvedAddress(family, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPPort::UDPPort(rtc::Thread* thread,
|
UDPPort::UDPPort(const PortParametersRef& args,
|
||||||
webrtc::IceCandidateType type,
|
webrtc::IceCandidateType type,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
rtc::AsyncPacketSocket* socket,
|
rtc::AsyncPacketSocket* socket,
|
||||||
absl::string_view username,
|
bool emit_local_for_anyaddress)
|
||||||
absl::string_view password,
|
: Port(args, type),
|
||||||
bool emit_local_for_anyaddress,
|
|
||||||
const webrtc::FieldTrialsView* field_trials)
|
|
||||||
: Port(thread, type, factory, network, username, password, field_trials),
|
|
||||||
request_manager_(
|
request_manager_(
|
||||||
thread,
|
args.network_thread,
|
||||||
[this](const void* data, size_t size, StunRequest* request) {
|
[this](const void* data, size_t size, StunRequest* request) {
|
||||||
OnSendPacket(data, size, request);
|
OnSendPacket(data, size, request);
|
||||||
}),
|
}),
|
||||||
@ -181,27 +176,14 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
|||||||
dscp_(rtc::DSCP_NO_CHANGE),
|
dscp_(rtc::DSCP_NO_CHANGE),
|
||||||
emit_local_for_anyaddress_(emit_local_for_anyaddress) {}
|
emit_local_for_anyaddress_(emit_local_for_anyaddress) {}
|
||||||
|
|
||||||
UDPPort::UDPPort(rtc::Thread* thread,
|
UDPPort::UDPPort(const PortParametersRef& args,
|
||||||
webrtc::IceCandidateType type,
|
webrtc::IceCandidateType type,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
bool emit_local_for_anyaddress)
|
||||||
absl::string_view password,
|
: Port(args, type, min_port, max_port),
|
||||||
bool emit_local_for_anyaddress,
|
|
||||||
const webrtc::FieldTrialsView* field_trials)
|
|
||||||
: Port(thread,
|
|
||||||
type,
|
|
||||||
factory,
|
|
||||||
network,
|
|
||||||
min_port,
|
|
||||||
max_port,
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
field_trials),
|
|
||||||
request_manager_(
|
request_manager_(
|
||||||
thread,
|
args.network_thread,
|
||||||
[this](const void* data, size_t size, StunRequest* request) {
|
[this](const void* data, size_t size, StunRequest* request) {
|
||||||
OnSendPacket(data, size, request);
|
OnSendPacket(data, size, request);
|
||||||
}),
|
}),
|
||||||
@ -624,7 +606,22 @@ bool UDPPort::HasStunCandidateWithAddress(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<StunPort> StunPort::Create(
|
std::unique_ptr<StunPort> StunPort::Create(
|
||||||
rtc::Thread* thread,
|
const PortParametersRef& args,
|
||||||
|
uint16_t min_port,
|
||||||
|
uint16_t max_port,
|
||||||
|
const ServerAddresses& servers,
|
||||||
|
absl::optional<int> stun_keepalive_interval) {
|
||||||
|
// Using `new` to access a non-public constructor.
|
||||||
|
auto port = absl::WrapUnique(new StunPort(args, min_port, max_port, servers));
|
||||||
|
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
||||||
|
if (!port->Init()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<StunPort> StunPort::Create(
|
||||||
|
webrtc::TaskQueueBase* thread,
|
||||||
rtc::PacketSocketFactory* factory,
|
rtc::PacketSocketFactory* factory,
|
||||||
const rtc::Network* network,
|
const rtc::Network* network,
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
@ -634,36 +631,24 @@ std::unique_ptr<StunPort> StunPort::Create(
|
|||||||
const ServerAddresses& servers,
|
const ServerAddresses& servers,
|
||||||
absl::optional<int> stun_keepalive_interval,
|
absl::optional<int> stun_keepalive_interval,
|
||||||
const webrtc::FieldTrialsView* field_trials) {
|
const webrtc::FieldTrialsView* field_trials) {
|
||||||
// Using `new` to access a non-public constructor.
|
return Create({.network_thread = thread,
|
||||||
auto port = absl::WrapUnique(new StunPort(thread, factory, network, min_port,
|
.socket_factory = factory,
|
||||||
max_port, username, password,
|
.network = network,
|
||||||
servers, field_trials));
|
.ice_username_fragment = username,
|
||||||
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
.ice_password = password,
|
||||||
if (!port->Init()) {
|
.field_trials = field_trials},
|
||||||
return nullptr;
|
min_port, max_port, servers, stun_keepalive_interval);
|
||||||
}
|
|
||||||
return port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StunPort::StunPort(rtc::Thread* thread,
|
StunPort::StunPort(const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
const ServerAddresses& servers)
|
||||||
absl::string_view password,
|
: UDPPort(args,
|
||||||
const ServerAddresses& servers,
|
|
||||||
const webrtc::FieldTrialsView* field_trials)
|
|
||||||
: UDPPort(thread,
|
|
||||||
webrtc::IceCandidateType::kSrflx,
|
webrtc::IceCandidateType::kSrflx,
|
||||||
factory,
|
|
||||||
network,
|
|
||||||
min_port,
|
min_port,
|
||||||
max_port,
|
max_port,
|
||||||
username,
|
false) {
|
||||||
password,
|
|
||||||
false,
|
|
||||||
field_trials) {
|
|
||||||
set_server_addresses(servers);
|
set_server_addresses(servers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,47 +36,77 @@ static const int HIGH_COST_PORT_KEEPALIVE_LIFETIME = 2 * 60 * 1000;
|
|||||||
class RTC_EXPORT UDPPort : public Port {
|
class RTC_EXPORT UDPPort : public Port {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<UDPPort> Create(
|
static std::unique_ptr<UDPPort> Create(
|
||||||
rtc::Thread* thread,
|
const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
rtc::AsyncPacketSocket* socket,
|
rtc::AsyncPacketSocket* socket,
|
||||||
absl::string_view username,
|
|
||||||
absl::string_view password,
|
|
||||||
bool emit_local_for_anyaddress,
|
bool emit_local_for_anyaddress,
|
||||||
absl::optional<int> stun_keepalive_interval,
|
absl::optional<int> stun_keepalive_interval) {
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
|
||||||
// Using `new` to access a non-public constructor.
|
// Using `new` to access a non-public constructor.
|
||||||
auto port = absl::WrapUnique(new UDPPort(
|
auto port =
|
||||||
thread, webrtc::IceCandidateType::kHost, factory, network, socket,
|
absl::WrapUnique(new UDPPort(args, webrtc::IceCandidateType::kHost,
|
||||||
username, password, emit_local_for_anyaddress, field_trials));
|
socket, emit_local_for_anyaddress));
|
||||||
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
||||||
if (!port->Init()) {
|
if (!port->Init()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
[[deprecated("Pass arguments using PortParametersRef")]] static std::
|
||||||
|
unique_ptr<UDPPort>
|
||||||
|
Create(webrtc::TaskQueueBase* thread,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
rtc::AsyncPacketSocket* socket,
|
||||||
|
absl::string_view username,
|
||||||
|
absl::string_view password,
|
||||||
|
bool emit_local_for_anyaddress,
|
||||||
|
absl::optional<int> stun_keepalive_interval,
|
||||||
|
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
||||||
|
return Create({.network_thread = thread,
|
||||||
|
.socket_factory = factory,
|
||||||
|
.network = network,
|
||||||
|
.ice_username_fragment = username,
|
||||||
|
.ice_password = password,
|
||||||
|
.field_trials = field_trials},
|
||||||
|
socket, emit_local_for_anyaddress, stun_keepalive_interval);
|
||||||
|
}
|
||||||
|
|
||||||
static std::unique_ptr<UDPPort> Create(
|
static std::unique_ptr<UDPPort> Create(
|
||||||
rtc::Thread* thread,
|
const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
|
||||||
absl::string_view password,
|
|
||||||
bool emit_local_for_anyaddress,
|
bool emit_local_for_anyaddress,
|
||||||
absl::optional<int> stun_keepalive_interval,
|
absl::optional<int> stun_keepalive_interval) {
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
|
||||||
// Using `new` to access a non-public constructor.
|
// Using `new` to access a non-public constructor.
|
||||||
auto port = absl::WrapUnique(new UDPPort(
|
auto port = absl::WrapUnique(
|
||||||
thread, webrtc::IceCandidateType::kHost, factory, network, min_port,
|
new UDPPort(args, webrtc::IceCandidateType::kHost, min_port, max_port,
|
||||||
max_port, username, password, emit_local_for_anyaddress, field_trials));
|
emit_local_for_anyaddress));
|
||||||
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
||||||
if (!port->Init()) {
|
if (!port->Init()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
[[deprecated("Pass arguments using PortParametersRef")]] static std::
|
||||||
|
unique_ptr<UDPPort>
|
||||||
|
Create(webrtc::TaskQueueBase* thread,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
uint16_t min_port,
|
||||||
|
uint16_t max_port,
|
||||||
|
absl::string_view username,
|
||||||
|
absl::string_view password,
|
||||||
|
bool emit_local_for_anyaddress,
|
||||||
|
absl::optional<int> stun_keepalive_interval,
|
||||||
|
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
||||||
|
return Create({.network_thread = thread,
|
||||||
|
.socket_factory = factory,
|
||||||
|
.network = network,
|
||||||
|
.ice_username_fragment = username,
|
||||||
|
.ice_password = password,
|
||||||
|
.field_trials = field_trials},
|
||||||
|
min_port, max_port, emit_local_for_anyaddress,
|
||||||
|
stun_keepalive_interval);
|
||||||
|
}
|
||||||
|
|
||||||
~UDPPort() override;
|
~UDPPort() override;
|
||||||
|
|
||||||
@ -117,27 +147,15 @@ class RTC_EXPORT UDPPort : public Port {
|
|||||||
StunRequestManager& request_manager() { return request_manager_; }
|
StunRequestManager& request_manager() { return request_manager_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UDPPort(rtc::Thread* thread,
|
UDPPort(const PortParametersRef& args,
|
||||||
|
webrtc::IceCandidateType type,
|
||||||
|
rtc::AsyncPacketSocket* socket,
|
||||||
|
bool emit_local_for_anyaddress);
|
||||||
|
UDPPort(const PortParametersRef& args,
|
||||||
webrtc::IceCandidateType type,
|
webrtc::IceCandidateType type,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
bool emit_local_for_anyaddress);
|
||||||
absl::string_view password,
|
|
||||||
bool emit_local_for_anyaddress,
|
|
||||||
const webrtc::FieldTrialsView* field_trials);
|
|
||||||
|
|
||||||
UDPPort(rtc::Thread* thread,
|
|
||||||
webrtc::IceCandidateType type,
|
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
rtc::AsyncPacketSocket* socket,
|
|
||||||
absl::string_view username,
|
|
||||||
absl::string_view password,
|
|
||||||
bool emit_local_for_anyaddress,
|
|
||||||
const webrtc::FieldTrialsView* field_trials);
|
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
|
|
||||||
int SendTo(const void* data,
|
int SendTo(const void* data,
|
||||||
@ -268,29 +286,30 @@ class RTC_EXPORT UDPPort : public Port {
|
|||||||
class StunPort : public UDPPort {
|
class StunPort : public UDPPort {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<StunPort> Create(
|
static std::unique_ptr<StunPort> Create(
|
||||||
rtc::Thread* thread,
|
const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
|
||||||
absl::string_view password,
|
|
||||||
const ServerAddresses& servers,
|
const ServerAddresses& servers,
|
||||||
absl::optional<int> stun_keepalive_interval,
|
absl::optional<int> stun_keepalive_interval);
|
||||||
const webrtc::FieldTrialsView* field_trials);
|
[[deprecated("Pass arguments using PortParametersRef")]] static std::
|
||||||
|
unique_ptr<StunPort>
|
||||||
|
Create(webrtc::TaskQueueBase* thread,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
uint16_t min_port,
|
||||||
|
uint16_t max_port,
|
||||||
|
absl::string_view username,
|
||||||
|
absl::string_view password,
|
||||||
|
const ServerAddresses& servers,
|
||||||
|
absl::optional<int> stun_keepalive_interval,
|
||||||
|
const webrtc::FieldTrialsView* field_trials);
|
||||||
void PrepareAddress() override;
|
void PrepareAddress() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StunPort(rtc::Thread* thread,
|
StunPort(const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
const ServerAddresses& servers);
|
||||||
absl::string_view password,
|
|
||||||
const ServerAddresses& servers,
|
|
||||||
const webrtc::FieldTrialsView* field_trials);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cricket
|
} // namespace cricket
|
||||||
|
|||||||
@ -137,9 +137,13 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
void CreateStunPort(const ServerAddresses& stun_servers,
|
void CreateStunPort(const ServerAddresses& stun_servers,
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
||||||
stun_port_ = cricket::StunPort::Create(
|
stun_port_ = cricket::StunPort::Create(
|
||||||
rtc::Thread::Current(), socket_factory(), &network_, 0, 0,
|
{.network_thread = rtc::Thread::Current(),
|
||||||
rtc::CreateRandomString(16), rtc::CreateRandomString(22), stun_servers,
|
.socket_factory = socket_factory(),
|
||||||
absl::nullopt, field_trials);
|
.network = &network_,
|
||||||
|
.ice_username_fragment = rtc::CreateRandomString(16),
|
||||||
|
.ice_password = rtc::CreateRandomString(22),
|
||||||
|
.field_trials = field_trials},
|
||||||
|
0, 0, stun_servers, absl::nullopt);
|
||||||
stun_port_->SetIceTiebreaker(kTiebreakerDefault);
|
stun_port_->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
stun_port_->set_stun_keepalive_delay(stun_keepalive_delay_);
|
stun_port_->set_stun_keepalive_delay(stun_keepalive_delay_);
|
||||||
// If `stun_keepalive_lifetime_` is negative, let the stun port
|
// If `stun_keepalive_lifetime_` is negative, let the stun port
|
||||||
@ -170,9 +174,13 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
OnReadPacket(socket, packet);
|
OnReadPacket(socket, packet);
|
||||||
});
|
});
|
||||||
stun_port_ = cricket::UDPPort::Create(
|
stun_port_ = cricket::UDPPort::Create(
|
||||||
rtc::Thread::Current(), socket_factory(), &network_, socket_.get(),
|
{.network_thread = rtc::Thread::Current(),
|
||||||
rtc::CreateRandomString(16), rtc::CreateRandomString(22), false,
|
.socket_factory = socket_factory(),
|
||||||
absl::nullopt, field_trials);
|
.network = &network_,
|
||||||
|
.ice_username_fragment = rtc::CreateRandomString(16),
|
||||||
|
.ice_password = rtc::CreateRandomString(22),
|
||||||
|
.field_trials = field_trials},
|
||||||
|
socket_.get(), false, absl::nullopt);
|
||||||
ASSERT_TRUE(stun_port_ != NULL);
|
ASSERT_TRUE(stun_port_ != NULL);
|
||||||
stun_port_->SetIceTiebreaker(kTiebreakerDefault);
|
stun_port_->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
ServerAddresses stun_servers;
|
ServerAddresses stun_servers;
|
||||||
|
|||||||
@ -90,24 +90,11 @@ using ::webrtc::IceCandidateType;
|
|||||||
using ::webrtc::SafeTask;
|
using ::webrtc::SafeTask;
|
||||||
using ::webrtc::TimeDelta;
|
using ::webrtc::TimeDelta;
|
||||||
|
|
||||||
TCPPort::TCPPort(rtc::Thread* thread,
|
TCPPort::TCPPort(const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
bool allow_listen)
|
||||||
absl::string_view password,
|
: Port(args, IceCandidateType::kHost, min_port, max_port),
|
||||||
bool allow_listen,
|
|
||||||
const webrtc::FieldTrialsView* field_trials)
|
|
||||||
: Port(thread,
|
|
||||||
IceCandidateType::kHost,
|
|
||||||
factory,
|
|
||||||
network,
|
|
||||||
min_port,
|
|
||||||
max_port,
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
field_trials),
|
|
||||||
allow_listen_(allow_listen),
|
allow_listen_(allow_listen),
|
||||||
error_(0) {
|
error_(0) {
|
||||||
// TODO(mallinath) - Set preference value as per RFC 6544.
|
// TODO(mallinath) - Set preference value as per RFC 6544.
|
||||||
|
|||||||
@ -36,20 +36,32 @@ class TCPConnection;
|
|||||||
// call this TCPPort::OnReadPacket (3 arg) to dispatch to a connection.
|
// call this TCPPort::OnReadPacket (3 arg) to dispatch to a connection.
|
||||||
class TCPPort : public Port {
|
class TCPPort : public Port {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<TCPPort> Create(
|
static std::unique_ptr<TCPPort> Create(const PortParametersRef& args,
|
||||||
rtc::Thread* thread,
|
uint16_t min_port,
|
||||||
rtc::PacketSocketFactory* factory,
|
uint16_t max_port,
|
||||||
const rtc::Network* network,
|
bool allow_listen) {
|
||||||
uint16_t min_port,
|
|
||||||
uint16_t max_port,
|
|
||||||
absl::string_view username,
|
|
||||||
absl::string_view password,
|
|
||||||
bool allow_listen,
|
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
|
||||||
// Using `new` to access a non-public constructor.
|
// Using `new` to access a non-public constructor.
|
||||||
return absl::WrapUnique(new TCPPort(thread, factory, network, min_port,
|
return absl::WrapUnique(
|
||||||
max_port, username, password,
|
new TCPPort(args, min_port, max_port, allow_listen));
|
||||||
allow_listen, field_trials));
|
}
|
||||||
|
[[deprecated("Pass arguments using PortParametersRef")]] static std::
|
||||||
|
unique_ptr<TCPPort>
|
||||||
|
Create(webrtc::TaskQueueBase* thread,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
uint16_t min_port,
|
||||||
|
uint16_t max_port,
|
||||||
|
absl::string_view username,
|
||||||
|
absl::string_view password,
|
||||||
|
bool allow_listen,
|
||||||
|
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
||||||
|
return Create({.network_thread = thread,
|
||||||
|
.socket_factory = factory,
|
||||||
|
.network = network,
|
||||||
|
.ice_username_fragment = username,
|
||||||
|
.ice_password = password,
|
||||||
|
.field_trials = field_trials},
|
||||||
|
min_port, max_port, allow_listen);
|
||||||
}
|
}
|
||||||
~TCPPort() override;
|
~TCPPort() override;
|
||||||
|
|
||||||
@ -68,15 +80,10 @@ class TCPPort : public Port {
|
|||||||
ProtocolType GetProtocol() const override;
|
ProtocolType GetProtocol() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TCPPort(rtc::Thread* thread,
|
TCPPort(const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
bool allow_listen);
|
||||||
absl::string_view password,
|
|
||||||
bool allow_listen,
|
|
||||||
const webrtc::FieldTrialsView* field_trials);
|
|
||||||
|
|
||||||
// Handles sending using the local TCP socket.
|
// Handles sending using the local TCP socket.
|
||||||
int SendTo(const void* data,
|
int SendTo(const void* data,
|
||||||
|
|||||||
@ -84,16 +84,26 @@ class TCPPortTest : public ::testing::Test, public sigslot::has_slots<> {
|
|||||||
|
|
||||||
std::unique_ptr<TCPPort> CreateTCPPort(const SocketAddress& addr) {
|
std::unique_ptr<TCPPort> CreateTCPPort(const SocketAddress& addr) {
|
||||||
auto port = std::unique_ptr<TCPPort>(
|
auto port = std::unique_ptr<TCPPort>(
|
||||||
TCPPort::Create(&main_, &socket_factory_, MakeNetwork(addr), 0, 0,
|
TCPPort::Create({.network_thread = &main_,
|
||||||
username_, password_, true, &field_trials_));
|
.socket_factory = &socket_factory_,
|
||||||
|
.network = MakeNetwork(addr),
|
||||||
|
.ice_username_fragment = username_,
|
||||||
|
.ice_password = password_,
|
||||||
|
.field_trials = &field_trials_},
|
||||||
|
0, 0, true));
|
||||||
port->SetIceTiebreaker(kTiebreakerDefault);
|
port->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<TCPPort> CreateTCPPort(const rtc::Network* network) {
|
std::unique_ptr<TCPPort> CreateTCPPort(const rtc::Network* network) {
|
||||||
auto port = std::unique_ptr<TCPPort>(
|
auto port = std::unique_ptr<TCPPort>(
|
||||||
TCPPort::Create(&main_, &socket_factory_, network, 0, 0, username_,
|
TCPPort::Create({.network_thread = &main_,
|
||||||
password_, true, &field_trials_));
|
.socket_factory = &socket_factory_,
|
||||||
|
.network = network,
|
||||||
|
.ice_username_fragment = username_,
|
||||||
|
.ice_password = password_,
|
||||||
|
.field_trials = &field_trials_},
|
||||||
|
0, 0, true));
|
||||||
port->SetIceTiebreaker(kTiebreakerDefault);
|
port->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -208,7 +208,68 @@ class TurnEntry : public sigslot::has_slots<> {
|
|||||||
webrtc::ScopedTaskSafety task_safety_;
|
webrtc::ScopedTaskSafety task_safety_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TurnPort::TurnPort(TaskQueueBase* thread,
|
TurnPort::TurnPort(const PortParametersRef& args,
|
||||||
|
rtc::AsyncPacketSocket* socket,
|
||||||
|
const ProtocolAddress& server_address,
|
||||||
|
const RelayCredentials& credentials,
|
||||||
|
int server_priority,
|
||||||
|
const std::vector<std::string>& tls_alpn_protocols,
|
||||||
|
const std::vector<std::string>& tls_elliptic_curves,
|
||||||
|
webrtc::TurnCustomizer* customizer,
|
||||||
|
rtc::SSLCertificateVerifier* tls_cert_verifier)
|
||||||
|
: Port(args, IceCandidateType::kRelay),
|
||||||
|
server_address_(server_address),
|
||||||
|
server_url_(ReconstructServerUrl()),
|
||||||
|
tls_alpn_protocols_(tls_alpn_protocols),
|
||||||
|
tls_elliptic_curves_(tls_elliptic_curves),
|
||||||
|
tls_cert_verifier_(tls_cert_verifier),
|
||||||
|
credentials_(credentials),
|
||||||
|
socket_(socket),
|
||||||
|
error_(0),
|
||||||
|
stun_dscp_value_(rtc::DSCP_NO_CHANGE),
|
||||||
|
request_manager_(
|
||||||
|
args.network_thread,
|
||||||
|
[this](const void* data, size_t size, StunRequest* request) {
|
||||||
|
OnSendStunPacket(data, size, request);
|
||||||
|
}),
|
||||||
|
next_channel_number_(TURN_CHANNEL_NUMBER_START),
|
||||||
|
state_(STATE_CONNECTING),
|
||||||
|
server_priority_(server_priority),
|
||||||
|
allocate_mismatch_retries_(0),
|
||||||
|
turn_customizer_(customizer) {}
|
||||||
|
|
||||||
|
TurnPort::TurnPort(const PortParametersRef& args,
|
||||||
|
uint16_t min_port,
|
||||||
|
uint16_t max_port,
|
||||||
|
const ProtocolAddress& server_address,
|
||||||
|
const RelayCredentials& credentials,
|
||||||
|
int server_priority,
|
||||||
|
const std::vector<std::string>& tls_alpn_protocols,
|
||||||
|
const std::vector<std::string>& tls_elliptic_curves,
|
||||||
|
webrtc::TurnCustomizer* customizer,
|
||||||
|
rtc::SSLCertificateVerifier* tls_cert_verifier)
|
||||||
|
: Port(args, IceCandidateType::kRelay, min_port, max_port),
|
||||||
|
server_address_(server_address),
|
||||||
|
server_url_(ReconstructServerUrl()),
|
||||||
|
tls_alpn_protocols_(tls_alpn_protocols),
|
||||||
|
tls_elliptic_curves_(tls_elliptic_curves),
|
||||||
|
tls_cert_verifier_(tls_cert_verifier),
|
||||||
|
credentials_(credentials),
|
||||||
|
socket_(nullptr),
|
||||||
|
error_(0),
|
||||||
|
stun_dscp_value_(rtc::DSCP_NO_CHANGE),
|
||||||
|
request_manager_(
|
||||||
|
args.network_thread,
|
||||||
|
[this](const void* data, size_t size, StunRequest* request) {
|
||||||
|
OnSendStunPacket(data, size, request);
|
||||||
|
}),
|
||||||
|
next_channel_number_(TURN_CHANNEL_NUMBER_START),
|
||||||
|
state_(STATE_CONNECTING),
|
||||||
|
server_priority_(server_priority),
|
||||||
|
allocate_mismatch_retries_(0),
|
||||||
|
turn_customizer_(customizer) {}
|
||||||
|
|
||||||
|
TurnPort::TurnPort(webrtc::TaskQueueBase* thread,
|
||||||
rtc::PacketSocketFactory* factory,
|
rtc::PacketSocketFactory* factory,
|
||||||
const rtc::Network* network,
|
const rtc::Network* network,
|
||||||
rtc::AsyncPacketSocket* socket,
|
rtc::AsyncPacketSocket* socket,
|
||||||
@ -222,34 +283,21 @@ TurnPort::TurnPort(TaskQueueBase* thread,
|
|||||||
webrtc::TurnCustomizer* customizer,
|
webrtc::TurnCustomizer* customizer,
|
||||||
rtc::SSLCertificateVerifier* tls_cert_verifier,
|
rtc::SSLCertificateVerifier* tls_cert_verifier,
|
||||||
const webrtc::FieldTrialsView* field_trials)
|
const webrtc::FieldTrialsView* field_trials)
|
||||||
: Port(thread,
|
: TurnPort({.network_thread = thread,
|
||||||
IceCandidateType::kRelay,
|
.socket_factory = factory,
|
||||||
factory,
|
.network = network,
|
||||||
network,
|
.ice_username_fragment = username,
|
||||||
username,
|
.ice_password = password,
|
||||||
password,
|
.field_trials = field_trials},
|
||||||
field_trials),
|
socket,
|
||||||
server_address_(server_address),
|
server_address,
|
||||||
server_url_(ReconstructServerUrl()),
|
credentials,
|
||||||
tls_alpn_protocols_(tls_alpn_protocols),
|
server_priority,
|
||||||
tls_elliptic_curves_(tls_elliptic_curves),
|
tls_alpn_protocols,
|
||||||
tls_cert_verifier_(tls_cert_verifier),
|
tls_elliptic_curves,
|
||||||
credentials_(credentials),
|
customizer,
|
||||||
socket_(socket),
|
tls_cert_verifier) {}
|
||||||
error_(0),
|
TurnPort::TurnPort(webrtc::TaskQueueBase* thread,
|
||||||
stun_dscp_value_(rtc::DSCP_NO_CHANGE),
|
|
||||||
request_manager_(
|
|
||||||
thread,
|
|
||||||
[this](const void* data, size_t size, StunRequest* request) {
|
|
||||||
OnSendStunPacket(data, size, request);
|
|
||||||
}),
|
|
||||||
next_channel_number_(TURN_CHANNEL_NUMBER_START),
|
|
||||||
state_(STATE_CONNECTING),
|
|
||||||
server_priority_(server_priority),
|
|
||||||
allocate_mismatch_retries_(0),
|
|
||||||
turn_customizer_(customizer) {}
|
|
||||||
|
|
||||||
TurnPort::TurnPort(TaskQueueBase* thread,
|
|
||||||
rtc::PacketSocketFactory* factory,
|
rtc::PacketSocketFactory* factory,
|
||||||
const rtc::Network* network,
|
const rtc::Network* network,
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
@ -264,34 +312,21 @@ TurnPort::TurnPort(TaskQueueBase* thread,
|
|||||||
webrtc::TurnCustomizer* customizer,
|
webrtc::TurnCustomizer* customizer,
|
||||||
rtc::SSLCertificateVerifier* tls_cert_verifier,
|
rtc::SSLCertificateVerifier* tls_cert_verifier,
|
||||||
const webrtc::FieldTrialsView* field_trials)
|
const webrtc::FieldTrialsView* field_trials)
|
||||||
: Port(thread,
|
: TurnPort({.network_thread = thread,
|
||||||
IceCandidateType::kRelay,
|
.socket_factory = factory,
|
||||||
factory,
|
.network = network,
|
||||||
network,
|
.ice_username_fragment = username,
|
||||||
min_port,
|
.ice_password = password,
|
||||||
max_port,
|
.field_trials = field_trials},
|
||||||
username,
|
min_port,
|
||||||
password,
|
max_port,
|
||||||
field_trials),
|
server_address,
|
||||||
server_address_(server_address),
|
credentials,
|
||||||
server_url_(ReconstructServerUrl()),
|
server_priority,
|
||||||
tls_alpn_protocols_(tls_alpn_protocols),
|
tls_alpn_protocols,
|
||||||
tls_elliptic_curves_(tls_elliptic_curves),
|
tls_elliptic_curves,
|
||||||
tls_cert_verifier_(tls_cert_verifier),
|
customizer,
|
||||||
credentials_(credentials),
|
tls_cert_verifier) {}
|
||||||
socket_(nullptr),
|
|
||||||
error_(0),
|
|
||||||
stun_dscp_value_(rtc::DSCP_NO_CHANGE),
|
|
||||||
request_manager_(
|
|
||||||
thread,
|
|
||||||
[this](const void* data, size_t size, StunRequest* request) {
|
|
||||||
OnSendStunPacket(data, size, request);
|
|
||||||
}),
|
|
||||||
next_channel_number_(TURN_CHANNEL_NUMBER_START),
|
|
||||||
state_(STATE_CONNECTING),
|
|
||||||
server_priority_(server_priority),
|
|
||||||
allocate_mismatch_retries_(0),
|
|
||||||
turn_customizer_(customizer) {}
|
|
||||||
|
|
||||||
TurnPort::~TurnPort() {
|
TurnPort::~TurnPort() {
|
||||||
// TODO(juberti): Should this even be necessary?
|
// TODO(juberti): Should this even be necessary?
|
||||||
|
|||||||
@ -81,12 +81,16 @@ class TurnPort : public Port {
|
|||||||
}
|
}
|
||||||
// Using `new` to access a non-public constructor.
|
// Using `new` to access a non-public constructor.
|
||||||
return absl::WrapUnique(
|
return absl::WrapUnique(
|
||||||
new TurnPort(args.network_thread, args.socket_factory, args.network,
|
new TurnPort({.network_thread = args.network_thread,
|
||||||
socket, args.username, args.password, *args.server_address,
|
.socket_factory = args.socket_factory,
|
||||||
args.config->credentials, args.relative_priority,
|
.network = args.network,
|
||||||
args.config->tls_alpn_protocols,
|
.ice_username_fragment = args.username,
|
||||||
|
.ice_password = args.password,
|
||||||
|
.field_trials = args.field_trials},
|
||||||
|
socket, *args.server_address, args.config->credentials,
|
||||||
|
args.relative_priority, args.config->tls_alpn_protocols,
|
||||||
args.config->tls_elliptic_curves, args.turn_customizer,
|
args.config->tls_elliptic_curves, args.turn_customizer,
|
||||||
args.config->tls_cert_verifier, args.field_trials));
|
args.config->tls_cert_verifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a TURN port that will use a new socket, bound to `network` and
|
// Create a TURN port that will use a new socket, bound to `network` and
|
||||||
@ -98,13 +102,17 @@ class TurnPort : public Port {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// Using `new` to access a non-public constructor.
|
// Using `new` to access a non-public constructor.
|
||||||
return absl::WrapUnique(
|
return absl::WrapUnique(new TurnPort(
|
||||||
new TurnPort(args.network_thread, args.socket_factory, args.network,
|
{.network_thread = args.network_thread,
|
||||||
min_port, max_port, args.username, args.password,
|
.socket_factory = args.socket_factory,
|
||||||
*args.server_address, args.config->credentials,
|
.network = args.network,
|
||||||
args.relative_priority, args.config->tls_alpn_protocols,
|
.ice_username_fragment = args.username,
|
||||||
args.config->tls_elliptic_curves, args.turn_customizer,
|
.ice_password = args.password,
|
||||||
args.config->tls_cert_verifier, args.field_trials));
|
.field_trials = args.field_trials},
|
||||||
|
min_port, max_port, *args.server_address, args.config->credentials,
|
||||||
|
args.relative_priority, args.config->tls_alpn_protocols,
|
||||||
|
args.config->tls_elliptic_curves, args.turn_customizer,
|
||||||
|
args.config->tls_cert_verifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
~TurnPort() override;
|
~TurnPort() override;
|
||||||
@ -201,36 +209,59 @@ class TurnPort : public Port {
|
|||||||
void SetCallbacksForTest(CallbacksForTest* callbacks);
|
void SetCallbacksForTest(CallbacksForTest* callbacks);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TurnPort(webrtc::TaskQueueBase* thread,
|
TurnPort(const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
rtc::AsyncPacketSocket* socket,
|
rtc::AsyncPacketSocket* socket,
|
||||||
absl::string_view username,
|
|
||||||
absl::string_view password,
|
|
||||||
const ProtocolAddress& server_address,
|
const ProtocolAddress& server_address,
|
||||||
const RelayCredentials& credentials,
|
const RelayCredentials& credentials,
|
||||||
int server_priority,
|
int server_priority,
|
||||||
const std::vector<std::string>& tls_alpn_protocols,
|
const std::vector<std::string>& tls_alpn_protocols,
|
||||||
const std::vector<std::string>& tls_elliptic_curves,
|
const std::vector<std::string>& tls_elliptic_curves,
|
||||||
webrtc::TurnCustomizer* customizer,
|
webrtc::TurnCustomizer* customizer,
|
||||||
rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr,
|
rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr);
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr);
|
|
||||||
|
|
||||||
TurnPort(webrtc::TaskQueueBase* thread,
|
TurnPort(const PortParametersRef& args,
|
||||||
rtc::PacketSocketFactory* factory,
|
|
||||||
const rtc::Network* network,
|
|
||||||
uint16_t min_port,
|
uint16_t min_port,
|
||||||
uint16_t max_port,
|
uint16_t max_port,
|
||||||
absl::string_view username,
|
|
||||||
absl::string_view password,
|
|
||||||
const ProtocolAddress& server_address,
|
const ProtocolAddress& server_address,
|
||||||
const RelayCredentials& credentials,
|
const RelayCredentials& credentials,
|
||||||
int server_priority,
|
int server_priority,
|
||||||
const std::vector<std::string>& tls_alpn_protocols,
|
const std::vector<std::string>& tls_alpn_protocols,
|
||||||
const std::vector<std::string>& tls_elliptic_curves,
|
const std::vector<std::string>& tls_elliptic_curves,
|
||||||
webrtc::TurnCustomizer* customizer,
|
webrtc::TurnCustomizer* customizer,
|
||||||
rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr,
|
rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr);
|
||||||
const webrtc::FieldTrialsView* field_trials = nullptr);
|
|
||||||
|
[[deprecated("Pass arguments using PortParametersRef")]] TurnPort(
|
||||||
|
webrtc::TaskQueueBase* thread,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
rtc::AsyncPacketSocket* socket,
|
||||||
|
absl::string_view username,
|
||||||
|
absl::string_view password,
|
||||||
|
const ProtocolAddress& server_address,
|
||||||
|
const RelayCredentials& credentials,
|
||||||
|
int server_priority,
|
||||||
|
const std::vector<std::string>& tls_alpn_protocols,
|
||||||
|
const std::vector<std::string>& tls_elliptic_curves,
|
||||||
|
webrtc::TurnCustomizer* customizer,
|
||||||
|
rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr,
|
||||||
|
const webrtc::FieldTrialsView* field_trials = nullptr);
|
||||||
|
|
||||||
|
[[deprecated("Pass arguments using PortParametersRef")]] TurnPort(
|
||||||
|
webrtc::TaskQueueBase* thread,
|
||||||
|
rtc::PacketSocketFactory* factory,
|
||||||
|
const rtc::Network* network,
|
||||||
|
uint16_t min_port,
|
||||||
|
uint16_t max_port,
|
||||||
|
absl::string_view username,
|
||||||
|
absl::string_view password,
|
||||||
|
const ProtocolAddress& server_address,
|
||||||
|
const RelayCredentials& credentials,
|
||||||
|
int server_priority,
|
||||||
|
const std::vector<std::string>& tls_alpn_protocols,
|
||||||
|
const std::vector<std::string>& tls_elliptic_curves,
|
||||||
|
webrtc::TurnCustomizer* customizer,
|
||||||
|
rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr,
|
||||||
|
const webrtc::FieldTrialsView* field_trials = nullptr);
|
||||||
|
|
||||||
// NOTE: This method needs to be accessible for StunPort
|
// NOTE: This method needs to be accessible for StunPort
|
||||||
// return true if entry was created (i.e channel_number consumed).
|
// return true if entry was created (i.e channel_number consumed).
|
||||||
|
|||||||
@ -366,9 +366,13 @@ class TurnPortTest : public ::testing::Test,
|
|||||||
void CreateUdpPort() { CreateUdpPort(kLocalAddr2); }
|
void CreateUdpPort() { CreateUdpPort(kLocalAddr2); }
|
||||||
|
|
||||||
void CreateUdpPort(const SocketAddress& address) {
|
void CreateUdpPort(const SocketAddress& address) {
|
||||||
udp_port_ = UDPPort::Create(&main_, socket_factory(), MakeNetwork(address),
|
udp_port_ = UDPPort::Create({.network_thread = &main_,
|
||||||
0, 0, kIceUfrag2, kIcePwd2, false,
|
.socket_factory = socket_factory(),
|
||||||
absl::nullopt, &field_trials_);
|
.network = MakeNetwork(address),
|
||||||
|
.ice_username_fragment = kIceUfrag2,
|
||||||
|
.ice_password = kIcePwd2,
|
||||||
|
.field_trials = &field_trials_},
|
||||||
|
0, 0, false, absl::nullopt);
|
||||||
// UDP port will be controlled.
|
// UDP port will be controlled.
|
||||||
udp_port_->SetIceRole(ICEROLE_CONTROLLED);
|
udp_port_->SetIceRole(ICEROLE_CONTROLLED);
|
||||||
udp_port_->SetIceTiebreaker(kTiebreakerDefault);
|
udp_port_->SetIceTiebreaker(kTiebreakerDefault);
|
||||||
|
|||||||
@ -1470,19 +1470,25 @@ void AllocationSequence::CreateUDPPorts() {
|
|||||||
!IsFlagSet(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE);
|
!IsFlagSet(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE);
|
||||||
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) {
|
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) {
|
||||||
port = UDPPort::Create(
|
port = UDPPort::Create(
|
||||||
session_->network_thread(), session_->socket_factory(), network_,
|
{.network_thread = session_->network_thread(),
|
||||||
udp_socket_.get(), session_->username(), session_->password(),
|
.socket_factory = session_->socket_factory(),
|
||||||
emit_local_candidate_for_anyaddress,
|
.network = network_,
|
||||||
session_->allocator()->stun_candidate_keepalive_interval(),
|
.ice_username_fragment = session_->username(),
|
||||||
session_->allocator()->field_trials());
|
.ice_password = session_->password(),
|
||||||
|
.field_trials = session_->allocator()->field_trials()},
|
||||||
|
udp_socket_.get(), emit_local_candidate_for_anyaddress,
|
||||||
|
session_->allocator()->stun_candidate_keepalive_interval());
|
||||||
} else {
|
} else {
|
||||||
port = UDPPort::Create(
|
port = UDPPort::Create(
|
||||||
session_->network_thread(), session_->socket_factory(), network_,
|
{.network_thread = session_->network_thread(),
|
||||||
|
.socket_factory = session_->socket_factory(),
|
||||||
|
.network = network_,
|
||||||
|
.ice_username_fragment = session_->username(),
|
||||||
|
.ice_password = session_->password(),
|
||||||
|
.field_trials = session_->allocator()->field_trials()},
|
||||||
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
||||||
session_->username(), session_->password(),
|
|
||||||
emit_local_candidate_for_anyaddress,
|
emit_local_candidate_for_anyaddress,
|
||||||
session_->allocator()->stun_candidate_keepalive_interval(),
|
session_->allocator()->stun_candidate_keepalive_interval());
|
||||||
session_->allocator()->field_trials());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port) {
|
if (port) {
|
||||||
@ -1516,11 +1522,15 @@ void AllocationSequence::CreateTCPPorts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Port> port = TCPPort::Create(
|
std::unique_ptr<Port> port = TCPPort::Create(
|
||||||
session_->network_thread(), session_->socket_factory(), network_,
|
{.network_thread = session_->network_thread(),
|
||||||
|
.socket_factory = session_->socket_factory(),
|
||||||
|
.network = network_,
|
||||||
|
.ice_username_fragment = session_->username(),
|
||||||
|
.ice_password = session_->password(),
|
||||||
|
.field_trials = session_->allocator()->field_trials()},
|
||||||
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
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) {
|
if (port) {
|
||||||
port->SetIceTiebreaker(session_->allocator()->ice_tiebreaker());
|
port->SetIceTiebreaker(session_->allocator()->ice_tiebreaker());
|
||||||
session_->AddAllocatedPort(port.release(), this);
|
session_->AddAllocatedPort(port.release(), this);
|
||||||
@ -1546,11 +1556,15 @@ void AllocationSequence::CreateStunPorts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<StunPort> port = StunPort::Create(
|
std::unique_ptr<StunPort> port = StunPort::Create(
|
||||||
session_->network_thread(), session_->socket_factory(), network_,
|
{.network_thread = session_->network_thread(),
|
||||||
|
.socket_factory = session_->socket_factory(),
|
||||||
|
.network = network_,
|
||||||
|
.ice_username_fragment = session_->username(),
|
||||||
|
.ice_password = session_->password(),
|
||||||
|
.field_trials = session_->allocator()->field_trials()},
|
||||||
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
session_->allocator()->min_port(), session_->allocator()->max_port(),
|
||||||
session_->username(), session_->password(), config_->StunServers(),
|
config_->StunServers(),
|
||||||
session_->allocator()->stun_candidate_keepalive_interval(),
|
session_->allocator()->stun_candidate_keepalive_interval());
|
||||||
session_->allocator()->field_trials());
|
|
||||||
if (port) {
|
if (port) {
|
||||||
port->SetIceTiebreaker(session_->allocator()->ice_tiebreaker());
|
port->SetIceTiebreaker(session_->allocator()->ice_tiebreaker());
|
||||||
session_->AddAllocatedPort(port.release(), this);
|
session_->AddAllocatedPort(port.release(), this);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user