From 5d96a8d14ecea48dc212f781532957f742c693cb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 13 Jul 2017 09:38:42 -0400 Subject: [PATCH 1/5] make code more robust by handling an undefined get_VideoEncoderConfiguration() --- onvif/scripts/zmonvif-probe.pl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/onvif/scripts/zmonvif-probe.pl b/onvif/scripts/zmonvif-probe.pl index c66403e56..7d4eaa25b 100755 --- a/onvif/scripts/zmonvif-probe.pl +++ b/onvif/scripts/zmonvif-probe.pl @@ -253,13 +253,16 @@ sub profiles foreach my $profile ( @{ $profiles } ) { my $token = $profile->attr()->get_token() ; - print $token . ", " . - $profile->get_Name() . ", " . - $profile->get_VideoEncoderConfiguration()->get_Encoding() . ", " . - $profile->get_VideoEncoderConfiguration()->get_Resolution()->get_Width() . ", " . - $profile->get_VideoEncoderConfiguration()->get_Resolution()->get_Height() . ", " . - $profile->get_VideoEncoderConfiguration()->get_RateControl()->get_FrameRateLimit() . - ", "; + my $VideoEncoderConfiguration = $profile->get_VideoEncoderConfiguration(); + print join(', ', $token, + $profile->get_Name(), + ( $VideoEncoderConfiguration ? ( + $VideoEncoderConfiguration->get_Encoding(), + $VideoEncoderConfiguration->get_Resolution()->get_Width(), + $VideoEncoderConfiguration->get_Resolution()->get_Height(), + $VideoEncoderConfiguration->get_RateControl()->get_FrameRateLimit(), + ) : () ) + ); # Specification gives conflicting values for unicast stream types, try both. # http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl#op.GetStreamUri From 9d1d2c1ce46f6833b176cc0f022b6bff8826809d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 13 Jul 2017 10:27:53 -0400 Subject: [PATCH 2/5] print the line out all at once, fixing the missing comma after fps. --- onvif/scripts/zmonvif-probe.pl | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/onvif/scripts/zmonvif-probe.pl b/onvif/scripts/zmonvif-probe.pl index 7d4eaa25b..de6c18aa3 100755 --- a/onvif/scripts/zmonvif-probe.pl +++ b/onvif/scripts/zmonvif-probe.pl @@ -250,19 +250,9 @@ sub profiles my $profiles = $result->get_Profiles(); - foreach my $profile ( @{ $profiles } ) { + foreach my $profile ( @{ $profiles } ) { my $token = $profile->attr()->get_token() ; - my $VideoEncoderConfiguration = $profile->get_VideoEncoderConfiguration(); - print join(', ', $token, - $profile->get_Name(), - ( $VideoEncoderConfiguration ? ( - $VideoEncoderConfiguration->get_Encoding(), - $VideoEncoderConfiguration->get_Resolution()->get_Width(), - $VideoEncoderConfiguration->get_Resolution()->get_Height(), - $VideoEncoderConfiguration->get_RateControl()->get_FrameRateLimit(), - ) : () ) - ); # Specification gives conflicting values for unicast stream types, try both. # http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl#op.GetStreamUri @@ -281,9 +271,18 @@ sub profiles die $result if not $result; # print $result . "\n"; - print $result->get_MediaUri()->get_Uri() . - "\n"; - } + my $VideoEncoderConfiguration = $profile->get_VideoEncoderConfiguration(); + print join(', ', $token, + $profile->get_Name(), + ( $VideoEncoderConfiguration ? ( + $VideoEncoderConfiguration->get_Encoding(), + $VideoEncoderConfiguration->get_Resolution()->get_Width(), + $VideoEncoderConfiguration->get_Resolution()->get_Height(), + $VideoEncoderConfiguration->get_RateControl()->get_FrameRateLimit(), + ) : () ), + $result->get_MediaUri()->get_Uri() , + ). "\n"; + } # end foreach profile # # use message parser without schema validation ??? From 3789dcb5de5e31ebe488a771fd012c0d2088391c Mon Sep 17 00:00:00 2001 From: Martin Goodwell Date: Thu, 13 Jul 2017 17:10:20 +0200 Subject: [PATCH 3/5] Introducing Maginon Supra IPC camera Controls and script (#1947) * Added Maginon Supra IPC to Controls * Adding support for Maginon Supra IPC camera --- db/zm_create.sql.in | 1 + .../lib/ZoneMinder/Control/MaginonIPC.pm | 333 ++++++++++++++++++ 2 files changed, 334 insertions(+) create mode 100644 scripts/ZoneMinder/lib/ZoneMinder/Control/MaginonIPC.pm diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index f12bf0ffe..62424c286 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -602,6 +602,7 @@ INSERT INTO `Controls` VALUES (NULL,'Vivotek ePTZ','Remote','Vivotek_ePTZ',0,0,1 INSERT INTO `Controls` VALUES (NULL,'Netcat ONVIF','Ffmpeg','Netcat',0,0,1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,100,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,100,5,5,0,0,0,1,255,1,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0); INSERT INTO `Controls` VALUES (NULL,'Keekoon','Remote','Keekoon', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); INSERT INTO `Controls` VALUES (NULL,'HikVision','Local','',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20,1,1,1,1,0,0,0,1,1,0,0,0,0,1,1,100,0,0,1,0,0,0,0,1,1,100,1,0,0,0); +INSERT INTO `Controls` VALUES (NULL,'Maginon Supra IPC','cURL','MaginonIPC',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,0,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0); -- -- Add some monitor preset values diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/MaginonIPC.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/MaginonIPC.pm new file mode 100644 index 000000000..35159fc4e --- /dev/null +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/MaginonIPC.pm @@ -0,0 +1,333 @@ +# ========================================================================== +# +# ZoneMinder Maginon Supra IPC Camera Control Protocol Module, +# Copyright (C) 2017 Martin Gutenbrunner (martin.gutenbrunner@SPAMsonic.net) +# +# 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 Maginon Supra IPC camera +# procotol version. +# +package ZoneMinder::Control::MaginonIPC; + +use 5.006; +use strict; +use warnings; + +require ZoneMinder::Base; +require ZoneMinder::Control; + +our @ISA = qw(ZoneMinder::Control); + +# ========================================================================== +# +# Maginon Supra IPC IP Camera 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" ); + + my $url = "http://".$self->{Monitor}->{ControlAddress}."$cmd"; +# Info($url); + my $req = HTTP::Request->new( GET=>$url ); + my $res = $self->{ua}->request($req); + return( !undef ); +} + +sub moveStop +{ + Debug("moveStop"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=1"; + $self->sendCmd( $cmd ); +} + +sub moveConUp +{ + Debug("moveConUp"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=0"; + $self->sendCmd( $cmd ); + my $autostop = $self->getParam( $params, 'autostop', 0 ); + if ( $autostop && $self->{Monitor}->{AutoStopTimeout} ) + { + usleep( $self->{Monitor}->{AutoStopTimeout} ); + $self->moveStop( $params ); + } +} + +sub moveConDown +{ + Debug("moveConDown"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=2"; + $self->sendCmd( $cmd ); + my $autostop = $self->getParam( $params, 'autostop', 0 ); + if ( $autostop && $self->{Monitor}->{AutoStopTimeout} ) + { + usleep( $self->{Monitor}->{AutoStopTimeout} ); + $self->moveStop( $params ); + } +} + +sub moveConLeft +{ + Debug("moveConLeft"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=4"; + $self->sendCmd( $cmd ); + my $autostop = $self->getParam( $params, 'autostop', 0 ); + if ( $autostop && $self->{Monitor}->{AutoStopTimeout} ) + { + usleep( $self->{Monitor}->{AutoStopTimeout} ); + $self->moveStop( $params ); + } +} + +sub moveConRight +{ + Debug("moveConRight"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=6"; + $self->sendCmd( $cmd ); + my $autostop = $self->getParam( $params, 'autostop', 0 ); + if ( $autostop && $self->{Monitor}->{AutoStopTimeout} ) + { + usleep( $self->{Monitor}->{AutoStopTimeout} ); + $self->moveStop( $params ); + } +} + +sub moveConUpRight +{ + Debug("moveConUpRight"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=91"; + $self->sendCmd( $cmd ); + my $autostop = $self->getParam( $params, 'autostop', 0 ); + if ( $autostop && $self->{Monitor}->{AutoStopTimeout} ) + { + usleep( $self->{Monitor}->{AutoStopTimeout} ); + $self->moveStop( $params ); + } +} + +sub moveConUpLeft +{ + Debug("moveConUpLeft"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=90"; + $self->sendCmd( $cmd ); + my $autostop = $self->getParam( $params, 'autostop', 0 ); + if ( $autostop && $self->{Monitor}->{AutoStopTimeout} ) + { + usleep( $self->{Monitor}->{AutoStopTimeout} ); + $self->moveStop( $params ); + } +} + +sub moveConDownRight +{ + Debug("moveConDownRight"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=93"; + $self->sendCmd( $cmd ); + my $autostop = $self->getParam( $params, 'autostop', 0 ); + if ( $autostop && $self->{Monitor}->{AutoStopTimeout} ) + { + usleep( $self->{Monitor}->{AutoStopTimeout} ); + $self->moveStop( $params ); + } +} + +sub moveConDownLeft +{ + Debug("moveConDownLeft"); + my $self = shift; + my $params = shift; + my $cmd = "/decoder_control.cgi?command=92"; + $self->sendCmd( $cmd ); + my $autostop = $self->getParam( $params, 'autostop', 0 ); + if ( $autostop && $self->{Monitor}->{AutoStopTimeout} ) + { + usleep( $self->{Monitor}->{AutoStopTimeout} ); + $self->moveStop( $params ); + } +} + +sub presetSet +{ + my $self = shift; + my $params = shift; + my $preset = $self->getParam( $params, 'preset' ); + Info( "Set Preset $preset" ); + + my $cmdNum; + if ($preset == 1) { + $cmdNum = 30; + } elsif ($preset == 2) { + $cmdNum = 32; + } elsif ($preset == 3) { + $cmdNum = 34; + } elsif ($preset == 4) { + $cmdNum = 36; + } else { + $cmdNum = 36; + } + + my $cmd = "/decoder_control.cgi?command=$cmdNum"; + $self->sendCmd( $cmd ); +} + +sub presetGoto +{ + my $self = shift; + my $params = shift; + my $preset = $self->getParam( $params, 'preset' ); + Info( "Goto Preset $preset" ); + + my $cmdNum; + if ($preset == 1) { + $cmdNum = 31; + } elsif ($preset == 2) { + $cmdNum = 33; + } elsif ($preset == 3) { + $cmdNum = 35; + } elsif ($preset == 4) { + $cmdNum = 37; + } else { + $cmdNum = 37; + } + + my $cmd = "/decoder_control.cgi?command=$cmdNum"; + $self->sendCmd( $cmd ); +} + +1; +__END__ +# Below is stub documentation for your module. You'd better edit it! + +=head1 NAME + +ZoneMinder::Control::MaginonIPC - Zoneminder PTZ control module for the Maginon Supra-IPC 40 IP Camera + +=head1 SYNOPSIS + + use ZoneMinder::Control::MaginonIPC; + blah blah blah + +=head1 DESCRIPTION + + This is for Zoneminder PTZ control module for the Maginon Supra-IPC 40 camera. It probably also works with other models. + +=head2 EXPORT + +None by default. + + + +=head1 SEE ALSO + +www.zoneminder.com + +=head1 AUTHOR + +Martin Gutenbrunner, Emartin.gutenbrunner@gmx.atE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2017 by Martin Gutenbrunner + +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 From c294e25dbc327834e93f5efb26cdf719f194fa20 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Fri, 14 Jul 2017 07:23:35 -0500 Subject: [PATCH 4/5] rpm packaging - migrate cakephp htaccess parms into main apache config --- distros/redhat/systemd/zoneminder.conf.in | 29 ++++++++++- distros/redhat/sysvinit/zoneminder.conf.in | 59 +++++++++++++++++++--- 2 files changed, 78 insertions(+), 10 deletions(-) diff --git a/distros/redhat/systemd/zoneminder.conf.in b/distros/redhat/systemd/zoneminder.conf.in index 005c959a6..0e546f9df 100644 --- a/distros/redhat/systemd/zoneminder.conf.in +++ b/distros/redhat/systemd/zoneminder.conf.in @@ -16,7 +16,7 @@ Alias /zm "@ZM_WEBDIR@" DirectoryIndex index.php SSLRequireSSL Options -Indexes +MultiViews +FollowSymLinks - AllowOverride All + AllowOverride None # Apache 2.4 Require all granted @@ -31,7 +31,7 @@ Alias /zm "@ZM_WEBDIR@" ScriptAlias /cgi-bin-zm "@ZM_CGIDIR@" SSLRequireSSL - AllowOverride All + AllowOverride None Options +ExecCGI +FollowSymLinks # Apache 2.4 @@ -44,3 +44,28 @@ ScriptAlias /cgi-bin-zm "@ZM_CGIDIR@" +# For better visibility, the following directives have been migrated from the +# default .htaccess files included with the CakePHP project. +# Parameters not set here are inherited from the parent directive above. + + RewriteEngine on + RewriteRule ^$ app/webroot/ [L] + RewriteRule (.*) app/webroot/$1 [L] + RewriteBase /zm/api + + + + RewriteEngine on + RewriteRule ^$ webroot/ [L] + RewriteRule (.*) webroot/$1 [L] + RewriteBase /zm/api + + + + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + RewriteBase /zm/api + + diff --git a/distros/redhat/sysvinit/zoneminder.conf.in b/distros/redhat/sysvinit/zoneminder.conf.in index 413910214..0e546f9df 100644 --- a/distros/redhat/sysvinit/zoneminder.conf.in +++ b/distros/redhat/sysvinit/zoneminder.conf.in @@ -11,18 +11,61 @@ RewriteRule ^/?(zm)(.*) https://%{SERVER_NAME}/$1$2 [R,L] Alias /zm "@ZM_WEBDIR@" + # explicitly set index.php as the only directoryindex + DirectoryIndex disabled + DirectoryIndex index.php SSLRequireSSL - Options -Indexes MultiViews FollowSymLinks - AllowOverride All - Order allow,deny - Allow from all + Options -Indexes +MultiViews +FollowSymLinks + AllowOverride None + + # Apache 2.4 + Require all granted + + + # Apache 2.2 + Order deny,allow + Allow from all + ScriptAlias /cgi-bin-zm "@ZM_CGIDIR@" SSLRequireSSL - AllowOverride All - Options ExecCGI FollowSymLinks - Order allow,deny - Allow from all + AllowOverride None + Options +ExecCGI +FollowSymLinks + + # Apache 2.4 + Require all granted + + + # Apache 2.2 + Order deny,allow + Allow from all + + +# For better visibility, the following directives have been migrated from the +# default .htaccess files included with the CakePHP project. +# Parameters not set here are inherited from the parent directive above. + + RewriteEngine on + RewriteRule ^$ app/webroot/ [L] + RewriteRule (.*) app/webroot/$1 [L] + RewriteBase /zm/api + + + + RewriteEngine on + RewriteRule ^$ webroot/ [L] + RewriteRule (.*) webroot/$1 [L] + RewriteBase /zm/api + + + + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + RewriteBase /zm/api + + From 99bb12dcc92395ae4f128e1fd448066b0deef963 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Fri, 14 Jul 2017 08:33:08 -0500 Subject: [PATCH 5/5] Update zoneminder.spec changes from rpmfusion feedback --- distros/redhat/zoneminder.spec | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/distros/redhat/zoneminder.spec b/distros/redhat/zoneminder.spec index b36547c5d..f60ae222a 100644 --- a/distros/redhat/zoneminder.spec +++ b/distros/redhat/zoneminder.spec @@ -109,6 +109,7 @@ Requires: perl(MIME::Lite) Requires: perl(Net::SMTP) Requires: perl(Net::FTP) Requires: perl(LWP::Protocol::https) +Requires: ca-certificates %{?with_init_systemd:Requires(post): systemd} %{?with_init_systemd:Requires(post): systemd-sysv} @@ -162,7 +163,14 @@ too much degradation of performance. %make_install # Remove unwanted files and folders -find %{buildroot} \( -name .packlist -or -name .git -or -name .gitignore -or -name .gitattributes -or -name .travis.yml \) -type f -delete > /dev/null 2>&1 || : +find %{buildroot} \( -name .htaccess -or -name .editorconfig -or -name .packlist -or -name .git -or -name .gitignore -or -name .gitattributes -or -name .travis.yml \) -type f -delete > /dev/null 2>&1 || : + +# Recursively change shebang in all relevant scripts and set execute permission +find %{buildroot}%{_datadir}/zoneminder/www/api \( -name cake -or -name cake.php \) -type f -exec sed -i 's\^#!/usr/bin/env bash$\#!/usr/bin/bash\' {} \; -exec %{__chmod} 755 {} \; + +# Use the system cacert file rather then the one bundled with CakePHP +%{__rm} -f %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem +%{__ln_s} ../../../../../../../..%{_sysconfdir}/pki/tls/certs/ca-bundle.crt %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem %post %if 0%{?with_init_sysv}