Kaynağa Gözat

feat(RTC): use sdpSemantics to stay on Plan B for now (#830)

It's supported in Chrome >= 65.
dev1
Saúl Ibarra Corretgé 6 yıl önce
ebeveyn
işleme
03411c7488
2 değiştirilmiş dosya ile 48 ekleme ve 21 silme
  1. 6
    0
      modules/RTC/RTC.js
  2. 42
    21
      modules/browser/BrowserCapabilities.js

+ 6
- 0
modules/RTC/RTC.js Dosyayı Görüntüle

@@ -448,7 +448,13 @@ export default class RTC extends Listenable {
448 448
                 { abtestSuspendVideo: options.abtestSuspendVideo });
449 449
         }
450 450
 
451
+        // FIXME: We should rename iceConfig to pcConfig.
452
+        if (browser.supportsSdpSemantics()) {
453
+            iceConfig.sdpSemantics = 'plan-b';
454
+        }
455
+
451 456
         peerConnectionIdCounter = safeCounterIncrement(peerConnectionIdCounter);
457
+
452 458
         const newConnection
453 459
             = new TraceablePeerConnection(
454 460
                 this,

+ 42
- 21
modules/browser/BrowserCapabilities.js Dosyayı Görüntüle

@@ -261,27 +261,7 @@ export default class BrowserCapabilities extends BrowserDetection {
261 261
         }
262 262
 
263 263
         if (this.isChromiumBased()) {
264
-            // NW.JS doesn't expose the Chrome version in the UA string.
265
-            if (this.isNWJS()) {
266
-                // eslint-disable-next-line no-undef
267
-                const version = Number.parseInt(process.versions.chromium, 10);
268
-
269
-                return version >= REQUIRED_CHROME_VERSION;
270
-            }
271
-
272
-            // Here we process all browsers which use the Chrome engine but
273
-            // don't necessarily identify as Chrome. We cannot use the version
274
-            // comparing functions because the Electron, Opera and NW.JS
275
-            // versions are inconsequential here, as we need to know the actual
276
-            // Chrome engine version.
277
-            const ua = navigator.userAgent;
278
-
279
-            if (ua.match(/Chrome/)) {
280
-                const version
281
-                    = Number.parseInt(ua.match(/Chrome\/([\d.]+)/)[1], 10);
282
-
283
-                return version >= REQUIRED_CHROME_VERSION;
284
-            }
264
+            return this._getChromiumBasedVersion() >= REQUIRED_CHROME_VERSION;
285 265
         }
286 266
 
287 267
         return false;
@@ -304,4 +284,45 @@ export default class BrowserCapabilities extends BrowserDetection {
304 284
     supportsGetDisplayMedia() {
305 285
         return navigator.getDisplayMedia !== undefined;
306 286
     }
287
+
288
+    /**
289
+     * Checks if the browser supports the "sdpSemantics" configuration option.
290
+     * https://webrtc.org/web-apis/chrome/unified-plan/
291
+     *
292
+     * @returns {boolean}
293
+     */
294
+    supportsSdpSemantics() {
295
+        return this.isChromiumBased() && this._getChromiumBasedVersion() >= 65;
296
+    }
297
+
298
+    /**
299
+     * Returns the version of a Chromium based browser.
300
+     *
301
+     * @returns {Number}
302
+     */
303
+    _getChromiumBasedVersion() {
304
+        if (this.isChromiumBased()) {
305
+            // NW.JS doesn't expose the Chrome version in the UA string.
306
+            if (this.isNWJS()) {
307
+                // eslint-disable-next-line no-undef
308
+                return Number.parseInt(process.versions.chromium, 10);
309
+            }
310
+
311
+            // Here we process all browsers which use the Chrome engine but
312
+            // don't necessarily identify as Chrome. We cannot use the version
313
+            // comparing functions because the Electron, Opera and NW.JS
314
+            // versions are inconsequential here, as we need to know the actual
315
+            // Chrome engine version.
316
+            const ua = navigator.userAgent;
317
+
318
+            if (ua.match(/Chrome/)) {
319
+                const version
320
+                    = Number.parseInt(ua.match(/Chrome\/([\d.]+)/)[1], 10);
321
+
322
+                return version;
323
+            }
324
+        }
325
+
326
+        return -1;
327
+    }
307 328
 }

Loading…
İptal
Kaydet