From 2c5b13d001c3ba1ebe0e6cf88860170e9f7c9578 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 11 Nov 2020 12:04:55 -0500 Subject: [PATCH 1/4] Revert to FriendsOfCake instead of our fork, as they have merged our patch. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index eb0e282a2..9f21bb62b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "web/api/app/Plugin/Crud"] path = web/api/app/Plugin/Crud - url = https://github.com/ZoneMinder/crud.git + url = https://github.com/FriendsOfCake/crud.git branch = 3.0 [submodule "web/api/app/Plugin/CakePHP-Enum-Behavior"] path = web/api/app/Plugin/CakePHP-Enum-Behavior From 02f2c86d430d95b275a6e60498e28316c5b7ad4c Mon Sep 17 00:00:00 2001 From: Bluemax <1403092+BlueMax@users.noreply.github.com> Date: Thu, 12 Nov 2020 01:32:15 +0100 Subject: [PATCH 2/4] Honor conf.d (zmlinkcontent.sh) Signed-off-by: Bluemax <1403092+BlueMax@users.noreply.github.com> --- zmlinkcontent.sh.in | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/zmlinkcontent.sh.in b/zmlinkcontent.sh.in index 409202cb1..f6e170ffa 100755 --- a/zmlinkcontent.sh.in +++ b/zmlinkcontent.sh.in @@ -88,16 +88,19 @@ if [[ -n "$ZM_CONFIG" && ! -f "$ZM_CONFIG" ]]; then fi # Load zm.conf -if [ -n "$ZM_CONFIG" ]; then - echo "Using custom zm.conf $ZM_CONFIG" - source "$ZM_CONFIG" -elif [ -f "zm.conf" ]; then - echo "Using local zm.conf" - source "zm.conf" -elif [ -f "/etc/zm.conf" ]; then - echo "Using system zm.conf" - source "/etc/zm.conf" -else +for zmconf in "$ZM_CONFIG" ./zm.conf /etc/zm.conf /etc/zoneminder/zm.conf; do + if [[ -f "$zmconf" ]]; then + echo "Using $zmconf" + source "$zmconf" + # remove filename from path + zmconf2="${zmconf%/*}" + # source conf.d + for i in $(find "${zmconf2}/conf.d" -name \*.conf |sort); do . "$i"; done; + break + fi +done + +if [[ -z "$zmconf2" ]]; then echo -e "Failed locating zoneminder configuration file (zm.conf)\nUse the -z option to specify the full path to the zoneminder configuration file" exit 45 fi From 5bf5d58ac125f14f28f22725bbfd951229b91806 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 16 Nov 2020 11:31:36 -0500 Subject: [PATCH 3/4] Fixes recovering frames from jpegs. Use Time::HiRes stat to get microseconds. --- scripts/ZoneMinder/lib/ZoneMinder/Event.pm | 32 +++++++++++++--------- web/api/app/Plugin/Crud | 2 +- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 589e4bbba..f2c7ea210 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -41,7 +41,7 @@ require Number::Bytes::Human; require Date::Parse; require POSIX; use Date::Format qw(time2str); -use Time::HiRes qw(gettimeofday tv_interval); +use Time::HiRes qw(gettimeofday tv_interval stat); #our @ISA = qw(ZoneMinder::Object); use parent qw(ZoneMinder::Object); @@ -765,44 +765,50 @@ sub recover_timestamps { return; } my @contents = readdir(DIR); - Debug('Have ' . @contents . " files in $path"); + Debug('Have ' . @contents . ' files in '.$path); closedir(DIR); - my @mp4_files = grep( /^\d+\-video\.mp4$/, @contents); + my @mp4_files = grep(/^\d+\-video\.mp4$/, @contents); if ( @mp4_files ) { $$Event{DefaultVideo} = $mp4_files[0]; } - my @analyse_jpgs = grep( /^\d+\-analyse\.jpg$/, @contents); + my @analyse_jpgs = grep(/^\d+\-analyse\.jpg$/, @contents); if ( @analyse_jpgs ) { - $$Event{Save_JPEGs} |= 2; + $$Event{SaveJPEGs} |= 2; } - my @capture_jpgs = grep( /^\d+\-capture\.jpg$/, @contents); + my @capture_jpgs = grep(/^\d+\-capture\.jpg$/, @contents); if ( @capture_jpgs ) { $$Event{Frames} = scalar @capture_jpgs; - $$Event{Save_JPEGs} |= 1; + $$Event{SaveJPEGs} |= 1; # can get start and end times from stat'ing first and last jpg @capture_jpgs = sort { $a cmp $b } @capture_jpgs; my $first_file = "$path/$capture_jpgs[0]"; ( $first_file ) = $first_file =~ /^(.*)$/; my $first_timestamp = (stat($first_file))[9]; - my $last_file = "$path/$capture_jpgs[@capture_jpgs-1]"; + my $last_file = $path.'/'.$capture_jpgs[@capture_jpgs-1]; ( $last_file ) = $last_file =~ /^(.*)$/; my $last_timestamp = (stat($last_file))[9]; my $duration = $last_timestamp - $first_timestamp; $Event->Length($duration); $Event->StartTime( Date::Format::time2str('%Y-%m-%d %H:%M:%S', $first_timestamp) ); + if ( $Event->Scheme() eq 'Deep' and $Event->RelativePath(undef) and ($path ne $Event->Path(undef)) ) { + my ( $year, $month, $day, $hour, $minute, $second ) = + ($path =~ /(\d{2})\/(\d{2})\/(\d{2})\/(\d{2})\/(\d{2})\/(\d{2})$/); + Error("Updating starttime to $path $year/$month/$day $hour:$minute:$second"); + $Event->StartTime(sprintf('%.4d-%.2d-%.2d %.2d:%.2d:%.2d', 2000+$year, $month, $day, $hour, $minute, $second)); + } $Event->EndTime( Date::Format::time2str('%Y-%m-%d %H:%M:%S', $last_timestamp) ); Debug("From capture Jpegs have duration $duration = $last_timestamp - $first_timestamp : $$Event{StartTime} to $$Event{EndTime}"); $ZoneMinder::Database::dbh->begin_work(); foreach my $jpg ( @capture_jpgs ) { my ( $id ) = $jpg =~ /^(\d+)\-capture\.jpg$/; - if ( ! ZoneMinder::Frame->find_one( EventId=>$$Event{Id}, FrameId=>$id ) ) { - my $file = "$path/$jpg"; + if ( ! ZoneMinder::Frame->find_one(EventId=>$$Event{Id}, FrameId=>$id) ) { + my $file = $path.'/'.$jpg; ( $file ) = $file =~ /^(.*)$/; my $timestamp = (stat($file))[9]; my $Frame = new ZoneMinder::Frame(); @@ -813,11 +819,11 @@ sub recover_timestamps { Type=>'Normal', Score=>0, }); - } - } + } # end if Frame not found + } # end foreach capture jpg $ZoneMinder::Database::dbh->commit(); } elsif ( @mp4_files ) { - my $file = "$path/$mp4_files[0]"; + my $file = $path.'/'.$mp4_files[0]; ( $file ) = $file =~ /^(.*)$/; my $first_timestamp = (stat($file))[9]; diff --git a/web/api/app/Plugin/Crud b/web/api/app/Plugin/Crud index 0bd63fb46..2ab7e23fb 160000 --- a/web/api/app/Plugin/Crud +++ b/web/api/app/Plugin/Crud @@ -1 +1 @@ -Subproject commit 0bd63fb464957080ead342db58ca9e01532cf1ef +Subproject commit 2ab7e23fb4f5b31a2f043ba9b9f607a518007f75 From 1b5448ede4b0a0ed70d10dee025b20d318a007b0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 20 Nov 2020 16:35:48 -0500 Subject: [PATCH 4/4] Handle there being no services in the response --- onvif/modules/lib/ONVIF/Client.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/onvif/modules/lib/ONVIF/Client.pm b/onvif/modules/lib/ONVIF/Client.pm index 9676dff85..945e96075 100644 --- a/onvif/modules/lib/ONVIF/Client.pm +++ b/onvif/modules/lib/ONVIF/Client.pm @@ -117,12 +117,15 @@ sub get_service_urls { } ); if ( $result ) { - foreach my $svc ( @{ $result->get_Service() } ) { - my $short_name = $namespace_map{$svc->get_Namespace()}; - my $url_svc = $svc->get_XAddr()->get_value(); - if ( defined $short_name && defined $url_svc ) { - #print "Got $short_name service\n"; - $self->set_service($short_name, 'url', $url_svc); + my $services = $result->get_Service(); + if ( $services ) { + foreach my $svc ( @{ $services } ) { + my $short_name = $namespace_map{$svc->get_Namespace()}; + my $url_svc = $svc->get_XAddr()->get_value(); + if ( defined $short_name && defined $url_svc ) { + #print "Got $short_name service\n"; + $self->set_service($short_name, 'url', $url_svc); + } } } #} else {