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

View File

@ -7,7 +7,7 @@ define('MSG_TIMEOUT', ZM_WEB_AJAX_TIMEOUT/2);
define('MSG_DATA_SIZE', 4+256); define('MSG_DATA_SIZE', 4+256);
if ( !($_REQUEST['connkey'] && $_REQUEST['command']) ) { if ( !($_REQUEST['connkey'] && $_REQUEST['command']) ) {
ajaxError("Unexpected received message type '$type'"); ajaxError('No connkey or no command in stream ajax');
} }
mkdir(ZM_PATH_SOCKS); 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 # 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'); $key = ftok(ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.sock', 'Z');
$semaphore = sem_get($key,1); $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)) ) { if ( !($socket = @socket_create(AF_UNIX, SOCK_DGRAM, 0)) ) {
ajaxError('socket_create() failed: '.socket_strerror(socket_last_error())); ajaxError('socket_create() failed: '.socket_strerror(socket_last_error()));
} }
@ -161,12 +171,11 @@ if ( sem_acquire($semaphore,1) !== false ) {
ajaxResponse(array('status'=>$data)); ajaxResponse(array('status'=>$data));
break; break;
default : default :
ajaxError("Unexpected received message type '$type'"); ajaxError('Unexpected received message type '.$data['type']);
} }
sem_release($semaphore); sem_release($semaphore);
} else { } else {
ZM\Debug('Couldn\'t get semaphore'); ajaxError("Unable to get semaphore.");
ajaxResponse(array());
} }
ajaxError('Unrecognised action or insufficient permissions in ajax/stream'); 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(); var monitorData = new Array();
<?php <?php
foreach ($monitors as $monitor) { foreach ($monitors as $m) {
?> ?>
monitorData[monitorData.length] = { monitorData[monitorData.length] = {
'id': <?php echo $monitor->Id() ?>, 'id': <?php echo $m->Id() ?>,
'width': <?php echo $monitor->ViewWidth() ?>, 'width': <?php echo $m->ViewWidth() ?>,
'height':<?php echo $monitor->ViewHeight() ?>, 'height':<?php echo $m->ViewHeight() ?>,
'url': '<?php echo $monitor->UrlToIndex() ?>', 'url': '<?php echo $m->UrlToIndex() ?>',
'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $monitor->Id() ?>' );}, 'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $m->Id() ?>' );},
'type': '<?php echo $monitor->Type() ?>', 'type': '<?php echo $m->Type() ?>',
'refresh': '<?php echo $monitor->Refresh() ?>' 'refresh': '<?php echo $m->Refresh() ?>'
}; };
<?php <?php
} // end foreach monitor } // end foreach monitor
@ -101,9 +101,10 @@ var appletRefreshTime = <?php echo ZM_RELOAD_CAMBOZOLA ?>;
var labels = new Array(); var labels = new Array();
<?php <?php
$labels = array(); $labels = array();
ZM\Debug("Presets");
foreach (dbFetchAll('SELECT * FROM ControlPresets WHERE MonitorId = ?', NULL, array($monitor->Id())) as $row) { foreach (dbFetchAll('SELECT * FROM ControlPresets WHERE MonitorId = ?', NULL, array($monitor->Id())) as $row) {
$label = $labels[$row['Preset']] = $row['Label']; $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') ?>"; var deleteString = "<?php echo translate('Delete') ?>";