fixed localrouter timeout, updated VideoGrant fields
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ func main() {
|
|||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "config-body",
|
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"},
|
EnvVars: []string{"LIVEKIT_CONFIG"},
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
type VideoGrant struct {
|
type VideoGrant struct {
|
||||||
RoomCreate bool `json:"room_create,omitempty"`
|
RoomCreate bool `json:"roomCreate,omitempty"`
|
||||||
RoomJoin bool `json:"room_join,omitempty"`
|
RoomJoin bool `json:"roomJoin,omitempty"`
|
||||||
RoomList bool `json:"room_list,omitempty"`
|
RoomList bool `json:"roomList,omitempty"`
|
||||||
Room string `json:"room,omitempty"`
|
Room string `json:"room,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ package routing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/livekit/livekit-server/proto/livekit"
|
"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 {
|
type LocalRouter struct {
|
||||||
currentNode LocalNode
|
currentNode LocalNode
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
@@ -68,7 +69,9 @@ func (r *LocalRouter) StartParticipant(roomName, participantId, participantName
|
|||||||
roomName,
|
roomName,
|
||||||
participantId,
|
participantId,
|
||||||
participantName,
|
participantName,
|
||||||
|
// request source
|
||||||
r.getOrCreateMessageChannel(r.requestChannels, participantId),
|
r.getOrCreateMessageChannel(r.requestChannels, participantId),
|
||||||
|
// response sink
|
||||||
r.getOrCreateMessageChannel(r.responseChannels, participantId),
|
r.getOrCreateMessageChannel(r.responseChannels, participantId),
|
||||||
)
|
)
|
||||||
return nil
|
return nil
|
||||||
@@ -93,6 +96,7 @@ func (r *LocalRouter) OnNewParticipant(callback ParticipantCallback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *LocalRouter) Start() error {
|
func (r *LocalRouter) Start() error {
|
||||||
|
go r.statsWorker()
|
||||||
// on local routers, Start doesn't do anything, websocket connections initiate the connections
|
// on local routers, Start doesn't do anything, websocket connections initiate the connections
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -100,6 +104,14 @@ func (r *LocalRouter) Start() error {
|
|||||||
func (r *LocalRouter) Stop() {
|
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 {
|
func (r *LocalRouter) getOrCreateMessageChannel(target map[string]*MessageChannel, participantId string) *MessageChannel {
|
||||||
r.lock.RLock()
|
r.lock.RLock()
|
||||||
mc := target[participantId]
|
mc := target[participantId]
|
||||||
|
|||||||
@@ -157,6 +157,10 @@ func (t *MediaTrack) AddSubscriber(participant types.Participant) error {
|
|||||||
"srcParticipant", t.participantId,
|
"srcParticipant", t.participantId,
|
||||||
"destParticipant", participant.ID())
|
"destParticipant", participant.ID())
|
||||||
if err := participant.PeerConnection().RemoveTrack(sender); err != nil {
|
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 {
|
if _, ok := err.(*rtcerr.InvalidStateError); !ok {
|
||||||
logger.Warnw("could not remove remoteTrack from forwarder",
|
logger.Warnw("could not remove remoteTrack from forwarder",
|
||||||
"participant", participant.ID(),
|
"participant", participant.ID(),
|
||||||
|
|||||||
@@ -321,6 +321,7 @@ func (p *ParticipantImpl) Close() error {
|
|||||||
return p.ctx.Err()
|
return p.ctx.Err()
|
||||||
}
|
}
|
||||||
close(p.rtcpCh)
|
close(p.rtcpCh)
|
||||||
|
p.onICECandidate = nil
|
||||||
p.updateState(livekit.ParticipantInfo_DISCONNECTED)
|
p.updateState(livekit.ParticipantInfo_DISCONNECTED)
|
||||||
p.responseSink.Close()
|
p.responseSink.Close()
|
||||||
if p.onClose != nil {
|
if p.onClose != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user