浏览代码

fix(safari): Use standard audio constraints on non-chromium browsers

Standard audio constraints need to be passed to gUM for audio input device selection
to work properly on Safari.
Safari doesn't support permissions query, add a workaround for that.
dev1
Jaya Allamsetty 5 年前
父节点
当前提交
fb1a910265
共有 2 个文件被更改,包括 37 次插入20 次删除
  1. 8
    0
      JitsiMediaDevices.js
  2. 29
    20
      modules/RTC/RTCUtils.js

+ 8
- 0
JitsiMediaDevices.js 查看文件

@@ -136,6 +136,14 @@ class JitsiMediaDevices {
136 136
             // Check using the Permissions API.
137 137
             this._permissionsApiSupported.then(supported => {
138 138
                 if (!supported) {
139
+                    // Workaround on Safari for audio input device
140
+                    // selection to work. Safari doesn't support the
141
+                    // permissions query.
142
+                    if (browser.isSafari()) {
143
+                        resolve(true);
144
+
145
+                        return;
146
+                    }
139 147
                     resolve(false);
140 148
 
141 149
                     return;

+ 29
- 20
modules/RTC/RTCUtils.js 查看文件

@@ -398,27 +398,36 @@ function newGetConstraints(um = [], options = {}) {
398 398
             constraints.audio = {};
399 399
         }
400 400
 
401
-        // NOTE(brian): the new-style ('advanced' instead of 'optional')
402
-        // doesn't seem to carry through the googXXX constraints
403
-        // Changing back to 'optional' here (even with video using
404
-        // the 'advanced' style) allows them to be passed through
405
-        // but also requires the device id to capture to be set in optional
406
-        // as sourceId otherwise the constraints are considered malformed.
407
-        if (!constraints.audio.optional) {
408
-            constraints.audio.optional = [];
401
+        // Use the standard audio constraints on non-chromium browsers.
402
+        if (browser.isFirefox() || browser.isSafari()) {
403
+            constraints.audio = {
404
+                deviceId: options.micDeviceId,
405
+                autoGainControl: !disableAGC && !disableAP,
406
+                echoCancellation: !disableAEC && !disableAP,
407
+                noiseSuppression: !disableNS && !disableAP
408
+            };
409
+        } else {
410
+            // NOTE(brian): the new-style ('advanced' instead of 'optional')
411
+            // doesn't seem to carry through the googXXX constraints
412
+            // Changing back to 'optional' here (even with video using
413
+            // the 'advanced' style) allows them to be passed through
414
+            // but also requires the device id to capture to be set in optional
415
+            // as sourceId otherwise the constraints are considered malformed.
416
+            if (!constraints.audio.optional) {
417
+                constraints.audio.optional = [];
418
+            }
419
+            constraints.audio.optional.push(
420
+                { sourceId: options.micDeviceId },
421
+                { echoCancellation: !disableAEC && !disableAP },
422
+                { googEchoCancellation: !disableAEC && !disableAP },
423
+                { googAutoGainControl: !disableAGC && !disableAP },
424
+                { googNoiseSuppression: !disableNS && !disableAP },
425
+                { googHighpassFilter: !disableHPF && !disableAP },
426
+                { googNoiseSuppression2: !disableNS && !disableAP },
427
+                { googEchoCancellation2: !disableAEC && !disableAP },
428
+                { googAutoGainControl2: !disableAGC && !disableAP }
429
+            );
409 430
         }
410
-
411
-        constraints.audio.optional.push(
412
-            { sourceId: options.micDeviceId },
413
-            { echoCancellation: !disableAEC && !disableAP },
414
-            { googEchoCancellation: !disableAEC && !disableAP },
415
-            { googAutoGainControl: !disableAGC && !disableAP },
416
-            { googNoiseSuppression: !disableNS && !disableAP },
417
-            { googHighpassFilter: !disableHPF && !disableAP },
418
-            { googNoiseSuppression2: !disableNS && !disableAP },
419
-            { googEchoCancellation2: !disableAEC && !disableAP },
420
-            { googAutoGainControl2: !disableAGC && !disableAP }
421
-        );
422 431
     } else {
423 432
         constraints.audio = false;
424 433
     }

正在加载...
取消
保存