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
|
||||
{
|
||||
|
||||
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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user