Support for TCP-ICE, updated config documentation
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
+11
-7
@@ -22,17 +22,19 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RTCConfig struct {
|
type RTCConfig struct {
|
||||||
ICEPortRangeStart uint16 `yaml:"port_range_start"`
|
ICETCPPort uint16 `yaml:"ice_tcp_port"`
|
||||||
ICEPortRangeEnd uint16 `yaml:"port_range_end"`
|
ICEPortRangeStart uint16 `yaml:"port_range_start"`
|
||||||
StunServers []string `yaml:"stun_servers"`
|
ICEPortRangeEnd uint16 `yaml:"port_range_end"`
|
||||||
UseExternalIP bool `yaml:"use_external_ip"`
|
// 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
|
// Number of packets to buffer for NACK
|
||||||
PacketBufferSize int `yaml:"packet_buffer_size"`
|
PacketBufferSize int `yaml:"packet_buffer_size"`
|
||||||
|
|
||||||
// Max bitrate for REMB
|
// Max bitrate for REMB
|
||||||
MaxBitrate uint64 `yaml:"max_bitrate"`
|
MaxBitrate uint64 `yaml:"max_bitrate"`
|
||||||
MaxBufferTime int `yaml:"max_buffer_time"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AudioConfig struct {
|
type AudioConfig struct {
|
||||||
@@ -47,6 +49,7 @@ type AudioConfig struct {
|
|||||||
|
|
||||||
type RedisConfig struct {
|
type RedisConfig struct {
|
||||||
Address string `yaml:"address"`
|
Address string `yaml:"address"`
|
||||||
|
Username string `yaml:"username"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +66,8 @@ func NewConfig(confString string) (*Config, error) {
|
|||||||
conf := &Config{
|
conf := &Config{
|
||||||
Port: 7880,
|
Port: 7880,
|
||||||
RTC: RTCConfig{
|
RTC: RTCConfig{
|
||||||
UseExternalIP: true,
|
UseExternalIP: true,
|
||||||
|
|
||||||
ICEPortRangeStart: 9000,
|
ICEPortRangeStart: 9000,
|
||||||
ICEPortRangeEnd: 11000,
|
ICEPortRangeEnd: 11000,
|
||||||
StunServers: []string{
|
StunServers: []string{
|
||||||
|
|||||||
+33
-2
@@ -1,7 +1,9 @@
|
|||||||
package rtc
|
package rtc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
|
|
||||||
"github.com/go-logr/zapr"
|
"github.com/go-logr/zapr"
|
||||||
"github.com/pion/ion-sfu/pkg/buffer"
|
"github.com/pion/ion-sfu/pkg/buffer"
|
||||||
@@ -21,7 +23,6 @@ type WebRTCConfig struct {
|
|||||||
type ReceiverConfig struct {
|
type ReceiverConfig struct {
|
||||||
packetBufferSize int
|
packetBufferSize int
|
||||||
maxBitrate uint64
|
maxBitrate uint64
|
||||||
maxBufferTime int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig, error) {
|
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()))
|
bufferFactory := buffer.NewBufferFactory(conf.PacketBufferSize, zapr.NewLogger(logger.Desugar()))
|
||||||
s.BufferFactory = bufferFactory.GetOrNew
|
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{
|
return &WebRTCConfig{
|
||||||
Configuration: c,
|
Configuration: c,
|
||||||
SettingEngine: s,
|
SettingEngine: s,
|
||||||
@@ -62,7 +94,6 @@ func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig,
|
|||||||
Receiver: ReceiverConfig{
|
Receiver: ReceiverConfig{
|
||||||
packetBufferSize: conf.PacketBufferSize,
|
packetBufferSize: conf.PacketBufferSize,
|
||||||
maxBitrate: conf.MaxBitrate,
|
maxBitrate: conf.MaxBitrate,
|
||||||
maxBufferTime: conf.MaxBufferTime,
|
|
||||||
},
|
},
|
||||||
}, nil
|
}, 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