♻️ Make ICE server endpoint configurable

This commit is contained in:
Gina Häußge committed 2021-09-15 18:28:02 +02:00
1 parent f8c529723b
commit 10a129e54f
7 files changed
+20 -4

No files matched your search

+3
View File
@@ -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"]:
+1
View File
@@ -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,
+3 -2
View File
@@ -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) {
@@ -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()]
);
}
@@ -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;
@@ -15,6 +15,7 @@
<div class="hide">
{% include "snippets/settings/webcam/webcamStreamTimeout.jinja2" %}
{% include "snippets/settings/webcam/webcamCacheBuster.jinja2" %}
{% include "snippets/settings/webcam/webcamStreamWebrtcIce.jinja2" %}
</div>
</div>
</form>
@@ -0,0 +1,7 @@
<div class="control-group" title="{{ _('Endpoint to use for WebRTC ICE')|edq }}">
<label class="control-label" for="settings-webcamStreamWebrtcIce">{{ _('WebRTC ICE endpoint') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: webcam_streamWebrtcIce, valueUpdate: 'afterkeydown'" id="settings-webcamStreamWebrtcIce">
<span class="help-block"><span class="label">{{ _('WebRTC') }}</span> {% trans %}Only used for WebRTC streams. Provide the endpoint to use for WebRTC's Interactive Connectivity Establishment (ICE). Usually a STUN server. If unsure, leave at the default of <code>stun:stun.l.google.com:19302</code>.{% endtrans %}</span>
</div>
</div>