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
SendableMetatype added a commit to EduGeyser/webrtc-java that referenced this pull request Oct 10, 2026
Brings in upstream 0.19.0 and the work after it: the FFmpeg-based
webrtc-java-media module with its native extension API (devopvoid#291, devopvoid#292,
devopvoid#299, devopvoid#300), encoded frame transforms (devopvoid#300), the remaining sender
encoding parameters and RTCConfiguration fields (devopvoid#316, devopvoid#317), custom
and hardware video codec factories (devopvoid#303, devopvoid#310 to devopvoid#315, devopvoid#318 to devopvoid#330),
the log sink and 32-bit ARM stats fixes, and upstream's CI rework
(devopvoid#294 to devopvoid#309).

Fork-side adaptations:
- The media module builds with Gradle, and only in the full variant:
  it needs audio and video. On Linux it links like the JNI library,
  since the Chromium sysroots no longer ship the static libgcc_eh.a.
  The sysroots carry stubs of glibc that no executable links against,
  so FFmpeg's configure links with lld and allows undefined symbols in
  shared libraries.
- The data channels variant leaves out the new media sources, the codec
  factory setup and the hardware codec headers, and skips the new tests
  that need audio or video.
- The module tests run on the module path with the test resources
  patched in, and the core tests open the internal package that
  NativeApi and NativeLoader are tested in.
- The WebRTC checkout keeps this fork's sync, with upstream's
  checkout_instrumented_libraries setting.
- CI builds all platforms from one reusable workflow, as upstream now
  does. The full variant also builds FFmpeg and tests the media module.
  The WebRTC and FFmpeg caches are saved as soon as their builds finish,
  and a release is prepared locally and pushed in one atomic push.
- The Maven poms and upstream's Dependabot setup stay out, and the
  README is the fork's own; the rename script now leaves it alone.
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