Merge branch 'master' into multistream

This commit is contained in:
Isaac Connor 2022-01-05 18:03:44 -05:00
commit aefed4e174
12 changed files with 56 additions and 34 deletions

9
.readthedocs.yaml Normal file
View File

@ -0,0 +1,9 @@
version: 2
build:
os: "ubuntu-20.04"
tools:
python: "3.8"
sphinx:
fail_on_warning: true

View File

@ -188,7 +188,7 @@ CREATE TABLE `Events` (
`StorageId` smallint(5) unsigned default 0,
`SecondaryStorageId` smallint(5) unsigned default 0,
`Name` varchar(64) NOT NULL default '',
`Cause` varchar(32) NOT NULL default '',
`Cause` TEXT,
`StartDateTime` datetime default NULL,
`EndDateTime` datetime default NULL,
`Width` smallint(5) unsigned NOT NULL default '0',

2
db/zm_update-1.37.7.sql Normal file
View File

@ -0,0 +1,2 @@
/* Change Cause from varchar(32) to TEXT. We now include alarmed zone name */
ALTER TABLE `Events` MODIFY `Cause` TEXT;

View File

@ -184,7 +184,7 @@ while (!$zm_terminate) {
foreach my $filter (@filters) {
last if $zm_terminate;
my $elapsed = ($now - $$filter{last_ran});
my $elapsed = ($now - ($$filter{last_ran} ? $$filter{last_ran} : 0));
if ($$filter{last_ran} and ($elapsed < $$filter{ExecuteInterval})) {
my $filter_delay = $$filter{ExecuteInterval} - ($now - $$filter{last_ran});
$delay = $filter_delay if $filter_delay < $delay;

View File

@ -295,7 +295,8 @@ int FfmpegCamera::OpenFfmpeg() {
ret = avformat_open_input(&mFormatContext, mPath.c_str(), nullptr, &opts);
if ( ret != 0 )
{
Error("Unable to open input %s due to: %s", mPath.c_str(),
logPrintf(Logger::ERROR + monitor->Importance(),
"Unable to open input %s due to: %s", mPath.c_str(),
av_make_error_string(ret).c_str());
if ( mFormatContext ) {

View File

@ -1901,16 +1901,14 @@ bool Monitor::Analyse() {
alarm_cause += std::string(zone.Label());
}
}
if (!alarm_cause.empty())
cause = cause+" "+alarm_cause;
Debug(3, "After motion detection, score:%d last_motion_score(%d), new motion score(%d)",
score, last_motion_score, motion_score);
motion_frame_count += 1;
last_motion_score = motion_score;
if (motion_score) {
if (cause.length()) cause += ", ";
cause += MOTION_CAUSE;
cause += MOTION_CAUSE+std::string(":")+alarm_cause;
noteSetMap[MOTION_CAUSE] = zoneSet;
} // end if motion_score
}

View File

@ -367,13 +367,15 @@ bool MonitorStream::sendFrame(const std::string &filepath, SystemTimePoint times
fputs("\r\n", stdout);
fflush(stdout);
TimePoint send_end_time = std::chrono::steady_clock::now();
TimePoint::duration frame_send_time = send_end_time - send_start_time;
if (maxfps > 0.0) {
TimePoint send_end_time = std::chrono::steady_clock::now();
TimePoint::duration frame_send_time = send_end_time - send_start_time;
if (frame_send_time > Milliseconds(lround(Milliseconds::period::den / maxfps))) {
Info("Frame send time %" PRIi64 " ms too slow, throttling maxfps to %.2f",
static_cast<int64>(std::chrono::duration_cast<Milliseconds>(frame_send_time).count()),
maxfps);
if (frame_send_time > Milliseconds(lround(Milliseconds::period::den / maxfps))) {
Info("Frame send time %" PRIi64 " ms too slow, throttling maxfps to %.2f",
static_cast<int64>(std::chrono::duration_cast<Milliseconds>(frame_send_time).count()),
maxfps);
}
}
last_frame_sent = now;
@ -456,7 +458,7 @@ bool MonitorStream::sendFrame(Image *image, SystemTimePoint timestamp) {
} // Not mpeg
last_frame_sent = std::chrono::steady_clock::now();
if (maxfps) {
if (maxfps > 0.0) {
TimePoint::duration frame_send_time = last_frame_sent - send_start_time;
TimePoint::duration maxfps_milliseconds = Milliseconds(lround(Milliseconds::period::den / maxfps));
@ -810,7 +812,7 @@ void MonitorStream::runStream() {
// sent a frame, so update
double capture_fps = monitor->GetFPS();
double fps = (maxfps && (capture_fps > maxfps)) ? maxfps : capture_fps;
double fps = ((maxfps > 0.0) && (capture_fps > maxfps)) ? maxfps : capture_fps;
double sleep_time_seconds = (1 / ((fps ? fps : 1))) // 1 second / fps
* (replay_rate ? abs(replay_rate)/ZM_RATE_BASE : 1); // replay_rate is 100 for 1x
Debug(3, "Using %f for maxfps. capture_fps: %f maxfps %f * replay_rate: %d = %f", fps, capture_fps, maxfps, replay_rate, sleep_time_seconds);

View File

@ -119,8 +119,8 @@ if [ ! -d "${GITHUB_FORK}_zoneminder_release" ]; then
if [ -d "${GITHUB_FORK}_ZoneMinder.git" ]; then
echo "Using local clone ${GITHUB_FORK}_ZoneMinder.git to pull from."
cd "${GITHUB_FORK}_ZoneMinder.git"
echo "git fetch..."
git fetch
echo "git pull..."
git pull
cd ../
echo "git clone ${GITHUB_FORK}_ZoneMinder.git ${GITHUB_FORK}_zoneminder_release"
@ -223,6 +223,8 @@ if [ -e "$DIRECTORY.orig.tar.gz" ]; then
if [[ "$REPLY" == "" || "$REPLY" == [yY] ]]; then
tar zcf $DIRECTORY.orig.tar.gz $DIRECTORY.orig
fi;
else
tar zcf $DIRECTORY.orig.tar.gz $DIRECTORY.orig
fi;
IFS=',' ;for DISTRO in `echo "$DISTROS"`; do

View File

@ -710,10 +710,6 @@ function renameEvent() {
actQuery('rename', {eventName: newName});
}
function exportEvent() {
window.location.assign('?view=export&eids[]='+eventData.Id);
}
function showEventFrames() {
window.location.assign('?view=frames&eid='+eventData.Id);
}
@ -1020,11 +1016,11 @@ function initPage() {
// Manage the EXPORT button
bindButton('#exportBtn', 'click', null, function onExportClick(evt) {
evt.preventDefault();
exportEvent();
window.location.assign('?view=export&eids[]='+eventData.Id);
});
// Manage the generateVideo button
bindButton('#videoBtn', 'click', null, function onExportClick(evt) {
bindButton('#videoBtn', 'click', null, function onVideoClick(evt) {
evt.preventDefault();
videoEvent();
});

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') ?>";

View File

@ -1327,9 +1327,9 @@ echo htmlSelect('newMonitor[ReturnLocation]', $return_options, $monitor->ReturnL
<?php
echo htmlselect('newMonitor[Importance]',
array(
'Not'=>translate('Not important'),
'Normal'=>translate('Normal'),
'Less'=>translate('Less important'),
'Normal'=>translate('Normal')
'Not'=>translate('Not important')
), $monitor->Importance());
?>
</td>

View File

@ -86,6 +86,17 @@ The following monitors will have these settings update when you click Save:<br/>
<label for="newMonitor[Enabled]"><?php echo translate('Enabled') ?></label>
<input type="checkbox" name="newMonitor[Enabled]" id="newMonitor[Enabled]" value="1"<?php if ( !empty($monitors[0]->Enabled()) ) { ?> checked="checked"<?php } ?>/>
</p>
<p>
<label for="newMonitor[Importance]"><?php echo translate('Importance'); echo makeHelpLink('OPTIONS_IMPORTANCE') ?></label>
<?php
echo htmlselect('newMonitor[Importance]',
array(
'Normal'=>translate('Normal'),
'Less'=>translate('Less important'),
'Not'=>translate('Not important')
), $monitor->Importance());
?>
</p>
<div id="contentButtons">
<button type="submit" value="Save"><?php echo translate('Save') ?></button>
<button type="button" data-on-click="backWindow"><?php echo translate('Cancel') ?></button>