diff --git a/cmd/server/main.go b/cmd/server/main.go index 14bea2d0..bdbbd48e 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -35,7 +35,7 @@ func main() { }, &cli.StringFlag{ Name: "config-body", - Usage: "LiveKit config in YAML, usually used via environment var", + Usage: "LiveKit config in YAML, typically passed in as an environment var in a container", EnvVars: []string{"LIVEKIT_CONFIG"}, }, &cli.StringFlag{ diff --git a/pkg/auth/grants.go b/pkg/auth/grants.go index f80a2da7..1e1f0ebc 100644 --- a/pkg/auth/grants.go +++ b/pkg/auth/grants.go @@ -1,9 +1,9 @@ package auth type VideoGrant struct { - RoomCreate bool `json:"room_create,omitempty"` - RoomJoin bool `json:"room_join,omitempty"` - RoomList bool `json:"room_list,omitempty"` + RoomCreate bool `json:"roomCreate,omitempty"` + RoomJoin bool `json:"roomJoin,omitempty"` + RoomList bool `json:"roomList,omitempty"` Room string `json:"room,omitempty"` } diff --git a/pkg/routing/localrouter.go b/pkg/routing/localrouter.go index 4b3d0874..68bd9835 100644 --- a/pkg/routing/localrouter.go +++ b/pkg/routing/localrouter.go @@ -2,11 +2,12 @@ package routing import ( "sync" + "time" "github.com/livekit/livekit-server/proto/livekit" ) -// a router of messages +// a router of messages on the same node, basic implementation for local testing type LocalRouter struct { currentNode LocalNode lock sync.RWMutex @@ -68,7 +69,9 @@ func (r *LocalRouter) StartParticipant(roomName, participantId, participantName roomName, participantId, participantName, + // request source r.getOrCreateMessageChannel(r.requestChannels, participantId), + // response sink r.getOrCreateMessageChannel(r.responseChannels, participantId), ) return nil @@ -93,6 +96,7 @@ func (r *LocalRouter) OnNewParticipant(callback ParticipantCallback) { } func (r *LocalRouter) Start() error { + go r.statsWorker() // on local routers, Start doesn't do anything, websocket connections initiate the connections return nil } @@ -100,6 +104,14 @@ func (r *LocalRouter) Start() error { func (r *LocalRouter) Stop() { } +func (r *LocalRouter) statsWorker() { + for { + // update every 10 seconds + <-time.After(statsUpdateInterval) + r.currentNode.Stats.UpdatedAt = time.Now().Unix() + } +} + func (r *LocalRouter) getOrCreateMessageChannel(target map[string]*MessageChannel, participantId string) *MessageChannel { r.lock.RLock() mc := target[participantId] diff --git a/pkg/rtc/mediatrack.go b/pkg/rtc/mediatrack.go index 4890b217..58b86c54 100644 --- a/pkg/rtc/mediatrack.go +++ b/pkg/rtc/mediatrack.go @@ -157,6 +157,10 @@ func (t *MediaTrack) AddSubscriber(participant types.Participant) error { "srcParticipant", t.participantId, "destParticipant", participant.ID()) if err := participant.PeerConnection().RemoveTrack(sender); err != nil { + if err == webrtc.ErrConnectionClosed { + // participant closing, can skip removing downtracks + return + } if _, ok := err.(*rtcerr.InvalidStateError); !ok { logger.Warnw("could not remove remoteTrack from forwarder", "participant", participant.ID(), diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index ad7846fe..04038257 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -321,6 +321,7 @@ func (p *ParticipantImpl) Close() error { return p.ctx.Err() } close(p.rtcpCh) + p.onICECandidate = nil p.updateState(livekit.ParticipantInfo_DISCONNECTED) p.responseSink.Close() if p.onClose != nil {