Moved the zmBandwidth option from a cookie to global Configure:: option
In addition I'm no longer passing this option around, instead calling it where needed. This _might_ fix #175 as the variable is being set very early on in bootstrap.php
This commit is contained in:
parent
83c744c7b7
commit
e3db6e0edc
|
@ -108,3 +108,7 @@ CakeLog::config('error', array(
|
||||||
'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
|
'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
|
||||||
'file' => 'error',
|
'file' => 'error',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
if (! Configure::read('zmBandwidth')) {
|
||||||
|
Configure::write('zmBandwidth', 'low');
|
||||||
|
}
|
||||||
|
|
|
@ -39,13 +39,12 @@ class AppController extends Controller {
|
||||||
'Form' => array('className' => 'BoostCake.BoostCakeForm'),
|
'Form' => array('className' => 'BoostCake.BoostCakeForm'),
|
||||||
'Paginator' => array('className' => 'BoostCake.BoostCakePaginator'),
|
'Paginator' => array('className' => 'BoostCake.BoostCakePaginator'),
|
||||||
);
|
);
|
||||||
public $components = array('Cookie', 'Session', 'RequestHandler');
|
public $components = array('Session', 'RequestHandler');
|
||||||
|
|
||||||
public function beforeFilter() {
|
public function beforeFilter() {
|
||||||
parent::beforeFilter();
|
parent::beforeFilter();
|
||||||
$this->loadModel('Config');
|
$this->loadModel('Config');
|
||||||
$this->loadModel('AppModel');
|
$this->loadModel('AppModel');
|
||||||
$this->Cookie->name = 'ZoneMinder';
|
|
||||||
|
|
||||||
$configFile = "/usr/local/etc/zm.conf";
|
$configFile = "/usr/local/etc/zm.conf";
|
||||||
$lines = file($configFile);
|
$lines = file($configFile);
|
||||||
|
@ -79,14 +78,6 @@ class AppController extends Controller {
|
||||||
$this->set('zmVersion', $zmVersion);
|
$this->set('zmVersion', $zmVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeRender() {
|
|
||||||
parent::beforeRender();
|
|
||||||
if (!$this->Cookie->read('zmBandwidth')) {
|
|
||||||
$this->Cookie->write('zmBandwidth', 'low', false);
|
|
||||||
}
|
|
||||||
$this->set('zmBandwidth', $this->Cookie->read('zmBandwidth'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractNamedParams($mandatory, $optional = array()) {
|
function extractNamedParams($mandatory, $optional = array()) {
|
||||||
$params = $this->params['named'];
|
$params = $this->params['named'];
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,16 @@ class BandwidthController extends AppController {
|
||||||
public function index() {
|
public function index() {
|
||||||
if (!empty($this->request->data)) {
|
if (!empty($this->request->data)) {
|
||||||
$bandwidth = $this->request->data['Bandwidth']['Bandwidth'];
|
$bandwidth = $this->request->data['Bandwidth']['Bandwidth'];
|
||||||
$this->Cookie->write('zmBandwidth', $bandwidth, false);
|
Configure::write('zmBandwidth', $bandwidth);
|
||||||
$this->set('bandwidth', $bandwidth);
|
$this->set('bandwidth', $bandwidth);
|
||||||
if ($this->Cookie->read('zmBandwidth') == $bandwidth) {
|
if (Configure::read('zmBandwidth') == $bandwidth) {
|
||||||
$this->Session->setFlash('Successfully updated bandwidth');
|
$this->Session->setFlash('Successfully updated bandwidth');
|
||||||
} else {
|
} else {
|
||||||
$this->Session->setFlash('Failed to update bandwidth');
|
$this->Session->setFlash('Failed to update bandwidth');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->set('bandwidth', $this->Cookie->read('zmBandwidth'));
|
$this->set('bandwidth', Configure::read('zmBandwidth'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,12 @@
|
||||||
public $helpers = array('Js'=>array('Jquery'));
|
public $helpers = array('Js'=>array('Jquery'));
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$zmBandwidth = $this->Cookie->read('zmBandwidth');
|
|
||||||
$monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence', 'Function', 'Width', 'StreamReplayBuffer'), 'order' => 'Sequence ASC', 'recursive' => -1);
|
$monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence', 'Function', 'Width', 'StreamReplayBuffer'), 'order' => 'Sequence ASC', 'recursive' => -1);
|
||||||
$monitors = $this->Monitor->find('all', $monitoroptions);
|
$monitors = $this->Monitor->find('all', $monitoroptions);
|
||||||
|
|
||||||
|
|
||||||
foreach ($monitors as $key => $value) {
|
foreach ($monitors as $key => $value) {
|
||||||
$monitors[$key]['img'] = $this->Monitor->getStreamSrc($value['Monitor']['Id'], $zmBandwidth, $value['Monitor']['StreamReplayBuffer'], $value['Monitor']['Function'], $value['Monitor']['Enabled'], $value['Monitor']['Name'], $value['Monitor']['Width']);
|
$monitors[$key]['img'] = $this->Monitor->getStreamSrc($value['Monitor']['Id'], $value['Monitor']['StreamReplayBuffer'], $value['Monitor']['Function'], $value['Monitor']['Enabled'], $value['Monitor']['Name'], $value['Monitor']['Width']);
|
||||||
}
|
}
|
||||||
$this->set('monitors', $monitors);
|
$this->set('monitors', $monitors);
|
||||||
}
|
}
|
||||||
|
@ -26,9 +25,8 @@
|
||||||
$this->set('monitor', $monitor);
|
$this->set('monitor', $monitor);
|
||||||
|
|
||||||
|
|
||||||
$zmBandwidth = $this->Cookie->read('zmBandwidth');
|
|
||||||
$buffer = $monitor['Monitor']['StreamReplayBuffer'];
|
$buffer = $monitor['Monitor']['StreamReplayBuffer'];
|
||||||
$this->set('streamSrc', $this->Monitor->getStreamSrc($id, $zmBandwidth, $buffer, $monitor['Monitor']['Function'], $monitor['Monitor']['Enabled'], $monitor['Monitor']['Name'], $monitor['Monitor']['Width'], false));
|
$this->set('streamSrc', $this->Monitor->getStreamSrc($id, $buffer, $monitor['Monitor']['Function'], $monitor['Monitor']['Enabled'], $monitor['Monitor']['Name'], $monitor['Monitor']['Width'], false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($id = null) {
|
public function edit($id = null) {
|
||||||
|
|
|
@ -3,7 +3,8 @@ class Config extends AppModel {
|
||||||
public $useTable = 'Config';
|
public $useTable = 'Config';
|
||||||
public $primaryKey = 'Name';
|
public $primaryKey = 'Name';
|
||||||
|
|
||||||
public function getWebOption($name, $zmBandwidth) {
|
public function getWebOption($name) {
|
||||||
|
$zmBandwidth = Configure::read('zmBandwidth');
|
||||||
$name_begin = substr($name, 0, 7);
|
$name_begin = substr($name, 0, 7);
|
||||||
$name_end = substr($name, 6);
|
$name_end = substr($name, 6);
|
||||||
$bandwidth_short = strtoupper($zmBandwidth[0]);
|
$bandwidth_short = strtoupper($zmBandwidth[0]);
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getStreamSrc($id = null, $zmBandwidth, $buffer, $function, $enabled, $name, $width, $scale = true) {
|
public function getStreamSrc($id = null, $buffer, $function, $enabled, $name, $width, $scale = true) {
|
||||||
$img['id'] = "livestream_$id";
|
$img['id'] = "livestream_$id";
|
||||||
$img['width'] = $width;
|
$img['width'] = $width;
|
||||||
|
|
||||||
$ZM_MPEG_LIVE_FORMAT = Configure::read('ZM_MPEG_LIVE_FORMAT');
|
$ZM_MPEG_LIVE_FORMAT = Configure::read('ZM_MPEG_LIVE_FORMAT');
|
||||||
$ZM_WEB_STREAM_METHOD = ClassRegistry::init('Config')->getWebOption('ZM_WEB_STREAM_METHOD', $zmBandwidth);
|
$ZM_WEB_STREAM_METHOD = ClassRegistry::init('Config')->getWebOption('ZM_WEB_STREAM_METHOD');
|
||||||
$ZM_WEB_VIDEO_BITRATE = ClassRegistry::init('Config')->getWebOption('ZM_WEB_VIDEO_BITRATE', $zmBandwidth);
|
$ZM_WEB_VIDEO_BITRATE = ClassRegistry::init('Config')->getWebOption('ZM_WEB_VIDEO_BITRATE');
|
||||||
$ZM_WEB_VIDEO_MAXFPS = ClassRegistry::init('Config')->getWebOption('ZM_WEB_VIDEO_MAXFPS', $zmBandwidth);
|
$ZM_WEB_VIDEO_MAXFPS = ClassRegistry::init('Config')->getWebOption('ZM_WEB_VIDEO_MAXFPS');
|
||||||
$ZM_MPEG_LIVE_FORMAT = $ZM_MPEG_LIVE_FORMAT;
|
$ZM_MPEG_LIVE_FORMAT = $ZM_MPEG_LIVE_FORMAT;
|
||||||
|
|
||||||
if (Configure::read('daemonStatus') && $function != "None" && $enabled) {
|
if (Configure::read('daemonStatus') && $function != "None" && $enabled) {
|
||||||
|
|
Loading…
Reference in New Issue