Преглед изворни кода

Video suspend abtest (#634)

* revert: Reverts be665cbff7.

* ref: Renames "peerjid".

* ref: Refactors the initialization of a peer connection.

* feat: Re-implements the A/B test for the "suspend video" feature.

* squash: Deep copy.

* ref: Renames forceSuspendVideo to abtestSuspendVideo.
dev1
bgrozev пре 7 година
родитељ
комит
3aa2356f7a

+ 13
- 12
JitsiConference.js Прегледај датотеку

@@ -1370,7 +1370,7 @@ JitsiConference.prototype.onIncomingCall = function(
1370 1370
         now) {
1371 1371
     // Handle incoming P2P call
1372 1372
     if (jingleSession.isP2P) {
1373
-        const role = this.room.getMemberRole(jingleSession.peerjid);
1373
+        const role = this.room.getMemberRole(jingleSession.remoteJid);
1374 1374
 
1375 1375
         if (role !== 'moderator') {
1376 1376
             // Reject incoming P2P call
@@ -1404,7 +1404,7 @@ JitsiConference.prototype.onIncomingCall = function(
1404 1404
         }
1405 1405
 
1406 1406
         return;
1407
-    } else if (!this.room.isFocus(jingleSession.peerjid)) {
1407
+    } else if (!this.room.isFocus(jingleSession.remoteJid)) {
1408 1408
         this._rejectIncomingCall(jingleSession);
1409 1409
 
1410 1410
         return;
@@ -1535,7 +1535,7 @@ JitsiConference.prototype._rejectIncomingCallNonModerator = function(
1535 1535
             reasonTag: 'security-error',
1536 1536
             reasonMsg: 'Only focus can start new sessions',
1537 1537
             errorMsg: 'Rejecting session-initiate from non-focus and'
1538
-                        + `non-moderator user: ${jingleSession.peerjid}`
1538
+                        + `non-moderator user: ${jingleSession.remoteJid}`
1539 1539
         });
1540 1540
 };
1541 1541
 
@@ -1625,7 +1625,7 @@ JitsiConference.prototype.onCallEnded = function(
1625 1625
         logger.error(
1626 1626
             'Received onCallEnded for invalid session',
1627 1627
             jingleSession.sid,
1628
-            jingleSession.peerjid,
1628
+            jingleSession.remoteJid,
1629 1629
             reasonCondition,
1630 1630
             reasonText);
1631 1631
     }
@@ -2120,7 +2120,7 @@ JitsiConference.prototype._acceptP2PIncomingCall = function(
2120 2120
 
2121 2121
     logger.info('Starting CallStats for P2P connection...');
2122 2122
 
2123
-    let remoteID = Strophe.getResourceFromJid(this.p2pJingleSession.peerjid);
2123
+    let remoteID = Strophe.getResourceFromJid(this.p2pJingleSession.remoteJid);
2124 2124
 
2125 2125
     if (this.options.config.enableStatsID) {
2126 2126
         const participant = this.participants[remoteID];
@@ -2394,10 +2394,10 @@ JitsiConference.prototype._setP2PStatus = function(newStatus) {
2394 2394
 
2395 2395
 /**
2396 2396
  * Starts new P2P session.
2397
- * @param {string} peerJid the JID of the remote participant
2397
+ * @param {string} remoteJid the JID of the remote participant
2398 2398
  * @private
2399 2399
  */
2400
-JitsiConference.prototype._startP2PSession = function(peerJid) {
2400
+JitsiConference.prototype._startP2PSession = function(remoteJid) {
2401 2401
     this._maybeClearDeferredStartP2P();
2402 2402
     if (this.p2pJingleSession) {
2403 2403
         logger.error('P2P session already started!');
@@ -2409,14 +2409,15 @@ JitsiConference.prototype._startP2PSession = function(peerJid) {
2409 2409
     this.p2pJingleSession
2410 2410
         = this.xmpp.connection.jingle.newP2PJingleSession(
2411 2411
             this.room.myroomjid,
2412
-            peerJid);
2413
-    logger.info('Created new P2P JingleSession', this.room.myroomjid, peerJid);
2412
+            remoteJid);
2413
+    logger.info(
2414
+        'Created new P2P JingleSession', this.room.myroomjid, remoteJid);
2414 2415
 
2415 2416
     this.p2pJingleSession.initialize(true /* initiator */, this.room, this.rtc);
2416 2417
 
2417 2418
     logger.info('Starting CallStats for P2P connection...');
2418 2419
 
2419
-    let remoteID = Strophe.getResourceFromJid(this.p2pJingleSession.peerjid);
2420
+    let remoteID = Strophe.getResourceFromJid(this.p2pJingleSession.remoteJid);
2420 2421
 
2421 2422
     if (this.options.config.enableStatsID) {
2422 2423
         const participant = this.participants[remoteID];
@@ -2526,7 +2527,7 @@ JitsiConference.prototype._maybeStartOrStopP2P = function(userLeftEvent) {
2526 2527
             this._startP2PSession(jid);
2527 2528
         }
2528 2529
     } else if (this.p2pJingleSession && !shouldBeInP2P) {
2529
-        logger.info(`Will stop P2P with: ${this.p2pJingleSession.peerjid}`);
2530
+        logger.info(`Will stop P2P with: ${this.p2pJingleSession.remoteJid}`);
2530 2531
 
2531 2532
         // Log that there will be a switch back to the JVB connection
2532 2533
         if (this.p2pJingleSession.isInitiator && peerCount > 1) {
@@ -2600,7 +2601,7 @@ JitsiConference.prototype._stopP2PSession = function(
2600 2601
                 ? reasonDescription : 'Turing off P2P session',
2601 2602
             sendSessionTerminate: this.room
2602 2603
                 && this.getParticipantById(
2603
-                    Strophe.getResourceFromJid(this.p2pJingleSession.peerjid))
2604
+                    Strophe.getResourceFromJid(this.p2pJingleSession.remoteJid))
2604 2605
         });
2605 2606
 
2606 2607
     this.p2pJingleSession = null;

+ 16
- 2
modules/RTC/RTC.js Прегледај датотеку

@@ -13,6 +13,7 @@ import * as MediaType from '../../service/RTC/MediaType';
13 13
 import RTCBrowserType from './RTCBrowserType';
14 14
 import RTCEvents from '../../service/RTC/RTCEvents';
15 15
 import RTCUtils from './RTCUtils';
16
+import Statistics from '../statistics/statistics';
16 17
 import TraceablePeerConnection from './TraceablePeerConnection';
17 18
 import VideoType from '../../service/RTC/VideoType';
18 19
 
@@ -433,12 +434,22 @@ export default class RTC extends Listenable {
433 434
      * @return {TraceablePeerConnection}
434 435
      */
435 436
     createPeerConnection(signaling, iceConfig, isP2P, options) {
437
+        const pcConstraints = RTC.getPCConstraints(isP2P);
438
+
439
+        if (typeof options.abtestSuspendVideo !== 'undefined') {
440
+            RTCUtils.setSuspendVideo(pcConstraints, options.abtestSuspendVideo);
441
+
442
+            Statistics.analytics.addPermanentProperties(
443
+                { abtestSuspendVideo: options.abtestSuspendVideo });
444
+        }
445
+
436 446
         const newConnection
437 447
             = new TraceablePeerConnection(
438 448
                 this,
439 449
                 this.peerConnectionIdCounter,
440 450
                 signaling,
441
-                iceConfig, RTC.getPCConstraints(isP2P), isP2P, options);
451
+                iceConfig, pcConstraints,
452
+                isP2P, options);
442 453
 
443 454
         this.peerConnections.set(newConnection.id, newConnection);
444 455
         this.peerConnectionIdCounter += 1;
@@ -610,7 +621,10 @@ export default class RTC extends Listenable {
610 621
      *
611 622
      */
612 623
     static getPCConstraints(isP2P) {
613
-        return isP2P ? RTCUtils.p2pPcConstraints : RTCUtils.pcConstraints;
624
+        const pcConstraints
625
+            = isP2P ? RTCUtils.p2pPcConstraints : RTCUtils.pcConstraints;
626
+
627
+        return JSON.parse(JSON.stringify(pcConstraints));
614 628
     }
615 629
 
616 630
     /**

+ 28
- 30
modules/RTC/RTCUtils.js Прегледај датотеку

@@ -1117,36 +1117,10 @@ class RTCUtils extends Listenable {
1117 1117
                     { googSuspendBelowMinBitrate: true });
1118 1118
             }
1119 1119
 
1120
-            /**
1121
-             * This option is used to enable the suspend video only for
1122
-             * part of the users on the P2P peer connection. The value of
1123
-             * the option is the ratio:
1124
-             * (users with suspended video enabled)/(all users).
1125
-             *
1126
-             * Note: The option is not documented because it is temporary
1127
-             * and only for internal testing purpose.
1128
-             *
1129
-             * @type {number}
1130
-             */
1131
-            const forceP2PSuspendVideoRatio
1132
-                = (options.testing || {}).forceP2PSuspendVideoRatio;
1133
-
1134
-            // If <tt>forceP2PSuspendVideoRatio</tt> is invalid (not a
1135
-            // number) fallback to the default behavior (enabled for every
1136
-            // user).
1137
-            if (typeof forceP2PSuspendVideoRatio !== 'number'
1138
-                    || Math.random() < forceP2PSuspendVideoRatio) {
1139
-                logger.info(`Enable suspend video mode for p2p (ratio=${
1140
-                    forceP2PSuspendVideoRatio})`);
1141
-
1142
-                Statistics.analytics.addPermanentProperties({
1143
-                    forceP2PSuspendVideo: true
1144
-                });
1145
-
1146
-                this.p2pPcConstraints.optional.push({
1147
-                    googSuspendBelowMinBitrate: true
1148
-                });
1149
-            }
1120
+            // There's no reason not to use this for p2p
1121
+            this.p2pPcConstraints.optional.push({
1122
+                googSuspendBelowMinBitrate: true
1123
+            });
1150 1124
         }
1151 1125
 
1152 1126
         this.p2pPcConstraints = this.p2pPcConstraints || this.pcConstraints;
@@ -1781,6 +1755,30 @@ class RTCUtils extends Listenable {
1781 1755
 
1782 1756
         return { deviceList };
1783 1757
     }
1758
+
1759
+    /**
1760
+     * Configures the given PeerConnection constraints to either enable or
1761
+     * disable (according to the value of the 'enable' parameter) the
1762
+     * 'googSuspendBelowMinBitrate' option.
1763
+     * @param constraints the constraints on which to operate.
1764
+     * @param enable {boolean} whether to enable or disable the suspend video
1765
+     * option.
1766
+     */
1767
+    setSuspendVideo(constraints, enable) {
1768
+        if (!constraints.optional) {
1769
+            constraints.optional = [];
1770
+        }
1771
+
1772
+        // Get rid of all "googSuspendBelowMinBitrate" constraints (we assume
1773
+        // that the elements of constraints.optional contain a single property).
1774
+        constraints.optional
1775
+            = constraints.optional.filter(
1776
+                c => !c.hasOwnProperty('googSuspendBelowMinBitrate'));
1777
+
1778
+        if (enable) {
1779
+            constraints.optional.push({ googSuspendBelowMinBitrate: 'true' });
1780
+        }
1781
+    }
1784 1782
 }
1785 1783
 
1786 1784
 /**

+ 24
- 0
modules/util/StringUtils.js Прегледај датотеку

@@ -0,0 +1,24 @@
1
+/**
2
+ * Implements a simple hash code for a string (see
3
+ * https://en.wikipedia.org/wiki/Java_hashCode()).
4
+ *
5
+ * @param {string} The string to return a hash of.
6
+ * @return {Number} the integer hash code of the string.
7
+ */
8
+function integerHash(string) {
9
+    if (!string) {
10
+        return 0;
11
+    }
12
+
13
+    let char, hash = 0, i;
14
+
15
+    for (i = 0; i < string.length; i++) {
16
+        char = string.charCodeAt(i);
17
+        hash += char * Math.pow(31, string.length - 1 - i);
18
+        hash = Math.abs(hash | 0); // eslint-disable-line no-bitwise
19
+    }
20
+
21
+    return hash;
22
+}
23
+
24
+module.exports = { integerHash };

+ 12
- 5
modules/xmpp/JingleSession.js Прегледај датотеку

@@ -17,7 +17,7 @@ export default class JingleSession {
17 17
      * Creates new <tt>JingleSession</tt>.
18 18
      * @param {string} sid the Jingle session identifier
19 19
      * @param {string} localJid our JID
20
-     * @param {string} peerjid the JID of the remote peer
20
+     * @param {string} remoteJid the JID of the remote peer
21 21
      * @param {Strophe.Connection} connection the XMPP connection
22 22
      * @param {Object} mediaConstraints the media constraints object passed to
23 23
      * the PeerConnection onCreateAnswer/Offer as defined by the WebRTC.
@@ -27,13 +27,13 @@ export default class JingleSession {
27 27
     constructor(
28 28
             sid,
29 29
             localJid,
30
-            peerjid,
30
+            remoteJid,
31 31
             connection,
32 32
             mediaConstraints,
33 33
             iceConfig) {
34 34
         this.sid = sid;
35 35
         this.localJid = localJid;
36
-        this.peerjid = peerjid;
36
+        this.remoteJid = remoteJid;
37 37
         this.connection = connection;
38 38
         this.mediaConstraints = mediaConstraints;
39 39
         this.iceConfig = iceConfig;
@@ -89,8 +89,8 @@ export default class JingleSession {
89 89
         this.room = room;
90 90
         this.rtc = rtc;
91 91
         this.state = JingleSessionState.PENDING;
92
-        this.initiator = isInitiator ? this.localJid : this.peerjid;
93
-        this.responder = isInitiator ? this.peerjid : this.localJid;
92
+        this.initiator = isInitiator ? this.localJid : this.remoteJid;
93
+        this.responder = isInitiator ? this.remoteJid : this.localJid;
94 94
         this.doInitialize();
95 95
     }
96 96
 
@@ -164,5 +164,12 @@ export default class JingleSession {
164 164
      */
165 165
     acceptOffer(jingle, success, failure) {}
166 166
 
167
+    /**
168
+     * Returns the JID of the initiator of the jingle session.
169
+     */
170
+    _getInitiatorJid() {
171
+        return this.isInitiator ? this.localJid : this.remoteJid;
172
+    }
173
+
167 174
     /* eslint-enable no-unused-vars, no-empty-function */
168 175
 }

+ 67
- 46
modules/xmpp/JingleSessionPC.js Прегледај датотеку

@@ -3,6 +3,7 @@
3 3
 import async from 'async';
4 4
 import { getLogger } from 'jitsi-meet-logger';
5 5
 import { $iq, Strophe } from 'strophe.js';
6
+import { integerHash } from '../util/StringUtils';
6 7
 
7 8
 import JingleSession from './JingleSession';
8 9
 import * as JingleSessionState from './JingleSessionState';
@@ -59,8 +60,8 @@ export default class JingleSessionPC extends JingleSession {
59 60
      * Creates new <tt>JingleSessionPC</tt>
60 61
      * @param {string} sid the Jingle Session ID - random string which
61 62
      * identifies the session
62
-     * @param {string} me our JID
63
-     * @param {string} peerjid remote peer JID
63
+     * @param {string} localJid our JID
64
+     * @param {string} remoteJid remote peer JID
64 65
      * @param {Strophe.Connection} connection Strophe XMPP connection instance
65 66
      * used to send packets.
66 67
      * @param mediaConstraints the media constraints object passed to
@@ -71,7 +72,7 @@ export default class JingleSessionPC extends JingleSession {
71 72
      * meant to be used in a direct, peer to peer connection or <tt>false</tt>
72 73
      * if it's a JVB connection.
73 74
      * @param {boolean} isInitiator indicates whether or not we are the side
74
-     * which sends the 'session-intiate'.
75
+     * which sends the 'session-initiate'.
75 76
      * @param {object} options a set of config options
76 77
      * @param {boolean} options.webrtcIceUdpDisable <tt>true</tt> to block UDP
77 78
      * candidates.
@@ -86,15 +87,16 @@ export default class JingleSessionPC extends JingleSession {
86 87
      */
87 88
     constructor(
88 89
             sid,
89
-            me,
90
-            peerjid,
90
+            localJid,
91
+            remoteJid,
91 92
             connection,
92 93
             mediaConstraints,
93 94
             iceConfig,
94 95
             isP2P,
95 96
             isInitiator,
96 97
             options) {
97
-        super(sid, me, peerjid, connection, mediaConstraints, iceConfig);
98
+        super(
99
+            sid, localJid, remoteJid, connection, mediaConstraints, iceConfig);
98 100
 
99 101
         /**
100 102
          * Stores result of {@link window.performance.now()} at the time when
@@ -240,40 +242,40 @@ export default class JingleSessionPC extends JingleSession {
240 242
         // Set to true if the connection was ever stable
241 243
         this.wasstable = false;
242 244
 
243
-        // Create new peer connection instance
245
+        const pcOptions = { disableRtx: this.room.options.disableRtx };
246
+
244 247
         if (this.isP2P) {
245
-            this.peerconnection = this.rtc.createPeerConnection(
246
-                this.signalingLayer,
247
-                this.iceConfig,
248
-                this.isP2P,
249
-                {
250
-                    // simulcast needs to be disabled for P2P (121) calls
251
-                    disableSimulcast: true,
252
-                    disableRtx: this.room.options.disableRtx,
253
-                    disableH264: this.room.options.p2p
254
-                        && this.room.options.p2p.disableH264,
255
-                    preferH264: this.room.options.p2p
256
-                        && this.room.options.p2p.preferH264
257
-                });
248
+            // simulcast needs to be disabled for P2P (121) calls
249
+            pcOptions.disableSimulcast = true;
250
+            pcOptions.disableH264
251
+                = this.room.options.p2p && this.room.options.p2p.disableH264;
252
+            pcOptions.preferH264
253
+                = this.room.options.p2p && this.room.options.p2p.preferH264;
254
+
255
+            const abtestSuspendVideo = this._abtestSuspendVideoEnabled();
256
+
257
+            if (typeof abtestSuspendVideo !== 'undefined') {
258
+                pcOptions.abtestSuspendVideo = abtestSuspendVideo;
259
+            }
258 260
         } else {
259
-            this.peerconnection = this.rtc.createPeerConnection(
260
-                this.signalingLayer,
261
-                this.iceConfig,
262
-                this.isP2P,
263
-                {
264
-                    // H264 does not support simulcast, so it needs to be
265
-                    // disabled.
266
-                    disableSimulcast: this.room.options.disableSimulcast
267
-                        || (this.room.options.preferH264
268
-                            && !this.room.options.disableH264),
269
-                    disableRtx: this.room.options.disableRtx,
270
-                    disableH264: this.room.options.disableH264,
271
-                    preferH264: this.room.options.preferH264,
272
-                    enableFirefoxSimulcast: this.room.options.testing
273
-                        && this.room.options.testing.enableFirefoxSimulcast
274
-                });
261
+            // H264 does not support simulcast, so it needs to be disabled.
262
+            pcOptions.disableSimulcast
263
+                = this.room.options.disableSimulcast
264
+                    || (this.room.options.preferH264
265
+                            && !this.room.options.disableH264);
266
+            pcOptions.preferH264 = this.room.options.preferH264;
267
+            pcOptions.enableFirefoxSimulcast
268
+                = this.room.options.testing
269
+                    && this.room.options.testing.enableFirefoxSimulcast;
275 270
         }
276 271
 
272
+        this.peerconnection
273
+            = this.rtc.createPeerConnection(
274
+                    this.signalingLayer,
275
+                    this.iceConfig,
276
+                    this.isP2P,
277
+                    pcOptions);
278
+
277 279
         this.peerconnection.onicecandidate = ev => {
278 280
             if (!ev) {
279 281
                 // There was an incomplete check for ev before which left
@@ -509,7 +511,7 @@ export default class JingleSessionPC extends JingleSession {
509 511
         }
510 512
 
511 513
         logger.log('sendIceCandidates', candidates);
512
-        const cand = $iq({ to: this.peerjid,
514
+        const cand = $iq({ to: this.remoteJid,
513 515
             type: 'set' })
514 516
             .c('jingle', { xmlns: 'urn:xmpp:jingle:1',
515 517
                 action: 'transport-info',
@@ -657,7 +659,7 @@ export default class JingleSessionPC extends JingleSession {
657 659
             if (this.isP2P) {
658 660
                 // In P2P all SSRCs are owner by the remote peer
659 661
                 this.signalingLayer.setSSRCOwner(
660
-                    ssrc, Strophe.getResourceFromJid(this.peerjid));
662
+                    ssrc, Strophe.getResourceFromJid(this.remoteJid));
661 663
             } else {
662 664
                 $(ssrcElement)
663 665
                     .find('>ssrc-info[xmlns="http://jitsi.org/jitmeet"]')
@@ -794,7 +796,7 @@ export default class JingleSessionPC extends JingleSession {
794 796
      */
795 797
     sendSessionInitiate(offerSdp) {
796 798
         let init = $iq({
797
-            to: this.peerjid,
799
+            to: this.remoteJid,
798 800
             type: 'set'
799 801
         }).c('jingle', {
800 802
             xmlns: 'urn:xmpp:jingle:1',
@@ -967,7 +969,7 @@ export default class JingleSessionPC extends JingleSession {
967 969
         // NOTE: since we're just reading from it, we don't need to be within
968 970
         //  the modification queue to access the local description
969 971
         const localSDP = new SDP(this.peerconnection.localDescription.sdp);
970
-        let accept = $iq({ to: this.peerjid,
972
+        let accept = $iq({ to: this.remoteJid,
971 973
             type: 'set' })
972 974
             .c('jingle', { xmlns: 'urn:xmpp:jingle:1',
973 975
                 action: 'session-accept',
@@ -1039,7 +1041,7 @@ export default class JingleSessionPC extends JingleSession {
1039 1041
 
1040 1042
         const sessionModify
1041 1043
             = $iq({
1042
-                to: this.peerjid,
1044
+                to: this.remoteJid,
1043 1045
                 type: 'set'
1044 1046
             })
1045 1047
                 .c('jingle', {
@@ -1074,7 +1076,7 @@ export default class JingleSessionPC extends JingleSession {
1074 1076
      * @private
1075 1077
      */
1076 1078
     sendTransportAccept(localSDP, success, failure) {
1077
-        let transportAccept = $iq({ to: this.peerjid,
1079
+        let transportAccept = $iq({ to: this.remoteJid,
1078 1080
             type: 'set' })
1079 1081
             .c('jingle', {
1080 1082
                 xmlns: 'urn:xmpp:jingle:1',
@@ -1123,7 +1125,7 @@ export default class JingleSessionPC extends JingleSession {
1123 1125
     sendTransportReject(success, failure) {
1124 1126
         // Send 'transport-reject', so that the focus will
1125 1127
         // know that we've failed
1126
-        let transportReject = $iq({ to: this.peerjid,
1128
+        let transportReject = $iq({ to: this.remoteJid,
1127 1129
             type: 'set' })
1128 1130
             .c('jingle', {
1129 1131
                 xmlns: 'urn:xmpp:jingle:1',
@@ -1152,7 +1154,7 @@ export default class JingleSessionPC extends JingleSession {
1152 1154
         if (!options || Boolean(options.sendSessionTerminate)) {
1153 1155
             let sessionTerminate
1154 1156
                 = $iq({
1155
-                    to: this.peerjid,
1157
+                    to: this.remoteJid,
1156 1158
                     type: 'set'
1157 1159
                 })
1158 1160
                     .c('jingle', {
@@ -2025,7 +2027,7 @@ export default class JingleSessionPC extends JingleSession {
2025 2027
 
2026 2028
         // send source-remove IQ.
2027 2029
         let sdpDiffer = new SDPDiffer(newSDP, oldSDP);
2028
-        const remove = $iq({ to: this.peerjid,
2030
+        const remove = $iq({ to: this.remoteJid,
2029 2031
             type: 'set' })
2030 2032
             .c('jingle', {
2031 2033
                 xmlns: 'urn:xmpp:jingle:1',
@@ -2047,7 +2049,7 @@ export default class JingleSessionPC extends JingleSession {
2047 2049
 
2048 2050
         // send source-add IQ.
2049 2051
         sdpDiffer = new SDPDiffer(oldSDP, newSDP);
2050
-        const add = $iq({ to: this.peerjid,
2052
+        const add = $iq({ to: this.remoteJid,
2051 2053
             type: 'set' })
2052 2054
             .c('jingle', {
2053 2055
                 xmlns: 'urn:xmpp:jingle:1',
@@ -2181,4 +2183,23 @@ export default class JingleSessionPC extends JingleSession {
2181 2183
         return `JingleSessionPC[p2p=${this.isP2P},`
2182 2184
                     + `initiator=${this.isInitiator},sid=${this.sid}]`;
2183 2185
     }
2186
+
2187
+    /**
2188
+     * If the A/B test for suspend video is disabled according to the room's
2189
+     * configuration, returns undefined. Otherwise returns a boolean which
2190
+     * indicates whether the suspend video option should be enabled or disabled.
2191
+     */
2192
+    _abtestSuspendVideoEnabled() {
2193
+        if (!this.room.options.abTesting
2194
+            || !this.room.options.abTesting.enableSuspendVideoTest) {
2195
+            return;
2196
+        }
2197
+
2198
+        // We want the two participants in a P2P call to agree on the value of
2199
+        // the "suspend" option. We use the JID of the initiator, because it is
2200
+        // both randomly selected and agreed upon by both participants.
2201
+        const jid = this._getInitiatorJid();
2202
+
2203
+        return integerHash(jid) % 2 === 0;
2204
+    }
2184 2205
 }

+ 3
- 3
modules/xmpp/strophe.jingle.js Прегледај датотеку

@@ -96,9 +96,9 @@ class JingleConnectionPlugin extends ConnectionPlugin {
96 96
             }
97 97
 
98 98
             // local jid is not checked
99
-            if (fromJid !== sess.peerjid) {
99
+            if (fromJid !== sess.remoteJid) {
100 100
                 logger.warn(
101
-                    'jid mismatch for session id', sid, sess.peerjid, iq);
101
+                    'jid mismatch for session id', sid, sess.remoteJid, iq);
102 102
                 ack.attrs({ type: 'error' });
103 103
                 ack.c('error', { type: 'cancel' })
104 104
                     .c('item-not-found', {
@@ -114,7 +114,7 @@ class JingleConnectionPlugin extends ConnectionPlugin {
114 114
             }
115 115
         } else if (sess !== undefined) {
116 116
             // Existing session with same session id. This might be out-of-order
117
-            // if the sess.peerjid is the same as from.
117
+            // if the sess.remoteJid is the same as from.
118 118
             ack.attrs({ type: 'error' });
119 119
             ack.c('error', { type: 'cancel' })
120 120
                 .c('service-unavailable', {

Loading…
Откажи
Сачувај