Bug 1322338: make ICE failed error message depend on presence of STUN and/or TURN servers. r=bwc
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Tue, 06 Dec 2016 23:49:50 -1000
changeset 325564 07271f6f741d4c3c6676fd14adb47975a6790bb9
parent 325563 284e73444c60dfcff0dcfcd4bd45a3c248a7b8ec
child 325565 3b64878e4797a4442e0887b2f4e563dce7cfaa57
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbwc
bugs1322338
milestone53.0a1
Bug 1322338: make ICE failed error message depend on presence of STUN and/or TURN servers. r=bwc MozReview-Commit-ID: GWta6xYxkZY
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -361,16 +361,18 @@ function RTCPeerConnection() {
   this._remoteType = null;
   // http://rtcweb-wg.github.io/jsep/#rfc.section.4.1.9
   // 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;
 }
 RTCPeerConnection.prototype = {
   classDescription: "RTCPeerConnection",
   classID: PC_CID,
   contractID: PC_CONTRACT,
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
                                          Ci.nsIDOMGlobalPropertyInitializer]),
   init: function(win) { this._win = win; },
@@ -607,16 +609,20 @@ RTCPeerConnection.prototype = {
                                              "InvalidAccessError");
           }
           if (server.credentialType != "password") {
             this.logWarning("RTCConfiguration TURN credentialType \""+
                             server.credentialType +
                             "\" is not yet implemented. Treating as password."+
                             " https://bugzil.la/1247616");
           }
+          this._hasTurnServer = true;
+        }
+        else if (url.scheme in { stun:1, stuns:1 }) {
+          this._hasStunServer = true;
         }
         else if (!(url.scheme in { stun:1, stuns:1 })) {
           throw new this._win.DOMException(msg + " - improper scheme: " + url.scheme,
                                            "SyntaxError");
         }
         if (url.scheme in { stuns:1, turns:1 }) {
           this.logWarning(url.scheme.toUpperCase() + " is not yet supported.");
         }
@@ -1375,17 +1381,25 @@ PeerConnectionObserver.prototype = {
           iceConnectionState === 'connected') {
         success_histogram.add(true);
       } else if (iceConnectionState === 'failed') {
         success_histogram.add(false);
       }
     }
 
     if (iceConnectionState === 'failed') {
-      pc.logError("ICE failed, see about:webrtc for more details");
+      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 {
+        pc.logError("ICE failed, see about:webrtc for more details");
+      }
     }
 
     pc.changeIceConnectionState(iceConnectionState);
   },
 
   // This method is responsible for updating iceGatheringState. This
   // state is defined in the WebRTC specification as follows:
   //