Browse Source

feat(RTCUtils): add options for suspend video evaluation

dev1
hristoterezov 8 years ago
parent
commit
be665cbff7
1 changed files with 28 additions and 4 deletions
  1. 28
    4
      modules/RTC/RTCUtils.js

+ 28
- 4
modules/RTC/RTCUtils.js View File

876
                         { googSuspendBelowMinBitrate: true });
876
                         { googSuspendBelowMinBitrate: true });
877
                 }
877
                 }
878
 
878
 
879
-                // There's no reason not to use this for p2p
880
-                this.p2pPcConstraints.optional.push({
881
-                    googSuspendBelowMinBitrate: true
882
-                });
879
+                /**
880
+                 * This option is used to enable the suspend video only for
881
+                 * part of the users on the P2P peer connection. The value of
882
+                 * the option is the ratio:
883
+                 * (users with suspended video enabled)/(all users).
884
+                 *
885
+                 * Note: The option is not documented because it is temporary
886
+                 * and only for internal testing purpose.
887
+                 *
888
+                 * @type {number}
889
+                 */
890
+                const forceP2PSuspendVideoRatio
891
+                    = options.testing.forceP2PSuspendVideoRatio;
892
+
893
+                // If <tt>forceP2PSuspendVideoRatio</tt> is invalid (not a
894
+                // number) fallback to the default behavior (enabled for every
895
+                // user).
896
+                if (typeof forceP2PSuspendVideoRatio !== 'number'
897
+                        || Math.random() < forceP2PSuspendVideoRatio) {
898
+                    logger.info(`Enable suspend video mode for p2p (ratio=${
899
+                        forceP2PSuspendVideoRatio})`);
900
+                    Statistics.analytics.addPermanentProperties({
901
+                        forceP2PSuspendVideo: true
902
+                    });
903
+                    this.p2pPcConstraints.optional.push({
904
+                        googSuspendBelowMinBitrate: true
905
+                    });
906
+                }
883
             } else if (RTCBrowserType.isEdge()) {
907
             } else if (RTCBrowserType.isEdge()) {
884
                 this.RTCPeerConnectionType = ortcRTCPeerConnection;
908
                 this.RTCPeerConnectionType = ortcRTCPeerConnection;
885
                 this.getUserMedia
909
                 this.getUserMedia

Loading…
Cancel
Save