Send explicit message to clients for mute/unmute. (#107)
* Send explicit message to clients for mute/unmute. * documentation in config
This commit is contained in:
@@ -38,7 +38,7 @@ func newMockParticipant(identity string, protocol types.ProtocolVersion, hidden
|
||||
}
|
||||
}
|
||||
|
||||
p.SetTrackMutedStub = func(sid string, muted bool) {
|
||||
p.SetTrackMutedStub = func(sid string, muted bool, fromServer bool) {
|
||||
updateTrack()
|
||||
}
|
||||
p.AddTrackStub = func(req *livekit.AddTrackRequest) {
|
||||
|
||||
+13
-1
@@ -536,7 +536,7 @@ func (p *ParticipantImpl) SendDataPacket(dp *livekit.DataPacket) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) SetTrackMuted(trackId string, muted bool) {
|
||||
func (p *ParticipantImpl) SetTrackMuted(trackId string, muted bool, fromAdmin bool) {
|
||||
isPending := false
|
||||
p.lock.RLock()
|
||||
for _, ti := range p.pendingTracks {
|
||||
@@ -559,6 +559,18 @@ func (p *ParticipantImpl) SetTrackMuted(trackId string, muted bool) {
|
||||
currentMuted := track.IsMuted()
|
||||
track.SetMuted(muted)
|
||||
|
||||
// when request is coming from admin, send message to current participant
|
||||
if fromAdmin {
|
||||
_ = p.writeMessage(&livekit.SignalResponse{
|
||||
Message: &livekit.SignalResponse_Mute{
|
||||
Mute: &livekit.MuteTrackRequest{
|
||||
Sid: trackId,
|
||||
Muted: muted,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if currentMuted != track.IsMuted() && p.onTrackUpdated != nil {
|
||||
logger.Debugw("mute status changed",
|
||||
"participant", p.Identity(),
|
||||
|
||||
@@ -165,7 +165,7 @@ func TestMuteSetting(t *testing.T) {
|
||||
ti := &livekit.TrackInfo{Sid: "testTrack"}
|
||||
p.pendingTracks["cid"] = ti
|
||||
|
||||
p.SetTrackMuted(ti.Sid, true)
|
||||
p.SetTrackMuted(ti.Sid, true, false)
|
||||
require.True(t, ti.Muted)
|
||||
|
||||
})
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestParticipantUpdate(t *testing.T) {
|
||||
"track mutes are sent to everyone",
|
||||
true,
|
||||
func(p types.Participant) {
|
||||
p.SetTrackMuted("", true)
|
||||
p.SetTrackMuted("", true, false)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ type Participant interface {
|
||||
SendParticipantUpdate(participants []*livekit.ParticipantInfo) error
|
||||
SendActiveSpeakers(speakers []*livekit.SpeakerInfo) error
|
||||
SendDataPacket(packet *livekit.DataPacket) error
|
||||
SetTrackMuted(trackId string, muted bool)
|
||||
SetTrackMuted(trackId string, muted bool, fromAdmin bool)
|
||||
GetAudioLevel() (level uint8, active bool)
|
||||
|
||||
// permissions
|
||||
|
||||
@@ -351,11 +351,12 @@ type FakeParticipant struct {
|
||||
setResponseSinkArgsForCall []struct {
|
||||
arg1 routing.MessageSink
|
||||
}
|
||||
SetTrackMutedStub func(string, bool)
|
||||
SetTrackMutedStub func(string, bool, bool)
|
||||
setTrackMutedMutex sync.RWMutex
|
||||
setTrackMutedArgsForCall []struct {
|
||||
arg1 string
|
||||
arg2 bool
|
||||
arg3 bool
|
||||
}
|
||||
StartStub func()
|
||||
startMutex sync.RWMutex
|
||||
@@ -2278,17 +2279,18 @@ func (fake *FakeParticipant) SetResponseSinkArgsForCall(i int) routing.MessageSi
|
||||
return argsForCall.arg1
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) SetTrackMuted(arg1 string, arg2 bool) {
|
||||
func (fake *FakeParticipant) SetTrackMuted(arg1 string, arg2 bool, arg3 bool) {
|
||||
fake.setTrackMutedMutex.Lock()
|
||||
fake.setTrackMutedArgsForCall = append(fake.setTrackMutedArgsForCall, struct {
|
||||
arg1 string
|
||||
arg2 bool
|
||||
}{arg1, arg2})
|
||||
arg3 bool
|
||||
}{arg1, arg2, arg3})
|
||||
stub := fake.SetTrackMutedStub
|
||||
fake.recordInvocation("SetTrackMuted", []interface{}{arg1, arg2})
|
||||
fake.recordInvocation("SetTrackMuted", []interface{}{arg1, arg2, arg3})
|
||||
fake.setTrackMutedMutex.Unlock()
|
||||
if stub != nil {
|
||||
fake.SetTrackMutedStub(arg1, arg2)
|
||||
fake.SetTrackMutedStub(arg1, arg2, arg3)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2298,17 +2300,17 @@ func (fake *FakeParticipant) SetTrackMutedCallCount() int {
|
||||
return len(fake.setTrackMutedArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) SetTrackMutedCalls(stub func(string, bool)) {
|
||||
func (fake *FakeParticipant) SetTrackMutedCalls(stub func(string, bool, bool)) {
|
||||
fake.setTrackMutedMutex.Lock()
|
||||
defer fake.setTrackMutedMutex.Unlock()
|
||||
fake.SetTrackMutedStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) SetTrackMutedArgsForCall(i int) (string, bool) {
|
||||
func (fake *FakeParticipant) SetTrackMutedArgsForCall(i int) (string, bool, bool) {
|
||||
fake.setTrackMutedMutex.RLock()
|
||||
defer fake.setTrackMutedMutex.RUnlock()
|
||||
argsForCall := fake.setTrackMutedArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) Start() {
|
||||
|
||||
Reference in New Issue
Block a user