Thrown away excess data. Camera re-stream
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
|
||||
class CameraController extends Controller
|
||||
{
|
||||
|
||||
public function actionStream($id)
|
||||
{
|
||||
$cms = Yii::$app->params['cameras'];
|
||||
if (!isset($cms[$id]))
|
||||
{
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$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);
|
||||
$fp = fopen($source_url, 'r', false);
|
||||
if ($fp)
|
||||
{
|
||||
Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
|
||||
// send mjpeg header:
|
||||
header("Cache-Control: no-cache");
|
||||
header("Cache-Control: private");
|
||||
header("Pragma: no-cache");
|
||||
header("Content-type: multipart/x-mixed-replace; boundary=boundarydonotcross");
|
||||
|
||||
// pass data
|
||||
fpassthru($fp);
|
||||
fclose($fp);
|
||||
}
|
||||
else throw new NotFoundHttpException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user