Bug 1322438: change ICE failed message depending on presence of relay candidates. r?abr draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Wed, 07 Dec 2016 14:59:32 -1000
changeset 447838 650d0350adfef971496a443c3c1610922714d665
parent 447706 abfbb61cbce41f7b5516ae30bd5378f770a48353
child 448141 a192f134adafd1b326d1e255a2da4d67bfd77062
child 448301 5f709ea5b767616b0443772dcf53931c20db990c
child 448302 1b25c4bf5b8a7d49141c98eea39c0bbac7801383
child 448336 5cad28416d6b4fa5635c39b214de949d81d09f8e
push id38183
push userdrno@ohlmeier.org
push dateThu, 08 Dec 2016 01:03:42 +0000
reviewersabr
bugs1322438
milestone53.0a1
Bug 1322438: change ICE failed message depending on presence of relay candidates. r?abr 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; },
@@ -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);
   },