mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-03-19 14:27:05 -04:00
No longer need LiveStreamHelper, and the logic of which image to
display (live or placeholder) has been moved to the Moniors model.
This way should be much easier to understand and support. This also
fixes my 'ugly hack' in commit eed6c81287
42 lines
1.5 KiB
PHP
42 lines
1.5 KiB
PHP
<?php
|
|
class Monitor extends AppModel {
|
|
public $useTable = 'Monitors';
|
|
public $primaryKey = 'Id';
|
|
public $hasMany = array(
|
|
'Event' => array(
|
|
'className' => 'Event',
|
|
'foreignKey' => 'MonitorId',
|
|
'fields' => 'Event.Id'
|
|
),
|
|
'Zone' => array(
|
|
'className' => 'Zone',
|
|
'foreignKey' => 'MonitorId',
|
|
'fields' => 'Zone.Id'
|
|
)
|
|
);
|
|
|
|
public function getStreamSrc($id = null, $zmBandwidth, $buffer, $function, $enabled, $name) {
|
|
$img['id'] = "livestream_$id";
|
|
|
|
$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 (Configure::read('daemonStatus') && $function != "None" && $enabled) {
|
|
$img['alt'] = "Live stream of $name";
|
|
if ($ZM_WEB_STREAM_METHOD == 'mpeg' && $ZM_MPEG_LIVE_FORMAT) {
|
|
$img['src'] = "/cgi-bin/nph-zms?mode=mpeg&scale=100&maxfps=$ZM_WEB_VIDEO_MAXFPS&bitrate=$ZM_WEB_VIDEO_BITRATE&format=$ZM_MPEG_LIVE_FORMAT&monitor=$id";
|
|
} else {
|
|
$img['src'] = "/cgi-bin/nph-zms?mode=jpeg&scale=100&maxfps=$ZM_WEB_VIDEO_MAXFPS&buffer=$buffer&monitor=$id";
|
|
}
|
|
} else {
|
|
$img['src'] = "/img/no-image.png";
|
|
$img['alt'] = "No live stream available for $name";
|
|
}
|
|
return $img;
|
|
}
|
|
}
|
|
?>
|