From caeb65233e4b87f3a42a3dcae9c77436c84dd871 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 8 Jul 2024 08:36:55 -0400 Subject: [PATCH 1/6] Fix not being able to unset use WallClockTimestamps --- web/includes/actions/monitor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/web/includes/actions/monitor.php b/web/includes/actions/monitor.php index e55cfce4eb..854fe04524 100644 --- a/web/includes/actions/monitor.php +++ b/web/includes/actions/monitor.php @@ -101,6 +101,7 @@ 'Exif' => 0, 'RTSPDescribe' => 0, 'V4LMultiBuffer' => '', + 'WallClockTimestamps' => '', 'RecordAudio' => 0, 'Method' => 'raw', 'GroupIds' => array(), From 63a2ed4b063706ade9defbf32da3b2eb2d8bc6f6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 8 Jul 2024 08:39:41 -0400 Subject: [PATCH 2/6] Take Importance into accoutn when logging Unable to read from stream --- src/zm_ffmpeg_camera.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index bf3eb8a878..9f20c3068a 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -235,8 +235,9 @@ int FfmpegCamera::Capture(std::shared_ptr &zm_packet) { Info("Unable to read packet from stream %d: error %d \"%s\".", packet->stream_index, ret, av_make_error_string(ret).c_str()); } else { - Error("Unable to read packet from stream %d: error %d \"%s\".", - packet->stream_index, ret, av_make_error_string(ret).c_str()); + logPrintf(Logger::ERROR + monitor->Importance(), + "Unable to read packet from stream %d: error %d \"%s\".", + packet->stream_index, ret, av_make_error_string(ret).c_str()); } return -1; } From 89b19d2439aab186402965fc1c39239750a64015 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 8 Jul 2024 08:53:44 -0400 Subject: [PATCH 3/6] Limit segfaults to 1 --- src/zm_signal.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/zm_signal.cpp b/src/zm_signal.cpp index efeb38c22c..e988a665bc 100644 --- a/src/zm_signal.cpp +++ b/src/zm_signal.cpp @@ -27,6 +27,7 @@ bool zm_reload = false; bool zm_terminate = false; +bool zm_panic = false; RETSIGTYPE zm_hup_handler(int signal) { // Shouldn't do complex things in signal handlers, logging is complex and can block due to mutexes. @@ -47,6 +48,9 @@ RETSIGTYPE zm_die_handler(int signal) #endif { zm_terminate = true; + if (zm_panic) + Panic("Got signal %d (%s), crashing", signal, strsignal(signal)); + zm_panic = true; Error("Got signal %d (%s), crashing", signal, strsignal(signal)); #if (defined(__i386__) || defined(__x86_64__)) // Get more information if available From a993ddb58420619e193a15db159f11fa320f3aa7 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 9 Jul 2024 08:13:16 -0400 Subject: [PATCH 4/6] POpulateFrame can be const --- src/zm_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 26e69644c0..fca64dd7f8 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -258,7 +258,7 @@ Image::Image(const AVFrame *frame, int p_width, int p_height) : static void dont_free(void *opaque, uint8_t *data) { } -int Image::PopulateFrame(AVFrame *frame) { +int Image::PopulateFrame(AVFrame *frame) const { Debug(1, "PopulateFrame: width %d height %d linesize %d colours %d imagesize %d %s", width, height, linesize, colours, size, av_get_pix_fmt_name(imagePixFormat) From 7665c63da045636cb640401e4450573e6e76e169 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 9 Jul 2024 08:14:09 -0400 Subject: [PATCH 5/6] Add datetime as a zms option --- src/zms.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/zms.cpp b/src/zms.cpp index f5bca10d77..6f7ee5aaed 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -24,6 +24,8 @@ #include "zm_monitorstream.h" #include "zm_eventstream.h" #include "zm_fifo_stream.h" +#include +#include #include #include @@ -154,6 +156,12 @@ int main(int argc, const char *argv[], char **envp) { monitor_id = atoi(value); if ( source == ZMS_UNKNOWN ) source = ZMS_MONITOR; + } else if ( !strcmp(name, "datetime") ) { + std::tm tm = {}; + std::stringstream ss(value); + ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S"); + auto tp = std::chrono::system_clock::from_time_t(std::mktime(&tm)); + event_time = std::chrono::duration_cast(tp.time_since_epoch()).count(); } else if ( !strcmp(name, "time") ) { event_time = atoi(value); } else if ( !strcmp(name, "event") ) { From b4c871dc096e3a7346c1f8a479dc29ae1463dbb6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 9 Jul 2024 08:21:08 -0400 Subject: [PATCH 6/6] Always re-apply the latest update. Mainly because sometimes Isaac forgets to add the zm_update file when bumping versions, also in release branches, we increment version before release. zm_update scripts are always supposed to be re-runnable, so this is ok, if a little skeezy --- scripts/zmupdate.pl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/zmupdate.pl.in b/scripts/zmupdate.pl.in index a35bf5b771..3c9aa04f91 100644 --- a/scripts/zmupdate.pl.in +++ b/scripts/zmupdate.pl.in @@ -941,7 +941,7 @@ if ( $version ) { foreach my $patch ( @files ) { my ( $v ) = $patch =~ /^zm_update\-([\d\.]+)\.sql$/; #PP make sure we use version compare - if ( version->parse('v'.$v) > version->parse('v'.$version) ) { + if ( version->parse('v'.$v) >= version->parse('v'.$version) ) { print("Upgrading DB to $v from $version\n"); if ( patchDB($dbh, $v) ) { my $res = $sth->execute($version) or die( "Can't execute: ".$sth->errstr() );