mirror of
https://github.com/livekit/livekit.git
synced 2026-05-14 22:45:20 +00:00
updated to ion-sfu v1.9.1, removed package bufferFactory
This commit is contained in:
@@ -4,7 +4,6 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/bep/debounce v1.2.0
|
||||
github.com/fatih/hclfmt v0.0.0-20181010234132-374cd0fd2a55 // indirect
|
||||
github.com/go-redis/redis/v8 v8.4.8
|
||||
github.com/golang/protobuf v1.4.3
|
||||
github.com/google/wire v0.4.0
|
||||
@@ -15,12 +14,12 @@ require (
|
||||
github.com/magefile/mage v1.11.0
|
||||
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/pion/ion-sfu v1.9.0
|
||||
github.com/pion/ion-sfu v1.9.1
|
||||
github.com/pion/rtcp v1.2.6
|
||||
github.com/pion/rtp v1.6.2
|
||||
github.com/pion/sdp/v3 v3.0.4
|
||||
github.com/pion/stun v0.3.5
|
||||
github.com/pion/webrtc/v3 v3.0.11
|
||||
github.com/pion/webrtc/v3 v3.0.12
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/thoas/go-funk v0.7.0
|
||||
@@ -34,5 +33,3 @@ require (
|
||||
gopkg.in/square/go-jose.v2 v2.5.1
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
|
||||
)
|
||||
|
||||
replace github.com/pion/ion-sfu => github.com/davidzhao/ion-sfu v1.8.3-0.20210301061808-6b1f502b192b
|
||||
|
||||
@@ -69,8 +69,6 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davidzhao/ion-sfu v1.8.3-0.20210301061808-6b1f502b192b h1:Liy9QupJ9vWqKJshlZFjE1ONPXylWWcYpkLm6Rompew=
|
||||
github.com/davidzhao/ion-sfu v1.8.3-0.20210301061808-6b1f502b192b/go.mod h1:eRGTRVxYYvW7mhxcBByROYvZdm2aUqDSG499rje2Jh8=
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
@@ -88,8 +86,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/hclfmt v0.0.0-20181010234132-374cd0fd2a55 h1:FucIiafNzNNvdfp8BzKYDPXMCAhJaBsNjqiPdPJcieA=
|
||||
github.com/fatih/hclfmt v0.0.0-20181010234132-374cd0fd2a55/go.mod h1:O9mb/7h6jenxXEB9aeff3D8kXpoBKCU2ASH1OflMFjM=
|
||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
@@ -193,7 +189,6 @@ github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
@@ -314,10 +309,13 @@ github.com/pion/dtls/v2 v2.0.7 h1:PNcUs/G1l9hb4jzMEorgFMxIBdp7fRN4LIApOTMtCYs=
|
||||
github.com/pion/dtls/v2 v2.0.7/go.mod h1:QuDII+8FVvk9Dp5t5vYIMTo7hh7uBkra+8QIm7QGm10=
|
||||
github.com/pion/ice/v2 v2.0.15 h1:KZrwa2ciL9od8+TUVJiYTNsCW9J5lktBjGwW1MacEnQ=
|
||||
github.com/pion/ice/v2 v2.0.15/go.mod h1:ZIiVGevpgAxF/cXiIVmuIUtCb3Xs4gCzCbXB6+nFkSI=
|
||||
github.com/pion/interceptor v0.0.9 h1:fk5hTdyLO3KURQsf/+RjMpEm4NE3yeTY9Kh97b5BvwA=
|
||||
github.com/pion/interceptor v0.0.9/go.mod h1:dHgEP5dtxOTf21MObuBAjJeAayPxLUAZjerGH8Xr07c=
|
||||
github.com/pion/interceptor v0.0.10 h1:dXFyFWRJFwmzQqyn0U8dUAbOJu+JJnMVAqxmvTu30B4=
|
||||
github.com/pion/interceptor v0.0.10/go.mod h1:qzeuWuD/ZXvPqOnxNcnhWfkCZ2e1kwwslicyyPnhoK4=
|
||||
github.com/pion/ion-log v1.0.0 h1:2lJLImCmfCWCR38hLWsjQfBWe6NFz/htbqiYHwvOP/Q=
|
||||
github.com/pion/ion-log v1.0.0/go.mod h1:jwcla9KoB9bB/4FxYDSRJPcPYSLp5XiUUMnOLaqwl4E=
|
||||
github.com/pion/ion-sfu v1.9.1 h1:EqTLTw2j2DUKc5qw2l6tvUnDRaEZy899NjXkEEEjoC4=
|
||||
github.com/pion/ion-sfu v1.9.1/go.mod h1:eRGTRVxYYvW7mhxcBByROYvZdm2aUqDSG499rje2Jh8=
|
||||
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
|
||||
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
|
||||
github.com/pion/mdns v0.0.4 h1:O4vvVqr4DGX63vzmO6Fw9vpy3lfztVWHGCQfyw0ZLSY=
|
||||
@@ -348,8 +346,8 @@ github.com/pion/turn/v2 v2.0.5/go.mod h1:APg43CFyt/14Uy7heYUOGWdkem/Wu4PhCO/bjyr
|
||||
github.com/pion/udp v0.1.0 h1:uGxQsNyrqG3GLINv36Ff60covYmfrLoxzwnCsIYspXI=
|
||||
github.com/pion/udp v0.1.0/go.mod h1:BPELIjbwE9PRbd/zxI/KYBnbo7B6+oA6YuEaNE8lths=
|
||||
github.com/pion/webrtc/v3 v3.0.10/go.mod h1:KdEZWLmBnxB2Qj4FtUb9vi1sIpqsHOisI7L6ggQBD0A=
|
||||
github.com/pion/webrtc/v3 v3.0.11 h1:RIxUbkWJn6YvLVmHZSzc30yQLyME5vGDkpqrV7EHxz4=
|
||||
github.com/pion/webrtc/v3 v3.0.11/go.mod h1:WEvXneGTeqNmiR59v5jTsxMc4yXQyOQcRsrdAbNwSEU=
|
||||
github.com/pion/webrtc/v3 v3.0.12 h1:XjTwtnx8dsyfBfESHAdBTnqmajku+2Y9RXXyC4KB0LM=
|
||||
github.com/pion/webrtc/v3 v3.0.12/go.mod h1:Y9t8I+0qeCCaUjg5wrweNVtK7reqZHc/MQdkznhzcro=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
|
||||
@@ -26,6 +26,9 @@ type RTCConfig struct {
|
||||
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"`
|
||||
@@ -51,6 +54,7 @@ func NewConfig(confString string) (*Config, error) {
|
||||
conf := &Config{
|
||||
Port: 7880,
|
||||
RTC: RTCConfig{
|
||||
UseExternalIP: true,
|
||||
ICEPortRangeStart: 9000,
|
||||
ICEPortRangeEnd: 9200,
|
||||
StunServers: []string{
|
||||
|
||||
+18
-9
@@ -3,6 +3,7 @@ package rtc
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pion/ion-sfu/pkg/buffer"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
@@ -12,16 +13,16 @@ type WebRTCConfig struct {
|
||||
Configuration webrtc.Configuration
|
||||
SettingEngine webrtc.SettingEngine
|
||||
Receiver ReceiverConfig
|
||||
BufferFactory *buffer.Factory
|
||||
}
|
||||
|
||||
type ReceiverConfig struct {
|
||||
maxBitrate uint64
|
||||
maxBufferTime int
|
||||
packetBufferSize int
|
||||
maxBitrate uint64
|
||||
maxBufferTime int
|
||||
}
|
||||
|
||||
type ExternalIP string
|
||||
|
||||
func NewWebRTCConfig(conf *config.RTCConfig, externalIP ExternalIP) (*WebRTCConfig, error) {
|
||||
func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig, error) {
|
||||
c := webrtc.Configuration{
|
||||
SDPSemantics: webrtc.SDPSemanticsUnifiedPlan,
|
||||
}
|
||||
@@ -42,16 +43,24 @@ func NewWebRTCConfig(conf *config.RTCConfig, externalIP ExternalIP) (*WebRTCConf
|
||||
URLs: iceUrls,
|
||||
},
|
||||
}
|
||||
if conf.UseExternalIP {
|
||||
s.SetNAT1To1IPs([]string{string(externalIP)}, webrtc.ICECandidateTypeHost)
|
||||
if conf.UseExternalIP && externalIP != "" {
|
||||
s.SetNAT1To1IPs([]string{externalIP}, webrtc.ICECandidateTypeHost)
|
||||
}
|
||||
|
||||
if conf.PacketBufferSize == 0 {
|
||||
conf.PacketBufferSize = 500
|
||||
}
|
||||
bufferFactory := buffer.NewBufferFactory(conf.PacketBufferSize)
|
||||
s.BufferFactory = bufferFactory.GetOrNew
|
||||
|
||||
return &WebRTCConfig{
|
||||
Configuration: c,
|
||||
SettingEngine: s,
|
||||
BufferFactory: bufferFactory,
|
||||
Receiver: ReceiverConfig{
|
||||
maxBitrate: conf.MaxBitrate,
|
||||
maxBufferTime: conf.MaxBufferTime,
|
||||
packetBufferSize: conf.PacketBufferSize,
|
||||
maxBitrate: conf.MaxBitrate,
|
||||
maxBufferTime: conf.MaxBufferTime,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package rtc
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/pion/ion-sfu/pkg/buffer"
|
||||
)
|
||||
|
||||
const (
|
||||
rtpPacketMaxSize = 1460
|
||||
)
|
||||
|
||||
// package level factories for buffers
|
||||
var (
|
||||
bufferFactory = buffer.NewBufferFactory()
|
||||
packetFactory = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
return make([]byte, rtpPacketMaxSize)
|
||||
},
|
||||
}
|
||||
)
|
||||
+13
-13
@@ -33,14 +33,15 @@ type MediaTrack struct {
|
||||
participantId string
|
||||
muted utils.AtomicFlag
|
||||
|
||||
ssrc webrtc.SSRC
|
||||
name string
|
||||
streamID string
|
||||
kind livekit.TrackType
|
||||
codec webrtc.RTPCodecParameters
|
||||
receiverConf ReceiverConfig
|
||||
audioConf config.AudioConfig
|
||||
onClose func()
|
||||
ssrc webrtc.SSRC
|
||||
name string
|
||||
streamID string
|
||||
kind livekit.TrackType
|
||||
codec webrtc.RTPCodecParameters
|
||||
bufferFactory *buffer.Factory
|
||||
receiverConf ReceiverConfig
|
||||
audioConf config.AudioConfig
|
||||
onClose func()
|
||||
|
||||
// channel to send RTCP packets to the source
|
||||
rtcpCh chan []rtcp.Packet
|
||||
@@ -54,7 +55,7 @@ type MediaTrack struct {
|
||||
lastPLI time.Time
|
||||
}
|
||||
|
||||
func NewMediaTrack(trackId string, pId string, rtcpCh chan []rtcp.Packet, track *webrtc.TrackRemote, rc ReceiverConfig, ac config.AudioConfig) *MediaTrack {
|
||||
func NewMediaTrack(trackId string, pId string, rtcpCh chan []rtcp.Packet, track *webrtc.TrackRemote, bufferFactory *buffer.Factory, rc ReceiverConfig, ac config.AudioConfig) *MediaTrack {
|
||||
t := &MediaTrack{
|
||||
id: trackId,
|
||||
participantId: pId,
|
||||
@@ -62,6 +63,7 @@ func NewMediaTrack(trackId string, pId string, rtcpCh chan []rtcp.Packet, track
|
||||
streamID: track.StreamID(),
|
||||
kind: ToProtoTrackKind(track.Kind()),
|
||||
codec: track.Codec(),
|
||||
bufferFactory: bufferFactory,
|
||||
receiverConf: rc,
|
||||
audioConf: ac,
|
||||
rtcpCh: rtcpCh,
|
||||
@@ -136,11 +138,10 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
|
||||
Channels: codec.Channels,
|
||||
SDPFmtpLine: codec.SDPFmtpLine,
|
||||
RTCPFeedback: feedbackTypes,
|
||||
}, t.receiver, sub.ID())
|
||||
}, t.receiver, t.bufferFactory, sub.ID(), t.receiverConf.packetBufferSize)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
downTrack.SetBufferFactory(bufferFactory)
|
||||
subTrack := NewSubscribedTrack(downTrack)
|
||||
|
||||
transceiver, err := sub.SubscriberPC().AddTransceiverFromTrack(downTrack, webrtc.RTPTransceiverInit{
|
||||
@@ -205,7 +206,7 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
|
||||
defer t.lock.Unlock()
|
||||
|
||||
//rid := track.RID()
|
||||
buff, rtcpReader := bufferFactory.GetBufferPair(uint32(track.SSRC()))
|
||||
buff, rtcpReader := t.bufferFactory.GetBufferPair(uint32(track.SSRC()))
|
||||
buff.OnFeedback(func(fb []rtcp.Packet) {
|
||||
// feedback for the source RTCP
|
||||
t.rtcpCh <- fb
|
||||
@@ -258,7 +259,6 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
|
||||
t.receiver.AddUpTrack(track, buff)
|
||||
|
||||
buff.Bind(receiver.GetParameters(), buffer.Options{
|
||||
BufferTime: t.receiverConf.maxBufferTime,
|
||||
MaxBitRate: t.receiverConf.maxBitrate,
|
||||
})
|
||||
}
|
||||
|
||||
+12
-11
@@ -29,19 +29,20 @@ const (
|
||||
)
|
||||
|
||||
type ParticipantImpl struct {
|
||||
id string
|
||||
publisher *PCTransport
|
||||
subscriber *PCTransport
|
||||
responseSink routing.MessageSink
|
||||
receiverConfig ReceiverConfig
|
||||
audioConfig config.AudioConfig
|
||||
isClosed utils.AtomicFlag
|
||||
identity string
|
||||
id string
|
||||
publisher *PCTransport
|
||||
subscriber *PCTransport
|
||||
responseSink routing.MessageSink
|
||||
audioConfig config.AudioConfig
|
||||
isClosed utils.AtomicFlag
|
||||
conf *WebRTCConfig
|
||||
identity string
|
||||
// JSON encoded metadata to pass to clients
|
||||
metadata string
|
||||
state atomic.Value // livekit.ParticipantInfo_State
|
||||
rtcpCh chan []rtcp.Packet
|
||||
|
||||
// hold reference for MediaTrack
|
||||
twcc *twcc.Responder
|
||||
|
||||
// tracks the current participant is subscribed to, map of otherParticipantId => []DownTrack
|
||||
@@ -61,15 +62,15 @@ type ParticipantImpl struct {
|
||||
onClose func(types.Participant)
|
||||
}
|
||||
|
||||
func NewParticipant(identity string, conf *WebRTCConfig, rs routing.MessageSink, rc ReceiverConfig, ac config.AudioConfig) (*ParticipantImpl, error) {
|
||||
func NewParticipant(identity string, conf *WebRTCConfig, rs routing.MessageSink, ac config.AudioConfig) (*ParticipantImpl, error) {
|
||||
// TODO: check to ensure params are valid, id and identity can't be empty
|
||||
|
||||
p := &ParticipantImpl{
|
||||
id: utils.NewGuid(utils.ParticipantPrefix),
|
||||
identity: identity,
|
||||
responseSink: rs,
|
||||
receiverConfig: rc,
|
||||
audioConfig: ac,
|
||||
conf: conf,
|
||||
rtcpCh: make(chan []rtcp.Packet, 50),
|
||||
subscribedTracks: make(map[string][]types.SubscribedTrack),
|
||||
lock: sync.RWMutex{},
|
||||
@@ -593,7 +594,7 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
|
||||
if trk, ok := ptrack.(*MediaTrack); ok {
|
||||
mt = trk
|
||||
} else {
|
||||
mt = NewMediaTrack(ti.Sid, p.id, p.rtcpCh, track, p.receiverConfig, p.audioConfig)
|
||||
mt = NewMediaTrack(ti.Sid, p.id, p.rtcpCh, track, p.conf.BufferFactory, p.conf.Receiver, p.audioConfig)
|
||||
mt.name = ti.Name
|
||||
newTrack = true
|
||||
}
|
||||
|
||||
@@ -120,11 +120,12 @@ func TestDisconnectTiming(t *testing.T) {
|
||||
}
|
||||
|
||||
func newParticipantForTest(identity string) *ParticipantImpl {
|
||||
conf, _ := config.NewConfig("")
|
||||
rtcConf, _ := NewWebRTCConfig(&conf.RTC, "")
|
||||
p, _ := NewParticipant(
|
||||
identity,
|
||||
&WebRTCConfig{},
|
||||
rtcConf,
|
||||
&routingfakes.FakeMessageSink{},
|
||||
ReceiverConfig{},
|
||||
config.AudioConfig{})
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@ func newPeerConnection(target livekit.SignalTarget, conf *WebRTCConfig) (*webrtc
|
||||
}
|
||||
se := conf.SettingEngine
|
||||
se.DisableMediaEngineCopy(true)
|
||||
se.BufferFactory = bufferFactory.GetOrNew
|
||||
|
||||
api := webrtc.NewAPI(webrtc.WithMediaEngine(me), webrtc.WithSettingEngine(se))
|
||||
pc, err := api.NewPeerConnection(conf.Configuration)
|
||||
|
||||
@@ -5,11 +5,9 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/google/wire"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/logger"
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/livekit-server/proto/livekit"
|
||||
@@ -19,15 +17,6 @@ const (
|
||||
trackIdSeparator = "|"
|
||||
)
|
||||
|
||||
var RTCSet = wire.NewSet(
|
||||
NewWebRTCConfig,
|
||||
RTCConfigFromConfig,
|
||||
)
|
||||
|
||||
func RTCConfigFromConfig(conf *config.Config) *config.RTCConfig {
|
||||
return &conf.RTC
|
||||
}
|
||||
|
||||
func UnpackTrackId(packed string) (peerId string, trackId string) {
|
||||
parts := strings.Split(packed, trackIdSeparator)
|
||||
if len(parts) > 1 {
|
||||
|
||||
@@ -33,17 +33,22 @@ type RoomManager struct {
|
||||
rooms map[string]*rtc.Room
|
||||
}
|
||||
|
||||
func NewRoomManager(rp RoomStore, router routing.Router, currentNode routing.LocalNode, selector routing.NodeSelector, config *rtc.WebRTCConfig, ac config.AudioConfig) *RoomManager {
|
||||
func NewRoomManager(rp RoomStore, router routing.Router, currentNode routing.LocalNode, selector routing.NodeSelector, config *config.Config) (*RoomManager, error) {
|
||||
rtcConf, err := rtc.NewWebRTCConfig(&config.RTC, currentNode.Ip)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &RoomManager{
|
||||
lock: sync.RWMutex{},
|
||||
roomStore: rp,
|
||||
config: config,
|
||||
audioConfig: ac,
|
||||
config: rtcConf,
|
||||
audioConfig: config.Audio,
|
||||
router: router,
|
||||
selector: selector,
|
||||
currentNode: currentNode,
|
||||
rooms: make(map[string]*rtc.Room),
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateRoom creates a new room from a request and allocates it to a node to handle
|
||||
@@ -203,7 +208,7 @@ func (r *RoomManager) StartSession(roomName, identity, metadata string, reconnec
|
||||
"num_participants", len(room.GetParticipants()),
|
||||
)
|
||||
|
||||
participant, err = rtc.NewParticipant(identity, r.config, responseSink, r.config.Receiver, r.audioConfig)
|
||||
participant, err = rtc.NewParticipant(identity, r.config, responseSink, r.audioConfig)
|
||||
if err != nil {
|
||||
logger.Errorw("could not create participant", "error", err)
|
||||
return
|
||||
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/logger"
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/rtc"
|
||||
"github.com/livekit/livekit-server/proto/livekit"
|
||||
)
|
||||
|
||||
@@ -20,14 +18,8 @@ var ServiceSet = wire.NewSet(
|
||||
NewRoomManager,
|
||||
config.GetAudioConfig,
|
||||
wire.Bind(new(livekit.RoomService), new(*RoomService)),
|
||||
externalIpFromNode,
|
||||
)
|
||||
|
||||
// helper to construct RTCConfig
|
||||
func externalIpFromNode(currentNode routing.LocalNode) rtc.ExternalIP {
|
||||
return rtc.ExternalIP(currentNode.Ip)
|
||||
}
|
||||
|
||||
func handleError(w http.ResponseWriter, status int, msg string) {
|
||||
l := logger.Desugar().WithOptions(zap.AddCallerSkip(1))
|
||||
l.Debug("error handling request", zap.String("error", msg), zap.Int("status", status))
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/livekit/livekit-server/pkg/auth"
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/rtc"
|
||||
)
|
||||
|
||||
func InitializeServer(conf *config.Config, keyProvider auth.KeyProvider,
|
||||
@@ -16,7 +15,6 @@ func InitializeServer(conf *config.Config, keyProvider auth.KeyProvider,
|
||||
selector routing.NodeSelector) (*LivekitServer, error) {
|
||||
wire.Build(
|
||||
ServiceSet,
|
||||
rtc.RTCSet,
|
||||
)
|
||||
return &LivekitServer{}, nil
|
||||
}
|
||||
|
||||
@@ -9,20 +9,15 @@ import (
|
||||
"github.com/livekit/livekit-server/pkg/auth"
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/rtc"
|
||||
)
|
||||
|
||||
// Injectors from wire.go:
|
||||
|
||||
func InitializeServer(conf *config.Config, keyProvider auth.KeyProvider, roomStore RoomStore, router routing.Router, currentNode routing.LocalNode, selector routing.NodeSelector) (*LivekitServer, error) {
|
||||
rtcConfig := rtc.RTCConfigFromConfig(conf)
|
||||
externalIP := externalIpFromNode(currentNode)
|
||||
webRTCConfig, err := rtc.NewWebRTCConfig(rtcConfig, externalIP)
|
||||
roomManager, err := NewRoomManager(roomStore, router, currentNode, selector, conf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
audioConfig := config.GetAudioConfig(conf)
|
||||
roomManager := NewRoomManager(roomStore, router, currentNode, selector, webRTCConfig, audioConfig)
|
||||
roomService, err := NewRoomService(roomManager)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user