feat: map the remaining peer connection configuration fields - #317
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RTCConfigurationgains the settings WebRTC has and the Java API didn't, plus a fix for howcreatePeerConnection()reports a rejected configuration.API
iceCandidatePoolSize,tcpCandidatePolicy,candidateNetworkPolicy,continualGatheringPolicy,disableIpv6OnWifi,maxIpv6Networks,networkPreference,vpnPreference,surfaceIceCandidatesOnIceTransportTypeChangediceConnectionReceivingTimeout,iceBackupCandidatePairPingInterval,iceCheckIntervalStrongConnectivity,iceCheckIntervalWeakConnectivity,iceCheckMinInterval,iceUnwritableTimeout,iceUnwritableMinChecks,iceInactiveTimeout,stunCandidateKeepaliveInterval,stableWritableConnectionPingInterval,prioritizeMostLikelyIceCandidatePairs,enableIceRenominationpresumeWritableWhenFullyRelayed,turnPortPrunePolicy,turnLoggingIdenableDscp,enableCpuAdaptation,suspendBelowMinBitrate,screencastMinBitratecryptoOptions: the newRTCCryptoOptionsfor SRTP cipher suites and cryptex (RFC 9335)offerExtmapAllowMixed,enableImplicitRollback,alwaysNegotiateDataChannelsNew enums:
RTCTcpCandidatePolicy,RTCCandidateNetworkPolicy,RTCContinualGatheringPolicy,RTCPortPrunePolicy,RTCVpnPreference,RTCAdapterType,RTCCryptexPolicy.Design
true(DSCP, CPU adaptation, extmap-allow-mixed), and a plain Javabooleanwould have silently turned them off.getConfiguration()returns the values in effect, defaults included.RTCAdapterTypeis mapped explicitly, because the native adapter types are bit flags, which the by-ordinal enum conversion can't map.requireFrameEncryption: it needs a native frame encryptor, which the library doesn't expose (its encryption uses encoded transforms), so it would stop all sending.networkPreferencewins over pair priority and network cost rather than only breaking ties, andscreencastMinBitratepads screen share video up to that bitrate.Fix (separate commit)
createPeerConnection()threw with a garbled error type.ToString(RTCErrorType)returns astring_view, which was passed to a%svararg as it was (undefined behavior). It's now passed as a C string.Testing
RTCConfigurationFieldsTests(5 tests):trueones.getConfiguration().setConfiguration(): changes to modifiable fields are applied.tcpCandidatePolicy = DISABLED, gathering yields no TCP candidates.mvn -pl webrtc test: 189 tests pass.-Pjni-check: 189 tests pass, with noFATAL 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.