Add new constructor for TestUDPPort
The new constructor exposes an already existing constructor, and is used to create a (test) UDPPort with a socket...so that one does not (really) need a socket factory. Bug: b/339018639 Change-Id: Ib591fe6ae61519fe29cdea819192694448b071e0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/356141 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Jonas Oreland <jonaso@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42571}
This commit is contained in:
parent
f101f3f803
commit
a58047d4e9
@ -1014,6 +1014,7 @@ if (rtc_include_tests) {
|
||||
"../rtc_base:task_queue_for_test",
|
||||
"../rtc_base:threading",
|
||||
"../rtc_base/memory:always_valid_pointer",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "p2p/base/basic_packet_socket_factory.h"
|
||||
#include "p2p/base/port_allocator.h"
|
||||
@ -47,6 +48,18 @@ class TestUDPPort : public UDPPort {
|
||||
return port;
|
||||
}
|
||||
|
||||
static std::unique_ptr<TestUDPPort> Create(
|
||||
const PortParametersRef& args,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
bool emit_localhost_for_anyaddress) {
|
||||
auto port = absl::WrapUnique(
|
||||
new TestUDPPort(args, socket, emit_localhost_for_anyaddress));
|
||||
if (!port->Init()) {
|
||||
return nullptr;
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
protected:
|
||||
TestUDPPort(const PortParametersRef& args,
|
||||
uint16_t min_port,
|
||||
@ -57,6 +70,14 @@ class TestUDPPort : public UDPPort {
|
||||
min_port,
|
||||
max_port,
|
||||
emit_localhost_for_anyaddress) {}
|
||||
|
||||
TestUDPPort(const PortParametersRef& args,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
bool emit_localhost_for_anyaddress)
|
||||
: UDPPort(args,
|
||||
webrtc::IceCandidateType::kHost,
|
||||
socket,
|
||||
emit_localhost_for_anyaddress) {}
|
||||
};
|
||||
|
||||
// A FakePortAllocatorSession can be used with either a real or fake socket
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user