From e6c236357a6930176914136493c8f6376fbbc620 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Sat, 5 Feb 2022 22:57:47 -0800 Subject: [PATCH] Option to disable ICE-Lite to improve compatibility (#408) --- pkg/config/config.go | 24 ++++++++++++------------ pkg/config/ip.go | 2 +- pkg/rtc/config.go | 4 ++++ pkg/rtc/transport.go | 4 ++-- pkg/service/roommanager.go | 4 ++-- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index b6a52a708..47d1605ca 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -46,16 +46,14 @@ type Config struct { } type RTCConfig struct { - UDPPort uint32 `yaml:"udp_port,omitempty"` - TCPPort uint32 `yaml:"tcp_port,omitempty"` - ICEPortRangeStart uint32 `yaml:"port_range_start,omitempty"` - ICEPortRangeEnd uint32 `yaml:"port_range_end,omitempty"` - NodeIP string `yaml:"node_ip,omitempty"` - // for testing, disable UDP - ForceTCP bool `yaml:"force_tcp,omitempty"` - StunServers []string `yaml:"stun_servers,omitempty"` - UseExternalIP bool `yaml:"use_external_ip"` - + UDPPort uint32 `yaml:"udp_port,omitempty"` + TCPPort uint32 `yaml:"tcp_port,omitempty"` + ICEPortRangeStart uint32 `yaml:"port_range_start,omitempty"` + ICEPortRangeEnd uint32 `yaml:"port_range_end,omitempty"` + NodeIP string `yaml:"node_ip,omitempty"` + STUNServers []string `yaml:"stun_servers,omitempty"` + UseExternalIP bool `yaml:"use_external_ip"` + UseICELite bool `yaml:"use_ice_lite,omitempty"` // Number of packets to buffer for NACK PacketBufferSize int `yaml:"packet_buffer_size,omitempty"` @@ -69,6 +67,8 @@ type RTCConfig struct { UseSendSideBWE bool `yaml:"send_side_bandwidth_estimation,omitempty"` CongestionControl CongestionControlConfig `yaml:"congestion_control,omitempty"` + // for testing, disable UDP + ForceTCP bool `yaml:"force_tcp,omitempty"` } type PLIThrottleConfig struct { @@ -168,8 +168,8 @@ func NewConfig(confString string, c *cli.Context) (*Config, error) { UDPPort: 0, ICEPortRangeStart: 0, ICEPortRangeEnd: 0, - StunServers: []string{}, - MaxBitrate: 3 * 1024 * 1024, // 3 mbps + STUNServers: []string{}, + MaxBitrate: 10 * 1024 * 1024, // 10 mbps PacketBufferSize: 500, PLIThrottle: PLIThrottleConfig{ LowQuality: 500 * time.Millisecond, diff --git a/pkg/config/ip.go b/pkg/config/ip.go index a33216f2c..f93dfb9b9 100644 --- a/pkg/config/ip.go +++ b/pkg/config/ip.go @@ -12,7 +12,7 @@ import ( func (conf *Config) determineIP() (string, error) { if conf.RTC.UseExternalIP { - stunServers := conf.RTC.StunServers + stunServers := conf.RTC.STUNServers if len(stunServers) == 0 { stunServers = DefaultStunServers } diff --git a/pkg/rtc/config.go b/pkg/rtc/config.go index 3dd8b7753..c58ea7a94 100644 --- a/pkg/rtc/config.go +++ b/pkg/rtc/config.go @@ -176,6 +176,10 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err subscriberConfig.RTCPFeedback.Video = append(subscriberConfig.RTCPFeedback.Video, webrtc.RTCPFeedback{Type: webrtc.TypeRTCPFBGoogREMB}) } + if rtcConf.UseICELite { + s.SetLite(true) + } + return &WebRTCConfig{ Configuration: c, SettingEngine: s, diff --git a/pkg/rtc/transport.go b/pkg/rtc/transport.go index 0ee924f03..602b981aa 100644 --- a/pkg/rtc/transport.go +++ b/pkg/rtc/transport.go @@ -108,8 +108,8 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat // se.DisableSRTPReplayProtection(true) se.DisableSRTCPReplayProtection(true) - if params.ProtocolVersion.SupportsICELite() { - se.SetLite(true) + if !params.ProtocolVersion.SupportsICELite() { + se.SetLite(false) } lf := serverlogger.NewLoggerFactory(logr.Logger(params.Logger)) diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index 92c892b40..d7eee25c7 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -515,9 +515,9 @@ func (r *RoomManager) iceServersForRoom(ri *livekit.Room) []*livekit.ICEServer { } } - if len(r.config.RTC.StunServers) > 0 { + if len(r.config.RTC.STUNServers) > 0 { hasSTUN = true - iceServers = append(iceServers, iceServerForStunServers(r.config.RTC.StunServers)) + iceServers = append(iceServers, iceServerForStunServers(r.config.RTC.STUNServers)) } if !hasSTUN {