Skip to content

feat: map the remaining peer connection configuration fields - #317

Merged
devopvoid merged 3 commits into
mainfrom
feat/rtc-configuration-fields
Sep 30, 2026
Merged

devopvoid merged 3 commits into
mainfrom
feat/rtc-configuration-fields

Conversation

@devopvoid

Copy link
Copy Markdown
Owner

RTCConfiguration gains the settings WebRTC has and the Java API didn't, plus a fix for how createPeerConnection() reports a rejected configuration.

API

Group New fields
Candidate gathering iceCandidatePoolSize, tcpCandidatePolicy, candidateNetworkPolicy, continualGatheringPolicy, disableIpv6OnWifi, maxIpv6Networks, networkPreference, vpnPreference, surfaceIceCandidatesOnIceTransportTypeChanged
ICE checks iceConnectionReceivingTimeout, iceBackupCandidatePairPingInterval, iceCheckIntervalStrongConnectivity, iceCheckIntervalWeakConnectivity, iceCheckMinInterval, iceUnwritableTimeout, iceUnwritableMinChecks, iceInactiveTimeout, stunCandidateKeepaliveInterval, stableWritableConnectionPingInterval, prioritizeMostLikelyIceCandidatePairs, enableIceRenomination
TURN presumeWritableWhenFullyRelayed, turnPortPrunePolicy, turnLoggingId
Media enableDscp, enableCpuAdaptation, suspendBelowMinBitrate, screencastMinBitrate
Security cryptoOptions: the new RTCCryptoOptions for SRTP cipher suites and cryptex (RFC 9335)
Signaling offerExtmapAllowMixed, enableImplicitRollback, alwaysNegotiateDataChannels

New enums: RTCTcpCandidatePolicy, RTCCandidateNetworkPolicy, RTCContinualGatheringPolicy, RTCPortPrunePolicy, RTCVpnPreference, RTCAdapterType, RTCCryptexPolicy.

Design

  • Unset means WebRTC's default. The new fields use nullable types. Several WebRTC defaults are true (DSCP, CPU adaptation, extmap-allow-mixed), and a plain Java boolean would have silently turned them off.
  • getConfiguration() returns the values in effect, defaults included.
  • RTCAdapterType is mapped explicitly, because the native adapter types are bit flags, which the by-ordinal enum conversion can't map.
  • Left out:
    • requireFrameEncryption: it needs a native frame encryptor, which the library doesn't expose (its encryption uses encoded transforms), so it would stop all sending.
    • Experimental or internal fields: SCTP SNAP, pacer burst, usage-pattern reporting.
  • Docs checked against WebRTC's comments. For example, networkPreference wins over pair priority and network cost rather than only breaking ties, and screencastMinBitrate pads screen share video up to that bitrate.

Fix (separate commit)

  • Garbled error: when WebRTC rejected a configuration, createPeerConnection() threw with a garbled error type. ToString(RTCErrorType) returns a string_view, which was passed to a %s vararg as it was (undefined behavior). It's now passed as a C string.
  • Leaked observer: the native observer created for the connection leaked in that case, since no peer connection took it. It's now deleted.

Testing

RTCConfigurationFieldsTests (5 tests):

  • Native defaults: a default configuration reads back WebRTC's defaults, including the true ones.
  • Round trip: every new field survives creation and getConfiguration().
  • setConfiguration(): changes to modifiable fields are applied.
  • Rejected configuration: the error message names a readable error type.
  • Behavior: with tcpCandidatePolicy = DISABLED, gathering yields no TCP candidates.

mvn -pl webrtc test: 189 tests pass. -Pjni-check: 189 tests pass, with no FATAL ERROR in native method.

Docs

New guide: docs/guide/networking/peer-connection-config.md (Peer Connection Configuration), linked from the sidebar and the guide index.

devopvoid and others added 3 commits September 30, 2026 19:27
…erver

When WebRTC rejected a configuration, createPeerConnection() threw with a
message whose error type was garbage: the type name is a string_view,
which was passed to a %s vararg as it was. It is now passed as a C string.

The native observer made for the connection also leaked then, as no peer
connection took it; it is now deleted.
RTCConfiguration gains the settings WebRTC has and the Java API did not:
candidate gathering (iceCandidatePoolSize, tcpCandidatePolicy,
candidateNetworkPolicy, continualGatheringPolicy, IPv6 limits,
networkPreference, vpnPreference), the timing of ICE checks, TURN port
pruning and logging, DSCP, CPU adaptation, suspension below the minimum
bitrate, the screen share bitrate floor, the SRTP cipher suites and cryptex
(RTCCryptoOptions), extmap-allow-mixed, implicit rollback and eager data
channel negotiation.

The new fields are unset by default, which keeps WebRTC's defaults, some of
which are true; getConfiguration() returns the values in effect. Network
adapter types are mapped explicitly, as their native values are bit flags.
Frame encryption is left out: it needs a native frame encryptor, which the
library does not expose, and would stop all sending otherwise.

A new guide describes the peer connection configuration.
@devopvoid
devopvoid merged commit 8f3fef6 into main Sep 30, 2026
15 of 16 checks passed
@devopvoid
devopvoid deleted the feat/rtc-configuration-fields branch September 30, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant