Send speaker update with inactive speaker when participant (#315)

* Send speaker update with inactive speaker when participant
leaves/unsubscribes

* Check that protocol version supports speaker updates
This commit is contained in:
Raja Subramanian
2022-01-04 22:37:13 +05:30
committed by GitHub
parent 973420faf5
commit 46446ef047
+22
View File
@@ -734,6 +734,28 @@ func (p *ParticipantImpl) RemoveSubscribedTrack(subTrack types.SubscribedTrack)
p.lock.Unlock()
if numRemaining == 0 {
p.subscribedTo.Delete(subTrack.PublisherID())
//
// When a participant leaves OR
// this participant unsubscribes from all tracks of another participant,
// have to send speaker update indicating that the participant speaker is no long active
// so that clients can clean up their speaker state for the leaving/unsubscribed participant
//
if p.ProtocolVersion().SupportsSpeakerChanged() {
_ = p.writeMessage(&livekit.SignalResponse{
Message: &livekit.SignalResponse_SpeakersChanged{
SpeakersChanged: &livekit.SpeakersChanged{
Speakers: []*livekit.SpeakerInfo{
&livekit.SpeakerInfo{
Sid: string(subTrack.PublisherID()),
Level: 0,
Active: false,
},
},
},
},
})
}
}
}