Make stream timeout adjustable

As suggested by @ntoff in #1937
This commit is contained in:
Gina Häußge 2017-05-30 17:26:30 +02:00
parent d274a9c73d
commit 33cafbbd8a
6 changed files with 23 additions and 1 deletions

View file

@ -99,6 +99,7 @@ def getSettings():
"webcam": {
"streamUrl": s.get(["webcam", "stream"]),
"streamRatio": s.get(["webcam", "streamRatio"]),
"streamTimeout": s.getInt(["webcam", "streamTimeout"]),
"snapshotUrl": s.get(["webcam", "snapshot"]),
"ffmpegPath": s.get(["webcam", "ffmpeg"]),
"bitrate": s.get(["webcam", "bitrate"]),
@ -306,6 +307,7 @@ def _saveSettings(data):
if "webcam" in data.keys():
if "streamUrl" in data["webcam"]: s.set(["webcam", "stream"], data["webcam"]["streamUrl"])
if "streamRatio" in data["webcam"] and data["webcam"]["streamRatio"] in ("16:9", "4:3"): s.set(["webcam", "streamRatio"], data["webcam"]["streamRatio"])
if "streamTimeout" in data["webcam"]: s.setInt(["webcam", "streamTimeout"], data["webcam"]["streamTimeout"])
if "snapshotUrl" in data["webcam"]: s.set(["webcam", "snapshot"], data["webcam"]["snapshotUrl"])
if "ffmpegPath" in data["webcam"]: s.set(["webcam", "ffmpeg"], data["webcam"]["ffmpegPath"])
if "bitrate" in data["webcam"]: s.set(["webcam", "bitrate"], data["webcam"]["bitrate"])

View file

@ -157,6 +157,7 @@ default_settings = {
"webcam": {
"stream": None,
"streamRatio": "16:9",
"streamTimeout": 5,
"snapshot": None,
"ffmpeg": None,
"ffmpegThreads": 1,

View file

@ -368,10 +368,12 @@ $(function() {
return;
}
var timeout = self.settings.webcam_streamTimeout() || 5;
self.webcamDisableTimeout = setTimeout(function () {
log.debug("Unloading webcam stream");
$("#webcam_image").attr("src", "");
self.webcamLoaded(false);
}, 5000);
}, timeout * 1000);
};
self._enableWebcam = function() {

View file

@ -113,6 +113,7 @@ $(function() {
self.webcam_streamUrl = ko.observable(undefined);
self.webcam_streamRatio = ko.observable(undefined);
self.webcam_streamTimeout = ko.observable(undefined);
self.webcam_snapshotUrl = ko.observable(undefined);
self.webcam_ffmpegPath = ko.observable(undefined);
self.webcam_bitrate = ko.observable(undefined);

View file

@ -4,6 +4,13 @@
{% include "snippets/settings/webcam/webcamStreamUrl.jinja2" %}
{% include "snippets/settings/webcam/webcamStreamRatio.jinja2" %}
{% include "snippets/settings/webcam/webcamOrientation.jinja2" %}
<div>
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.form-horizontal', container: '.hide' }"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
{% include "snippets/settings/webcam/webcamStreamTimeout.jinja2" %}
</div>
</div>
</form>
<h3>{{ _('Timelapse Recordings') }}</h3>

View file

@ -0,0 +1,9 @@
<div class="control-group" title="{{ _('Timeout after which to unload the stream if the control tab is not visible') }}">
<label class="control-label" for="settings-webcamStreamTimeout">{{ _('Stream timeout') }}</label>
<div class="controls">
<div class="input-append">
<input type="number" min="1" class="input-mini text-right" data-bind="value: webcam_streamTimeout" id="settings-webcamStreamTimeout">
<span class="add-on">sec</span>
</div>
</div>
</div>