Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Participant's Permission and Kind fields #390

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions participant.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"sync"

"go.uber.org/atomic"
"google.golang.org/protobuf/proto"

"github.com/livekit/protocol/livekit"
)
Expand All @@ -26,6 +27,7 @@ type Participant interface {
SID() string
Identity() string
Name() string
Kind() livekit.ParticipantInfo_Kind
IsSpeaking() bool
AudioLevel() float32
Tracks() []TrackPublication
Expand All @@ -34,6 +36,7 @@ type Participant interface {
IsScreenShareEnabled() bool
Metadata() string
GetTrack(source livekit.TrackSource) TrackPublication
Permissions() *livekit.ParticipantPermission

setAudioLevel(level float32)
setIsSpeaking(speaking bool)
Expand Down Expand Up @@ -91,12 +94,28 @@ func (p *baseParticipant) Name() string {
return p.name
}

func (p *baseParticipant) Kind() livekit.ParticipantInfo_Kind {
p.lock.RLock()
defer p.lock.RUnlock()
return p.info.GetKind()
}

func (p *baseParticipant) Metadata() string {
p.lock.RLock()
defer p.lock.RUnlock()
return p.metadata
}

func (p *baseParticipant) Permissions() *livekit.ParticipantPermission {
p.lock.RLock()
defer p.lock.RUnlock()
perm := p.info.GetPermission()
if perm != nil {
return proto.Clone(perm).(*livekit.ParticipantPermission)
}
return nil
}

func (p *baseParticipant) IsSpeaking() bool {
return p.isSpeaking.Load()
}
Expand Down
Loading