From a3c298ca930ed108dc4f1d86b0d46bb60310a64e Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 8 Jan 2022 13:17:04 -0600 Subject: [PATCH 1/2] Add nullptr checks to prevent a crash when in NODECT mode --- src/zm_monitor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 008ca8a77..7a8d49b4d 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2163,6 +2163,7 @@ bool Monitor::Analyse() { snap->analysis_image->Overlay(*(zone.AlarmImage())); } // end if zone is alarmed } // end foreach zone + if (snap->analysis_image != nullptr) alarm_image.Assign(*(snap->analysis_image)); } // end if image. @@ -2177,6 +2178,7 @@ bool Monitor::Analyse() { snap->analysis_image->Overlay(*(zone.AlarmImage())); } // end if zone is alarmed } // end foreach zone + if (snap->analysis_image != nullptr) alarm_image.Assign(*(snap->analysis_image)); } From 52b377ca8667580a20fba57c13b0ca2fad752206 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 8 Jan 2022 14:05:57 -0600 Subject: [PATCH 2/2] Adds the 'closes_event" ONVIF option, to handle motionDetection message quirks. --- src/zm_monitor.cpp | 11 +++++++++++ src/zm_monitor.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 7a8d49b4d..f194378d3 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -421,6 +421,7 @@ Monitor::Monitor() linked_monitors(nullptr), #ifdef WITH_GSOAP soap(nullptr), + ONVIF_Closes_Event(FALSE), #endif red_val(0), green_val(0), @@ -1080,6 +1081,9 @@ bool Monitor::connect() { if (onvif_event_listener) { //Temporarily using this option to enable the feature Debug(1, "Starting ONVIF"); ONVIF_Healthy = FALSE; + if (onvif_options.find("closes_event") != std::string::npos) { //Option to indicate that ONVIF will send a close event message + ONVIF_Closes_Event = TRUE; + } tev__PullMessages.Timeout = "PT600S"; tev__PullMessages.MessageLimit = 100; soap = soap_new(); @@ -1802,6 +1806,10 @@ bool Monitor::Poll() { } else { Debug(1, "Triggered off ONVIF"); ONVIF_Trigger_State = FALSE; + if (!ONVIF_Closes_Event) { //If we get a close event, then we know to expect them. + ONVIF_Closes_Event = TRUE; + Debug(1,"Setting ClosesEvent"); + } } } } @@ -1868,6 +1876,9 @@ bool Monitor::Analyse() { Event::StringSet noteSet; noteSet.insert("ONVIF2"); noteSetMap[MOTION_CAUSE] = noteSet; + //If the camera isn't going to send an event close, we need to close it here, but only after it has actually triggered an alarm. + if (!ONVIF_Closes_Event && state == ALARM) + ONVIF_Trigger_State = FALSE; } // end ONVIF_Trigger #endif diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 371f8a231..f461c6430 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -436,6 +436,7 @@ protected: struct soap *soap; bool ONVIF_Trigger_State; bool ONVIF_Healthy; + bool ONVIF_Closes_Event; _tev__CreatePullPointSubscription request; _tev__CreatePullPointSubscriptionResponse response; _tev__PullMessages tev__PullMessages;