Fixed camera stream. Stub for camera view page

This commit is contained in:
ftc
2023-05-23 22:44:07 +03:00
parent bb28c8372c
commit b19e70b005
2 changed files with 35 additions and 4 deletions
+17 -4
View File
@@ -7,16 +7,16 @@ use yii\web\Controller;
class CameraController extends Controller
{
public function actionStream($id)
public function actionStream($id, $scale = 50)
{
$cms = Yii::$app->params['cameras'];
if (!isset($cms[$id]))
{
throw new NotFoundHttpException();
}
if (!is_numeric($scale)) $scale = 50;
$zm_id = $cms[$id];
$source_url = Yii::$app->params['zmUrl'].'/cgi-bin/nph-zms?scale=50&mode=jpeg&maxfps=30&buffer=1000&monitor='.$zm_id.'&connkey='.rand(0, 65536);
$source_url = Yii::$app->params['zmUrl'].'/cgi-bin/nph-zms?scale='.$scale.'&mode=jpeg&maxfps=30&buffer=1000&monitor='.$zm_id.'&connkey='.rand(0, 65536);
$fp = fopen($source_url, 'r', false);
if ($fp)
{
@@ -25,7 +25,7 @@ class CameraController extends Controller
header("Cache-Control: no-cache");
header("Cache-Control: private");
header("Pragma: no-cache");
header("Content-type: multipart/x-mixed-replace; boundary=boundarydonotcross");
header("Content-type: multipart/x-mixed-replace; boundary=ZoneMinderFrame");
// pass data
fpassthru($fp);
@@ -33,4 +33,17 @@ class CameraController extends Controller
}
else throw new NotFoundHttpException();
}
public function actionView($id)
{
$cms = Yii::$app->params['cameras'];
if (!isset($cms[$id]))
{
throw new NotFoundHttpException();
}
return $this->render('view',
[
'id' => $id
]);
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
/** @var yii\web\View $this */
use yii\helpers\Url;
$this->title = 'Камера '.$id;
?>
<div class="site-index">
<div class="body-content">
<div class="row">
<div class="col-lg-4">
<img style="max-width:100%;" src='<?= Url::to(['camera/stream', 'id' => $id]); ?>'>
</div>
<div class="col-lg-8">
Архив записей:
</div>
</div>
</div>