Expose IsPublisher and IsSubscribedTo via LocalParticipant interface (#772)

This commit is contained in:
David Zhao
2022-06-19 23:58:31 -07:00
committed by GitHub
parent 1e6a12167b
commit 301bd2771c
4 changed files with 155 additions and 10 deletions
+13 -9
View File
@@ -435,7 +435,7 @@ func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo {
Permission: p.grants.Video.ToPermission(),
Metadata: p.grants.Metadata,
Region: p.params.Region,
IsPublisher: p.isPublisher.Load(),
IsPublisher: p.IsPublisher(),
}
p.lock.RUnlock()
info.Tracks = p.UpTrackManager.ToProto()
@@ -828,6 +828,18 @@ func (p *ParticipantImpl) GetSubscribedParticipants() []livekit.ParticipantID {
return participantIDs
}
func (p *ParticipantImpl) IsSubscribedTo(participantID livekit.ParticipantID) bool {
p.lock.RLock()
defer p.lock.RUnlock()
_, ok := p.subscribedTo[participantID]
return ok
}
func (p *ParticipantImpl) IsPublisher() bool {
return p.isPublisher.Load()
}
func (p *ParticipantImpl) CanPublish() bool {
p.lock.RLock()
defer p.lock.RUnlock()
@@ -1362,14 +1374,6 @@ func (p *ParticipantImpl) configureReceiverDTX() {
}
}
func (p *ParticipantImpl) isSubscribedTo(participantID livekit.ParticipantID) bool {
p.lock.RLock()
defer p.lock.RUnlock()
_, ok := p.subscribedTo[participantID]
return ok
}
func (p *ParticipantImpl) onStreamStateChange(update *sfu.StreamStateUpdate) error {
if len(update.StreamStates) == 0 {
return nil