diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 1ce052c86f..73d580925b 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -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", ] } diff --git a/p2p/base/fake_port_allocator.h b/p2p/base/fake_port_allocator.h index d45d1e4998..bf05cda60d 100644 --- a/p2p/base/fake_port_allocator.h +++ b/p2p/base/fake_port_allocator.h @@ -16,6 +16,7 @@ #include #include +#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 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