@@ -14,6 +14,7 @@ import EventEmitterForwarder from './modules/util/EventEmitterForwarder';
1414import JingleSessionPC from './modules/xmpp/JingleSessionPC' ;
1515import { MediaType } from './service/RTC/MediaType' ;
1616import RTCEvents from './service/RTC/RTCEvents' ;
17+ import { ReceiverAudioSubscription } from './service/RTC/ReceiverAudioSubscription' ;
1718import { VideoType } from './service/RTC/VideoType' ;
1819import AuthenticationEvents
1920 from './service/authentication/AuthenticationEvents' ;
@@ -487,8 +488,27 @@ export default class JitsiConferenceEventManager {
487488 RTCEvents . REMOTE_TRACK_REMOVED ,
488489 conference . onRemoteTrackRemoved . bind ( conference ) ) ;
489490
491+ rtc . addListener (
492+ RTCEvents . AUDIO_SUBSCRIPTION_MODE_CHANGED ,
493+ ( mode , list ) => {
494+ conference . eventEmitter . emit (
495+ JitsiConferenceEvents . AUDIO_SUBSCRIPTION_MODE_CHANGED , mode , list ) ;
496+
497+ // We need to update the speaker list if audio subscription mode changes such that it triggers a
498+ // dominant speaker change based on the remote audio levels.
499+ if ( conference . statistics && mode !== ReceiverAudioSubscription . ALL ) {
500+ const remoteSpeakerIds = Array . isArray ( list ) ? list . map ( source => source . split ( '-' ) [ 0 ] ) : [ ] ;
501+
502+ conference . statistics . setSpeakerList ( remoteSpeakerIds ) ;
503+ }
504+ }
505+ ) ;
506+
490507 rtc . addListener ( RTCEvents . DOMINANT_SPEAKER_CHANGED ,
491508 ( dominant : string , previous : string [ ] , silence : boolean ) => {
509+ if ( conference . statistics . dominantSpeakerEnabled ) {
510+ return ;
511+ }
492512 if ( ( conference . lastDominantSpeaker !== dominant || conference . dominantSpeakerIsSilent !== silence )
493513 && conference . room ) {
494514 conference . lastDominantSpeaker = dominant ;
@@ -598,6 +618,10 @@ export default class JitsiConferenceEventManager {
598618 JitsiConferenceEvents . BEFORE_STATISTICS_DISPOSED ) ;
599619 } ) ;
600620
621+ conference . statistics . addDominantSpeakerListener ( ( tpc , dominant , previous ) => {
622+ conference . eventEmitter . emit ( JitsiConferenceEvents . DOMINANT_SPEAKER_CHANGED , dominant , previous ) ;
623+ } ) ;
624+
601625 conference . statistics . addEncodeTimeStatsListener ( ( tpc : TraceablePeerConnection , stats : RTCEncodedAudioFrameMetadata ) => {
602626 conference . eventEmitter . emit (
603627 JitsiConferenceEvents . ENCODE_TIME_STATS_RECEIVED , tpc , stats ) ;
0 commit comments