Skip to content

Commit

Permalink
ref(JitsiConference): Cleanup code related to forceJVB121Ratio. (#2382)
Browse files Browse the repository at this point in the history
  • Loading branch information
jallamsetty1 authored Oct 23, 2023
1 parent 540aed1 commit a1d7b0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
35 changes: 5 additions & 30 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ function _getCodecMimeType(codec) {
* @param {number} [options.config.channelLastN=-1] The requested amount of
* videos are going to be delivered after the value is in effect. Set to -1 for
* unlimited or all available videos.
* @param {number} [options.config.forceJVB121Ratio]
* "Math.random() < forceJVB121Ratio" will determine whether a 2 people
* conference should be moved to the JVB instead of P2P. The decision is made on
* the responder side, after ICE succeeds on the P2P connection.
* @constructor
*
* FIXME Make all methods which are called from lib-internal classes
Expand Down Expand Up @@ -2397,20 +2393,12 @@ JitsiConference.prototype.onCallEnded = function(jingleSession, reasonCondition,
} else if (jingleSession === this.p2pJingleSession) {
const stopOptions = {};

// It's the responder who decides to enforce JVB mode, so that both
// initiator and responder are aware if it was intentional.
if (reasonCondition === 'decline' && reasonText === 'force JVB121') {
logger.info('In forced JVB 121 mode...');
Statistics.analytics.addPermanentProperties({ forceJvb121: true });
} else if (reasonCondition === 'connectivity-error'
&& reasonText === 'ICE FAILED') {
// It can happen that the other peer detects ICE failed and
// terminates the session, before we get the event on our side.
// But we are able to parse the reason and mark it here.
if (reasonCondition === 'connectivity-error' && reasonText === 'ICE FAILED') {
// It can happen that the other peer detects ICE failed and terminates the session, before we get the event
// on our side. But we are able to parse the reason and mark it here.
Statistics.analytics.addPermanentProperties({ p2pFailed: true });
} else if (reasonCondition === 'success' && reasonText === 'restart') {
// When we are restarting media sessions we don't want to switch the tracks
// to the JVB just yet.
// When we are restarting media sessions we don't want to switch the tracks to the JVB just yet.
stopOptions.requestRestart = true;
}
this._stopP2PSession(stopOptions);
Expand Down Expand Up @@ -3096,25 +3084,13 @@ JitsiConference.prototype._onIceConnectionEstablished = function(jingleSession)
}

let done = false;
const forceJVB121Ratio = this.options.config.forceJVB121Ratio;

// We don't care about the JVB case, there's nothing to be done
if (!jingleSession.isP2P) {
done = true;
} else if (this.p2pJingleSession !== jingleSession) {
logger.error('CONNECTION_ESTABLISHED - wrong P2P session instance ?!');

done = true;
} else if (!jingleSession.isInitiator
&& typeof forceJVB121Ratio === 'number'
&& Math.random() < forceJVB121Ratio) {
logger.info(`Forcing JVB 121 mode (ratio=${forceJVB121Ratio})...`);
Statistics.analytics.addPermanentProperties({ forceJvb121: true });
this._stopP2PSession({
reason: 'decline',
reasonDescription: 'force JVB121'
});

done = true;
}

Expand Down Expand Up @@ -3305,8 +3281,7 @@ JitsiConference.prototype._setP2PStatus = function(newStatus) {
// When we end up in a valid P2P session need to reset the properties
// in case they have persisted, after session with another peer.
Statistics.analytics.addPermanentProperties({
p2pFailed: false,
forceJvb121: false
p2pFailed: false
});

// Sync up video transfer active in case p2pJingleSession not existed
Expand Down
3 changes: 1 addition & 2 deletions types/hand-crafted/JitsiConference.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export default class JitsiConference {
enabled: boolean,
backToP2PDelay?: number
},
channelLastN?: number,
forceJVB121Ratio?: number
channelLastN?: number
},
connection: unknown
} ); // TODO:
Expand Down

0 comments on commit a1d7b0e

Please sign in to comment.