From c04fcfb23992c83e2d341c8250587def1130b51b Mon Sep 17 00:00:00 2001 From: Isaac Date: Mon, 22 Jan 2018 15:50:18 +0100 Subject: [PATCH 1/9] Need a few more pixels of width to fit all preset buttons --- web/skins/classic/css/base/views/control.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/css/base/views/control.css b/web/skins/classic/css/base/views/control.css index b3d620f5c..90757a146 100644 --- a/web/skins/classic/css/base/views/control.css +++ b/web/skins/classic/css/base/views/control.css @@ -1,7 +1,7 @@ .ptzControls { vertical-align: top; margin: 10px auto 0; - width: 500px; + width: 520px; } .ptzControls::after { From 1b23f7b564e89ff9d83c439a2d7452ff1daeb1cf Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 23 Jan 2018 17:34:49 +0100 Subject: [PATCH 2/9] turn off debug --- web/ajax/stream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ajax/stream.php b/web/ajax/stream.php index 1f0245a69..94b621ed4 100644 --- a/web/ajax/stream.php +++ b/web/ajax/stream.php @@ -55,7 +55,7 @@ $remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.soc $max_socket_tries = 10; // FIXME This should not exceed web_ajax_timeout while ( !file_exists($remSockFile) && $max_socket_tries-- ) { //sometimes we are too fast for our own good, if it hasn't been setup yet give it a second. - Logger::Debug("$remSockFile does not exist, waiting, current " . (time() - $start_time) . ' seconds' ); + //Logger::Debug("$remSockFile does not exist, waiting, current " . (time() - $start_time) . ' seconds' ); usleep(200000); } From 83371d0f21d836df0899b6d91c04a44da0c21ffb Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 23 Jan 2018 17:42:57 +0100 Subject: [PATCH 3/9] Fix Error => Debug --- scripts/zmdc.pl.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/zmdc.pl.in b/scripts/zmdc.pl.in index e7198fdd7..623769d81 100644 --- a/scripts/zmdc.pl.in +++ b/scripts/zmdc.pl.in @@ -185,7 +185,7 @@ use Sys::CpuLoad; my $attempts = 0; while( !connect( CLIENT, $saddr ) ) { $attempts++; - Error("Waiting for zmdc.pl server process at " . SOCK_FILE.", attempt $attempts" ); + Debug("Waiting for zmdc.pl server process at ".SOCK_FILE.", attempt $attempts" ); Fatal( "Can't connect: $!" ) if ($attempts > MAX_CONNECT_DELAY); usleep(200000); } # end while @@ -566,13 +566,19 @@ sub restart { my $command = $daemon; $command .= ' '.join( ' ', ( @args ) ) if @args; + dPrint ( ZoneMinder::Logger::WARNING, "Restarting $command\n"); my $process = $cmd_hash{$command}; if ( $process ) { + dPrint ( ZoneMinder::Logger::WARNING, "Have process" ); if ( $process->{pid} ) { + dPrint ( ZoneMinder::Logger::WARNING, "Have process pid " .$process->{pid} ); my $cpid = $process->{pid}; if ( defined($pid_hash{$cpid}) ) { + dPrint ( ZoneMinder::Logger::WARNING, "Have process pid hash " .$process->{pid} ); _stop( 0, $process ); return; + } else { + dPrint ( ZoneMinder::Logger::WARNING, "Not sending stop" ); } } } From abb2cfbe125f70ef8306c3af5b4b2664e4c54924 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 23 Jan 2018 18:14:55 +0100 Subject: [PATCH 4/9] fix zm_av_packet_ref for old ffmpeg. Need to set the size and flags as well as copying the mem. --- src/zm_ffmpeg.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 2db516cf4..5ddd8ee82 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -354,8 +354,10 @@ int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt) { #if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100) #else unsigned int zm_av_packet_ref( AVPacket *dst, AVPacket *src ) { - dst->data = reinterpret_cast(new uint64_t[(src->size + FF_INPUT_BUFFER_PADDING_SIZE)/sizeof(uint64_t) + 1]); + dst->size = (src->size + FF_INPUT_BUFFER_PADDING_SIZE)/sizeof(uint64_t) + 1; + dst->data = reinterpret_cast(new uint64_t[dst->size]); memcpy(dst->data, src->data, src->size ); + dst->flags = src->flags; return 0; } #endif From 66fd02a29eb8d0cb1010d501e8de8899ae12f4f3 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 23 Jan 2018 18:15:29 +0100 Subject: [PATCH 5/9] Use dumpPacket --- src/zm_videostore.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 432a74011..d530c6716 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -814,10 +814,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) { AVPacket safepkt; memcpy(&safepkt, &opkt, sizeof(AVPacket)); - Debug(1, - "writing video packet keyframe(%d) pts(%d) dts(%d) duration(%d) " - "ipkt.duration(%d)", - opkt.flags & AV_PKT_FLAG_KEY, opkt.pts, opkt.dts, duration, ipkt->duration); + dumpPacket( &opkt, "writing video packet" ); if ((opkt.data == NULL) || (opkt.size < 1)) { Warning("%s:%d: Mangled AVPacket: discarding frame", __FILE__, __LINE__); dumpPacket(ipkt); @@ -839,7 +836,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) { Warning( "%s:%d: Writing frame [av_interleaved_write_frame()] failed: %s(%d) " " ", - __FILE__, __LINE__, av_make_error_string(ret).c_str(), (ret)); + __FILE__, __LINE__, av_make_error_string(ret).c_str(), ret); dumpPacket(&safepkt); #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) zm_dump_codecpar(video_in_stream->codecpar); From 8bd1e4cec6dc75c730f5718e18c458c0f8da46fe Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 23 Jan 2018 18:15:59 +0100 Subject: [PATCH 6/9] Only show groups filter if there are groups --- web/skins/classic/views/_monitor_filters.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/skins/classic/views/_monitor_filters.php b/web/skins/classic/views/_monitor_filters.php index eb58fccf6..d2564f7a5 100644 --- a/web/skins/classic/views/_monitor_filters.php +++ b/web/skins/classic/views/_monitor_filters.php @@ -46,6 +46,9 @@ foreach ( $storage_areas as $S ) { ?>
+ + Date: Tue, 23 Jan 2018 18:16:24 +0100 Subject: [PATCH 7/9] bump version to 1.31.27 for new event_update trigger --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index fca4bdfac..060b0a197 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.31.26 +1.31.27 From de08e3114ee73ee5eca7040e47ffbae7e7faccc8 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 23 Jan 2018 18:16:37 +0100 Subject: [PATCH 8/9] more and less debug --- web/skins/classic/views/events.php | 2 +- web/views/image.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/web/skins/classic/views/events.php b/web/skins/classic/views/events.php index cb6b4ea2c..7218b67f6 100644 --- a/web/skins/classic/views/events.php +++ b/web/skins/classic/views/events.php @@ -206,7 +206,7 @@ while ( $event_row = dbFetchNext( $results ) ) { SaveJPEGs() == 0 ) and file_exists($event->Path().'/snapshot.jpg') ) { - Logger::Debug("Using snapshot"); + Logger::Debug("Using snapshot" . $event->Path().'/snapshot.jpg' ); $imgSrc = '?view=image&eid='.$event->Id().'&fid=snapshot&width='.$thumbData['Width'].'&height='.$thumbData['Height']; } else { Logger::Debug("Not Using snapshot" . $event->Path().'/snapshot.jpg' ); diff --git a/web/views/image.php b/web/views/image.php index 6214c7b44..eb1bd4743 100644 --- a/web/views/image.php +++ b/web/views/image.php @@ -66,7 +66,6 @@ if ( empty($_REQUEST['path']) ) { $Frame = new Frame(); $Frame->FrameId('snapshot'); $path = $Event->Path().'/snapshot.jpg'; -Warning("Path to snapshot: $path"); } else { $show = empty($_REQUEST['show']) ? 'capture' : $_REQUEST['show']; From fd2d2a0d77147d834fb6bde50d5e052d62521ca2 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 23 Jan 2018 18:43:59 +0100 Subject: [PATCH 9/9] ad update to update events_update_trigger to dix totaldiskspace --- db/zm_update-1.31.27.sql | 100 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 db/zm_update-1.31.27.sql diff --git a/db/zm_update-1.31.27.sql b/db/zm_update-1.31.27.sql new file mode 100644 index 000000000..6500c1efd --- /dev/null +++ b/db/zm_update-1.31.27.sql @@ -0,0 +1,100 @@ +delimiter // +DROP TRIGGER IF EXISTS event_update_trigger; + +CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events +FOR EACH ROW +BEGIN + declare diff BIGINT default 0; + + set diff = NEW.DiskSpace - OLD.DiskSpace; + IF ( NEW.StorageId = OLD.StorageID ) THEN + IF ( diff ) THEN + call update_storage_stats(OLD.StorageId, diff); + END IF; + ELSE + IF ( NEW.DiskSpace ) THEN + call update_storage_stats(NEW.StorageId, NEW.DiskSpace); + END IF; + IF ( OLD.DiskSpace ) THEN + call update_storage_stats(OLD.StorageId, -OLD.DiskSpace); + END IF; + END IF; + + UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + IF ( NEW.Archived != OLD.Archived ) THEN + IF ( NEW.Archived ) THEN + INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace); + UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)+1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=NEW.MonitorId; + ELSEIF ( OLD.Archived ) THEN + DELETE FROM Events_Archived WHERE EventId=OLD.Id; + UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)-1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) WHERE Id=OLD.MonitorId; + ELSE + IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN + UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + UPDATE Monitors SET + ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) + WHERE Id=OLD.MonitorId; + END IF; + END IF; + END IF; + + IF ( + ( (OLD.DiskSpace IS NOT NULL) AND (NEW.DiskSpace IS NULL) ) + OR + ( (OLD.DiskSpace IS NULL) AND (NEW.DiskSpace IS NOT NULL) ) + OR ( OLD.DiskSpace != NEW.DiskSpace ) + ) THEN + UPDATE Monitors SET TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=OLD.MonitorId; + END IF; + +END; + +// + +DROP TRIGGER IF EXISTS event_insert_trigger; + +create trigger event_insert_trigger after insert on Events +for each row + begin + + INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); + INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); + INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); + INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); + UPDATE Monitors SET TotalEvents = COALESCE(TotalEvents,0)+1 WHERE Id=NEW.MonitorId; +end; +// + +UPDATE Monitors INNER JOIN ( + SELECT MonitorId, + COUNT(Id) AS TotalEvents, + SUM(DiskSpace) AS TotalEventDiskSpace, + SUM(IF(Archived,1,0)) AS ArchivedEvents, + SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace + FROM Events GROUP BY MonitorId + ) AS E ON E.MonitorId=Monitors.Id SET + Monitors.TotalEvents = E.TotalEvents, + Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace, + Monitors.ArchivedEvents = E.ArchivedEvents, + Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace, + Monitors.HourEvents = E.HourEvents, + Monitors.HourEventDiskSpace = E.HourEventDiskSpace, + Monitors.DayEvents = E.DayEvents, + Monitors.DayEventDiskSpace = E.DayEventDiskSpace, + Monitors.WeekEvents = E.WeekEvents, + Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace, + Monitors.MonthEvents = E.MonthEvents, + Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace// + +