Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into tesla

This commit is contained in:
Isaac Connor 2018-01-23 09:44:28 -08:00
commit c85bb6e614
10 changed files with 120 additions and 12 deletions

100
db/zm_update-1.31.27.sql Normal file
View File

@ -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//

View File

@ -185,7 +185,7 @@ use Sys::CpuLoad;
my $attempts = 0; my $attempts = 0;
while( !connect( CLIENT, $saddr ) ) { while( !connect( CLIENT, $saddr ) ) {
$attempts++; $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); Fatal( "Can't connect: $!" ) if ($attempts > MAX_CONNECT_DELAY);
usleep(200000); usleep(200000);
} # end while } # end while
@ -566,13 +566,19 @@ sub restart {
my $command = $daemon; my $command = $daemon;
$command .= ' '.join( ' ', ( @args ) ) if @args; $command .= ' '.join( ' ', ( @args ) ) if @args;
dPrint ( ZoneMinder::Logger::WARNING, "Restarting $command\n");
my $process = $cmd_hash{$command}; my $process = $cmd_hash{$command};
if ( $process ) { if ( $process ) {
dPrint ( ZoneMinder::Logger::WARNING, "Have process" );
if ( $process->{pid} ) { if ( $process->{pid} ) {
dPrint ( ZoneMinder::Logger::WARNING, "Have process pid " .$process->{pid} );
my $cpid = $process->{pid}; my $cpid = $process->{pid};
if ( defined($pid_hash{$cpid}) ) { if ( defined($pid_hash{$cpid}) ) {
dPrint ( ZoneMinder::Logger::WARNING, "Have process pid hash " .$process->{pid} );
_stop( 0, $process ); _stop( 0, $process );
return; return;
} else {
dPrint ( ZoneMinder::Logger::WARNING, "Not sending stop" );
} }
} }
} }

View File

@ -354,8 +354,10 @@ int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt) {
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100) #if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
#else #else
unsigned int zm_av_packet_ref( AVPacket *dst, AVPacket *src ) { unsigned int zm_av_packet_ref( AVPacket *dst, AVPacket *src ) {
dst->data = reinterpret_cast<uint8_t*>(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<uint8_t*>(new uint64_t[dst->size]);
memcpy(dst->data, src->data, src->size ); memcpy(dst->data, src->data, src->size );
dst->flags = src->flags;
return 0; return 0;
} }
#endif #endif

View File

@ -814,10 +814,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
AVPacket safepkt; AVPacket safepkt;
memcpy(&safepkt, &opkt, sizeof(AVPacket)); memcpy(&safepkt, &opkt, sizeof(AVPacket));
Debug(1, dumpPacket( &opkt, "writing video packet" );
"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);
if ((opkt.data == NULL) || (opkt.size < 1)) { if ((opkt.data == NULL) || (opkt.size < 1)) {
Warning("%s:%d: Mangled AVPacket: discarding frame", __FILE__, __LINE__); Warning("%s:%d: Mangled AVPacket: discarding frame", __FILE__, __LINE__);
dumpPacket(ipkt); dumpPacket(ipkt);
@ -839,7 +836,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
Warning( Warning(
"%s:%d: Writing frame [av_interleaved_write_frame()] failed: %s(%d) " "%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); dumpPacket(&safepkt);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_dump_codecpar(video_in_stream->codecpar); zm_dump_codecpar(video_in_stream->codecpar);

View File

@ -1 +1 @@
1.31.26 1.31.27

View File

@ -55,7 +55,7 @@ $remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.soc
$max_socket_tries = 10; $max_socket_tries = 10;
// FIXME This should not exceed web_ajax_timeout // 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. 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); usleep(200000);
} }

View File

@ -1,7 +1,7 @@
.ptzControls { .ptzControls {
vertical-align: top; vertical-align: top;
margin: 10px auto 0; margin: 10px auto 0;
width: 500px; width: 520px;
} }
.ptzControls::after { .ptzControls::after {

View File

@ -46,6 +46,9 @@ foreach ( $storage_areas as $S ) {
?> ?>
<div class="controlHeader"> <div class="controlHeader">
<input type="hidden" name="filtering" value="" /> <input type="hidden" name="filtering" value="" />
<?php
$groupSql = '';
if ( Group::find_all() ) { ?>
<span id="groupControl"><label><?php echo translate('Group') ?>:</label> <span id="groupControl"><label><?php echo translate('Group') ?>:</label>
<?php <?php
# This will end up with the group_id of the deepest selection # This will end up with the group_id of the deepest selection
@ -54,6 +57,7 @@ echo Group::get_group_dropdown();
$groupSql = Group::get_group_sql( $group_id ); $groupSql = Group::get_group_sql( $group_id );
?> ?>
</span> </span>
<?php } ?>
<span id="monitorControl"><label><?php echo translate('Monitor') ?>:</label> <span id="monitorControl"><label><?php echo translate('Monitor') ?>:</label>
<?php <?php

View File

@ -206,7 +206,7 @@ while ( $event_row = dbFetchNext( $results ) ) {
<td class="colThumbnail"> <td class="colThumbnail">
<?php <?php
if ( ( $event->SaveJPEGs() == 0 ) and file_exists($event->Path().'/snapshot.jpg') ) { if ( ( $event->SaveJPEGs() == 0 ) and file_exists($event->Path().'/snapshot.jpg') ) {
Logger::Debug("Using snapshot"); Logger::Debug("Using snapshot" . $event->Path().'/snapshot.jpg' );
$imgSrc = '?view=image&amp;eid='.$event->Id().'&amp;fid=snapshot&amp;width='.$thumbData['Width'].'&amp;height='.$thumbData['Height']; $imgSrc = '?view=image&amp;eid='.$event->Id().'&amp;fid=snapshot&amp;width='.$thumbData['Width'].'&amp;height='.$thumbData['Height'];
} else { } else {
Logger::Debug("Not Using snapshot" . $event->Path().'/snapshot.jpg' ); Logger::Debug("Not Using snapshot" . $event->Path().'/snapshot.jpg' );

View File

@ -66,7 +66,6 @@ if ( empty($_REQUEST['path']) ) {
$Frame = new Frame(); $Frame = new Frame();
$Frame->FrameId('snapshot'); $Frame->FrameId('snapshot');
$path = $Event->Path().'/snapshot.jpg'; $path = $Event->Path().'/snapshot.jpg';
Warning("Path to snapshot: $path");
} else { } else {
$show = empty($_REQUEST['show']) ? 'capture' : $_REQUEST['show']; $show = empty($_REQUEST['show']) ? 'capture' : $_REQUEST['show'];