|
|
@@ -56,6 +56,10 @@ const logger = getLogger(__filename);
|
|
56
|
56
|
* @param {number} [options.config.channelLastN=-1] The requested amount of
|
|
57
|
57
|
* videos are going to be delivered after the value is in effect. Set to -1 for
|
|
58
|
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
|
63
|
* @constructor
|
|
60
|
64
|
*
|
|
61
|
65
|
* FIXME Make all methods which are called from lib-internal classes
|
|
|
@@ -1466,6 +1470,18 @@ JitsiConference.prototype.onCallEnded
|
|
1466
|
1470
|
// Let the RTC service do any cleanups
|
|
1467
|
1471
|
this.rtc.onCallEnded();
|
|
1468
|
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
|
1485
|
this._stopP2PSession();
|
|
1470
|
1486
|
} else {
|
|
1471
|
1487
|
logger.error(
|
|
|
@@ -1905,6 +1921,11 @@ JitsiConference.prototype._onIceConnectionFailed = function(session) {
|
|
1905
|
1921
|
// We do nothing for the JVB connection, because it's up to the Jicofo to
|
|
1906
|
1922
|
// eventually come up with the new offer (at least for the time being).
|
|
1907
|
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
|
1929
|
if (this.p2pJingleSession && this.p2pJingleSession.isInitiator) {
|
|
1909
|
1930
|
Statistics.sendEventToAll('p2p.failed');
|
|
1910
|
1931
|
}
|
|
|
@@ -2007,12 +2028,26 @@ JitsiConference.prototype._addRemoteTracks = function(logName, remoteTracks) {
|
|
2007
|
2028
|
*/
|
|
2008
|
2029
|
JitsiConference.prototype._onIceConnectionEstablished
|
|
2009
|
2030
|
= function(jingleSession) {
|
|
|
2031
|
+ const forceJVB121Ratio = this.options.config.forceJVB121Ratio;
|
|
|
2032
|
+
|
|
2010
|
2033
|
// We don't care about the JVB case, there's nothing to be done
|
|
2011
|
2034
|
if (!jingleSession.isP2P) {
|
|
2012
|
2035
|
return;
|
|
2013
|
2036
|
} else if (this.p2pJingleSession !== jingleSession) {
|
|
2014
|
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
|
2051
|
return;
|
|
2017
|
2052
|
}
|
|
2018
|
2053
|
|
|
|
@@ -2125,6 +2160,13 @@ JitsiConference.prototype._setP2PStatus = function(newStatus) {
|
|
2125
|
2160
|
if (newStatus) {
|
|
2126
|
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
|
2170
|
// Sync up video transfer active in case p2pJingleSession not existed
|
|
2129
|
2171
|
// when the lastN value was being adjusted.
|
|
2130
|
2172
|
const isVideoActive = this.rtc.getLastN() !== 0;
|