Pārlūkot izejas kodu

make audio processing constraints configurable (#491)

* make audio processing constraints configurable

AP: echoCancellation is a "master switch" for disabling all audio processing.  set to disableAP=true and stereo=true allows fullband, stereo sound.
AGC: misbehaves with certain 'pre-gained' mics.
HPF: can't hear any effect but it's the last constraint to make configurable.

* Update RTCUtils.js
dev1
jlightfoot 8 gadus atpakaļ
vecāks
revīzija
f85134be8c
1 mainītis faili ar 25 papildinājumiem un 3 dzēšanām
  1. 25
    3
      modules/RTC/RTCUtils.js

+ 25
- 3
modules/RTC/RTCUtils.js Parādīt failu

@@ -51,12 +51,21 @@ let audioOutputDeviceId = 'default'; // default device
51 51
 // whether user has explicitly set a device to use
52 52
 let audioOutputChanged = false;
53 53
 
54
+// Disables all audio processing
55
+let disableAP = false;
56
+
54 57
 // Disables Acoustic Echo Cancellation
55 58
 let disableAEC = false;
56 59
 
57 60
 // Disables Noise Suppression
58 61
 let disableNS = false;
59 62
 
63
+// Disables Automatic Gain Control
64
+let disableAGC = false;
65
+
66
+// Disables Highpass Filter
67
+let disableHPF = false;
68
+
60 69
 const featureDetectionAudioEl = document.createElement('audio');
61 70
 const isAudioOutputDeviceChangeAvailable
62 71
     = typeof featureDetectionAudioEl.setSinkId !== 'undefined';
@@ -251,13 +260,14 @@ function getConstraints(um, options) {
251 260
 
252 261
             // if it is good enough for hangouts...
253 262
             constraints.audio.optional.push(
263
+                { echoCancellation: !disableAP },
254 264
                 { googEchoCancellation: !disableAEC },
255
-                { googAutoGainControl: true },
265
+                { googAutoGainControl: !disableAGC },
256 266
                 { googNoiseSupression: !disableNS },
257
-                { googHighpassFilter: true },
267
+                { googHighpassFilter: !disableHPF },
258 268
                 { googNoiseSuppression2: !disableNS },
259 269
                 { googEchoCancellation2: !disableAEC },
260
-                { googAutoGainControl2: true }
270
+                { googAutoGainControl2: !disableAGC }
261 271
             );
262 272
         }
263 273
     }
@@ -737,6 +747,18 @@ class RTCUtils extends Listenable {
737 747
             disableNS = options.disableNS;
738 748
             logger.info(`Disable NS: ${disableNS}`);
739 749
         }
750
+        if (typeof options.disableAP === 'boolean') {
751
+            disableAP = options.disableAP;
752
+            logger.info(`Disable AP: ${disableAP}`);
753
+        }
754
+        if (typeof options.disableAGC === 'boolean') {
755
+            disableAGC = options.disableAGC;
756
+            logger.info(`Disable AGC: ${disableAGC}`);
757
+        }
758
+        if (typeof options.disableHPF === 'boolean') {
759
+            disableHPF = options.disableHPF;
760
+            logger.info(`Disable HPF: ${disableHPF}`);
761
+        }
740 762
 
741 763
         return new Promise((resolve, reject) => {
742 764
             if (RTCBrowserType.isFirefox()) {

Notiek ielāde…
Atcelt
Saglabāt