Feature: codec restrictions.
In order to ensure clients are publishing with compatible codecs, the server can enforce codec restrictions.
This commit is contained in:
@@ -40,7 +40,6 @@ func printPorts(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if conf.TURN.Enabled {
|
if conf.TURN.Enabled {
|
||||||
udpPorts = append(udpPorts, fmt.Sprintf("%d-%d", conf.TURN.PortRangeStart, conf.TURN.PortRangeEnd))
|
|
||||||
tcpPorts = append(tcpPorts, strconv.Itoa(conf.TURN.TLSPort))
|
tcpPorts = append(tcpPorts, strconv.Itoa(conf.TURN.TLSPort))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-3
@@ -52,6 +52,21 @@ keys:
|
|||||||
key1: secret1
|
key1: secret1
|
||||||
key2: secret2
|
key2: secret2
|
||||||
|
|
||||||
|
# Default room config
|
||||||
|
# Each room created will inherit these settings. If rooms are created explicitly with CreateRoom, they will take
|
||||||
|
# precedence over defaults
|
||||||
|
#room:
|
||||||
|
# # number of seconds to leave a room open when it's empty
|
||||||
|
# empty_timeout: 300
|
||||||
|
# # limit number of participants that can be in a room, 0 for no limit
|
||||||
|
# max_participants: 0
|
||||||
|
# # only accept specific codecs for clients publishing to this room
|
||||||
|
# # this is useful to standardize codecs across clients
|
||||||
|
# # other supported codecs are video/h264, video/vp9
|
||||||
|
# enabled_codecs:
|
||||||
|
# - mime: audio/opus
|
||||||
|
# - mime: video/vp8
|
||||||
|
|
||||||
# customize audio level sensitivity
|
# customize audio level sensitivity
|
||||||
#audio:
|
#audio:
|
||||||
# # minimum level to be considered active, 0-127, where 0 is loudest
|
# # minimum level to be considered active, 0-127, where 0 is loudest
|
||||||
@@ -59,12 +74,12 @@ keys:
|
|||||||
# active_level: 40
|
# active_level: 40
|
||||||
# # percentile to measure, a participant is considered active if it has exceeded the
|
# # percentile to measure, a participant is considered active if it has exceeded the
|
||||||
# # ActiveLevel more than MinPercentile% of the time
|
# # ActiveLevel more than MinPercentile% of the time
|
||||||
# # defaults to 15
|
# # defaults to 40
|
||||||
# min_percentile: 15
|
# min_percentile: 40
|
||||||
# # frequency in ms to notify changes to clients, defaults to 500
|
# # frequency in ms to notify changes to clients, defaults to 500
|
||||||
# update_interval: 500
|
# update_interval: 500
|
||||||
# # to prevent speaker updates from too jumpy, smooth out values over N samples
|
# # to prevent speaker updates from too jumpy, smooth out values over N samples
|
||||||
# smooth_samples: 5
|
# smooth_samples: 8
|
||||||
|
|
||||||
# turn server
|
# turn server
|
||||||
turn:
|
turn:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ require (
|
|||||||
github.com/google/wire v0.5.0
|
github.com/google/wire v0.5.0
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/jxskiss/base62 v0.0.0-20191017122030-4f11678b909b
|
github.com/jxskiss/base62 v0.0.0-20191017122030-4f11678b909b
|
||||||
github.com/livekit/protocol v0.5.4
|
github.com/livekit/protocol v0.5.5
|
||||||
github.com/magefile/mage v1.11.0
|
github.com/magefile/mage v1.11.0
|
||||||
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
|
|||||||
@@ -236,6 +236,8 @@ github.com/livekit/pion-webrtc/v3 v3.0.30 h1:2RomVfztLegWIePXcyPFJDiF5pbT64aIX4R
|
|||||||
github.com/livekit/pion-webrtc/v3 v3.0.30/go.mod h1:XFQeLYBf++bWWA0sJqh6zF1ouWluosxwTOMOoTZGaD0=
|
github.com/livekit/pion-webrtc/v3 v3.0.30/go.mod h1:XFQeLYBf++bWWA0sJqh6zF1ouWluosxwTOMOoTZGaD0=
|
||||||
github.com/livekit/protocol v0.5.4 h1:OFOOahFXGOusgd8X1Ucnl8H/sxa3DzwSrnmKNIUOu/0=
|
github.com/livekit/protocol v0.5.4 h1:OFOOahFXGOusgd8X1Ucnl8H/sxa3DzwSrnmKNIUOu/0=
|
||||||
github.com/livekit/protocol v0.5.4/go.mod h1:wo3CGfYB7XMF8GoVJAfTARrYSP/ombi+sbLl6AYdKP0=
|
github.com/livekit/protocol v0.5.4/go.mod h1:wo3CGfYB7XMF8GoVJAfTARrYSP/ombi+sbLl6AYdKP0=
|
||||||
|
github.com/livekit/protocol v0.5.5 h1:ZsfmTpaApf2o75qpJLP2f/FsCOwxW2sDJE3HKDa2OXE=
|
||||||
|
github.com/livekit/protocol v0.5.5/go.mod h1:wo3CGfYB7XMF8GoVJAfTARrYSP/ombi+sbLl6AYdKP0=
|
||||||
github.com/lucsky/cuid v1.0.2 h1:z4XlExeoderxoPj2/dxKOyPxe9RCOu7yNq9/XWxIUMQ=
|
github.com/lucsky/cuid v1.0.2 h1:z4XlExeoderxoPj2/dxKOyPxe9RCOu7yNq9/XWxIUMQ=
|
||||||
github.com/lucsky/cuid v1.0.2/go.mod h1:QaaJqckboimOmhRSJXSx/+IT+VTfxfPGSo/6mfgUfmE=
|
github.com/lucsky/cuid v1.0.2/go.mod h1:QaaJqckboimOmhRSJXSx/+IT+VTfxfPGSo/6mfgUfmE=
|
||||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||||
|
|||||||
+33
-14
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
|
"github.com/pion/webrtc/v3"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@@ -15,6 +16,7 @@ type Config struct {
|
|||||||
RTC RTCConfig `yaml:"rtc"`
|
RTC RTCConfig `yaml:"rtc"`
|
||||||
Redis RedisConfig `yaml:"redis"`
|
Redis RedisConfig `yaml:"redis"`
|
||||||
Audio AudioConfig `yaml:"audio"`
|
Audio AudioConfig `yaml:"audio"`
|
||||||
|
Room RoomConfig `yaml:"room"`
|
||||||
TURN TURNConfig `yaml:"turn"`
|
TURN TURNConfig `yaml:"turn"`
|
||||||
KeyFile string `yaml:"key_file"`
|
KeyFile string `yaml:"key_file"`
|
||||||
Keys map[string]string `yaml:"keys"`
|
Keys map[string]string `yaml:"keys"`
|
||||||
@@ -69,14 +71,23 @@ type RedisConfig struct {
|
|||||||
DB int `yaml:"db"`
|
DB int `yaml:"db"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RoomConfig struct {
|
||||||
|
EnabledCodecs []CodecSpec `yaml:"enabled_codecs"`
|
||||||
|
MaxParticipants uint32 `yaml:"max_participants"`
|
||||||
|
EmptyTimeout uint32 `yaml:"empty_timeout"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CodecSpec struct {
|
||||||
|
Mime string `yaml:"mime"`
|
||||||
|
FmtpLine string `yaml:"fmtp_line"`
|
||||||
|
}
|
||||||
|
|
||||||
type TURNConfig struct {
|
type TURNConfig struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
Domain string `yaml:"domain"`
|
Domain string `yaml:"domain"`
|
||||||
CertFile string `yaml:"cert_file"`
|
CertFile string `yaml:"cert_file"`
|
||||||
KeyFile string `yaml:"key_file"`
|
KeyFile string `yaml:"key_file"`
|
||||||
TLSPort int `yaml:"tls_port"`
|
TLSPort int `yaml:"tls_port"`
|
||||||
PortRangeStart uint16 `yaml:"port_range_start"`
|
|
||||||
PortRangeEnd uint16 `yaml:"port_range_end"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(confString string) (*Config, error) {
|
func NewConfig(confString string) (*Config, error) {
|
||||||
@@ -103,21 +114,29 @@ func NewConfig(confString string) (*Config, error) {
|
|||||||
},
|
},
|
||||||
Audio: AudioConfig{
|
Audio: AudioConfig{
|
||||||
ActiveLevel: 40,
|
ActiveLevel: 40,
|
||||||
MinPercentile: 15,
|
MinPercentile: 40,
|
||||||
UpdateInterval: 500,
|
UpdateInterval: 500,
|
||||||
SmoothSamples: 5,
|
SmoothSamples: 8,
|
||||||
},
|
},
|
||||||
Redis: RedisConfig{},
|
Redis: RedisConfig{},
|
||||||
|
Room: RoomConfig{
|
||||||
|
// by default only enable opus and VP8
|
||||||
|
EnabledCodecs: []CodecSpec{
|
||||||
|
{Mime: webrtc.MimeTypeOpus},
|
||||||
|
{Mime: webrtc.MimeTypeVP8},
|
||||||
|
//{Mime: webrtc.MimeTypeH264},
|
||||||
|
//{Mime: webrtc.MimeTypeVP9},
|
||||||
|
},
|
||||||
|
EmptyTimeout: 5 * 60,
|
||||||
|
},
|
||||||
TURN: TURNConfig{
|
TURN: TURNConfig{
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
TLSPort: 3478,
|
TLSPort: 3478,
|
||||||
PortRangeStart: 12000,
|
|
||||||
PortRangeEnd: 14000,
|
|
||||||
},
|
},
|
||||||
Keys: map[string]string{},
|
Keys: map[string]string{},
|
||||||
}
|
}
|
||||||
if confString != "" {
|
if confString != "" {
|
||||||
yaml.Unmarshal([]byte(confString), conf)
|
_ = yaml.Unmarshal([]byte(confString), conf)
|
||||||
}
|
}
|
||||||
return conf, nil
|
return conf, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-8
@@ -1,6 +1,9 @@
|
|||||||
package rtc
|
package rtc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
livekit "github.com/livekit/livekit-server/proto"
|
||||||
"github.com/pion/sdp/v3"
|
"github.com/pion/sdp/v3"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
)
|
)
|
||||||
@@ -9,13 +12,16 @@ const (
|
|||||||
frameMarking = "urn:ietf:params:rtp-hdrext:framemarking"
|
frameMarking = "urn:ietf:params:rtp-hdrext:framemarking"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createPubMediaEngine() (*webrtc.MediaEngine, error) {
|
func createPubMediaEngine(codecs []*livekit.Codec) (*webrtc.MediaEngine, error) {
|
||||||
me := &webrtc.MediaEngine{}
|
me := &webrtc.MediaEngine{}
|
||||||
if err := me.RegisterCodec(webrtc.RTPCodecParameters{
|
opusCodec := webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus, ClockRate: 48000, Channels: 2, SDPFmtpLine: "minptime=10;useinbandfec=1", RTCPFeedback: nil}
|
||||||
RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus, ClockRate: 48000, Channels: 2, SDPFmtpLine: "minptime=10;useinbandfec=1", RTCPFeedback: nil},
|
if isCodecEnabled(codecs, opusCodec) {
|
||||||
PayloadType: 111,
|
if err := me.RegisterCodec(webrtc.RTPCodecParameters{
|
||||||
}, webrtc.RTPCodecTypeAudio); err != nil {
|
RTPCodecCapability: opusCodec,
|
||||||
return nil, err
|
PayloadType: 111,
|
||||||
|
}, webrtc.RTPCodecTypeAudio); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
videoRTCPFeedback := []webrtc.RTCPFeedback{
|
videoRTCPFeedback := []webrtc.RTCPFeedback{
|
||||||
@@ -57,8 +63,10 @@ func createPubMediaEngine() (*webrtc.MediaEngine, error) {
|
|||||||
PayloadType: 123,
|
PayloadType: 123,
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
if err := me.RegisterCodec(codec, webrtc.RTPCodecTypeVideo); err != nil {
|
if isCodecEnabled(codecs, codec.RTPCodecCapability) {
|
||||||
return nil, err
|
if err := me.RegisterCodec(codec, webrtc.RTPCodecTypeVideo); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,3 +97,15 @@ func createSubMediaEngine() (*webrtc.MediaEngine, error) {
|
|||||||
me := &webrtc.MediaEngine{}
|
me := &webrtc.MediaEngine{}
|
||||||
return me, nil
|
return me, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isCodecEnabled(codecs []*livekit.Codec, cap webrtc.RTPCodecCapability) bool {
|
||||||
|
for _, codec := range codecs {
|
||||||
|
if !strings.EqualFold(codec.Mime, cap.MimeType) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if codec.FmtpLine == "" || strings.EqualFold(codec.FmtpLine, cap.SDPFmtpLine) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package rtc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
livekit "github.com/livekit/livekit-server/proto"
|
||||||
|
"github.com/pion/webrtc/v3"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsCodecEnabled(t *testing.T) {
|
||||||
|
t.Run("empty fmtp requirement should match all", func(t *testing.T) {
|
||||||
|
enabledCodecs := []*livekit.Codec{{Mime: "video/h264"}}
|
||||||
|
require.True(t, isCodecEnabled(enabledCodecs, webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264, SDPFmtpLine: "special"}))
|
||||||
|
require.True(t, isCodecEnabled(enabledCodecs, webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264}))
|
||||||
|
require.False(t, isCodecEnabled(enabledCodecs, webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeVP8}))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("when fmtp is provided, require match", func(t *testing.T) {
|
||||||
|
enabledCodecs := []*livekit.Codec{{Mime: "video/h264", FmtpLine: "special"}}
|
||||||
|
require.True(t, isCodecEnabled(enabledCodecs, webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264, SDPFmtpLine: "special"}))
|
||||||
|
require.False(t, isCodecEnabled(enabledCodecs, webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264}))
|
||||||
|
require.False(t, isCodecEnabled(enabledCodecs, webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeVP8}))
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -38,6 +38,7 @@ type ParticipantParams struct {
|
|||||||
ProtocolVersion types.ProtocolVersion
|
ProtocolVersion types.ProtocolVersion
|
||||||
Stats *RoomStatsReporter
|
Stats *RoomStatsReporter
|
||||||
ThrottleConfig config.PLIThrottleConfig
|
ThrottleConfig config.PLIThrottleConfig
|
||||||
|
EnabledCodecs []*livekit.Codec
|
||||||
}
|
}
|
||||||
|
|
||||||
type ParticipantImpl struct {
|
type ParticipantImpl struct {
|
||||||
@@ -102,9 +103,10 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
p.publisher, err = NewPCTransport(TransportParams{
|
p.publisher, err = NewPCTransport(TransportParams{
|
||||||
Target: livekit.SignalTarget_PUBLISHER,
|
Target: livekit.SignalTarget_PUBLISHER,
|
||||||
Config: params.Config,
|
Config: params.Config,
|
||||||
Stats: p.params.Stats,
|
Stats: p.params.Stats,
|
||||||
|
EnabledCodecs: p.params.EnabledCodecs,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -39,16 +39,17 @@ type PCTransport struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TransportParams struct {
|
type TransportParams struct {
|
||||||
Target livekit.SignalTarget
|
Target livekit.SignalTarget
|
||||||
Config *WebRTCConfig
|
Config *WebRTCConfig
|
||||||
Stats *RoomStatsReporter
|
Stats *RoomStatsReporter
|
||||||
|
EnabledCodecs []*livekit.Codec
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPeerConnection(params TransportParams) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) {
|
func newPeerConnection(params TransportParams) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) {
|
||||||
var me *webrtc.MediaEngine
|
var me *webrtc.MediaEngine
|
||||||
var err error
|
var err error
|
||||||
if params.Target == livekit.SignalTarget_PUBLISHER {
|
if params.Target == livekit.SignalTarget_PUBLISHER {
|
||||||
me, err = createPubMediaEngine()
|
me, err = createPubMediaEngine(params.EnabledCodecs)
|
||||||
} else {
|
} else {
|
||||||
me, err = createSubMediaEngine()
|
me, err = createSubMediaEngine()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func NewRoomManager(rp RoomStore, router routing.Router, currentNode routing.Loc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateRoom creates a new room from a request and allocates it to a node to handle
|
// CreateRoom creates a new room from a request and allocates it to a node to handle
|
||||||
// it'll also monitor its state, and cleans it up when appropriate
|
// it'll also monitor fits state, and cleans it up when appropriate
|
||||||
func (r *RoomManager) CreateRoom(req *livekit.CreateRoomRequest) (*livekit.Room, error) {
|
func (r *RoomManager) CreateRoom(req *livekit.CreateRoomRequest) (*livekit.Room, error) {
|
||||||
// find existing room and update it
|
// find existing room and update it
|
||||||
rm, err := r.roomStore.GetRoom(req.Name)
|
rm, err := r.roomStore.GetRoom(req.Name)
|
||||||
@@ -63,6 +63,7 @@ func (r *RoomManager) CreateRoom(req *livekit.CreateRoomRequest) (*livekit.Room,
|
|||||||
CreationTime: time.Now().Unix(),
|
CreationTime: time.Now().Unix(),
|
||||||
TurnPassword: utils.RandomSecret(),
|
TurnPassword: utils.RandomSecret(),
|
||||||
}
|
}
|
||||||
|
applyDefaultRoomConfig(rm, &r.config.Room)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -268,6 +269,7 @@ func (r *RoomManager) StartSession(roomName string, pi routing.ParticipantInit,
|
|||||||
ProtocolVersion: pv,
|
ProtocolVersion: pv,
|
||||||
Stats: room.GetStatsReporter(),
|
Stats: room.GetStatsReporter(),
|
||||||
ThrottleConfig: r.config.RTC.PLIThrottle,
|
ThrottleConfig: r.config.RTC.PLIThrottle,
|
||||||
|
EnabledCodecs: room.Room.EnabledCodecs,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorw("could not create participant", err)
|
logger.Errorw("could not create participant", err)
|
||||||
@@ -488,3 +490,14 @@ func (r *RoomManager) iceServersForRoom(ri *livekit.Room) []*livekit.ICEServer {
|
|||||||
}
|
}
|
||||||
return iceServers
|
return iceServers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func applyDefaultRoomConfig(room *livekit.Room, conf *config.RoomConfig) {
|
||||||
|
room.EmptyTimeout = conf.EmptyTimeout
|
||||||
|
room.MaxParticipants = conf.MaxParticipants
|
||||||
|
for _, codec := range conf.EnabledCodecs {
|
||||||
|
room.EnabledCodecs = append(room.EnabledCodecs, &livekit.Codec{
|
||||||
|
Mime: codec.Mime,
|
||||||
|
FmtpLine: codec.FmtpLine,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package service_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/livekit/livekit-server/pkg/config"
|
||||||
|
"github.com/livekit/livekit-server/pkg/routing"
|
||||||
|
"github.com/livekit/livekit-server/pkg/routing/routingfakes"
|
||||||
|
"github.com/livekit/livekit-server/pkg/service"
|
||||||
|
"github.com/livekit/livekit-server/pkg/service/servicefakes"
|
||||||
|
livekit "github.com/livekit/livekit-server/proto"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCreateRoom(t *testing.T) {
|
||||||
|
manager, conf := newTestRoomManager(t)
|
||||||
|
|
||||||
|
t.Run("ensure default room settings are applied", func(t *testing.T) {
|
||||||
|
room, err := manager.CreateRoom(&livekit.CreateRoomRequest{Name: "myroom"})
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, conf.Room.EmptyTimeout, room.EmptyTimeout)
|
||||||
|
require.Len(t, room.EnabledCodecs, 4)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTestRoomManager(t *testing.T) (*service.RoomManager, *config.Config) {
|
||||||
|
store := &servicefakes.FakeRoomStore{}
|
||||||
|
store.GetRoomReturns(nil, service.ErrRoomNotFound)
|
||||||
|
router := &routingfakes.FakeRouter{}
|
||||||
|
conf, err := config.NewConfig("")
|
||||||
|
require.NoError(t, err)
|
||||||
|
selector := &routing.RandomSelector{}
|
||||||
|
node, err := routing.NewLocalNode(conf)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
router.GetNodeForRoomReturns(node, nil)
|
||||||
|
|
||||||
|
rm, err := service.NewRoomManager(store, router, node, selector, conf)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return rm, conf
|
||||||
|
}
|
||||||
+6
-6
@@ -2,7 +2,6 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -15,7 +14,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
allocateRetries = 1000
|
allocateRetries = 50
|
||||||
|
turnMinPort = 1024
|
||||||
|
turnMaxPort = 30000
|
||||||
livekitRealm = "livekit"
|
livekitRealm = "livekit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,8 +54,8 @@ func NewTurnServer(conf *config.Config, roomStore RoomStore, node routing.LocalN
|
|||||||
RelayAddressGenerator: &turn.RelayAddressGeneratorPortRange{
|
RelayAddressGenerator: &turn.RelayAddressGeneratorPortRange{
|
||||||
RelayAddress: net.ParseIP(node.Ip),
|
RelayAddress: net.ParseIP(node.Ip),
|
||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
MinPort: turnConf.PortRangeStart,
|
MinPort: turnMinPort,
|
||||||
MaxPort: turnConf.PortRangeEnd,
|
MaxPort: turnMaxPort,
|
||||||
MaxRetries: allocateRetries,
|
MaxRetries: allocateRetries,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -62,8 +63,7 @@ func NewTurnServer(conf *config.Config, roomStore RoomStore, node routing.LocalN
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Infow("Starting TURN server",
|
logger.Infow("Starting TURN server",
|
||||||
"TCP port", turnConf.TLSPort,
|
"TLS port", turnConf.TLSPort)
|
||||||
"portRange", fmt.Sprintf("%d-%d", turnConf.PortRangeStart, turnConf.PortRangeEnd))
|
|
||||||
return turn.NewServer(serverConfig)
|
return turn.NewServer(serverConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user