From 89e4e50e06efe8c7e16fcee56e4ff7a269c49d97 Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Mon, 30 Nov 2026 03:36:57 +0100 Subject: [PATCH] Expose the Data Channel DSCP as a setting Adds PeerConnectionConfiguration.withDataChannelDscp, which marks Data Channel packets and the DTLS handshake with the given DSCP instead of libdatachannel's default AF11. AF11 lands in the 802.11 background access category on access points that map DSCP by its top three bits, so applications can now send best effort (0) instead. Bumps libdatachannel to the commit that adds the setting. --- jni/libdatachannel | 2 +- jni/src/native_peer.cpp | 16 +++--- .../libdatachannel/IceUdpMuxListener.java | 4 +- .../libdatachannel/LibDataChannelNative.java | 4 +- .../schich/libdatachannel/PeerConnection.java | 1 + .../PeerConnectionConfiguration.java | 54 +++++++++++++------ 6 files changed, 53 insertions(+), 28 deletions(-) diff --git a/jni/libdatachannel b/jni/libdatachannel index 0b15881..e736932 160000 --- a/jni/libdatachannel +++ b/jni/libdatachannel @@ -1 +1 @@ -Subproject commit 0b158812cfbd9676e7cf4a63452e0e13f305997e +Subproject commit e7369322104e1d2754aaf4563bbdf8af05815693 diff --git a/jni/src/native_peer.cpp b/jni/src/native_peer.cpp index aff5e96..1854a35 100644 --- a/jni/src/native_peer.cpp +++ b/jni/src/native_peer.cpp @@ -68,7 +68,7 @@ static jint create_peer(JNIEnv* env, jclass clazz, const jboolean disableAutoNegotiation, const jboolean forceMediaTransport, const jint portRangeBegin, const jint portRangeEnd, - const jint mtu, const jint maxMessageSize, + const jint mtu, const jint maxMessageSize, const jint dataChannelDscp, jstring certificateFile, jstring keyFile, jstring keyPassword, incoming_peer* incoming) { // Field by field so that added configuration fields keep compiling. @@ -84,6 +84,8 @@ static jint create_peer(JNIEnv* env, jclass clazz, config.portRangeEnd = portRangeEnd; config.mtu = mtu; config.maxMessageSize = maxMessageSize; + config.manualDataChannelDscp = dataChannelDscp >= 0; + config.dataChannelDscp = dataChannelDscp; jstring* serverStrings = nullptr; @@ -181,10 +183,10 @@ Java_tel_schich_libdatachannel_LibDataChannelNative_rtcCreatePeerConnection(JNIE const jboolean disableAutoNegotiation, const jboolean forceMediaTransport, const jint portRangeBegin, const jint portRangeEnd, - const jint mtu, const jint maxMessageSize) { + const jint mtu, const jint maxMessageSize, const jint dataChannelDscp) { return create_peer(env, clazz, iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, - portRangeEnd, mtu, maxMessageSize, nullptr, nullptr, nullptr, nullptr); + portRangeEnd, mtu, maxMessageSize, dataChannelDscp, nullptr, nullptr, nullptr, nullptr); } JNIEXPORT jint JNICALL @@ -198,12 +200,12 @@ Java_tel_schich_libdatachannel_LibDataChannelNative_rtcCreatePeerConnectionWithI const jboolean disableAutoNegotiation, const jboolean forceMediaTransport, const jint portRangeBegin, const jint portRangeEnd, - const jint mtu, const jint maxMessageSize, + const jint mtu, const jint maxMessageSize, const jint dataChannelDscp, jstring certificateFile, jstring keyFile, jstring keyPassword) { return create_peer(env, clazz, iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, - portRangeEnd, mtu, maxMessageSize, certificateFile, keyFile, keyPassword, nullptr); + portRangeEnd, mtu, maxMessageSize, dataChannelDscp, certificateFile, keyFile, keyPassword, nullptr); } JNIEXPORT jint JNICALL @@ -472,7 +474,7 @@ extern "C" JNIEXPORT jintArray JNICALL Java_tel_schich_libdatachannel_IceUdpMuxL jobjectArray iceServers, jstring proxyServer, jstring bindAddress, const jint certificateType, const jint iceTransportPolicy, const jboolean enableIceTcp, const jboolean enableIceUdpMux, const jboolean disableAutoNegotiation, const jboolean forceMediaTransport, - const jint portRangeBegin, const jint portRangeEnd, const jint mtu, const jint maxMessageSize, + const jint portRangeBegin, const jint portRangeEnd, const jint mtu, const jint maxMessageSize, const jint dataChannelDscp, jstring certificateFile, jstring keyFile, jstring keyPassword, jstring remoteDescription, jstring localUfrag, jstring localPassword) { // Allocate the result before creating anything: ownership must never be lost on allocation failure. @@ -492,7 +494,7 @@ extern "C" JNIEXPORT jintArray JNICALL Java_tel_schich_libdatachannel_IceUdpMuxL // Prepared peers are admitted through the listener, never direct. status = create_peer(env, clazz, iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, JNI_FALSE, disableAutoNegotiation, forceMediaTransport, portRangeBegin, - portRangeEnd, mtu, maxMessageSize, certificateFile, keyFile, keyPassword, &incoming); + portRangeEnd, mtu, maxMessageSize, dataChannelDscp, certificateFile, keyFile, keyPassword, &incoming); } if (incoming.remote_sdp != nullptr) { env->ReleaseStringUTFChars(remoteDescription, incoming.remote_sdp); diff --git a/src/main/java/tel/schich/libdatachannel/IceUdpMuxListener.java b/src/main/java/tel/schich/libdatachannel/IceUdpMuxListener.java index f2560d0..e083002 100644 --- a/src/main/java/tel/schich/libdatachannel/IceUdpMuxListener.java +++ b/src/main/java/tel/schich/libdatachannel/IceUdpMuxListener.java @@ -494,14 +494,14 @@ private static int[] prepareNative(int handle, long requestId, PeerConnectionCon Util.bindAddress(config.bindAddress), config.certificateType.state, config.iceTransportPolicy.state, config.enableIceTcp, config.enableIceUdpMux, config.disableAutoNegotiation, config.forceMediaTransport, - config.portRangeBegin, config.portRangeEnd, config.mtu, config.maxMessageSize, + config.portRangeBegin, config.portRangeEnd, config.mtu, config.maxMessageSize, config.dataChannelDscp, certificate, key, keyPassword, remoteDescription, localUfrag, localPassword); } private static native int[] prepareConfiguredNative(int handle, long requestId, String @Nullable [] iceServers, @Nullable String proxyServer, @Nullable String bindAddress, int certificateType, int iceTransportPolicy, boolean enableIceTcp, boolean enableIceUdpMux, boolean disableAutoNegotiation, boolean forceMediaTransport, int portRangeBegin, int portRangeEnd, - int mtu, int maxMessageSize, @Nullable String certificate, @Nullable String key, @Nullable String keyPassword, + int mtu, int maxMessageSize, int dataChannelDscp, @Nullable String certificate, @Nullable String key, @Nullable String keyPassword, String remoteDescription, String localUfrag, String localPassword); private static native int acceptNative(int handle, long requestId, int peer); private static native int attachNative(int handle, long requestId, int peer); diff --git a/src/main/java/tel/schich/libdatachannel/LibDataChannelNative.java b/src/main/java/tel/schich/libdatachannel/LibDataChannelNative.java index 09b4798..5493250 100644 --- a/src/main/java/tel/schich/libdatachannel/LibDataChannelNative.java +++ b/src/main/java/tel/schich/libdatachannel/LibDataChannelNative.java @@ -9,8 +9,8 @@ class LibDataChannelNative { LibDataChannel.initialize(); } - static native int rtcCreatePeerConnection(String @Nullable [] iceServers, @Nullable String proxyServer, @Nullable String bindAddress, int certificateType, int iceTransportPolicy, boolean enableIceTcp, boolean enableIceUdpMux, boolean iceUdpMuxDirect, boolean disableAutoNegotiation, boolean forceMediaTransport, int portRangeBegin, int portRangeEnd, int mtu, int maxMessageSize); - static native int rtcCreatePeerConnectionWithIdentity(String @Nullable [] iceServers, @Nullable String proxyServer, @Nullable String bindAddress, int certificateType, int iceTransportPolicy, boolean enableIceTcp, boolean enableIceUdpMux, boolean iceUdpMuxDirect, boolean disableAutoNegotiation, boolean forceMediaTransport, int portRangeBegin, int portRangeEnd, int mtu, int maxMessageSize, @Nullable String certificateFile, @Nullable String keyFile, @Nullable String keyPassword); + static native int rtcCreatePeerConnection(String @Nullable [] iceServers, @Nullable String proxyServer, @Nullable String bindAddress, int certificateType, int iceTransportPolicy, boolean enableIceTcp, boolean enableIceUdpMux, boolean iceUdpMuxDirect, boolean disableAutoNegotiation, boolean forceMediaTransport, int portRangeBegin, int portRangeEnd, int mtu, int maxMessageSize, int dataChannelDscp); + static native int rtcCreatePeerConnectionWithIdentity(String @Nullable [] iceServers, @Nullable String proxyServer, @Nullable String bindAddress, int certificateType, int iceTransportPolicy, boolean enableIceTcp, boolean enableIceUdpMux, boolean iceUdpMuxDirect, boolean disableAutoNegotiation, boolean forceMediaTransport, int portRangeBegin, int portRangeEnd, int mtu, int maxMessageSize, int dataChannelDscp, @Nullable String certificateFile, @Nullable String keyFile, @Nullable String keyPassword); static native int setupPeerConnectionListener(int peerHandle, PeerConnectionListener listener); static native long rtcGetPeerConnectionCreationAttempts(); static native int setTestDispatchDelay(int millis); diff --git a/src/main/java/tel/schich/libdatachannel/PeerConnection.java b/src/main/java/tel/schich/libdatachannel/PeerConnection.java index 3bee17f..92f0e5a 100644 --- a/src/main/java/tel/schich/libdatachannel/PeerConnection.java +++ b/src/main/java/tel/schich/libdatachannel/PeerConnection.java @@ -194,6 +194,7 @@ private static PeerConnection createPeer(PeerConnectionConfiguration config, Cal config.portRangeEnd, config.mtu, config.maxMessageSize, + config.dataChannelDscp, certificate == null ? null : certificate.toString(), key == null ? null : key.toString(), keyPassword); diff --git a/src/main/java/tel/schich/libdatachannel/PeerConnectionConfiguration.java b/src/main/java/tel/schich/libdatachannel/PeerConnectionConfiguration.java index 7a76c13..b5aae28 100644 --- a/src/main/java/tel/schich/libdatachannel/PeerConnectionConfiguration.java +++ b/src/main/java/tel/schich/libdatachannel/PeerConnectionConfiguration.java @@ -15,6 +15,7 @@ public class PeerConnectionConfiguration { public static final int AUTO_MTU = 0; + public static final int DEFAULT_DATA_CHANNEL_DSCP = -1; public static final PeerConnectionConfiguration DEFAULT = new PeerConnectionConfiguration(Collections.emptyList(), null, null, @@ -28,7 +29,8 @@ public class PeerConnectionConfiguration { 0, 0, AUTO_MTU, - 0); + 0, + DEFAULT_DATA_CHANNEL_DSCP); final List iceServers; @Nullable @@ -46,8 +48,9 @@ public class PeerConnectionConfiguration { final int portRangeEnd; final int mtu; final int maxMessageSize; + final int dataChannelDscp; - private PeerConnectionConfiguration(List iceServers, @Nullable URI proxyServer, @Nullable InetAddress bindAddress, CertificateType certificateType, IceTransportPolicy iceTransportPolicy, boolean enableIceTcp, boolean enableIceUdpMux, boolean iceUdpMuxDirect, boolean disableAutoNegotiation, boolean forceMediaTransport, int portRangeBegin, int portRangeEnd, int mtu, int maxMessageSize) { + private PeerConnectionConfiguration(List iceServers, @Nullable URI proxyServer, @Nullable InetAddress bindAddress, CertificateType certificateType, IceTransportPolicy iceTransportPolicy, boolean enableIceTcp, boolean enableIceUdpMux, boolean iceUdpMuxDirect, boolean disableAutoNegotiation, boolean forceMediaTransport, int portRangeBegin, int portRangeEnd, int mtu, int maxMessageSize, int dataChannelDscp) { this.iceServers = iceServers; this.proxyServer = proxyServer; this.bindAddress = bindAddress; @@ -62,6 +65,7 @@ private PeerConnectionConfiguration(List iceServers, @Nullable URI proxySer this.portRangeEnd = portRangeEnd; this.mtu = mtu; this.maxMessageSize = maxMessageSize; + this.dataChannelDscp = dataChannelDscp; } /** @@ -79,7 +83,7 @@ public PeerConnectionConfiguration withIceServers(Collection iceServers) { newIceServers.add(iceServer); } } - return new PeerConnectionConfiguration(newIceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(newIceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public List iceServers() { @@ -97,7 +101,7 @@ public List iceServers() { * @return fluent interface */ public PeerConnectionConfiguration withProxyServer(URI proxyServer) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public Optional proxyServer() { @@ -111,7 +115,7 @@ public Optional proxyServer() { * @return fluent interface */ public PeerConnectionConfiguration withBindAddress(InetAddress bindAddress) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public Optional bindAddress() { @@ -125,7 +129,7 @@ public Optional bindAddress() { * @return fluent interface */ public PeerConnectionConfiguration withCertificateType(CertificateType certificateType) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public CertificateType certificateType() { @@ -140,7 +144,7 @@ public CertificateType certificateType() { * @return fluent interface */ public PeerConnectionConfiguration iceTransportPolicy(IceTransportPolicy iceTransportPolicy) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public IceTransportPolicy iceTransportPolicy() { @@ -154,7 +158,7 @@ public IceTransportPolicy iceTransportPolicy() { * @return fluent interface */ public PeerConnectionConfiguration withEnableIceTcp(boolean enableIceTcp) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public boolean enableIceTcp() { @@ -169,7 +173,7 @@ public boolean enableIceTcp() { * @return fluent interface */ public PeerConnectionConfiguration withEnableIceUdpMux(boolean enableIceUdpMux) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public boolean enableIceUdpMux() { @@ -185,7 +189,7 @@ public boolean enableIceUdpMux() { * @return fluent interface */ public PeerConnectionConfiguration withIceUdpMuxDirect(boolean iceUdpMuxDirect) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public boolean iceUdpMuxDirect() { @@ -199,7 +203,7 @@ public boolean iceUdpMuxDirect() { * @return fluent interface */ public PeerConnectionConfiguration withDisableAutoNegotiation(boolean disableAutoNegotiation) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public boolean disableAutoNegotiation() { @@ -213,7 +217,7 @@ public boolean disableAutoNegotiation() { * @return fluent interface */ public PeerConnectionConfiguration withForceMediaTransport(boolean forceMediaTransport) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public boolean forceMediaTransport() { @@ -228,7 +232,7 @@ public boolean forceMediaTransport() { * @return fluent interface */ public PeerConnectionConfiguration withPortRangeBegin(int portRangeBegin) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public int portRangeBegin() { @@ -243,7 +247,7 @@ public int portRangeBegin() { * @return fluent interface */ public PeerConnectionConfiguration withPortRangeEnd(int portRangeEnd) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public int portRangeEnd() { @@ -257,7 +261,7 @@ public int portRangeEnd() { * @return fluent interface */ public PeerConnectionConfiguration withMtu(int mtu) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public int mtu() { @@ -271,13 +275,31 @@ public int mtu() { * @return fluent interface */ public PeerConnectionConfiguration withMaxMessageSize(int maxMessageSize) { - return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize); + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); } public int maxMessageSize() { return maxMessageSize; } + /** + * (optional): the DSCP to mark Data Channel packets and the DTLS handshake with, 0 to 63, for instance 0 for best effort + * ({@link #DEFAULT_DATA_CHANNEL_DSCP} for libdatachannel's default, AF11) + * + * @param dataChannelDscp the DSCP value + * @return fluent interface + */ + public PeerConnectionConfiguration withDataChannelDscp(int dataChannelDscp) { + if (dataChannelDscp != DEFAULT_DATA_CHANNEL_DSCP && (dataChannelDscp < 0 || dataChannelDscp > 63)) { + throw new IllegalArgumentException("DSCP must be between 0 and 63: " + dataChannelDscp); + } + return new PeerConnectionConfiguration(iceServers, proxyServer, bindAddress, certificateType, iceTransportPolicy, enableIceTcp, enableIceUdpMux, iceUdpMuxDirect, disableAutoNegotiation, forceMediaTransport, portRangeBegin, portRangeEnd, mtu, maxMessageSize, dataChannelDscp); + } + + public int dataChannelDscp() { + return dataChannelDscp; + } + public static Collection uris(String... uris) { try { List out = new ArrayList<>(uris.length);