Skip to content

Commit 083ca1e

Browse files
Merge branch 'master' into ai_server
2 parents 2de116e + 5a57239 commit 083ca1e

9 files changed

Lines changed: 67 additions & 44 deletions

File tree

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
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/Event.pm

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ sub delete {
417417
# Do it individually to avoid locking up the table for new events
418418
ZoneMinder::Database::zmDbDo('DELETE FROM Events WHERE Id=?', $$event{Id});
419419
$ZoneMinder::Database::dbh->commit() if ! $in_transaction;
420+
421+
my $storage = $event->Storage();
422+
$storage->save({DiskSpace=>$storage->DiskSpace()-$event->DiskSpace()}) if $event->DiskSpace();
420423
}
421424

422425
if ( ( $in_zmaudit or (!$Config{ZM_OPT_FAST_DELETE})) and $event->Storage()->DoDelete() ) {
@@ -759,16 +762,29 @@ sub MoveTo {
759762
Warning("Event $$self{Id} has already been moved from $$OldStorage{Id} $SrcPath, just updating the event record in db to $$NewStorage{Id} $NewPath.");
760763
} else {
761764
$error = $self->CopyTo($NewStorage);
762-
return $error if $error;
765+
if ($error) {
766+
$ZoneMinder::Database::dbh->commit() if !$was_in_transaction;
767+
return $error;
768+
}
763769
}
764770

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

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+
772788
$self->delete_files($OldStorage);
773789
return $error;
774790
} # end sub MoveTo

web/includes/Event.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ function DiskSpace( $new='' ) {
314314
$this->{'DiskSpace'} = folder_size($this->Path());
315315
if ($this->{'EndDateTime'} and $this->{'DiskSpace'}) {
316316
# Finished events shouldn't grow in size much so we can commit it to the db.
317-
dbQuery('UPDATE Events SET DiskSpace=? WHERE Id=?', array($this->{'DiskSpace'}, $this->{'Id'}));
317+
#dbQuery('UPDATE Events SET DiskSpace=? WHERE Id=?', array($this->{'DiskSpace'}, $this->{'Id'}));
318318
}
319319
}
320320
return $this->{'DiskSpace'};

web/js/MonitorStream.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -512,19 +512,24 @@ function MonitorStream(monitorData) {
512512
this.started = true;
513513
this.streamListenerBind();
514514
this.activePlayer = 'zms';
515-
this.updateStreamInfo('MJPEG');
515+
this.updateStreamInfo('ZMS MJPEG');
516516
}; // this.start
517517

518518
this.stop = function() {
519+
/* Stop should stop the stream (killing zms) but NOT set src=''; This leaves the last jpeg up on screen instead of a broken image */
519520
const stream = this.getElement();
520521
if (!stream) {
521522
console.warn(`! ${dateTimeToISOLocal(new Date())} Stream for ID=${this.id} it is impossible to stop because it is not found.`);
522523
return;
523524
}
524525
console.debug(`! ${dateTimeToISOLocal(new Date())} Stream for ID=${this.id} STOPPED`);
525-
//if ( 1 ) {
526-
if (-1 === this.activePlayer.indexOf('rtsp2web')) {
527-
if (stream.src) {
526+
this.statusCmdTimer = clearInterval(this.statusCmdTimer);
527+
this.streamCmdTimer = clearInterval(this.streamCmdTimer);
528+
this.started = false;
529+
530+
if (-1 !== this.activePlayer.indexOf('zms')) {
531+
// Icon: My current thought is to just tell zms to stop. Don't go to single.
532+
if (0 && stream.src) {
528533
let src = stream.src;
529534
if (-1 === src.indexOf('mode=')) {
530535
src += '&mode=single';
@@ -537,20 +542,20 @@ function MonitorStream(monitorData) {
537542
stream.src = src;
538543
}
539544
}
540-
}
541-
this.streamCommand(CMD_STOP);
542-
this.statusCmdTimer = clearInterval(this.statusCmdTimer);
543-
this.streamCmdTimer = clearInterval(this.streamCmdTimer);
544-
this.started = false;
545-
if (-1 !== this.activePlayer.indexOf('go2rtc')) {
545+
this.streamCommand(CMD_STOP);
546+
} else if (-1 !== this.activePlayer.indexOf('go2rtc')) {
546547
if (!(stream.wsState === WebSocket.CLOSED && stream.pcState === WebSocket.CLOSED)) {
547548
try {
548549
stream.ondisconnect();
549550
} catch (e) {
550551
console.warn(e);
551552
}
552553
}
553-
if (this.webrtc && ('close' in this.webrtc)) this.webrtc.close();
554+
if (this.webrtc && ('close' in this.webrtc)) {
555+
this.webrtc.close();
556+
} else {
557+
console.log('close not in ', this.webrtc);
558+
}
554559
this.webrtc = null;
555560
} else if (-1 !== this.activePlayer.indexOf('rtsp2web')) {
556561
if (this.webrtc) {
@@ -570,6 +575,8 @@ function MonitorStream(monitorData) {
570575
stream.src = '';
571576
stream.srcObject = null;
572577
janus = null;
578+
} else {
579+
console.log("Unknown activePlayer", this.activePlayer);
573580
}
574581
};
575582

@@ -631,6 +638,7 @@ function MonitorStream(monitorData) {
631638
};
632639

633640
this.kill = function() {
641+
/* kill should actually remove the zms process. Resulting in a broken image on screen. */
634642
if (janus && streaming[this.id]) {
635643
streaming[this.id].detach();
636644
}
@@ -643,9 +651,12 @@ function MonitorStream(monitorData) {
643651
stream.onload = null;
644652

645653
// this.stop tells zms to stop streaming, but the process remains. We need to turn the stream into an image.
646-
if (stream.src && -1 === this.player.indexOf('rtsp2web')) {
654+
if (stream.src && (-1 !== this.player.indexOf('zms'))) {
647655
stream.src = '';
656+
// Make zms exit
657+
this.streamCommand(CMD_QUIT);
648658
}
659+
// Kill and stop share a lot of the same code... so just call stop
649660
this.stop();
650661
};
651662

@@ -1258,7 +1269,7 @@ function MonitorStream(monitorData) {
12581269
$j.ajaxSetup({timeout: AJAX_TIMEOUT});
12591270

12601271
this.streamCmdReq = function(streamCmdParms) {
1261-
if (!(streamCmdParms.command == CMD_STOP && (this.RTSP2WebEnabled || this.Go2RTCEnabled))) {
1272+
if (!(streamCmdParms.command == CMD_STOP && ((-1 !== this.activePlayer.indexOf('go2rtc')) || (-1 !== this.activePlayer.indexOf('rtsp2web'))))) {
12621273
//Otherwise, there will be errors in the console "Socket ... does not exist" when quickly switching stop->start and we also do not need to replace SRC in getStreamCmdResponse
12631274
this.ajaxQueue = jQuery.ajaxQueue({
12641275
url: this.url + (auth_relay?'?'+auth_relay:''),

web/skins/classic/views/js/watch.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ function streamCmdStop(action) {
216216
setButtonState('fastRevBtn', 'unavail');
217217
}
218218
if (action) {
219-
//monitorStream.streamCommand(CMD_STOP);
220-
monitorStream.kill();
219+
monitorStream.stop();
221220
}
222221
//setButtonState('stopBtn', 'unavail');
223222
//setButtonState('playBtn', 'active');

0 commit comments

Comments
 (0)