Bug 1322438: change ICE failed message depending on presence of relay candidates. r=bwc
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Wed, 07 Dec 2016 14:59:32 -1000
changeset 325565 3b64878e4797a4442e0887b2f4e563dce7cfaa57
parent 325564 07271f6f741d4c3c6676fd14adb47975a6790bb9
child 325566 2b1f8432c5195659946f093a9190da12d636ccbb
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbwc
bugs1322438
milestone53.0a1
Bug 1322438: change ICE failed message depending on presence of relay candidates. r=bwc MozReview-Commit-ID: IvGkNmqbVlz
dom/media/PeerConnection.js
--- 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; },
@@ -1308,16 +1309,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
           }
       ));
     }
@@ -1387,16 +1391,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);
   },