server to support mutes

This commit is contained in:
David Zhao
2020-12-31 14:21:19 -08:00
parent be6086ce95
commit 313236e3d3
11 changed files with 231 additions and 150 deletions
+6 -2
View File
@@ -64,14 +64,14 @@ func (r *Room) Join(participant Participant) error {
log := logger.GetLogger()
// it's important to set this before connection, we don't want to miss out on any tracks
// it's important to set this before connection, we don't want to miss out on any publishedTracks
participant.OnTrackPublished(r.onTrackAdded)
participant.OnStateChange(func(p Participant, oldState livekit.ParticipantInfo_State) {
log.Debugw("participant state changed", "state", p.State(), "participant", p.ID())
r.broadcastParticipantState(p)
if oldState == livekit.ParticipantInfo_JOINING && p.State() == livekit.ParticipantInfo_JOINED {
// subscribe participant to existing tracks
// subscribe participant to existing publishedTracks
for _, op := range r.participants {
if p.ID() == op.ID() {
// don't send to itself
@@ -152,6 +152,10 @@ func (r *Room) onTrackAdded(participant Participant, track PublishedTrack) {
}
}
func (r *Room) onTrackMuted(p Participant, track PublishedTrack) {
r.broadcastParticipantState(p)
}
func (r *Room) broadcastParticipantState(p Participant) {
r.lock.RLock()
defer r.lock.RUnlock()