import ActiveSpeakerPolicy from './ActiveSpeakerPolicy' ; export default class DefaultActiveSpeakerPolicy implements ActiveSpeakerPolicy { /**
     * The map of attendeeIds to their active speaker score values
     */ private volumes : { [ attendeeId ] : number ; } = { } ; param speakerWeight param cutoffThreshold param silenceThreshold param takeoverRate constructor ( private speakerWeight = 0.9 , private cutoffThreshold = 0.01 , private silenceThreshold = 0.2 , private takeoverRate = 0.2 ) { } calculateScore ( attendeeId , volume , muted ) { if ( muted || volume === null ) { volume = 0 ; } if ( ! this . volumes . hasOwnProperty ( attendeeId ) ) { this . volumes [ attendeeId ] = 0 ; } if ( volume > this . silenceThreshold ) { volume = 1.0 ; } else { volume = 0.0 ; } const score = this . volumes [ attendeeId ] * this . speakerWeight + volume * ( 1 - this . speakerWeight ) ; this . volumes [ attendeeId ] = score ; for ( const otherAttendeeId in this . volumes ) { if ( otherAttendeeId !== attendeeId ) { this . volumes [ otherAttendeeId ] = Math . max ( this . volumes [ otherAttendeeId ] - this . takeoverRate * volume , 0 ) ; } } if ( score < this . cutoffThreshold ) { return 0 ; } return score ; } prioritizeVideoSendBandwidthForActiveSpeaker ( ) { return true ; } }