From adc20649ce49a4d9ab7d9eec62fcb0a7b7443ed4 Mon Sep 17 00:00:00 2001 From: sibi <12626864+sibis@users.noreply.github.com> Date: Tue, 22 Mar 2022 13:55:06 -0700 Subject: [PATCH] limit speaker events to microhpone track (#553) * limit speaker events to microhpone track * PR suggestion --- pkg/rtc/participant.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 9eb5df30f..22a80b04b 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -635,11 +635,14 @@ func (p *ParticipantImpl) ICERestart() error { func (p *ParticipantImpl) GetAudioLevel() (level uint8, active bool) { level = SilentAudioLevel for _, pt := range p.GetPublishedTracks() { - tl, ta := pt.(types.LocalMediaTrack).GetAudioLevel() - if ta { - active = true - if tl < level { - level = tl + mediaTrack := pt.(types.LocalMediaTrack) + if mediaTrack.Source() == livekit.TrackSource_MICROPHONE { + tl, ta := mediaTrack.GetAudioLevel() + if ta { + active = true + if tl < level { + level = tl + } } } }