Merge branch 'master' of github.com:ZoneMinder/ZoneMinder

This commit is contained in:
Isaac Connor 2019-10-18 09:29:42 -04:00
commit 0f1b186eb1
17 changed files with 125 additions and 40 deletions

View File

@ -41,6 +41,7 @@ env:
- SMPFLAGS=-j4 OS=ubuntu DIST=disco DOCKER_REPO=iconzm/packpack USE_SFTP=yes
- SMPFLAGS=-j4 OS=debian DIST=buster DOCKER_REPO=iconzm/packpack USE_SFTP=yes
- SMPFLAGS=-j4 OS=debian DIST=stretch DOCKER_REPO=iconzm/packpack USE_SFTP=yes
- SMPFLAGS=-j4 OS=debian DIST=jessie DOCKER_REPO=iconzm/packpack USE_SFTP=yes
- SMPFLAGS=-j4 OS=ubuntu DIST=trusty ARCH=i386
- SMPFLAGS=-j4 OS=ubuntu DIST=xenial ARCH=i386
- SMPFLAGS=-j4 OS=ubuntu DIST=bionic ARCH=i386

View File

@ -1,8 +1,8 @@
Source: zoneminder
Section: net
Priority: optional
Maintainer: Dmitry Smirnov <onlyjob@debian.org>
Uploaders: Vagrant Cascadian <vagrant@debian.org>
Maintainer: Isaac Connor <isaac@zoneminder.com>
Uploaders: Isaac Connor <isaac@zoneminder.com>
Build-Depends: debhelper (>= 9), python-sphinx | python3-sphinx, apache2-dev, dh-linktree
,cmake
,libx264-dev, libmp4v2-dev
@ -57,6 +57,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
,libsys-mmap-perl [!hurd-any]
,liburi-encode-perl
,libwww-perl
,libdatetime-perl
,libdata-uuid-perl
,libnumber-bytes-human-perl
,libfile-slurp-perl

View File

@ -63,6 +63,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
,liburi-encode-perl
,libwww-perl
,libdata-dump-perl
,libdatetime-perl
,libclass-std-fast-perl
,libsoap-wsdl-perl
,libio-socket-multicast-perl

View File

@ -409,12 +409,12 @@ sub delete_files {
) ) {
my $storage_path = $Storage->Path();
if ( ! $storage_path ) {
if ( !$storage_path ) {
Error("Empty storage path when deleting files for event $$event{Id} with storage id $$event{StorageId}");
return;
}
if ( ! $$event{MonitorId} ) {
if ( !$$event{MonitorId} ) {
Error("No monitor id assigned to event $$event{Id}");
return;
}
@ -450,11 +450,13 @@ sub delete_files {
}
};
Error($@) if $@;
}
} # end if s3fs
if ( !$deleted ) {
my $command = "/bin/rm -rf $storage_path/$event_path";
ZoneMinder::General::executeShellCommand($command);
}
} else {
Error('No event path in delete files. ' . $event->to_string());
} # end if event_path
if ( $event->Scheme() eq 'Deep' ) {
@ -465,6 +467,34 @@ sub delete_files {
unlink($storage_path.'/'.$link_path) or Error("Unable to unlink '$storage_path/$link_path': $!");
}
} # end if Scheme eq Deep
# Now check for empty directories and delete them.
my @path_parts = split('/', $event_path);
pop @path_parts;
# Guaranteed the first part is the monitor id
Debug("Initial path_parts: @path_parts");
while ( @path_parts > 1 ) {
my $path = join('/', $storage_path, @path_parts);
my $dh;
if ( !opendir($dh, $path) ) {
Warning("Fail to open $path");
last;
}
my @dir = readdir($dh);
closedir($dh);
if ( scalar(grep { $_ ne '.' and $_ ne '..' } @dir) == 0 ) {
Debug("Removing empty dir at $path");
if ( !rmdir $path ) {
Warning("Fail to rmdir $path: $!");
last;
}
} else {
Debug("Dir $path is not empty @dir");
last;
}
pop @path_parts;
} # end while path_parts
} # end foreach Storage
} # end sub delete_files

