Skip to content

Commit 3ee8547

Browse files
authored
Merge branch 'master' into patch-474778
2 parents 50528ef + adba371 commit 3ee8547

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1145
-714
lines changed

db/triggers.sql

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,7 @@ CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
122122
FOR EACH ROW
123123
BEGIN
124124
declare diff BIGINT default 0;
125-
126125
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
127-
IF ( NEW.StorageId = OLD.StorageID ) THEN
128-
IF ( diff ) THEN
129-
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) + diff,0) WHERE Storage.Id = OLD.StorageId;
130-
END IF;
131-
ELSE
132-
IF ( NEW.DiskSpace ) THEN
133-
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + NEW.DiskSpace WHERE Storage.Id = NEW.StorageId;
134-
END IF;
135-
IF ( OLD.DiskSpace ) THEN
136-
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) - COALESCE(OLD.DiskSpace,0),0) WHERE Storage.Id = OLD.StorageId;
137-
END IF;
138-
END IF;
139126

140127
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
141128
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
@@ -204,9 +191,6 @@ DROP TRIGGER IF EXISTS event_delete_trigger//
204191
CREATE TRIGGER event_delete_trigger BEFORE DELETE ON Events
205192
FOR EACH ROW
206193
BEGIN
207-
IF ( OLD.DiskSpace ) THEN
208-
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) - COALESCE(OLD.DiskSpace,0),0) WHERE Storage.Id = OLD.StorageId;
209-
END IF;
210194
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
211195
DELETE FROM Events_Day WHERE EventId=OLD.Id;
212196
DELETE FROM Events_Week WHERE EventId=OLD.Id;

db/zm_update-1.37.69.sql.in

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
SELECT 'This update may make changes that require SUPER privileges. If you see an error message saying:
2+
3+
ERROR 1419 (HY000) at line 298: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
4+
5+
You will have to either run this update as root manually using something like (on ubuntu/debian)
6+
7+
sudo mysql --defaults-file=/etc/mysql/debian.cnf zm < /usr/share/zoneminder/db/zm_update-1.37.69.sql
8+
9+
OR
10+
11+
sudo mysql --defaults-file=/etc/mysql/debian.cnf "set global log_bin_trust_function_creators=1;"
12+
sudo zmupdate.pl
13+
14+
OR
15+
16+
Turn off binary logging in your mysql server by adding this to your mysql config.
17+
[mysqld]
18+
skip-log-bin
19+
20+
';
21+
22+
source @PKGDATADIR@/db/triggers.sql

docs/installationguide/easydocker.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
An Easy To Use Docker Image
22
===========================
3-
If you are interested in trying out ZoneMinder quickly, user Dan Landon maintains an easy to use docker image for ZoneMinder. With a few simple configuration changes, it also provides complete Event Notification Server and Machine Learning hook support. Please follow instructions in his repository. He maintains two repositories:
4-
5-
* If you want to run the latest stable release, please use his `zoneminder machine learning repository <https://github.com/dlandon/zoneminder.machine.learning>`__.
6-
* If you want to run the latest zoneminder master, please use his `zoneminder master repository <https://github.com/dlandon/zoneminder.master-docker>`__.
7-
8-
In both cases, instructions are provided in the repo README files.
3+
The docker images previously linked to are now depreciated.
94

105
If you are looking at building your own native (non docker) binary packages of ZoneMinder for your distro, please refer to the distro specific install guides or :doc:`packpack`.
116

docs/installationguide/index.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Contents:
77

88
.. toctree::
99
:maxdepth: 2
10-
11-
easydocker
1210
packpack
1311
ubuntu
1412
debian

docs/installationguide/packpack.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
All Distros - A Docker Way to Build ZoneMinder
22
===============================================
33

4-
.. note:: If you are looking for an easy way to run ZoneMinder and not interested in building your own docker image, please refer to :doc:`easydocker`.
5-
64
.. contents::
75

86
These instructions represent an alternative way to build ZoneMinder for any supported distro.

scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,11 +2834,11 @@ our @options = (
28342834
{
28352835
name => 'ZM_WEB_LIST_THUMBS',
28362836
default => 'yes',
2837-
description => 'Display mini-thumbnails of event images in event lists',
2837+
description => 'Display mini-thumbnails of event images in event lists and on console',
28382838
help => q`
2839-
Ordinarily the event lists just display text details of the
2840-
events to save space and time. By switching this option on you
2841-
can also display small thumbnails to help you identify events
2839+
Originally the event lists and console just displayed text details of the
2840+
events and monitors to save space and time. By switching this option on you
2841+
can also display small thumbnails to help you identify events or cameras
28422842
of interest. The size of these thumbnails is controlled by the
28432843
following two options.
28442844
`,
@@ -2848,10 +2848,10 @@ our @options = (
28482848
{
28492849
name => 'ZM_WEB_LIST_THUMB_WIDTH',
28502850
default => '48',
2851-
description => 'The width of the thumbnails that appear in the event lists',
2851+
description => 'The width of the thumbnails that appear in the event lists and on console',
28522852
help => q`
28532853
This options controls the width of the thumbnail images that
2854-
appear in the event lists. It should be fairly small to fit in
2854+
appear in the event lists and on the console. It should be fairly small to fit in
28552855
with the rest of the table. If you prefer you can specify a
28562856
height instead in the next option but you should only use one
28572857
of the width or height and the other option should be set to

scripts/ZoneMinder/lib/ZoneMinder/Control/AxisV2.pm

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ use Time::HiRes qw( usleep );
4646
use URI;
4747

4848
our $uri;
49+
my $use_optics;
4950

5051
sub open {
5152
my $self = shift;
@@ -390,17 +391,46 @@ sub focusRelNear {
390391
my $self = shift;
391392
my $params = shift;
392393
my $step = $self->getParam($params, 'step');
393-
Debug('Focus Near');
394-
my $cmd = "/axis-cgi/com/ptz.cgi?rfocus=-$step";
395-
$self->sendCmd($cmd);
394+
Debug('Focus Rel Near');
395+
if ($use_optics) {
396+
my $cmd = "/axis-cgi/opticssetup.cgi?rfocus=-minstep";
397+
$self->sendCmd($cmd);
398+
} else {
399+
my $cmd = "/axis-cgi/com/ptz.cgi?rfocus=-$step";
400+
my $res = $self->sendCmd($cmd);
401+
if ($res->content ne 'ok') {
402+
$use_optics = 1;
403+
$self->focusRelNear($self, $params);
404+
}
405+
}
396406
}
397407

398408
sub focusRelFar {
399409
my $self = shift;
400410
my $params = shift;
401411
my $step = $self->getParam($params, 'step');
402-
Debug('Focus Far');
403-
my $cmd = "/axis-cgi/com/ptz.cgi?rfocus=$step";
412+
Debug('FocusRelFar');
413+
if ($use_optics) {
414+
my $cmd = "/axis-cgi/opticssetup.cgi?rfocus=minstep";
415+
$self->sendCmd($cmd);
416+
} else {
417+
my $cmd = "/axis-cgi/com/ptz.cgi?rfocus=$step";
418+
my $res = $self->sendCmd($cmd);
419+
if ($res->content ne 'ok') {
420+
$use_optics = 1;
421+
$self->focusRelNear($self, $params);
422+
}
423+
}
424+
}
425+
426+
sub focusAbs {
427+
# Takes a value 0-1 in small decimal incremements
428+
my $self = shift;
429+
my $params = shift;
430+
my $step = $self->getParam($params, 'step');
431+
# step comes in as an integer, needs to be 0-1
432+
Debug('Focus Abs');
433+
my $cmd = "/axis-cgi/opticssetup.cgi.cgi?afocus=$step";
404434
$self->sendCmd($cmd);
405435
}
406436

scripts/ZoneMinder/lib/ZoneMinder/Event.pm

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ sub delete {
403403
$ZoneMinder::Database::dbh->commit() if ! $in_transaction;
404404
return;
405405
}
406+
ZoneMinder::Database::zmDbDo('DELETE FROM Event_Data WHERE EventId=?', $$event{Id});
407+
if ( $ZoneMinder::Database::dbh->errstr() ) {
408+
$ZoneMinder::Database::dbh->commit() if ! $in_transaction;
409+
return;
410+
}
406411
ZoneMinder::Database::zmDbDo('DELETE FROM Frames WHERE EventId=?', $$event{Id});
407412
if ( $ZoneMinder::Database::dbh->errstr() ) {
408413
$ZoneMinder::Database::dbh->commit() if ! $in_transaction;
@@ -412,6 +417,9 @@ sub delete {
412417
# Do it individually to avoid locking up the table for new events
413418
ZoneMinder::Database::zmDbDo('DELETE FROM Events WHERE Id=?', $$event{Id});
414419
$ZoneMinder::Database::dbh->commit() if ! $in_transaction;
420+
421+
my $storage = $event->Storage();
422+
$storage->save({DiskSpace=>$storage->DiskSpace()-$event->DiskSpace()}) if $event->DiskSpace();
415423
}
416424

417425
if ( ( $in_zmaudit or (!$Config{ZM_OPT_FAST_DELETE})) and $event->Storage()->DoDelete() ) {
@@ -751,20 +759,32 @@ sub MoveTo {
751759

752760
my $error = '';
753761
if ((! -e $SrcPath) and -e $NewPath) {
754-
Debug("srcPath: $SrcPath newPath: $NewPath");
755-
Warning("Event has already been moved, just updating the event record in db.");
762+
Warning("Event $$self{Id} has already been moved from $$OldStorage{Id} $SrcPath, just updating the event record in db to $$NewStorage{Id} $NewPath.");
756763
} else {
757764
$error = $self->CopyTo($NewStorage);
758-
return $error if $error;
765+
if ($error) {
766+
$ZoneMinder::Database::dbh->commit() if !$was_in_transaction;
767+
return $error;
768+
}
759769
}
760770

771+
my $old_diskspace = $self->DiskSpace();
772+
my $new_diskspace = $self->DiskSpace(undef);
773+
761774
# Succeeded in copying all files, so we may now update the Event.
762775
$self->Storage($NewStorage);
763776
$error .= $self->save();
764777
# Going to leave it to upper layer as to whether we rollback or not
765-
return $error if $error;
778+
if ($error) {
779+
$ZoneMinder::Database::dbh->rollback() if !$was_in_transaction;
780+
return $error;
781+
}
766782
$ZoneMinder::Database::dbh->commit() if !$was_in_transaction;
767783

784+
# Update storage diskspace. The triggers no longer do this. This is ... less important so do it outside the transaction
785+
$OldStorage->save({DiskSpace => $OldStorage->DiskSpace()-$old_diskspace}) if $old_diskspace;
786+
$NewStorage->save({DiskSpace => $NewStorage->DiskSpace()+$new_diskspace}) if $new_diskspace;
787+
768788
$self->delete_files($OldStorage);
769789
return $error;
770790
} # end sub MoveTo

src/zm_db.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,18 @@ MYSQL_RES *zmDbFetch(const std::string &query) {
137137
return nullptr;
138138
}
139139

140-
int rc = mysql_query(&dbconn, query.c_str());
141140

141+
int rc = mysql_query(&dbconn, query.c_str());
142142
if (rc) {
143-
Debug(1, "Can't run query: %s rc:%d, reason:%s", query.c_str(), rc, mysql_error(&dbconn));
143+
std::string reason = mysql_error(&dbconn); // store for later because it will get clobbered by second attempt
144+
Debug(1, "Can't run query: %s rc:%d, reason:%s", query.c_str(), rc, reason.c_str());
144145
if (mysql_ping(&dbconn) and zmDbReconnect()) {
145146
rc = mysql_query(&dbconn, query.c_str());
146147
}
147-
}
148-
if (rc) {
149-
Error("Can't run query: %s rc:%d, reason:%s", query.c_str(), rc, mysql_error(&dbconn));
150-
return nullptr;
148+
if (rc) {
149+
Error("Can't run query: %s rc:%d, reason:%s", query.c_str(), rc, reason.c_str());
150+
return nullptr;
151+
}
151152
}
152153
MYSQL_RES *result = mysql_store_result(&dbconn);
153154
if (!result) {

src/zm_ffmpeg_camera.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ int FfmpegCamera::OpenFfmpeg() {
391391
return -1;
392392
}
393393

394-
// Find first video stream present
395-
// The one we want Might not be the first
394+
// Find first video stream present, the one we want Might not be the first
396395
mVideoStreamId = -1;
397396
mAudioStreamId = -1;
398397
for (unsigned int i=0; i < mFormatContext->nb_streams; i++) {
@@ -408,13 +407,13 @@ int FfmpegCamera::OpenFfmpeg() {
408407
mVideoStream = stream;
409408
} else {
410409
Debug(2, "Have another video stream.");
411-
if (stream->codecpar->width == width and stream->codecpar->height == height) {
412-
Debug(1, "Choosing alternate video stream because it matches our resolution.");
413-
mVideoStreamId = i;
414-
mVideoStream = stream;
415-
} else {
416-
stream->discard = AVDISCARD_ALL;
417-
}
410+
if (stream->codecpar->width == width and stream->codecpar->height == height) {
411+
Debug(1, "Choosing alternate video stream because it matches our resolution.");
412+
mVideoStreamId = i;
413+
mVideoStream = stream;
414+
} else {
415+
stream->discard = AVDISCARD_ALL;
416+
}
418417
}
419418
} else if (is_audio_stream(stream)) {
420419
if (mAudioStreamId == -1) {
@@ -446,9 +445,9 @@ int FfmpegCamera::OpenFfmpeg() {
446445
}
447446

448447
if (!mVideoCodec) {
448+
// Try and get the codec from the codec context
449449
mVideoCodec = avcodec_find_decoder(mVideoStream->codecpar->codec_id);
450450
if (!mVideoCodec) {
451-
// Try and get the codec from the codec context
452451
Error("Can't find codec for video stream from %s", mMaskedPath.c_str());
453452
return -1;
454453
}

0 commit comments

Comments
 (0)