diff --git a/CMakeLists.txt b/CMakeLists.txt index d39c97d4c..df55d288d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -483,24 +483,24 @@ if(MP4V2_LIBRARIES) if(MP4V2_INCLUDE_DIR) include_directories("${MP4V2_INCLUDE_DIR}") set(CMAKE_REQUIRED_INCLUDES "${MP4V2_INCLUDE_DIR}") + check_include_file("mp4v2/mp4v2.h" HAVE_MP4V2_MP4V2_H) endif(MP4V2_INCLUDE_DIR) - check_include_file("mp4v2/mp4v2.h" HAVE_MP4V2_MP4V2_H) # mp4v2.h find_path(MP4V2_INCLUDE_DIR mp4v2.h) if(MP4V2_INCLUDE_DIR) include_directories("${MP4V2_INCLUDE_DIR}") set(CMAKE_REQUIRED_INCLUDES "${MP4V2_INCLUDE_DIR}") + check_include_file("mp4v2.h" HAVE_MP4V2_H) endif(MP4V2_INCLUDE_DIR) - check_include_file("mp4v2.h" HAVE_MP4V2_H) # mp4.h find_path(MP4V2_INCLUDE_DIR mp4.h) if(MP4V2_INCLUDE_DIR) include_directories("${MP4V2_INCLUDE_DIR}") set(CMAKE_REQUIRED_INCLUDES "${MP4V2_INCLUDE_DIR}") + check_include_file("mp4.h" HAVE_MP4_H) endif(MP4V2_INCLUDE_DIR) - check_include_file("mp4.h" HAVE_MP4_H) mark_as_advanced(FORCE MP4V2_LIBRARIES MP4V2_INCLUDE_DIR) set(optlibsfound "${optlibsfound} mp4v2") diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 8e46f8b4a..9ff82ce52 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -771,6 +771,7 @@ INSERT INTO `Controls` VALUES (NULL,'Floureon 1080P','Ffmpeg','Floureon',0,0,0,1 INSERT INTO `Controls` VALUES (NULL,'Reolink RLC-423','Ffmpeg','Reolink',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,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,64,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,'Reolink RLC-411','Ffmpeg','Reolink',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,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,0,0,0,0,0); INSERT INTO `Controls` VALUES (NULL,'Reolink RLC-420','Ffmpeg','Reolink',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,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); +INSERT INTO `Controls` VALUES (NULL,'D-LINK DCS-3415','Remote','DCS3415',0,0,0,1,0,0,0,0,0,0,0,0,0,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,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/distros/ubuntu1604/README.Debian b/distros/ubuntu1604/README.Debian index 8182e0678..4fe3464d2 100644 --- a/distros/ubuntu1604/README.Debian +++ b/distros/ubuntu1604/README.Debian @@ -23,8 +23,7 @@ configuration file: Upgrading database ------------------ -Prior to 1.28.1 database upgrade was performed automatically. -"zoneminder" service will refuse to start with outdated database. +The database is updated automatically on installation. You should not need to take this step. Assuming that database is on "localhost" then the following command can be used to upgrade "zm" database: @@ -45,17 +44,11 @@ The following command prints the current version of zoneminder database: Enabling service ---------------- -By default Zoneminder service is not starting automatically and need to be -manually activated once database is configured: - -On systemd: +By default Zoneminder service is not automatically started and needs to be +manually enabled once database is configured: sudo systemctl enable zoneminder.service -On SysV: - - sudo update-rc.d zoneminder enable - Web server set-up ----------------- @@ -82,10 +75,10 @@ Common configuration steps for Apache2: ## nginx / fcgiwrap -Nginx needs "php5-fpm" package to support PHP and "fcgiwrap" package +Nginx needs "php-fpm" package to support PHP and "fcgiwrap" package for binary "cgi-bin" applications: - sudo apt-get install php5-fpm fcgiwrap + sudo apt-get install php-fpm fcgiwrap To enable a URL alias that makes Zoneminder available from @@ -119,32 +112,9 @@ site configuration. Changing the location for images and events ------------------------------------------- -Zoneminder, in its upstream form, stores data in /usr/share/zoneminder/. This -package modifies that by changing /usr/share/zoneminder/images and -/usr/share/zoneminder/events to symlinks to directories under -/var/cache/zoneminder. - -There are numerous places these could be put and ways to do it. But, at the -moment, if you change this, an upgrade will fail with a warning about these -locations having changed (the reason for this was that previously, an upgrade -would silently revert the changes and cause event loss - refer -bug #608793). - -If you do want to change the location, here are a couple of suggestions. -(thanks to vagrant@freegeek.org): - -These lines in fstab could allow you to bind-mount an alternate location - - /dev/sdX1 /otherdrive ext3 defaults 0 2 - /otherdrive/zoneminder/images /var/cache/zoneminder/images bind defaults 0 2 - /otherdrive/zoneminder/events /var/cache/zoneminder/events bind defaults 0 2 - - or if you have a separate partition for each: - - /dev/sdX1 /var/cache/zoneminder/images ext3 defaults 0 2 - /dev/sdX2 /var/cache/zoneminder/events ext3 defaults 0 2 - - -- Peter Howard , Sun, 16 Jan 2010 01:35:51 +1100 +ZoneMinder is now able to be configured to use an alternative location for storing +events and images at compile time. This package makes use of that, so symlinks in +/usr/share/zoneminder/www are no longer necessary. Access to /dev/video* --------------------- diff --git a/distros/ubuntu1604/control b/distros/ubuntu1604/control index e31014a46..884f3a2d9 100644 --- a/distros/ubuntu1604/control +++ b/distros/ubuntu1604/control @@ -16,7 +16,7 @@ Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apa ,libcurl4-gnutls-dev ,libgnutls-openssl-dev ,libjpeg8-dev | libjpeg9-dev | libjpeg62-turbo-dev - ,default-libmysqlclient-dev | libmysqlclient-dev | libmariadbclient-dev + ,default-libmysqlclient-dev | libmysqlclient-dev | libmariadbclient-dev-compat ,libpcre3-dev ,libpolkit-gobject-1-dev ,libv4l-dev (>= 0.8.3) [!hurd-any] @@ -39,7 +39,7 @@ Package: zoneminder Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends} ,javascript-common - ,libmp4v2-2, libx264-142|libx264-148, libswscale-ffmpeg3|libswscale4|libswscale3 + ,libmp4v2-2, libx264-142|libx264-148|libx264-152, libswscale-ffmpeg3|libswscale4|libswscale3 ,ffmpeg | libav-tools ,libdate-manip-perl, libmime-lite-perl, libmime-tools-perl ,libdbd-mysql-perl @@ -61,7 +61,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends} ,libdigest-sha-perl ,libsys-cpu-perl, libsys-cpuload-perl, libsys-meminfo-perl ,libdata-uuid-perl - ,mysql-client | virtual-mysql-client + ,mysql-client | mariadb-client | virtual-mysql-client ,perl-modules ,php5-mysql | php-mysql, php5-gd | php-gd , php5-apcu | php-apcu , php-apc | php-apcu-bc ,policykit-1 @@ -70,7 +70,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends} ,libpcre3 Recommends: ${misc:Recommends} ,libapache2-mod-php5 | libapache2-mod-php | php5-fpm | php-fpm - ,mysql-server | virtual-mysql-server + ,mysql-server | mariadb-server | virtual-mysql-server ,zoneminder-doc (>= ${source:Version}) ,ffmpeg Suggests: fcgiwrap, logrotate diff --git a/distros/ubuntu1604/rules b/distros/ubuntu1604/rules index 53a9a237a..97c084e42 100755 --- a/distros/ubuntu1604/rules +++ b/distros/ubuntu1604/rules @@ -66,9 +66,6 @@ override_dh_fixperms: chown root:www-data $(CURDIR)/debian/zoneminder/etc/zm/zm.conf chmod 640 $(CURDIR)/debian/zoneminder/etc/zm/zm.conf -override_dh_installinit: - dh_installinit --no-start - override_dh_systemd_start: dh_systemd_start --no-start diff --git a/distros/ubuntu1604/zoneminder.init b/distros/ubuntu1604/zoneminder.init deleted file mode 100644 index 5cdf62165..000000000 --- a/distros/ubuntu1604/zoneminder.init +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: zoneminder -# Required-Start: $network $remote_fs $syslog -# Required-Stop: $network $remote_fs $syslog -# Should-Start: mysql -# Should-Stop: mysql -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Control ZoneMinder as a Service -# Description: ZoneMinder CCTV recording and surveillance system -### END INIT INFO -# chkconfig: 2345 20 20 - -# Source function library. -. /lib/lsb/init-functions - -prog=ZoneMinder -ZM_PATH_BIN="/usr/bin" -RUNDIR="/var/run/zm" -TMPDIR="/tmp/zm" -command="$ZM_PATH_BIN/zmpkg.pl" - -start() { - echo -n "Starting $prog: " - export TZ=:/etc/localtime - mkdir -p "$RUNDIR" && chown www-data:www-data "$RUNDIR" - mkdir -p "$TMPDIR" && chown www-data:www-data "$TMPDIR" - $command start - RETVAL=$? - [ $RETVAL = 0 ] && echo success - [ $RETVAL != 0 ] && echo failure - echo - [ $RETVAL = 0 ] && touch /var/lock/zm - return $RETVAL -} -stop() { - echo -n "Stopping $prog: " - # - # Why is this status check being done? - # as $command stop returns 1 if zoneminder - # is stopped, which will result in - # this returning 1, which will stuff - # dpkg when it tries to stop zoneminder before - # uninstalling . . . - # - result=`$command status` - if [ ! "$result" = "running" ]; then - echo "Zoneminder already stopped" - echo - RETVAL=0 - else - $command stop - RETVAL=$? - [ $RETVAL = 0 ] && echo success - [ $RETVAL != 0 ] && echo failure - echo - [ $RETVAL = 0 ] && rm -f /var/lock/zm - fi -} -status() { - result=`$command status` - if [ "$result" = "running" ]; then - echo "ZoneMinder is running" - RETVAL=0 - else - echo "ZoneMinder is stopped" - RETVAL=1 - fi -} - -case "$1" in -'start') - start - ;; -'stop') - stop - ;; -'restart' | 'force-reload') - stop - start - ;; -'status') - status - ;; -*) - echo "Usage: $0 { start | stop | restart | status }" - RETVAL=1 - ;; -esac -exit $RETVAL diff --git a/distros/ubuntu1604/zoneminder.postinst b/distros/ubuntu1604/zoneminder.postinst index d69619b54..c9fbe245e 100644 --- a/distros/ubuntu1604/zoneminder.postinst +++ b/distros/ubuntu1604/zoneminder.postinst @@ -1,36 +1,53 @@ #! /bin/sh -set -e +set +e if [ "$1" = "configure" ]; then - + . /etc/zm/zm.conf - for i in /etc/zm/conf.d/*.conf; do - . $i - done; - + for CONFFILE in /etc/zm/conf.d/*.conf; do + . "$CONFFILE" + done + # The logs can contain passwords, etc... so by setting group root, only www-data can read them, not people in the www-data group chown www-data:root /var/log/zm chown www-data:www-data /var/lib/zm if [ -z "$2" ]; then - chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/* /usr/share/zoneminder/www/cache + chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/* /usr/share/zoneminder/www/cache fi - if [ ! -e "/etc/apache2/mods-enabled/cgi.load" ]; then + if [ ! -e "/etc/apache2/mods-enabled/cgi.load" ] && [ "$(command -v a2enmod)" != "" ]; then echo "The cgi module is not enabled in apache2. I am enabling it using a2enmod cgi." a2enmod cgi fi if [ "$ZM_DB_HOST" = "localhost" ]; then - if [ -e "/etc/init.d/mysql" ]; then - # Do this every time the package is installed or upgraded + if [ -e "/lib/systemd/system/mysql.service" ] || [ -e "/lib/systemd/system/mariadb.service" ]; then # Ensure zoneminder is stopped deb-systemd-invoke stop zoneminder.service || exit $? + # Get mysql started if it isn't running # - # Get mysql started if it isn't - # - if $(/etc/init.d/mysql status >/dev/null 2>&1); then + $(systemctl status mysql.service >/dev/null 2>&1); MYSQL_STATUS=$? + $(systemctl status mariadb.service >/dev/null 2>&1); MARIADB_STATUS=$? + + # 3 = inactive, 4 = nonexistant + if [ "$MARIADB_STATUS" != "4" ]; then + DBSERVICE="mariadb.service" + else + DBSERVICE="mysql.service" + fi + + if [ "$MYSQL_STATUS" != "0" ] && [ "$MARIADB_STATUS" != "0" ]; then + # 3 = inactive, 4 = nonexistant + # Due to /etc/init.d service autogeneration, mysql.service always returns the status of mariadb.service + # However, mariadb.service will not return the status of mysql.service. + deb-systemd-invoke start $DBSERVICE + fi + + # Make sure systemctl status exit code is 0; i.e. the DB is running + if systemctl status "$DBSERVICE" >/dev/null 2>&1; then + mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload # test if database if already present... if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null 2> /dev/null) ; then @@ -40,25 +57,19 @@ if [ "$1" = "configure" ]; then else echo "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql fi - - zmupdate.pl --nointeractive - zmupdate.pl --nointeractive -f - - # Add any new PTZ control configurations to the database (will not overwrite) - zmcamtool.pl --import >/dev/null 2>&1 - + else - echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.' + echo 'NOTE: MySQL/MariaDB not running; please start mysql and run dpkg-reconfigure zoneminder when it is running.' fi else - echo 'mysql not found, assuming remote server.' + echo 'MySQL/MariaDB not found; assuming remote server.' fi else - echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" + echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)." fi - echo "Done Updating, starting ZoneMinder" - deb-systemd-invoke restart zoneminder.service || exit $? + echo "Done Updating; starting ZoneMinder." + deb-systemd-invoke restart zoneminder.service fi diff --git a/docs/installationguide/dedicateddrive.rst b/docs/installationguide/dedicateddrive.rst new file mode 100644 index 000000000..40db1ee93 --- /dev/null +++ b/docs/installationguide/dedicateddrive.rst @@ -0,0 +1,39 @@ +Dedicated Drive, Partition, or Network Share +============================================ + +One of the first steps the end user must perform after installing ZoneMinder is to dedicate an entire partition, drive, or network share for ZoneMinder's event storage. +The reason being, ZoneMinder will, by design, fill up your hard disk, and you don't want to do that to your root volume! + +The following steps apply to ZoneMinder 1.31 or newer, running on a typical Linux system, which uses systemd. +If you are using an older version of ZoneMinder, please follow the legacy steps in the `ZoneMinder Wiki `_. + +**Step 1:** Stop ZoneMinder +:: + + sudo systemctl stop zoneminder + +**Step 2:** Mount your dedicated drive, partition, or network share to the local filesystem in any folder of your choosing. +We recommend you use systemd to manage the mount points. +Instructions on how to accomplish this can be found `here `_ and `here `_. +Note that bind mounting ZoneMinder's images folder is optional. Newer version of ZoneMinder write very little, if anything, to the images folder. +Verify the dedicated drive, partition, or network share is successfully mounted before proceeding to the next step. + +**Step 3:** Set the owner and group to that of the web server user account. Debian based distros typically use "www-data" as the web server user account while many rpm based distros use "apache". +:: + + sudo chown -R apache:apache /path/to/your/zoneminder/events/folder + sudo chown -R apache:apache /path/to/your/zoneminder/images/folder + +Recall from the previous step, the images folder is optional. + +**Step 4:** Create a config file under /etc/zm/conf.d using your favorite text editor. Name the file anything you want just as long as it ends in ".conf". +Add the following content to the file and save your changes: +:: + + ZM_DIR_EVENTS=/full/path/to/the/events/folder + ZM_DIR_IMAGES=/full/path/to/the/images/folder + +**Step 5:** Start ZoneMinder and inspect the ZoneMinder log files for errors. +:: + + sudo systemctl start zoneminder diff --git a/docs/installationguide/index.rst b/docs/installationguide/index.rst index 8b8a7c376..4e2288de6 100644 --- a/docs/installationguide/index.rst +++ b/docs/installationguide/index.rst @@ -11,3 +11,4 @@ Contents: debian redhat multiserver + dedicateddrive diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/DCS3415.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/DCS3415.pm new file mode 100644 index 000000000..2db704320 --- /dev/null +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/DCS3415.pm @@ -0,0 +1,195 @@ +# ========================================================================== +# +# ZoneMinder D-Link DCS-3415 IP Control Protocol Module, 2018-03-04, 0.1 +# Copyright (C) 2015-2018 Habib Kamei +# +# Modified for use with D-Link DCS-3415 IP Camera by Habib Kamei +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ========================================================================== +# +# This module contains the implementation of the D-Link DCS-3415 device control protocol +# +#=========================================================================== + +package ZoneMinder::Control::DCS3415; + +use 5.006; +use strict; +use warnings; + +require ZoneMinder::Base; +require ZoneMinder::Control; + +our @ISA = qw(ZoneMinder::Control); + +# ========================================================================== +# +# D-Link DCS-3415 Control Protocol +# +# On ControlAddress use the format : +# USERNAME:PASSWORD@ADDRESS:PORT +# eg : admin:@10.1.2.1:80 +# zoneuser:zonepass@192.168.0.20:40000 +# +# ========================================================================== + +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( ) || 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 $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/cgi-bin/viewer/$cmd" ); + my $res = $self->{ua}->request($req); + + + if ( $res->is_success ) + { + $result = !undef; + } + else + { + Error( "Error check failed:'".$res->status_line()."'" ); + } + + return( $result ); +} + +#Zoom In +sub Tele +{ + my $self = shift; + Debug( "Zoom Tele" ); + my $cmd = "camctrl.cgi?channel=0&camid=1&zoom=tele"; + $self->sendCmd( $cmd ); +} + +#Zoom Out +sub Wide +{ + my $self = shift; + Debug( "Zoom Wide" ); + my $cmd = "camctrl.cgi?channel=0&camid=1&zoom=wide"; + $self->sendCmd( $cmd ); +} + +#Focus Near +sub Near +{ + my $self = shift; + Debug( "Focus Near" ); + my $cmd = "camctrl.cgi?channel=0&camid=1&focus=near"; + $self->sendCmd( $cmd ); +} + +#Focus Far +sub Far +{ + my $self = shift; + Debug( "Focus Far" ); + my $cmd = "camctrl.cgi?channel=0&camid=1&focus=far"; + $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::Database; + 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, Ephilip.coombes@zoneminder.comE +=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 diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 6e882b1e5..0baf5fa5a 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -300,8 +300,8 @@ sub GenerateVideo { $frame_rate = $fps; } - my $width = $self->{MonitorWidth}; - my $height = $self->{MonitorHeight}; + my $width = $self->{Width}; + my $height = $self->{Height}; my $video_size = " ${width}x${height}"; if ( $scale ) { diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in index 2386c5d6f..834e0747c 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in @@ -166,6 +166,8 @@ our $mem_data = { last_write_time => { type=>'time_t64', seq=>$mem_seq++ }, last_read_time => { type=>'time_t64', seq=>$mem_seq++ }, control_state => { type=>'uint8[256]', seq=>$mem_seq++ }, + alarm_cause => { type=>'int8[256]', seq=>$mem_seq++ }, + } }, trigger_data => { type=>'TriggerData', seq=>$mem_seq++, 'contents'=> { @@ -315,6 +317,12 @@ sub zmMemRead { my $type = $mem_data->{$section}->{contents}->{$element}->{type}; my $size = $mem_data->{$section}->{contents}->{$element}->{size}; + if (!defined $offset || !defined $type || !defined $size) { + Error ("Invalid field:".$field." setting to undef and exiting zmMemRead"); + zmMemInvalidate( $monitor ); + return( undef ); + } + my $data = zmMemGet( $monitor, $offset, $size ); if ( !defined($data) ) { Error( "Unable to read '$field' from memory for monitor ".$monitor->{Id} ); @@ -820,6 +828,7 @@ colour Read/write location for the current monitor colour contrast Read/write location for the current monitor contrast alarm_x Image x co-ordinate (from left) of the centre of the last motion event, -1 if none alarm_y Image y co-ordinate (from top) of the centre of the last motion event, -1 if none +alarm_cause The current alarm event cause string along with zone names(s) alarmed trigger_data The triggered event mapped memory section size The size, in bytes of this section diff --git a/scripts/zmvideo.pl.in b/scripts/zmvideo.pl.in index 788ecde87..1f1b33acc 100644 --- a/scripts/zmvideo.pl.in +++ b/scripts/zmvideo.pl.in @@ -197,8 +197,6 @@ my $sql = " SELECT (SELECT max(Delta) FROM Frames WHERE EventId=Events.Id)-(SELE Events.*, unix_timestamp(Events.StartTime) as Time, M.Name as MonitorName, - M.Width as MonitorWidth, - M.Height as MonitorHeight, M.Palette FROM Events INNER JOIN Monitors as M on Events.MonitorId = M.Id diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 980b92b64..58330478e 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -453,6 +453,7 @@ Monitor::Monitor( shared_data->alarm_y = -1; shared_data->format = camera->SubpixelOrder(); shared_data->imagesize = camera->ImageSize(); + shared_data->alarm_cause[0] = 0; trigger_data->size = sizeof(TriggerData); trigger_data->trigger_state = TRIGGER_CANCEL; trigger_data->trigger_score = 0; @@ -1567,6 +1568,18 @@ bool Monitor::Analyse() { event = new Event( this, *(image_buffer[pre_index].timestamp), cause, noteSetMap ); } shared_data->last_event = event->Id(); + // lets construct alarm cause. It will contain cause + names of zones alarmed + std::string alarm_cause=""; + for ( int i=0; i < n_zones; i++) { + if (zones[i]->Alarmed()) { + alarm_cause += std::string(zones[i]->Label()); + if (i < n_zones-1) { + alarm_cause +=","; + } + } + } + alarm_cause = cause+" "+alarm_cause; + strncpy( shared_data->alarm_cause,alarm_cause.c_str() , sizeof(shared_data->alarm_cause) ); //set up video store data snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile()); video_store_data->recording = event->StartTime(); diff --git a/src/zm_monitor.h b/src/zm_monitor.h index fee44aba2..00729bd92 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -145,6 +145,8 @@ protected: }; uint8_t control_state[256]; /* +88 */ + char alarm_cause[256]; + } SharedData; typedef enum { TRIGGER_CANCEL, TRIGGER_ON, TRIGGER_OFF } TriggerState; diff --git a/web/api/app/Model/Host.php b/web/api/app/Model/Host.php index 5c24c7531..481849db9 100644 --- a/web/api/app/Model/Host.php +++ b/web/api/app/Model/Host.php @@ -1,4 +1,3 @@ - 'toggle', 'RTSPDescribe' => 'toggle', 'RecordAudio' => 'toggle', + 'Method' => 'raw', ); if ( $_REQUEST['newMonitor']['ServerId'] == 'auto' ) { diff --git a/web/includes/functions.php b/web/includes/functions.php index e073b0587..c3c35fd61 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -700,7 +700,7 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) { if ( empty($value) ) { $changes[$key] = "$key = 0"; } else { - $changes[$key] = "$key = 0"; + $changes[$key] = "$key = 1"; //$changes[$key] = $key . ' = '.dbEscape(trim($value)); } }