Add PortAllocator configuration to RTCConfiguration

So applications don't need to create and inject their own instance of
BasicPortAllocator, just to change these settings.

Bug: webrtc:13145
Change-Id: I08ac8658b4c0ef87019fa579be9195a8a6b50feb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/239643
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35476}
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index efe84fb..678ece8 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -295,6 +295,13 @@
 
   enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY };
 
+  struct PortAllocatorConfig {
+    // For min_port and max_port, 0 means not specified.
+    int min_port = 0;
+    int max_port = 0;
+    uint32_t flags = 0;  // Same as kDefaultPortAllocatorFlags.
+  };
+
   enum class RTCConfigurationType {
     // A configuration that is safer to use, despite not having the best
     // performance. Currently this is the default configuration.
@@ -372,6 +379,18 @@
           video_rtcp_report_interval_ms;
     }
 
+    // Settings for the port allcoator. Applied only if the port allocator is
+    // created by PeerConnectionFactory, not if it is injected with
+    // PeerConnectionDependencies
+    int min_port() const { return port_allocator_config.min_port; }
+    void set_min_port(int port) { port_allocator_config.min_port = port; }
+    int max_port() const { return port_allocator_config.max_port; }
+    void set_max_port(int port) { port_allocator_config.max_port = port; }
+    uint32_t port_allocator_flags() { return port_allocator_config.flags; }
+    void set_port_allocator_flags(uint32_t flags) {
+      port_allocator_config.flags = flags;
+    }
+
     static const int kUndefined = -1;
     // Default maximum number of packets in the audio jitter buffer.
     static const int kAudioJitterBufferMaxPackets = 200;
@@ -670,6 +689,8 @@
     // VPN (in case webrtc fails to auto detect them).
     std::vector<rtc::NetworkMask> vpn_list;
 
+    PortAllocatorConfig port_allocator_config;
+
     //
     // Don't forget to update operator== if adding something.
     //