ソースを参照

fix(safari): override min/max video constraints on safari (#1243)

* fix(safari): override min/max video constraints on safari
Override the constraints on Safari because of the following webkit bug.
https://bugs.webkit.org/show_bug.cgi?id=210932
Camera doesn't start on older macOS versions if min/max constraints are specified.
dev1
Jaya Allamsetty 5年前
コミット
fb997564a6
コミッターのメールアドレスに関連付けられたアカウントが存在しません
2個のファイルの変更19行の追加2行の削除
  1. 18
    2
      modules/RTC/RTCUtils.js
  2. 1
    0
      package.json

+ 18
- 2
modules/RTC/RTCUtils.js ファイルの表示

@@ -10,6 +10,7 @@ import { AVAILABLE_DEVICE } from '../../service/statistics/AnalyticsEvents';
10 10
 import CameraFacingMode from '../../service/RTC/CameraFacingMode';
11 11
 import EventEmitter from 'events';
12 12
 import { getLogger } from 'jitsi-meet-logger';
13
+import clonedeep from 'lodash.clonedeep';
13 14
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
14 15
 import JitsiTrackError from '../../JitsiTrackError';
15 16
 import Listenable from '../util/Listenable';
@@ -374,14 +375,29 @@ function getConstraints(um, options = {}) {
374 375
 function newGetConstraints(um = [], options = {}) {
375 376
     // Create a deep copy of the constraints to avoid any modification of
376 377
     // the passed in constraints object.
377
-    const constraints = JSON.parse(JSON.stringify(
378
-        options.constraints || DEFAULT_CONSTRAINTS));
378
+    const constraints = clonedeep(options.constraints || DEFAULT_CONSTRAINTS);
379 379
 
380 380
     if (um.indexOf('video') >= 0) {
381 381
         if (!constraints.video) {
382 382
             constraints.video = {};
383 383
         }
384 384
 
385
+        // Override the constraints on Safari because of the following webkit bug.
386
+        // https://bugs.webkit.org/show_bug.cgi?id=210932
387
+        // Camera doesn't start on older macOS versions if min/max constraints are specified.
388
+        // TODO: remove this hack when the bug fix is available on Mojave, Sierra and High Sierra.
389
+        if (browser.isSafari()) {
390
+            if (constraints.video.height && constraints.video.height.ideal) {
391
+                constraints.video.height = { ideal: clonedeep(constraints.video.height.ideal) };
392
+            } else {
393
+                logger.warn('Ideal camera height missing, camera may not start properly');
394
+            }
395
+            if (constraints.video.width && constraints.video.width.ideal) {
396
+                constraints.video.width = { ideal: clonedeep(constraints.video.width.ideal) };
397
+            } else {
398
+                logger.warn('Ideal camera width missing, camera may not start properly');
399
+            }
400
+        }
385 401
         if (options.cameraDeviceId) {
386 402
             constraints.video.deviceId = options.cameraDeviceId;
387 403
         } else {

+ 1
- 0
package.json ファイルの表示

@@ -22,6 +22,7 @@
22 22
     "current-executing-script": "0.1.3",
23 23
     "jitsi-meet-logger": "github:jitsi/jitsi-meet-logger#5ec92357570dc8f0b7ffc1528820721c84c6af8b",
24 24
     "js-utils": "github:jitsi/js-utils#cf11996bd866fdb47326c59a5d3bc24be17282d4",
25
+    "lodash.clonedeep": "4.5.0",
25 26
     "lodash.isequal": "4.5.0",
26 27
     "sdp-transform": "2.3.0",
27 28
     "strophe.js": "1.3.4",

読み込み中…
キャンセル
保存