diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index b16099eb0..07ce1ffe3 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -129,6 +129,7 @@ def getSettings(): "streamUrl": s.get(["webcam", "stream"]), "streamRatio": s.get(["webcam", "streamRatio"]), "streamTimeout": s.getInt(["webcam", "streamTimeout"]), + "streamWebrtcIce": s.get(["webcam", "streamWebrtcIce"]), "snapshotUrl": s.get(["webcam", "snapshot"]), "snapshotTimeout": s.getInt(["webcam", "snapshotTimeout"]), "snapshotSslValidation": s.getBoolean(["webcam", "snapshotSslValidation"]), @@ -549,6 +550,8 @@ def _saveSettings(data): s.set(["webcam", "streamRatio"], data["webcam"]["streamRatio"]) if "streamTimeout" in data["webcam"]: s.setInt(["webcam", "streamTimeout"], data["webcam"]["streamTimeout"]) + if "streamWebrtcIce" in data["webcam"]: + s.set(["webcam", "streamWebrtcIce"], data["webcam"]["streamWebrtcIce"]) if "snapshotUrl" in data["webcam"]: s.set(["webcam", "snapshot"], data["webcam"]["snapshotUrl"]) if "snapshotTimeout" in data["webcam"]: diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 53ea034c2..9a05cba90 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -249,6 +249,7 @@ default_settings = { "stream": None, "streamRatio": "16:9", "streamTimeout": 5, + "streamWebrtcIce": "stun:stun.l.google.com:19302", "snapshot": None, "snapshotTimeout": 5, "snapshotSslValidation": True, diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index b57aee74d..b4b71f05c 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -1685,10 +1685,11 @@ var negotiateWebRTC = function (streamUrl) { }); }; -var startWebRTC = function (videoElement, streamUrl) { +var startWebRTC = function (videoElement, streamUrl, iceServers) { + iceServers = iceServers || ["stun:stun.l.google.com:19302"]; var config = { sdpSemantics: "unified-plan", - iceServers: [{urls: ["stun:stun.l.google.com:19302"]}] + iceServers: [{urls: iceServers}] }; pc = new RTCPeerConnection(config); pc.addEventListener("track", function (evt) { diff --git a/src/octoprint/static/js/app/viewmodels/control.js b/src/octoprint/static/js/app/viewmodels/control.js index a92048c9d..4bb0b3147 100644 --- a/src/octoprint/static/js/app/viewmodels/control.js +++ b/src/octoprint/static/js/app/viewmodels/control.js @@ -756,7 +756,8 @@ $(function () { if (self.webRTCPeerConnection == null) { self.webRTCPeerConnection = startWebRTC( video, - self.settings.webcam_streamUrl() + self.settings.webcam_streamUrl(), + [self.settings.webcam_streamWebrtcIce()] ); } diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 518b61120..554c30d57 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -153,6 +153,7 @@ $(function () { self.webcam_streamUrl = ko.observable(undefined); self.webcam_streamRatio = ko.observable(undefined); self.webcam_streamTimeout = ko.observable(undefined); + self.webcam_streamWebrtcIce = ko.observable(undefined); self.webcam_snapshotUrl = ko.observable(undefined); self.webcam_snapshotTimeout = ko.observable(undefined); self.webcam_snapshotSslValidation = ko.observable(undefined); @@ -462,7 +463,8 @@ $(function () { webrtc_peer_connection = startWebRTC( video_element, - self.webcam_streamUrl() + self.webcam_streamUrl(), + [self.webcam_streamWebrtcIce()] ); } else { throw "Unknown stream type " + streamType; diff --git a/src/octoprint/templates/dialogs/settings/webcam.jinja2 b/src/octoprint/templates/dialogs/settings/webcam.jinja2 index 13a15a3f5..0478fc280 100644 --- a/src/octoprint/templates/dialogs/settings/webcam.jinja2 +++ b/src/octoprint/templates/dialogs/settings/webcam.jinja2 @@ -15,6 +15,7 @@
stun:stun.l.google.com:19302.{% endtrans %}
+