Merge branch 'master' of github.com:ZoneMinder/zoneminder

This commit is contained in:
Isaac Connor 2021-12-22 11:27:39 -05:00
commit 96a450db3d
3 changed files with 36 additions and 25 deletions

View File

@ -460,8 +460,9 @@ bool MonitorStream::sendFrame(Image *image, SystemTimePoint timestamp) {
} // Not mpeg
TimePoint send_end_time = std::chrono::steady_clock::now();
TimePoint::duration frame_send_time = send_end_time - send_start_time;
last_frame_sent = std::chrono::steady_clock::now();
if (maxfps) {
TimePoint::duration frame_send_time = last_frame_sent - send_start_time;
TimePoint::duration maxfps_milliseconds = Milliseconds(lround(Milliseconds::period::den / maxfps));
if (frame_send_time > maxfps_milliseconds) {
@ -471,7 +472,7 @@ bool MonitorStream::sendFrame(Image *image, SystemTimePoint timestamp) {
static_cast<int64>(std::chrono::duration_cast<Milliseconds>(maxfps_milliseconds).count()),
maxfps);
}
last_frame_sent = send_end_time;
}
return true;
} // end bool MonitorStream::sendFrame(Image *image, SystemTimePoint timestamp)

View File

@ -1,5 +1,5 @@
<?php
error_reporting(0);
error_reporting(0);
$start_time = time();
@ -7,7 +7,7 @@ define('MSG_TIMEOUT', ZM_WEB_AJAX_TIMEOUT/2);
define('MSG_DATA_SIZE', 4+256);
if ( !($_REQUEST['connkey'] && $_REQUEST['command']) ) {
ajaxError("Unexpected received message type '$type'");
ajaxError('No connkey or no command in stream ajax');
}
mkdir(ZM_PATH_SOCKS);
@ -15,7 +15,17 @@ mkdir(ZM_PATH_SOCKS);
# The file that we point ftok to has to exist, and only exist if zms is running, so we are pointing it at the .sock
$key = ftok(ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.sock', 'Z');
$semaphore = sem_get($key,1);
if ( sem_acquire($semaphore,1) !== false ) {
$semaphore_tries = 10;
$have_semaphore = false;
while ( $semaphore_tries ) {
$have_semaphore = sem_acquire($semaphore,1);
if ($have_semaphore !== false) break;
ZM\Debug("Failed to get semaphore, trying again");
usleep(100000);
$semaphore_tries -= 1;
}
if ($have_semaphore) {
if ( !($socket = @socket_create(AF_UNIX, SOCK_DGRAM, 0)) ) {
ajaxError('socket_create() failed: '.socket_strerror(socket_last_error()));
}
@ -161,12 +171,11 @@ if ( sem_acquire($semaphore,1) !== false ) {
ajaxResponse(array('status'=>$data));
break;
default :
ajaxError("Unexpected received message type '$type'");
ajaxError('Unexpected received message type '.$data['type']);
}
sem_release($semaphore);
} else {
ZM\Debug('Couldn\'t get semaphore');
ajaxResponse(array());
ajaxError("Unable to get semaphore.");
}
ajaxError('Unrecognised action or insufficient permissions in ajax/stream');

View File

@ -60,16 +60,16 @@ var mode = "<?php echo $options['mode'] ?>";
var monitorData = new Array();
<?php
foreach ($monitors as $monitor) {
foreach ($monitors as $m) {
?>
monitorData[monitorData.length] = {
'id': <?php echo $monitor->Id() ?>,
'width': <?php echo $monitor->ViewWidth() ?>,
'height':<?php echo $monitor->ViewHeight() ?>,
'url': '<?php echo $monitor->UrlToIndex() ?>',
'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $monitor->Id() ?>' );},
'type': '<?php echo $monitor->Type() ?>',
'refresh': '<?php echo $monitor->Refresh() ?>'
'id': <?php echo $m->Id() ?>,
'width': <?php echo $m->ViewWidth() ?>,
'height':<?php echo $m->ViewHeight() ?>,
'url': '<?php echo $m->UrlToIndex() ?>',
'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $m->Id() ?>' );},
'type': '<?php echo $m->Type() ?>',
'refresh': '<?php echo $m->Refresh() ?>'
};
<?php
} // end foreach monitor
@ -101,9 +101,10 @@ var appletRefreshTime = <?php echo ZM_RELOAD_CAMBOZOLA ?>;
var labels = new Array();
<?php
$labels = array();
ZM\Debug("Presets");
foreach (dbFetchAll('SELECT * FROM ControlPresets WHERE MonitorId = ?', NULL, array($monitor->Id())) as $row) {
$label = $labels[$row['Preset']] = $row['Label'];
echo 'labels['. validInt($index) .'] = \''.validJsStr($label).'\'';
echo 'labels['. validInt($row['Preset']) .'] = \''.validJsStr($label).'\';'.PHP_EOL;
}
?>
var deleteString = "<?php echo translate('Delete') ?>";