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 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));
|
||||
$monitors = $this->Monitor->find('list', array('fields' => array('Id')));
|
||||
$intervals = array('HOUR', 'DAY', 'WEEK', 'MONTH');
|
||||
foreach ($monitors as $monitor) {
|
||||
foreach ($intervals as $interval) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$monitors = $this->Monitor->find('all', array('recursive' => -1, 'fields' => array('Id', 'StreamReplayBuffer')));
|
||||
foreach ($monitors as $monitor => $mon) {
|
||||
$streamSrc[$monitor] = $this->Monitor->getStreamSrc($monitor['Monitor']['Id'], $zmBandwidth, $monitor['Monitor']['StreamReplayBuffer']);
|
||||
}
|
||||
$this->set('streamSrc', $streamSrc);
|
||||
}
|
||||
|
||||
public function view($id = null) {
|
||||
$this->loadModel('Config');
|
||||
if (!$id) {
|
||||
throw new NotFoundException(__('Invalid monitor'));
|
||||
}
|
||||
|
@ -30,24 +26,8 @@
|
|||
|
||||
|
||||
$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'];
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
$this->set('streamSrc', $this->Monitor->getStreamSrc($id, $zmBandwidth, $buffer));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,22 @@
|
|||
'foreignKey' => 'MonitorId',
|
||||
'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>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Function</th>
|
||||
<th>Zones</th>
|
||||
</tr>
|
||||
<?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 foreach ($monitors as $monitor => $mon): ?>
|
||||
<div class="monitor">
|
||||
<?php echo $this->Html->link($mon['Monitor']['Name'],array('controller' => 'monitors', 'action' => 'view', $mon['Monitor']['Id'])); ?>
|
||||
<?php echo $this->LiveStream->makeLiveStream($mon['Monitor']['Name'], $streamSrc[$monitor], $mon['Monitor']['Id']); ?>
|
||||
<?php echo $this->Html->link($mon['Monitor']['Function'], array('action' => 'edit', $mon['Monitor']['Id'])); ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php unset($monitor); ?>
|
||||
</table>
|
||||
<?php echo $this->Html->link(
|
||||
'Add Monitor',
|
||||
array('controller' => 'monitors', 'action' => 'add')
|
||||
|
|
Loading…
Reference in New Issue