Permalink
Browse files

ref(P2P): deal with ICE "completed" state

  • Loading branch information...
paweldomas committed Feb 23, 2017
1 parent a33e197 commit 328b3a2af7578ed82299efa406cf44414a1e15e3
View
@@ -1330,11 +1330,14 @@ JitsiConference.prototype.getActivePeerConnection = function () {
/**
* Returns the connection state for the current room. Its ice connection state
* 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 () {
if(this.jvbJingleSession)
return this.jvbJingleSession.getIceConnectionState();
return null;
const peerConnection = this.getActivePeerConnection();
return peerConnection ? peerConnection.getConnectionState() : null;
};
/**
@@ -563,7 +563,7 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function () {
if(!ssrc || !stats.hasOwnProperty(ssrc))
return;
track._setByteSent(stats[ssrc]);
track._setByteSent(tPeerConn, stats[ssrc]);
});
});
};
View
@@ -580,27 +580,15 @@ export default class P2PEnabledConference extends JitsiConference {
: 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.
* NOTE: method is used by the jitsi-meet-torture tests.
* @return {string|null} an ICE state or <tt>null</tt> if there's currently
* no P2P connection.
*/
getP2PConnectionState() {
if (this.p2pEstablished && this.p2pJingleSession) {
return this.p2pJingleSession.getIceConnectionState();
return this.p2pJingleSession.peerconnection.getConnectionState();
} else {
return null;
}
@@ -585,17 +585,13 @@ JitsiLocalTrack.prototype.getParticipantId = function() {
/**
* 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.
*/
JitsiLocalTrack.prototype._setByteSent = function (bytesSent) {
JitsiLocalTrack.prototype._setByteSent = function (tpc, bytesSent) {
this._bytesSent = bytesSent;
// FIXME it's a shame that PeerConnection and ICE status does not belong
// 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
let iceConnectionState = tpc.getConnectionState();
if(this._testByteSent && "connected" === iceConnectionState) {
setTimeout(function () {
if(this._bytesSent <= 0){
@@ -298,6 +298,24 @@ const dumpSDP = function(description) {
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.
* @return {boolean} <tt>true</tt> if simulcast is enabled and active or

0 comments on commit 328b3a2

Please sign in to comment.