Admin APIs for participant management (#13)
* stubs for room admin APIs * room store APIs to persist participants * participant persistence * updated protobufs * implemented APIs to mute/remove/etc * fixed mute handling
This commit is contained in:
+18
-7
@@ -358,6 +358,16 @@ func (p *ParticipantImpl) Close() error {
|
||||
// already closed
|
||||
return nil
|
||||
}
|
||||
|
||||
// remove all downtracks
|
||||
p.lock.Lock()
|
||||
for _, t := range p.publishedTracks {
|
||||
// skip updates
|
||||
t.OnClose(nil)
|
||||
t.RemoveAllSubscribers()
|
||||
}
|
||||
p.lock.Unlock()
|
||||
|
||||
p.updateState(livekit.ParticipantInfo_DISCONNECTED)
|
||||
p.onICECandidate = nil
|
||||
p.peerConn.OnDataChannel(nil)
|
||||
@@ -437,16 +447,17 @@ func (p *ParticipantImpl) SetTrackMuted(trackId string, muted bool) {
|
||||
defer p.lock.RUnlock()
|
||||
track := p.publishedTracks[trackId]
|
||||
if track == nil {
|
||||
logger.Warnw("could not locate track", "track", trackId)
|
||||
return
|
||||
}
|
||||
updated := false
|
||||
currentMuted := track.IsMuted()
|
||||
track.SetMuted(muted)
|
||||
|
||||
switch t := track.(type) {
|
||||
case *MediaTrack:
|
||||
updated = t.muted.TrySet(muted)
|
||||
}
|
||||
|
||||
if updated && p.onTrackUpdated != nil {
|
||||
if currentMuted != track.IsMuted() && p.onTrackUpdated != nil {
|
||||
logger.Debugw("mute status changed",
|
||||
"participant", p.identity,
|
||||
"track", trackId,
|
||||
"muted", track.IsMuted())
|
||||
p.onTrackUpdated(p, track)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user