Bug 1322438: change ICE failed message depending on presence of relay candidates. r?abr
MozReview-Commit-ID: IvGkNmqbVlz
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -363,16 +363,17 @@ function RTCPeerConnection() {
// canTrickle == null means unknown; when a remote description is received it
// is set to true or false based on the presence of the "trickle" ice-option
this._canTrickle = null;
// States
this._iceGatheringState = this._iceConnectionState = "new";
this._hasStunServer = this._hasTurnServer = false;
+ this._iceGatheredRelayCandidates = false;
}
RTCPeerConnection.prototype = {
classDescription: "RTCPeerConnection",
classID: PC_CID,
contractID: PC_CONTRACT,
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
Ci.nsIDOMGlobalPropertyInitializer]),
init: function(win) { this._win = win; },
@@ -1331,16 +1332,19 @@ PeerConnectionObserver.prototype = {
onAddIceCandidateError: function(code, message) {
this._dompc._onAddIceCandidateError(this.newError(message, code));
},
onIceCandidate: function(level, mid, candidate) {
if (candidate == "") {
this.foundIceCandidate(null);
} else {
+ if (candidate.includes(" typ relay ")) {
+ this._dompc._iceGatheredRelayCandidates = true;
+ }
this.foundIceCandidate(new this._dompc._win.RTCIceCandidate(
{
candidate: candidate,
sdpMid: mid,
sdpMLineIndex: level
}
));
}
@@ -1410,16 +1414,19 @@ PeerConnectionObserver.prototype = {
if (iceConnectionState === 'failed') {
if (!pc._hasStunServer) {
pc.logError("ICE failed, add a STUN server and see about:webrtc for more details");
}
else if (!pc._hasTurnServer) {
pc.logError("ICE failed, add a TURN server and see about:webrtc for more details");
}
+ else if (pc._hasTurnServer && !pc._iceGatheredRelayCandidates) {
+ pc.logError("ICE failed, your TURN server appears to be broken, see about:webrtc for more details");
+ }
else {
pc.logError("ICE failed, see about:webrtc for more details");
}
}
pc.changeIceConnectionState(iceConnectionState);
},