Merge branch 'storageareas' of github.com:ZoneMinder/ZoneMinder into storageareas

This commit is contained in:
Isaac Connor
2016-02-12 19:12:12 -05:00
91 changed files with 3160 additions and 510 deletions

View File

@@ -104,6 +104,7 @@ BEGIN
#$dbh->disconnect();
if ( ! exists $Config{ZM_SERVER_ID} ) {
$Config{ZM_SERVER_ID} = undef;
$sth = $dbh->prepare_cached( 'SELECT * FROM Servers WHERE Name=?' );
if ( $Config{ZM_SERVER_NAME} ) {
$res = $sth->execute( $Config{ZM_SERVER_NAME} );
@@ -114,7 +115,6 @@ BEGIN
my $result = $sth->fetchrow_hashref();
$Config{ZM_SERVER_ID} = $$result{Id};
}
$Config{ZM_SERVER_ID} = undef;
}
}

View File

@@ -1985,7 +1985,7 @@ our @options =
You can use filters to instruct ZoneMinder to upload events to
a remote server. This option indicates the password that
ZoneMinder should use to log in for transfer. If you are using
certicate based logins for SFTP servers you can leave this
certificate based logins for SFTP servers you can leave this
option blank.
"),
requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ],
@@ -2077,6 +2077,21 @@ our @options =
type => $types{integer},
category => "upload",
},
{
name => "ZM_UPLOAD_STRICT",
default => "no",
description => "Require strict host key checking for SFTP uploads",
help => qqq("
You can require SFTP uploads to verify the host key of the remote server
for protection against man-in-the-middle attacks. You will need to add the
server's key to the known_hosts file. On most systems, this will be
~/.ssh/known_hosts, where ~ is the home directory of the web server running
ZoneMinder.
"),
requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ],
type => $types{boolean},
category => "upload",
},
{
name => "ZM_UPLOAD_FTP_PASSIVE",
default => "yes",

View File

@@ -173,6 +173,7 @@ sub moveConDown
Debug( "Move Down" );
my $cmd = "decoder_control.cgi?command=2";
$self->sendCmd( $cmd );
$self->autoStop( $self->{Monitor}->{AutoStopTimeout} );
}
#Left Arrow

View File

@@ -155,7 +155,7 @@ sub reset
#my $cmd = "setOSDSetting%26isEnableTimeStamp%3D0%26isEnableDevName%3D1%26dispPos%3D0%26isEnabledOSDMask%3D0";
Info ("Sending reboot $cmd");
$self->sendCmd( $cmd );
# Setup For Stream=0 Resolution=720p Bandwith=4M FPS=30 KeyFrameInterval/GOP=100 VBR=ON
# Setup For Stream=0 Resolution=720p Bandwidth=4M FPS=30 KeyFrameInterval/GOP=100 VBR=ON
#$cmd = "setVideoStreamParam%26streamType%3D0%26resolution%3D0%26bitRate%3D4194304%26frameRate%3D30%26GOP%3D100%26isVBR%3D1";
#$self->sendCmd( $cmd );
# Setup For Infrared AUTO

View File

