fixed localrouter timeout, updated VideoGrant fields

This commit is contained in:
David Zhao
2021-01-24 12:52:40 -08:00
parent 18264e7a8b
commit c4fb1b3808
5 changed files with 22 additions and 5 deletions
+1 -1
View File
@@ -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{
+3 -3
View File
@@ -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"`
}
+13 -1
View File
@@ -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]
+4
View File
@@ -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(),
+1
View File
@@ -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 {