@@ -40,10 +40,17 @@ export interface IScreensharingOpts {
40
40
throwOnFail ?: boolean ;
41
41
}
42
42
43
+ export interface AudioSettings {
44
+ autoGainControl : boolean ;
45
+ echoCancellation : boolean ;
46
+ noiseSuppression : boolean ;
47
+ }
48
+
43
49
export class MediaHandler extends TypedEventEmitter <
44
50
MediaHandlerEvent . LocalStreamsChanged , MediaHandlerEventHandlerMap
45
51
> {
46
52
private audioInput ?: string ;
53
+ private audioSettings ?: AudioSettings ;
47
54
private videoInput ?: string ;
48
55
private localUserMediaStream ?: MediaStream ;
49
56
public userMediaStreams : MediaStream [ ] = [ ] ;
@@ -64,21 +71,32 @@ export class MediaHandler extends TypedEventEmitter<
64
71
* undefined treated as unset
65
72
*/
66
73
public async setAudioInput ( deviceId : string ) : Promise < void > {
67
- logger . info ( "LOG setting audio input to" , deviceId ) ;
74
+ logger . info ( "Setting audio input to" , deviceId ) ;
68
75
69
76
if ( this . audioInput === deviceId ) return ;
70
77
71
78
this . audioInput = deviceId ;
72
79
await this . updateLocalUsermediaStreams ( ) ;
73
80
}
74
81
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
+
75
93
/**
76
94
* Set a video input device to use for MatrixCalls
77
95
* @param {string } deviceId the identifier for the device
78
96
* undefined treated as unset
79
97
*/
80
98
public async setVideoInput ( deviceId : string ) : Promise < void > {
81
- logger . info ( "LOG setting video input to" , deviceId ) ;
99
+ logger . info ( "Setting video input to" , deviceId ) ;
82
100
83
101
if ( this . videoInput === deviceId ) return ;
84
102
@@ -362,6 +380,9 @@ export class MediaHandler extends TypedEventEmitter<
362
380
audio : audio
363
381
? {
364
382
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 ,
365
386
}
366
387
: false ,
367
388
video : video
0 commit comments