@@ -40,10 +40,17 @@ export interface IScreensharingOpts {
4040 throwOnFail ?: boolean ;
4141}
4242
43+ export interface AudioSettings {
44+ autoGainControl : boolean ;
45+ echoCancellation : boolean ;
46+ noiseSuppression : boolean ;
47+ }
48+
4349export class MediaHandler extends TypedEventEmitter <
4450 MediaHandlerEvent . LocalStreamsChanged , MediaHandlerEventHandlerMap
4551> {
4652 private audioInput ?: string ;
53+ private audioSettings ?: AudioSettings ;
4754 private videoInput ?: string ;
4855 private localUserMediaStream ?: MediaStream ;
4956 public userMediaStreams : MediaStream [ ] = [ ] ;
@@ -64,21 +71,32 @@ export class MediaHandler extends TypedEventEmitter<
6471 * undefined treated as unset
6572 */
6673 public async setAudioInput ( deviceId : string ) : Promise < void > {
67- logger . info ( "LOG setting audio input to" , deviceId ) ;
74+ logger . info ( "Setting audio input to" , deviceId ) ;
6875
6976 if ( this . audioInput === deviceId ) return ;
7077
7178 this . audioInput = deviceId ;
7279 await this . updateLocalUsermediaStreams ( ) ;
7380 }
7481
82+ /**
83+ * Set audio settings for MatrixCalls
84+ * @param {AudioSettings } opts audio options to set
85+ */
86+ public async setAudioSettings ( opts : AudioSettings ) : Promise < void > {
87+ logger . info ( "Setting audio settings to" , opts ) ;
88+
89+ this . audioSettings = Object . assign ( { } , opts ) as AudioSettings ;
90+ await this . updateLocalUsermediaStreams ( ) ;
91+ }
92+
7593 /**
7694 * Set a video input device to use for MatrixCalls
7795 * @param {string } deviceId the identifier for the device
7896 * undefined treated as unset
7997 */
8098 public async setVideoInput ( deviceId : string ) : Promise < void > {
81- logger . info ( "LOG setting video input to" , deviceId ) ;
99+ logger . info ( "Setting video input to" , deviceId ) ;
82100
83101 if ( this . videoInput === deviceId ) return ;
84102
@@ -362,6 +380,9 @@ export class MediaHandler extends TypedEventEmitter<
362380 audio : audio
363381 ? {
364382 deviceId : this . audioInput ? { ideal : this . audioInput } : undefined ,
383+ autoGainControl : this . audioSettings ? { ideal : this . audioSettings . autoGainControl } : undefined ,
384+ echoCancellation : this . audioSettings ? { ideal : this . audioSettings . echoCancellation } : undefined ,
385+ noiseSuppression : this . audioSettings ? { ideal : this . audioSettings . noiseSuppression } : undefined ,
365386 }
366387 : false ,
367388 video : video
0 commit comments