Reworked to allow displaying of monitors from many views with less code.
* Moved getStreamSrc from Monitors Controller to Monitors Model * Minor indenting of code * Removed some old code * Changed how I lookup ZM_MPEG_LIVE_FORMAT from within getStreamSrc * Changed Monitors View view to use divs instead of tables
This commit is contained in:
parent
7b98b62c16
commit
05c8ddf153
|
@ -3,21 +3,17 @@
|
||||||
public $helpers = array('LiveStream');
|
public $helpers = array('LiveStream');
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$monitoroptions['fields'] = array('Name', 'Id', 'Function');
|
$zmBandwidth = $this->Cookie->read('zmBandwidth');
|
||||||
|
$monitoroptions = array( 'fields' => array('Name', 'Id', 'Function'), 'recursive' => -1);
|
||||||
$this->set('monitors', $this->Monitor->find('all', $monitoroptions));
|
$this->set('monitors', $this->Monitor->find('all', $monitoroptions));
|
||||||
$monitors = $this->Monitor->find('list', array('fields' => array('Id')));
|
$monitors = $this->Monitor->find('all', array('recursive' => -1, 'fields' => array('Id', 'StreamReplayBuffer')));
|
||||||
$intervals = array('HOUR', 'DAY', 'WEEK', 'MONTH');
|
foreach ($monitors as $monitor => $mon) {
|
||||||
foreach ($monitors as $monitor) {
|
$streamSrc[$monitor] = $this->Monitor->getStreamSrc($monitor['Monitor']['Id'], $zmBandwidth, $monitor['Monitor']['StreamReplayBuffer']);
|
||||||
foreach ($intervals as $interval) {
|
}
|
||||||
|
$this->set('streamSrc', $streamSrc);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view($id = null) {
|
public function view($id = null) {
|
||||||
$this->loadModel('Config');
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
throw new NotFoundException(__('Invalid monitor'));
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
}
|
}
|
||||||
|
@ -30,24 +26,8 @@
|
||||||
|
|
||||||
|
|
||||||
$zmBandwidth = $this->Cookie->read('zmBandwidth');
|
$zmBandwidth = $this->Cookie->read('zmBandwidth');
|
||||||
|
|
||||||
$ZM_MPEG_LIVE_FORMAT = $this->Config->find('first', array(
|
|
||||||
'fields' => array('Value'), 'conditions' => array('Name' => 'ZM_MPEG_LIVE_FORMAT')
|
|
||||||
));
|
|
||||||
|
|
||||||
$ZM_WEB_STREAM_METHOD = $this->Config->getWebOption('ZM_WEB_STREAM_METHOD', $zmBandwidth);
|
|
||||||
$ZM_WEB_VIDEO_BITRATE = $this->Config->getWebOption('ZM_WEB_VIDEO_BITRATE', $zmBandwidth);
|
|
||||||
$ZM_WEB_VIDEO_MAXFPS = $this->Config->getWebOption('ZM_WEB_VIDEO_MAXFPS', $zmBandwidth);
|
|
||||||
$ZM_MPEG_LIVE_FORMAT = $ZM_MPEG_LIVE_FORMAT['Config']['Value'];
|
|
||||||
$buffer = $monitor['Monitor']['StreamReplayBuffer'];
|
$buffer = $monitor['Monitor']['StreamReplayBuffer'];
|
||||||
|
$this->set('streamSrc', $this->Monitor->getStreamSrc($id, $zmBandwidth, $buffer));
|
||||||
if ($ZM_WEB_STREAM_METHOD == 'mpeg' && $ZM_MPEG_LIVE_FORMAT) {
|
|
||||||
$this->set('streamSrc', "/cgi-bin/nph-zms?mode=mpeg&scale=100&maxfps=$ZM_WEB_VIDEO_MAXFPS&bitrate=$ZM_WEB_VIDEO_BITRATE&format=$ZM_MPEG_LIVE_FORMAT");
|
|
||||||
} else {
|
|
||||||
$this->set('streamSrc', "/cgi-bin/nph-zms?mode=jpeg&scale=100&maxfps=$ZM_WEB_VIDEO_MAXFPS&buffer=$buffer");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,22 @@
|
||||||
'foreignKey' => 'MonitorId',
|
'foreignKey' => 'MonitorId',
|
||||||
'fields' => 'Zone.Id'
|
'fields' => 'Zone.Id'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function getStreamSrc($id = null, $zmBandwidth, $buffer) {
|
||||||
|
|
||||||
|
$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_VIDEO_BITRATE = ClassRegistry::init('Config')->getWebOption('ZM_WEB_VIDEO_BITRATE', $zmBandwidth);
|
||||||
|
$ZM_WEB_VIDEO_MAXFPS = ClassRegistry::init('Config')->getWebOption('ZM_WEB_VIDEO_MAXFPS', $zmBandwidth);
|
||||||
|
$ZM_MPEG_LIVE_FORMAT = $ZM_MPEG_LIVE_FORMAT;
|
||||||
|
|
||||||
|
if ($ZM_WEB_STREAM_METHOD == 'mpeg' && $ZM_MPEG_LIVE_FORMAT) {
|
||||||
|
return "/cgi-bin/nph-zms?mode=mpeg&scale=100&maxfps=$ZM_WEB_VIDEO_MAXFPS&bitrate=$ZM_WEB_VIDEO_BITRATE&format=$ZM_MPEG_LIVE_FORMAT";
|
||||||
|
} else {
|
||||||
|
return "/cgi-bin/nph-zms?mode=jpeg&scale=100&maxfps=$ZM_WEB_VIDEO_MAXFPS&buffer=$buffer";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
<h2>Monitors</h2>
|
<h2>Monitors</h2>
|
||||||
<table>
|
<?php foreach ($monitors as $monitor => $mon): ?>
|
||||||
<tr>
|
<div class="monitor">
|
||||||
<th>Name</th>
|
<?php echo $this->Html->link($mon['Monitor']['Name'],array('controller' => 'monitors', 'action' => 'view', $mon['Monitor']['Id'])); ?>
|
||||||
<th>Function</th>
|
<?php echo $this->LiveStream->makeLiveStream($mon['Monitor']['Name'], $streamSrc[$monitor], $mon['Monitor']['Id']); ?>
|
||||||
<th>Zones</th>
|
<?php echo $this->Html->link($mon['Monitor']['Function'], array('action' => 'edit', $mon['Monitor']['Id'])); ?>
|
||||||
</tr>
|
</div>
|
||||||
<?php foreach ($monitors as $monitor): ?>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<?php echo $this->Html->link($monitor['Monitor']['Name'],array('controller' => 'monitors', 'action' => 'view', $monitor['Monitor']['Id'])); ?>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<?php echo $this->Html->link($monitor['Monitor']['Function'], array('action' => 'edit', $monitor['Monitor']['Id'])); ?>
|
|
||||||
</td>
|
|
||||||
<td><?php echo count($monitor['Zone']); ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php unset($monitor); ?>
|
<?php unset($monitor); ?>
|
||||||
</table>
|
|
||||||
<?php echo $this->Html->link(
|
<?php echo $this->Html->link(
|
||||||
'Add Monitor',
|
'Add Monitor',
|
||||||
array('controller' => 'monitors', 'action' => 'add')
|
array('controller' => 'monitors', 'action' => 'add')
|
||||||
|
|
Loading…
Reference in New Issue