diff --git a/doc/ipcam-streaming.md b/doc/ipcam-streaming.md new file mode 100644 index 0000000..524e0e2 --- /dev/null +++ b/doc/ipcam-streaming.md @@ -0,0 +1,6 @@ +Let's assume IP cameras stream h264 via rtsp. + +To `/etc/fstab`: +``` +tmpfs /var/ipcamfs tmpfs mode=1755,uid=1000,gid=1000 0 0 +``` \ No newline at end of file diff --git a/localwebsite/config.php b/localwebsite/config.php index 47be2f7..262aeae 100644 --- a/localwebsite/config.php +++ b/localwebsite/config.php @@ -49,10 +49,15 @@ return [ ], 'static' => [ - 'app.css' => 6, + 'app.css' => 8, 'app.js' => 1, 'polyfills.js' => 1, 'modem.js' => 1, 'inverter.js' => 2, + ], + + 'cam_hls_host' => '192.168.1.1', + 'cam_list' => [ + // fill me with names ] ]; diff --git a/localwebsite/engine/tpl.php b/localwebsite/engine/tpl.php index a12807d..3d18c9a 100644 --- a/localwebsite/engine/tpl.php +++ b/localwebsite/engine/tpl.php @@ -20,7 +20,7 @@ abstract class base_tpl { public function __construct($templates_dir, $cache_dir) { global $config; - $cl = get_called_class(); + // $cl = get_called_class(); $this->twig = self::twig_instance($templates_dir, $cache_dir, $config['is_dev']); $this->static_time = time(); diff --git a/localwebsite/handlers/MiscHandler.php b/localwebsite/handlers/MiscHandler.php index 4f35981..314920a 100644 --- a/localwebsite/handlers/MiscHandler.php +++ b/localwebsite/handlers/MiscHandler.php @@ -49,4 +49,17 @@ class MiscHandler extends RequestHandler $this->tpl->render_page('pump.twig'); } + public function GET_cams() { + global $config; + + $this->tpl->add_external_static('js', 'https://cdn.jsdelivr.net/npm/hls.js@latest'); + + $this->tpl->set([ + 'hls_host' => $config['cam_hls_host'], + 'cams' => $config['cam_list'] + ]); + $this->tpl->set_title('Камеры'); + $this->tpl->render_page('cams.twig'); + } + } \ No newline at end of file diff --git a/localwebsite/htdocs/assets/app.css b/localwebsite/htdocs/assets/app.css index cab674e..73e0667 100644 --- a/localwebsite/htdocs/assets/app.css +++ b/localwebsite/htdocs/assets/app.css @@ -150,4 +150,19 @@ @keyframes sk-circleFadeDelay { 0%, 39%, 100% { opacity: 0; } 40% { opacity: 1; } +} + +/* cams page */ +.camfeeds { + display: flex; + flex-wrap: wrap; + flex-direction: row; +} +.camfeeds > video { + display: flex; + flex-basis: calc(50% - 20px); + justify-content: center; + flex-direction: column; + width: calc(50% - 10px); + margin: 5px; } \ No newline at end of file diff --git a/localwebsite/htdocs/index.php b/localwebsite/htdocs/index.php index 3961c2c..65afc72 100644 --- a/localwebsite/htdocs/index.php +++ b/localwebsite/htdocs/index.php @@ -25,6 +25,7 @@ $router->add('/', 'Misc main'); $router->add('sensors/', 'Misc sensors_page'); $router->add('pump/', 'Misc pump_page'); $router->add('phpinfo/', 'Misc phpinfo'); +$router->add('cams/', 'Misc cams'); $route = routerFind($router); diff --git a/localwebsite/templates-web/cams.twig b/localwebsite/templates-web/cams.twig new file mode 100644 index 0000000..2963fdb --- /dev/null +++ b/localwebsite/templates-web/cams.twig @@ -0,0 +1,64 @@ + + +
+ + + \ No newline at end of file diff --git a/localwebsite/templates-web/index.twig b/localwebsite/templates-web/index.twig index d293cfd..1635459 100644 --- a/localwebsite/templates-web/index.twig +++ b/localwebsite/templates-web/index.twig @@ -17,5 +17,6 @@