Skip to content

Commit

Permalink
ref(P2P): deal with ICE "completed" state
Browse files Browse the repository at this point in the history
  • Loading branch information
paweldomas committed Feb 27, 2017
1 parent a33e197 commit 328b3a2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
9 changes: 6 additions & 3 deletions JitsiConference.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1330,11 +1330,14 @@ JitsiConference.prototype.getActivePeerConnection = function () {
/** /**
* Returns the connection state for the current room. Its ice connection state * Returns the connection state for the current room. Its ice connection state
* for its session. * for its session.
* NOTE that "completed" ICE state which can appear on the P2P connection will
* be converted to "connected".
* @return {string|null} ICE state name or <tt>null</tt> if there is no active
* peer connection at this time.
*/ */
JitsiConference.prototype.getConnectionState = function () { JitsiConference.prototype.getConnectionState = function () {
if(this.jvbJingleSession) const peerConnection = this.getActivePeerConnection();
return this.jvbJingleSession.getIceConnectionState(); return peerConnection ? peerConnection.getConnectionState() : null;
return null;
}; };


/** /**
Expand Down
2 changes: 1 addition & 1 deletion JitsiConferenceEventManager.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function () {
if(!ssrc || !stats.hasOwnProperty(ssrc)) if(!ssrc || !stats.hasOwnProperty(ssrc))
return; return;


track._setByteSent(stats[ssrc]); track._setByteSent(tPeerConn, stats[ssrc]);
}); });
}); });
}; };
Expand Down
16 changes: 2 additions & 14 deletions P2PEnabledConference.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -580,27 +580,15 @@ export default class P2PEnabledConference extends JitsiConference {
: super.getActivePeerConnection(); : super.getActivePeerConnection();
} }


/**
* @inheritDoc
* @override
*/
getConnectionState () {
const p2pState = this.getP2PConnectionState();
if (p2pState) {
return p2pState;
} else {
return super.getConnectionState();
}
}

/** /**
* Returns the current ICE state of the P2P connection. * Returns the current ICE state of the P2P connection.
* NOTE: method is used by the jitsi-meet-torture tests.
* @return {string|null} an ICE state or <tt>null</tt> if there's currently * @return {string|null} an ICE state or <tt>null</tt> if there's currently
* no P2P connection. * no P2P connection.
*/ */
getP2PConnectionState() { getP2PConnectionState() {
if (this.p2pEstablished && this.p2pJingleSession) { if (this.p2pEstablished && this.p2pJingleSession) {
return this.p2pJingleSession.getIceConnectionState(); return this.p2pJingleSession.peerconnection.getConnectionState();
} else { } else {
return null; return null;
} }
Expand Down
12 changes: 4 additions & 8 deletions modules/RTC/JitsiLocalTrack.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -585,17 +585,13 @@ JitsiLocalTrack.prototype.getParticipantId = function() {


/** /**
* Sets the value of bytes sent statistic. * Sets the value of bytes sent statistic.
* @param bytesSent {integer} the new value (FIXME: what is an integer in js?) * @param {TraceablePeerConnection} tpc the source of the "bytes sent" stat
* @param {number} bytesSent the new value
* NOTE: used only for audio tracks to detect audio issues. * NOTE: used only for audio tracks to detect audio issues.
*/ */
JitsiLocalTrack.prototype._setByteSent = function (bytesSent) { JitsiLocalTrack.prototype._setByteSent = function (tpc, bytesSent) {
this._bytesSent = bytesSent; this._bytesSent = bytesSent;
// FIXME it's a shame that PeerConnection and ICE status does not belong let iceConnectionState = tpc.getConnectionState();
// to the RTC module and it has to be accessed through
// the conference(and through the XMPP chat room ???) instead
let iceConnectionState
= this.conference ? this.conference.getConnectionState() : null;
// FIXME take "completed" into account for P2P
if(this._testByteSent && "connected" === iceConnectionState) { if(this._testByteSent && "connected" === iceConnectionState) {
setTimeout(function () { setTimeout(function () {
if(this._bytesSent <= 0){ if(this._bytesSent <= 0){
Expand Down
18 changes: 18 additions & 0 deletions modules/RTC/TraceablePeerConnection.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -298,6 +298,24 @@ const dumpSDP = function(description) {
return 'type: ' + description.type + '\r\n' + description.sdp; return 'type: ' + description.type + '\r\n' + description.sdp;
}; };



/**
* Forwards the {@link peerconnection.iceConnectionState} state except that it
* will convert "completed" into "connected" where both mean that the ICE has
* succeeded and is up and running. We never see "completed" state for
* the JVB connection, but it started appearing for the P2P one. This method
* allows to adapt old logic to this new situation.
* @return {string}
*/
TraceablePeerConnection.prototype.getConnectionState = function () {
let state = this.peerconnection.iceConnectionState;
if ("completed" === state) {
return "connected";
} else {
return state;
}
};

/** /**
* Tells whether or not this TPC instance is using Simulcast. * Tells whether or not this TPC instance is using Simulcast.
* @return {boolean} <tt>true</tt> if simulcast is enabled and active or * @return {boolean} <tt>true</tt> if simulcast is enabled and active or
Expand Down

0 comments on commit 328b3a2

Please sign in to comment.