mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 17:45:40 +00:00
Support for TCP-ICE, updated config documentation
This commit is contained in:
52
config-sample.yaml
Normal file
52
config-sample.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
# main TCP port for RoomService and RTC endpoint
|
||||
# for production setups, this port should be placed behind a load balancer with TLS
|
||||
port: 7880
|
||||
|
||||
# log level, valid values: debug, info, warning, error
|
||||
log_level: info
|
||||
|
||||
# when redis is set, LiveKit will automatically operate in a fully distributed fashion
|
||||
# clients could connect to any node and be routed to the same room
|
||||
redis:
|
||||
address: redis.host:6379
|
||||
# username: myuser
|
||||
# password: mypassword
|
||||
|
||||
# WebRTC configuration
|
||||
rtc:
|
||||
# when set, LiveKit will try to route traffic over TCP when UDP isn't available
|
||||
# this port cannot be behind load balancer or TLS, and must be exposed on the node
|
||||
ice_tcp_port: 7881
|
||||
# UDP port range to transport WebRTC data
|
||||
port_range_start: 9000
|
||||
port_range_end: 11000
|
||||
# when set to true, attempts to discover the host's public IP via STUN
|
||||
# this is useful for cloud environments such as AWS, where hosts have an internal IP
|
||||
# that maps to an external one
|
||||
use_external_ip: true
|
||||
# when using REMB, the max bitrate that the SFU would accept
|
||||
max_bitrate: 3145728
|
||||
# number of packets to buffer in the SFU, defaults to 500
|
||||
# packet_buffer_size: 500
|
||||
# optional stun servers to use. by default LiveKit uses Google's public STUN servers
|
||||
# stun_servers:
|
||||
# - server1
|
||||
|
||||
# API key / secret pairs.
|
||||
# Keys are used for JWT authentication
|
||||
keys:
|
||||
key1: secret1
|
||||
key2: secret2
|
||||
|
||||
# customize audio level sensitivity
|
||||
#audio:
|
||||
# # minimum level to be considered active, 0-127, where 0 is loudest
|
||||
# # defaults to 40
|
||||
# active_level: 40
|
||||
# # percentile to measure, a participant is considered active if it has exceeded the
|
||||
# # ActiveLevel more than MinPercentile% of the time
|
||||
# # defaults to 15
|
||||
# min_percentile: 15
|
||||
# # frequency in ms to notify changes to clients, defaults to 500
|
||||
# update_interval: 500
|
||||
|
||||
@@ -22,17 +22,19 @@ type Config struct {
|
||||
}
|
||||
|
||||
type RTCConfig struct {
|
||||
ICEPortRangeStart uint16 `yaml:"port_range_start"`
|
||||
ICEPortRangeEnd uint16 `yaml:"port_range_end"`
|
||||
StunServers []string `yaml:"stun_servers"`
|
||||
UseExternalIP bool `yaml:"use_external_ip"`
|
||||
ICETCPPort uint16 `yaml:"ice_tcp_port"`
|
||||
ICEPortRangeStart uint16 `yaml:"port_range_start"`
|
||||
ICEPortRangeEnd uint16 `yaml:"port_range_end"`
|
||||
// for testing, disable UDP
|
||||
ForceTCP bool `yaml:"force_tcp"`
|
||||
StunServers []string `yaml:"stun_servers"`
|
||||
UseExternalIP bool `yaml:"use_external_ip"`
|
||||
|
||||
// Number of packets to buffer for NACK
|
||||
PacketBufferSize int `yaml:"packet_buffer_size"`
|
||||
|
||||
// Max bitrate for REMB
|
||||
MaxBitrate uint64 `yaml:"max_bitrate"`
|
||||
MaxBufferTime int `yaml:"max_buffer_time"`
|
||||
MaxBitrate uint64 `yaml:"max_bitrate"`
|
||||
}
|
||||
|
||||
type AudioConfig struct {
|
||||
@@ -47,6 +49,7 @@ type AudioConfig struct {
|
||||
|
||||
type RedisConfig struct {
|
||||
Address string `yaml:"address"`
|
||||
Username string `yaml:"username"`
|
||||
Password string `yaml:"password"`
|
||||
}
|
||||
|
||||
@@ -63,7 +66,8 @@ func NewConfig(confString string) (*Config, error) {
|
||||
conf := &Config{
|
||||
Port: 7880,
|
||||
RTC: RTCConfig{
|
||||
UseExternalIP: true,
|
||||
UseExternalIP: true,
|
||||
|
||||
ICEPortRangeStart: 9000,
|
||||
ICEPortRangeEnd: 11000,
|
||||
StunServers: []string{
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package rtc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/go-logr/zapr"
|
||||
"github.com/pion/ion-sfu/pkg/buffer"
|
||||
@@ -21,7 +23,6 @@ type WebRTCConfig struct {
|
||||
type ReceiverConfig struct {
|
||||
packetBufferSize int
|
||||
maxBitrate uint64
|
||||
maxBufferTime int
|
||||
}
|
||||
|
||||
func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig, error) {
|
||||
@@ -55,6 +56,37 @@ func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig,
|
||||
bufferFactory := buffer.NewBufferFactory(conf.PacketBufferSize, zapr.NewLogger(logger.Desugar()))
|
||||
s.BufferFactory = bufferFactory.GetOrNew
|
||||
|
||||
networkTypes := []webrtc.NetworkType{}
|
||||
|
||||
if !conf.ForceTCP {
|
||||
networkTypes = append(networkTypes,
|
||||
webrtc.NetworkTypeUDP4,
|
||||
webrtc.NetworkTypeUDP6)
|
||||
}
|
||||
|
||||
// use TCP mux when it's set
|
||||
if conf.ICETCPPort != 0 {
|
||||
networkTypes = append(networkTypes,
|
||||
webrtc.NetworkTypeTCP4,
|
||||
webrtc.NetworkTypeTCP6,
|
||||
)
|
||||
tcpListener, err := net.ListenTCP("tcp", &net.TCPAddr{
|
||||
IP: net.IP{0, 0, 0, 0},
|
||||
Port: int(conf.ICETCPPort),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tcpMux := webrtc.NewICETCPMux(nil, tcpListener, 10)
|
||||
s.SetICETCPMux(tcpMux)
|
||||
}
|
||||
|
||||
if len(networkTypes) == 0 {
|
||||
return nil, errors.New("TCP is forced but not configured")
|
||||
}
|
||||
s.SetNetworkTypes(networkTypes)
|
||||
|
||||
return &WebRTCConfig{
|
||||
Configuration: c,
|
||||
SettingEngine: s,
|
||||
@@ -62,7 +94,6 @@ func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig,
|
||||
Receiver: ReceiverConfig{
|
||||
packetBufferSize: conf.PacketBufferSize,
|
||||
maxBitrate: conf.MaxBitrate,
|
||||
maxBufferTime: conf.MaxBufferTime,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
port: 7880
|
||||
redis:
|
||||
address: redis.host:6379
|
||||
multi_node: true
|
||||
keys:
|
||||
key1: secret1
|
||||
Reference in New Issue
Block a user