From 4a39b3215b90e277622b48acb08bf2690f4a6c59 Mon Sep 17 00:00:00 2001 From: "Jan M. Hochstein" Date: Fri, 5 Dec 2014 09:29:57 +0100 Subject: [PATCH] New monitor function 'Extdect' --- db/zm_update-1.27.99.0.sql | 257 ------------------------------- db/zm_update-1.28.99.0.sql | 55 +++++++ onvif/scripts/zmonvif-trigger.pl | 16 +- scripts/zmpkg.pl.in | 19 ++- src/zm_monitor.cpp | 30 +--- src/zm_monitor.h | 9 +- 6 files changed, 93 insertions(+), 293 deletions(-) delete mode 100644 db/zm_update-1.27.99.0.sql create mode 100644 db/zm_update-1.28.99.0.sql diff --git a/db/zm_update-1.27.99.0.sql b/db/zm_update-1.27.99.0.sql deleted file mode 100644 index 5b4719195..000000000 --- a/db/zm_update-1.27.99.0.sql +++ /dev/null @@ -1,257 +0,0 @@ --- --- This updates a 1.27.0 database to 1.27.1 --- - --- --- Add Controls definition for Wanscam --- -INSERT INTO Controls -SELECT * FROM (SELECT NULL as Id, - 'WanscamPT' as Name, - 'Remote' as Type, - 'Wanscam' as Protocol, - 1 as CanWake, - 1 as CanSleep, - 1 as CanReset, - 0 as CanZoom, - 0 as CanAutoZoom, - 0 as CanZoomAbs, - 0 as CanZoomRel, - 0 as CanZoomCon, - 0 as MinZoomRange, - 0 as MaxZoomRange, - 0 as MinZoomStep, - 0 as MaxZoomStep, - 0 as HasZoomSpeed, - 0 as MinZoomSpeed, - 0 as MaxZoomSpeed, - 0 as CanFocus, - 0 as CanAutoFocus, - 0 as CanFocusAbs, - 0 as CanFocusRel, - 0 as CanFocusCon, - 0 as MinFocusRange, - 0 as MaxFocusRange, - 0 as MinFocusStep, - 0 as MaxFocusStep, - 0 as HasFocusSpeed, - 0 as MinFocusSpeed, - 0 as MaxFocusSpeed, - 1 as CanIris, - 0 as CanAutoIris, - 1 as CanIrisAbs, - 0 as CanIrisRel, - 0 as CanIrisCon, - 0 as MinIrisRange, - 16 as MaxIrisRange, - 0 as MinIrisStep, - 0 as MaxIrisStep, - 0 as HasIrisSpeed, - 0 as MinIrisSpeed, - 0 as MaxIrisSpeed, - 0 as CanGain, - 0 as CanAutoGain, - 0 as CanGainAbs, - 0 as CanGainRel, - 0 as CanGainCon, - 0 as MinGainRange, - 0 as MaxGainRange, - 0 as MinGainStep, - 0 as MaxGainStep, - 0 as HasGainSpeed, - 0 as MinGainSpeed, - 0 as MaxGainSpeed, - 1 as CanWhite, - 0 as CanAutoWhite, - 1 as CanWhiteAbs, - 0 as CanWhiteRel, - 0 as CanWhiteCon, - 0 as MinWhiteRange, - 16 as MaxWhiteRange, - 0 as MinWhiteStep, - 0 as MaxWhiteStep, - 0 as HasWhiteSpeed, - 0 as MinWhiteSpeed, - 0 as MaxWhiteSpeed, - 1 as HasPresets, - 16 as NumPresets, - 1 as HasHomePreset, - 1 as CanSetPresets, - 1 as CanMove, - 1 as CanMoveDiag, - 0 as CanMoveMap, - 0 as CanMoveAbs, - 0 as CanMoveRel, - 1 as CanMoveCon, - 1 as CanPan, - 0 as MinPanRange, - 0 as MaxPanRange, - 0 as MinPanStep, - 0 as MaxPanStep, - 0 as HasPanSpeed, - 0 as MinPanSpeed, - 0 as MaxPanSpeed, - 0 as HasTurboPan, - 0 as TurboPanSpeed, - 1 as CanTilt, - 0 as MinTiltRange, - 0 as MaxTiltRange, - 0 as MinTiltStep, - 0 as MaxTiltStep, - 0 as HasTiltSpeed, - 0 as MinTiltSpeed, - 0 as MaxTiltSpeed, - 0 as HasTurboTilt, - 0 as TurboTiltSpeed, - 0 as CanAutoScan, - 0 as NumScanPaths) AS tmp -WHERE NOT EXISTS ( - SELECT Name FROM Controls WHERE name = 'WanscamPT' -) LIMIT 1; - --- Add extend alarm frame count to zone definition and Presets -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'Zones' - AND table_schema = DATABASE() - AND column_name = 'ExtendAlarmFrames' - ) > 0, -"SELECT 'Column ExtendAlarmFrames exists in Zones'", -"ALTER TABLE `Zones` ADD `ExtendAlarmFrames` smallint(5) unsigned not null default 0 AFTER `OverloadFrames`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; - -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'ZonePresets' - AND table_schema = DATABASE() - AND column_name = 'ExtendAlarmFrames' - ) > 0, -"SELECT 'Column ExtendAlarmFrames exists in ZonePresets'", -"ALTER TABLE `ZonePresets` ADD `ExtendAlarmFrames` smallint(5) unsigned not null default 0 AFTER `OverloadFrames`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; - --- --- Add MotionSkipFrame field for controlling how many frames motion detection should skip. --- - -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'Monitors' - AND table_schema = DATABASE() - AND column_name = 'MotionFrameSkip' - ) > 0, -"SELECT 1", -"ALTER TABLE `Monitors` ADD `MotionFrameSkip` smallint(5) unsigned NOT NULL default '0' AFTER `FrameSkip`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; - --- --- Add Monitor Options field; used for specifying Ffmpeg AVoptions like rtsp_transport http or libVLC options --- -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'Monitors' - AND table_schema = DATABASE() - AND column_name = 'Options' - ) > 0, -"SELECT 'Column Options already exists in Monitors'", -"ALTER TABLE `Monitors` ADD `Options` varchar(255) not null default '' AFTER `Path`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; - --- --- Add V4LMultiBuffer and V4LCapturesPerFrame to Monitor --- - -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'Monitors' - AND table_schema = DATABASE() - AND column_name = 'V4LMultiBuffer' - ) > 0, -"SELECT 'Column V4LMultiBuffer exists in Monitors'", -"ALTER TABLE `Monitors` ADD `V4LMultiBuffer` tinyint(1) unsigned not null default 0 AFTER `Format`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; - -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'Monitors' - AND table_schema = DATABASE() - AND column_name = 'V4LCapturesPerFrame' - ) > 0, -"SELECT 'Column CapturesPerFrame exists in Monitors'", -"ALTER TABLE `Monitors` ADD `V4LCapturesPerFrame` tinyint(3) unsigned not null default 0 AFTER `V4LMultiBuffer`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; - --- --- Add Config* fields; used for specifying ONVIF/PSIA options --- -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'Monitors' - AND table_schema = DATABASE() - AND column_name = 'ConfigType' - ) > 0, -"SELECT 'Column ConfigType already exists in Monitors'", -"ALTER TABLE `Monitors` ADD COLUMN `ConfigType` ENUM('None','ONVIF','PSIA') NOT NULL DEFAULT '' AFTER `Triggers`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; - --- --- Add Config* fields; used for specifying ONVIF/PSIA options --- -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'Monitors' - AND table_schema = DATABASE() - AND column_name = 'ConfigURL' - ) > 0, -"SELECT 'Column ConfigURL already exists in Monitors'", -"ALTER TABLE `Monitors` ADD COLUMN `ConfigURL` VARCHAR(255) NOT NULL DEFAULT 'None' AFTER `ConfigType`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; - --- --- Add Config* fields; used for specifying ONVIF/PSIA options --- -SET @s = (SELECT IF( - (SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'Monitors' - AND table_schema = DATABASE() - AND column_name = 'ConfigOptions' - ) > 0, -"SELECT 'Column ConfigOptions already exists in Monitors'", -"ALTER TABLE `Monitors` ADD COLUMN `ConfigOptions` VARCHAR(64) NOT NULL DEFAULT '' AFTER `ConfigURL`" -)); - -PREPARE stmt FROM @s; -EXECUTE stmt; diff --git a/db/zm_update-1.28.99.0.sql b/db/zm_update-1.28.99.0.sql new file mode 100644 index 000000000..3f1ce36cd --- /dev/null +++ b/db/zm_update-1.28.99.0.sql @@ -0,0 +1,55 @@ +-- +-- This updates a 1.28.0 database to 1.28.99.0 +-- + + +-- +-- Add Config* fields; used for specifying ONVIF/PSIA options +-- +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Monitors' + AND table_schema = DATABASE() + AND column_name = 'ConfigType' + ) > 0, +"SELECT 'Column ConfigType already exists in Monitors'", +"ALTER TABLE `Monitors` ADD COLUMN `ConfigType` ENUM('None','ONVIF','PSIA') NOT NULL DEFAULT '' AFTER `Triggers`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +-- +-- Add Config* fields; used for specifying ONVIF/PSIA options +-- +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Monitors' + AND table_schema = DATABASE() + AND column_name = 'ConfigURL' + ) > 0, +"SELECT 'Column ConfigURL already exists in Monitors'", +"ALTER TABLE `Monitors` ADD COLUMN `ConfigURL` VARCHAR(255) NOT NULL DEFAULT 'None' AFTER `ConfigType`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +-- +-- Add Config* fields; used for specifying ONVIF/PSIA options +-- +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Monitors' + AND table_schema = DATABASE() + AND column_name = 'ConfigOptions' + ) > 0, +"SELECT 'Column ConfigOptions already exists in Monitors'", +"ALTER TABLE `Monitors` ADD COLUMN `ConfigOptions` VARCHAR(64) NOT NULL DEFAULT '' AFTER `ConfigURL`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; diff --git a/onvif/scripts/zmonvif-trigger.pl b/onvif/scripts/zmonvif-trigger.pl index 22bafd046..c74d7f194 100755 --- a/onvif/scripts/zmonvif-trigger.pl +++ b/onvif/scripts/zmonvif-trigger.pl @@ -213,7 +213,7 @@ sub xs_duration my %new_monitors = (); - # my $sql = "select * from Monitors where find_in_set( Function, 'Modect,Mocord,Nodect' )>0 and ConfigType='ONVIF'"; + # my $sql = "select * from Monitors where find_in_set( Function, 'Modect,Mocord,Nodect,ExtDect' )>0 and ConfigType='ONVIF'"; my $sql = "select * from Monitors where ConfigType='ONVIF'"; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute() or Fatal( "Can't execute: ".$sth->errstr() ); @@ -557,6 +557,16 @@ sub events my $zm = _ZoneMinder->new(); $zm->init(); $zm->loadMonitors(); # call before fork() + + my %monitors = $zm->monitors(); + my $monitor_count = scalar keys(%monitors); + if($monitor_count == 0) { + print("No active ONVIF monitors found. Exiting\n"); + return; + } + else { + Debug( "Found $monitor_count active ONVIF monitors\n" ); + } Info( "ONVIF Trigger daemon starting\n" ); @@ -592,9 +602,7 @@ sub events my $transport = SOAP::Transport::HTTP::Client->new( # 'local_address' => $localaddr ); ## REUSE port 'local_address' => $localip ); - - my %monitors = $zm->monitors(); - + foreach my $monitor (values(%monitors)) { my $client = $monitor->{onvif_client}; diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index cdbca5dba..022d1aaef 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -183,14 +183,17 @@ if ( $command =~ /^(?:start|restart)$/ ) { if ( $monitor->{Function} ne 'None' ) { - if ( $monitor->{Type} eq 'Local' ) - { - runCommand( "zmdc.pl start zmc -d $monitor->{Device}" ); - } - else - { - runCommand( "zmdc.pl start zmc -m $monitor->{Id}" ); - } + if ( $monitor->{Type} ne 'Extdect' ) + { + if ( $monitor->{Type} eq 'Local' ) + { + runCommand( "zmdc.pl start zmc -d $monitor->{Device}" ); + } + else + { + runCommand( "zmdc.pl start zmc -m $monitor->{Id}" ); + } + } if ( $monitor->{Function} ne 'Monitor' ) { if ( $Config{ZM_OPT_FRAME_SERVER} ) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 8a14cf20f..825716cd7 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2495,27 +2495,6 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); col++; - bool v4l_multi_buffer; - if ( dbrow[col] ) { - if (*dbrow[col] == '0' ) { - v4l_multi_buffer = false; - } else if ( *dbrow[col] == '1' ) { - v4l_multi_buffer = true; - } - } else { - v4l_multi_buffer = config.v4l_multi_buffer; - } - col++; - - int v4l_captures_per_frame = 0; - if ( dbrow[col] ) { - v4l_captures_per_frame = atoi(dbrow[col]); - } else { - v4l_captures_per_frame = config.captures_per_frame; - } -Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); - col++; - std::string protocol = dbrow[col]; col++; std::string method = dbrow[col]; col++; std::string host = dbrow[col]; col++; @@ -2783,10 +2762,15 @@ int Monitor::Capture() { static int FirstCapture = 1; int captureResult; - + + if ( function != EXTDECT ) { + shared_data->last_write_index ++; + return 0; + } + int index = image_count%image_buffer_count; Image* capture_image = image_buffer[index].image; - + if ( (deinterlacing & 0xff) == 4) { if ( FirstCapture != 1 ) { /* Copy the next image into the shared memory */ diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 8addd658c..f3164dd51 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -64,7 +64,8 @@ public: MODECT, RECORD, MOCORD, - NODECT + NODECT, + EXTDECT } Function; typedef enum @@ -372,15 +373,21 @@ public: inline int PrimeCapture() { + if ( function == EXTDECT ) + return( 0 ); return( camera->PrimeCapture() ); } inline int PreCapture() { + if ( function == EXTDECT ) + return( 0 ); return( camera->PreCapture() ); } int Capture(); int PostCapture() { + if ( function == EXTDECT ) + return( 0 ); return( camera->PostCapture() ); }