浏览代码

feat: Always enables googSuspendBelowMinBitrate for p2p. (#542)

dev1
bgrozev 8 年前
父节点
当前提交
77d2583f38
共有 2 个文件被更改,包括 21 次插入10 次删除
  1. 4
    3
      modules/RTC/RTC.js
  2. 17
    7
      modules/RTC/RTCUtils.js

+ 4
- 3
modules/RTC/RTC.js 查看文件

@@ -369,7 +369,8 @@ export default class RTC extends Listenable {
369 369
             = new TraceablePeerConnection(
370 370
                 this,
371 371
                 this.peerConnectionIdCounter,
372
-                signaling, iceConfig, RTC.getPCConstraints(), isP2P, options);
372
+                signaling,
373
+                iceConfig, RTC.getPCConstraints(isP2P), isP2P, options);
373 374
 
374 375
         this.peerConnections.set(newConnection.id, newConnection);
375 376
         this.peerConnectionIdCounter += 1;
@@ -540,8 +541,8 @@ export default class RTC extends Listenable {
540 541
     /**
541 542
      *
542 543
      */
543
-    static getPCConstraints() {
544
-        return RTCUtils.pcConstraints;
544
+    static getPCConstraints(isP2P) {
545
+        return isP2P ? RTCUtils.p2pPcConstraints : RTCUtils.pcConstraints;
545 546
     }
546 547
 
547 548
     /**

+ 17
- 7
modules/RTC/RTCUtils.js 查看文件

@@ -851,13 +851,6 @@ class RTCUtils extends Listenable {
851 851
 
852 852
                 this.pcConstraints = { optional: [] };
853 853
 
854
-                // Allows sending of video to be suspended if the bandwidth
855
-                // estimation is too low.
856
-                if (!options.disableSuspendVideo) {
857
-                    this.pcConstraints.optional.push(
858
-                        { googSuspendBelowMinBitrate: true });
859
-                }
860
-
861 854
                 if (options.useIPv6) {
862 855
                     // https://code.google.com/p/webrtc/issues/detail?id=2828
863 856
                     this.pcConstraints.optional.push({ googIPv6: true });
@@ -873,6 +866,21 @@ class RTCUtils extends Listenable {
873 866
                         return this.audioTracks;
874 867
                     };
875 868
                 }
869
+
870
+                this.p2pPcConstraints
871
+                    = JSON.parse(JSON.stringify(this.pcConstraints));
872
+
873
+                // Allows sending of video to be suspended if the bandwidth
874
+                // estimation is too low.
875
+                if (!options.disableSuspendVideo) {
876
+                    this.pcConstraints.optional.push(
877
+                        { googSuspendBelowMinBitrate: true });
878
+                }
879
+
880
+                // There's no reason not to use this for p2p
881
+                this.p2pPcConstraints.optional.push({
882
+                    googSuspendBelowMinBitrate: true
883
+                });
876 884
             } else if (RTCBrowserType.isEdge()) {
877 885
                 this.RTCPeerConnectionType = ortcRTCPeerConnection;
878 886
                 this.getUserMedia
@@ -986,6 +994,8 @@ class RTCUtils extends Listenable {
986 994
                 return;
987 995
             }
988 996
 
997
+            this.p2pPcConstraints = this.p2pPcConstraints || this.pcConstraints;
998
+
989 999
             // Call onReady() if Temasys plugin is not used
990 1000
             if (!RTCBrowserType.isTemasysPluginUsed()) {
991 1001
                 onReady(options, this.getUserMediaWithConstraints.bind(this));

正在加载...
取消
保存