Bläddra i källkod

feat(JingleSessionPC): add options for P2P evaluation

Add 'forceJVB121Ratio' config option which allows to enforce JVB
conference even if the P2P connection can be established. In such case
'forceJVB121' permanent analytics property will be added.

Will also set 'p2pFailed' analytics property to 'true' in case ICE fails
on the P2P connection.
dev1
paweldomas 8 år sedan
förälder
incheckning
903999840d
1 ändrade filer med 42 tillägg och 0 borttagningar
  1. 42
    0
      JitsiConference.js

+ 42
- 0
JitsiConference.js Visa fil

56
  * @param {number} [options.config.channelLastN=-1] The requested amount of
56
  * @param {number} [options.config.channelLastN=-1] The requested amount of
57
  * videos are going to be delivered after the value is in effect. Set to -1 for
57
  * videos are going to be delivered after the value is in effect. Set to -1 for
58
  * unlimited or all available videos.
58
  * unlimited or all available videos.
59
+ * @param {number} [options.config.forceJVB121Ratio]
60
+ * "Math.random() < forceJVB121Ratio" will determine whether a 2 people
61
+ * conference should be moved to the JVB instead of P2P. The decision is made on
62
+ * the responder side, after ICE succeeds on the P2P connection.
59
  * @constructor
63
  * @constructor
60
  *
64
  *
61
  * FIXME Make all methods which are called from lib-internal classes
65
  * FIXME Make all methods which are called from lib-internal classes
1466
         // Let the RTC service do any cleanups
1470
         // Let the RTC service do any cleanups
1467
         this.rtc.onCallEnded();
1471
         this.rtc.onCallEnded();
1468
     } else if (jingleSession === this.p2pJingleSession) {
1472
     } else if (jingleSession === this.p2pJingleSession) {
1473
+        // It's the responder who decides to enforce JVB mode, so that both
1474
+        // initiator and responder are aware if it was intentional.
1475
+        if (reasonCondition === 'decline' && reasonText === 'force JVB121') {
1476
+            logger.info('In forced JVB 121 mode...');
1477
+            Statistics.analytics.addPermanentProperties({ forceJvb121: true });
1478
+        } else if (reasonCondition === 'connectivity-error'
1479
+            && reasonText === 'ICE FAILED') {
1480
+            // It can happen that the other peer detects ICE failed and
1481
+            // terminates the session, before we get the event on our side.
1482
+            // But we are able to parse the reason and mark it here.
1483
+            Statistics.analytics.addPermanentProperties({ p2pFailed: true });
1484
+        }
1469
         this._stopP2PSession();
1485
         this._stopP2PSession();
1470
     } else {
1486
     } else {
1471
         logger.error(
1487
         logger.error(
1905
     // We do nothing for the JVB connection, because it's up to the Jicofo to
1921
     // We do nothing for the JVB connection, because it's up to the Jicofo to
1906
     // eventually come up with the new offer (at least for the time being).
1922
     // eventually come up with the new offer (at least for the time being).
1907
     if (session.isP2P) {
1923
     if (session.isP2P) {
1924
+        // Add p2pFailed property to analytics to distinguish, between "good"
1925
+        // and "bad" connection
1926
+        Statistics.analytics.addPermanentProperties({ p2pFailed: true });
1927
+
1928
+        // Log analytics event, but only for the initiator to not count it twice
1908
         if (this.p2pJingleSession && this.p2pJingleSession.isInitiator) {
1929
         if (this.p2pJingleSession && this.p2pJingleSession.isInitiator) {
1909
             Statistics.sendEventToAll('p2p.failed');
1930
             Statistics.sendEventToAll('p2p.failed');
1910
         }
1931
         }
2007
  */
2028
  */
2008
 JitsiConference.prototype._onIceConnectionEstablished
2029
 JitsiConference.prototype._onIceConnectionEstablished
2009
 = function(jingleSession) {
2030
 = function(jingleSession) {
2031
+    const forceJVB121Ratio = this.options.config.forceJVB121Ratio;
2032
+
2010
     // We don't care about the JVB case, there's nothing to be done
2033
     // We don't care about the JVB case, there's nothing to be done
2011
     if (!jingleSession.isP2P) {
2034
     if (!jingleSession.isP2P) {
2012
         return;
2035
         return;
2013
     } else if (this.p2pJingleSession !== jingleSession) {
2036
     } else if (this.p2pJingleSession !== jingleSession) {
2014
         logger.error('CONNECTION_ESTABLISHED - wrong P2P session instance ?!');
2037
         logger.error('CONNECTION_ESTABLISHED - wrong P2P session instance ?!');
2015
 
2038
 
2039
+        return;
2040
+    } else if (!jingleSession.isInitiator
2041
+        && typeof forceJVB121Ratio === 'number'
2042
+        && Math.random() < forceJVB121Ratio) {
2043
+        logger.info(`Forcing JVB 121 mode (ratio=${forceJVB121Ratio})...`);
2044
+        this._rejectIncomingCall(
2045
+            jingleSession, {
2046
+                reasonTag: 'decline',
2047
+                reasonMsg: 'force JVB121'
2048
+            });
2049
+        Statistics.analytics.addPermanentProperties({ forceJvb121: true });
2050
+
2016
         return;
2051
         return;
2017
     }
2052
     }
2018
 
2053
 
2125
     if (newStatus) {
2160
     if (newStatus) {
2126
         logger.info('Peer to peer connection established!');
2161
         logger.info('Peer to peer connection established!');
2127
 
2162
 
2163
+        // When we end up in a valid P2P session need to reset the properties
2164
+        // in case they have persisted, after session with another peer.
2165
+        Statistics.analytics.addPermanentProperties({
2166
+            p2pFailed: false,
2167
+            forceJvb121: false
2168
+        });
2169
+
2128
         // Sync up video transfer active in case p2pJingleSession not existed
2170
         // Sync up video transfer active in case p2pJingleSession not existed
2129
         // when the lastN value was being adjusted.
2171
         // when the lastN value was being adjusted.
2130
         const isVideoActive = this.rtc.getLastN() !== 0;
2172
         const isVideoActive = this.rtc.getLastN() !== 0;

Laddar…
Avbryt
Spara