From 68767204d2e4a008865e496dfc70255bda3362dc Mon Sep 17 00:00:00 2001 From: Sam Avery Date: Thu, 4 Jun 2026 12:49:34 -0700 Subject: [PATCH] Add ICE candidate-pair acceptance min-wait parameters Forward pion's host/srflx/prflx/relay AcceptanceMinWait to the SettingEngine via rtc.* config, guarded by >0 like the sctp_* params. Unset/0 keeps pion's defaults. Lowering prflx_acceptance_min_wait removes a fixed ~1s connect delay for server-side SDKs co-located with the SFU (no NAT), whose connectivity check can reach the server before their trickled host candidate. --- pkg/rtcconfig/config.go | 6 ++++++ pkg/rtcconfig/webrtc_config.go | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/pkg/rtcconfig/config.go b/pkg/rtcconfig/config.go index 2aaf22b..a0d03d2 100644 --- a/pkg/rtcconfig/config.go +++ b/pkg/rtcconfig/config.go @@ -67,6 +67,12 @@ type RTCConfig struct { SCTPFastRtxWnd int `yaml:"sctp_fast_rtx_wnd,omitempty"` SCTPCwndCAStep int `yaml:"sctp_cwnd_ca_step,omitempty"` + // ICE candidate-pair acceptance min-waits; 0 keeps pion's default + HostAcceptanceMinWait time.Duration `yaml:"host_acceptance_min_wait,omitempty"` + SrflxAcceptanceMinWait time.Duration `yaml:"srflx_acceptance_min_wait,omitempty"` + PrflxAcceptanceMinWait time.Duration `yaml:"prflx_acceptance_min_wait,omitempty"` + RelayAcceptanceMinWait time.Duration `yaml:"relay_acceptance_min_wait,omitempty"` + // for testing, disable UDP ForceTCP bool `yaml:"force_tcp,omitempty"` } diff --git a/pkg/rtcconfig/webrtc_config.go b/pkg/rtcconfig/webrtc_config.go index 55b1663..3c9d489 100644 --- a/pkg/rtcconfig/webrtc_config.go +++ b/pkg/rtcconfig/webrtc_config.go @@ -202,6 +202,19 @@ func NewWebRTCConfig(rtcConf *RTCConfig, development bool) (*WebRTCConfig, error } s.SetNetworkTypes(networkTypes) + if rtcConf.HostAcceptanceMinWait > 0 { + s.SetHostAcceptanceMinWait(rtcConf.HostAcceptanceMinWait) + } + if rtcConf.SrflxAcceptanceMinWait > 0 { + s.SetSrflxAcceptanceMinWait(rtcConf.SrflxAcceptanceMinWait) + } + if rtcConf.PrflxAcceptanceMinWait > 0 { + s.SetPrflxAcceptanceMinWait(rtcConf.PrflxAcceptanceMinWait) + } + if rtcConf.RelayAcceptanceMinWait > 0 { + s.SetRelayAcceptanceMinWait(rtcConf.RelayAcceptanceMinWait) + } + if rtcConf.EnableLoopbackCandidate { s.SetIncludeLoopbackCandidate(true) }