Add PortAllocator min/max ports to JAVA API

This helps Java clients control the port range.

Bug: None
Change-Id: Icfe16cdfac4e08cd21346a3cb4bb65b9fb2fa0d0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/374841
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Youjie Zhou <youjiezhou@google.com>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43789}
This commit is contained in:
Youjie Zhou 2025-01-19 08:48:04 -08:00 committed by WebRTC LUCI CQ
parent 79e5e721b5
commit a2a528c20b
2 changed files with 20 additions and 0 deletions

View File

@ -579,6 +579,10 @@ public class PeerConnection {
*/
public boolean offerExtmapAllowMixed;
/** Limit ports used for connections. */
public int portAllocatorMinPort;
public int portAllocatorMaxPort;
/** Control port allocation, including what kinds of ports are allocated. */
@PortAllocatorFlags public int portAllocatorFlags;
@ -623,6 +627,8 @@ public class PeerConnection {
turnLoggingId = null;
enableImplicitRollback = false;
offerExtmapAllowMixed = true;
portAllocatorMinPort = 0;
portAllocatorMaxPort = 0;
portAllocatorFlags = 0;
}
@ -833,6 +839,16 @@ public class PeerConnection {
return offerExtmapAllowMixed;
}
@CalledByNative("RTCConfiguration")
int getPortAllocatorMinPort() {
return portAllocatorMinPort;
}
@CalledByNative("RTCConfiguration")
int getPortAllocatorMaxPort() {
return portAllocatorMaxPort;
}
@CalledByNative("RTCConfiguration")
@PortAllocatorFlags
int getPortAllocatorFlags() {

View File

@ -284,6 +284,10 @@ void JavaToNativeRTCConfiguration(
rtc_config->turn_logging_id = JavaToNativeString(jni, j_turn_logging_id);
}
rtc_config->port_allocator_config.min_port =
Java_RTCConfiguration_getPortAllocatorMinPort(jni, j_rtc_config);
rtc_config->port_allocator_config.max_port =
Java_RTCConfiguration_getPortAllocatorMaxPort(jni, j_rtc_config);
rtc_config->port_allocator_config.flags =
Java_RTCConfiguration_getPortAllocatorFlags(jni, j_rtc_config);
}