summaryrefslogtreecommitdiff
path: root/localwebsite
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-05-26 01:25:21 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-05-26 01:25:21 +0300
commitb46401b5a91f63917157dee40e986d3d3091025b (patch)
tree634766ef848b76d29c01be79cd6ad889dbc03fcd /localwebsite
parente20f0ef7c91e7862150f362fb2718cf5f5f6c909 (diff)
localwebsite upd
Diffstat (limited to 'localwebsite')
-rw-r--r--localwebsite/config.php2
-rw-r--r--localwebsite/handlers/MiscHandler.php8
-rw-r--r--localwebsite/templates-web/cams.twig5
3 files changed, 13 insertions, 2 deletions
diff --git a/localwebsite/config.php b/localwebsite/config.php
index d28d714..c046b10 100644
--- a/localwebsite/config.php
+++ b/localwebsite/config.php
@@ -56,6 +56,8 @@ return [
'inverter.js' => 2,
],
+ 'cam_hls_access_key' => '',
+ 'cam_hls_proto' => 'http',
'cam_hls_host' => '192.168.1.1',
'cam_list' => [
// fill me with names
diff --git a/localwebsite/handlers/MiscHandler.php b/localwebsite/handlers/MiscHandler.php
index 1230b35..ef4d8ef 100644
--- a/localwebsite/handlers/MiscHandler.php
+++ b/localwebsite/handlers/MiscHandler.php
@@ -68,10 +68,16 @@ class MiscHandler extends RequestHandler
$hls_opts['debug'] = true;
$this->tpl->add_external_static('js', 'https://cdn.jsdelivr.net/npm/hls.js@latest');
+
+ $hls_host = is_callable($config['cam_hls_host']) ? $config['cam_hls_host']() : $config['cam_hls_host'];
+ $hls_proto = is_callable($config['cam_hls_proto']) ? $config['cam_hls_proto']() : $config['cam_hls_proto'];
$this->tpl->set([
- 'hls_host' => $config['cam_hls_host'],
+ 'hls_host' => $hls_host,
+ 'hls_proto' => $hls_proto,
'hls_opts' => $hls_opts,
+ 'hls_access_key' => $config['cam_hls_access_key'],
+
'cams' => $config['cam_list'],
'video_events' => $video_events
]);
diff --git a/localwebsite/templates-web/cams.twig b/localwebsite/templates-web/cams.twig
index cf6009c..71642ee 100644
--- a/localwebsite/templates-web/cams.twig
+++ b/localwebsite/templates-web/cams.twig
@@ -14,7 +14,10 @@ function hasFallbackSupport() {
}
function setupHls(video, name, useHls) {
- var src = 'http://{{ hls_host }}/ipcam/'+name+'/live.m3u8';
+ var src = '{{ hls_proto }}://{{ hls_host }}/ipcam/'+name+'/live.m3u8';
+ {% if hls_access_key %}
+ src += '?access_key={{ hls_access_key }}';
+ {% endif %}
// hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.