Fixed camera stream. Stub for camera view page
This commit is contained in:
@@ -7,16 +7,16 @@ use yii\web\Controller;
|
|||||||
|
|
||||||
class CameraController extends Controller
|
class CameraController extends Controller
|
||||||
{
|
{
|
||||||
|
public function actionStream($id, $scale = 50)
|
||||||
public function actionStream($id)
|
|
||||||
{
|
{
|
||||||
$cms = Yii::$app->params['cameras'];
|
$cms = Yii::$app->params['cameras'];
|
||||||
if (!isset($cms[$id]))
|
if (!isset($cms[$id]))
|
||||||
{
|
{
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
if (!is_numeric($scale)) $scale = 50;
|
||||||
$zm_id = $cms[$id];
|
$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);
|
$fp = fopen($source_url, 'r', false);
|
||||||
if ($fp)
|
if ($fp)
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ class CameraController extends Controller
|
|||||||
header("Cache-Control: no-cache");
|
header("Cache-Control: no-cache");
|
||||||
header("Cache-Control: private");
|
header("Cache-Control: private");
|
||||||
header("Pragma: no-cache");
|
header("Pragma: no-cache");
|
||||||
header("Content-type: multipart/x-mixed-replace; boundary=boundarydonotcross");
|
header("Content-type: multipart/x-mixed-replace; boundary=ZoneMinderFrame");
|
||||||
|
|
||||||
// pass data
|
// pass data
|
||||||
fpassthru($fp);
|
fpassthru($fp);
|
||||||
@@ -33,4 +33,17 @@ class CameraController extends Controller
|
|||||||
}
|
}
|
||||||
else throw new NotFoundHttpException();
|
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
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
Reference in New Issue
Block a user