@@ -0,0 +1,377 @@
# ==========================================================================
#
# ZoneMinder IPCC-7210W IP Control Protocol Module, $Date: 2015-11-18$, $Revision: 0001$
# Modified for use with IPCC-7210W on Nov 2015
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This module contains the implementation of the
# IPCC-7210W IP camera control protocol
#
package ZoneMinder::Control::IPCC-7210W;
use 5.006;
use strict;
use warnings;
require ZoneMinder::Base;
require ZoneMinder::Control;
our @ISA = qw(ZoneMinder::Control);
# ==========================================================================
#
# IPCC-7210W IP Control Protocol
#
# ==========================================================================
use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);
use Time::HiRes qw( usleep );
sub new
{
my $class = shift;
my $id = shift;
my $self = ZoneMinder::Control->new( $id );
bless( $self, $class );
srand( time() );
return $self;
}
our $AUTOLOAD;
sub AUTOLOAD
{
my $self = shift;
my $class = ref($self) || croak( "$self not object" );
my $name = $AUTOLOAD;
$name =~ s/.*://;
if ( exists($self->{$name}) )
{
return( $self->{$name} );
}
Fatal( "Can't access $name member of object of class $class" );
}
sub open
{
my $self = shift;
$self->loadMonitor();
use LWP::UserAgent;
$self->{ua} = LWP::UserAgent->new;
$self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION );
$self->{state} = 'open';
}
sub close
{
my $self = shift;
$self->{state} = 'closed';
}
sub printMsg
{
my $self = shift;
my $msg = shift;
my $msg_len = length($msg);
Debug( $msg."[".$msg_len."]" );
}
sub sendCmd
{
my $self = shift;
my $cmd = shift;
my $result = undef;
printMsg( $cmd, "Tx" );
#print( "http://$address/$cmd\n" );
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd".$self->{Monitor}->{ControlDevice} );
Info( "http://".$self->{Monitor}->{ControlAddress}."/$cmd".$self->{Monitor}->{ControlDevice} );
my $res = $self->{ua}->request($req);
if ( $res->is_success )
{
$result = !undef;
}
else
{
Error( "Error check failed: '".$res->status_line()."'" );
}
return( $result );
}
sub cameraReset
{
my $self = shift;
Debug( "Camera Reset" );
my $cmd = "reboot.cgi?";
$self->sendCmd( $cmd );
}
#Up Arrow
sub moveConUp
{
my $self = shift;
my $params = shift;
Debug( "Move Up" );
my $cmd = "decoder_control.cgi?command=0&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Down Arrow
sub moveConDown
{
my $self = shift;
my $params = shift;
Debug( "Move Down" );
my $cmd = "decoder_control.cgi?command=2&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Left Arrow
sub moveConLeft
{
my $self = shift;
my $params = shift;
Debug( "Move Left" );
my $cmd = "decoder_control.cgi?command=4&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Right Arrow
sub moveConRight
{
my $self = shift;
my $params = shift;
Debug( "Move Right" );
my $cmd = "decoder_control.cgi?command=6&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Diagonally Up Right Arrow
sub moveConUpRight
{
my $self = shift;
my $params = shift;
Debug( "Move Diagonally Up Right" );
my $cmd = "decoder_control.cgi?command=91&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Diagonally Down Right Arrow
sub moveConDownRight
{
my $self = shift;
my $params = shift;
Debug( "Move Diagonally Down Right" );
my $cmd = "decoder_control.cgi?command=93&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Diagonally Up Left Arrow
sub moveConUpLeft
{
my $self = shift;
my $params = shift;
Debug( "Move Diagonally Up Left" );
my $cmd = "decoder_control.cgi?command=90&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Diagonally Down Left Arrow
sub moveConDownLeft
{
my $self = shift;
my $params = shift;
Debug( "Move Diagonally Down Left" );
my $cmd = "decoder_control.cgi?command=92&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Stop
sub moveStop
{
my $self = shift;
Debug( "Move Stop" );
my $cmd = "decoder_control.cgi?command=1&onestep=1&";
$self->sendCmd( $cmd );
}
#Move Camera to Home Position
sub presetHome
{
my $self = shift;
Debug( "Home Preset" );
my $cmd = "decoder_control.cgi?command=25&onestep=0&";
$self->sendCmd( $cmd );
}
# zoom out
sub zoomRelTele
{
my $self = shift;
Debug( "Zoom Tele" );
my $cmd = "camera_control.cgi?param=17&value=1&";
$self->sendCmd( $cmd );
}
#zoom in
sub zoomRelWide
{
my $self = shift;
Debug( "Zoom Wide" );
my $cmd = "camera_control.cgi?param=18&value=1&";
$self->sendCmd( $cmd );
}
#Set preset
sub presetSet
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $presetCmd = 30 + (($preset-1)*2);
Debug( "Set Preset $preset with cmd $presetCmd" );
my $cmd = "decoder_control.cgi?command=$presetCmd&onestep=0&sit=$presetCmd&";
$self->sendCmd( $cmd );
}
#Goto preset
sub presetGoto
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $presetCmd = 31 + (($preset-1)*2);
Debug( "Goto Preset $preset with cmd $presetCmd" );
my $cmd = "decoder_control.cgi?command=$presetCmd&onestep=0&sit=$presetCmd&";
$self->sendCmd( $cmd );
}
#Turn IR on
sub wake
{
my $self = shift;
Debug( "Wake - IR on" );
my $cmd = "camera_control.cgi?param=14&value=1&";
$self->sendCmd( $cmd );
}
#Turn IR off
sub sleep
{
my $self = shift;
Debug( "Sleep - IR off" );
my $cmd = "camera_control.cgi?param=14&value=0&";
$self->sendCmd( $cmd );
}
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
=head1 NAME
ZoneMinder::IPCC-7210W - Perl extension for IPCC-7210W PTZ control
=head1 SYNOPSIS
use ZoneMinder::Control::IPCC
=head1 DESCRIPTION
This script provides Pan/Tilt/Zoom control for IPCC-7210W camera.
=head1 SEE ALSO
ZoneMinder::Control::Wanscam
=head1 AUTHOR
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2001-2008
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.
=cut

View File

@@ -133,8 +133,10 @@ sub sendCmd
my $result = undef;
# Pelco P protocol checksum is created by XOR'ing the first seven bytes in the message
# including the first byte, the STX sync packet
my $checksum = 0x00;
for ( my $i = 1; $i < int(@$cmd); $i++ )
for ( my $i = 0; $i < int(@$cmd); $i++ )
{
$checksum ^= $cmd->[$i];
}

View File

@@ -0,0 +1,227 @@
# ==========================================================================
#
# ZoneMinder Vivotek ePTZ Control Protocol Module
# Copyright (C) 2015 Robin Daermann
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This module contains the implementation of the Vivotek ePTZ camera control
# protocol
#
package ZoneMinder::Control::Vivotek_ePTZ;
use 5.006;
use strict;
use warnings;
require ZoneMinder::Base;
require ZoneMinder::Control;
our @ISA = qw(ZoneMinder::Control);
# ==========================================================================
#
# Vivotek ePTZ Control Protocol
#
# ==========================================================================
use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);
use Time::HiRes qw( usleep );
sub new
{
my $class = shift;
my $id = shift;
my $self = ZoneMinder::Control->new( $id );
Debug( "Camera New" );
bless( $self, $class );
srand( time() );
return $self;
}
our $AUTOLOAD;
sub AUTOLOAD
{
my $self = shift;
my $class = ref($self) || croak( "$self not object" );
my $name = $AUTOLOAD;
Debug( "Camera AUTOLOAD" );
$name =~ s/.*://;
if ( exists($self->{$name}) )
{
return( $self->{$name} );
}
Fatal( "Can't access $name member of object of class $class" );
}
sub open
{
my $self = shift;
$self->loadMonitor();
Debug( "Camera open" );
use LWP::UserAgent;
$self->{ua} = LWP::UserAgent->new;
$self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION );
$self->{state} = 'open';
}
sub close
{
my $self = shift;
$self->{state} = 'closed';
}
sub printMsg
{
my $msg = shift;
my $msg_len = length($msg);
Debug( $msg."[".$msg_len."]" );
}
sub sendCmd
{
my ($self, $cmd, $speedcmd) = @_;
my $result = undef;
printMsg( $speedcmd, "Tx" );
printMsg( $cmd, "Tx" );
my $req = HTTP::Request->new( GET => "http://" . $self->{Monitor}->{ControlAddress} . "/cgi-bin/camctrl/eCamCtrl.cgi?stream=0&$speedcmd&$cmd" );
my $res = $self->{ua}->request($req);
if ( $res->is_success )
{
$result = !undef;
}
else
{
Error( "Request failed: '" . $res->status_line() . "' (URI: '" . $req->as_string() . "')" );
}
return( $result );
}
sub moveConUp
{
my ($self, $params) = @_;
my $speed = 'speedtilt=' . ($params->{tiltspeed} - 6);
Debug( "Move Up" );
$self->sendCmd( 'move=up', $speed );
}
sub moveConDown
{
my ($self, $params) = @_;
my $speed = 'speedtilt=' . ($params->{tiltspeed} - 6);
Debug( "Move Down" );
$self->sendCmd( 'move=down', $speed );
}
sub moveConLeft
{
my ($self, $params) = @_;
my $speed = 'speedpan=-' . $params->{panspeed};
Debug( "Move Left" );
$self->sendCmd( 'move=left', $speed );
}
sub moveConRight
{
my ($self, $params) = @_;
my $speed = 'speedpan=' . ($params->{panspeed} - 6);
Debug( "Move Right" );
$self->sendCmd( 'move=right', $speed );
}
sub moveStop
{
my $self = shift;
Debug( "Move Stop" );
# not implemented
}
sub zoomConTele
{
my ($self, $params) = @_;
my $speed = 'speedzoom=' . ($params->{speed} - 6);
Debug( "Zoom In" );
$self->sendCmd( 'zoom=tele', $speed );
}
sub zoomConWide
{
my ($self, $params) = @_;
my $speed = 'speedzoom=' . ($params->{speed} - 6);
Debug( "Zoom Out" );
$self->sendCmd( 'zoom=wide', $speed );
}
sub reset
{
my $self = shift;
Debug( "Camera Reset" );
$self->sendCmd( 'move=home' );
}
1;
__END__
=head1 NAME
ZoneMinder::Control::Vivotek_ePTZ - ZoneMinder Perl extension for Vivotek ePTZ
camera control protocol
=head1 SYNOPSIS
use ZoneMinder::Control::Vivotek_ePTZ;
=head1 DESCRIPTION
This module implements the ePTZ protocol used in various Vivotek IP cameras,
developed with a Vivotek IB8369 model.
Currently, only simple pan, tilt and zoom function is implemented. Presets will
follow later.
=head2 EXPORT
None.
=head1 SEE ALSO
I would say, see ZoneMinder::Control documentation. But it is a stub.
=head1 AUTHOR
Robin Daermann E<lt>r.daermann@ids-services.deE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2015 by Robin Daermann
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.
=cut

View File

@@ -0,0 +1,399 @@
# ==========================================================================
#
# ZoneMinder Wanscam HW0025 IP Control Protocol Module, $Date: 2009-11-25 09:20:00 +0000 (Wed, 04 Nov 2009) $, $Revision: 0001 $
# Copyright (C) 2001-2015 Florian Neumair
# Modified for use with Foscam FI8918W IP Camera by Dave Harris
# Modified Feb 2011 by Howard Durdle (http://durdl.es/x) to:
# fix horizontal panning, add presets and IR on/off
# use Control Device field to pass username and password
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This module contains the implementation of the Wanscam HW0025 IP camera control
# protocol
#
# Known working Devices:
# * Wanscam HW0025
# * IPCC-7210W
#
package ZoneMinder::Control::WanscamHW0025;
use 5.006;
use strict;
use warnings;
require ZoneMinder::Base;
require ZoneMinder::Control;
our @ISA = qw(ZoneMinder::Control);
# ==========================================================================
#
# Wanscam HW0025 IP Control Protocol
#
# ==========================================================================
use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);
use Time::HiRes qw( usleep );
sub new
{
my $class = shift;
my $id = shift;
my $self = ZoneMinder::Control->new( $id );
bless( $self, $class );
srand( time() );
return $self;
}
our $AUTOLOAD;
sub AUTOLOAD
{
my $self = shift;
my $class = ref($self) || croak( "$self not object" );
my $name = $AUTOLOAD;
$name =~ s/.*://;
if ( exists($self->{$name}) )
{
return( $self->{$name} );
}
Fatal( "Can't access $name member of object of class $class" );
}
sub open
{
my $self = shift;
$self->loadMonitor();
use LWP::UserAgent;
$self->{ua} = LWP::UserAgent->new;
$self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION );
$self->{state} = 'open';
}
sub close
{
my $self = shift;
$self->{state} = 'closed';
}
sub printMsg
{
my $self = shift;
my $msg = shift;
my $msg_len = length($msg);
Debug( $msg."[".$msg_len."]" );
}
sub sendCmd
{
my $self = shift;
my $cmd = shift;
my $result = undef;
printMsg( $cmd, "Tx" );
#print( "http://$address/$cmd\n" );
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd".$self->{Monitor}->{ControlDevice} );
Info( "http://".$self->{Monitor}->{ControlAddress}."/$cmd".$self->{Monitor}->{ControlDevice} );
my $res = $self->{ua}->request($req);
if ( $res->is_success )
{
$result = !undef;
}
else
{
Error( "Error check failed: '".$res->status_line()."'" );
}
return( $result );
}
sub cameraReset
{
my $self = shift;
Debug( "Camera Reset" );
my $cmd = "reboot.cgi?";
$self->sendCmd( $cmd );
}
#Up Arrow
sub moveConUp
{
my $self = shift;
my $params = shift;
Debug( "Move Up" );
my $cmd = "decoder_control.cgi?command=0&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Down Arrow
sub moveConDown
{
my $self = shift;
my $params = shift;
Debug( "Move Down" );
my $cmd = "decoder_control.cgi?command=2&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Left Arrow
sub moveConLeft
{
my $self = shift;
my $params = shift;
Debug( "Move Left" );
my $cmd = "decoder_control.cgi?command=4&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Right Arrow
sub moveConRight
{
my $self = shift;
my $params = shift;
Debug( "Move Right" );
my $cmd = "decoder_control.cgi?command=6&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Diagonally Up Right Arrow
sub moveConUpRight
{
my $self = shift;
my $params = shift;
Debug( "Move Diagonally Up Right" );
my $cmd = "decoder_control.cgi?command=91&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Diagonally Down Right Arrow
sub moveConDownRight
{
my $self = shift;
my $params = shift;
Debug( "Move Diagonally Down Right" );
my $cmd = "decoder_control.cgi?command=93&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Diagonally Up Left Arrow
sub moveConUpLeft
{
my $self = shift;
my $params = shift;
Debug( "Move Diagonally Up Left" );
my $cmd = "decoder_control.cgi?command=90&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Diagonally Down Left Arrow
sub moveConDownLeft
{
my $self = shift;
my $params = shift;
Debug( "Move Diagonally Down Left" );
my $cmd = "decoder_control.cgi?command=92&onestep=1&";
$self->sendCmd( $cmd );
my $autostop = $self->getParam( $params, 'autostop', 0 );
if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
{
usleep( $self->{Monitor}->{AutoStopTimeout} );
$self->moveStop( $params );
}
}
#Stop
sub moveStop
{
my $self = shift;
Debug( "Move Stop" );
my $cmd = "decoder_control.cgi?command=1&onestep=1&";
$self->sendCmd( $cmd );
}
#Move Camera to Home Position
sub presetHome
{
my $self = shift;
Debug( "Home Preset" );
my $cmd = "decoder_control.cgi?command=25&onestep=0&";
$self->sendCmd( $cmd );
}
# zoom out
sub zoomRelTele
{
my $self = shift;
Debug( "Zoom Tele" );
my $cmd = "camera_control.cgi?param=17&value=1&";
$self->sendCmd( $cmd );
}
#zoom in
sub zoomRelWide
{
my $self = shift;
Debug( "Zoom Wide" );
my $cmd = "camera_control.cgi?param=18&value=1&";
$self->sendCmd( $cmd );
}
#Set preset
sub presetSet
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $presetCmd = 30 + (($preset-1)*2);
Debug( "Set Preset $preset with cmd $presetCmd" );
my $cmd = "decoder_control.cgi?command=$presetCmd&onestep=0&sit=$presetCmd&";
$self->sendCmd( $cmd );
}
#Goto preset
sub presetGoto
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $presetCmd = 31 + (($preset-1)*2);
Debug( "Goto Preset $preset with cmd $presetCmd" );
my $cmd = "decoder_control.cgi?command=$presetCmd&onestep=0&sit=$presetCmd&";
$self->sendCmd( $cmd );
}
#Turn IR on
sub wake
{
my $self = shift;
Debug( "Wake - IR on" );
my $cmd = "camera_control.cgi?param=14&value=1&";
$self->sendCmd( $cmd );
}
#Turn IR off
sub sleep
{
my $self = shift;
Debug( "Sleep - IR off" );
my $cmd = "camera_control.cgi?param=14&value=0&";
$self->sendCmd( $cmd );
}
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
=head1 NAME
ZoneMinder::Database - Perl extension for blah blah blah
=head1 SYNOPSIS
use ZoneMinder::Control::Wanscam
blah blah blah
=head1 DESCRIPTION
Stub documentation for ZoneMinder, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.
Blah blah blah.
=head2 EXPORT
None by default.
=head1 SEE ALSO
Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.
If you have a mailing list set up for your module, mention it here.
If you have a web site set up for your module, mention it here.
=head1 AUTHOR
Philip Coombes, <philip.coombes@zoneminder.com>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2001-2008 Philip Coombes
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.
=cut

View File

@@ -98,29 +98,28 @@ sub getEventPath
{
my $event = shift;
my $Storage = $event->Storage();
my $event_path = "";
if ( $Config{ZM_USE_DEEP_STORAGE} )
{
$event_path = $Config{ZM_DIR_EVENTS}
.'/'.$event->{MonitorId}
.'/'.strftime( "%y/%m/%d/%H/%M/%S",
$event_path = join('/',
$Storage->Path(),
$event->{MonitorId},
strftime( "%y/%m/%d/%H/%M/%S",
localtime($event->{Time})
)
;
),
);
}
else
{
$event_path = $Config{ZM_DIR_EVENTS}
.'/'.$event->{MonitorId}
.'/'.$event->{Id}
;
$event_path = join('/',
$Storage->Path(),
$event->{MonitorId},
$event->{Id},
);
}
if ( index($Config{ZM_DIR_EVENTS},'/') != 0 ){
$event_path = $Config{ZM_PATH_WEB}
.'/'.$event_path
;
}
return( $event_path );
}

View File

@@ -127,6 +127,7 @@ sub Execute {
while( my $event = $sth->fetchrow_hashref() ) {
push @results, $event;
}
Debug($sql . ' returned ' . @results . ' events.' );
$sth->finish();
Debug("Loaded " . @results . " events for filter $_[0]{Name} using query ($sql)");
return @results;
@@ -360,7 +361,6 @@ sub Sql {
{
$sql .= " limit 0,".$filter_expr->{limit};
}
Debug( "SQL:$sql\n" );
$self->{Sql} = $sql;
} # end if has Sql
return $self->{Sql};

View File

@@ -212,6 +212,10 @@ MAIN: while( $loop ) {
my $count = 0;
foreach my $event_link ( @event_links )
{
if ( $event_link =~ /[^\d\.]/ ) {
Warning("Non-event link found $event_link in $day_dir, skipping");
next;
}
Debug( "Checking link $event_link" );
( my $event = $event_link ) =~ s/^.*\.//;
my $event_path = readlink( $event_link );

View File

@@ -419,9 +419,9 @@ sub toPreset
foreach (@data) {
s/\b(?:\d{1,3}\.){3}\d{1,3}\b/<ip-address>/; # ip address
s/<ip-address>:(6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)$/<ip-address>:<port>/; # tcpip port
s/\/\/.*:.*@/\/\/<username>:<pwd>@/; # user & pwd preceeding an ip address
s/(&|\?)(user|username)=\w\w*(&|\?)/$1$2=<username>$3/i; # username embeded in url
s/(&|\?)(pwd|password)=\w\w*(&|\?)/$1$2=<pwd>$3/i; # password embeded in url
s/\/\/.*:.*@/\/\/<username>:<pwd>@/; # user & pwd preceding an ip address
s/(&|\?)(user|username)=\w\w*(&|\?)/$1$2=<username>$3/i; # username embedded in url
s/(&|\?)(pwd|password)=\w\w*(&|\?)/$1$2=<pwd>$3/i; # password embedded in url
s/\w\w*:\w\w*/<username>:<pwd>/; # user & pwd in their own field
s/\/dev\/video\d\d*/\/dev\/video<?>/; # local video devices
}

View File

@@ -27,7 +27,7 @@ zmfilter.pl - ZoneMinder tool to filter events
=head1 SYNOPSIS
zmfilter.pl [-f <filter name>,--filter=<filter name>] | -v, --version
zmfilter.pl [-f <filter name>,--filter=<filter name>] [--filter_id=<filter id>] | -v, --version
=head1 DESCRIPTION
@@ -37,7 +37,9 @@ matching events.
=head1 OPTIONS
-f{filter name}, --filter={filter name} - The name of a specific filter to run
--filter_id={filter id} - The id of a specific filter to run
-v, --version - Print ZoneMinder version
=cut
@@ -60,8 +62,6 @@ use constant START_DELAY => 5; # How long to wait before starting
@EXTRA_PERL_LIB@
use ZoneMinder;
require ZoneMinder::Event;
require ZoneMinder::Filter;
use DBI;
use POSIX;
use Time::HiRes qw/gettimeofday/;
@@ -70,6 +70,24 @@ use Getopt::Long;
use autouse 'Pod::Usage'=>qw(pod2usage);
use autouse 'Data::Dumper'=>qw(Dumper);
my $filter_name = "";
my $filter_id;
my $version = 0;
GetOptions(
'filter=s' =>\$filter_name,
'filter_id=s' =>\$filter_id,
'version' =>\$version
) or pod2usage(-exitstatus => -1);
if ( $version ) {
print ZoneMinder::Base::ZM_VERSION . "\n";
exit(0);
}
require ZoneMinder::Event;
require ZoneMinder::Filter;
use constant EVENT_PATH => ($Config{ZM_DIR_EVENTS}=~m|/|)
? $Config{ZM_DIR_EVENTS}
: ($Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS})
@@ -135,20 +153,6 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
my $delay = $Config{ZM_FILTER_EXECUTE_INTERVAL};
my $event_id = 0;
my $filter_parm = "";
my $version = 0;
#
GetOptions(
'filter=s' =>\$filter_parm,
'version' =>\$version
) or pod2usage(-exitstatus => -1);
if ( $version ) {
print ZoneMinder::Base::ZM_VERSION . "\n";
exit(0);
}
if ( ! EVENT_PATH ) {
Error( "No event path defined. Config was $Config{ZM_DIR_EVENTS}\n" );
@@ -159,39 +163,42 @@ chdir( EVENT_PATH );
my $dbh = zmDbConnect();
if ( $filter_parm )
{
Info( "Scanning for events using filter '$filter_parm'\n" );
}
else
{
if ( $filter_name ) {
Info( "Scanning for events using filter '$filter_name'\n" );
} elsif ( $filter_id ) {
Info( "Scanning for events using filter id '$filter_id'\n" );
} else {
Info( "Scanning for events\n" );
}
if ( !$filter_parm )
{
if ( ! ( $filter_name or $filter_id ) ) {
sleep( START_DELAY );
}
my $filters;
my $last_action = 0;
while( 1 )
{
while( 1 ) {
my $now = time;
if ( ($now - $last_action) > $Config{ZM_FILTER_RELOAD_DELAY} )
{
if ( ($now - $last_action) > $Config{ZM_FILTER_RELOAD_DELAY} ) {
Debug( "Reloading filters\n" );
$last_action = $now;
$filters = getFilters( $filter_parm );
$filters = getFilters( { Name=>$filter_name, Id=>$filter_id } );
}
foreach my $filter ( @$filters )
{
checkFilter( $filter );
foreach my $filter ( @$filters ) {
if ( $$filter{Concurrent} and ! ( $filter_id or $filter_name ) ) {
my ( $proc ) = $0 =~ /(\S+)/;
my ( $id ) = $$filter{Id} =~ /(\d+)/;
Debug("Running concurrent filter process $proc --filter_id $$filter{Id} => $id for $$filter{Name}");
system( qq`$proc --filter "$$filter{Name}" &` );
} else {
checkFilter( $filter );
}
}
last if ( $filter_parm );
last if ( $filter_name or $filter_id );
Debug( "Sleeping for $delay seconds\n" );
sleep( $delay );
@@ -199,16 +206,18 @@ while( 1 )
sub getFilters
{
my $filter_name = shift;
my $sql_filters = @_ ? shift : {};
my @sql_values;
my @filters;
my $sql = "SELECT * FROM Filters WHERE";
if ( $filter_name )
{
if ( $$sql_filters{Name} ) {
$sql .= " Name = ? and";
}
else
{
push @sql_values, $$sql_filters{Name};
} elsif ( $$sql_filters{Id} ) {
$sql .= " Id = ? and";
push @sql_values, $$sql_filters{Id};
} else {
$sql .= " Background = 1 and";
}
$sql .= "( AutoArchive = 1
@@ -221,17 +230,8 @@ sub getFilters
) ORDER BY Name";
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res;
if ( $filter_name )
{
$res = $sth->execute( $filter_name )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
}
else
{
$res = $sth->execute()
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
}
my $res = $sth->execute( @sql_values )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
FILTER: while( my $db_filter = $sth->fetchrow_hashref() )
{
my $filter = new ZoneMinder::Filter( $$db_filter{Id}, $db_filter );
@@ -245,7 +245,12 @@ sub getFilters
push( @filters, $filter );
}
$sth->finish();
Debug( "Got " . @filters . " filters" );
if ( ! @filters ) {
Error("No filter found for $sql with values(@sql_values)");
} else {
Debug( "Got " . @filters . " filters" );
}
return( \@filters );
}
@@ -530,7 +535,8 @@ sub uploadArchFile
if $Config{ZM_UPLOAD_PORT};
$sftpOptions{timeout} = $Config{ZM_UPLOAD_TIMEOUT}
if $Config{ZM_UPLOAD_TIMEOUT};
$sftpOptions{more} = [ '-o'=>'StrictHostKeyChecking=no' ];
$sftpOptions{more} = [ '-o'=>'StrictHostKeyChecking=no' ]
if ! $Config{ZM_UPLOAD_STRICT};
$Net::SFTP::Foreign::debug = -1
if $Config{ZM_UPLOAD_DEBUG};
my $sftp = Net::SFTP::Foreign->new( $Config{ZM_UPLOAD_HOST}, %sftpOptions );

View File

@@ -504,22 +504,11 @@ sub handleMessage
Info( "Set monitor to $state\n" );
if ( $delay )
{
my $action_time = time()+$delay;
my $action_text = $id."|".( ($state eq "enable")
? "disable"
: "enable"
)
;
my $action_array = $actions{$action_time};
if ( !$action_array )
{
$action_array = $actions{$action_time} = [];
}
push( @$action_array, { connection=>$connection,
message=>$action_text
}
);
Debug( "Added timed event '$action_text', expires at $action_time (+$delay secs)\n" );
);
handleDelay($delay, $connection, $action_text);
}
}
elsif ( $action =~ /^(on|off)(?:[ \+](\d+))?$/ )
@@ -534,43 +523,33 @@ sub handleMessage
zmTriggerEventOn( $monitor, $score, $cause, $text );
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
Info( "Trigger '$trigger' '$cause'\n" );
if ( $delay )
{
my $action_text = $id."|cancel";
handleDelay($delay, $connection, $action_text);
}
}
elsif ( $trigger eq "off" )
{
my $last_event = zmGetLastEvent( $monitor );
zmTriggerEventOff( $monitor );
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
Info( "Trigger '$trigger'\n" );
# Wait til it's finished
while( zmInAlarm( $monitor )
&& ($last_event == zmGetLastEvent( $monitor ))
)
if ( $delay )
{
# Tenth of a second
usleep( 100000 );
}
my $action_text = $id."|off|0|".$cause."|".$text;
handleDelay($delay, $connection, $action_text);
} else {
my $last_event = zmGetLastEvent( $monitor );
zmTriggerEventOff( $monitor );
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
Info( "Trigger '$trigger'\n" );
# Wait til it's finished
while( zmInAlarm( $monitor )
&& ($last_event == zmGetLastEvent( $monitor ))
)
{
# Tenth of a second
usleep( 100000 );
}
zmTriggerEventCancel( $monitor );
}
else
{
Info( "Trigger '$trigger'\n" );
zmTriggerEventCancel( $monitor );
}
if ( $delay )
{
my $action_time = time()+$delay;
#my $action_text = $id."|cancel|0|".$cause."|".$text;
my $action_text = $id."|cancel";
my $action_array = $actions{$action_time};
if ( !$action_array )
{
$action_array = $actions{$action_time} = [];
}
push( @$action_array, { connection=>$connection,
message=>$action_text
}
);
Debug( "Added timed event '$action_text', expires at $action_time (+$delay secs)\n" );
}
}
elsif( $action eq "cancel" )
@@ -590,5 +569,23 @@ sub handleMessage
}
} # end sub handleMessage
sub handleDelay
{
my $delay = shift;
my $connection = shift;
my $action_text = shift;
my $action_time = time()+$delay;
my $action_array = $actions{$action_time};
if ( !$action_array )
{
$action_array = $actions{$action_time} = [];
}
push( @$action_array, { connection=>$connection,
message=>$action_text
}
);
Debug( "Added timed event '$action_text', expires at $action_time (+$delay secs)\n" );
}
1;
__END__

View File

@@ -23,7 +23,7 @@
=head1 NAME
zmupdate.pl - check and upgrade Zoneminer database
zmupdate.pl - check and upgrade ZoneMinder database
=head1 SYNOPSIS