View File

@ -236,6 +236,11 @@ sub Sql {
|| $term->{attr} eq 'Cause'
|| $term->{attr} eq 'Notes'
) {
if ( $term->{op} eq 'LIKE'
|| $term->{op} eq 'NOT LIKE'
) {
$temp_value = '%'.$temp_value.'%' if $temp_value !~ /%/;
}
$value = "'$temp_value'";
} elsif ( $term->{attr} eq 'DateTime' or $term->{attr} eq 'StartDateTime' or $term->{attr} eq 'EndDateTime' ) {
if ( $temp_value eq 'NULL' ) {
@ -295,6 +300,10 @@ sub Sql {
$self->{Sql} .= ' IN ('.join(',', @value_list).')';
} elsif ( $term->{op} eq '!~' ) {
$self->{Sql} .= ' NOT IN ('.join(',', @value_list).')';
} elsif ( $term->{op} eq 'LIKE' ) {
$self->{Sql} .= " LIKE $value";
} elsif ( $term->{op} eq 'NOT LIKE' ) {
$self->{Sql} .= " NOT LIKE $value";
} else {
$self->{Sql} .= ' '.$term->{op}.' '.$value;
}

View File

@ -60,7 +60,7 @@ if ( $version ) {
if ( $help ) {
pod2usage(-exitstatus => -1);
}
if ( ! defined $interval ) {
if ( !defined $interval ) {
$interval = eval($Config{ZM_TELEMETRY_INTERVAL});
}
@ -69,16 +69,17 @@ if ( !($Config{ZM_TELEMETRY_DATA} or $force) ) {
exit(0);
}
print 'ZoneMinder Telemetry Agent starting at '.strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n";
print 'ZoneMinder Telemetry Agent starting at '.strftime('%y/%m/%d %H:%M:%S', localtime())."\n";
my $lastCheck = $Config{ZM_TELEMETRY_LAST_UPLOAD};
while( 1 ) {
my $now = time();
my $since_last_check = $now-$lastCheck;
Debug(" Last Check time (now($now) - lastCheck($lastCheck)) = $since_last_check > interval($interval) or force($force)");
Debug("Last Check time (now($now) - lastCheck($lastCheck)) = $since_last_check > interval($interval) or force($force)");
if ( $since_last_check < 0 ) {
Warning( 'Seconds since last check is negative! Which means that lastCheck is in the future!' );
Warning('Seconds since last check is negative! Which means that lastCheck is in the future!');
sleep($interval);
next;
}
if ( ( ($since_last_check) > $interval ) or $force ) {
@ -88,8 +89,8 @@ while( 1 ) {
# We should keep *BSD systems in mind when calling system commands
my %telemetry;
$telemetry{uuid} = getUUID($dbh);
($telemetry{city}, $telemetry{region}, $telemetry{country}, $telemetry{latitude}, $telemetry{longitude}) = getGeo();
$telemetry{timestamp} = strftime( '%Y-%m-%dT%H:%M:%S%z', localtime() );
@telemetry{qw(city region country latitude longitude)} = getGeo();
$telemetry{timestamp} = strftime('%Y-%m-%dT%H:%M:%S%z', localtime());
$telemetry{monitor_count} = countQuery($dbh,'Monitors');
$telemetry{event_count} = countQuery($dbh,'Events');
$telemetry{architecture} = runSysCmd('uname -p');
@ -138,6 +139,7 @@ sub runSysCmd {
chomp($path);
$arguments[0] = $path;
my $cmd = join(' ',@arguments);
($cmd) = $cmd =~ /(.*)/; # detaint
$result = qx( $cmd );
chomp($result);
}
@ -221,7 +223,7 @@ sub getGeo {
} else {
Warning("Geoip data retrieval returned HTTP POST error code: $resp_code");
Debug("Geoip data retrieval failure response message: $resp_msg");
return ($unknown, $unknown, $unknown, $unknown);
return ($unknown, $unknown, $unknown, $unknown, $unknown);
}
}

View File

@ -27,7 +27,7 @@ extern "C" {
#if HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE
void log_libav_callback( void *ptr, int level, const char *fmt, va_list vargs ) {
void log_libav_callback(void *ptr, int level, const char *fmt, va_list vargs) {
Logger *log = Logger::fetch();
int log_level = 0;
if ( level == AV_LOG_QUIET ) { // -8
@ -62,8 +62,11 @@ void log_libav_callback( void *ptr, int level, const char *fmt, va_list vargs )
}
if ( log ) {
char logString[8192];
char logString[8192];
vsnprintf(logString, sizeof(logString)-1, fmt, vargs);
int length = strlen(logString);
// ffmpeg logs have a carriage return, so replace it with terminator
logString[length-1] = 0;
log->logPrint(false, __FILE__, __LINE__, log_level, logString);
}
}
@ -74,15 +77,14 @@ void FFMPEGInit() {
if ( !bInit ) {
if ( logDebugging() && config.log_ffmpeg ) {
av_log_set_level( AV_LOG_DEBUG );
av_log_set_level(AV_LOG_DEBUG);
av_log_set_callback(log_libav_callback);
Info("Enabling ffmpeg logs, as LOG_DEBUG+LOG_FFMPEG are enabled in options");
} else {
Info("Not enabling ffmpeg logs, as LOG_FFMPEG and/or LOG_DEBUG is disabled in options, or this monitor not part of your debug targets");
av_log_set_level( AV_LOG_QUIET );
av_log_set_level(AV_LOG_QUIET);
}
#if LIBAVFORMAT_VERSION_CHECK(58, 9, 0, 64, 0)
#else
#if !LIBAVFORMAT_VERSION_CHECK(58, 9, 0, 64, 0)
av_register_all();
#endif
avformat_network_init();
@ -550,7 +552,6 @@ int zm_send_packet_receive_frame(
if ( AVERROR(EAGAIN) == ret ) {
// The codec may need more samples than it has, perfectly valid
Debug(2, "Codec not ready to give us a frame");
return 0;
} else {
Error("Could not recieve frame (error %d = '%s')", ret,
av_make_error_string(ret).c_str());
@ -571,7 +572,7 @@ int zm_send_packet_receive_frame(
}
} // end while !frameComplete
#endif
return 1;
return 0;
} // end int zm_send_packet_receive_frame(AVCodecContext *context, AVFrame *frame, AVPacket &packet)
/* Returns < 0 on error, 0 if codec not ready, 1 on success
@ -689,10 +690,14 @@ int zm_resample_audio(
AVFrame *out_frame
) {
#if defined(HAVE_LIBSWRESAMPLE)
// Resample the in_frame into the audioSampleBuffer until we process the whole
// decoded data. Note: pts does not survive resampling or converting
Debug(2, "Converting %d to %d samples using swresample",
in_frame->nb_samples, out_frame->nb_samples);
if ( in_frame ) {
// Resample the in_frame into the audioSampleBuffer until we process the whole
// decoded data. Note: pts does not survive resampling or converting
Debug(2, "Converting %d to %d samples using swresample",
in_frame->nb_samples, out_frame->nb_samples);
} else {
Debug(2, "Sending NULL frame to flush resampler");
}
int ret = swr_convert_frame(resample_ctx, out_frame, in_frame);
if ( ret < 0 ) {
Error("Could not resample frame (error '%s')",
@ -703,6 +708,10 @@ int zm_resample_audio(
swr_get_delay(resample_ctx, out_frame->sample_rate));
#else
#if defined(HAVE_LIBAVRESAMPLE)
if ( ! in_frame ) {
Error("Flushing resampler not supported by AVRESAMPLE");
return 0;
}
int ret = avresample_convert(resample_ctx, NULL, 0, 0, in_frame->data,
0, in_frame->nb_samples);
if ( ret < 0 ) {

View File

@ -277,8 +277,8 @@ VideoStore::VideoStore(
#endif
video_first_pts = 0;
video_first_dts = 0;
video_last_pts = 0;
video_last_dts = 0;
video_next_pts = 0;
video_next_dts = 0;
audio_first_pts = 0;
audio_first_dts = 0;
@ -898,6 +898,8 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
video_first_dts = ipkt->dts;
}
opkt.dts = ipkt->dts - video_first_dts;
} else {
opkt.dts = av_rescale_q(video_next_dts, video_out_stream->time_base, video_in_stream->time_base);;
}
if ( ipkt->pts != AV_NOPTS_VALUE ) {
opkt.pts = ipkt->pts - video_first_dts;
@ -906,6 +908,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
dumpPacket(video_out_stream, &opkt, "after pts adjustment");
write_packet(&opkt, video_out_stream);
video_next_dts = opkt.dts + opkt.duration;
zm_av_packet_unref(&opkt);
return 0;
@ -934,8 +937,8 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) {
if ( audio_out_codec ) {
// I wonder if we can get multiple frames per packet? Probably
ret = zm_send_packet_receive_frame(audio_in_ctx, in_frame, *ipkt);
if ( ret <= 0 ) {
Debug(3, "Not ready to receive frame");
if ( ret < 0 ) {
Debug(3, "failed to receive frame code: %d", ret);
return 0;
}
zm_dump_frame(in_frame, "In frame from decode");

View File

@ -26,7 +26,7 @@ if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${OS}" == "debian" ] || [ "${OS}"
echo "Target subfolder set to $targetfolder"
echo
if [ "${USE_SFTP}" == "yes" ]; then
results="$(rsync build/* "zmrepo@zmrepo.zoneminder.com:${targetfolder}/" 2>&1)"
results="$(rsync build/* zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1)"
if [ -z "$results" ]; then
echo
echo "Files copied successfully."

View File

@ -23,7 +23,7 @@ protected $defaults = array(
'Channel' => 0,
'Format' => '0',
'V4LMultiBuffer' => null,
'V4LCapturesPerFrame' => null,
'V4LCapturesPerFrame' => 1,
'Protocol' => null,
'Method' => '',
'Host' => null,

View File

@ -116,7 +116,16 @@ class Storage extends ZM_Object {
public function Server() {
if ( ! array_key_exists('Server',$this) ) {
$this->{'Server'}= new Server($this->{'ServerId'});
if ( array_key_exists('ServerId', $this) ) {
$this->{'Server'} = Server::find_one(array('Id'=>$this->{'ServerId'}));
if ( ! $this->{'Server'} ) {
Error('No Server record found for server id ' . $this->{'ServerId'});
$this->{'Server'} = new Server();
}
$this->{'Server'} = new Server();
} else {
$this->{'Server'} = new Server();
}
}
return $this->{'Server'};
}

View File

@ -78,7 +78,7 @@ if ( $action == 'monitor' ) {
$restart = false;
if ( count($changes) ) {
if ( $mid ) {
if ( $monitor->Id() ) {
# If we change anything that changes the shared mem size, zma can complain. So let's stop first.
if ( $monitor->Type() != 'WebSite' ) {
@ -203,6 +203,8 @@ if ( $action == 'monitor' ) {
dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) );
//$view = 'none';
$Storage = $monitor->Storage();
error_reporting(0);
mkdir($Storage->Path().'/'.$mid, 0755);
$saferName = basename($_REQUEST['newMonitor']['Name']);
symlink($mid, $Storage->Path().'/'.$saferName);

View File

@ -1223,6 +1223,9 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&amp;') {
case 'Name':
case 'Cause':
case 'Notes':
if($term['op'] == 'LIKE' || $term['op'] == 'NOT LIKE') {
$value = '%'.$value.'%';
}
$value = dbEscape($value);
break;
case 'MonitorServerId':
@ -1275,6 +1278,8 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&amp;') {
case '>' :
case '<' :
case '<=' :
case 'LIKE' :
case 'NOT LIKE':
$filter['sql'] .= ' '.$term['op'].' '. $value;
break;
case '=~' :

View File

@ -579,6 +579,8 @@ $SLANG = array(
'OpNotMatches' => 'does not match',
'OpIs' => 'is',
'OpIsNot' => 'is not',
'OpLike' => 'contains',
'OpNotLike' => 'does not contain',
'OptionalEncoderParam' => 'Optional Encoder Parameters',
'OptionHelp' => 'Option Help',
'OptionRestartWarning' => 'These changes may not come into effect fully\nwhile the system is running. When you have\nfinished making your changes please ensure that\nyou restart ZoneMinder.',

View File

@ -172,13 +172,22 @@ if ( canEdit('Events') ) {
} // end if Event->DefaultVideo
?>
<div id="exportEvent"><button type="button" data-on-click="exportEvent"><?php echo translate('Export') ?></button></div>
<div id="replayControl"><label for="replayMode"><?php echo translate('Replay') ?></label><?php echo buildSelect('replayMode', $replayModes, 'changeReplayMode();'); ?></div>
<div id="scaleControl"><label for="scale"><?php echo translate('Scale') ?></label><?php echo buildSelect('scale', $scales, 'changeScale();'); ?></div>
<div id="codecControl"><label for="codec"><?php echo translate('Codec') ?></label><?php echo htmlSelect('codec', $codecs, $codec, array('onchange'=>'changeCodec(this);')); ?></div>
<div id="replayControl">
<label for="replayMode"><?php echo translate('Replay') ?></label>
<?php echo htmlSelect('replayMode', $replayModes, $replayMode, array('data-on-change'=>'changeReplayMode')); ?>
</div>
<div id="scaleControl">
<label for="scale"><?php echo translate('Scale') ?></label>
<?php echo htmlSelect('scale', $scales, $scale, array('data-on-change'=>'changeScale')); ?>
</div>
<div id="codecControl">
<label for="codec"><?php echo translate('Codec') ?></label>
<?php echo htmlSelect('codec', $codecs, $codec, array('data-on-change-this'=>'changeCodec')); ?>
</div>
</div>
</div>
</div>
<div id="content">
<div id="eventVideo" class="">
<div id="eventVideo">
<?php
if ( ($codec == 'MP4' || $codec == 'auto' ) && $Event->DefaultVideo() ) {
?>

View File

@ -115,6 +115,8 @@ $opTypes = array(
'![]' => translate('OpNotIn'),
'IS' => translate('OpIs'),
'IS NOT' => translate('OpIsNot'),
'LIKE' => translate('OpLike'),
'NOT LIKE' => translate('OpNotLike'),
);
$archiveTypes = array(

View File

@ -26,10 +26,10 @@ function createEventHtml(zm_event, frame) {
new Element('p').inject(eventHtml).set('text', zm_event.Name+(frame?('('+frame.FrameId+')'):''));
new Element('p').inject(eventHtml).set('text', zm_event.StartTime+' - '+zm_event.Length+'s');
new Element('p').inject(eventHtml).set('text', zm_event.Cause);
if ( event.Notes ) {
new Element('p').inject(eventHtml).set('text', event.Notes);
if ( zm_event.Notes ) {
new Element('p').inject(eventHtml).set('text', zm_event.Notes);
}
if ( event.Archived > 0 ) {
if ( zm_event.Archived > 0 ) {
new Element('p').inject(eventHtml).set( 'text', archivedString);
}