Merge branch 'storageareas' into ffmpeg_321
This commit is contained in:
commit
eb390c323e
|
@ -2,11 +2,12 @@
|
||||||
# Created by mastertheknife (Kfir Itzhak)
|
# Created by mastertheknife (Kfir Itzhak)
|
||||||
# For more information and installation, see the INSTALL file
|
# For more information and installation, see the INSTALL file
|
||||||
#
|
#
|
||||||
cmake_minimum_required (VERSION 2.8.7)
|
cmake_minimum_required (VERSION 3.1.0)
|
||||||
project (zoneminder)
|
project (zoneminder)
|
||||||
file (STRINGS "version" zoneminder_VERSION)
|
file (STRINGS "version" zoneminder_VERSION)
|
||||||
# make API version a minor of ZM version
|
# make API version a minor of ZM version
|
||||||
set(zoneminder_API_VERSION "${zoneminder_VERSION}.1")
|
set(zoneminder_API_VERSION "${zoneminder_VERSION}.1")
|
||||||
|
set (CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
# Make sure the submodules are there
|
# Make sure the submodules are there
|
||||||
if( NOT EXISTS "${CMAKE_SOURCE_DIR}/web/api/app/Plugin/Crud/Lib/CrudControllerTrait.php" )
|
if( NOT EXISTS "${CMAKE_SOURCE_DIR}/web/api/app/Plugin/Crud/Lib/CrudControllerTrait.php" )
|
||||||
|
@ -66,6 +67,24 @@ set(CMAKE_CXX_FLAGS_DEBUG "-Wall -D__STDC_CONSTANT_MACROS -g")
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||||
|
|
||||||
|
# GCC below 6.0 doesn't support __target__("fpu=neon") attribute, required for compiling ARM Neon code, otherwise compilation fails.
|
||||||
|
# Must use -mfpu=neon compiler flag instead, but only do that for processors that support neon, otherwise strip the neon code alltogether,
|
||||||
|
# because passing -fmpu=neon is unsafe to processors that don't support neon
|
||||||
|
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
|
||||||
|
EXEC_PROGRAM(grep ARGS " neon " "/proc/cpuinfo" OUTPUT_VARIABLE neonoutput RETURN_VALUE neonresult)
|
||||||
|
IF(neonresult EQUAL 0)
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfpu=neon")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpu=neon")
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfpu=neon")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mfpu=neon")
|
||||||
|
ELSE(neonresult EQUAL 0)
|
||||||
|
add_definitions(-DZM_STRIP_NEON=1)
|
||||||
|
message(STATUS "ARM Neon is not available on this processor. Neon functions will be absent")
|
||||||
|
ENDIF(neonresult EQUAL 0)
|
||||||
|
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
|
||||||
|
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
|
||||||
# Modules that we need:
|
# Modules that we need:
|
||||||
include (GNUInstallDirs)
|
include (GNUInstallDirs)
|
||||||
include (CheckIncludeFile)
|
include (CheckIncludeFile)
|
||||||
|
@ -546,21 +565,21 @@ if(NOT ZM_NO_FFMPEG)
|
||||||
endif(SWSCALE_LIBRARIES)
|
endif(SWSCALE_LIBRARIES)
|
||||||
|
|
||||||
# rescale (using find_library and find_path)
|
# rescale (using find_library and find_path)
|
||||||
find_library(SWRESAMPLE_LIBRARIES swresample)
|
find_library(AVRESAMPLE_LIBRARIES avresample)
|
||||||
if(SWRESAMPLE_LIBRARIES)
|
if(AVRESAMPLE_LIBRARIES)
|
||||||
set(HAVE_LIBSWRESAMPLE 1)
|
set(HAVE_LIBAVRESAMPLE 1)
|
||||||
list(APPEND ZM_BIN_LIBS "${SWRESAMPLE_LIBRARIES}")
|
list(APPEND ZM_BIN_LIBS "${AVRESAMPLE_LIBRARIES}")
|
||||||
find_path(SWRESAMPLE_INCLUDE_DIR "libswresample/swresample.h" /usr/include/ffmpeg)
|
find_path(AVRESAMPLE_INCLUDE_DIR "libavresample/avresample.h" /usr/include/ffmpeg)
|
||||||
if(SWRESAMPLE_INCLUDE_DIR)
|
if(AVRESAMPLE_INCLUDE_DIR)
|
||||||
include_directories("${SWRESAMPLE_INCLUDE_DIR}")
|
include_directories("${AVRESAMPLE_INCLUDE_DIR}")
|
||||||
set(CMAKE_REQUIRED_INCLUDES "${SWRESAMPLE_INCLUDE_DIR}")
|
set(CMAKE_REQUIRED_INCLUDES "${AVRESAMPLE_INCLUDE_DIR}")
|
||||||
endif(SWRESAMPLE_INCLUDE_DIR)
|
endif(AVRESAMPLE_INCLUDE_DIR)
|
||||||
mark_as_advanced(FORCE SWRESAMPLE_LIBRARIES SWRESAMPLE_INCLUDE_DIR)
|
mark_as_advanced(FORCE AVRESAMPLE_LIBRARIES AVRESAMPLE_INCLUDE_DIR)
|
||||||
check_include_file("libswresample/swresample.h" HAVE_LIBSWRESAMPLE_SWRESAMPLE_H)
|
check_include_file("libavresample/avresample.h" HAVE_LIBAVRESAMPLE_AVRESAMPLE_H)
|
||||||
set(optlibsfound "${optlibsfound} SWResample")
|
set(optlibsfound "${optlibsfound} AVResample")
|
||||||
else(SWRESAMPLE_LIBRARIES)
|
else(AVRESAMPLE_LIBRARIES)
|
||||||
set(optlibsnotfound "${optlibsnotfound} SWResample")
|
set(optlibsnotfound "${optlibsnotfound} AVResample")
|
||||||
endif(SWRESAMPLE_LIBRARIES)
|
endif(AVRESAMPLE_LIBRARIES)
|
||||||
|
|
||||||
# Find the path to the ffmpeg executable
|
# Find the path to the ffmpeg executable
|
||||||
find_program(FFMPEG_EXECUTABLE
|
find_program(FFMPEG_EXECUTABLE
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
D @ZM_TMPDIR@ 0755 @WEB_USER@ @WEB_GROUP@
|
D @ZM_TMPDIR@ 0755 @WEB_USER@ @WEB_GROUP@
|
||||||
|
D @ZM_TMPDIR@/logs 0755 @WEB_USER@ @WEB_GROUP@
|
||||||
|
D @ZM_TMPDIR@/cache 0755 @WEB_USER@ @WEB_GROUP@
|
||||||
|
D @ZM_TMPDIR@/cache/models 0755 @WEB_USER@ @WEB_GROUP@
|
||||||
|
D @ZM_TMPDIR@/cache/persistent 0755 @WEB_USER@ @WEB_GROUP@
|
||||||
|
D @ZM_TMPDIR@/cache/views 0755 @WEB_USER@ @WEB_GROUP@
|
||||||
D @ZM_SOCKDIR@ 0755 @WEB_USER@ @WEB_GROUP@
|
D @ZM_SOCKDIR@ 0755 @WEB_USER@ @WEB_GROUP@
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
Name: zoneminder
|
Name: zoneminder
|
||||||
Version: 1.30.2
|
Version: 1.30.2
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Summary: A camera monitoring and analysis tool
|
Summary: A camera monitoring and analysis tool
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
# jscalendar is LGPL (any version): http://www.dynarch.com/projects/calendar/
|
# jscalendar is LGPL (any version): http://www.dynarch.com/projects/calendar/
|
||||||
|
@ -39,7 +39,7 @@ Group: System Environment/Daemons
|
||||||
License: GPLv2+ and LGPLv2+ and MIT
|
License: GPLv2+ and LGPLv2+ and MIT
|
||||||
URL: http://www.zoneminder.com/
|
URL: http://www.zoneminder.com/
|
||||||
|
|
||||||
Source0: https://github.com/ZoneMinder/ZoneMinder/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
Source0: https://github.com/ZoneMinder/ZoneMinder/archive/%{version}.tar.gz#/zoneminder-%{version}.tar.gz
|
||||||
Source1: https://github.com/FriendsOfCake/crud/archive/v%{crud_version}.tar.gz#/crud-%{crud_version}.tar.gz
|
Source1: https://github.com/FriendsOfCake/crud/archive/v%{crud_version}.tar.gz#/crud-%{crud_version}.tar.gz
|
||||||
|
|
||||||
%{?with_init_systemd:BuildRequires: systemd-devel}
|
%{?with_init_systemd:BuildRequires: systemd-devel}
|
||||||
|
@ -130,8 +130,8 @@ designed to support as many cameras as you can attach to your computer without
|
||||||
too much degradation of performance.
|
too much degradation of performance.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup
|
%autosetup -n ZoneMinder-%{version}
|
||||||
%autosetup -a 1
|
%autosetup -a 1 -n ZoneMinder-%{version}
|
||||||
rmdir ./web/api/app/Plugin/Crud
|
rmdir ./web/api/app/Plugin/Crud
|
||||||
mv -f crud-%{crud_version} ./web/api/app/Plugin/Crud
|
mv -f crud-%{crud_version} ./web/api/app/Plugin/Crud
|
||||||
|
|
||||||
|
@ -336,8 +336,11 @@ rm -rf %{_docdir}/%{name}-%{version}
|
||||||
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %ghost %{_localstatedir}/run/zoneminder
|
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %ghost %{_localstatedir}/run/zoneminder
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Mar 30 2017 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.30.2-2
|
||||||
|
- 1.30.2 release
|
||||||
|
|
||||||
* Wed Feb 08 2017 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.30.2-1
|
* Wed Feb 08 2017 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.30.2-1
|
||||||
- Bump version for 1.30.2 release
|
- Bump version for 1.30.2 release candidate 1
|
||||||
|
|
||||||
* Wed Dec 28 2016 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.30.1-2
|
* Wed Dec 28 2016 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.30.1-2
|
||||||
- Changes from rpmfusion #4393
|
- Changes from rpmfusion #4393
|
||||||
|
|
|
@ -5,6 +5,7 @@ Maintainer: Dmitry Smirnov <onlyjob@debian.org>
|
||||||
Uploaders: Vagrant Cascadian <vagrant@debian.org>
|
Uploaders: Vagrant Cascadian <vagrant@debian.org>
|
||||||
Build-Depends: debhelper (>= 9), python-sphinx | python3-sphinx, apache2-dev, dh-linktree
|
Build-Depends: debhelper (>= 9), python-sphinx | python3-sphinx, apache2-dev, dh-linktree
|
||||||
,cmake
|
,cmake
|
||||||
|
,libx264-dev, libmp4v2-dev
|
||||||
,libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libavdevice-dev
|
,libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libavdevice-dev
|
||||||
,libboost1.55-dev
|
,libboost1.55-dev
|
||||||
,libbz2-dev
|
,libbz2-dev
|
||||||
|
@ -35,6 +36,7 @@ Package: zoneminder
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
||||||
,javascript-common
|
,javascript-common
|
||||||
|
,libmp4v2-2, libx264-142
|
||||||
,libav-tools|ffmpeg
|
,libav-tools|ffmpeg
|
||||||
,libdate-manip-perl
|
,libdate-manip-perl
|
||||||
,libdbd-mysql-perl
|
,libdbd-mysql-perl
|
||||||
|
|
|
@ -58,8 +58,10 @@ override_dh_auto_install:
|
||||||
|
|
||||||
override_dh_fixperms:
|
override_dh_fixperms:
|
||||||
dh_fixperms
|
dh_fixperms
|
||||||
## 637685
|
#
|
||||||
chmod -c o-r $(CURDIR)/debian/zoneminder/etc/zm/zm.conf
|
# As requested by the Debian Webapps Policy Manual §3.2.1
|
||||||
|
chown root:www-data $(CURDIR)/debian/zoneminder/etc/zm/zm.conf
|
||||||
|
chmod 640 $(CURDIR)/debian/zoneminder/etc/zm/zm.conf
|
||||||
|
|
||||||
override_dh_installinit:
|
override_dh_installinit:
|
||||||
dh_installinit --no-start
|
dh_installinit --no-start
|
||||||
|
|
|
@ -7,26 +7,24 @@ Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apa
|
||||||
,cmake
|
,cmake
|
||||||
,libx264-dev, libmp4v2-dev
|
,libx264-dev, libmp4v2-dev
|
||||||
,libavcodec-dev, libavformat-dev, libswscale-dev
|
,libavcodec-dev, libavformat-dev, libswscale-dev
|
||||||
, libavutil-dev, libavdevice-dev
|
,libavutil-dev, libavdevice-dev
|
||||||
,libboost-dev
|
,libboost-dev
|
||||||
,libbz2-dev
|
,libbz2-dev
|
||||||
,libgcrypt-dev
|
,libgcrypt-dev
|
||||||
,libcurl4-gnutls-dev
|
,libcurl4-gnutls-dev
|
||||||
,libgnutls-openssl-dev
|
,libgnutls-openssl-dev
|
||||||
,libjpeg-dev
|
, libjpeg8-dev | libjpeg9-dev | libjpeg62-turbo-dev
|
||||||
,libmysqlclient-dev
|
,libmysqlclient-dev
|
||||||
,libpcre3-dev
|
,libpcre3-dev
|
||||||
,libpolkit-gobject-1-dev
|
,libpolkit-gobject-1-dev
|
||||||
,libv4l-dev (>= 0.8.3) [!hurd-any]
|
,libv4l-dev (>= 0.8.3) [!hurd-any]
|
||||||
,libvlc-dev
|
,libvlc-dev,
|
||||||
,libdate-manip-perl
|
,libdate-manip-perl
|
||||||
,libdbd-mysql-perl
|
,libdbd-mysql-perl
|
||||||
,libphp-serialization-perl
|
,libphp-serialization-perl
|
||||||
,libsys-mmap-perl [!hurd-any]
|
,libsys-mmap-perl [!hurd-any]
|
||||||
,libwww-perl
|
,libwww-perl
|
||||||
,libdata-uuid-perl
|
,libdata-uuid-perl
|
||||||
,libx264-dev
|
|
||||||
,libmp4v2-dev
|
|
||||||
# Unbundled (dh_linktree):
|
# Unbundled (dh_linktree):
|
||||||
,libjs-jquery
|
,libjs-jquery
|
||||||
,libjs-mootools
|
,libjs-mootools
|
||||||
|
@ -39,6 +37,7 @@ Package: zoneminder
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
||||||
,javascript-common
|
,javascript-common
|
||||||
|
,libmp4v2-2, libx264-142|libx264-148, libswscale-ffmpeg3|libswscale4|libswscale3
|
||||||
,ffmpeg | libav-tools
|
,ffmpeg | libav-tools
|
||||||
,libdate-manip-perl, libmime-lite-perl, libmime-tools-perl
|
,libdate-manip-perl, libmime-lite-perl, libmime-tools-perl
|
||||||
,libdbd-mysql-perl
|
,libdbd-mysql-perl
|
||||||
|
@ -66,6 +65,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
||||||
,policykit-1
|
,policykit-1
|
||||||
,rsyslog | system-log-daemon
|
,rsyslog | system-log-daemon
|
||||||
,zip
|
,zip
|
||||||
|
,libprce3
|
||||||
Recommends: ${misc:Recommends}
|
Recommends: ${misc:Recommends}
|
||||||
,libapache2-mod-php5 | libapache2-mod-php | php5-fpm | php-fpm
|
,libapache2-mod-php5 | libapache2-mod-php | php5-fpm | php-fpm
|
||||||
,mysql-server | virtual-mysql-server
|
,mysql-server | virtual-mysql-server
|
||||||
|
|
|
@ -58,8 +58,10 @@ override_dh_auto_install:
|
||||||
|
|
||||||
override_dh_fixperms:
|
override_dh_fixperms:
|
||||||
dh_fixperms
|
dh_fixperms
|
||||||
## 637685
|
#
|
||||||
chmod -c o-r $(CURDIR)/debian/zoneminder/etc/zm/zm.conf
|
# As requested by the Debian Webapps Policy Manual §3.2.1
|
||||||
|
chown root:www-data $(CURDIR)/debian/zoneminder/etc/zm/zm.conf
|
||||||
|
chmod 640 $(CURDIR)/debian/zoneminder/etc/zm/zm.conf
|
||||||
|
|
||||||
override_dh_installinit:
|
override_dh_installinit:
|
||||||
dh_installinit --no-start
|
dh_installinit --no-start
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
3.0 (git)
|
1.0
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
/var/cache/zoneminder/events /usr/share/zoneminder/www/events
|
/var/cache/zoneminder/events /usr/share/zoneminder/www/events
|
||||||
/var/cache/zoneminder/images /usr/share/zoneminder/www/images
|
/var/cache/zoneminder/images /usr/share/zoneminder/www/images
|
||||||
/var/cache/zoneminder/temp /usr/share/zoneminder/www/temp
|
/var/cache/zoneminder/temp /usr/share/zoneminder/www/temp
|
||||||
|
/var/tmp /usr/share/zoneminder/www/api/app/tmp
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
d /var/run/zm 0755 www-data www-data
|
d /var/run/zm 0755 www-data www-data
|
||||||
d /tmp/zm 0755 www-data www-data
|
d /tmp/zm 0755 www-data www-data
|
||||||
|
d /var/tmp/zm 0755 www-data www-data
|
||||||
|
d /var/tmp/cache 0755 www-data www-data
|
||||||
|
d /var/tmp/cache/models 0755 www-data www-data
|
||||||
|
d /var/tmp/cache/persistent 0755 www-data www-data
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
|
@ -0,0 +1 @@
|
||||||
|
<mxfile type="dropbox" userAgent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0" version="5.2.7.3" editor="www.draw.io"><diagram>7Vvfb+I4F/1rkHYfFpEEQnlsmXZ2pXZUqaPd/fZlZIib+JsQs44pZf76uU6uEydOgELoUgkeELn+fc/JuddO6HnTxetnQZbRAw9o3HMHwWvP+9Rz3SvfhW9l2OSGsTfKDaFgQW5ySsMT+0HROEDrigU0rVSUnMeSLavGOU8SOpcVGxGCr6vVnnlcHXVJQj1iaXiak9i2/sUCGeGyXL+0/05ZGOmRHX+Sl8zI/Hso+CrB8Xqu95x98uIF0X1lC/VuwYeCc+hG/Vq8Tmms/Kh9lHvjrqW0mKSgCU5kRwMHUXgh8QpX+g9P6ANLAirA/rACF//2RMVLdvmFyjUX3+HXV77kMQ83PdePYaibGRT7ofqVd5jKjXZdtniqRnSgeB0xSZ+WZK5K18AVsEVyEWNxKgX/TqfQtwBLAnMB4zOL45op4oL94IkkuiFMUDLA6zpmYQI2yVXPz1AFyeRcFZMzHYQ+U80pkjUzocM+U76gUsA6B1jqISORyB52sC5ZMR5jlchgxFgzmSATw6LnEiD4gRi14OWOLbweSALkW6gF7cYC1qjsBzicoF/nMBBwwXb4ggWBGqYRYQ61n2O+BksE9Sg0MLFR0AguiWRcdeWCA2Fm0AVLQnVdXgHvwKCKVXM9R7ipBgPfn067gdgZDCsYu+MrC+QR3jkmxg7e88dBjJ0YEN+zBO65C7jdgKtRKsAd9xHLHfCimB4Fr2aSARsNINLgJRcy4iFPSHxbWsF7WkGVbwx8aRJcq+BWIgmWO8AXq/6fSrlBGMhKcgVWMcI9z9yt+ml1a8pXIoM6cxzGcElESLHeCAVJLWKr9wWNgQEv1XDa5MmsKayKqFa6wpKzRKZGz4/KYIhyTZUdDMwlKnmPza2dQa31EMO6Hj53A7aqgV2scS/8J+jDjvB/ZfJvZe57Pl7+L7scT/DykQoG01M3ddb4XRnjoYyeIWFGflXia4Sx6g8neOPuQ7ADeKHdYqj+n5DxcjDdX3+xOGNwwJRzkMpp9rG0H0r8qyvnxoOSUJCAAW61IKDNn5iADDoX60SBX3SmM99MsiOyVJNZvEK7ZdRP8tQw7c9WAMEhY9Q0H7Nk72ZpUFhl0zPoyqD1jbYha0GlMfyguxqy4jcHDb8qEOBMO+vTCV7XIWOEzDOo8SS5UBuWCznOkBzDyTuSowjKtnDk+WLAXnTCOI2Vd6HuL183S5Xd/dqUVOYWGNdoaVGsLT9r3oVp6z2Z0fiRpwzBnXEp+QIqxLWCIg+1EtMz5vZyfgJuOTVyTeztZpG9VLabnXALifzfJSswY7OJujbbqOt6o5NnMNrWXQazPyD23tBGyMrwUpi9rNnM+6h2RpJVN1LCaoLY6rad7jB3Vw2M1ba35X12Lj9sUeMdufzOjootoe4o50QXmwJfy8IWWNUZYnGihWac4D4CU5yMkpnusTxwbBKeSTU/9jT1TOFpCmqF8aiUp4nneWBS689Wo+Xd/3eljkuBmN7dnQcf05SHrzJd0ieZW8JePsAl7u0d99Lcp7VTHKXXO4JhQfvd0dBg3aSJdDoEHkM6HWm33YUGDPuBe1Mc/zdlr820afB9K7StZIhIkOm90uyApFERkes4Mp6O+wzUIe2rpyIZkkdhpbPi6oZ5bCfFQ/SviaQ+xznuCHUPPT3bMInuc8cYborwYztwWxjdP2LWRxpO8CzirRGzdcrdR0zd8xsDxGAwnSqpqAeITwTiIkntCGHFA2tTdcywb4hDl13ZUdHpW4opQPc7NHgKXM2U9La+skVrelqkjcdpnb3//3BaN3QgaWtKtTvXuvpIB+8OWqd8gt3B9kf0WrAuWrB/ptq1Bng+hsxCA2wCnyxvdVyk4keWgNGwnjucSgLqIx0sAa1T7l4C7IdDFwk4MwkYTqqvFbyzBOBpzUeWAP/ddjz1kQ7e8bROuXsJsB8CXiTgzCTAr78a+J4SoJ9KNOyIZ3rD+McjVJiSBRXE3nru91Cw6OtCtb2oNl8JJjff5rnTO3mBbTSqbj2KR8AGzTQTO3/crDu+vIB6yncUXa/+jqL99OVkL6DqN5ovL6CeCNyR9Xbx6V5Ahcvy7wR52lH+P8O7/Qk=</diagram></mxfile>
|
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
|
@ -0,0 +1,12 @@
|
||||||
|
Installation Guide
|
||||||
|
======================================
|
||||||
|
|
||||||
|
Contents:
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
ubuntu
|
||||||
|
debian
|
||||||
|
redhat
|
||||||
|
multiserver
|
|
@ -0,0 +1,55 @@
|
||||||
|
Multi-Server Install
|
||||||
|
====================
|
||||||
|
|
||||||
|
It is possible to run multiple ZoneMinder servers and manage them from a single interface. To achieve this each zoneminder server is connected to a single shared database server and shares file storage for event data.
|
||||||
|
|
||||||
|
.. image:: images/zm-multiserver.png
|
||||||
|
|
||||||
|
Topology Design Notes
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
1. Device symbols represent separate logical functions, not necessarily separate hardware. For example, the Database Server and a ZoneMinder Server, can reside on the same physical hardware.
|
||||||
|
|
||||||
|
2. Configure each ZoneMinder Server to use the same, remote Database Server (Green).
|
||||||
|
|
||||||
|
3. The Storage Server (Red) represents shared storage, accessible by all ZoneMinder Servers, mounted under each server’s events folder.
|
||||||
|
|
||||||
|
4. Create at least two networks for best performance. Dedicate a Storage LAN for communication with the Storage and Database Servers. Make use of multipath and jumbo frames if possible. Keep all other traffic off the Storage LAN! Dedicate the second LAN, called the Video LAN in the diagram, for all other traffic.
|
||||||
|
|
||||||
|
New installs
|
||||||
|
------------
|
||||||
|
|
||||||
|
1. Follow the normal instructions for your distro for installing ZoneMinder onto all the ZoneMinder servers in the normal fashion. Only a single database will be needed either as standalone, or on one of the ZoneMinder Servers.
|
||||||
|
|
||||||
|
2. On each ZoneMinder server, edit zm.conf. Find the ZM_DB_HOST variable and set it to the name or ip address of your Database Server. Find the ZM_SERVER_HOST and enter a name for this ZoneMinder server. Use a name easily recognizable by you. This name is not used by ZoneMinder for dns or any other form of network conectivity.
|
||||||
|
|
||||||
|
3. Copy the file /usr/share/zoneminder/db/zm_create.sql from one of the ZoneMinder Servers to the machine targeted as the Database Server.
|
||||||
|
|
||||||
|
4. Install mysql/mariadb server onto the Database Server.
|
||||||
|
|
||||||
|
5. It is advised to run "mysql_secure_installation" to help secure the server.
|
||||||
|
|
||||||
|
6. Using the password for the root account set during the previous step, create the ZoneMinder database and configure a database account for ZoneMinder to use:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
mysql -u root -p < zm_create.sql
|
||||||
|
mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
|
||||||
|
mysqladmin -u root -p reload
|
||||||
|
|
||||||
|
The database account credentials, zmuser/zmpass, are arbitrary. Set them to anything that suits your environment.
|
||||||
|
Note that these commands are just an example and might not be secure enough for your environment.
|
||||||
|
|
||||||
|
7. If you have chosen to change the ZoneMinder database account credentials to something other than zmuser/zmpass, you must now update zm.conf on each ZoneMinder Server. Change ZM_DB_USER and ZM_DB_PASS to the values you created in the previous step.
|
||||||
|
|
||||||
|
Additionally, you must also edit /usr/share/zoneminder/www/api/app/Config/database.php in a similar manner on each ZoneMinder Server. Scroll down and change login and password to the values you created in the previous step.
|
||||||
|
|
||||||
|
8. All ZoneMinders Servers must share a common events folder. This can be done in any manner supported by the underlying operating system. From the Storage Server, share/export a folder to be used for ZoneMinder events.
|
||||||
|
|
||||||
|
9. From each ZoneMinder Server, mount the shared events folder on the Storage Server to the events folder on the local ZoneMinder Server.
|
||||||
|
|
||||||
|
NOTE: The location of this folder varies by distro. This folder is often found under "/var/lib/zoneminder/events" for RedHat based distros and "/var/cache/zoneminder/events" for Debain based distros. This folder is NOT a Symbolic Link!
|
||||||
|
|
||||||
|
10. Open your browser and point it to the web console on any of the ZoneMinder Servers (they will all be the same). Open Options, click the Servers tab,and populate this screen with all of your ZoneMinder Servers. Each server has a field for its name and its hostname. The name is what you used for ZM_SERVER_HOST in step 2. The hostname is the network name or ip address ZoneMinder should use.
|
||||||
|
|
||||||
|
11. When creating a new Monitor, remember to select the server the camera will be assigned to from the Server drop down box.
|
|
@ -12,7 +12,7 @@ Type=forking
|
||||||
ExecStart=@BINDIR@/zmpkg.pl start
|
ExecStart=@BINDIR@/zmpkg.pl start
|
||||||
ExecReload=@BINDIR@/zmpkg.pl restart
|
ExecReload=@BINDIR@/zmpkg.pl restart
|
||||||
ExecStop=@BINDIR@/zmpkg.pl stop
|
ExecStop=@BINDIR@/zmpkg.pl stop
|
||||||
PIDFile="@ZM_RUNDIR@/zm.pid"
|
PIDFile=@ZM_RUNDIR@/zm.pid
|
||||||
Environment=TZ=:/etc/localtime
|
Environment=TZ=:/etc/localtime
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
|
@ -354,6 +354,26 @@ our @options = (
|
||||||
type => $types{boolean},
|
type => $types{boolean},
|
||||||
category => 'system',
|
category => 'system',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name => 'ZM_ENABLE_CSRF_MAGIC',
|
||||||
|
default => 'no',
|
||||||
|
description => 'Enable csrf-magic library',
|
||||||
|
help => q`
|
||||||
|
CSRF stands for Cross-Site Request Forgery which, under specific
|
||||||
|
circumstances, can allow an attacker to perform any task your
|
||||||
|
ZoneMinder user account has permission to perform. To accomplish
|
||||||
|
this, the attacker must write a very specific web page and get
|
||||||
|
you to navigate to it, while you are logged into the ZoneMinder
|
||||||
|
web console at the same time. Enabling ZM_ENABLE_CSRF_MAGIC will
|
||||||
|
help mitigate these kinds of attackes. Be warned this feature
|
||||||
|
is experimental and may cause problems, particularly with the API.
|
||||||
|
If you find a false positive and can document how to reproduce it,
|
||||||
|
then please report it. This feature defaults to OFF currently due to
|
||||||
|
its experimental nature.
|
||||||
|
`,
|
||||||
|
type => $types{boolean},
|
||||||
|
category => 'system',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name => 'ZM_OPT_USE_API',
|
name => 'ZM_OPT_USE_API',
|
||||||
default => 'yes',
|
default => 'yes',
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,27 +1,34 @@
|
||||||
|
# ==========================================================================
|
||||||
|
#
|
||||||
|
# ZoneMinder SunEyes SP-P1802SWPTZ IP Control Protocol Module, $Date: 2017-03-19 23:00:00 +1000 (Sat, 19 March 2017) $, $Revision: 0002 $
|
||||||
|
# Copyright (C) 2001-2008 Philip Coombes
|
||||||
|
# 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
|
||||||
|
# Modified May 2014 by Arun Horne (http://arunhorne.co.uk) to:
|
||||||
|
# use HTTP basic auth as required by firmware 11.37.x.x upward
|
||||||
# Modified on Sep 28 2015 by Bobby Billingsley
|
# Modified on Sep 28 2015 by Bobby Billingsley
|
||||||
# Changes made
|
# Changes made
|
||||||
# - Copied FI8918W.pm to SPP1802SWPTZ.pm
|
# - Copied FI8918W.pm to SPP1802SWPTZ.pm
|
||||||
# - modified to control a SunEyes SP-P1802SWPTZ
|
# - modified to control a SunEyes SP-P1802SWPTZ
|
||||||
|
# Modified on 13 March 2017 by Steve Gilvarry
|
||||||
# ==========================================================================
|
# -Address license and copyright issues
|
||||||
# ZoneMinder SunEyes SP-P1802SWPTZ IP Control Protocol Module
|
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify it under
|
# This program is free software; you can redistribute it and/or
|
||||||
# the terms of the GNU General Public License as published by the Free Software
|
# modify it under the terms of the GNU General Public License
|
||||||
# Foundation; either version 2 of the License, or (at your option) any later
|
# as published by the Free Software Foundation; either version 2
|
||||||
# version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# This program is distributed in the hope that it will be useful,
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
#
|
#
|
||||||
# ==========================================================================
|
|
||||||
#
|
|
||||||
# This module contains the implementation of the SunEyes SP-P1802SWPTZ IP
|
# This module contains the implementation of the SunEyes SP-P1802SWPTZ IP
|
||||||
# camera control protocol
|
# camera control protocol
|
||||||
#
|
#
|
||||||
|
|
|
@ -241,6 +241,7 @@ sub GenerateVideo {
|
||||||
sub delete {
|
sub delete {
|
||||||
my $event = $_[0];
|
my $event = $_[0];
|
||||||
Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} $event->{StartTime}\n" );
|
Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} $event->{StartTime}\n" );
|
||||||
|
$ZoneMinder::Database::dbh->ping();
|
||||||
# Do it individually to avoid locking up the table for new events
|
# Do it individually to avoid locking up the table for new events
|
||||||
my $sql = 'delete from Events where Id = ?';
|
my $sql = 'delete from Events where Id = ?';
|
||||||
my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
|
my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
|
||||||
|
@ -331,12 +332,15 @@ sub delete_files {
|
||||||
sub Storage {
|
sub Storage {
|
||||||
return new ZoneMinder::Storage( $_[0]{StorageId} );
|
return new ZoneMinder::Storage( $_[0]{StorageId} );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_for_in_filesystem {
|
sub check_for_in_filesystem {
|
||||||
my $path = $_[0]->Path();
|
my $path = $_[0]->Path();
|
||||||
if ( $path ) {
|
if ( $path ) {
|
||||||
my @files = glob( $path . '/*' );
|
my @files = glob( $path . '/*' );
|
||||||
|
Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found " . scalar @files . " files");
|
||||||
return 1 if @files;
|
return 1 if @files;
|
||||||
}
|
}
|
||||||
|
Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found no files");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,14 +254,14 @@ sub Sql {
|
||||||
} # end if terms
|
} # end if terms
|
||||||
|
|
||||||
if ( $self->{Sql} ) {
|
if ( $self->{Sql} ) {
|
||||||
if ( $self->{AutoMessage} ) {
|
#if ( $self->{AutoMessage} ) {
|
||||||
# Include all events, including events that are still ongoing
|
# Include all events, including events that are still ongoing
|
||||||
# and have no EndTime yet
|
# and have no EndTime yet
|
||||||
$sql .= " and ( ".$self->{Sql}." )";
|
$sql .= " and ( ".$self->{Sql}." )";
|
||||||
} else {
|
#} else {
|
||||||
# Only include closed events (events with valid EndTime)
|
# Only include closed events (events with valid EndTime)
|
||||||
$sql .= " where not isnull(E.EndTime) and ( ".$self->{Sql}." )";
|
#$sql .= " where not isnull(E.EndTime) and ( ".$self->{Sql}." )";
|
||||||
}
|
#}
|
||||||
}
|
}
|
||||||
my @auto_terms;
|
my @auto_terms;
|
||||||
if ( $self->{AutoArchive} ) {
|
if ( $self->{AutoArchive} ) {
|
||||||
|
|
|
@ -179,7 +179,7 @@ sub runCommand {
|
||||||
sub getEventPath {
|
sub getEventPath {
|
||||||
my $event = shift;
|
my $event = shift;
|
||||||
|
|
||||||
my $Storage = new ZoneMinder::Storage( $$event{Id} );
|
my $Storage = new ZoneMinder::Storage( $$event{StorageId} );
|
||||||
my $event_path = join( '/',
|
my $event_path = join( '/',
|
||||||
$Storage->Path(),
|
$Storage->Path(),
|
||||||
$event->{MonitorId},
|
$event->{MonitorId},
|
||||||
|
|
|
@ -0,0 +1,358 @@
|
||||||
|
# ==========================================================================
|
||||||
|
#
|
||||||
|
# ZoneMinder ONVIF Module, $Date$, $Revision$
|
||||||
|
# Copyright (C) 2001-2008 Philip Coombes
|
||||||
|
#
|
||||||
|
# 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 common definitions and functions used by the rest
|
||||||
|
# of the ZoneMinder scripts
|
||||||
|
#
|
||||||
|
package ZoneMinder::ONVIF;
|
||||||
|
|
||||||
|
use 5.006;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
require Exporter;
|
||||||
|
require ZoneMinder::Base;
|
||||||
|
|
||||||
|
our @ISA = qw(Exporter);
|
||||||
|
|
||||||
|
our %EXPORT_TAGS = (
|
||||||
|
functions => [ qw(
|
||||||
|
) ]
|
||||||
|
);
|
||||||
|
push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS;
|
||||||
|
|
||||||
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||||
|
|
||||||
|
our @EXPORT = qw();
|
||||||
|
|
||||||
|
our $VERSION = $ZoneMinder::Base::VERSION;
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
use Data::UUID;
|
||||||
|
|
||||||
|
require ONVIF::Client;
|
||||||
|
|
||||||
|
require WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort;
|
||||||
|
require WSDiscovery10::Elements::Header;
|
||||||
|
require WSDiscovery10::Elements::Types;
|
||||||
|
require WSDiscovery10::Elements::Scopes;
|
||||||
|
|
||||||
|
require WSDiscovery::TransportUDP;
|
||||||
|
|
||||||
|
sub deserialize_message {
|
||||||
|
my ($wsdl_client, $response) = @_;
|
||||||
|
|
||||||
|
# copied and adapted from SOAP::WSDL::Client
|
||||||
|
|
||||||
|
# get deserializer
|
||||||
|
my $deserializer = $wsdl_client->get_deserializer();
|
||||||
|
|
||||||
|
if(! $deserializer) {
|
||||||
|
$deserializer = SOAP::WSDL::Factory::Deserializer->get_deserializer({
|
||||||
|
soap_version => $wsdl_client->get_soap_version(),
|
||||||
|
%{ $wsdl_client->get_deserializer_args() },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
# set class resolver if serializer supports it
|
||||||
|
$deserializer->set_class_resolver( $wsdl_client->get_class_resolver() )
|
||||||
|
if ( $deserializer->can('set_class_resolver') );
|
||||||
|
|
||||||
|
# Try deserializing response - there may be some,
|
||||||
|
# even if transport did not succeed (got a 500 response)
|
||||||
|
if ( $response ) {
|
||||||
|
# as our faults are false, returning a success marker is the only
|
||||||
|
# reliable way of determining whether the deserializer succeeded.
|
||||||
|
# Custom deserializers may return an empty list, or undef,
|
||||||
|
# and $@ is not guaranteed to be undefined.
|
||||||
|
my ($success, $result_body, $result_header) = eval {
|
||||||
|
(1, $deserializer->deserialize( $response ));
|
||||||
|
};
|
||||||
|
if (defined $success) {
|
||||||
|
return wantarray
|
||||||
|
? ($result_body, $result_header)
|
||||||
|
: $result_body;
|
||||||
|
}
|
||||||
|
elsif (blessed $@) { #}&& $@->isa('SOAP::WSDL::SOAP::Typelib::Fault11')) {
|
||||||
|
return $@;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $deserializer->generate_fault({
|
||||||
|
code => 'soap:Server',
|
||||||
|
role => 'urn:localhost',
|
||||||
|
message => "Error deserializing message: $@. \n"
|
||||||
|
. "Message was: \n$response"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
ub interpret_messages {
|
||||||
|
my ($svc_discover, $services, @responses ) = @_;
|
||||||
|
|
||||||
|
my @results;
|
||||||
|
foreach my $response ( @responses ) {
|
||||||
|
|
||||||
|
if($verbose) {
|
||||||
|
print "Received message:\n" . $response . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = deserialize_message($svc_discover, $response);
|
||||||
|
if(not $result) {
|
||||||
|
print "Error deserializing message. No message returned from deserializer.\n" if $verbose;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $xaddr;
|
||||||
|
foreach my $l_xaddr (split ' ', $result->get_ProbeMatch()->get_XAddrs()) {
|
||||||
|
# find IPv4 address
|
||||||
|
print "l_xaddr = $l_xaddr\n" if $verbose;
|
||||||
|
if($l_xaddr =~ m|//[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[:/]|) {
|
||||||
|
$xaddr = $l_xaddr;
|
||||||
|
last;
|
||||||
|
} else {
|
||||||
|
print STDERR "Unable to find IPv4 address from xaddr $l_xaddr\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# No usable address found
|
||||||
|
next if not $xaddr;
|
||||||
|
|
||||||
|
# ignore multiple responses from one service
|
||||||
|
next if defined $services->{$xaddr};
|
||||||
|
$services->{$xaddr} = 1;
|
||||||
|
|
||||||
|
print "$xaddr, " . $svc_discover->get_soap_version() . ", ";
|
||||||
|
|
||||||
|
print "(";
|
||||||
|
my $scopes = $result->get_ProbeMatch()->get_Scopes();
|
||||||
|
my $count = 0;
|
||||||
|
my %scopes;
|
||||||
|
foreach my $scope(split ' ', $scopes) {
|
||||||
|
if($scope =~ m|onvif://www\.onvif\.org/(.+)/(.*)|) {
|
||||||
|
my ($attr, $value) = ($1,$2);
|
||||||
|
if( 0 < $count ++) {
|
||||||
|
print ", ";
|
||||||
|
}
|
||||||
|
print $attr . "=\'" . $value . "\'";
|
||||||
|
$scopes{$attr} = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print ")\n";
|
||||||
|
push @results, { xaddr=>$xaddr,
|
||||||
|
soap_version => $svc_discover->get_soap_version(),
|
||||||
|
scopes => \%scopes,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
return @results;
|
||||||
|
} # end sub interpret_messages
|
||||||
|
|
||||||
|
# functions
|
||||||
|
|
||||||
|
sub discover {
|
||||||
|
my @results;
|
||||||
|
|
||||||
|
## collect all responses
|
||||||
|
my @responses = ();
|
||||||
|
|
||||||
|
no warnings 'redefine';
|
||||||
|
|
||||||
|
*WSDiscovery::TransportUDP::_notify_response = sub {
|
||||||
|
my ($transport, $response) = @_;
|
||||||
|
push @responses, $response;
|
||||||
|
};
|
||||||
|
|
||||||
|
## try both soap versions
|
||||||
|
my %services;
|
||||||
|
|
||||||
|
my $uuid_gen = Data::UUID->new();
|
||||||
|
|
||||||
|
if ( ( ! $soap_version ) or ( $soap_version eq '1.1' ) ) {
|
||||||
|
|
||||||
|
if($verbose) {
|
||||||
|
print "Probing for SOAP 1.1\n"
|
||||||
|
}
|
||||||
|
my $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({
|
||||||
|
# no_dispatch => '1',
|
||||||
|
});
|
||||||
|
$svc_discover->set_soap_version('1.1');
|
||||||
|
|
||||||
|
my $uuid = $uuid_gen->create_str();
|
||||||
|
|
||||||
|
my $result = $svc_discover->ProbeOp(
|
||||||
|
{ # WSDiscovery::Types::ProbeType
|
||||||
|
Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType
|
||||||
|
Scopes => { value => '' },
|
||||||
|
},
|
||||||
|
WSDiscovery10::Elements::Header->new({
|
||||||
|
Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' },
|
||||||
|
MessageID => { value => "urn:uuid:$uuid" },
|
||||||
|
To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' },
|
||||||
|
})
|
||||||
|
);
|
||||||
|
print $result . "\n" if $verbose;
|
||||||
|
|
||||||
|
push @results, interpret_messages($svc_discover, \%services, @responses);
|
||||||
|
@responses = ();
|
||||||
|
} # end if doing soap 1.1
|
||||||
|
|
||||||
|
if ( ( ! $soap_version ) or ( $soap_version eq '1.2' ) ) {
|
||||||
|
if($verbose) {
|
||||||
|
print "Probing for SOAP 1.2\n"
|
||||||
|
}
|
||||||
|
my $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({
|
||||||
|
# no_dispatch => '1',
|
||||||
|
});
|
||||||
|
$svc_discover->set_soap_version('1.2');
|
||||||
|
|
||||||
|
# copies of the same Probe message must have the same MessageID.
|
||||||
|
# This is not a copy. So we generate a new uuid.
|
||||||
|
my $uuid = $uuid_gen->create_str();
|
||||||
|
|
||||||
|
# Everyone else, like the nodejs onvif code and odm only ask for NetworkVideoTransmitter
|
||||||
|
my $result = $svc_discover->ProbeOp(
|
||||||
|
{ # WSDiscovery::Types::ProbeType
|
||||||
|
xmlattr => { 'xmlns:dn' => 'http://www.onvif.org/ver10/network/wsdl', },
|
||||||
|
Types => 'dn:NetworkVideoTransmitter', # QNameListType
|
||||||
|
Scopes => { value => '' },
|
||||||
|
},
|
||||||
|
WSDiscovery10::Elements::Header->new({
|
||||||
|
Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' },
|
||||||
|
MessageID => { value => "urn:uuid:$uuid" },
|
||||||
|
To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' },
|
||||||
|
})
|
||||||
|
);
|
||||||
|
print $result . "\n" if $verbose;
|
||||||
|
push @results, interpret_messages($svc_discover, \%services, @responses);
|
||||||
|
} # end if doing soap 1.2
|
||||||
|
return @results;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub profiles {
|
||||||
|
my $result = $client->get_endpoint('media')->GetProfiles( { } ,, );
|
||||||
|
die $result if not $result;
|
||||||
|
if($verbose) {
|
||||||
|
print "Received message:\n" . $result . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $profiles = $result->get_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() .
|
||||||
|
", ";
|
||||||
|
|
||||||
|
# Specification gives conflicting values for unicast stream types, try both.
|
||||||
|
# http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl#op.GetStreamUri
|
||||||
|
foreach my $streamtype ( 'RTP_unicast', 'RTP-Unicast' ) {
|
||||||
|
$result = $client->get_endpoint('media')->GetStreamUri( {
|
||||||
|
StreamSetup => { # ONVIF::Media::Types::StreamSetup
|
||||||
|
Stream => $streamtype, # StreamType
|
||||||
|
Transport => { # ONVIF::Media::Types::Transport
|
||||||
|
Protocol => 'RTSP', # TransportProtocol
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ProfileToken => $token, # ReferenceToken
|
||||||
|
} ,, );
|
||||||
|
last if $result;
|
||||||
|
}
|
||||||
|
die $result if not $result;
|
||||||
|
# print $result . "\n";
|
||||||
|
|
||||||
|
print $result->get_MediaUri()->get_Uri() .
|
||||||
|
"\n";
|
||||||
|
} # end foreach profile
|
||||||
|
|
||||||
|
#
|
||||||
|
# use message parser without schema validation ???
|
||||||
|
#
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub move {
|
||||||
|
my ($dir) = @_;
|
||||||
|
|
||||||
|
my $result = $client->get_endpoint('ptz')->GetNodes( { } ,, );
|
||||||
|
|
||||||
|
die $result if not $result;
|
||||||
|
print $result . "\n";
|
||||||
|
} # end sub move
|
||||||
|
|
||||||
|
sub metadata {
|
||||||
|
my $result = $client->get_endpoint('media')->GetMetadataConfigurations( { } ,, );
|
||||||
|
die $result if not $result;
|
||||||
|
print $result . "\n";
|
||||||
|
|
||||||
|
$result = $client->get_endpoint('media')->GetVideoAnalyticsConfigurations( { } ,, );
|
||||||
|
die $result if not $result;
|
||||||
|
print $result . "\n";
|
||||||
|
|
||||||
|
# $result = $client->get_endpoint('analytics')->GetServiceCapabilities( { } ,, );
|
||||||
|
# die $result if not $result;
|
||||||
|
# print $result . "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
ZoneMinder::ONVIF - perl module to access onvif functions for ZoneMinder
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
use ZoneMinder::ONVIF;
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
This is a module to contain useful functions and import all the other modules
|
||||||
|
required for ONVIF to work.
|
||||||
|
|
||||||
|
=head2 EXPORT
|
||||||
|
|
||||||
|
None by default.
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
http://www.zoneminder.com
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Philip Coombes, E<lt>philip.coombes@zoneminder.comE<gt>
|
||||||
|
|
||||||
|
=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
|
|
@ -45,70 +45,69 @@ use ZoneMinder::Database qw(:all);
|
||||||
use vars qw/ $AUTOLOAD /;
|
use vars qw/ $AUTOLOAD /;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $parent, $id, $data ) = @_;
|
my ( $parent, $id, $data ) = @_;
|
||||||
|
|
||||||
my $self = {};
|
my $self = {};
|
||||||
bless $self, $parent;
|
bless $self, $parent;
|
||||||
no strict 'refs';
|
no strict 'refs';
|
||||||
my $primary_key = ${$parent.'::primary_key'};
|
my $primary_key = ${$parent.'::primary_key'};
|
||||||
if ( ! $primary_key ) {
|
if ( ! $primary_key ) {
|
||||||
Error( 'NO primary_key for type ' . $parent );
|
Error( 'NO primary_key for type ' . $parent );
|
||||||
return;
|
return;
|
||||||
} # end if
|
} # end if
|
||||||
if ( ( $$self{$primary_key} = $id ) or $data ) {
|
if ( ( $$self{$primary_key} = $id ) or $data ) {
|
||||||
#$log->debug("loading $parent $id") if $debug or DEBUG_ALL;
|
#$log->debug("loading $parent $id") if $debug or DEBUG_ALL;
|
||||||
$self->load( $data );
|
$self->load( $data );
|
||||||
}
|
}
|
||||||
return $self;
|
return $self;
|
||||||
} # end sub new
|
} # end sub new
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ( $self, $data ) = @_;
|
my ( $self, $data ) = @_;
|
||||||
my $type = ref $self;
|
my $type = ref $self;
|
||||||
if ( ! $data ) {
|
if ( ! $data ) {
|
||||||
no strict 'refs';
|
no strict 'refs';
|
||||||
my $table = ${$type.'::table'};
|
my $table = ${$type.'::table'};
|
||||||
if ( ! $table ) {
|
if ( ! $table ) {
|
||||||
Error( 'NO table for type ' . $type );
|
Error( 'NO table for type ' . $type );
|
||||||
return;
|
return;
|
||||||
} # end if
|
} # end if
|
||||||
my $primary_key = ${$type.'::primary_key'};
|
my $primary_key = ${$type.'::primary_key'};
|
||||||
if ( ! $primary_key ) {
|
if ( ! $primary_key ) {
|
||||||
Error( 'NO primary_key for type ' . $type );
|
Error( 'NO primary_key for type ' . $type );
|
||||||
return;
|
return;
|
||||||
} # end if
|
} # end if
|
||||||
|
|
||||||
if ( ! $$self{$primary_key} ) {
|
if ( ! $$self{$primary_key} ) {
|
||||||
my ( $caller, undef, $line ) = caller;
|
my ( $caller, undef, $line ) = caller;
|
||||||
Error( (ref $self) . "::load called without $primary_key from $caller:$line");
|
Error( (ref $self) . "::load called without $primary_key from $caller:$line");
|
||||||
} else {
|
} else {
|
||||||
#$log->debug("Object::load Loading from db $type");
|
#$log->debug("Object::load Loading from db $type");
|
||||||
Debug("Loading $type from $table WHERE $primary_key = $$self{$primary_key}");
|
Debug("Loading $type from $table WHERE $primary_key = $$self{$primary_key}");
|
||||||
$data = $ZoneMinder::Database::dbh->selectrow_hashref( "SELECT * FROM $table WHERE $primary_key=?", {}, $$self{$primary_key} );
|
$data = $ZoneMinder::Database::dbh->selectrow_hashref( "SELECT * FROM $table WHERE $primary_key=?", {}, $$self{$primary_key} );
|
||||||
if ( ! $data ) {
|
if ( ! $data ) {
|
||||||
if ( $ZoneMinder::Database::dbh->errstr ) {
|
if ( $ZoneMinder::Database::dbh->errstr ) {
|
||||||
Error( "Failure to load Object record for $$self{$primary_key}: Reason: " . $ZoneMinder::Database::dbh->errstr );
|
Error( "Failure to load Object record for $$self{$primary_key}: Reason: " . $ZoneMinder::Database::dbh->errstr );
|
||||||
} else {
|
} else {
|
||||||
Debug("No Results Loading $type from $table WHERE $primary_key = $$self{$primary_key}");
|
Debug("No Results Loading $type from $table WHERE $primary_key = $$self{$primary_key}");
|
||||||
|
} # end if
|
||||||
} # end if
|
} # end if
|
||||||
} # end if
|
} # end if
|
||||||
} # end if
|
} # end if ! $data
|
||||||
} # end if ! $data
|
if ( $data and %$data ) {
|
||||||
if ( $data and %$data ) {
|
@$self{keys %$data} = values %$data;
|
||||||
@$self{keys %$data} = values %$data;
|
} # end if
|
||||||
} # end if
|
|
||||||
} # end sub load
|
} # end sub load
|
||||||
|
|
||||||
sub AUTOLOAD {
|
sub AUTOLOAD {
|
||||||
my ( $self, $newvalue ) = @_;
|
my ( $self, $newvalue ) = @_;
|
||||||
my $type = ref($_[0]);
|
my $type = ref($_[0]);
|
||||||
my $name = $AUTOLOAD;
|
my $name = $AUTOLOAD;
|
||||||
$name =~ s/.*://;
|
$name =~ s/.*://;
|
||||||
if ( @_ > 1 ) {
|
if ( @_ > 1 ) {
|
||||||
return $_[0]{$name} = $_[1];
|
return $_[0]{$name} = $_[1];
|
||||||
}
|
}
|
||||||
return $_[0]{$name};
|
return $_[0]{$name};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,12 @@ yet.
|
||||||
|
|
||||||
=head1 OPTIONS
|
=head1 OPTIONS
|
||||||
|
|
||||||
-r, --report - Just report don't actually do anything
|
|
||||||
-i, --interactive - Ask before applying any changes
|
|
||||||
-c, --continuous - Run continuously
|
-c, --continuous - Run continuously
|
||||||
|
-i, --interactive - Ask before applying any changes
|
||||||
|
-m, --monitor_id - Restrict zmaudit actions to events pertaining to the specified monitor id
|
||||||
|
-r, --report - Just report don't actually do anything
|
||||||
-v, --version - Print the installed version of ZoneMinder
|
-v, --version - Print the installed version of ZoneMinder
|
||||||
|
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
use strict;
|
use strict;
|
||||||
|
@ -89,15 +91,17 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
|
||||||
my $report = 0;
|
my $report = 0;
|
||||||
my $interactive = 0;
|
my $interactive = 0;
|
||||||
my $continuous = 0;
|
my $continuous = 0;
|
||||||
|
my $monitor_id = 0;
|
||||||
my $version;
|
my $version;
|
||||||
|
|
||||||
logInit();
|
logInit();
|
||||||
logSetSignal();
|
logSetSignal();
|
||||||
|
|
||||||
GetOptions(
|
GetOptions(
|
||||||
'report' =>\$report,
|
|
||||||
'interactive' =>\$interactive,
|
'interactive' =>\$interactive,
|
||||||
'continuous' =>\$continuous,
|
'continuous' =>\$continuous,
|
||||||
|
'monitor_id=s' =>\$monitor_id,
|
||||||
|
'report' =>\$report,
|
||||||
'version' =>\$version
|
'version' =>\$version
|
||||||
) or pod2usage(-exitstatus => -1);
|
) or pod2usage(-exitstatus => -1);
|
||||||
|
|
||||||
|
@ -153,7 +157,7 @@ MAIN: while( $loop ) {
|
||||||
|
|
||||||
my %Monitors;
|
my %Monitors;
|
||||||
my $db_monitors;
|
my $db_monitors;
|
||||||
my $monitorSelectSql = 'select * from Monitors order by Id';
|
my $monitorSelectSql = $monitor_id ? 'SELECT * FRO Monitors WHERE Id=?' : 'SELECT * FROM Monitors ORDER BY Id';
|
||||||
my $monitorSelectSth = $dbh->prepare_cached( $monitorSelectSql )
|
my $monitorSelectSth = $dbh->prepare_cached( $monitorSelectSql )
|
||||||
or Fatal( "Can't prepare '$monitorSelectSql': ".$dbh->errstr() );
|
or Fatal( "Can't prepare '$monitorSelectSql': ".$dbh->errstr() );
|
||||||
|
|
||||||
|
@ -163,7 +167,7 @@ MAIN: while( $loop ) {
|
||||||
or Fatal( "Can't prepare '$eventSelectSql': ".$dbh->errstr() );
|
or Fatal( "Can't prepare '$eventSelectSql': ".$dbh->errstr() );
|
||||||
|
|
||||||
$cleaned = 0;
|
$cleaned = 0;
|
||||||
my $res = $monitorSelectSth->execute()
|
my $res = $monitorSelectSth->execute( $monitor_id ? $monitor_id : () )
|
||||||
or Fatal( "Can't execute: ".$monitorSelectSth->errstr() );
|
or Fatal( "Can't execute: ".$monitorSelectSth->errstr() );
|
||||||
while( my $monitor = $monitorSelectSth->fetchrow_hashref() ) {
|
while( my $monitor = $monitorSelectSth->fetchrow_hashref() ) {
|
||||||
$Monitors{$$monitor{Id}} = $monitor;
|
$Monitors{$$monitor{Id}} = $monitor;
|
||||||
|
@ -267,7 +271,7 @@ MAIN: while( $loop ) {
|
||||||
} # if USE_DEEP_STORAGE
|
} # if USE_DEEP_STORAGE
|
||||||
Debug( 'Got '.int(keys(%$fs_events))." events for monitor $monitor_dir\n" );
|
Debug( 'Got '.int(keys(%$fs_events))." events for monitor $monitor_dir\n" );
|
||||||
|
|
||||||
delete_empty_directories( $monitor_dir );
|
#delete_empty_directories( $monitor_dir );
|
||||||
} # end foreach monitor
|
} # end foreach monitor
|
||||||
redo MAIN if ( $cleaned );
|
redo MAIN if ( $cleaned );
|
||||||
|
|
||||||
|
@ -334,7 +338,10 @@ MAIN: while( $loop ) {
|
||||||
my $deleteStatsSth = $dbh->prepare_cached( $deleteStatsSql )
|
my $deleteStatsSth = $dbh->prepare_cached( $deleteStatsSql )
|
||||||
or Fatal( "Can't prepare '$deleteStatsSql': ".$dbh->errstr() );
|
or Fatal( "Can't prepare '$deleteStatsSql': ".$dbh->errstr() );
|
||||||
|
|
||||||
|
# Foreach database monitor and it's list of events.
|
||||||
while ( my ( $db_monitor, $db_events ) = each(%$db_monitors) ) {
|
while ( my ( $db_monitor, $db_events ) = each(%$db_monitors) ) {
|
||||||
|
|
||||||
|
# If we found the monitor in the file system
|
||||||
if ( my $fs_events = $fs_monitors->{$db_monitor} ) {
|
if ( my $fs_events = $fs_monitors->{$db_monitor} ) {
|
||||||
next if ! $db_events;
|
next if ! $db_events;
|
||||||
|
|
||||||
|
@ -351,7 +358,7 @@ Debug("Event $db_event is not in fs.");
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if ( $Event->check_for_in_filesystem() ) {
|
if ( $Event->check_for_in_filesystem() ) {
|
||||||
Debug('Database events apparent exists at ' . $Event->Path() );
|
Debug('Database events apparently exists at ' . $Event->Path() );
|
||||||
} else {
|
} else {
|
||||||
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||||
aud_print( "Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem' );
|
aud_print( "Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem' );
|
||||||
|
@ -653,6 +660,7 @@ sub deleteSwapImage {
|
||||||
|
|
||||||
sub delete_empty_directories {
|
sub delete_empty_directories {
|
||||||
my $DIR;
|
my $DIR;
|
||||||
|
Debug("delete_empty_directories $_[0]");
|
||||||
if ( ! opendir( $DIR, $_[0] ) ) {
|
if ( ! opendir( $DIR, $_[0] ) ) {
|
||||||
Error( "delete_empty_directories: Can't open directory '".getcwd()."/$_[0]': $!" );
|
Error( "delete_empty_directories: Can't open directory '".getcwd()."/$_[0]': $!" );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -209,6 +209,7 @@ use ZoneMinder;
|
||||||
use POSIX;
|
use POSIX;
|
||||||
use Socket;
|
use Socket;
|
||||||
use IO::Handle;
|
use IO::Handle;
|
||||||
|
use Time::HiRes qw(usleep);
|
||||||
#use Data::Dumper;
|
#use Data::Dumper;
|
||||||
|
|
||||||
our %cmd_hash;
|
our %cmd_hash;
|
||||||
|
@ -456,20 +457,25 @@ sub send_stop {
|
||||||
} # end sub send_stop
|
} # end sub send_stop
|
||||||
|
|
||||||
sub kill_until_dead {
|
sub kill_until_dead {
|
||||||
my ( $process ) = @_;
|
my ( $process ) = @_;
|
||||||
# Now check it has actually gone away, if not kill -9 it
|
# Now check it has actually gone away, if not kill -9 it
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
while( $process and $$process{pid} and kill( 0, $$process{pid} ) ) {
|
my $sigset = POSIX::SigSet->new;
|
||||||
if ( $count++ > 5 ) {
|
my $blockset = POSIX::SigSet->new(SIGCHLD);
|
||||||
dPrint( ZoneMinder::Logger::WARNING, "'$$process{command}' has not stopped at "
|
sigprocmask(SIG_BLOCK, $blockset, $sigset ) or die "dying at block...\n";
|
||||||
.strftime( '%y/%m/%d %H:%M:%S', localtime() )
|
while( $process and $$process{pid} and kill( 0, $$process{pid} ) ) {
|
||||||
.". Sending KILL to pid $$process{pid}\n"
|
if ( $count++ > 50 ) {
|
||||||
);
|
dPrint( ZoneMinder::Logger::WARNING, "'$$process{command}' has not stopped at "
|
||||||
kill( 'KILL', $$process{pid} );
|
.strftime( '%y/%m/%d %H:%M:%S', localtime() )
|
||||||
}
|
.". Sending KILL to pid $$process{pid}\n"
|
||||||
|
);
|
||||||
sleep( 1 );
|
kill( 'KILL', $$process{pid} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sigprocmask(SIG_UNBLOCK, $blockset) or die "dying at unblock...\n";
|
||||||
|
usleep( 100 );
|
||||||
|
sigprocmask(SIG_BLOCK, $blockset, $sigset ) or die "dying at block...\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _stop {
|
sub _stop {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@
|
||||||
configure_file(zm_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/zm_config.h" @ONLY)
|
configure_file(zm_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/zm_config.h" @ONLY)
|
||||||
|
|
||||||
# Group together all the source files that are used by all the binaries (zmc, zma, zmu, zms etc)
|
# Group together all the source files that are used by all the binaries (zmc, zma, zmu, zms etc)
|
||||||
set(ZM_BIN_SRC_FILES zm_box.cpp zm_buffer.cpp zm_camera.cpp zm_comms.cpp zm_config.cpp zm_coord.cpp zm_curl_camera.cpp zm.cpp zm_db.cpp zm_logger.cpp zm_event.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_camera.cpp zm_image.cpp zm_jpeg.cpp zm_libvlc_camera.cpp zm_local_camera.cpp zm_monitor.cpp zm_ffmpeg.cpp zm_mpeg.cpp zm_packet.cpp zm_packetqueue.cpp zm_poly.cpp zm_regexp.cpp zm_remote_camera.cpp zm_remote_camera_http.cpp zm_remote_camera_rtsp.cpp zm_rtp.cpp zm_rtp_ctrl.cpp zm_rtp_data.cpp zm_rtp_source.cpp zm_rtsp.cpp zm_rtsp_auth.cpp zm_sdp.cpp zm_signal.cpp zm_stream.cpp zm_thread.cpp zm_time.cpp zm_timer.cpp zm_user.cpp zm_utils.cpp zm_video.cpp zm_videostore.cpp zm_zone.cpp zm_storage.cpp)
|
set(ZM_BIN_SRC_FILES zm_box.cpp zm_buffer.cpp zm_camera.cpp zm_comms.cpp zm_config.cpp zm_coord.cpp zm_curl_camera.cpp zm.cpp zm_db.cpp zm_logger.cpp zm_event.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_camera.cpp zm_image.cpp zm_jpeg.cpp zm_libvlc_camera.cpp zm_local_camera.cpp zm_monitor.cpp zm_monitorstream.cpp zm_ffmpeg.cpp zm_mpeg.cpp zm_packet.cpp zm_packetqueue.cpp zm_poly.cpp zm_regexp.cpp zm_remote_camera.cpp zm_remote_camera_http.cpp zm_remote_camera_rtsp.cpp zm_rtp.cpp zm_rtp_ctrl.cpp zm_rtp_data.cpp zm_rtp_source.cpp zm_rtsp.cpp zm_rtsp_auth.cpp zm_sdp.cpp zm_signal.cpp zm_stream.cpp zm_thread.cpp zm_time.cpp zm_timer.cpp zm_user.cpp zm_utils.cpp zm_video.cpp zm_videostore.cpp zm_zone.cpp zm_storage.cpp)
|
||||||
|
|
||||||
# A fix for cmake recompiling the source files for every target.
|
# A fix for cmake recompiling the source files for every target.
|
||||||
add_library(zm STATIC ${ZM_BIN_SRC_FILES})
|
add_library(zm STATIC ${ZM_BIN_SRC_FILES})
|
||||||
|
|
|
@ -55,8 +55,10 @@ char Event::capture_file_format[PATH_MAX];
|
||||||
char Event::analyse_file_format[PATH_MAX];
|
char Event::analyse_file_format[PATH_MAX];
|
||||||
char Event::general_file_format[PATH_MAX];
|
char Event::general_file_format[PATH_MAX];
|
||||||
char Event::video_file_format[PATH_MAX];
|
char Event::video_file_format[PATH_MAX];
|
||||||
|
constexpr const char * Event::frame_type_names[3];
|
||||||
|
|
||||||
int Event::pre_alarm_count = 0;
|
int Event::pre_alarm_count = 0;
|
||||||
|
|
||||||
Event::PreAlarmData Event::pre_alarm_data[MAX_PRE_ALARM_FRAMES] = { { 0 } };
|
Event::PreAlarmData Event::pre_alarm_data[MAX_PRE_ALARM_FRAMES] = { { 0 } };
|
||||||
|
|
||||||
Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap, bool p_videoEvent ) :
|
Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap, bool p_videoEvent ) :
|
||||||
|
@ -192,7 +194,6 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
||||||
#if ZM_HAVE_VIDEOWRITER_X264MP4
|
#if ZM_HAVE_VIDEOWRITER_X264MP4
|
||||||
videowriter = new X264MP4Writer(video_file, monitor->Width(), monitor->Height(), monitor->Colours(), monitor->SubpixelOrder(), monitor->GetOptEncoderParams());
|
videowriter = new X264MP4Writer(video_file, monitor->Width(), monitor->Height(), monitor->Colours(), monitor->SubpixelOrder(), monitor->GetOptEncoderParams());
|
||||||
#else
|
#else
|
||||||
videowriter = NULL;
|
|
||||||
Error("ZoneMinder was not compiled with the X264 MP4 video writer, check dependencies (x264 and mp4v2)");
|
Error("ZoneMinder was not compiled with the X264 MP4 video writer, check dependencies (x264 and mp4v2)");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -629,16 +630,16 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
||||||
struct DeltaTimeval delta_time;
|
struct DeltaTimeval delta_time;
|
||||||
DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 );
|
DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 );
|
||||||
|
|
||||||
const char *frame_type = score>0?"Alarm":(score<0?"Bulk":"Normal");
|
FrameType frame_type = score>0?ALARM:(score<0?BULK:NORMAL);
|
||||||
if ( score < 0 )
|
if ( score < 0 )
|
||||||
score = 0;
|
score = 0;
|
||||||
|
|
||||||
bool db_frame = (strcmp(frame_type,"Bulk") != 0) || ((frames%config.bulk_frame_interval)==0) || !frames;
|
bool db_frame = ( frame_type != BULK ) || ((frames%config.bulk_frame_interval)==0) || !frames;
|
||||||
if ( db_frame ) {
|
if ( db_frame ) {
|
||||||
|
|
||||||
Debug( 1, "Adding frame %d of type \"%s\" to DB", frames, frame_type );
|
Debug( 1, "Adding frame %d of type \"%s\" to DB", frames, Event::frame_type_names[frame_type] );
|
||||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||||
snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type, timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score );
|
snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type_names[frame_type], timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score );
|
||||||
if ( mysql_query( &dbconn, sql ) ) {
|
if ( mysql_query( &dbconn, sql ) ) {
|
||||||
Error( "Can't insert frame: %s", mysql_error( &dbconn ) );
|
Error( "Can't insert frame: %s", mysql_error( &dbconn ) );
|
||||||
exit( mysql_errno( &dbconn ) );
|
exit( mysql_errno( &dbconn ) );
|
||||||
|
@ -646,7 +647,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
||||||
last_db_frame = frames;
|
last_db_frame = frames;
|
||||||
|
|
||||||
// We are writing a Bulk frame
|
// We are writing a Bulk frame
|
||||||
if ( !strcmp( frame_type,"Bulk") ) {
|
if ( frame_type == BULK ) {
|
||||||
snprintf( sql, sizeof(sql), "update Events set Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id );
|
snprintf( sql, sizeof(sql), "update Events set Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id );
|
||||||
if ( mysql_query( &dbconn, sql ) ) {
|
if ( mysql_query( &dbconn, sql ) ) {
|
||||||
Error( "Can't update event: %s", mysql_error( &dbconn ) );
|
Error( "Can't update event: %s", mysql_error( &dbconn ) );
|
||||||
|
@ -658,7 +659,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
||||||
end_time = timestamp;
|
end_time = timestamp;
|
||||||
|
|
||||||
// We are writing an Alarm frame
|
// We are writing an Alarm frame
|
||||||
if ( !strcmp( frame_type,"Alarm") ) {
|
if ( frame_type == ALARM ) {
|
||||||
alarm_frames++;
|
alarm_frames++;
|
||||||
|
|
||||||
tot_score += score;
|
tot_score += score;
|
||||||
|
|
|
@ -65,7 +65,8 @@ class Event {
|
||||||
typedef std::map<std::string,StringSet> StringSetMap;
|
typedef std::map<std::string,StringSet> StringSetMap;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef enum { NORMAL, BULK, ALARM } FrameType;
|
typedef enum { NORMAL=0, BULK, ALARM } FrameType;
|
||||||
|
static constexpr const char * frame_type_names[3] = { "Normal", "Bulk", "Alarm" };
|
||||||
|
|
||||||
struct PreAlarmData {
|
struct PreAlarmData {
|
||||||
Image *image;
|
Image *image;
|
||||||
|
|
|
@ -42,8 +42,7 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri
|
||||||
mMethod( p_method ),
|
mMethod( p_method ),
|
||||||
mOptions( p_options )
|
mOptions( p_options )
|
||||||
{
|
{
|
||||||
if ( capture )
|
if ( capture ) {
|
||||||
{
|
|
||||||
Initialise();
|
Initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,20 +83,19 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FfmpegCamera::~FfmpegCamera()
|
FfmpegCamera::~FfmpegCamera() {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( videoStore ) {
|
||||||
|
delete videoStore;
|
||||||
|
}
|
||||||
CloseFfmpeg();
|
CloseFfmpeg();
|
||||||
|
|
||||||
if ( capture )
|
if ( capture ) {
|
||||||
{
|
|
||||||
Terminate();
|
Terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FfmpegCamera::Initialise()
|
void FfmpegCamera::Initialise() {
|
||||||
{
|
|
||||||
if ( logDebugging() )
|
if ( logDebugging() )
|
||||||
av_log_set_level( AV_LOG_DEBUG );
|
av_log_set_level( AV_LOG_DEBUG );
|
||||||
else
|
else
|
||||||
|
@ -107,12 +105,10 @@ void FfmpegCamera::Initialise()
|
||||||
avformat_network_init();
|
avformat_network_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FfmpegCamera::Terminate()
|
void FfmpegCamera::Terminate() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int FfmpegCamera::PrimeCapture()
|
int FfmpegCamera::PrimeCapture() {
|
||||||
{
|
|
||||||
mVideoStreamId = -1;
|
mVideoStreamId = -1;
|
||||||
mAudioStreamId = -1;
|
mAudioStreamId = -1;
|
||||||
Info( "Priming capture from %s", mPath.c_str() );
|
Info( "Priming capture from %s", mPath.c_str() );
|
||||||
|
@ -435,6 +431,10 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" );
|
Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" );
|
||||||
#endif // HAVE_LIBSWSCALE
|
#endif // HAVE_LIBSWSCALE
|
||||||
|
|
||||||
|
if ( mVideoCodecContext->width != width || mVideoCodecContext->height != height ) {
|
||||||
|
Warning( "Monitor dimensions are %dx%d but camera is sending %dx%d", width, height, mVideoCodecContext->width, mVideoCodecContext->height );
|
||||||
|
}
|
||||||
|
|
||||||
mCanCapture = true;
|
mCanCapture = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -676,16 +676,22 @@ Debug(5, "After av_read_frame (%d)", ret );
|
||||||
videoStore = NULL;
|
videoStore = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Buffer video packets, since we are not recording. All audio packets are keyframes, so only if it's a video keyframe
|
// Buffer video packets, since we are not recording.
|
||||||
|
// All audio packets are keyframes, so only if it's a video keyframe
|
||||||
if ( packet.stream_index == mVideoStreamId) {
|
if ( packet.stream_index == mVideoStreamId) {
|
||||||
if ( key_frame ) {
|
if ( key_frame ) {
|
||||||
Debug(3, "Clearing queue");
|
Debug(3, "Clearing queue");
|
||||||
packetqueue.clearQueue();
|
packetqueue.clearQueue();
|
||||||
}
|
}
|
||||||
if ( packet.pts && video_last_pts > packet.pts ) {
|
#if 0
|
||||||
Warning( "Clearing queue due to out of order pts packet.pts=%d video_last_pts=%d", packet.pts, video_last_pts );
|
// Not sure this is valid. While a camera will PROBABLY always have an increasing pts... it doesn't have to.
|
||||||
|
// Also, I think there are integer wrap-around issues.
|
||||||
|
|
||||||
|
else if ( packet.pts && video_last_pts > packet.pts ) {
|
||||||
|
Warning( "Clearing queue due to out of order pts packet.pts(%d) < video_last_pts(%d)");
|
||||||
packetqueue.clearQueue();
|
packetqueue.clearQueue();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -708,7 +714,7 @@ Debug(5, "After av_read_frame (%d)", ret );
|
||||||
}
|
}
|
||||||
Debug(4, "about to decode video" );
|
Debug(4, "about to decode video" );
|
||||||
|
|
||||||
#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0)
|
#if LIBAVCODEC_VERSION_CHECK(58, 0, 0, 0, 0)
|
||||||
ret = avcodec_send_packet( mVideoCodecContext, &packet );
|
ret = avcodec_send_packet( mVideoCodecContext, &packet );
|
||||||
if ( ret < 0 ) {
|
if ( ret < 0 ) {
|
||||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||||
|
@ -779,7 +785,7 @@ Debug(5, "After av_read_frame (%d)", ret );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if LIBAVUTIL_VERSION_CHECK(54, 23, 0, 23, 0)
|
#if LIBAVUTIL_VERSION_CHECK(56, 23, 0, 23, 0)
|
||||||
Debug( 3, "Some other stream index %d, %s", packet.stream_index, av_get_media_type_string( mFormatContext->streams[packet.stream_index]->codecpar->codec_type) );
|
Debug( 3, "Some other stream index %d, %s", packet.stream_index, av_get_media_type_string( mFormatContext->streams[packet.stream_index]->codecpar->codec_type) );
|
||||||
#else
|
#else
|
||||||
Debug( 3, "Some other stream index %d", packet.stream_index );
|
Debug( 3, "Some other stream index %d", packet.stream_index );
|
||||||
|
|
1419
src/zm_image.cpp
1419
src/zm_image.cpp
File diff suppressed because it is too large
Load Diff
|
@ -122,8 +122,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { CHAR_HEIGHT=11, CHAR_WIDTH=6 };
|
enum { ZM_CHAR_HEIGHT=11, ZM_CHAR_WIDTH=6 };
|
||||||
enum { LINE_HEIGHT=CHAR_HEIGHT+0 };
|
enum { LINE_HEIGHT=ZM_CHAR_HEIGHT+0 };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static bool initialised;
|
static bool initialised;
|
||||||
|
@ -264,6 +264,7 @@ public:
|
||||||
/* Blend functions */
|
/* Blend functions */
|
||||||
void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent);
|
void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent);
|
||||||
void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent);
|
void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent);
|
||||||
|
void neon32_armv7_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent);
|
||||||
void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent);
|
void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent);
|
||||||
|
|
||||||
/* Delta functions */
|
/* Delta functions */
|
||||||
|
@ -274,6 +275,11 @@ void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result,
|
||||||
void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void neon32_armv7_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void neon32_armv7_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void neon32_armv7_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void neon32_armv7_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
void neon32_armv7_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
void sse2_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void sse2_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
void sse2_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void sse2_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
void sse2_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
void sse2_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||||
|
@ -293,6 +299,9 @@ void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long
|
||||||
void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void ssse3_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void ssse3_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
void ssse3_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void ssse3_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void ssse3_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void zm_convert_yuyv_rgb(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void zm_convert_yuyv_rgb(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
void zm_convert_yuyv_rgba(const uint8_t* col1, uint8_t* result, unsigned long count);
|
void zm_convert_yuyv_rgba(const uint8_t* col1, uint8_t* result, unsigned long count);
|
||||||
|
@ -309,8 +318,3 @@ void std_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int thre
|
||||||
void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
||||||
void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
||||||
void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
||||||
void ssse3_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
|
||||||
void ssse3_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
|
||||||
void ssse3_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
|
||||||
void ssse3_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
|
||||||
void ssse3_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height);
|
|
||||||
|
|
|
@ -638,6 +638,7 @@ Monitor::~Monitor() {
|
||||||
close( map_fd );
|
close( map_fd );
|
||||||
|
|
||||||
if ( purpose == CAPTURE ) {
|
if ( purpose == CAPTURE ) {
|
||||||
|
// How about we store this in the object on instantiation so that we don't have to do this again.
|
||||||
char mmap_path[PATH_MAX] = "";
|
char mmap_path[PATH_MAX] = "";
|
||||||
snprintf( mmap_path, sizeof(mmap_path), "%s/zm.mmap.%d", config.path_map, id );
|
snprintf( mmap_path, sizeof(mmap_path), "%s/zm.mmap.%d", config.path_map, id );
|
||||||
|
|
||||||
|
@ -1380,7 +1381,8 @@ bool Monitor::Analyse() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end if section_length
|
} // end if section_length
|
||||||
if ( !event ) {
|
|
||||||
|
if ( ! event ) {
|
||||||
|
|
||||||
// Create event
|
// Create event
|
||||||
event = new Event( this, *timestamp, "Continuous", noteSetMap, videoRecording );
|
event = new Event( this, *timestamp, "Continuous", noteSetMap, videoRecording );
|
||||||
|
@ -1443,7 +1445,7 @@ bool Monitor::Analyse() {
|
||||||
}
|
}
|
||||||
event->AddFrames( pre_event_images, images, timestamps );
|
event->AddFrames( pre_event_images, images, timestamps );
|
||||||
}
|
}
|
||||||
}
|
} // end if false or config.overlap_timed_events
|
||||||
} // end if ! event
|
} // end if ! event
|
||||||
}
|
}
|
||||||
if ( score ) {
|
if ( score ) {
|
||||||
|
@ -1619,7 +1621,8 @@ bool Monitor::Analyse() {
|
||||||
}
|
}
|
||||||
shared_data->state = state = IDLE;
|
shared_data->state = state = IDLE;
|
||||||
last_section_mod = 0;
|
last_section_mod = 0;
|
||||||
}
|
} // end if ( trigger_data->trigger_state != TRIGGER_OFF )
|
||||||
|
|
||||||
if ( (!signal_change && signal) && (function == MODECT || function == MOCORD) ) {
|
if ( (!signal_change && signal) && (function == MODECT || function == MOCORD) ) {
|
||||||
if ( state == ALARM ) {
|
if ( state == ALARM ) {
|
||||||
ref_image.Blend( *snap_image, alarm_ref_blend_perc );
|
ref_image.Blend( *snap_image, alarm_ref_blend_perc );
|
||||||
|
@ -1628,9 +1631,9 @@ bool Monitor::Analyse() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_signal = signal;
|
last_signal = signal;
|
||||||
}
|
} // end if Enabled()
|
||||||
|
|
||||||
shared_data->last_read_index = index%image_buffer_count;
|
shared_data->last_read_index = index % image_buffer_count;
|
||||||
//shared_data->last_read_time = image_buffer[index].timestamp->tv_sec;
|
//shared_data->last_read_time = image_buffer[index].timestamp->tv_sec;
|
||||||
shared_data->last_read_time = now.tv_sec;
|
shared_data->last_read_time = now.tv_sec;
|
||||||
|
|
||||||
|
@ -3235,782 +3238,6 @@ bool Monitor::DumpSettings( char *output, bool verbose ) {
|
||||||
return( true );
|
return( true );
|
||||||
} // bool Monitor::DumpSettings( char *output, bool verbose )
|
} // bool Monitor::DumpSettings( char *output, bool verbose )
|
||||||
|
|
||||||
bool MonitorStream::checkSwapPath( const char *path, bool create_path ) {
|
|
||||||
uid_t uid = getuid();
|
|
||||||
gid_t gid = getgid();
|
|
||||||
|
|
||||||
struct stat stat_buf;
|
|
||||||
if ( stat( path, &stat_buf ) < 0 ) {
|
|
||||||
if ( create_path && errno == ENOENT ) {
|
|
||||||
Debug( 3, "Swap path '%s' missing, creating", path );
|
|
||||||
if ( mkdir( path, 0755 ) ) {
|
|
||||||
Error( "Can't mkdir %s: %s", path, strerror(errno));
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
if ( stat( path, &stat_buf ) < 0 ) {
|
|
||||||
Error( "Can't stat '%s': %s", path, strerror(errno) );
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Error( "Can't stat '%s': %s", path, strerror(errno) );
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( !S_ISDIR(stat_buf.st_mode) ) {
|
|
||||||
Error( "Swap image path '%s' is not a directory", path );
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
mode_t mask = 0;
|
|
||||||
if ( uid == stat_buf.st_uid ) {
|
|
||||||
// If we are the owner
|
|
||||||
mask = 00700;
|
|
||||||
} else if ( gid == stat_buf.st_gid ) {
|
|
||||||
// If we are in the owner group
|
|
||||||
mask = 00070;
|
|
||||||
} else {
|
|
||||||
// We are neither the owner nor in the group
|
|
||||||
mask = 00007;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (stat_buf.st_mode & mask) != mask ) {
|
|
||||||
Error( "Insufficient permissions on swap image path '%s'", path );
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
return( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|
||||||
Debug( 2, "Got message, type %d, msg %d", msg->msg_type, msg->msg_data[0] );
|
|
||||||
// Check for incoming command
|
|
||||||
switch( (MsgCommand)msg->msg_data[0] ) {
|
|
||||||
case CMD_PAUSE :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got PAUSE command" );
|
|
||||||
|
|
||||||
// Set paused flag
|
|
||||||
paused = true;
|
|
||||||
// Set delayed flag
|
|
||||||
delayed = true;
|
|
||||||
last_frame_sent = TV_2_FLOAT( now );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_PLAY :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got PLAY command" );
|
|
||||||
if ( paused ) {
|
|
||||||
// Clear paused flag
|
|
||||||
paused = false;
|
|
||||||
// Set delayed_play flag
|
|
||||||
delayed = true;
|
|
||||||
}
|
|
||||||
replay_rate = ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_VARPLAY :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got VARPLAY command" );
|
|
||||||
if ( paused ) {
|
|
||||||
// Clear paused flag
|
|
||||||
paused = false;
|
|
||||||
// Set delayed_play flag
|
|
||||||
delayed = true;
|
|
||||||
}
|
|
||||||
replay_rate = ntohs(((unsigned char)msg->msg_data[2]<<8)|(unsigned char)msg->msg_data[1])-32768;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_STOP :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got STOP command" );
|
|
||||||
|
|
||||||
// Clear paused flag
|
|
||||||
paused = false;
|
|
||||||
// Clear delayed_play flag
|
|
||||||
delayed = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_FASTFWD :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got FAST FWD command" );
|
|
||||||
if ( paused ) {
|
|
||||||
// Clear paused flag
|
|
||||||
paused = false;
|
|
||||||
// Set delayed_play flag
|
|
||||||
delayed = true;
|
|
||||||
}
|
|
||||||
// Set play rate
|
|
||||||
switch ( replay_rate )
|
|
||||||
{
|
|
||||||
case 2 * ZM_RATE_BASE :
|
|
||||||
replay_rate = 5 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
case 5 * ZM_RATE_BASE :
|
|
||||||
replay_rate = 10 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
case 10 * ZM_RATE_BASE :
|
|
||||||
replay_rate = 25 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
case 25 * ZM_RATE_BASE :
|
|
||||||
case 50 * ZM_RATE_BASE :
|
|
||||||
replay_rate = 50 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
replay_rate = 2 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_SLOWFWD :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got SLOW FWD command" );
|
|
||||||
// Set paused flag
|
|
||||||
paused = true;
|
|
||||||
// Set delayed flag
|
|
||||||
delayed = true;
|
|
||||||
// Set play rate
|
|
||||||
replay_rate = ZM_RATE_BASE;
|
|
||||||
// Set step
|
|
||||||
step = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_SLOWREV :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got SLOW REV command" );
|
|
||||||
// Set paused flag
|
|
||||||
paused = true;
|
|
||||||
// Set delayed flag
|
|
||||||
delayed = true;
|
|
||||||
// Set play rate
|
|
||||||
replay_rate = ZM_RATE_BASE;
|
|
||||||
// Set step
|
|
||||||
step = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_FASTREV :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got FAST REV command" );
|
|
||||||
if ( paused ) {
|
|
||||||
// Clear paused flag
|
|
||||||
paused = false;
|
|
||||||
// Set delayed_play flag
|
|
||||||
delayed = true;
|
|
||||||
}
|
|
||||||
// Set play rate
|
|
||||||
switch ( replay_rate ) {
|
|
||||||
case -2 * ZM_RATE_BASE :
|
|
||||||
replay_rate = -5 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
case -5 * ZM_RATE_BASE :
|
|
||||||
replay_rate = -10 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
case -10 * ZM_RATE_BASE :
|
|
||||||
replay_rate = -25 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
case -25 * ZM_RATE_BASE :
|
|
||||||
case -50 * ZM_RATE_BASE :
|
|
||||||
replay_rate = -50 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
replay_rate = -2 * ZM_RATE_BASE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_ZOOMIN :
|
|
||||||
{
|
|
||||||
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
|
||||||
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
|
||||||
Debug( 1, "Got ZOOM IN command, to %d,%d", x, y );
|
|
||||||
switch ( zoom ) {
|
|
||||||
case 100:
|
|
||||||
zoom = 150;
|
|
||||||
break;
|
|
||||||
case 150:
|
|
||||||
zoom = 200;
|
|
||||||
break;
|
|
||||||
case 200:
|
|
||||||
zoom = 300;
|
|
||||||
break;
|
|
||||||
case 300:
|
|
||||||
zoom = 400;
|
|
||||||
break;
|
|
||||||
case 400:
|
|
||||||
default :
|
|
||||||
zoom = 500;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_ZOOMOUT :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got ZOOM OUT command" );
|
|
||||||
switch ( zoom ) {
|
|
||||||
case 500:
|
|
||||||
zoom = 400;
|
|
||||||
break;
|
|
||||||
case 400:
|
|
||||||
zoom = 300;
|
|
||||||
break;
|
|
||||||
case 300:
|
|
||||||
zoom = 200;
|
|
||||||
break;
|
|
||||||
case 200:
|
|
||||||
zoom = 150;
|
|
||||||
break;
|
|
||||||
case 150:
|
|
||||||
default :
|
|
||||||
zoom = 100;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_PAN :
|
|
||||||
{
|
|
||||||
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
|
||||||
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
|
||||||
Debug( 1, "Got PAN command, to %d,%d", x, y );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_SCALE :
|
|
||||||
{
|
|
||||||
scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
|
||||||
Debug( 1, "Got SCALE command, to %d", scale );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_QUIT :
|
|
||||||
{
|
|
||||||
Info ("User initiated exit - CMD_QUIT");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_QUERY :
|
|
||||||
{
|
|
||||||
Debug( 1, "Got QUERY command, sending STATUS" );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default :
|
|
||||||
{
|
|
||||||
Error( "Got unexpected command %d", msg->msg_data[0] );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct {
|
|
||||||
int id;
|
|
||||||
int state;
|
|
||||||
double fps;
|
|
||||||
int buffer_level;
|
|
||||||
int rate;
|
|
||||||
double delay;
|
|
||||||
int zoom;
|
|
||||||
bool delayed;
|
|
||||||
bool paused;
|
|
||||||
bool enabled;
|
|
||||||
bool forced;
|
|
||||||
} status_data;
|
|
||||||
|
|
||||||
status_data.id = monitor->Id();
|
|
||||||
status_data.fps = monitor->GetFPS();
|
|
||||||
status_data.state = monitor->shared_data->state;
|
|
||||||
if ( playback_buffer > 0 )
|
|
||||||
status_data.buffer_level = (MOD_ADD( (temp_write_index-temp_read_index), 0, temp_image_buffer_count )*100)/temp_image_buffer_count;
|
|
||||||
else
|
|
||||||
status_data.buffer_level = 0;
|
|
||||||
status_data.delayed = delayed;
|
|
||||||
status_data.paused = paused;
|
|
||||||
status_data.rate = replay_rate;
|
|
||||||
status_data.delay = TV_2_FLOAT( now ) - TV_2_FLOAT( last_frame_timestamp );
|
|
||||||
status_data.zoom = zoom;
|
|
||||||
//status_data.enabled = monitor->shared_data->active;
|
|
||||||
status_data.enabled = monitor->trigger_data->trigger_state!=Monitor::TRIGGER_OFF;
|
|
||||||
status_data.forced = monitor->trigger_data->trigger_state==Monitor::TRIGGER_ON;
|
|
||||||
Debug( 2, "L:%d, D:%d, P:%d, R:%d, d:%.3f, Z:%d, E:%d F:%d",
|
|
||||||
status_data.buffer_level,
|
|
||||||
status_data.delayed,
|
|
||||||
status_data.paused,
|
|
||||||
status_data.rate,
|
|
||||||
status_data.delay,
|
|
||||||
status_data.zoom,
|
|
||||||
status_data.enabled,
|
|
||||||
status_data.forced
|
|
||||||
);
|
|
||||||
|
|
||||||
DataMsg status_msg;
|
|
||||||
status_msg.msg_type = MSG_DATA_WATCH;
|
|
||||||
memcpy( &status_msg.msg_data, &status_data, sizeof(status_data) );
|
|
||||||
int nbytes = 0;
|
|
||||||
if ( (nbytes = sendto( sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr) )) < 0 ) {
|
|
||||||
//if ( errno != EAGAIN )
|
|
||||||
{
|
|
||||||
Error( "Can't sendto on sd %d: %s", sd, strerror(errno) );
|
|
||||||
//exit( -1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// quit after sending a status, if this was a quit request
|
|
||||||
if ((MsgCommand)msg->msg_data[0]==CMD_QUIT)
|
|
||||||
exit(0);
|
|
||||||
|
|
||||||
updateFrameRate( monitor->GetFPS() );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MonitorStream::sendFrame( const char *filepath, struct timeval *timestamp ) {
|
|
||||||
bool send_raw = ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE));
|
|
||||||
|
|
||||||
if ( type != STREAM_JPEG )
|
|
||||||
send_raw = false;
|
|
||||||
if ( !config.timestamp_on_capture && timestamp )
|
|
||||||
send_raw = false;
|
|
||||||
|
|
||||||
if ( !send_raw ) {
|
|
||||||
Image temp_image( filepath );
|
|
||||||
|
|
||||||
return( sendFrame( &temp_image, timestamp ) );
|
|
||||||
} else {
|
|
||||||
int img_buffer_size = 0;
|
|
||||||
static unsigned char img_buffer[ZM_MAX_IMAGE_SIZE];
|
|
||||||
|
|
||||||
FILE *fdj = NULL;
|
|
||||||
if ( (fdj = fopen( filepath, "r" )) ) {
|
|
||||||
img_buffer_size = fread( img_buffer, 1, sizeof(img_buffer), fdj );
|
|
||||||
fclose( fdj );
|
|
||||||
} else {
|
|
||||||
Error( "Can't open %s: %s", filepath, strerror(errno) );
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate how long it takes to actually send the frame
|
|
||||||
struct timeval frameStartTime;
|
|
||||||
gettimeofday( &frameStartTime, NULL );
|
|
||||||
|
|
||||||
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
|
||||||
fprintf( stdout, "Content-Length: %d\r\n", img_buffer_size );
|
|
||||||
fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
|
|
||||||
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
|
|
||||||
if ( !zm_terminate )
|
|
||||||
Error( "Unable to send stream frame: %s", strerror(errno) );
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
fprintf( stdout, "\r\n\r\n" );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
struct timeval frameEndTime;
|
|
||||||
gettimeofday( &frameEndTime, NULL );
|
|
||||||
|
|
||||||
int frameSendTime = tvDiffMsec( frameStartTime, frameEndTime );
|
|
||||||
if ( frameSendTime > 1000/maxfps ) {
|
|
||||||
maxfps /= 2;
|
|
||||||
Error( "Frame send time %d msec too slow, throttling maxfps to %.2f", frameSendTime, maxfps );
|
|
||||||
}
|
|
||||||
|
|
||||||
last_frame_sent = TV_2_FLOAT( now );
|
|
||||||
|
|
||||||
return( true );
|
|
||||||
}
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MonitorStream::sendFrame( Image *image, struct timeval *timestamp ) {
|
|
||||||
Image *send_image = prepareImage( image );
|
|
||||||
if ( !config.timestamp_on_capture && timestamp )
|
|
||||||
monitor->TimestampImage( send_image, timestamp );
|
|
||||||
|
|
||||||
#if HAVE_LIBAVCODEC
|
|
||||||
if ( type == STREAM_MPEG ) {
|
|
||||||
if ( !vid_stream ) {
|
|
||||||
vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->SubpixelOrder(), send_image->Width(), send_image->Height() );
|
|
||||||
fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() );
|
|
||||||
vid_stream->OpenStream();
|
|
||||||
}
|
|
||||||
static struct timeval base_time;
|
|
||||||
struct DeltaTimeval delta_time;
|
|
||||||
if ( !frame_count )
|
|
||||||
base_time = *timestamp;
|
|
||||||
DELTA_TIMEVAL( delta_time, *timestamp, base_time, DT_PREC_3 );
|
|
||||||
/* double pts = */ vid_stream->EncodeFrame( send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_time.delta );
|
|
||||||
} else
|
|
||||||
#endif // HAVE_LIBAVCODEC
|
|
||||||
{
|
|
||||||
static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE];
|
|
||||||
|
|
||||||
int img_buffer_size = 0;
|
|
||||||
unsigned char *img_buffer = temp_img_buffer;
|
|
||||||
|
|
||||||
// Calculate how long it takes to actually send the frame
|
|
||||||
struct timeval frameStartTime;
|
|
||||||
gettimeofday( &frameStartTime, NULL );
|
|
||||||
|
|
||||||
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
|
||||||
switch( type ) {
|
|
||||||
case STREAM_JPEG :
|
|
||||||
send_image->EncodeJpeg( img_buffer, &img_buffer_size );
|
|
||||||
fprintf( stdout, "Content-Type: image/jpeg\r\n" );
|
|
||||||
break;
|
|
||||||
case STREAM_RAW :
|
|
||||||
fprintf( stdout, "Content-Type: image/x-rgb\r\n" );
|
|
||||||
img_buffer = (uint8_t*)send_image->Buffer();
|
|
||||||
img_buffer_size = send_image->Size();
|
|
||||||
break;
|
|
||||||
case STREAM_ZIP :
|
|
||||||
fprintf( stdout, "Content-Type: image/x-rgbz\r\n" );
|
|
||||||
unsigned long zip_buffer_size;
|
|
||||||
send_image->Zip( img_buffer, &zip_buffer_size );
|
|
||||||
img_buffer_size = zip_buffer_size;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
Fatal( "Unexpected frame type %d", type );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size );
|
|
||||||
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
|
|
||||||
if ( !zm_terminate )
|
|
||||||
Error( "Unable to send stream frame: %s", strerror(errno) );
|
|
||||||
return( false );
|
|
||||||
}
|
|
||||||
fprintf( stdout, "\r\n\r\n" );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
struct timeval frameEndTime;
|
|
||||||
gettimeofday( &frameEndTime, NULL );
|
|
||||||
|
|
||||||
int frameSendTime = tvDiffMsec( frameStartTime, frameEndTime );
|
|
||||||
if ( frameSendTime > 1000/maxfps ) {
|
|
||||||
maxfps /= 1.5;
|
|
||||||
Error( "Frame send time %d msec too slow, throttling maxfps to %.2f", frameSendTime, maxfps );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
last_frame_sent = TV_2_FLOAT( now );
|
|
||||||
return( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
void MonitorStream::runStream() {
|
|
||||||
if ( type == STREAM_SINGLE ) {
|
|
||||||
// Not yet migrated over to stream class
|
|
||||||
monitor->SingleImage( scale );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
openComms();
|
|
||||||
|
|
||||||
checkInitialised();
|
|
||||||
|
|
||||||
updateFrameRate( monitor->GetFPS() );
|
|
||||||
|
|
||||||
if ( type == STREAM_JPEG )
|
|
||||||
fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
|
|
||||||
|
|
||||||
int last_read_index = monitor->image_buffer_count;
|
|
||||||
|
|
||||||
time_t stream_start_time;
|
|
||||||
time( &stream_start_time );
|
|
||||||
|
|
||||||
frame_count = 0;
|
|
||||||
|
|
||||||
temp_image_buffer = 0;
|
|
||||||
temp_image_buffer_count = playback_buffer;
|
|
||||||
temp_read_index = temp_image_buffer_count;
|
|
||||||
temp_write_index = temp_image_buffer_count;
|
|
||||||
|
|
||||||
char *swap_path = 0;
|
|
||||||
bool buffered_playback = false;
|
|
||||||
|
|
||||||
// 15 is the max length for the swap path suffix, /zmswap-whatever, assuming max 6 digits for monitor id
|
|
||||||
const int max_swap_len_suffix = 15;
|
|
||||||
|
|
||||||
int swap_path_length = strlen(config.path_swap) + 1; // +1 for NULL terminator
|
|
||||||
int subfolder1_length = snprintf(NULL, 0, "/zmswap-m%d", monitor->Id() ) + 1;
|
|
||||||
int subfolder2_length = snprintf(NULL, 0, "/zmswap-q%06d", connkey ) + 1;
|
|
||||||
int total_swap_path_length = swap_path_length + subfolder1_length + subfolder2_length;
|
|
||||||
|
|
||||||
if ( connkey && playback_buffer > 0 ) {
|
|
||||||
|
|
||||||
if ( total_swap_path_length + max_swap_len_suffix > PATH_MAX ) {
|
|
||||||
Error( "Swap Path is too long. %d > %d ", total_swap_path_length+max_swap_len_suffix, PATH_MAX );
|
|
||||||
} else {
|
|
||||||
swap_path = (char *)malloc( total_swap_path_length+max_swap_len_suffix );
|
|
||||||
strncpy( swap_path, config.path_swap, swap_path_length );
|
|
||||||
|
|
||||||
Debug( 3, "Checking swap path folder: %s", swap_path );
|
|
||||||
if ( checkSwapPath( swap_path, false ) ) {
|
|
||||||
// Append the subfolder name /zmswap-m{monitor-id} to the end of swap_path
|
|
||||||
int ndx = swap_path_length - 1; // Array index of the NULL terminator
|
|
||||||
snprintf( &(swap_path[ndx]), subfolder1_length, "/zmswap-m%d", monitor->Id() );
|
|
||||||
|
|
||||||
Debug( 4, "Checking swap path subfolder: %s", swap_path );
|
|
||||||
if ( checkSwapPath( swap_path, true ) ) {
|
|
||||||
// Append the subfolder name /zmswap-q{connection key} to the end of swap_path
|
|
||||||
ndx = swap_path_length+subfolder1_length - 2; // Array index of the NULL terminator
|
|
||||||
snprintf( &(swap_path[ndx]), subfolder2_length, "/zmswap-q%06d", connkey );
|
|
||||||
|
|
||||||
Debug( 4, "Checking swap path subfolder: %s", swap_path );
|
|
||||||
if ( checkSwapPath( swap_path, true ) ) {
|
|
||||||
buffered_playback = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !buffered_playback ) {
|
|
||||||
Error( "Unable to validate swap image path, disabling buffered playback" );
|
|
||||||
} else {
|
|
||||||
Debug( 2, "Assigning temporary buffer" );
|
|
||||||
temp_image_buffer = new SwapImage[temp_image_buffer_count];
|
|
||||||
memset( temp_image_buffer, 0, sizeof(*temp_image_buffer)*temp_image_buffer_count );
|
|
||||||
Debug( 2, "Assigned temporary buffer" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float max_secs_since_last_sent_frame = 10.0; //should be > keep alive amount (5 secs)
|
|
||||||
while ( !zm_terminate ) {
|
|
||||||
bool got_command = false;
|
|
||||||
if ( feof( stdout ) || ferror( stdout ) || !monitor->ShmValid() ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
gettimeofday( &now, NULL );
|
|
||||||
|
|
||||||
if ( connkey ) {
|
|
||||||
while(checkCommandQueue()) {
|
|
||||||
got_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//bool frame_sent = false;
|
|
||||||
if ( buffered_playback && delayed ) {
|
|
||||||
if ( temp_read_index == temp_write_index ) {
|
|
||||||
// Go back to live viewing
|
|
||||||
Debug( 1, "Exceeded temporary streaming buffer" );
|
|
||||||
// Clear paused flag
|
|
||||||
paused = false;
|
|
||||||
// Clear delayed_play flag
|
|
||||||
delayed = false;
|
|
||||||
replay_rate = ZM_RATE_BASE;
|
|
||||||
} else {
|
|
||||||
if ( !paused ) {
|
|
||||||
int temp_index = MOD_ADD( temp_read_index, 0, temp_image_buffer_count );
|
|
||||||
//Debug( 3, "tri: %d, ti: %d", temp_read_index, temp_index );
|
|
||||||
SwapImage *swap_image = &temp_image_buffer[temp_index];
|
|
||||||
|
|
||||||
if ( !swap_image->valid ) {
|
|
||||||
paused = true;
|
|
||||||
delayed = true;
|
|
||||||
temp_read_index = MOD_ADD( temp_read_index, (replay_rate>=0?-1:1), temp_image_buffer_count );
|
|
||||||
} else {
|
|
||||||
//Debug( 3, "siT: %f, lfT: %f", TV_2_FLOAT( swap_image->timestamp ), TV_2_FLOAT( last_frame_timestamp ) );
|
|
||||||
double expected_delta_time = ((TV_2_FLOAT( swap_image->timestamp ) - TV_2_FLOAT( last_frame_timestamp )) * ZM_RATE_BASE)/replay_rate;
|
|
||||||
double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent;
|
|
||||||
|
|
||||||
//Debug( 3, "eDT: %.3lf, aDT: %.3f, lFS:%.3f, NOW:%.3f", expected_delta_time, actual_delta_time, last_frame_sent, TV_2_FLOAT( now ) );
|
|
||||||
// If the next frame is due
|
|
||||||
if ( actual_delta_time > expected_delta_time ) {
|
|
||||||
//Debug( 2, "eDT: %.3lf, aDT: %.3f", expected_delta_time, actual_delta_time );
|
|
||||||
if ( temp_index%frame_mod == 0 ) {
|
|
||||||
Debug( 2, "Sending delayed frame %d", temp_index );
|
|
||||||
// Send the next frame
|
|
||||||
if ( !sendFrame( temp_image_buffer[temp_index].file_name, &temp_image_buffer[temp_index].timestamp ) )
|
|
||||||
zm_terminate = true;
|
|
||||||
memcpy( &last_frame_timestamp, &(swap_image->timestamp), sizeof(last_frame_timestamp) );
|
|
||||||
//frame_sent = true;
|
|
||||||
}
|
|
||||||
temp_read_index = MOD_ADD( temp_read_index, (replay_rate>0?1:-1), temp_image_buffer_count );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ( step != 0 ) {
|
|
||||||
temp_read_index = MOD_ADD( temp_read_index, (step>0?1:-1), temp_image_buffer_count );
|
|
||||||
|
|
||||||
SwapImage *swap_image = &temp_image_buffer[temp_read_index];
|
|
||||||
|
|
||||||
// Send the next frame
|
|
||||||
if ( !sendFrame( temp_image_buffer[temp_read_index].file_name, &temp_image_buffer[temp_read_index].timestamp ) )
|
|
||||||
zm_terminate = true;
|
|
||||||
memcpy( &last_frame_timestamp, &(swap_image->timestamp), sizeof(last_frame_timestamp) );
|
|
||||||
//frame_sent = true;
|
|
||||||
step = 0;
|
|
||||||
} else {
|
|
||||||
int temp_index = MOD_ADD( temp_read_index, 0, temp_image_buffer_count );
|
|
||||||
|
|
||||||
double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent;
|
|
||||||
if ( got_command || actual_delta_time > 5 ) {
|
|
||||||
// Send keepalive
|
|
||||||
Debug( 2, "Sending keepalive frame %d", temp_index );
|
|
||||||
// Send the next frame
|
|
||||||
if ( !sendFrame( temp_image_buffer[temp_index].file_name, &temp_image_buffer[temp_index].timestamp ) )
|
|
||||||
zm_terminate = true;
|
|
||||||
//frame_sent = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( temp_read_index == temp_write_index ) {
|
|
||||||
// Go back to live viewing
|
|
||||||
Warning( "Rewound over write index, resuming live play" );
|
|
||||||
// Clear paused flag
|
|
||||||
paused = false;
|
|
||||||
// Clear delayed_play flag
|
|
||||||
delayed = false;
|
|
||||||
replay_rate = ZM_RATE_BASE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( (unsigned int)last_read_index != monitor->shared_data->last_write_index ) {
|
|
||||||
int index = monitor->shared_data->last_write_index%monitor->image_buffer_count;
|
|
||||||
last_read_index = monitor->shared_data->last_write_index;
|
|
||||||
//Debug( 1, "%d: %x - %x", index, image_buffer[index].image, image_buffer[index].image->buffer );
|
|
||||||
if ( (frame_mod == 1) || ((frame_count%frame_mod) == 0) ) {
|
|
||||||
if ( !paused && !delayed ) {
|
|
||||||
// Send the next frame
|
|
||||||
Monitor::Snapshot *snap = &monitor->image_buffer[index];
|
|
||||||
|
|
||||||
if ( !sendFrame( snap->image, snap->timestamp ) )
|
|
||||||
zm_terminate = true;
|
|
||||||
memcpy( &last_frame_timestamp, snap->timestamp, sizeof(last_frame_timestamp) );
|
|
||||||
//frame_sent = true;
|
|
||||||
|
|
||||||
temp_read_index = temp_write_index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( buffered_playback ) {
|
|
||||||
if ( monitor->shared_data->valid ) {
|
|
||||||
if ( monitor->image_buffer[index].timestamp->tv_sec ) {
|
|
||||||
int temp_index = temp_write_index%temp_image_buffer_count;
|
|
||||||
Debug( 2, "Storing frame %d", temp_index );
|
|
||||||
if ( !temp_image_buffer[temp_index].valid ) {
|
|
||||||
snprintf( temp_image_buffer[temp_index].file_name, sizeof(temp_image_buffer[0].file_name), "%s/zmswap-i%05d.jpg", swap_path, temp_index );
|
|
||||||
temp_image_buffer[temp_index].valid = true;
|
|
||||||
}
|
|
||||||
memcpy( &(temp_image_buffer[temp_index].timestamp), monitor->image_buffer[index].timestamp, sizeof(temp_image_buffer[0].timestamp) );
|
|
||||||
monitor->image_buffer[index].image->WriteJpeg( temp_image_buffer[temp_index].file_name, config.jpeg_file_quality );
|
|
||||||
temp_write_index = MOD_ADD( temp_write_index, 1, temp_image_buffer_count );
|
|
||||||
if ( temp_write_index == temp_read_index ) {
|
|
||||||
// Go back to live viewing
|
|
||||||
Warning( "Exceeded temporary buffer, resuming live play" );
|
|
||||||
// Clear paused flag
|
|
||||||
paused = false;
|
|
||||||
// Clear delayed_play flag
|
|
||||||
delayed = false;
|
|
||||||
replay_rate = ZM_RATE_BASE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Warning( "Unable to store frame as timestamp invalid" );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Warning( "Unable to store frame as shared memory invalid" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
frame_count++;
|
|
||||||
}
|
|
||||||
usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) );
|
|
||||||
if ( ttl ) {
|
|
||||||
if ( (now.tv_sec - stream_start_time) > ttl ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( (TV_2_FLOAT( now ) - last_frame_sent) > max_secs_since_last_sent_frame ) {
|
|
||||||
Error( "Terminating, last frame sent time %f secs more than maximum of %f", TV_2_FLOAT( now ) - last_frame_sent, max_secs_since_last_sent_frame );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( buffered_playback ) {
|
|
||||||
Debug( 1, "Cleaning swap files from %s", swap_path );
|
|
||||||
struct stat stat_buf;
|
|
||||||
if ( stat( swap_path, &stat_buf ) < 0 ) {
|
|
||||||
if ( errno != ENOENT ) {
|
|
||||||
Error( "Can't stat '%s': %s", swap_path, strerror(errno) );
|
|
||||||
}
|
|
||||||
} else if ( !S_ISDIR(stat_buf.st_mode) ) {
|
|
||||||
Error( "Swap image path '%s' is not a directory", swap_path );
|
|
||||||
} else {
|
|
||||||
char glob_pattern[PATH_MAX] = "";
|
|
||||||
|
|
||||||
snprintf( glob_pattern, sizeof(glob_pattern), "%s/*.*", swap_path );
|
|
||||||
glob_t pglob;
|
|
||||||
int glob_status = glob( glob_pattern, 0, 0, &pglob );
|
|
||||||
if ( glob_status != 0 ) {
|
|
||||||
if ( glob_status < 0 ) {
|
|
||||||
Error( "Can't glob '%s': %s", glob_pattern, strerror(errno) );
|
|
||||||
} else {
|
|
||||||
Debug( 1, "Can't glob '%s': %d", glob_pattern, glob_status );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for ( unsigned int i = 0; i < pglob.gl_pathc; i++ ) {
|
|
||||||
if ( unlink( pglob.gl_pathv[i] ) < 0 ) {
|
|
||||||
Error( "Can't unlink '%s': %s", pglob.gl_pathv[i], strerror(errno) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
globfree( &pglob );
|
|
||||||
if ( rmdir( swap_path ) < 0 ) {
|
|
||||||
Error( "Can't rmdir '%s': %s", swap_path, strerror(errno) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( swap_path ) free( swap_path );
|
|
||||||
closeComms();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Monitor::SingleImage( int scale) {
|
|
||||||
int img_buffer_size = 0;
|
|
||||||
static JOCTET img_buffer[ZM_MAX_IMAGE_SIZE];
|
|
||||||
Image scaled_image;
|
|
||||||
int index = shared_data->last_write_index%image_buffer_count;
|
|
||||||
Snapshot *snap = &image_buffer[index];
|
|
||||||
Image *snap_image = snap->image;
|
|
||||||
|
|
||||||
if ( scale != ZM_SCALE_BASE ) {
|
|
||||||
scaled_image.Assign( *snap_image );
|
|
||||||
scaled_image.Scale( scale );
|
|
||||||
snap_image = &scaled_image;
|
|
||||||
}
|
|
||||||
if ( !config.timestamp_on_capture ) {
|
|
||||||
TimestampImage( snap_image, snap->timestamp );
|
|
||||||
}
|
|
||||||
snap_image->EncodeJpeg( img_buffer, &img_buffer_size );
|
|
||||||
|
|
||||||
fprintf( stdout, "Content-Length: %d\r\n", img_buffer_size );
|
|
||||||
fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
|
|
||||||
fwrite( img_buffer, img_buffer_size, 1, stdout );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Monitor::SingleImageRaw( int scale) {
|
|
||||||
Image scaled_image;
|
|
||||||
int index = shared_data->last_write_index%image_buffer_count;
|
|
||||||
Snapshot *snap = &image_buffer[index];
|
|
||||||
Image *snap_image = snap->image;
|
|
||||||
|
|
||||||
if ( scale != ZM_SCALE_BASE ) {
|
|
||||||
scaled_image.Assign( *snap_image );
|
|
||||||
scaled_image.Scale( scale );
|
|
||||||
snap_image = &scaled_image;
|
|
||||||
}
|
|
||||||
if ( !config.timestamp_on_capture ) {
|
|
||||||
TimestampImage( snap_image, snap->timestamp );
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf( stdout, "Content-Length: %d\r\n", snap_image->Size() );
|
|
||||||
fprintf( stdout, "Content-Type: image/x-rgb\r\n\r\n" );
|
|
||||||
fwrite( snap_image->Buffer(), snap_image->Size(), 1, stdout );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Monitor::SingleImageZip( int scale) {
|
|
||||||
unsigned long img_buffer_size = 0;
|
|
||||||
static Bytef img_buffer[ZM_MAX_IMAGE_SIZE];
|
|
||||||
Image scaled_image;
|
|
||||||
int index = shared_data->last_write_index%image_buffer_count;
|
|
||||||
Snapshot *snap = &image_buffer[index];
|
|
||||||
Image *snap_image = snap->image;
|
|
||||||
|
|
||||||
if ( scale != ZM_SCALE_BASE ) {
|
|
||||||
scaled_image.Assign( *snap_image );
|
|
||||||
scaled_image.Scale( scale );
|
|
||||||
snap_image = &scaled_image;
|
|
||||||
}
|
|
||||||
if ( !config.timestamp_on_capture ) {
|
|
||||||
TimestampImage( snap_image, snap->timestamp );
|
|
||||||
}
|
|
||||||
snap_image->Zip( img_buffer, &img_buffer_size );
|
|
||||||
|
|
||||||
fprintf( stdout, "Content-Length: %ld\r\n", img_buffer_size );
|
|
||||||
fprintf( stdout, "Content-Type: image/x-rgbz\r\n\r\n" );
|
|
||||||
fwrite( img_buffer, img_buffer_size, 1, stdout );
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Monitor::Colours() const { return( camera->Colours() ); }
|
unsigned int Monitor::Colours() const { return( camera->Colours() ); }
|
||||||
unsigned int Monitor::SubpixelOrder() const { return( camera->SubpixelOrder() ); }
|
unsigned int Monitor::SubpixelOrder() const { return( camera->SubpixelOrder() ); }
|
||||||
int Monitor::PrimeCapture() {
|
int Monitor::PrimeCapture() {
|
||||||
|
@ -4023,3 +3250,7 @@ int Monitor::PostCapture() {
|
||||||
return( camera->PostCapture() );
|
return( camera->PostCapture() );
|
||||||
}
|
}
|
||||||
Monitor::Orientation Monitor::getOrientation() const { return orientation; }
|
Monitor::Orientation Monitor::getOrientation() const { return orientation; }
|
||||||
|
|
||||||
|
Monitor::Snapshot *Monitor::getSnapshot() {
|
||||||
|
return &image_buffer[ shared_data->last_write_index%image_buffer_count ];
|
||||||
|
}
|
||||||
|
|
|
@ -443,6 +443,7 @@ public:
|
||||||
|
|
||||||
State GetState() const;
|
State GetState() const;
|
||||||
int GetImage( int index=-1, int scale=100 );
|
int GetImage( int index=-1, int scale=100 );
|
||||||
|
Snapshot *getSnapshot();
|
||||||
struct timeval GetTimestamp( int index=-1 ) const;
|
struct timeval GetTimestamp( int index=-1 ) const;
|
||||||
void UpdateAdaptiveSkip();
|
void UpdateAdaptiveSkip();
|
||||||
useconds_t GetAnalysisRate();
|
useconds_t GetAnalysisRate();
|
||||||
|
@ -509,9 +510,6 @@ public:
|
||||||
//void StreamImages( int scale=100, int maxfps=10, time_t ttl=0, int msq_id=0 );
|
//void StreamImages( int scale=100, int maxfps=10, time_t ttl=0, int msq_id=0 );
|
||||||
//void StreamImagesRaw( int scale=100, int maxfps=10, time_t ttl=0 );
|
//void StreamImagesRaw( int scale=100, int maxfps=10, time_t ttl=0 );
|
||||||
//void StreamImagesZip( int scale=100, int maxfps=10, time_t ttl=0 );
|
//void StreamImagesZip( int scale=100, int maxfps=10, time_t ttl=0 );
|
||||||
void SingleImage( int scale=100 );
|
|
||||||
void SingleImageRaw( int scale=100 );
|
|
||||||
void SingleImageZip( int scale=100 );
|
|
||||||
#if HAVE_LIBAVCODEC
|
#if HAVE_LIBAVCODEC
|
||||||
//void StreamMpeg( const char *format, int scale=100, int maxfps=10, int bitrate=100000 );
|
//void StreamMpeg( const char *format, int scale=100, int maxfps=10, int bitrate=100000 );
|
||||||
#endif // HAVE_LIBAVCODEC
|
#endif // HAVE_LIBAVCODEC
|
||||||
|
@ -519,49 +517,4 @@ public:
|
||||||
|
|
||||||
#define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit))
|
#define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit))
|
||||||
|
|
||||||
class MonitorStream : public StreamBase {
|
|
||||||
protected:
|
|
||||||
typedef struct SwapImage {
|
|
||||||
bool valid;
|
|
||||||
struct timeval timestamp;
|
|
||||||
char file_name[PATH_MAX];
|
|
||||||
} SwapImage;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SwapImage *temp_image_buffer;
|
|
||||||
int temp_image_buffer_count;
|
|
||||||
int temp_read_index;
|
|
||||||
int temp_write_index;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
time_t ttl;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int playback_buffer;
|
|
||||||
bool delayed;
|
|
||||||
|
|
||||||
int frame_count;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool checkSwapPath( const char *path, bool create_path );
|
|
||||||
|
|
||||||
bool sendFrame( const char *filepath, struct timeval *timestamp );
|
|
||||||
bool sendFrame( Image *image, struct timeval *timestamp );
|
|
||||||
void processCommand( const CmdMsg *msg );
|
|
||||||
|
|
||||||
public:
|
|
||||||
MonitorStream() : playback_buffer( 0 ), delayed( false ), frame_count( 0 ) {
|
|
||||||
}
|
|
||||||
void setStreamBuffer( int p_playback_buffer ) {
|
|
||||||
playback_buffer = p_playback_buffer;
|
|
||||||
}
|
|
||||||
void setStreamTTL( time_t p_ttl ) {
|
|
||||||
ttl = p_ttl;
|
|
||||||
}
|
|
||||||
bool setStreamStart( int monitor_id ) {
|
|
||||||
return loadMonitor( monitor_id );
|
|
||||||
}
|
|
||||||
void runStream();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ZM_MONITOR_H
|
#endif // ZM_MONITOR_H
|
||||||
|
|
|
@ -0,0 +1,803 @@
|
||||||
|
//
|
||||||
|
// ZoneMinder Monitor Class Implementation, $Date$, $Revision$
|
||||||
|
// Copyright (C) 2001-2008 Philip Coombes
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "zm.h"
|
||||||
|
#include "zm_db.h"
|
||||||
|
#include "zm_time.h"
|
||||||
|
#include "zm_mpeg.h"
|
||||||
|
#include "zm_signal.h"
|
||||||
|
#include "zm_monitor.h"
|
||||||
|
#include "zm_monitorstream.h"
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <glob.h>
|
||||||
|
|
||||||
|
bool MonitorStream::checkSwapPath( const char *path, bool create_path ) {
|
||||||
|
|
||||||
|
struct stat stat_buf;
|
||||||
|
if ( stat( path, &stat_buf ) < 0 ) {
|
||||||
|
if ( create_path && errno == ENOENT ) {
|
||||||
|
Debug( 3, "Swap path '%s' missing, creating", path );
|
||||||
|
if ( mkdir( path, 0755 ) ) {
|
||||||
|
Error( "Can't mkdir %s: %s", path, strerror(errno));
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
if ( stat( path, &stat_buf ) < 0 ) {
|
||||||
|
Error( "Can't stat '%s': %s", path, strerror(errno) );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Error( "Can't stat '%s': %s", path, strerror(errno) );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !S_ISDIR(stat_buf.st_mode) ) {
|
||||||
|
Error( "Swap image path '%s' is not a directory", path );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
uid_t uid = getuid();
|
||||||
|
gid_t gid = getgid();
|
||||||
|
|
||||||
|
mode_t mask = 0;
|
||||||
|
if ( uid == stat_buf.st_uid ) {
|
||||||
|
// If we are the owner
|
||||||
|
mask = 00700;
|
||||||
|
} else if ( gid == stat_buf.st_gid ) {
|
||||||
|
// If we are in the owner group
|
||||||
|
mask = 00070;
|
||||||
|
} else {
|
||||||
|
// We are neither the owner nor in the group
|
||||||
|
mask = 00007;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (stat_buf.st_mode & mask) != mask ) {
|
||||||
|
Error( "Insufficient permissions on swap image path '%s'", path );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
return( true );
|
||||||
|
} // end bool MonitorStream::checkSwapPath( const char *path, bool create_path )
|
||||||
|
|
||||||
|
void MonitorStream::processCommand( const CmdMsg *msg ) {
|
||||||
|
Debug( 2, "Got message, type %d, msg %d", msg->msg_type, msg->msg_data[0] );
|
||||||
|
// Check for incoming command
|
||||||
|
switch( (MsgCommand)msg->msg_data[0] ) {
|
||||||
|
case CMD_PAUSE :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got PAUSE command" );
|
||||||
|
|
||||||
|
// Set paused flag
|
||||||
|
paused = true;
|
||||||
|
// Set delayed flag
|
||||||
|
delayed = true;
|
||||||
|
last_frame_sent = TV_2_FLOAT( now );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_PLAY :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got PLAY command" );
|
||||||
|
if ( paused ) {
|
||||||
|
// Clear paused flag
|
||||||
|
paused = false;
|
||||||
|
// Set delayed_play flag
|
||||||
|
delayed = true;
|
||||||
|
}
|
||||||
|
replay_rate = ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_VARPLAY :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got VARPLAY command" );
|
||||||
|
if ( paused ) {
|
||||||
|
// Clear paused flag
|
||||||
|
paused = false;
|
||||||
|
// Set delayed_play flag
|
||||||
|
delayed = true;
|
||||||
|
}
|
||||||
|
replay_rate = ntohs(((unsigned char)msg->msg_data[2]<<8)|(unsigned char)msg->msg_data[1])-32768;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_STOP :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got STOP command" );
|
||||||
|
|
||||||
|
// Clear paused flag
|
||||||
|
paused = false;
|
||||||
|
// Clear delayed_play flag
|
||||||
|
delayed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_FASTFWD :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got FAST FWD command" );
|
||||||
|
if ( paused ) {
|
||||||
|
// Clear paused flag
|
||||||
|
paused = false;
|
||||||
|
// Set delayed_play flag
|
||||||
|
delayed = true;
|
||||||
|
}
|
||||||
|
// Set play rate
|
||||||
|
switch ( replay_rate )
|
||||||
|
{
|
||||||
|
case 2 * ZM_RATE_BASE :
|
||||||
|
replay_rate = 5 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
case 5 * ZM_RATE_BASE :
|
||||||
|
replay_rate = 10 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
case 10 * ZM_RATE_BASE :
|
||||||
|
replay_rate = 25 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
case 25 * ZM_RATE_BASE :
|
||||||
|
case 50 * ZM_RATE_BASE :
|
||||||
|
replay_rate = 50 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
replay_rate = 2 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_SLOWFWD :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got SLOW FWD command" );
|
||||||
|
// Set paused flag
|
||||||
|
paused = true;
|
||||||
|
// Set delayed flag
|
||||||
|
delayed = true;
|
||||||
|
// Set play rate
|
||||||
|
replay_rate = ZM_RATE_BASE;
|
||||||
|
// Set step
|
||||||
|
step = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_SLOWREV :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got SLOW REV command" );
|
||||||
|
// Set paused flag
|
||||||
|
paused = true;
|
||||||
|
// Set delayed flag
|
||||||
|
delayed = true;
|
||||||
|
// Set play rate
|
||||||
|
replay_rate = ZM_RATE_BASE;
|
||||||
|
// Set step
|
||||||
|
step = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_FASTREV :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got FAST REV command" );
|
||||||
|
if ( paused ) {
|
||||||
|
// Clear paused flag
|
||||||
|
paused = false;
|
||||||
|
// Set delayed_play flag
|
||||||
|
delayed = true;
|
||||||
|
}
|
||||||
|
// Set play rate
|
||||||
|
switch ( replay_rate ) {
|
||||||
|
case -2 * ZM_RATE_BASE :
|
||||||
|
replay_rate = -5 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
case -5 * ZM_RATE_BASE :
|
||||||
|
replay_rate = -10 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
case -10 * ZM_RATE_BASE :
|
||||||
|
replay_rate = -25 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
case -25 * ZM_RATE_BASE :
|
||||||
|
case -50 * ZM_RATE_BASE :
|
||||||
|
replay_rate = -50 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
replay_rate = -2 * ZM_RATE_BASE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_ZOOMIN :
|
||||||
|
{
|
||||||
|
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||||
|
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||||
|
Debug( 1, "Got ZOOM IN command, to %d,%d", x, y );
|
||||||
|
switch ( zoom ) {
|
||||||
|
case 100:
|
||||||
|
zoom = 150;
|
||||||
|
break;
|
||||||
|
case 150:
|
||||||
|
zoom = 200;
|
||||||
|
break;
|
||||||
|
case 200:
|
||||||
|
zoom = 300;
|
||||||
|
break;
|
||||||
|
case 300:
|
||||||
|
zoom = 400;
|
||||||
|
break;
|
||||||
|
case 400:
|
||||||
|
default :
|
||||||
|
zoom = 500;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_ZOOMOUT :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got ZOOM OUT command" );
|
||||||
|
switch ( zoom ) {
|
||||||
|
case 500:
|
||||||
|
zoom = 400;
|
||||||
|
break;
|
||||||
|
case 400:
|
||||||
|
zoom = 300;
|
||||||
|
break;
|
||||||
|
case 300:
|
||||||
|
zoom = 200;
|
||||||
|
break;
|
||||||
|
case 200:
|
||||||
|
zoom = 150;
|
||||||
|
break;
|
||||||
|
case 150:
|
||||||
|
default :
|
||||||
|
zoom = 100;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_PAN :
|
||||||
|
{
|
||||||
|
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||||
|
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||||
|
Debug( 1, "Got PAN command, to %d,%d", x, y );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_SCALE :
|
||||||
|
{
|
||||||
|
scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||||
|
Debug( 1, "Got SCALE command, to %d", scale );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_QUIT :
|
||||||
|
{
|
||||||
|
Info ("User initiated exit - CMD_QUIT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_QUERY :
|
||||||
|
{
|
||||||
|
Debug( 1, "Got QUERY command, sending STATUS" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default :
|
||||||
|
{
|
||||||
|
Error( "Got unexpected command %d", msg->msg_data[0] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int id;
|
||||||
|
int state;
|
||||||
|
double fps;
|
||||||
|
int buffer_level;
|
||||||
|
int rate;
|
||||||
|
double delay;
|
||||||
|
int zoom;
|
||||||
|
bool delayed;
|
||||||
|
bool paused;
|
||||||
|
bool enabled;
|
||||||
|
bool forced;
|
||||||
|
} status_data;
|
||||||
|
|
||||||
|
status_data.id = monitor->Id();
|
||||||
|
status_data.fps = monitor->GetFPS();
|
||||||
|
status_data.state = monitor->shared_data->state;
|
||||||
|
if ( playback_buffer > 0 )
|
||||||
|
status_data.buffer_level = (MOD_ADD( (temp_write_index-temp_read_index), 0, temp_image_buffer_count )*100)/temp_image_buffer_count;
|
||||||
|
else
|
||||||
|
status_data.buffer_level = 0;
|
||||||
|
status_data.delayed = delayed;
|
||||||
|
status_data.paused = paused;
|
||||||
|
status_data.rate = replay_rate;
|
||||||
|
status_data.delay = TV_2_FLOAT( now ) - TV_2_FLOAT( last_frame_timestamp );
|
||||||
|
status_data.zoom = zoom;
|
||||||
|
//status_data.enabled = monitor->shared_data->active;
|
||||||
|
status_data.enabled = monitor->trigger_data->trigger_state!=Monitor::TRIGGER_OFF;
|
||||||
|
status_data.forced = monitor->trigger_data->trigger_state==Monitor::TRIGGER_ON;
|
||||||
|
Debug( 2, "L:%d, D:%d, P:%d, R:%d, d:%.3f, Z:%d, E:%d F:%d",
|
||||||
|
status_data.buffer_level,
|
||||||
|
status_data.delayed,
|
||||||
|
status_data.paused,
|
||||||
|
status_data.rate,
|
||||||
|
status_data.delay,
|
||||||
|
status_data.zoom,
|
||||||
|
status_data.enabled,
|
||||||
|
status_data.forced
|
||||||
|
);
|
||||||
|
|
||||||
|
DataMsg status_msg;
|
||||||
|
status_msg.msg_type = MSG_DATA_WATCH;
|
||||||
|
memcpy( &status_msg.msg_data, &status_data, sizeof(status_data) );
|
||||||
|
int nbytes = 0;
|
||||||
|
if ( (nbytes = sendto( sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr) )) < 0 ) {
|
||||||
|
//if ( errno != EAGAIN )
|
||||||
|
{
|
||||||
|
Error( "Can't sendto on sd %d: %s", sd, strerror(errno) );
|
||||||
|
//exit( -1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// quit after sending a status, if this was a quit request
|
||||||
|
if ((MsgCommand)msg->msg_data[0]==CMD_QUIT)
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
updateFrameRate( monitor->GetFPS() );
|
||||||
|
} // end void MonitorStream::processCommand( const CmdMsg *msg )
|
||||||
|
|
||||||
|
bool MonitorStream::sendFrame( const char *filepath, struct timeval *timestamp ) {
|
||||||
|
bool send_raw = ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE));
|
||||||
|
|
||||||
|
if ( type != STREAM_JPEG )
|
||||||
|
send_raw = false;
|
||||||
|
if ( !config.timestamp_on_capture && timestamp )
|
||||||
|
send_raw = false;
|
||||||
|
|
||||||
|
if ( !send_raw ) {
|
||||||
|
Image temp_image( filepath );
|
||||||
|
|
||||||
|
return( sendFrame( &temp_image, timestamp ) );
|
||||||
|
} else {
|
||||||
|
int img_buffer_size = 0;
|
||||||
|
static unsigned char img_buffer[ZM_MAX_IMAGE_SIZE];
|
||||||
|
|
||||||
|
FILE *fdj = NULL;
|
||||||
|
if ( (fdj = fopen( filepath, "r" )) ) {
|
||||||
|
img_buffer_size = fread( img_buffer, 1, sizeof(img_buffer), fdj );
|
||||||
|
fclose( fdj );
|
||||||
|
} else {
|
||||||
|
Error( "Can't open %s: %s", filepath, strerror(errno) );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate how long it takes to actually send the frame
|
||||||
|
struct timeval frameStartTime;
|
||||||
|
gettimeofday( &frameStartTime, NULL );
|
||||||
|
|
||||||
|
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
||||||
|
fprintf( stdout, "Content-Length: %d\r\n", img_buffer_size );
|
||||||
|
fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
|
||||||
|
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
|
||||||
|
if ( ! zm_terminate )
|
||||||
|
Error( "Unable to send stream frame: %s", strerror(errno) );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
fprintf( stdout, "\r\n\r\n" );
|
||||||
|
fflush( stdout );
|
||||||
|
|
||||||
|
struct timeval frameEndTime;
|
||||||
|
gettimeofday( &frameEndTime, NULL );
|
||||||
|
|
||||||
|
int frameSendTime = tvDiffMsec( frameStartTime, frameEndTime );
|
||||||
|
if ( frameSendTime > 1000/maxfps ) {
|
||||||
|
maxfps /= 2;
|
||||||
|
Error( "Frame send time %d msec too slow, throttling maxfps to %.2f", frameSendTime, maxfps );
|
||||||
|
}
|
||||||
|
|
||||||
|
last_frame_sent = TV_2_FLOAT( now );
|
||||||
|
|
||||||
|
return( true );
|
||||||
|
}
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MonitorStream::sendFrame( Image *image, struct timeval *timestamp ) {
|
||||||
|
Image *send_image = prepareImage( image );
|
||||||
|
if ( !config.timestamp_on_capture && timestamp )
|
||||||
|
monitor->TimestampImage( send_image, timestamp );
|
||||||
|
|
||||||
|
#if HAVE_LIBAVCODEC
|
||||||
|
if ( type == STREAM_MPEG ) {
|
||||||
|
if ( !vid_stream ) {
|
||||||
|
vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->SubpixelOrder(), send_image->Width(), send_image->Height() );
|
||||||
|
fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() );
|
||||||
|
vid_stream->OpenStream();
|
||||||
|
}
|
||||||
|
static struct timeval base_time;
|
||||||
|
struct DeltaTimeval delta_time;
|
||||||
|
if ( !frame_count )
|
||||||
|
base_time = *timestamp;
|
||||||
|
DELTA_TIMEVAL( delta_time, *timestamp, base_time, DT_PREC_3 );
|
||||||
|
/* double pts = */ vid_stream->EncodeFrame( send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_time.delta );
|
||||||
|
} else
|
||||||
|
#endif // HAVE_LIBAVCODEC
|
||||||
|
{
|
||||||
|
static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE];
|
||||||
|
|
||||||
|
int img_buffer_size = 0;
|
||||||
|
unsigned char *img_buffer = temp_img_buffer;
|
||||||
|
|
||||||
|
// Calculate how long it takes to actually send the frame
|
||||||
|
struct timeval frameStartTime;
|
||||||
|
gettimeofday( &frameStartTime, NULL );
|
||||||
|
|
||||||
|
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
||||||
|
switch( type ) {
|
||||||
|
case STREAM_JPEG :
|
||||||
|
send_image->EncodeJpeg( img_buffer, &img_buffer_size );
|
||||||
|
fprintf( stdout, "Content-Type: image/jpeg\r\n" );
|
||||||
|
break;
|
||||||
|
case STREAM_RAW :
|
||||||
|
fprintf( stdout, "Content-Type: image/x-rgb\r\n" );
|
||||||
|
img_buffer = (uint8_t*)send_image->Buffer();
|
||||||
|
img_buffer_size = send_image->Size();
|
||||||
|
break;
|
||||||
|
case STREAM_ZIP :
|
||||||
|
fprintf( stdout, "Content-Type: image/x-rgbz\r\n" );
|
||||||
|
unsigned long zip_buffer_size;
|
||||||
|
send_image->Zip( img_buffer, &zip_buffer_size );
|
||||||
|
img_buffer_size = zip_buffer_size;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
Fatal( "Unexpected frame type %d", type );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size );
|
||||||
|
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
|
||||||
|
if ( !zm_terminate )
|
||||||
|
Error( "Unable to send stream frame: %s", strerror(errno) );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
fprintf( stdout, "\r\n\r\n" );
|
||||||
|
fflush( stdout );
|
||||||
|
|
||||||
|
struct timeval frameEndTime;
|
||||||
|
gettimeofday( &frameEndTime, NULL );
|
||||||
|
|
||||||
|
int frameSendTime = tvDiffMsec( frameStartTime, frameEndTime );
|
||||||
|
if ( frameSendTime > 1000/maxfps ) {
|
||||||
|
maxfps /= 1.5;
|
||||||
|
Error( "Frame send time %d msec too slow, throttling maxfps to %.2f", frameSendTime, maxfps );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last_frame_sent = TV_2_FLOAT( now );
|
||||||
|
return( true );
|
||||||
|
} // end bool MonitorStream::sendFrame( Image *image, struct timeval *timestamp )
|
||||||
|
|
||||||
|
void MonitorStream::runStream() {
|
||||||
|
if ( type == STREAM_SINGLE ) {
|
||||||
|
// Not yet migrated over to stream class
|
||||||
|
SingleImage( scale );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
openComms();
|
||||||
|
|
||||||
|
checkInitialised();
|
||||||
|
|
||||||
|
updateFrameRate( monitor->GetFPS() );
|
||||||
|
|
||||||
|
if ( type == STREAM_JPEG )
|
||||||
|
fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
|
||||||
|
|
||||||
|
int last_read_index = monitor->image_buffer_count;
|
||||||
|
|
||||||
|
time_t stream_start_time;
|
||||||
|
time( &stream_start_time );
|
||||||
|
|
||||||
|
frame_count = 0;
|
||||||
|
|
||||||
|
temp_image_buffer = 0;
|
||||||
|
temp_image_buffer_count = playback_buffer;
|
||||||
|
temp_read_index = temp_image_buffer_count;
|
||||||
|
temp_write_index = temp_image_buffer_count;
|
||||||
|
|
||||||
|
char *swap_path = 0;
|
||||||
|
bool buffered_playback = false;
|
||||||
|
|
||||||
|
// 15 is the max length for the swap path suffix, /zmswap-whatever, assuming max 6 digits for monitor id
|
||||||
|
const int max_swap_len_suffix = 15;
|
||||||
|
|
||||||
|
int swap_path_length = strlen(config.path_swap) + 1; // +1 for NULL terminator
|
||||||
|
int subfolder1_length = snprintf(NULL, 0, "/zmswap-m%d", monitor->Id() ) + 1;
|
||||||
|
int subfolder2_length = snprintf(NULL, 0, "/zmswap-q%06d", connkey ) + 1;
|
||||||
|
int total_swap_path_length = swap_path_length + subfolder1_length + subfolder2_length;
|
||||||
|
|
||||||
|
if ( connkey && playback_buffer > 0 ) {
|
||||||
|
|
||||||
|
if ( total_swap_path_length + max_swap_len_suffix > PATH_MAX ) {
|
||||||
|
Error( "Swap Path is too long. %d > %d ", total_swap_path_length+max_swap_len_suffix, PATH_MAX );
|
||||||
|
} else {
|
||||||
|
swap_path = (char *)malloc( total_swap_path_length+max_swap_len_suffix );
|
||||||
|
strncpy( swap_path, config.path_swap, swap_path_length );
|
||||||
|
|
||||||
|
Debug( 3, "Checking swap path folder: %s", swap_path );
|
||||||
|
if ( checkSwapPath( swap_path, false ) ) {
|
||||||
|
// Append the subfolder name /zmswap-m{monitor-id} to the end of swap_path
|
||||||
|
int ndx = swap_path_length - 1; // Array index of the NULL terminator
|
||||||
|
snprintf( &(swap_path[ndx]), subfolder1_length, "/zmswap-m%d", monitor->Id() );
|
||||||
|
|
||||||
|
Debug( 4, "Checking swap path subfolder: %s", swap_path );
|
||||||
|
if ( checkSwapPath( swap_path, true ) ) {
|
||||||
|
// Append the subfolder name /zmswap-q{connection key} to the end of swap_path
|
||||||
|
ndx = swap_path_length+subfolder1_length - 2; // Array index of the NULL terminator
|
||||||
|
snprintf( &(swap_path[ndx]), subfolder2_length, "/zmswap-q%06d", connkey );
|
||||||
|
|
||||||
|
Debug( 4, "Checking swap path subfolder: %s", swap_path );
|
||||||
|
if ( checkSwapPath( swap_path, true ) ) {
|
||||||
|
buffered_playback = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !buffered_playback ) {
|
||||||
|
Error( "Unable to validate swap image path, disabling buffered playback" );
|
||||||
|
} else {
|
||||||
|
Debug( 2, "Assigning temporary buffer" );
|
||||||
|
temp_image_buffer = new SwapImage[temp_image_buffer_count];
|
||||||
|
memset( temp_image_buffer, 0, sizeof(*temp_image_buffer)*temp_image_buffer_count );
|
||||||
|
Debug( 2, "Assigned temporary buffer" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float max_secs_since_last_sent_frame = 10.0; //should be > keep alive amount (5 secs)
|
||||||
|
while ( !zm_terminate ) {
|
||||||
|
bool got_command = false;
|
||||||
|
if ( feof( stdout ) || ferror( stdout ) || !monitor->ShmValid() ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday( &now, NULL );
|
||||||
|
|
||||||
|
if ( connkey ) {
|
||||||
|
while(checkCommandQueue()) {
|
||||||
|
got_command = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//bool frame_sent = false;
|
||||||
|
if ( buffered_playback && delayed ) {
|
||||||
|
if ( temp_read_index == temp_write_index ) {
|
||||||
|
// Go back to live viewing
|
||||||
|
Debug( 1, "Exceeded temporary streaming buffer" );
|
||||||
|
// Clear paused flag
|
||||||
|
paused = false;
|
||||||
|
// Clear delayed_play flag
|
||||||
|
delayed = false;
|
||||||
|
replay_rate = ZM_RATE_BASE;
|
||||||
|
} else {
|
||||||
|
if ( !paused ) {
|
||||||
|
int temp_index = MOD_ADD( temp_read_index, 0, temp_image_buffer_count );
|
||||||
|
//Debug( 3, "tri: %d, ti: %d", temp_read_index, temp_index );
|
||||||
|
SwapImage *swap_image = &temp_image_buffer[temp_index];
|
||||||
|
|
||||||
|
if ( !swap_image->valid ) {
|
||||||
|
paused = true;
|
||||||
|
delayed = true;
|
||||||
|
temp_read_index = MOD_ADD( temp_read_index, (replay_rate>=0?-1:1), temp_image_buffer_count );
|
||||||
|
} else {
|
||||||
|
//Debug( 3, "siT: %f, lfT: %f", TV_2_FLOAT( swap_image->timestamp ), TV_2_FLOAT( last_frame_timestamp ) );
|
||||||
|
double expected_delta_time = ((TV_2_FLOAT( swap_image->timestamp ) - TV_2_FLOAT( last_frame_timestamp )) * ZM_RATE_BASE)/replay_rate;
|
||||||
|
double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent;
|
||||||
|
|
||||||
|
//Debug( 3, "eDT: %.3lf, aDT: %.3f, lFS:%.3f, NOW:%.3f", expected_delta_time, actual_delta_time, last_frame_sent, TV_2_FLOAT( now ) );
|
||||||
|
// If the next frame is due
|
||||||
|
if ( actual_delta_time > expected_delta_time ) {
|
||||||
|
//Debug( 2, "eDT: %.3lf, aDT: %.3f", expected_delta_time, actual_delta_time );
|
||||||
|
if ( temp_index%frame_mod == 0 ) {
|
||||||
|
Debug( 2, "Sending delayed frame %d", temp_index );
|
||||||
|
// Send the next frame
|
||||||
|
if ( ! sendFrame( temp_image_buffer[temp_index].file_name, &temp_image_buffer[temp_index].timestamp ) )
|
||||||
|
zm_terminate = true;
|
||||||
|
memcpy( &last_frame_timestamp, &(swap_image->timestamp), sizeof(last_frame_timestamp) );
|
||||||
|
//frame_sent = true;
|
||||||
|
}
|
||||||
|
temp_read_index = MOD_ADD( temp_read_index, (replay_rate>0?1:-1), temp_image_buffer_count );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ( step != 0 ) {
|
||||||
|
temp_read_index = MOD_ADD( temp_read_index, (step>0?1:-1), temp_image_buffer_count );
|
||||||
|
|
||||||
|
SwapImage *swap_image = &temp_image_buffer[temp_read_index];
|
||||||
|
|
||||||
|
// Send the next frame
|
||||||
|
if ( !sendFrame( temp_image_buffer[temp_read_index].file_name, &temp_image_buffer[temp_read_index].timestamp ) )
|
||||||
|
zm_terminate = true;
|
||||||
|
memcpy( &last_frame_timestamp, &(swap_image->timestamp), sizeof(last_frame_timestamp) );
|
||||||
|
//frame_sent = true;
|
||||||
|
step = 0;
|
||||||
|
} else {
|
||||||
|
int temp_index = MOD_ADD( temp_read_index, 0, temp_image_buffer_count );
|
||||||
|
|
||||||
|
double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent;
|
||||||
|
if ( got_command || actual_delta_time > 5 ) {
|
||||||
|
// Send keepalive
|
||||||
|
Debug( 2, "Sending keepalive frame %d", temp_index );
|
||||||
|
// Send the next frame
|
||||||
|
if ( !sendFrame( temp_image_buffer[temp_index].file_name, &temp_image_buffer[temp_index].timestamp ) )
|
||||||
|
zm_terminate = true;
|
||||||
|
//frame_sent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( temp_read_index == temp_write_index ) {
|
||||||
|
// Go back to live viewing
|
||||||
|
Warning( "Rewound over write index, resuming live play" );
|
||||||
|
// Clear paused flag
|
||||||
|
paused = false;
|
||||||
|
// Clear delayed_play flag
|
||||||
|
delayed = false;
|
||||||
|
replay_rate = ZM_RATE_BASE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( (unsigned int)last_read_index != monitor->shared_data->last_write_index ) {
|
||||||
|
int index = monitor->shared_data->last_write_index%monitor->image_buffer_count;
|
||||||
|
last_read_index = monitor->shared_data->last_write_index;
|
||||||
|
//Debug( 1, "%d: %x - %x", index, image_buffer[index].image, image_buffer[index].image->buffer );
|
||||||
|
if ( (frame_mod == 1) || ((frame_count%frame_mod) == 0) ) {
|
||||||
|
if ( !paused && !delayed ) {
|
||||||
|
// Send the next frame
|
||||||
|
Monitor::Snapshot *snap = &monitor->image_buffer[index];
|
||||||
|
|
||||||
|
if ( !sendFrame( snap->image, snap->timestamp ) )
|
||||||
|
zm_terminate = true;
|
||||||
|
memcpy( &last_frame_timestamp, snap->timestamp, sizeof(last_frame_timestamp) );
|
||||||
|
//frame_sent = true;
|
||||||
|
|
||||||
|
temp_read_index = temp_write_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( buffered_playback ) {
|
||||||
|
if ( monitor->shared_data->valid ) {
|
||||||
|
if ( monitor->image_buffer[index].timestamp->tv_sec ) {
|
||||||
|
int temp_index = temp_write_index%temp_image_buffer_count;
|
||||||
|
Debug( 2, "Storing frame %d", temp_index );
|
||||||
|
if ( !temp_image_buffer[temp_index].valid ) {
|
||||||
|
snprintf( temp_image_buffer[temp_index].file_name, sizeof(temp_image_buffer[0].file_name), "%s/zmswap-i%05d.jpg", swap_path, temp_index );
|
||||||
|
temp_image_buffer[temp_index].valid = true;
|
||||||
|
}
|
||||||
|
memcpy( &(temp_image_buffer[temp_index].timestamp), monitor->image_buffer[index].timestamp, sizeof(temp_image_buffer[0].timestamp) );
|
||||||
|
monitor->image_buffer[index].image->WriteJpeg( temp_image_buffer[temp_index].file_name, config.jpeg_file_quality );
|
||||||
|
temp_write_index = MOD_ADD( temp_write_index, 1, temp_image_buffer_count );
|
||||||
|
if ( temp_write_index == temp_read_index ) {
|
||||||
|
// Go back to live viewing
|
||||||
|
Warning( "Exceeded temporary buffer, resuming live play" );
|
||||||
|
// Clear paused flag
|
||||||
|
paused = false;
|
||||||
|
// Clear delayed_play flag
|
||||||
|
delayed = false;
|
||||||
|
replay_rate = ZM_RATE_BASE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Warning( "Unable to store frame as timestamp invalid" );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Warning( "Unable to store frame as shared memory invalid" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frame_count++;
|
||||||
|
}
|
||||||
|
usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) );
|
||||||
|
if ( ttl ) {
|
||||||
|
if ( (now.tv_sec - stream_start_time) > ttl ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( (TV_2_FLOAT( now ) - last_frame_sent) > max_secs_since_last_sent_frame ) {
|
||||||
|
Error( "Terminating, last frame sent time %f secs more than maximum of %f", TV_2_FLOAT( now ) - last_frame_sent, max_secs_since_last_sent_frame );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( buffered_playback ) {
|
||||||
|
Debug( 1, "Cleaning swap files from %s", swap_path );
|
||||||
|
struct stat stat_buf;
|
||||||
|
if ( stat( swap_path, &stat_buf ) < 0 ) {
|
||||||
|
if ( errno != ENOENT ) {
|
||||||
|
Error( "Can't stat '%s': %s", swap_path, strerror(errno) );
|
||||||
|
}
|
||||||
|
} else if ( !S_ISDIR(stat_buf.st_mode) ) {
|
||||||
|
Error( "Swap image path '%s' is not a directory", swap_path );
|
||||||
|
} else {
|
||||||
|
char glob_pattern[PATH_MAX] = "";
|
||||||
|
|
||||||
|
snprintf( glob_pattern, sizeof(glob_pattern), "%s/*.*", swap_path );
|
||||||
|
glob_t pglob;
|
||||||
|
int glob_status = glob( glob_pattern, 0, 0, &pglob );
|
||||||
|
if ( glob_status != 0 ) {
|
||||||
|
if ( glob_status < 0 ) {
|
||||||
|
Error( "Can't glob '%s': %s", glob_pattern, strerror(errno) );
|
||||||
|
} else {
|
||||||
|
Debug( 1, "Can't glob '%s': %d", glob_pattern, glob_status );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for ( unsigned int i = 0; i < pglob.gl_pathc; i++ ) {
|
||||||
|
if ( unlink( pglob.gl_pathv[i] ) < 0 ) {
|
||||||
|
Error( "Can't unlink '%s': %s", pglob.gl_pathv[i], strerror(errno) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globfree( &pglob );
|
||||||
|
if ( rmdir( swap_path ) < 0 ) {
|
||||||
|
Error( "Can't rmdir '%s': %s", swap_path, strerror(errno) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( swap_path ) free( swap_path );
|
||||||
|
closeComms();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MonitorStream::SingleImage( int scale ) {
|
||||||
|
int img_buffer_size = 0;
|
||||||
|
static JOCTET img_buffer[ZM_MAX_IMAGE_SIZE];
|
||||||
|
Image scaled_image;
|
||||||
|
Monitor::Snapshot *snap = monitor->getSnapshot();
|
||||||
|
Image *snap_image = snap->image;
|
||||||
|
|
||||||
|
if ( scale != ZM_SCALE_BASE ) {
|
||||||
|
scaled_image.Assign( *snap_image );
|
||||||
|
scaled_image.Scale( scale );
|
||||||
|
snap_image = &scaled_image;
|
||||||
|
}
|
||||||
|
if ( !config.timestamp_on_capture ) {
|
||||||
|
monitor->TimestampImage( snap_image, snap->timestamp );
|
||||||
|
}
|
||||||
|
snap_image->EncodeJpeg( img_buffer, &img_buffer_size );
|
||||||
|
|
||||||
|
fprintf( stdout, "Content-Length: %d\r\n", img_buffer_size );
|
||||||
|
fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
|
||||||
|
fwrite( img_buffer, img_buffer_size, 1, stdout );
|
||||||
|
}
|
||||||
|
|
||||||
|
void MonitorStream::SingleImageRaw( int scale ) {
|
||||||
|
Image scaled_image;
|
||||||
|
Monitor::Snapshot *snap = monitor->getSnapshot();
|
||||||
|
Image *snap_image = snap->image;
|
||||||
|
|
||||||
|
if ( scale != ZM_SCALE_BASE ) {
|
||||||
|
scaled_image.Assign( *snap_image );
|
||||||
|
scaled_image.Scale( scale );
|
||||||
|
snap_image = &scaled_image;
|
||||||
|
}
|
||||||
|
if ( !config.timestamp_on_capture ) {
|
||||||
|
monitor->TimestampImage( snap_image, snap->timestamp );
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf( stdout, "Content-Length: %d\r\n", snap_image->Size() );
|
||||||
|
fprintf( stdout, "Content-Type: image/x-rgb\r\n\r\n" );
|
||||||
|
fwrite( snap_image->Buffer(), snap_image->Size(), 1, stdout );
|
||||||
|
}
|
||||||
|
|
||||||
|
void MonitorStream::SingleImageZip( int scale ) {
|
||||||
|
unsigned long img_buffer_size = 0;
|
||||||
|
static Bytef img_buffer[ZM_MAX_IMAGE_SIZE];
|
||||||
|
Image scaled_image;
|
||||||
|
|
||||||
|
Monitor::Snapshot *snap = monitor->getSnapshot();
|
||||||
|
Image *snap_image = snap->image;
|
||||||
|
|
||||||
|
if ( scale != ZM_SCALE_BASE ) {
|
||||||
|
scaled_image.Assign( *snap_image );
|
||||||
|
scaled_image.Scale( scale );
|
||||||
|
snap_image = &scaled_image;
|
||||||
|
}
|
||||||
|
if ( !config.timestamp_on_capture ) {
|
||||||
|
monitor->TimestampImage( snap_image, snap->timestamp );
|
||||||
|
}
|
||||||
|
snap_image->Zip( img_buffer, &img_buffer_size );
|
||||||
|
|
||||||
|
fprintf( stdout, "Content-Length: %ld\r\n", img_buffer_size );
|
||||||
|
fprintf( stdout, "Content-Type: image/x-rgbz\r\n\r\n" );
|
||||||
|
fwrite( img_buffer, img_buffer_size, 1, stdout );
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
//
|
||||||
|
// ZoneMinder MonitorStream Class Interfaces, $Date$, $Revision$
|
||||||
|
// Copyright (C) 2001-2008 Philip Coombes
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef ZM_MONITORSTREAM_H
|
||||||
|
#define ZM_MONITORSTREAM_H
|
||||||
|
|
||||||
|
#include "zm.h"
|
||||||
|
#include "zm_coord.h"
|
||||||
|
#include "zm_image.h"
|
||||||
|
#include "zm_utils.h"
|
||||||
|
#include "zm_monitor.h"
|
||||||
|
|
||||||
|
class MonitorStream : public StreamBase {
|
||||||
|
protected:
|
||||||
|
typedef struct SwapImage {
|
||||||
|
bool valid;
|
||||||
|
struct timeval timestamp;
|
||||||
|
char file_name[PATH_MAX];
|
||||||
|
} SwapImage;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SwapImage *temp_image_buffer;
|
||||||
|
int temp_image_buffer_count;
|
||||||
|
int temp_read_index;
|
||||||
|
int temp_write_index;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
time_t ttl;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int playback_buffer;
|
||||||
|
bool delayed;
|
||||||
|
|
||||||
|
int frame_count;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool checkSwapPath( const char *path, bool create_path );
|
||||||
|
|
||||||
|
bool sendFrame( const char *filepath, struct timeval *timestamp );
|
||||||
|
bool sendFrame( Image *image, struct timeval *timestamp );
|
||||||
|
void processCommand( const CmdMsg *msg );
|
||||||
|
void SingleImage( int scale=100 );
|
||||||
|
void SingleImageRaw( int scale=100 );
|
||||||
|
void SingleImageZip( int scale=100 );
|
||||||
|
|
||||||
|
public:
|
||||||
|
MonitorStream() : playback_buffer( 0 ), delayed( false ), frame_count( 0 ) {
|
||||||
|
}
|
||||||
|
void setStreamBuffer( int p_playback_buffer ) {
|
||||||
|
playback_buffer = p_playback_buffer;
|
||||||
|
}
|
||||||
|
void setStreamTTL( time_t p_ttl ) {
|
||||||
|
ttl = p_ttl;
|
||||||
|
}
|
||||||
|
bool setStreamStart( int monitor_id ) {
|
||||||
|
return loadMonitor( monitor_id );
|
||||||
|
}
|
||||||
|
void runStream();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ZM_MONITORSTREAM_H
|
|
@ -227,7 +227,7 @@ int RemoteCameraHttp::ReadData( Buffer &buffer, unsigned int bytes_expected ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( total_bytes_to_read == 0 ) {
|
if ( total_bytes_to_read == 0 ) {
|
||||||
if( mode == SINGLE_IMAGE ) {
|
if ( mode == SINGLE_IMAGE ) {
|
||||||
int error = 0;
|
int error = 0;
|
||||||
socklen_t len = sizeof (error);
|
socklen_t len = sizeof (error);
|
||||||
int retval = getsockopt( sd, SOL_SOCKET, SO_ERROR, &error, &len );
|
int retval = getsockopt( sd, SOL_SOCKET, SO_ERROR, &error, &len );
|
||||||
|
@ -267,7 +267,7 @@ int RemoteCameraHttp::ReadData( Buffer &buffer, unsigned int bytes_expected ) {
|
||||||
Debug( 2, "Socket closed" );
|
Debug( 2, "Socket closed" );
|
||||||
//Disconnect(); // Disconnect is done outside of ReadData now.
|
//Disconnect(); // Disconnect is done outside of ReadData now.
|
||||||
return( -1 );
|
return( -1 );
|
||||||
} else if ( bytes_read < total_bytes_to_read ) {
|
} else if ( (unsigned int)bytes_read < total_bytes_to_read ) {
|
||||||
Error( "Incomplete read, expected %d, got %d", total_bytes_to_read, bytes_read );
|
Error( "Incomplete read, expected %d, got %d", total_bytes_to_read, bytes_read );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
102
src/zm_utils.cpp
102
src/zm_utils.cpp
|
@ -24,8 +24,16 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#if defined(__arm__)
|
||||||
|
#include <sys/auxv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CURL_CURL_H
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned int sseversion = 0;
|
unsigned int sseversion = 0;
|
||||||
|
unsigned int neonversion = 0;
|
||||||
|
|
||||||
std::string trimSet(std::string str, std::string trimset) {
|
std::string trimSet(std::string str, std::string trimset) {
|
||||||
// Trim Both leading and trailing sets
|
// Trim Both leading and trailing sets
|
||||||
|
@ -234,30 +242,59 @@ int pairsplit(const char* string, const char delim, std::string& name, std::stri
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sets sse_version */
|
/* Detect special hardware features, such as SIMD instruction sets */
|
||||||
void ssedetect() {
|
void hwcaps_detect() {
|
||||||
|
neonversion = 0;
|
||||||
|
sseversion = 0;
|
||||||
#if (defined(__i386__) || defined(__x86_64__))
|
#if (defined(__i386__) || defined(__x86_64__))
|
||||||
/* x86 or x86-64 processor */
|
/* x86 or x86-64 processor */
|
||||||
uint32_t r_edx, r_ecx;
|
uint32_t r_edx, r_ecx, r_ebx;
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
#if defined(__i386__)
|
"push %%rbx\n\t"
|
||||||
"pushl %%ebx;\n\t"
|
"mov $0x0,%%ecx\n\t"
|
||||||
#endif
|
"mov $0x7,%%eax\n\t"
|
||||||
|
"cpuid\n\t"
|
||||||
|
"push %%rbx\n\t"
|
||||||
"mov $0x1,%%eax\n\t"
|
"mov $0x1,%%eax\n\t"
|
||||||
"cpuid\n\t"
|
"cpuid\n\t"
|
||||||
#if defined(__i386__)
|
"pop %%rax\n\t"
|
||||||
"popl %%ebx;\n\t"
|
"pop %%rbx\n\t"
|
||||||
#endif
|
: "=d" (r_edx), "=c" (r_ecx), "=a" (r_ebx)
|
||||||
: "=d" (r_edx), "=c" (r_ecx)
|
:
|
||||||
:
|
:
|
||||||
: "%eax"
|
|
||||||
#if !defined(__i386__)
|
|
||||||
, "%ebx"
|
|
||||||
#endif
|
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
if (r_ecx & 0x00000200) {
|
__asm__ __volatile__(
|
||||||
|
"push %%ebx\n\t"
|
||||||
|
"mov $0x0,%%ecx\n\t"
|
||||||
|
"mov $0x7,%%eax\n\t"
|
||||||
|
"cpuid\n\t"
|
||||||
|
"push %%ebx\n\t"
|
||||||
|
"mov $0x1,%%eax\n\t"
|
||||||
|
"cpuid\n\t"
|
||||||
|
"pop %%eax\n\t"
|
||||||
|
"pop %%ebx\n\t"
|
||||||
|
: "=d" (r_edx), "=c" (r_ecx), "=a" (r_ebx)
|
||||||
|
:
|
||||||
|
:
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (r_ebx & 0x00000020) {
|
||||||
|
sseversion = 52; /* AVX2 */
|
||||||
|
Debug(1,"Detected a x86\\x86-64 processor with AVX2");
|
||||||
|
} else if (r_ecx & 0x10000000) {
|
||||||
|
sseversion = 51; /* AVX */
|
||||||
|
Debug(1,"Detected a x86\\x86-64 processor with AVX");
|
||||||
|
} else if (r_ecx & 0x00100000) {
|
||||||
|
sseversion = 42; /* SSE4.2 */
|
||||||
|
Debug(1,"Detected a x86\\x86-64 processor with SSE4.2");
|
||||||
|
} else if (r_ecx & 0x00080000) {
|
||||||
|
sseversion = 41; /* SSE4.1 */
|
||||||
|
Debug(1,"Detected a x86\\x86-64 processor with SSE4.1");
|
||||||
|
} else if (r_ecx & 0x00000200) {
|
||||||
sseversion = 35; /* SSSE3 */
|
sseversion = 35; /* SSSE3 */
|
||||||
Debug(1,"Detected a x86\\x86-64 processor with SSSE3");
|
Debug(1,"Detected a x86\\x86-64 processor with SSSE3");
|
||||||
} else if (r_ecx & 0x00000001) {
|
} else if (r_ecx & 0x00000001) {
|
||||||
|
@ -272,12 +309,20 @@ void ssedetect() {
|
||||||
} else {
|
} else {
|
||||||
sseversion = 0;
|
sseversion = 0;
|
||||||
Debug(1,"Detected a x86\\x86-64 processor");
|
Debug(1,"Detected a x86\\x86-64 processor");
|
||||||
|
}
|
||||||
|
#elif defined(__arm__)
|
||||||
|
// ARM processor
|
||||||
|
// To see if it supports NEON, we need to get that information from the kernel
|
||||||
|
unsigned long auxval = getauxval(AT_HWCAP);
|
||||||
|
if (auxval & HWCAP_ARM_NEON) {
|
||||||
|
Debug(1,"Detected ARM processor with Neon");
|
||||||
|
neonversion = 1;
|
||||||
|
} else {
|
||||||
|
Debug(1,"Detected ARM processor");
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* Non x86 or x86-64 processor, SSE2 is not available */
|
// Unknown processor
|
||||||
Debug(1,"Detected a non x86\\x86-64 processor");
|
Debug(1,"Detected unknown processor architecture");
|
||||||
sseversion = 0;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,3 +390,18 @@ void timespec_diff(struct timespec *start, struct timespec *end, struct timespec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UriDecode( const std::string &encoded ) {
|
||||||
|
#ifdef HAVE_LIBCURL
|
||||||
|
CURL *curl = curl_easy_init();
|
||||||
|
int outlength;
|
||||||
|
char *cres = curl_easy_unescape(curl, encoded.c_str(), encoded.length(), &outlength);
|
||||||
|
std::string res(cres, cres + outlength);
|
||||||
|
curl_free(cres);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
return res;
|
||||||
|
#else
|
||||||
|
Warning("ZM Compiled without LIBCURL. UriDecoding not implemented.");
|
||||||
|
return encoded;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,10 +54,13 @@ inline int min( int a, int b )
|
||||||
return( a<=b?a:b );
|
return( a<=b?a:b );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ssedetect();
|
|
||||||
void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes);
|
void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes);
|
||||||
void timespec_diff(struct timespec *start, struct timespec *end, struct timespec *diff);
|
void timespec_diff(struct timespec *start, struct timespec *end, struct timespec *diff);
|
||||||
|
|
||||||
|
void hwcaps_detect();
|
||||||
extern unsigned int sseversion;
|
extern unsigned int sseversion;
|
||||||
|
extern unsigned int neonversion;
|
||||||
|
|
||||||
|
std::string UriDecode( const std::string &encoded );
|
||||||
|
|
||||||
#endif // ZM_UTILS_H
|
#endif // ZM_UTILS_H
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,6 +8,9 @@ extern "C" {
|
||||||
#ifdef HAVE_LIBSWRESAMPLE
|
#ifdef HAVE_LIBSWRESAMPLE
|
||||||
#include "libswresample/swresample.h"
|
#include "libswresample/swresample.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBAVRESAMPLE
|
||||||
|
#include "libavresample/avresample.h"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_LIBAVCODEC
|
#if HAVE_LIBAVCODEC
|
||||||
|
@ -44,7 +47,10 @@ private:
|
||||||
AVAudioFifo *fifo;
|
AVAudioFifo *fifo;
|
||||||
int output_frame_size;
|
int output_frame_size;
|
||||||
#ifdef HAVE_LIBSWRESAMPLE
|
#ifdef HAVE_LIBSWRESAMPLE
|
||||||
SwrContext *resample_context = NULL;
|
//SwrContext *resample_context = NULL;
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIBAVRESAMPLE
|
||||||
|
AVAudioResampleContext* resample_context;
|
||||||
#endif
|
#endif
|
||||||
uint8_t *converted_input_samples = NULL;
|
uint8_t *converted_input_samples = NULL;
|
||||||
|
|
||||||
|
@ -54,17 +60,20 @@ private:
|
||||||
bool keyframeMessage;
|
bool keyframeMessage;
|
||||||
int keyframeSkipNumber;
|
int keyframeSkipNumber;
|
||||||
|
|
||||||
int64_t video_start_pts;
|
// These are for input
|
||||||
int64_t video_start_dts;
|
int64_t video_last_pts;
|
||||||
int64_t audio_start_pts;
|
int64_t video_last_dts;
|
||||||
int64_t audio_start_dts;
|
int64_t audio_last_pts;
|
||||||
|
int64_t audio_last_dts;
|
||||||
|
|
||||||
int64_t start_pts;
|
// These are for output, should start at zero. We assume they do not wrap because we just aren't going to save files that big.
|
||||||
int64_t start_dts;
|
int64_t previous_pts;
|
||||||
|
int64_t previous_dts;
|
||||||
|
|
||||||
int64_t prevDts;
|
|
||||||
int64_t filter_in_rescale_delta_last;
|
int64_t filter_in_rescale_delta_last;
|
||||||
|
|
||||||
|
bool setup_resampler();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoStore(const char *filename_in, const char *format_in, AVStream *video_input_stream, AVStream *audio_input_stream, int64_t nStartTime, Monitor * p_monitor );
|
VideoStore(const char *filename_in, const char *format_in, AVStream *video_input_stream, AVStream *audio_input_stream, int64_t nStartTime, Monitor * p_monitor );
|
||||||
~VideoStore();
|
~VideoStore();
|
||||||
|
|
|
@ -945,15 +945,13 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
||||||
{
|
{
|
||||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||||
snprintf( sql, sizeof(sql), "select Id,Name,Type+0,Units,Coords,AlarmRGB,CheckMethod+0,MinPixelThreshold,MaxPixelThreshold,MinAlarmPixels,MaxAlarmPixels,FilterX,FilterY,MinFilterPixels,MaxFilterPixels,MinBlobPixels,MaxBlobPixels,MinBlobs,MaxBlobs,OverloadFrames,ExtendAlarmFrames from Zones where MonitorId = %d order by Type, Id", monitor->Id() );
|
snprintf( sql, sizeof(sql), "select Id,Name,Type+0,Units,Coords,AlarmRGB,CheckMethod+0,MinPixelThreshold,MaxPixelThreshold,MinAlarmPixels,MaxAlarmPixels,FilterX,FilterY,MinFilterPixels,MaxFilterPixels,MinBlobPixels,MaxBlobPixels,MinBlobs,MaxBlobs,OverloadFrames,ExtendAlarmFrames from Zones where MonitorId = %d order by Type, Id", monitor->Id() );
|
||||||
if ( mysql_query( &dbconn, sql ) )
|
if ( mysql_query( &dbconn, sql ) ) {
|
||||||
{
|
|
||||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||||
exit( mysql_errno( &dbconn ) );
|
exit( mysql_errno( &dbconn ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||||
if ( !result )
|
if ( !result ) {
|
||||||
{
|
|
||||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||||
exit( mysql_errno( &dbconn ) );
|
exit( mysql_errno( &dbconn ) );
|
||||||
}
|
}
|
||||||
|
@ -961,8 +959,7 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
||||||
Debug( 1, "Got %d zones for monitor %s", n_zones, monitor->Name() );
|
Debug( 1, "Got %d zones for monitor %s", n_zones, monitor->Name() );
|
||||||
delete[] zones;
|
delete[] zones;
|
||||||
zones = new Zone *[n_zones];
|
zones = new Zone *[n_zones];
|
||||||
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) {
|
||||||
{
|
|
||||||
zones[i] = NULL;
|
zones[i] = NULL;
|
||||||
int col = 0;
|
int col = 0;
|
||||||
|
|
||||||
|
@ -995,17 +992,18 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
||||||
Polygon polygon;
|
Polygon polygon;
|
||||||
if ( !ParsePolygonString( Coords, polygon ) ) {
|
if ( !ParsePolygonString( Coords, polygon ) ) {
|
||||||
Error( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s, ignoring", Coords, Id, Name, monitor->Name() );
|
Error( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s, ignoring", Coords, Id, Name, monitor->Name() );
|
||||||
|
n_zones -= 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( polygon.LoX() < 0 || polygon.HiX() >= (int)monitor->Width()
|
if ( polygon.LoX() < 0 || polygon.HiX() >= (int)monitor->Width()
|
||||||
|| polygon.LoY() < 0 || polygon.HiY() >= (int)monitor->Height() ) {
|
|| polygon.LoY() < 0 || polygon.HiY() >= (int)monitor->Height() ) {
|
||||||
Error( "Zone %d/%s for monitor %s extends outside of image dimensions, (%d,%d), (%d,%d), ignoring", Id, Name, monitor->Name(), polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY() );
|
Error( "Zone %d/%s for monitor %s extends outside of image dimensions, (%d,%d), (%d,%d), ignoring", Id, Name, monitor->Name(), polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY() );
|
||||||
|
n_zones -= 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( false && !strcmp( Units, "Percent" ) )
|
if ( false && !strcmp( Units, "Percent" ) ) {
|
||||||
{
|
|
||||||
MinAlarmPixels = (MinAlarmPixels*polygon.Area())/100;
|
MinAlarmPixels = (MinAlarmPixels*polygon.Area())/100;
|
||||||
MaxAlarmPixels = (MaxAlarmPixels*polygon.Area())/100;
|
MaxAlarmPixels = (MaxAlarmPixels*polygon.Area())/100;
|
||||||
MinFilterPixels = (MinFilterPixels*polygon.Area())/100;
|
MinFilterPixels = (MinFilterPixels*polygon.Area())/100;
|
||||||
|
|
|
@ -133,7 +133,7 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
logInit( log_id_string );
|
logInit( log_id_string );
|
||||||
|
|
||||||
ssedetect();
|
hwcaps_detect();
|
||||||
|
|
||||||
Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS );
|
Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS );
|
||||||
|
|
||||||
|
|
111
src/zmc.cpp
111
src/zmc.cpp
|
@ -73,8 +73,7 @@ possible, this should run at more or less constant speed.
|
||||||
#include "zm_signal.h"
|
#include "zm_signal.h"
|
||||||
#include "zm_monitor.h"
|
#include "zm_monitor.h"
|
||||||
|
|
||||||
void Usage()
|
void Usage() {
|
||||||
{
|
|
||||||
fprintf( stderr, "zmc -d <device_path> or -r <proto> -H <host> -P <port> -p <path> or -f <file_path> or -m <monitor_id>\n" );
|
fprintf( stderr, "zmc -d <device_path> or -r <proto> -H <host> -P <port> -p <path> or -f <file_path> or -m <monitor_id>\n" );
|
||||||
|
|
||||||
fprintf( stderr, "Options:\n" );
|
fprintf( stderr, "Options:\n" );
|
||||||
|
@ -91,8 +90,7 @@ void Usage()
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] ) {
|
||||||
{
|
|
||||||
self = argv[0];
|
self = argv[0];
|
||||||
|
|
||||||
srand( getpid() * time( 0 ) );
|
srand( getpid() * time( 0 ) );
|
||||||
|
@ -110,21 +108,19 @@ int main( int argc, char *argv[] )
|
||||||
{"protocol", 1, 0, 'r'},
|
{"protocol", 1, 0, 'r'},
|
||||||
{"host", 1, 0, 'H'},
|
{"host", 1, 0, 'H'},
|
||||||
{"port", 1, 0, 'P'},
|
{"port", 1, 0, 'P'},
|
||||||
{"path", 1, 0, 'p'},
|
{"path", 1, 0, 'p'},
|
||||||
{"file", 1, 0, 'f'},
|
{"file", 1, 0, 'f'},
|
||||||
{"monitor", 1, 0, 'm'},
|
{"monitor", 1, 0, 'm'},
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
{"version", 0, 0, 'v'},
|
{"version", 0, 0, 'v'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
int c = getopt_long (argc, argv, "d:H:P:p:f:m:h:v", long_options, &option_index);
|
int c = getopt_long (argc, argv, "d:H:P:p:f:m:h:v", long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,8 +157,7 @@ int main( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc)
|
if (optind < argc) {
|
||||||
{
|
|
||||||
fprintf( stderr, "Extraneous options, " );
|
fprintf( stderr, "Extraneous options, " );
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
printf ("%s ", argv[optind++]);
|
printf ("%s ", argv[optind++]);
|
||||||
|
@ -171,37 +166,28 @@ int main( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
int modes = ( device[0]?1:0 + host[0]?1:0 + file[0]?1:0 + (monitor_id>0?1:0) );
|
int modes = ( device[0]?1:0 + host[0]?1:0 + file[0]?1:0 + (monitor_id>0?1:0) );
|
||||||
if ( modes > 1 )
|
if ( modes > 1 ) {
|
||||||
{
|
|
||||||
fprintf( stderr, "Only one of device, host/port/path, file or monitor id allowed\n" );
|
fprintf( stderr, "Only one of device, host/port/path, file or monitor id allowed\n" );
|
||||||
Usage();
|
Usage();
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( modes < 1 )
|
if ( modes < 1 ) {
|
||||||
{
|
|
||||||
fprintf( stderr, "One of device, host/port/path, file or monitor id must be specified\n" );
|
fprintf( stderr, "One of device, host/port/path, file or monitor id must be specified\n" );
|
||||||
Usage();
|
Usage();
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
char log_id_string[32] = "";
|
char log_id_string[32] = "";
|
||||||
if ( device[0] )
|
if ( device[0] ) {
|
||||||
{
|
|
||||||
const char *slash_ptr = strrchr( device, '/' );
|
const char *slash_ptr = strrchr( device, '/' );
|
||||||
snprintf( log_id_string, sizeof(log_id_string), "zmc_d%s", slash_ptr?slash_ptr+1:device );
|
snprintf( log_id_string, sizeof(log_id_string), "zmc_d%s", slash_ptr?slash_ptr+1:device );
|
||||||
}
|
} else if ( host[0] ) {
|
||||||
else if ( host[0] )
|
|
||||||
{
|
|
||||||
snprintf( log_id_string, sizeof(log_id_string), "zmc_h%s", host );
|
snprintf( log_id_string, sizeof(log_id_string), "zmc_h%s", host );
|
||||||
}
|
} else if ( file[0] ) {
|
||||||
else if ( file[0] )
|
|
||||||
{
|
|
||||||
const char *slash_ptr = strrchr( file, '/' );
|
const char *slash_ptr = strrchr( file, '/' );
|
||||||
snprintf( log_id_string, sizeof(log_id_string), "zmc_f%s", slash_ptr?slash_ptr+1:file );
|
snprintf( log_id_string, sizeof(log_id_string), "zmc_f%s", slash_ptr?slash_ptr+1:file );
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf( log_id_string, sizeof(log_id_string), "zmc_m%d", monitor_id );
|
snprintf( log_id_string, sizeof(log_id_string), "zmc_m%d", monitor_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,40 +195,31 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
logInit( log_id_string );
|
logInit( log_id_string );
|
||||||
|
|
||||||
ssedetect();
|
hwcaps_detect();
|
||||||
|
|
||||||
Monitor **monitors = 0;
|
Monitor **monitors = 0;
|
||||||
int n_monitors = 0;
|
int n_monitors = 0;
|
||||||
#if ZM_HAS_V4L
|
#if ZM_HAS_V4L
|
||||||
if ( device[0] )
|
if ( device[0] ) {
|
||||||
{
|
|
||||||
n_monitors = Monitor::LoadLocalMonitors( device, monitors, Monitor::CAPTURE );
|
n_monitors = Monitor::LoadLocalMonitors( device, monitors, Monitor::CAPTURE );
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif // ZM_HAS_V4L
|
#endif // ZM_HAS_V4L
|
||||||
if ( host[0] )
|
if ( host[0] ) {
|
||||||
{
|
|
||||||
if ( !port )
|
if ( !port )
|
||||||
port = "80";
|
port = "80";
|
||||||
n_monitors = Monitor::LoadRemoteMonitors( protocol, host, port, path, monitors, Monitor::CAPTURE );
|
n_monitors = Monitor::LoadRemoteMonitors( protocol, host, port, path, monitors, Monitor::CAPTURE );
|
||||||
}
|
} else if ( file[0] ) {
|
||||||
else if ( file[0] )
|
|
||||||
{
|
|
||||||
n_monitors = Monitor::LoadFileMonitors( file, monitors, Monitor::CAPTURE );
|
n_monitors = Monitor::LoadFileMonitors( file, monitors, Monitor::CAPTURE );
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Monitor *monitor = Monitor::Load( monitor_id, true, Monitor::CAPTURE );
|
Monitor *monitor = Monitor::Load( monitor_id, true, Monitor::CAPTURE );
|
||||||
if ( monitor )
|
if ( monitor ) {
|
||||||
{
|
|
||||||
monitors = new Monitor *[1];
|
monitors = new Monitor *[1];
|
||||||
monitors[0] = monitor;
|
monitors[0] = monitor;
|
||||||
n_monitors = 1;
|
n_monitors = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !n_monitors )
|
if ( !n_monitors ) {
|
||||||
{
|
|
||||||
Error( "No monitors found" );
|
Error( "No monitors found" );
|
||||||
exit ( -1 );
|
exit ( -1 );
|
||||||
}
|
}
|
||||||
|
@ -259,8 +236,7 @@ int main( int argc, char *argv[] )
|
||||||
sigaddset( &block_set, SIGUSR2 );
|
sigaddset( &block_set, SIGUSR2 );
|
||||||
|
|
||||||
monitors[0]->setStartupTime( (time_t)time(NULL) );
|
monitors[0]->setStartupTime( (time_t)time(NULL) );
|
||||||
if ( monitors[0]->PrimeCapture() < 0 )
|
if ( monitors[0]->PrimeCapture() < 0 ) {
|
||||||
{
|
|
||||||
Error( "Failed to prime capture of initial monitor" );
|
Error( "Failed to prime capture of initial monitor" );
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
}
|
}
|
||||||
|
@ -269,8 +245,7 @@ int main( int argc, char *argv[] )
|
||||||
long *alarm_capture_delays = new long[n_monitors];
|
long *alarm_capture_delays = new long[n_monitors];
|
||||||
long *next_delays = new long[n_monitors];
|
long *next_delays = new long[n_monitors];
|
||||||
struct timeval * last_capture_times = new struct timeval[n_monitors];
|
struct timeval * last_capture_times = new struct timeval[n_monitors];
|
||||||
for ( int i = 0; i < n_monitors; i++ )
|
for ( int i = 0; i < n_monitors; i++ ) {
|
||||||
{
|
|
||||||
last_capture_times[i].tv_sec = last_capture_times[i].tv_usec = 0;
|
last_capture_times[i].tv_sec = last_capture_times[i].tv_usec = 0;
|
||||||
capture_delays[i] = monitors[i]->GetCaptureDelay();
|
capture_delays[i] = monitors[i]->GetCaptureDelay();
|
||||||
alarm_capture_delays[i] = monitors[i]->GetAlarmCaptureDelay();
|
alarm_capture_delays[i] = monitors[i]->GetAlarmCaptureDelay();
|
||||||
|
@ -279,18 +254,14 @@ int main( int argc, char *argv[] )
|
||||||
int result = 0;
|
int result = 0;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
struct DeltaTimeval delta_time;
|
struct DeltaTimeval delta_time;
|
||||||
while( !zm_terminate )
|
while( !zm_terminate ) {
|
||||||
{
|
|
||||||
sigprocmask( SIG_BLOCK, &block_set, 0 );
|
sigprocmask( SIG_BLOCK, &block_set, 0 );
|
||||||
for ( int i = 0; i < n_monitors; i++ )
|
for ( int i = 0; i < n_monitors; i++ ) {
|
||||||
{
|
|
||||||
long min_delay = MAXINT;
|
long min_delay = MAXINT;
|
||||||
|
|
||||||
gettimeofday( &now, NULL );
|
gettimeofday( &now, NULL );
|
||||||
for ( int j = 0; j < n_monitors; j++ )
|
for ( int j = 0; j < n_monitors; j++ ) {
|
||||||
{
|
if ( last_capture_times[j].tv_sec ) {
|
||||||
if ( last_capture_times[j].tv_sec )
|
|
||||||
{
|
|
||||||
DELTA_TIMEVAL( delta_time, now, last_capture_times[j], DT_PREC_3 );
|
DELTA_TIMEVAL( delta_time, now, last_capture_times[j], DT_PREC_3 );
|
||||||
if ( monitors[i]->GetState() == Monitor::ALARM )
|
if ( monitors[i]->GetState() == Monitor::ALARM )
|
||||||
next_delays[j] = alarm_capture_delays[j]-delta_time.delta;
|
next_delays[j] = alarm_capture_delays[j]-delta_time.delta;
|
||||||
|
@ -298,48 +269,39 @@ int main( int argc, char *argv[] )
|
||||||
next_delays[j] = capture_delays[j]-delta_time.delta;
|
next_delays[j] = capture_delays[j]-delta_time.delta;
|
||||||
if ( next_delays[j] < 0 )
|
if ( next_delays[j] < 0 )
|
||||||
next_delays[j] = 0;
|
next_delays[j] = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
next_delays[j] = 0;
|
next_delays[j] = 0;
|
||||||
}
|
}
|
||||||
if ( next_delays[j] <= min_delay )
|
if ( next_delays[j] <= min_delay ) {
|
||||||
{
|
|
||||||
min_delay = next_delays[j];
|
min_delay = next_delays[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( next_delays[i] <= min_delay || next_delays[i] <= 0 )
|
if ( next_delays[i] <= min_delay || next_delays[i] <= 0 ) {
|
||||||
{
|
if ( monitors[i]->PreCapture() < 0 ) {
|
||||||
if ( monitors[i]->PreCapture() < 0 )
|
|
||||||
{
|
|
||||||
Error( "Failed to pre-capture monitor %d %d (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
|
Error( "Failed to pre-capture monitor %d %d (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
|
||||||
zm_terminate = true;
|
zm_terminate = true;
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( monitors[i]->Capture() < 0 )
|
if ( monitors[i]->Capture() < 0 ) {
|
||||||
{
|
|
||||||
Error( "Failed to capture image from monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
|
Error( "Failed to capture image from monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
|
||||||
zm_terminate = true;
|
zm_terminate = true;
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( monitors[i]->PostCapture() < 0 )
|
if ( monitors[i]->PostCapture() < 0 ) {
|
||||||
{
|
|
||||||
Error( "Failed to post-capture monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
|
Error( "Failed to post-capture monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
|
||||||
zm_terminate = true;
|
zm_terminate = true;
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( next_delays[i] > 0 )
|
if ( next_delays[i] > 0 ) {
|
||||||
{
|
|
||||||
gettimeofday( &now, NULL );
|
gettimeofday( &now, NULL );
|
||||||
DELTA_TIMEVAL( delta_time, now, last_capture_times[i], DT_PREC_3 );
|
DELTA_TIMEVAL( delta_time, now, last_capture_times[i], DT_PREC_3 );
|
||||||
long sleep_time = next_delays[i]-delta_time.delta;
|
long sleep_time = next_delays[i]-delta_time.delta;
|
||||||
if ( sleep_time > 0 )
|
if ( sleep_time > 0 ) {
|
||||||
{
|
|
||||||
usleep( sleep_time*(DT_MAXGRAN/DT_PREC_3) );
|
usleep( sleep_time*(DT_MAXGRAN/DT_PREC_3) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,8 +311,7 @@ int main( int argc, char *argv[] )
|
||||||
} // end foreach n_monitors
|
} // end foreach n_monitors
|
||||||
sigprocmask( SIG_UNBLOCK, &block_set, 0 );
|
sigprocmask( SIG_UNBLOCK, &block_set, 0 );
|
||||||
} // end while ! zm_terminate
|
} // end while ! zm_terminate
|
||||||
for ( int i = 0; i < n_monitors; i++ )
|
for ( int i = 0; i < n_monitors; i++ ) {
|
||||||
{
|
|
||||||
delete monitors[i];
|
delete monitors[i];
|
||||||
}
|
}
|
||||||
delete [] monitors;
|
delete [] monitors;
|
||||||
|
|
258
src/zmf.cpp
258
src/zmf.cpp
|
@ -138,157 +138,158 @@ void Usage()
|
||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
self = argv[0];
|
self = argv[0];
|
||||||
|
|
||||||
srand( getpid() * time( 0 ) );
|
srand( getpid() * time( 0 ) );
|
||||||
|
|
||||||
int id = -1;
|
int id = -1;
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"monitor", 1, 0, 'm'},
|
{"monitor", 1, 0, 'm'},
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
{"version", 0, 0, 'v'},
|
{"version", 0, 0, 'v'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
int c = getopt_long (argc, argv, "m:h:v", long_options, &option_index);
|
int c = getopt_long (argc, argv, "m:h:v", long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'm':
|
case 'm':
|
||||||
id = atoi(optarg);
|
id = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
Usage();
|
Usage();
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
std::cout << ZM_VERSION << "\n";
|
std::cout << ZM_VERSION << "\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
default:
|
default:
|
||||||
//fprintf( stderr, "?? getopt returned character code 0%o ??\n", c );
|
//fprintf( stderr, "?? getopt returned character code 0%o ??\n", c );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Extraneous options, " );
|
fprintf( stderr, "Extraneous options, " );
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
printf ("%s ", argv[optind++]);
|
printf ("%s ", argv[optind++]);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
Usage();
|
Usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( id < 0 )
|
if ( id < 0 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Bogus monitor %d\n", id );
|
fprintf( stderr, "Bogus monitor %d\n", id );
|
||||||
Usage();
|
Usage();
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
char log_id_string[16];
|
char log_id_string[16];
|
||||||
snprintf( log_id_string, sizeof(log_id_string), "m%d", id );
|
snprintf( log_id_string, sizeof(log_id_string), "m%d", id );
|
||||||
|
|
||||||
zmLoadConfig();
|
zmLoadConfig();
|
||||||
|
|
||||||
logInit( "zmf" );
|
logInit( "zmf" );
|
||||||
|
|
||||||
ssedetect();
|
hwcaps_detect();
|
||||||
|
|
||||||
Monitor *monitor = Monitor::Load( id, false, Monitor::QUERY );
|
Monitor *monitor = Monitor::Load( id, false, Monitor::QUERY );
|
||||||
|
|
||||||
if ( !monitor )
|
if ( !monitor )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Can't find monitor with id of %d\n", id );
|
fprintf( stderr, "Can't find monitor with id of %d\n", id );
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
}
|
}
|
||||||
Storage *Storage = monitor->getStorage();
|
|
||||||
|
|
||||||
char capt_path[PATH_MAX];
|
Storage *Storage = monitor->getStorage();
|
||||||
char anal_path[PATH_MAX];
|
|
||||||
snprintf( capt_path, sizeof(capt_path), "%s/%d/%%s/%%0%dd-capture.jpg", Storage->Path(), monitor->Id(), config.event_image_digits );
|
|
||||||
snprintf( anal_path, sizeof(anal_path), "%s/%d/%%s/%%0%dd-analyse.jpg", Storage->Path(), monitor->Id(), config.event_image_digits );
|
|
||||||
zmSetDefaultTermHandler();
|
|
||||||
zmSetDefaultDieHandler();
|
|
||||||
|
|
||||||
sigset_t block_set;
|
char capt_path[PATH_MAX];
|
||||||
sigemptyset( &block_set );
|
char anal_path[PATH_MAX];
|
||||||
|
snprintf( capt_path, sizeof(capt_path), "%s/%d/%%s/%%0%dd-capture.jpg", Storage->Path(), monitor->Id(), config.event_image_digits );
|
||||||
|
snprintf( anal_path, sizeof(anal_path), "%s/%d/%%s/%%0%dd-analyse.jpg", Storage->Path(), monitor->Id(), config.event_image_digits );
|
||||||
|
zmSetDefaultTermHandler();
|
||||||
|
zmSetDefaultDieHandler();
|
||||||
|
|
||||||
int sd = OpenSocket( monitor->Id() );
|
sigset_t block_set;
|
||||||
|
sigemptyset( &block_set );
|
||||||
|
|
||||||
FrameHeader frame_header = { 0, 0, false, 0 };
|
int sd = OpenSocket( monitor->Id() );
|
||||||
//unsigned char *image_data = 0;
|
|
||||||
|
|
||||||
fd_set rfds;
|
FrameHeader frame_header = { 0, 0, false, 0 };
|
||||||
|
//unsigned char *image_data = 0;
|
||||||
|
|
||||||
struct timeval timeout;
|
fd_set rfds;
|
||||||
timeout.tv_sec = 1;
|
|
||||||
timeout.tv_usec = 0;
|
|
||||||
while( 1 )
|
|
||||||
{
|
|
||||||
struct timeval temp_timeout = timeout;
|
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
struct timeval timeout;
|
||||||
FD_SET(sd, &rfds);
|
timeout.tv_sec = 1;
|
||||||
int n_found = select( sd+1, &rfds, NULL, NULL, &temp_timeout );
|
timeout.tv_usec = 0;
|
||||||
if( n_found == 0 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
Debug( 1, "Select timed out" );
|
struct timeval temp_timeout = timeout;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if ( n_found < 0)
|
|
||||||
{
|
|
||||||
Error( "Select error: %s", strerror(errno) );
|
|
||||||
ReopenSocket( sd, monitor->Id() );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sigprocmask( SIG_BLOCK, &block_set, 0 );
|
FD_ZERO(&rfds);
|
||||||
|
FD_SET(sd, &rfds);
|
||||||
|
int n_found = select( sd+1, &rfds, NULL, NULL, &temp_timeout );
|
||||||
|
if( n_found == 0 )
|
||||||
|
{
|
||||||
|
Debug( 1, "Select timed out" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if ( n_found < 0)
|
||||||
|
{
|
||||||
|
Error( "Select error: %s", strerror(errno) );
|
||||||
|
ReopenSocket( sd, monitor->Id() );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int n_bytes = read( sd, &frame_header, sizeof(frame_header) );
|
sigprocmask( SIG_BLOCK, &block_set, 0 );
|
||||||
if ( n_bytes != sizeof(frame_header) )
|
|
||||||
{
|
|
||||||
if ( n_bytes < 0 )
|
|
||||||
{
|
|
||||||
Error( "Can't read frame header: %s", strerror(errno) );
|
|
||||||
}
|
|
||||||
else if ( n_bytes > 0 )
|
|
||||||
{
|
|
||||||
Error( "Incomplete read of frame header, %d bytes only", n_bytes );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Warning( "Socket closed at remote end" );
|
|
||||||
}
|
|
||||||
ReopenSocket( sd, monitor->Id() );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Debug( 1, "Read frame header, expecting %ld bytes of image", frame_header.image_length );
|
|
||||||
static unsigned char image_data[ZM_MAX_IMAGE_SIZE];
|
|
||||||
|
|
||||||
// Read for pipe and loop until bytes expected have been read or an error occurs
|
int n_bytes = read( sd, &frame_header, sizeof(frame_header) );
|
||||||
int bytes_read = 0;
|
if ( n_bytes != sizeof(frame_header) )
|
||||||
do
|
{
|
||||||
{
|
if ( n_bytes < 0 )
|
||||||
n_bytes = read( sd, image_data+bytes_read, frame_header.image_length-bytes_read );
|
{
|
||||||
if (n_bytes < 0) break; // break on error
|
Error( "Can't read frame header: %s", strerror(errno) );
|
||||||
if (n_bytes < (int)frame_header.image_length)
|
}
|
||||||
{
|
else if ( n_bytes > 0 )
|
||||||
// print some informational messages
|
{
|
||||||
if (bytes_read == 0)
|
Error( "Incomplete read of frame header, %d bytes only", n_bytes );
|
||||||
{
|
}
|
||||||
Debug(4,"Image read : Short read %d bytes of %d expected bytes",n_bytes,frame_header.image_length);
|
else
|
||||||
|
{
|
||||||
|
Warning( "Socket closed at remote end" );
|
||||||
|
}
|
||||||
|
ReopenSocket( sd, monitor->Id() );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Debug( 1, "Read frame header, expecting %ld bytes of image", frame_header.image_length );
|
||||||
|
static unsigned char image_data[ZM_MAX_IMAGE_SIZE];
|
||||||
|
|
||||||
|
// Read for pipe and loop until bytes expected have been read or an error occurs
|
||||||
|
int bytes_read = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
n_bytes = read( sd, image_data+bytes_read, frame_header.image_length-bytes_read );
|
||||||
|
if (n_bytes < 0) break; // break on error
|
||||||
|
if (n_bytes < (int)frame_header.image_length)
|
||||||
|
{
|
||||||
|
// print some informational messages
|
||||||
|
if (bytes_read == 0)
|
||||||
|
{
|
||||||
|
Debug(4,"Image read : Short read %d bytes of %d expected bytes",n_bytes,frame_header.image_length);
|
||||||
}
|
}
|
||||||
else if (bytes_read+n_bytes == (int)frame_header.image_length)
|
else if (bytes_read+n_bytes == (int)frame_header.image_length)
|
||||||
{
|
{
|
||||||
Debug(5,"Image read : Read rest of short read: %d bytes read total of %d bytes",n_bytes,frame_header.image_length);
|
Debug(5,"Image read : Read rest of short read: %d bytes read total of %d bytes",n_bytes,frame_header.image_length);
|
||||||
}
|
}
|
||||||
|
@ -296,13 +297,14 @@ int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
Debug(6,"Image read : continuing, read %d bytes (%d so far)", n_bytes, bytes_read+n_bytes);
|
Debug(6,"Image read : continuing, read %d bytes (%d so far)", n_bytes, bytes_read+n_bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bytes_read+= n_bytes;
|
bytes_read+= n_bytes;
|
||||||
} while (n_bytes>0 && (bytes_read < (ssize_t)frame_header.image_length) );
|
} while (n_bytes>0 && (bytes_read < (ssize_t)frame_header.image_length) );
|
||||||
|
|
||||||
// Print errors if there was a problem
|
// Print errors if there was a problem
|
||||||
if ( n_bytes < 1 )
|
if ( n_bytes < 1 )
|
||||||
{
|
{
|
||||||
|
|
||||||
Error( "Only read %d bytes of %d\n", bytes_read, frame_header.image_length);
|
Error( "Only read %d bytes of %d\n", bytes_read, frame_header.image_length);
|
||||||
if ( n_bytes < 0 )
|
if ( n_bytes < 0 )
|
||||||
{
|
{
|
||||||
|
|
31
src/zms.cpp
31
src/zms.cpp
|
@ -25,6 +25,7 @@
|
||||||
#include "zm_user.h"
|
#include "zm_user.h"
|
||||||
#include "zm_signal.h"
|
#include "zm_signal.h"
|
||||||
#include "zm_monitor.h"
|
#include "zm_monitor.h"
|
||||||
|
#include "zm_monitorstream.h"
|
||||||
|
|
||||||
bool ValidateAccess( User *user, int mon_id ) {
|
bool ValidateAccess( User *user, int mon_id ) {
|
||||||
bool allowed = true;
|
bool allowed = true;
|
||||||
|
@ -66,9 +67,9 @@ int main( int argc, const char *argv[] )
|
||||||
unsigned int bitrate = 100000;
|
unsigned int bitrate = 100000;
|
||||||
unsigned int ttl = 0;
|
unsigned int ttl = 0;
|
||||||
EventStream::StreamMode replay = EventStream::MODE_SINGLE;
|
EventStream::StreamMode replay = EventStream::MODE_SINGLE;
|
||||||
char username[64] = "";
|
std::string username;
|
||||||
char password[64] = "";
|
std::string password;
|
||||||
char auth[64] = "";
|
char auth[64] = "";
|
||||||
unsigned int connkey = 0;
|
unsigned int connkey = 0;
|
||||||
unsigned int playback_buffer = 0;
|
unsigned int playback_buffer = 0;
|
||||||
|
|
||||||
|
@ -86,8 +87,8 @@ int main( int argc, const char *argv[] )
|
||||||
zmLoadConfig();
|
zmLoadConfig();
|
||||||
|
|
||||||
logInit( "zms" );
|
logInit( "zms" );
|
||||||
|
|
||||||
ssedetect();
|
hwcaps_detect();
|
||||||
|
|
||||||
zmSetDefaultTermHandler();
|
zmSetDefaultTermHandler();
|
||||||
zmSetDefaultDieHandler();
|
zmSetDefaultDieHandler();
|
||||||
|
@ -148,7 +149,7 @@ int main( int argc, const char *argv[] )
|
||||||
else if ( config.opt_use_auth ) {
|
else if ( config.opt_use_auth ) {
|
||||||
if ( strcmp( config.auth_relay, "none" ) == 0 ) {
|
if ( strcmp( config.auth_relay, "none" ) == 0 ) {
|
||||||
if ( !strcmp( name, "user" ) ) {
|
if ( !strcmp( name, "user" ) ) {
|
||||||
strncpy( username, value, sizeof(username) );
|
username = UriDecode( value );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
||||||
|
@ -160,10 +161,12 @@ int main( int argc, const char *argv[] )
|
||||||
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
||||||
{
|
{
|
||||||
if ( !strcmp( name, "user" ) ) {
|
if ( !strcmp( name, "user" ) ) {
|
||||||
strncpy( username, value, sizeof(username) );
|
username = UriDecode( value );
|
||||||
|
Debug( 1, "Have %s for username", username.c_str() );
|
||||||
}
|
}
|
||||||
if ( !strcmp( name, "pass" ) ) {
|
if ( !strcmp( name, "pass" ) ) {
|
||||||
strncpy( password, value, sizeof(password) );
|
password = UriDecode( value );
|
||||||
|
Debug( 1, "Have %s for password", password.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,20 +178,24 @@ int main( int argc, const char *argv[] )
|
||||||
User *user = 0;
|
User *user = 0;
|
||||||
|
|
||||||
if ( strcmp( config.auth_relay, "none" ) == 0 ) {
|
if ( strcmp( config.auth_relay, "none" ) == 0 ) {
|
||||||
if ( *username ) {
|
if ( username.length() ) {
|
||||||
user = zmLoadUser( username );
|
user = zmLoadUser( username.c_str() );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
||||||
{
|
{
|
||||||
if ( *auth ) {
|
if ( *auth ) {
|
||||||
user = zmLoadAuthUser( auth, config.auth_hash_ips );
|
user = zmLoadAuthUser( auth, config.auth_hash_ips );
|
||||||
|
} else {
|
||||||
|
Debug( 1, "Need both username and password" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
||||||
{
|
{
|
||||||
if ( *username && *password ) {
|
if ( username.length() && password.length() ) {
|
||||||
user = zmLoadUser( username, password );
|
user = zmLoadUser( username.c_str(), password.c_str() );
|
||||||
|
} else {
|
||||||
|
Debug( 1, "Need both username and password" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // auth is none or something else
|
} // auth is none or something else
|
||||||
|
|
|
@ -200,7 +200,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
logInit("zmstreamer");
|
logInit("zmstreamer");
|
||||||
|
|
||||||
ssedetect();
|
hwcaps_detect();
|
||||||
|
|
||||||
// Setting stream parameters
|
// Setting stream parameters
|
||||||
MonitorStream stream;
|
MonitorStream stream;
|
||||||
|
|
|
@ -87,12 +87,12 @@ else
|
||||||
echo "Defaulting to master branch";
|
echo "Defaulting to master branch";
|
||||||
BRANCH="master";
|
BRANCH="master";
|
||||||
fi;
|
fi;
|
||||||
|
if [ "$SNAPSHOT" == "NOW" ]; then
|
||||||
|
SNAPSHOT=`date +%Y%m%d%H%M%S`;
|
||||||
|
fi;
|
||||||
fi;
|
fi;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$URGENCY" = "" ]; then
|
|
||||||
URGENCY="medium"
|
|
||||||
fi;
|
|
||||||
|
|
||||||
# Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead.
|
# Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead.
|
||||||
if [ ! -d "${GITHUB_FORK}_zoneminder_release" ]; then
|
if [ ! -d "${GITHUB_FORK}_zoneminder_release" ]; then
|
||||||
|
@ -139,10 +139,10 @@ cd "$DIRECTORY.orig";
|
||||||
|
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
if [ $DISTRO == "trusty" ] || [ $DISTRO == "precise" ]; then
|
if [ "$DISTRO" == "trusty" ] || [ "$DISTRO" == "precise" ]; then
|
||||||
ln -sf distros/ubuntu1204 debian
|
ln -sf distros/ubuntu1204 debian
|
||||||
else
|
else
|
||||||
if [ $DISTRO == "wheezy" ]; then
|
if [ "$DISTRO" == "wheezy" ]; then
|
||||||
ln -sf distros/debian debian
|
ln -sf distros/debian debian
|
||||||
else
|
else
|
||||||
ln -sf distros/ubuntu1604 debian
|
ln -sf distros/ubuntu1604 debian
|
||||||
|
@ -159,6 +159,10 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$URGENCY" = "" ]; then
|
||||||
|
URGENCY="medium"
|
||||||
|
fi;
|
||||||
|
|
||||||
if [ "$SNAPSHOT" == "stable" ]; then
|
if [ "$SNAPSHOT" == "stable" ]; then
|
||||||
cat <<EOF > debian/changelog
|
cat <<EOF > debian/changelog
|
||||||
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
|
||||||
|
@ -182,6 +186,7 @@ fi;
|
||||||
# Auto-install all ZoneMinder's depedencies using the Debian control file
|
# Auto-install all ZoneMinder's depedencies using the Debian control file
|
||||||
sudo apt-get install devscripts equivs
|
sudo apt-get install devscripts equivs
|
||||||
sudo mk-build-deps -ir ./debian/control
|
sudo mk-build-deps -ir ./debian/control
|
||||||
|
echo "Status: $?"
|
||||||
|
|
||||||
#rm -rf .git
|
#rm -rf .git
|
||||||
#rm .gitignore
|
#rm .gitignore
|
||||||
|
@ -201,6 +206,7 @@ if [ "$DEBSIGN_KEYID" != "" ]; then
|
||||||
DEBUILD="$DEBUILD -k$DEBSIGN_KEYID"
|
DEBUILD="$DEBUILD -k$DEBSIGN_KEYID"
|
||||||
fi
|
fi
|
||||||
$DEBUILD
|
$DEBUILD
|
||||||
|
echo "Status: $?"
|
||||||
|
|
||||||
cd ../
|
cd ../
|
||||||
if [ "$INTERACTIVE" != "no" ]; then
|
if [ "$INTERACTIVE" != "no" ]; then
|
||||||
|
@ -222,7 +228,7 @@ if [ $TYPE == "binary" ]; then
|
||||||
echo "Do you want to upload this binary to zmrepo? (y/N)"
|
echo "Do you want to upload this binary to zmrepo? (y/N)"
|
||||||
read install
|
read install
|
||||||
if [ "$install" == "Y" ]; then
|
if [ "$install" == "Y" ]; then
|
||||||
scp "zoneminder_*-${VERSION}-${DISTRO}*" "zmrepo.connortechnology.com:zmrepo/debian-${BRANCH}/"
|
scp "zoneminder_*-${VERSION}-${DISTRO}*" "zmrepo@zmrepo.connortechnology.com:debian/${BRANCH}/mini-dinstall/incoming/"
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- a/packpack/pack/deb.mk 2017-01-15 16:41:32.938418279 -0600
|
||||||
|
+++ b/packpack/pack/deb.mk 2017-02-16 15:44:43.267900717 -0600
|
||||||
|
@@ -14,7 +14,7 @@
|
||||||
|
DPKG_BUILD:=$(PRODUCT)_$(DEB_VERSION)-$(RELEASE)_$(DPKG_ARCH).build
|
||||||
|
DPKG_DSC:=$(PRODUCT)_$(DEB_VERSION)-$(RELEASE).dsc
|
||||||
|
DPKG_ORIG_TARBALL:=$(PRODUCT)_$(DEB_VERSION).orig.tar.$(TARBALL_COMPRESSOR)
|
||||||
|
-DPKG_DEBIAN_TARBALL:=$(PRODUCT)_$(DEB_VERSION)-$(RELEASE).debian.tar.$(TARBALL_COMPRESSOR)
|
||||||
|
+DPKG_DEBIAN_TARBALL:=$(PRODUCT)_$(DEB_VERSION)-$(RELEASE).tar.$(TARBALL_COMPRESSOR)
|
||||||
|
|
||||||
|
# gh-7: Ubuntu/Debian should export DEBIAN_FRONTEND=noninteractive
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
|
@ -52,6 +52,12 @@ if [ "${OS}" == "el" ] || [ "${OS}" == "fedora" ]; then
|
||||||
#patch -p1 < utils/packpack/autosetup.patch
|
#patch -p1 < utils/packpack/autosetup.patch
|
||||||
ln -sf distros/redhat rpm
|
ln -sf distros/redhat rpm
|
||||||
|
|
||||||
|
# The rpm specfile requires the Crud submodule folder to be empty
|
||||||
|
if [ -e "web/api/app/Plugin/Crud/LICENSE.txt" ]; then
|
||||||
|
rm -rf web/api/app/Plugin/Crud
|
||||||
|
mkdir web/api/app/Plugin/Crud
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${OS}" == "el" ]; then
|
if [ "${OS}" == "el" ]; then
|
||||||
zmrepodistro=${OS}
|
zmrepodistro=${OS}
|
||||||
else
|
else
|
||||||
|
@ -80,6 +86,12 @@ if [ "${OS}" == "el" ] || [ "${OS}" == "fedora" ]; then
|
||||||
elif [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ]; then
|
elif [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ]; then
|
||||||
echo "Begin Debian build..."
|
echo "Begin Debian build..."
|
||||||
|
|
||||||
|
# patch packpack to remove "debian" from the source tarball filename
|
||||||
|
patch --dry-run --silent -f -p1 < utils/packpack/deb.mk.patch 2>/dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
patch -p1 < utils/packpack/deb.mk.patch
|
||||||
|
fi
|
||||||
|
|
||||||
# Uncompress the Crud tarball and move it into place
|
# Uncompress the Crud tarball and move it into place
|
||||||
if [ -e "web/api/app/Plugin/Crud/LICENSE.txt" ]; then
|
if [ -e "web/api/app/Plugin/Crud/LICENSE.txt" ]; then
|
||||||
echo "Crud plugin already installed..."
|
echo "Crud plugin already installed..."
|
||||||
|
|
|
@ -113,11 +113,13 @@ switch ( $data['type'] )
|
||||||
$data['delay'] = round( $data['delay'], 2 );
|
$data['delay'] = round( $data['delay'], 2 );
|
||||||
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
||||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) {
|
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) {
|
||||||
|
session_start();
|
||||||
$time = time();
|
$time = time();
|
||||||
// Regenerate auth hash after half the lifetime of the hash
|
// Regenerate auth hash after half the lifetime of the hash
|
||||||
if ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) {
|
if ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) {
|
||||||
$data['auth'] = generateAuthHash( ZM_AUTH_HASH_IPS );
|
$data['auth'] = generateAuthHash( ZM_AUTH_HASH_IPS );
|
||||||
}
|
}
|
||||||
|
session_write_close();
|
||||||
}
|
}
|
||||||
ajaxResponse( array( 'status'=>$data ) );
|
ajaxResponse( array( 'status'=>$data ) );
|
||||||
break;
|
break;
|
||||||
|
@ -129,11 +131,13 @@ switch ( $data['type'] )
|
||||||
$data['rate'] /= RATE_BASE;
|
$data['rate'] /= RATE_BASE;
|
||||||
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
||||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) {
|
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) {
|
||||||
|
session_start();
|
||||||
$time = time();
|
$time = time();
|
||||||
// Regenerate auth hash after half the lifetime of the hash
|
// Regenerate auth hash after half the lifetime of the hash
|
||||||
if ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) {
|
if ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) {
|
||||||
$data['auth'] = generateAuthHash( ZM_AUTH_HASH_IPS );
|
$data['auth'] = generateAuthHash( ZM_AUTH_HASH_IPS );
|
||||||
}
|
}
|
||||||
|
session_write_close();
|
||||||
}
|
}
|
||||||
ajaxResponse( array( 'status'=>$data ) );
|
ajaxResponse( array( 'status'=>$data ) );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
* In production mode, flash messages redirect after a time interval.
|
* In production mode, flash messages redirect after a time interval.
|
||||||
* In development mode, you need to click the flash message to continue.
|
* In development mode, you need to click the flash message to continue.
|
||||||
*/
|
*/
|
||||||
Configure::write('debug', 2);
|
Configure::write('debug', 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the Error handler used to handle errors for your application. By default
|
* Configure the Error handler used to handle errors for your application. By default
|
||||||
|
|
|
@ -91,7 +91,7 @@ class AppController extends Controller {
|
||||||
if( ! $this->Session->Read('user.Username') ) {
|
if( ! $this->Session->Read('user.Username') ) {
|
||||||
throw new UnauthorizedException(__('Not Authenticated'));
|
throw new UnauthorizedException(__('Not Authenticated'));
|
||||||
return;
|
return;
|
||||||
} else if ( ! $this->Session->Read('user.Username') ) {
|
} else if ( ! $this->Session->Read('user.Enabled') ) {
|
||||||
throw new UnauthorizedException(__('User is not enabled'));
|
throw new UnauthorizedException(__('User is not enabled'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ class Event {
|
||||||
} // end function createListThumbnail
|
} // end function createListThumbnail
|
||||||
|
|
||||||
function getImageSrc( $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
function getImageSrc( $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
||||||
$Storage = new Storage( $this->{'StorageId'} );
|
$Storage = new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL );
|
||||||
$Event = $this;
|
$Event = $this;
|
||||||
$eventPath = $Event->Path();
|
$eventPath = $Event->Path();
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ private $control_fields = array(
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Error("No row for Monitor " . $IdOrRow );
|
Error('No row for Monitor ' . $IdOrRow );
|
||||||
}
|
}
|
||||||
} # end if isset($IdOrRow)
|
} # end if isset($IdOrRow)
|
||||||
} // end function __construct
|
} // end function __construct
|
||||||
|
@ -170,6 +170,7 @@ private $control_fields = array(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStreamSrc( $args, $querySep='&' ) {
|
public function getStreamSrc( $args, $querySep='&' ) {
|
||||||
if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) {
|
if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) {
|
||||||
$Server = new Server( $this->{'ServerId'} );
|
$Server = new Server( $this->{'ServerId'} );
|
||||||
|
@ -178,27 +179,27 @@ private $control_fields = array(
|
||||||
$streamSrc = ZM_BASE_URL.ZM_PATH_ZMS;
|
$streamSrc = ZM_BASE_URL.ZM_PATH_ZMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
$args[] = "monitor=".$this->{'Id'};
|
$args['monitor'] = $this->{'Id'};
|
||||||
|
|
||||||
if ( ZM_OPT_USE_AUTH ) {
|
if ( ZM_OPT_USE_AUTH ) {
|
||||||
if ( ZM_AUTH_RELAY == "hashed" ) {
|
if ( ZM_AUTH_RELAY == 'hashed' ) {
|
||||||
$args[] = "auth=".generateAuthHash( ZM_AUTH_HASH_IPS );
|
$args['auth'] = generateAuthHash( ZM_AUTH_HASH_IPS );
|
||||||
} elseif ( ZM_AUTH_RELAY == "plain" ) {
|
} elseif ( ZM_AUTH_RELAY == 'plain' ) {
|
||||||
$args[] = "user=".$_SESSION['username'];
|
$args['user'] = $_SESSION['username'];
|
||||||
$args[] = "pass=".$_SESSION['password'];
|
$args['pass'] = $_SESSION['password'];
|
||||||
} elseif ( ZM_AUTH_RELAY == "none" ) {
|
} elseif ( ZM_AUTH_RELAY == 'none' ) {
|
||||||
$args[] = "user=".$_SESSION['username'];
|
$args['user'] = $_SESSION['username'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !in_array( "mode=single", $args ) && !empty($GLOBALS['connkey']) ) {
|
if ( ( (!isset($args['mode'])) or ( $args['mode'] != 'single' ) ) && !empty($GLOBALS['connkey']) ) {
|
||||||
$args[] = "connkey=".$GLOBALS['connkey'];
|
$args['connkey'] = $GLOBALS['connkey'];
|
||||||
}
|
}
|
||||||
if ( ZM_RAND_STREAM ) {
|
if ( ZM_RAND_STREAM ) {
|
||||||
$args[] = "rand=".time();
|
$args['rand'] = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count($args) ) {
|
if ( count($args) ) {
|
||||||
$streamSrc .= "?".join( $querySep, $args );
|
$streamSrc .= '?'.http_build_query( $args,'', $querySep );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( $streamSrc );
|
return( $streamSrc );
|
||||||
|
|
|
@ -103,6 +103,7 @@ if ( !empty($action) ) {
|
||||||
userLogin( $username, $password );
|
userLogin( $username, $password );
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
$view = 'console';
|
$view = 'console';
|
||||||
|
$redirect = true;
|
||||||
} else if ( $action == 'logout' ) {
|
} else if ( $action == 'logout' ) {
|
||||||
userLogout();
|
userLogout();
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
|
@ -133,37 +134,50 @@ if ( !empty($action) ) {
|
||||||
$filterName = $_REQUEST['newFilterName'];
|
$filterName = $_REQUEST['newFilterName'];
|
||||||
}
|
}
|
||||||
if ( $filterName ) {
|
if ( $filterName ) {
|
||||||
$sql = "REPLACE INTO Filters SET Name = ".dbEscape($filterName).",";
|
# Replace will teplace any filter with the same Id
|
||||||
|
# Since we aren't specifying the Id , this is effectively an insert
|
||||||
|
$sql = 'REPLACE INTO Filters SET Name = '.dbEscape($filterName).',';
|
||||||
} else {
|
} else {
|
||||||
$sql = 'UPDATE Filters SET';
|
$sql = 'UPDATE Filters SET';
|
||||||
$endSql = "where Id = ".$_REQUEST['Id'];
|
$endSql = 'WHERE Id = '.$_REQUEST['Id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endSql is only set if ! filterName... so... woulnd't this always be true
|
||||||
if ( !empty($filterName) || $endSql ) {
|
if ( !empty($filterName) || $endSql ) {
|
||||||
$_REQUEST['filter']['sort_field'] = validStr($_REQUEST['sort_field']);
|
$_REQUEST['filter']['sort_field'] = validStr($_REQUEST['sort_field']);
|
||||||
$_REQUEST['filter']['sort_asc'] = validStr($_REQUEST['sort_asc']);
|
$_REQUEST['filter']['sort_asc'] = validStr($_REQUEST['sort_asc']);
|
||||||
$_REQUEST['filter']['limit'] = validInt($_REQUEST['limit']);
|
$_REQUEST['filter']['limit'] = validInt($_REQUEST['limit']);
|
||||||
$sql .= " Query = ".dbEscape(jsonEncode($_REQUEST['filter']));
|
$sql .= ' Query = '.dbEscape(jsonEncode($_REQUEST['filter']));
|
||||||
if ( !empty($_REQUEST['AutoArchive']) )
|
if ( !empty($_REQUEST['AutoArchive']) )
|
||||||
$sql .= ", AutoArchive = ".dbEscape($_REQUEST['AutoArchive']);
|
$sql .= ', AutoArchive = '.dbEscape($_REQUEST['AutoArchive']);
|
||||||
if ( !empty($_REQUEST['AutoVideo']) )
|
if ( !empty($_REQUEST['AutoVideo']) )
|
||||||
$sql .= ", AutoVideo = ".dbEscape($_REQUEST['AutoVideo']);
|
$sql .= ', AutoVideo = '.dbEscape($_REQUEST['AutoVideo']);
|
||||||
if ( !empty($_REQUEST['AutoUpload']) )
|
if ( !empty($_REQUEST['AutoUpload']) )
|
||||||
$sql .= ", AutoUpload = ".dbEscape($_REQUEST['AutoUpload']);
|
$sql .= ', AutoUpload = '.dbEscape($_REQUEST['AutoUpload']);
|
||||||
if ( !empty($_REQUEST['AutoEmail']) )
|
if ( !empty($_REQUEST['AutoEmail']) )
|
||||||
$sql .= ", AutoEmail = ".dbEscape($_REQUEST['AutoEmail']);
|
$sql .= ', AutoEmail = '.dbEscape($_REQUEST['AutoEmail']);
|
||||||
if ( !empty($_REQUEST['AutoMessage']) )
|
if ( !empty($_REQUEST['AutoMessage']) )
|
||||||
$sql .= ", AutoMessage = ".dbEscape($_REQUEST['AutoMessage']);
|
$sql .= ', AutoMessage = '.dbEscape($_REQUEST['AutoMessage']);
|
||||||
if ( !empty($_REQUEST['AutoExecute']) && !empty($_REQUEST['AutoExecuteCmd']) )
|
if ( !empty($_REQUEST['AutoExecute']) && !empty($_REQUEST['AutoExecuteCmd']) )
|
||||||
$sql .= ", AutoExecute = ".dbEscape($_REQUEST['AutoExecute']).", AutoExecuteCmd = ".dbEscape($_REQUEST['AutoExecuteCmd']);
|
$sql .= ', AutoExecute = '.dbEscape($_REQUEST['AutoExecute']).", AutoExecuteCmd = ".dbEscape($_REQUEST['AutoExecuteCmd']);
|
||||||
if ( !empty($_REQUEST['AutoDelete']) )
|
if ( !empty($_REQUEST['AutoDelete']) )
|
||||||
$sql .= ", AutoDelete = ".dbEscape($_REQUEST['AutoDelete']);
|
$sql .= ', AutoDelete = '.dbEscape($_REQUEST['AutoDelete']);
|
||||||
if ( !empty($_REQUEST['background']) )
|
if ( !empty($_REQUEST['background']) )
|
||||||
$sql .= ", Background = ".dbEscape($_REQUEST['background']);
|
$sql .= ', Background = '.dbEscape($_REQUEST['background']);
|
||||||
if ( !empty($_REQUEST['concurrent']) )
|
if ( !empty($_REQUEST['concurrent']) )
|
||||||
$sql .= ", Concurrent = ".dbEscape($_REQUEST['concurrent']);
|
$sql .= ', Concurrent = '.dbEscape($_REQUEST['concurrent']);
|
||||||
$sql .= $endSql;
|
$sql .= $endSql;
|
||||||
dbQuery( $sql );
|
dbQuery( $sql );
|
||||||
$refreshParent = true;
|
if ( $filterName ) {
|
||||||
|
$filter = dbFetchOne( 'SELECT * FROM Filters WHERE Name=?', NULL, array($filterName) );
|
||||||
|
if ( $filter ) {
|
||||||
|
# This won't work yet because refreshparent refreshes the old filter. Need to do a redirect instead of a refresh.
|
||||||
|
$_REQUEST['Id'] = $filter['Id'];
|
||||||
|
} else {
|
||||||
|
Error("No new Id despite new name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$refreshParent = '/index.php?view=filter&Id='.$_REQUEST['Id'];
|
||||||
}
|
}
|
||||||
} // end if canedit events
|
} // end if canedit events
|
||||||
} // end if action == filter
|
} // end if action == filter
|
||||||
|
@ -512,7 +526,7 @@ if ( !empty($action) ) {
|
||||||
dbQuery( "update TriggersX10 set ".implode( ", ", $x10Changes )." where MonitorId=?", array($mid) );
|
dbQuery( "update TriggersX10 set ".implode( ", ", $x10Changes )." where MonitorId=?", array($mid) );
|
||||||
} elseif ( !$user['MonitorIds'] ) {
|
} elseif ( !$user['MonitorIds'] ) {
|
||||||
if ( !$x10Monitor ) {
|
if ( !$x10Monitor ) {
|
||||||
dbQuery( "insert into TriggersX10 set MonitorId = ?".implode( ", ", $x10Changes ), array( $mid ) );
|
dbQuery( "insert into TriggersX10 set MonitorId = ?, ".implode( ", ", $x10Changes ), array( $mid ) );
|
||||||
} else {
|
} else {
|
||||||
dbQuery( "delete from TriggersX10 where MonitorId = ?", array($mid) );
|
dbQuery( "delete from TriggersX10 where MonitorId = ?", array($mid) );
|
||||||
}
|
}
|
||||||
|
@ -822,12 +836,13 @@ if ( !empty($action) ) {
|
||||||
if ( count( $changes ) ) {
|
if ( count( $changes ) ) {
|
||||||
if ( !empty($_REQUEST['uid']) ) {
|
if ( !empty($_REQUEST['uid']) ) {
|
||||||
dbQuery( "update Users set ".implode( ", ", $changes )." where Id = ?", array($_REQUEST['uid']) );
|
dbQuery( "update Users set ".implode( ", ", $changes )." where Id = ?", array($_REQUEST['uid']) );
|
||||||
|
# If we are updating the logged in user, then update our session user data.
|
||||||
|
if ( $user and ( $dbUser['Username'] == $user['Username'] ) )
|
||||||
|
userLogin( $dbUser['Username'], $dbUser['Password'] );
|
||||||
} else {
|
} else {
|
||||||
dbQuery( "insert into Users set ".implode( ", ", $changes ) );
|
dbQuery( "insert into Users set ".implode( ", ", $changes ) );
|
||||||
}
|
}
|
||||||
$refreshParent = true;
|
$refreshParent = true;
|
||||||
if ( $dbUser['Username'] == $user['Username'] )
|
|
||||||
userLogin( $dbUser['Username'], $dbUser['Password'] );
|
|
||||||
}
|
}
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
} elseif ( $action == 'state' ) {
|
} elseif ( $action == 'state' ) {
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
Copyright (c) 2008-2013, Edward Z. Yang
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,69 @@
|
||||||
|
|
||||||
|
[[ news ]]
|
||||||
|
|
||||||
|
1.0.4 released 2013-07-17
|
||||||
|
|
||||||
|
[SECURITY FIXES]
|
||||||
|
|
||||||
|
- When secret key was not explicitly set, it was not being used
|
||||||
|
by the csrf_hash() function. Thanks sparticvs for reporting.
|
||||||
|
|
||||||
|
[FEATURES]
|
||||||
|
|
||||||
|
- The default 'CSRF check failed' page now offers a handy 'Try
|
||||||
|
again' button, which resubmits the form.
|
||||||
|
|
||||||
|
[BUG FIXES]
|
||||||
|
|
||||||
|
- The fix for 1.0.3 inadvertantly turned off XMLHttpRequest
|
||||||
|
overloading for all browsers; it has now been fixed to only
|
||||||
|
apply to IE.
|
||||||
|
|
||||||
|
1.0.3 released 2012-01-31
|
||||||
|
|
||||||
|
[BUG FIXES]
|
||||||
|
|
||||||
|
- Internet Explorer 8 adds support for XMLHttpRequest.prototype,
|
||||||
|
but this support is broken for method overloading. We
|
||||||
|
explicitly disable JavaScript overloading for Internet Explorer.
|
||||||
|
Thanks Kelly Lu for reporting. <lubird@gmail.com>
|
||||||
|
|
||||||
|
- A global declaration was omitted, resulting in a variable
|
||||||
|
not being properly introduced in PHP 5.3. Thanks Whitney Beck for
|
||||||
|
reporting. <whitney.a.beck@gmail.com>
|
||||||
|
|
||||||
|
1.0.2 released 2009-03-08
|
||||||
|
|
||||||
|
[SECURITY FIXES]
|
||||||
|
|
||||||
|
- Due to a typo, csrf-magic accidentally treated the secret key
|
||||||
|
as always present. This means that there was a possible CSRF
|
||||||
|
attack against users without any cookies. No attacks in the
|
||||||
|
wild were known at the time of this release. Thanks Jakub
|
||||||
|
Vrána for reporting.
|
||||||
|
|
||||||
|
1.0.1 released 2008-11-02
|
||||||
|
|
||||||
|
[NEW FEATURES]
|
||||||
|
|
||||||
|
- Support for composite tokens; this also fixes a bug with using
|
||||||
|
IP-based tokens for users with cookies disabled.
|
||||||
|
|
||||||
|
- Native support cookie tokens; use csrf_conf('cookie', $name) to
|
||||||
|
specify the name of a cookie that the CSRF token should be
|
||||||
|
placed in. This is useful if you have a Squid cache, and need
|
||||||
|
to configure it to ignore this token.
|
||||||
|
|
||||||
|
- Tips/tricks section in README.txt.
|
||||||
|
|
||||||
|
- There is now a two hour expiration time on all tokens. This
|
||||||
|
can be modified using csrf_conf('expires', $seconds).
|
||||||
|
|
||||||
|
- ClickJacking protection using an iframe breaker. Disable with
|
||||||
|
csrf_conf('frame-breaker', false).
|
||||||
|
|
||||||
|
[BUG FIXES]
|
||||||
|
|
||||||
|
- CsrfMagic.send() incorrectly submitted GET requests twice,
|
||||||
|
once without the magic token and once with the token. Reported
|
||||||
|
by Kelly Lu <lubird@gmail.com>.
|
|
@ -0,0 +1,160 @@
|
||||||
|
|
||||||
|
[[ csrf-magic ]]
|
||||||
|
|
||||||
|
Add the following line to the top of all web-accessible PHP pages. If you have
|
||||||
|
a common file included by everything, put it there.
|
||||||
|
|
||||||
|
include_once '/path/to/csrf-magic.php';
|
||||||
|
|
||||||
|
Do it, test it, then forget about it. csrf-magic is protecting you if nothing
|
||||||
|
bad happens. Read on if you run into problems.
|
||||||
|
|
||||||
|
|
||||||
|
TABLE OF CONTENTS
|
||||||
|
+ ------------------- +
|
||||||
|
1. TIPS AND TRICKS
|
||||||
|
2. AJAX
|
||||||
|
3. CONFIGURE
|
||||||
|
4. THANKS
|
||||||
|
5. FOOTNOTES
|
||||||
|
+ ------------------- +
|
||||||
|
|
||||||
|
|
||||||
|
1. TIPS AND TRICKS
|
||||||
|
|
||||||
|
* If your JavaScript and AJAX is persistently getting errors, check the
|
||||||
|
AJAX section below on how to fix.
|
||||||
|
|
||||||
|
* The CSS overlay protection makes it impossible to display your website
|
||||||
|
in frame/iframe elements. You can disable it with
|
||||||
|
csrf_conf('frame-breaker', false) in your csrf_startup() function.
|
||||||
|
|
||||||
|
* csrf-magic will start a session. To disable, use csrf_conf('auto-session',
|
||||||
|
false) in your csrf_startup() function.
|
||||||
|
|
||||||
|
* The default error message is a little user unfriendly. Write your own
|
||||||
|
function which outputs an error message and set csrf_conf('callback',
|
||||||
|
'myCallbackFunction') in your csrf_startup() function.
|
||||||
|
|
||||||
|
* Make sure csrf_conf('secret', 'ABCDEFG') has something random in it. If
|
||||||
|
the directory csrf-magic.php is in is writable, csrf-magic will generate
|
||||||
|
a secret key for you in the csrf-secret.php file.
|
||||||
|
|
||||||
|
* Remember you can use auto_prepend to include csrf-magic.php on all your
|
||||||
|
pages. You may want to create a stub file which you can include that
|
||||||
|
includes csrf-magic.php as well as performs configuration.
|
||||||
|
|
||||||
|
* The default expiration time for tokens is two hours. If you expect your
|
||||||
|
users to need longer to fill out forms, be sure to enable double
|
||||||
|
submission when the token is invalid.
|
||||||
|
|
||||||
|
|
||||||
|
2. AJAX
|
||||||
|
|
||||||
|
csrf-magic has the ability to dynamically rewrite AJAX requests which use
|
||||||
|
XMLHttpRequest. However, due to the invasiveness of this procedure, it is
|
||||||
|
not enabled by default. You can enable it by adding this code before you
|
||||||
|
include csrf-magic.php.
|
||||||
|
|
||||||
|
function csrf_startup() {
|
||||||
|
csrf_conf('rewrite-js', '/web/path/to/csrf-magic.js');
|
||||||
|
}
|
||||||
|
// include_once '/path/to/csrf-magic.php';
|
||||||
|
|
||||||
|
(Be sure to place csrf-magic.js somewhere web accessible).
|
||||||
|
|
||||||
|
The default method CSRF Magic uses to rewrite AJAX requests will
|
||||||
|
only work for browsers with support for XmlHttpRequest.prototype (this excludes
|
||||||
|
all versions of Internet Explorer). See this page for more information:
|
||||||
|
http://stackoverflow.com/questions/664315/internet-explorer-8-prototypes-and-xmlhttprequest
|
||||||
|
|
||||||
|
However, csrf-magic.js will
|
||||||
|
automatically detect and play nice with the following JavaScript frameworks:
|
||||||
|
|
||||||
|
* jQuery
|
||||||
|
* Prototype
|
||||||
|
* MooTools
|
||||||
|
* Ext
|
||||||
|
* Dojo
|
||||||
|
|
||||||
|
(Note 2013-07-16: It has been a long time since this manual support has
|
||||||
|
been updated, and some JavaScript libraries have placed their copies of XHR
|
||||||
|
in local variables in closures, which makes it difficult for us to monkey-patch
|
||||||
|
it in automatically.)
|
||||||
|
|
||||||
|
To rewrite your own JavaScript library to use csrf-magic.js, you should modify
|
||||||
|
your function that generates XMLHttpRequest to have this at the end:
|
||||||
|
|
||||||
|
return new CsrfMagic(xhrObject);
|
||||||
|
|
||||||
|
With whatever xhrObject may be. If you have literal instances of XMLHttpRequest
|
||||||
|
in your code, find and replace ''new XMLHttpRequest'' with ''new CsrfMagic''
|
||||||
|
(CsrfMagic will automatically instantiate an XMLHttpRequest object in a
|
||||||
|
cross-platform manner as necessary).
|
||||||
|
|
||||||
|
If you don't want csrf-magic monkeying around with your XMLHttpRequest object,
|
||||||
|
you can manually rewrite your AJAX code to include the variable. The important
|
||||||
|
information is stored in the global variables csrfMagicName and csrfMagicToken.
|
||||||
|
CsrfMagic.process may also be of interest, as it takes one parameter, a
|
||||||
|
querystring, and prepends the CSRF token to the value.
|
||||||
|
|
||||||
|
|
||||||
|
3. CONFIGURE
|
||||||
|
|
||||||
|
csrf-magic has some configuration options that you can set inside the
|
||||||
|
csrf_startup() function. They are described in csrf-magic.php, and you can
|
||||||
|
set them using the convenience function csrf_conf($name, $value).
|
||||||
|
|
||||||
|
For example, this is a recommended configuration:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a function that gets called if a csrf check fails. csrf-magic will
|
||||||
|
* then exit afterwards.
|
||||||
|
*/
|
||||||
|
function my_csrf_callback() {
|
||||||
|
echo "You're doing bad things young man!";
|
||||||
|
}
|
||||||
|
|
||||||
|
function csrf_startup() {
|
||||||
|
|
||||||
|
// While csrf-magic has a handy little heuristic for determining whether
|
||||||
|
// or not the content in the buffer is HTML or not, you should really
|
||||||
|
// give it a nudge and turn rewriting *off* when the content is
|
||||||
|
// not HTML. Implementation details will vary.
|
||||||
|
if (isset($_POST['ajax'])) csrf_conf('rewrite', false);
|
||||||
|
|
||||||
|
// This is a secret value that must be set in order to enable username
|
||||||
|
// and IP based checks. Don't show this to anyone. A secret id will
|
||||||
|
// automatically be generated for you if the directory csrf-magic.php
|
||||||
|
// is placed in is writable.
|
||||||
|
csrf_conf('secret', 'ABCDEFG123456');
|
||||||
|
|
||||||
|
// This enables JavaScript rewriting and will ensure your AJAX calls
|
||||||
|
// don't stop working.
|
||||||
|
csrf_conf('rewrite-js', '/csrf-magic.js');
|
||||||
|
|
||||||
|
// This makes csrf-magic call my_csrf_callback() before exiting when
|
||||||
|
// there is a bad csrf token. This lets me customize the error page.
|
||||||
|
csrf_conf('callback', 'my_csrf_callback');
|
||||||
|
|
||||||
|
// While this is enabled by default to boost backwards compatibility,
|
||||||
|
// for security purposes it should ideally be off. Some users can be
|
||||||
|
// NATted or have dialup addresses which rotate frequently. Cookies
|
||||||
|
// are much more reliable.
|
||||||
|
csrf_conf('allow-ip', false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, include the library
|
||||||
|
include_once '/path/to/csrf-magic.php';
|
||||||
|
|
||||||
|
Configuration gets stored in the $GLOBALS['csrf'] array.
|
||||||
|
|
||||||
|
|
||||||
|
4. THANKS
|
||||||
|
|
||||||
|
My thanks to Chris Shiflett, for unintentionally inspiring the idea, as well
|
||||||
|
as telling me the original variant of the Bob and Mallory story,
|
||||||
|
and the Django CSRF Middleware authors, who thought up of this before me.
|
||||||
|
Gareth Heyes suggested using the frame-breaker option to protect against
|
||||||
|
CSS overlay attacks.
|
|
@ -0,0 +1,191 @@
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* Rewrites XMLHttpRequest to automatically send CSRF token with it. In theory
|
||||||
|
* plays nice with other JavaScript libraries, needs testing though.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Here are the basic overloaded method definitions
|
||||||
|
// The wrapper must be set BEFORE onreadystatechange is written to, since
|
||||||
|
// a bug in ActiveXObject prevents us from properly testing for it.
|
||||||
|
CsrfMagic = function(real) {
|
||||||
|
// try to make it ourselves, if you didn't pass it
|
||||||
|
if (!real) try { real = new XMLHttpRequest; } catch (e) {;}
|
||||||
|
if (!real) try { real = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) {;}
|
||||||
|
if (!real) try { real = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) {;}
|
||||||
|
if (!real) try { real = new ActiveXObject('Msxml2.XMLHTTP.4.0'); } catch (e) {;}
|
||||||
|
this.csrf = real;
|
||||||
|
// properties
|
||||||
|
var csrfMagic = this;
|
||||||
|
real.onreadystatechange = function() {
|
||||||
|
csrfMagic._updateProps();
|
||||||
|
return csrfMagic.onreadystatechange ? csrfMagic.onreadystatechange() : null;
|
||||||
|
};
|
||||||
|
csrfMagic._updateProps();
|
||||||
|
}
|
||||||
|
|
||||||
|
CsrfMagic.prototype = {
|
||||||
|
|
||||||
|
open: function(method, url, async, username, password) {
|
||||||
|
if (method == 'POST') this.csrf_isPost = true;
|
||||||
|
// deal with Opera bug, thanks jQuery
|
||||||
|
if (username) return this.csrf_open(method, url, async, username, password);
|
||||||
|
else return this.csrf_open(method, url, async);
|
||||||
|
},
|
||||||
|
csrf_open: function(method, url, async, username, password) {
|
||||||
|
if (username) return this.csrf.open(method, url, async, username, password);
|
||||||
|
else return this.csrf.open(method, url, async);
|
||||||
|
},
|
||||||
|
|
||||||
|
send: function(data) {
|
||||||
|
if (!this.csrf_isPost) return this.csrf_send(data);
|
||||||
|
prepend = csrfMagicName + '=' + csrfMagicToken + '&';
|
||||||
|
// XXX: Removed to eliminate 'Refused to set unsafe header "Content-length" ' errors in modern browsers
|
||||||
|
// if (this.csrf_purportedLength === undefined) {
|
||||||
|
// this.csrf_setRequestHeader("Content-length", this.csrf_purportedLength + prepend.length);
|
||||||
|
// delete this.csrf_purportedLength;
|
||||||
|
// }
|
||||||
|
delete this.csrf_isPost;
|
||||||
|
return this.csrf_send(prepend + data);
|
||||||
|
},
|
||||||
|
csrf_send: function(data) {
|
||||||
|
return this.csrf.send(data);
|
||||||
|
},
|
||||||
|
|
||||||
|
setRequestHeader: function(header, value) {
|
||||||
|
// We have to auto-set this at the end, since we don't know how long the
|
||||||
|
// nonce is when added to the data.
|
||||||
|
if (this.csrf_isPost && header == "Content-length") {
|
||||||
|
this.csrf_purportedLength = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.csrf_setRequestHeader(header, value);
|
||||||
|
},
|
||||||
|
csrf_setRequestHeader: function(header, value) {
|
||||||
|
return this.csrf.setRequestHeader(header, value);
|
||||||
|
},
|
||||||
|
|
||||||
|
abort: function() {
|
||||||
|
return this.csrf.abort();
|
||||||
|
},
|
||||||
|
getAllResponseHeaders: function() {
|
||||||
|
return this.csrf.getAllResponseHeaders();
|
||||||
|
},
|
||||||
|
getResponseHeader: function(header) {
|
||||||
|
return this.csrf.getResponseHeader(header);
|
||||||
|
} // ,
|
||||||
|
}
|
||||||
|
|
||||||
|
// proprietary
|
||||||
|
CsrfMagic.prototype._updateProps = function() {
|
||||||
|
this.readyState = this.csrf.readyState;
|
||||||
|
if (this.readyState == 4) {
|
||||||
|
this.responseText = this.csrf.responseText;
|
||||||
|
this.responseXML = this.csrf.responseXML;
|
||||||
|
this.status = this.csrf.status;
|
||||||
|
this.statusText = this.csrf.statusText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CsrfMagic.process = function(base) {
|
||||||
|
if(typeof base == 'object') {
|
||||||
|
base[csrfMagicName] = csrfMagicToken;
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
var prepend = csrfMagicName + '=' + csrfMagicToken;
|
||||||
|
if (base) return prepend + '&' + base;
|
||||||
|
return prepend;
|
||||||
|
}
|
||||||
|
// callback function for when everything on the page has loaded
|
||||||
|
CsrfMagic.end = function() {
|
||||||
|
// This rewrites forms AGAIN, so in case buffering didn't work this
|
||||||
|
// certainly will.
|
||||||
|
forms = document.getElementsByTagName('form');
|
||||||
|
for (var i = 0; i < forms.length; i++) {
|
||||||
|
form = forms[i];
|
||||||
|
if (form.method.toUpperCase() !== 'POST') continue;
|
||||||
|
if (form.elements[csrfMagicName]) continue;
|
||||||
|
var input = document.createElement('input');
|
||||||
|
input.setAttribute('name', csrfMagicName);
|
||||||
|
input.setAttribute('value', csrfMagicToken);
|
||||||
|
input.setAttribute('type', 'hidden');
|
||||||
|
form.appendChild(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets things up for Mozilla/Opera/nice browsers
|
||||||
|
// We very specifically match against Internet Explorer, since they haven't
|
||||||
|
// implemented prototypes correctly yet.
|
||||||
|
if (window.XMLHttpRequest && window.XMLHttpRequest.prototype && '\v' != 'v') {
|
||||||
|
var x = XMLHttpRequest.prototype;
|
||||||
|
var c = CsrfMagic.prototype;
|
||||||
|
|
||||||
|
// Save the original functions
|
||||||
|
x.csrf_open = x.open;
|
||||||
|
x.csrf_send = x.send;
|
||||||
|
x.csrf_setRequestHeader = x.setRequestHeader;
|
||||||
|
|
||||||
|
// Notice that CsrfMagic is itself an instantiatable object, but only
|
||||||
|
// open, send and setRequestHeader are necessary as decorators.
|
||||||
|
x.open = c.open;
|
||||||
|
x.send = c.send;
|
||||||
|
x.setRequestHeader = c.setRequestHeader;
|
||||||
|
} else {
|
||||||
|
// The only way we can do this is by modifying a library you have been
|
||||||
|
// using. We support YUI, script.aculo.us, prototype, MooTools,
|
||||||
|
// jQuery, Ext and Dojo.
|
||||||
|
if (window.jQuery) {
|
||||||
|
// jQuery didn't implement a new XMLHttpRequest function, so we have
|
||||||
|
// to do this the hard way.
|
||||||
|
jQuery.csrf_ajax = jQuery.ajax;
|
||||||
|
jQuery.ajax = function( s ) {
|
||||||
|
if (s.type && s.type.toUpperCase() == 'POST') {
|
||||||
|
s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
|
||||||
|
if ( s.data && s.processData && typeof s.data != "string" ) {
|
||||||
|
s.data = jQuery.param(s.data);
|
||||||
|
}
|
||||||
|
s.data = CsrfMagic.process(s.data);
|
||||||
|
}
|
||||||
|
return jQuery.csrf_ajax( s );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (window.Prototype) {
|
||||||
|
// This works for script.aculo.us too
|
||||||
|
Ajax.csrf_getTransport = Ajax.getTransport;
|
||||||
|
Ajax.getTransport = function() {
|
||||||
|
return new CsrfMagic(Ajax.csrf_getTransport());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (window.MooTools) {
|
||||||
|
Browser.csrf_Request = Browser.Request;
|
||||||
|
Browser.Request = function () {
|
||||||
|
return new CsrfMagic(Browser.csrf_Request());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (window.YAHOO) {
|
||||||
|
// old YUI API
|
||||||
|
YAHOO.util.Connect.csrf_createXhrObject = YAHOO.util.Connect.createXhrObject;
|
||||||
|
YAHOO.util.Connect.createXhrObject = function (transaction) {
|
||||||
|
obj = YAHOO.util.Connect.csrf_createXhrObject(transaction);
|
||||||
|
obj.conn = new CsrfMagic(obj.conn);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (window.Ext) {
|
||||||
|
// Ext can use other js libraries as loaders, so it has to come last
|
||||||
|
// Ext's implementation is pretty identical to Yahoo's, but we duplicate
|
||||||
|
// it for comprehensiveness's sake.
|
||||||
|
Ext.lib.Ajax.csrf_createXhrObject = Ext.lib.Ajax.createXhrObject;
|
||||||
|
Ext.lib.Ajax.createXhrObject = function (transaction) {
|
||||||
|
obj = Ext.lib.Ajax.csrf_createXhrObject(transaction);
|
||||||
|
obj.conn = new CsrfMagic(obj.conn);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (window.dojo) {
|
||||||
|
// NOTE: this doesn't work with latest dojo
|
||||||
|
dojo.csrf__xhrObj = dojo._xhrObj;
|
||||||
|
dojo._xhrObj = function () {
|
||||||
|
return new CsrfMagic(dojo.csrf__xhrObj());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,405 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* csrf-magic is a PHP library that makes adding CSRF-protection to your
|
||||||
|
* web applications a snap. No need to modify every form or create a database
|
||||||
|
* of valid nonces; just include this file at the top of every
|
||||||
|
* web-accessible page (or even better, your common include file included
|
||||||
|
* in every page), and forget about it! (There are, of course, configuration
|
||||||
|
* options for advanced users).
|
||||||
|
*
|
||||||
|
* This library is PHP4 and PHP5 compatible.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// CONFIGURATION:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, when you include this file csrf-magic will automatically check
|
||||||
|
* and exit if the CSRF token is invalid. This will defer executing
|
||||||
|
* csrf_check() until you're ready. You can also pass false as a parameter to
|
||||||
|
* that function, in which case the function will not exit but instead return
|
||||||
|
* a boolean false if the CSRF check failed. This allows for tighter integration
|
||||||
|
* with your system.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['defer'] = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the amount of seconds you wish to allow before any token becomes
|
||||||
|
* invalid; the default is two hours, which should be more than enough for
|
||||||
|
* most websites.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['expires'] = 7200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback function to execute when there's the CSRF check fails and
|
||||||
|
* $fatal == true (see csrf_check). This will usually output an error message
|
||||||
|
* about the failure.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['callback'] = 'csrf_callback';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not to include our JavaScript library which also rewrites
|
||||||
|
* AJAX requests on this domain. Set this to the web path. This setting only works
|
||||||
|
* with supported JavaScript libraries in Internet Explorer; see README.txt for
|
||||||
|
* a list of supported libraries.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['rewrite-js'] = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A secret key used when hashing items. Please generate a random string and
|
||||||
|
* place it here. If you change this value, all previously generated tokens
|
||||||
|
* will become invalid.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['secret'] = '';
|
||||||
|
// nota bene: library code should use csrf_get_secret() and not access
|
||||||
|
// this global directly
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set this to false to disable csrf-magic's output handler, and therefore,
|
||||||
|
* its rewriting capabilities. If you're serving non HTML content, you should
|
||||||
|
* definitely set this false.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['rewrite'] = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not to use IP addresses when binding a user to a token. This is
|
||||||
|
* less reliable and less secure than sessions, but is useful when you need
|
||||||
|
* to give facilities to anonymous users and do not wish to maintain a database
|
||||||
|
* of valid keys.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['allow-ip'] = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this information is available, use the cookie by this name to determine
|
||||||
|
* whether or not to allow the request. This is a shortcut implementation
|
||||||
|
* very similar to 'key', but we randomly set the cookie ourselves.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['cookie'] = '__csrf_cookie';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this information is available, set this to a unique identifier (it
|
||||||
|
* can be an integer or a unique username) for the current "user" of this
|
||||||
|
* application. The token will then be globally valid for all of that user's
|
||||||
|
* operations, but no one else. This requires that 'secret' be set.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['user'] = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an arbitrary secret value associated with the user's session. This
|
||||||
|
* will most probably be the contents of a cookie, as an attacker cannot easily
|
||||||
|
* determine this information. Warning: If the attacker knows this value, they
|
||||||
|
* can easily spoof a token. This is a generic implementation; sessions should
|
||||||
|
* work in most cases.
|
||||||
|
*
|
||||||
|
* Why would you want to use this? Lets suppose you have a squid cache for your
|
||||||
|
* website, and the presence of a session cookie bypasses it. Let's also say
|
||||||
|
* you allow anonymous users to interact with the website; submitting forms
|
||||||
|
* and AJAX. Previously, you didn't have any CSRF protection for anonymous users
|
||||||
|
* and so they never got sessions; you don't want to start using sessions either,
|
||||||
|
* otherwise you'll bypass the Squid cache. Setup a different cookie for CSRF
|
||||||
|
* tokens, and have Squid ignore that cookie for get requests, for anonymous
|
||||||
|
* users. (If you haven't guessed, this scheme was(?) used for MediaWiki).
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['key'] = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the magic CSRF token that will be placed in all forms, i.e.
|
||||||
|
* the contents of <input type="hidden" name="$name" value="CSRF-TOKEN" />
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['input-name'] = '__csrf_magic';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set this to false if your site must work inside of frame/iframe elements,
|
||||||
|
* but do so at your own risk: this configuration protects you against CSS
|
||||||
|
* overlay attacks that defeat tokens.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['frame-breaker'] = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not CSRF Magic should be allowed to start a new session in order
|
||||||
|
* to determine the key.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['auto-session'] = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not csrf-magic should produce XHTML style tags.
|
||||||
|
*/
|
||||||
|
$GLOBALS['csrf']['xhtml'] = true;
|
||||||
|
|
||||||
|
// FUNCTIONS:
|
||||||
|
|
||||||
|
// Don't edit this!
|
||||||
|
$GLOBALS['csrf']['version'] = '1.0.4';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrites <form> on the fly to add CSRF tokens to them. This can also
|
||||||
|
* inject our JavaScript library.
|
||||||
|
*/
|
||||||
|
function csrf_ob_handler($buffer, $flags) {
|
||||||
|
// Even though the user told us to rewrite, we should do a quick heuristic
|
||||||
|
// to check if the page is *actually* HTML. We don't begin rewriting until
|
||||||
|
// we hit the first <html tag.
|
||||||
|
static $is_html = false;
|
||||||
|
if (!$is_html) {
|
||||||
|
// not HTML until proven otherwise
|
||||||
|
if (stripos($buffer, '<html') !== false) {
|
||||||
|
$is_html = true;
|
||||||
|
} else {
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$tokens = csrf_get_tokens();
|
||||||
|
$name = $GLOBALS['csrf']['input-name'];
|
||||||
|
$endslash = $GLOBALS['csrf']['xhtml'] ? ' /' : '';
|
||||||
|
$input = "<input type='hidden' name='$name' value=\"$tokens\"$endslash>";
|
||||||
|
$buffer = preg_replace('#(<form[^>]*method\s*=\s*["\']post["\'][^>]*>)#i', '$1' . $input, $buffer);
|
||||||
|
if ($GLOBALS['csrf']['frame-breaker']) {
|
||||||
|
$buffer = str_ireplace('</head>', '<script type="text/javascript">if (top != self) {top.location.href = self.location.href;}</script></head>', $buffer);
|
||||||
|
}
|
||||||
|
if ($js = $GLOBALS['csrf']['rewrite-js']) {
|
||||||
|
$buffer = str_ireplace(
|
||||||
|
'</head>',
|
||||||
|
'<script type="text/javascript">'.
|
||||||
|
'var csrfMagicToken = "'.$tokens.'";'.
|
||||||
|
'var csrfMagicName = "'.$name.'";</script>'.
|
||||||
|
'<script src="'.$js.'" type="text/javascript"></script></head>',
|
||||||
|
$buffer
|
||||||
|
);
|
||||||
|
$script = '<script type="text/javascript">CsrfMagic.end();</script>';
|
||||||
|
$buffer = str_ireplace('</body>', $script . '</body>', $buffer, $count);
|
||||||
|
if (!$count) {
|
||||||
|
$buffer .= $script;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this is a post request, and if it is, checks if the nonce is valid.
|
||||||
|
* @param bool $fatal Whether or not to fatally error out if there is a problem.
|
||||||
|
* @return True if check passes or is not necessary, false if failure.
|
||||||
|
*/
|
||||||
|
function csrf_check($fatal = true) {
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') return true;
|
||||||
|
csrf_start();
|
||||||
|
$name = $GLOBALS['csrf']['input-name'];
|
||||||
|
$ok = false;
|
||||||
|
$tokens = '';
|
||||||
|
do {
|
||||||
|
if (!isset($_POST[$name])) break;
|
||||||
|
// we don't regenerate a token and check it because some token creation
|
||||||
|
// schemes are volatile.
|
||||||
|
$tokens = $_POST[$name];
|
||||||
|
if (!csrf_check_tokens($tokens)) break;
|
||||||
|
$ok = true;
|
||||||
|
} while (false);
|
||||||
|
if ($fatal && !$ok) {
|
||||||
|
$callback = $GLOBALS['csrf']['callback'];
|
||||||
|
if (trim($tokens, 'A..Za..z0..9:;,') !== '') $tokens = 'hidden';
|
||||||
|
$callback($tokens);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a valid token(s) for a particular context. Tokens are separated
|
||||||
|
* by semicolons.
|
||||||
|
*/
|
||||||
|
function csrf_get_tokens() {
|
||||||
|
$has_cookies = !empty($_COOKIE);
|
||||||
|
|
||||||
|
// $ip implements a composite key, which is sent if the user hasn't sent
|
||||||
|
// any cookies. It may or may not be used, depending on whether or not
|
||||||
|
// the cookies "stick"
|
||||||
|
$secret = csrf_get_secret();
|
||||||
|
if (!$has_cookies && $secret) {
|
||||||
|
// :TODO: Harden this against proxy-spoofing attacks
|
||||||
|
$IP_ADDRESS = (isset($_SERVER['IP_ADDRESS']) ? $_SERVER['IP_ADDRESS'] : $_SERVER['REMOTE_ADDR']);
|
||||||
|
$ip = ';ip:' . csrf_hash($IP_ADDRESS);
|
||||||
|
} else {
|
||||||
|
$ip = '';
|
||||||
|
}
|
||||||
|
csrf_start();
|
||||||
|
|
||||||
|
// These are "strong" algorithms that don't require per se a secret
|
||||||
|
if (session_id()) return 'sid:' . csrf_hash(session_id()) . $ip;
|
||||||
|
if ($GLOBALS['csrf']['cookie']) {
|
||||||
|
$val = csrf_generate_secret();
|
||||||
|
setcookie($GLOBALS['csrf']['cookie'], $val);
|
||||||
|
return 'cookie:' . csrf_hash($val) . $ip;
|
||||||
|
}
|
||||||
|
if ($GLOBALS['csrf']['key']) return 'key:' . csrf_hash($GLOBALS['csrf']['key']) . $ip;
|
||||||
|
// These further algorithms require a server-side secret
|
||||||
|
if (!$secret) return 'invalid';
|
||||||
|
if ($GLOBALS['csrf']['user'] !== false) {
|
||||||
|
return 'user:' . csrf_hash($GLOBALS['csrf']['user']);
|
||||||
|
}
|
||||||
|
if ($GLOBALS['csrf']['allow-ip']) {
|
||||||
|
return ltrim($ip, ';');
|
||||||
|
}
|
||||||
|
return 'invalid';
|
||||||
|
}
|
||||||
|
|
||||||
|
function csrf_flattenpost($data) {
|
||||||
|
$ret = array();
|
||||||
|
foreach($data as $n => $v) {
|
||||||
|
$ret = array_merge($ret, csrf_flattenpost2(1, $n, $v));
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
function csrf_flattenpost2($level, $key, $data) {
|
||||||
|
if(!is_array($data)) return array($key => $data);
|
||||||
|
$ret = array();
|
||||||
|
foreach($data as $n => $v) {
|
||||||
|
$nk = $level >= 1 ? $key."[$n]" : "[$n]";
|
||||||
|
$ret = array_merge($ret, csrf_flattenpost2($level+1, $nk, $v));
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $tokens is safe for HTML consumption
|
||||||
|
*/
|
||||||
|
function csrf_callback($tokens) {
|
||||||
|
// (yes, $tokens is safe to echo without escaping)
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
|
||||||
|
$data = '';
|
||||||
|
foreach (csrf_flattenpost($_POST) as $key => $value) {
|
||||||
|
if ($key == $GLOBALS['csrf']['input-name']) continue;
|
||||||
|
$data .= '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($value).'" />';
|
||||||
|
}
|
||||||
|
echo "<html><head><title>CSRF check failed</title></head>
|
||||||
|
<body>
|
||||||
|
<p>CSRF check failed. Your form session may have expired, or you may not have
|
||||||
|
cookies enabled.</p>
|
||||||
|
<form method='post' action=''>$data<input type='submit' value='Try again' /></form>
|
||||||
|
<p>Debug: $tokens</p></body></html>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a composite token is valid. Outward facing code should use this
|
||||||
|
* instead of csrf_check_token()
|
||||||
|
*/
|
||||||
|
function csrf_check_tokens($tokens) {
|
||||||
|
if (is_string($tokens)) $tokens = explode(';', $tokens);
|
||||||
|
foreach ($tokens as $token) {
|
||||||
|
if (csrf_check_token($token)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a token is valid.
|
||||||
|
*/
|
||||||
|
function csrf_check_token($token) {
|
||||||
|
if (strpos($token, ':') === false) return false;
|
||||||
|
list($type, $value) = explode(':', $token, 2);
|
||||||
|
if (strpos($value, ',') === false) return false;
|
||||||
|
list($x, $time) = explode(',', $token, 2);
|
||||||
|
if ($GLOBALS['csrf']['expires']) {
|
||||||
|
if (time() > $time + $GLOBALS['csrf']['expires']) return false;
|
||||||
|
}
|
||||||
|
switch ($type) {
|
||||||
|
case 'sid':
|
||||||
|
return $value === csrf_hash(session_id(), $time);
|
||||||
|
case 'cookie':
|
||||||
|
$n = $GLOBALS['csrf']['cookie'];
|
||||||
|
if (!$n) return false;
|
||||||
|
if (!isset($_COOKIE[$n])) return false;
|
||||||
|
return $value === csrf_hash($_COOKIE[$n], $time);
|
||||||
|
case 'key':
|
||||||
|
if (!$GLOBALS['csrf']['key']) return false;
|
||||||
|
return $value === csrf_hash($GLOBALS['csrf']['key'], $time);
|
||||||
|
// We could disable these 'weaker' checks if 'key' was set, but
|
||||||
|
// that doesn't make me feel good then about the cookie-based
|
||||||
|
// implementation.
|
||||||
|
case 'user':
|
||||||
|
if (!csrf_get_secret()) return false;
|
||||||
|
if ($GLOBALS['csrf']['user'] === false) return false;
|
||||||
|
return $value === csrf_hash($GLOBALS['csrf']['user'], $time);
|
||||||
|
case 'ip':
|
||||||
|
if (!csrf_get_secret()) return false;
|
||||||
|
// do not allow IP-based checks if the username is set, or if
|
||||||
|
// the browser sent cookies
|
||||||
|
if ($GLOBALS['csrf']['user'] !== false) return false;
|
||||||
|
if (!empty($_COOKIE)) return false;
|
||||||
|
if (!$GLOBALS['csrf']['allow-ip']) return false;
|
||||||
|
$IP_ADDRESS = (isset($_SERVER['IP_ADDRESS']) ? $_SERVER['IP_ADDRESS'] : $_SERVER['REMOTE_ADDR']);
|
||||||
|
return $value === csrf_hash($IP_ADDRESS, $time);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a configuration value.
|
||||||
|
*/
|
||||||
|
function csrf_conf($key, $val) {
|
||||||
|
if (!isset($GLOBALS['csrf'][$key])) {
|
||||||
|
trigger_error('No such configuration ' . $key, E_USER_WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$GLOBALS['csrf'][$key] = $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a session if we're allowed to.
|
||||||
|
*/
|
||||||
|
function csrf_start() {
|
||||||
|
if ($GLOBALS['csrf']['auto-session'] && !session_id()) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the secret, and generates one if necessary.
|
||||||
|
*/
|
||||||
|
function csrf_get_secret() {
|
||||||
|
if ($GLOBALS['csrf']['secret']) return $GLOBALS['csrf']['secret'];
|
||||||
|
$dir = dirname(__FILE__);
|
||||||
|
$file = $dir . '/csrf-secret.php';
|
||||||
|
$secret = '';
|
||||||
|
if (file_exists($file)) {
|
||||||
|
include $file;
|
||||||
|
return $secret;
|
||||||
|
}
|
||||||
|
if (is_writable($dir)) {
|
||||||
|
$secret = csrf_generate_secret();
|
||||||
|
$fh = fopen($file, 'w');
|
||||||
|
fwrite($fh, '<?php $secret = "'.$secret.'";' . PHP_EOL);
|
||||||
|
fclose($fh);
|
||||||
|
return $secret;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a random string as the hash of time, microtime, and mt_rand.
|
||||||
|
*/
|
||||||
|
function csrf_generate_secret($len = 32) {
|
||||||
|
$r = '';
|
||||||
|
for ($i = 0; $i < $len; $i++) {
|
||||||
|
$r .= chr(mt_rand(0, 255));
|
||||||
|
}
|
||||||
|
$r .= time() . microtime();
|
||||||
|
return sha1($r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a hash/expiry double. If time isn't set it will be calculated
|
||||||
|
* from the current time.
|
||||||
|
*/
|
||||||
|
function csrf_hash($value, $time = null) {
|
||||||
|
if (!$time) $time = time();
|
||||||
|
return sha1(csrf_get_secret() . $value . $time) . ',' . $time;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load user configuration
|
||||||
|
if (function_exists('csrf_startup')) csrf_startup();
|
||||||
|
// Initialize our handler
|
||||||
|
if ($GLOBALS['csrf']['rewrite']) ob_start('csrf_ob_handler');
|
||||||
|
// Perform check
|
||||||
|
if (!$GLOBALS['csrf']['defer']) csrf_check();
|
|
@ -19,7 +19,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// Compatibility functions
|
// Compatibility functions
|
||||||
if ( version_compare( phpversion(), "4.3.0", "<") ) {
|
if ( version_compare( phpversion(), '4.3.0', '<') ) {
|
||||||
function ob_get_clean() {
|
function ob_get_clean() {
|
||||||
$buffer = ob_get_contents();
|
$buffer = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
@ -27,24 +27,24 @@ if ( version_compare( phpversion(), "4.3.0", "<") ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function userLogin( $username, $password="", $passwordHashed=false ) {
|
function userLogin( $username, $password='', $passwordHashed=false ) {
|
||||||
global $user, $cookies;
|
global $user, $cookies;
|
||||||
|
|
||||||
$sql = "select * from Users where Enabled = 1";
|
$sql = 'SELECT * FROM Users WHERE Enabled = 1';
|
||||||
$sql_values = NULL;
|
$sql_values = NULL;
|
||||||
if ( ZM_AUTH_TYPE == "builtin" ) {
|
if ( ZM_AUTH_TYPE == 'builtin' ) {
|
||||||
if ( $passwordHashed ) {
|
if ( $passwordHashed ) {
|
||||||
$sql .= " AND Username=? AND Password=?";
|
$sql .= ' AND Username=? AND Password=?';
|
||||||
} else {
|
} else {
|
||||||
$sql .= " AND Username=? AND Password=password(?)";
|
$sql .= ' AND Username=? AND Password=password(?)';
|
||||||
}
|
}
|
||||||
$sql_values = array( $username, $password );
|
$sql_values = array( $username, $password );
|
||||||
} else {
|
} else {
|
||||||
$sql .= " AND Username = ?";
|
$sql .= ' AND Username = ?';
|
||||||
$sql_values = array( $username );
|
$sql_values = array( $username );
|
||||||
}
|
}
|
||||||
$_SESSION['username'] = $username;
|
$_SESSION['username'] = $username;
|
||||||
if ( ZM_AUTH_RELAY == "plain" ) {
|
if ( ZM_AUTH_RELAY == 'plain' ) {
|
||||||
// Need to save this in session
|
// Need to save this in session
|
||||||
$_SESSION['password'] = $password;
|
$_SESSION['password'] = $password;
|
||||||
}
|
}
|
||||||
|
@ -338,9 +338,9 @@ function outputImageStream( $id, $src, $width, $height, $title="" ) {
|
||||||
|
|
||||||
function getImageStream( $id, $src, $width, $height, $title="" ) {
|
function getImageStream( $id, $src, $width, $height, $title="" ) {
|
||||||
if ( canStreamIframe() ) {
|
if ( canStreamIframe() ) {
|
||||||
return '<iframe id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" width="'. validInt($width)." height=".validInt($height).'"/>';
|
return '<iframe id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" '.($width? ' width="'. validInt($width).'"' : '').($height?' height="'.validInt($height).'"' : '' ).'/>';
|
||||||
} else {
|
} else {
|
||||||
return '<img id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" width="'. validInt($width) .'" height="'. validInt( $height ).'"/>';
|
return '<img id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" style="'.($width? ' width:'. validInt($width) .'px;': '').($height ? ' height:'. validInt( $height ).'px;':'').'"/>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -829,36 +829,38 @@ function packageControl( $command ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function daemonControl( $command, $daemon=false, $args=false ) {
|
function daemonControl( $command, $daemon=false, $args=false ) {
|
||||||
$string = ZM_PATH_BIN."/zmdc.pl $command";
|
$string = escapeshellcmd(ZM_PATH_BIN).'/zmdc.pl '.$command;
|
||||||
if ( $daemon ) {
|
if ( $daemon ) {
|
||||||
$string .= " $daemon";
|
#$string .= ' ' . $daemon;
|
||||||
|
$string .= ' ' . $daemon;
|
||||||
if ( $args ) {
|
if ( $args ) {
|
||||||
$string .= " $args";
|
$string .= ' ' . $args;
|
||||||
|
#$string .= ' ' . $args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$string .= " 2>/dev/null >&- <&- >/dev/null";
|
$string .= ' 2>/dev/null >&- <&- >/dev/null';
|
||||||
|
Debug("exec $string");
|
||||||
exec( $string );
|
exec( $string );
|
||||||
}
|
}
|
||||||
|
|
||||||
function zmcControl( $monitor, $mode=false ) {
|
function zmcControl( $monitor, $mode=false ) {
|
||||||
if ( (!defined('ZM_SERVER_ID')) or ( ZM_SERVER_ID==$monitor['ServerId'] ) ) {
|
if ( (!defined('ZM_SERVER_ID')) or ( ZM_SERVER_ID==$monitor['ServerId'] ) ) {
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
if ( $monitor['Type'] == "Local" ) {
|
if ( $monitor['Type'] == 'Local' ) {
|
||||||
$row = dbFetchOne( "select count(if(Function!='None',1,NULL)) as ActiveCount from Monitors where Device = ?", NULL, array($monitor['Device']) );
|
$row = dbFetchOne( "SELECT count(if(Function!='None',1,NULL)) AS ActiveCount FROM Monitors WHERE Device = ?", NULL, array($monitor['Device']) );
|
||||||
$zmcArgs = "-d ".$monitor['Device'];
|
$zmcArgs = '-d '.escapeshellarg( $monitor['Device'] );
|
||||||
} else {
|
} else {
|
||||||
$row = dbFetchOne( "select count(if(Function!='None',1,NULL)) as ActiveCount from Monitors where Id = ?", NULL, array($monitor['Id']) );
|
$row = dbFetchOne( "SELECT count(if(Function!='None',1,NULL)) AS ActiveCount FROM Monitors WHERE Id = ?", NULL, array($monitor['Id']) );
|
||||||
$zmcArgs = "-m ".$monitor['Id'];
|
$zmcArgs = '-m '.$monitor['Id'];
|
||||||
}
|
}
|
||||||
$activeCount = $row['ActiveCount'];
|
$activeCount = $row['ActiveCount'];
|
||||||
|
if ( (!$activeCount) || ($mode == 'stop') ) {
|
||||||
if ( !$activeCount || $mode == "stop" ) {
|
daemonControl( 'stop', 'zmc', $zmcArgs );
|
||||||
daemonControl( "stop", "zmc", $zmcArgs );
|
|
||||||
} else {
|
} else {
|
||||||
if ( $mode == "restart" ) {
|
if ( $mode == 'restart' ) {
|
||||||
daemonControl( "stop", "zmc", $zmcArgs );
|
daemonControl( 'stop', 'zmc', $zmcArgs );
|
||||||
}
|
}
|
||||||
daemonControl( "start", "zmc", $zmcArgs );
|
daemonControl( 'start', 'zmc', $zmcArgs );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$Server = new Server( $monitor['ServerId'] );
|
$Server = new Server( $monitor['ServerId'] );
|
||||||
|
@ -878,7 +880,6 @@ function zmcControl( $monitor, $mode=false ) {
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
$result = file_get_contents($url, false, $context);
|
$result = file_get_contents($url, false, $context);
|
||||||
if ($result === FALSE) { /* Handle error */ }
|
if ($result === FALSE) { /* Handle error */ }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -937,34 +938,34 @@ function daemonStatus( $daemon, $args=false ) {
|
||||||
|
|
||||||
initDaemonStatus();
|
initDaemonStatus();
|
||||||
|
|
||||||
$string = "$daemon";
|
$string = $daemon;
|
||||||
if ( $args )
|
if ( $args )
|
||||||
$string .= " $args";
|
$string .= ' ' . $args;
|
||||||
return( strpos( $daemon_status, "'$string' running" ) !== false );
|
return( strpos( $daemon_status, "'$string' running" ) !== false );
|
||||||
}
|
}
|
||||||
|
|
||||||
function zmcStatus( $monitor ) {
|
function zmcStatus( $monitor ) {
|
||||||
if ( $monitor['Type'] == 'Local' ) {
|
if ( $monitor['Type'] == 'Local' ) {
|
||||||
$zmcArgs = "-d ".$monitor['Device'];
|
$zmcArgs = '-d '.$monitor['Device'];
|
||||||
} else {
|
} else {
|
||||||
$zmcArgs = "-m ".$monitor['Id'];
|
$zmcArgs = '-m '.$monitor['Id'];
|
||||||
}
|
}
|
||||||
return( daemonStatus( "zmc", $zmcArgs ) );
|
return( daemonStatus( 'zmc', $zmcArgs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function zmaStatus( $monitor ) {
|
function zmaStatus( $monitor ) {
|
||||||
if ( is_array( $monitor ) ) {
|
if ( is_array( $monitor ) ) {
|
||||||
$monitor = $monitor['Id'];
|
$monitor = $monitor['Id'];
|
||||||
}
|
}
|
||||||
return( daemonStatus( "zma", "-m $monitor" ) );
|
return( daemonStatus( 'zma', "-m $monitor" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function daemonCheck( $daemon=false, $args=false ) {
|
function daemonCheck( $daemon=false, $args=false ) {
|
||||||
$string = ZM_PATH_BIN."/zmdc.pl check";
|
$string = ZM_PATH_BIN."/zmdc.pl check";
|
||||||
if ( $daemon ) {
|
if ( $daemon ) {
|
||||||
$string .= " $daemon";
|
$string .= ' ' . escapeshellarg( $daemon );
|
||||||
if ( $args )
|
if ( $args )
|
||||||
$string .= " $args";
|
$string .= ' ' . escapeshellarg( $args );
|
||||||
}
|
}
|
||||||
$result = exec( $string );
|
$result = exec( $string );
|
||||||
return( preg_match( '/running/', $result ) );
|
return( preg_match( '/running/', $result ) );
|
||||||
|
@ -972,18 +973,18 @@ function daemonCheck( $daemon=false, $args=false ) {
|
||||||
|
|
||||||
function zmcCheck( $monitor ) {
|
function zmcCheck( $monitor ) {
|
||||||
if ( $monitor['Type'] == 'Local' ) {
|
if ( $monitor['Type'] == 'Local' ) {
|
||||||
$zmcArgs = "-d ".$monitor['Device'];
|
$zmcArgs = '-d '.$monitor['Device'];
|
||||||
} else {
|
} else {
|
||||||
$zmcArgs = "-m ".$monitor['Id'];
|
$zmcArgs = '-m '.$monitor['Id'];
|
||||||
}
|
}
|
||||||
return( daemonCheck( "zmc", $zmcArgs ) );
|
return( daemonCheck( 'zmc', $zmcArgs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function zmaCheck( $monitor ) {
|
function zmaCheck( $monitor ) {
|
||||||
if ( is_array( $monitor ) ) {
|
if ( is_array( $monitor ) ) {
|
||||||
$monitor = $monitor['Id'];
|
$monitor = $monitor['Id'];
|
||||||
}
|
}
|
||||||
return( daemonCheck( "zma", "-m $monitor" ) );
|
return( daemonCheck( 'zma', "-m $monitor" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageSrc( $event, $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
function getImageSrc( $event, $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
||||||
|
@ -1404,9 +1405,9 @@ function sortHeader( $field, $querySep='&' ) {
|
||||||
function sortTag( $field ) {
|
function sortTag( $field ) {
|
||||||
if ( $_REQUEST['sort_field'] == $field )
|
if ( $_REQUEST['sort_field'] == $field )
|
||||||
if ( $_REQUEST['sort_asc'] )
|
if ( $_REQUEST['sort_asc'] )
|
||||||
return( "(^)" );
|
return( '(^)' );
|
||||||
else
|
else
|
||||||
return( "(v)" );
|
return( '(v)' );
|
||||||
return( false );
|
return( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1417,21 +1418,24 @@ function getLoad() {
|
||||||
|
|
||||||
function getDiskPercent($path = ZM_DIR_EVENTS) {
|
function getDiskPercent($path = ZM_DIR_EVENTS) {
|
||||||
$total = disk_total_space($path);
|
$total = disk_total_space($path);
|
||||||
if ( ! $total ) {
|
if ( $total === false ) {
|
||||||
Error("disk_total_space returned false for " . $path );
|
Error('disk_total_space returned false. Verify the web account user has access to ' . $path );
|
||||||
return 0;
|
return 0;
|
||||||
|
} elseif ( $total == 0 ) {
|
||||||
|
Error('disk_total_space indicates the following path has a filesystem size of zero bytes' . $path );
|
||||||
|
return 100;
|
||||||
}
|
}
|
||||||
$free = disk_free_space($path);
|
$free = disk_free_space($path);
|
||||||
if ( ! $free ) {
|
if ( $free === false ) {
|
||||||
Error("disk_free_space returned false for " . $path );
|
Error('disk_free_space returned false. Verify the web account user has access to ' . $path );
|
||||||
}
|
}
|
||||||
$space = round(($total - $free) / $total * 100);
|
$space = round((($total - $free) / $total) * 100);
|
||||||
return( $space );
|
return( $space );
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDiskBlocks() {
|
function getDiskBlocks() {
|
||||||
if ( ! $StorageArea ) $StorageArea = new Storage();
|
if ( ! $StorageArea ) $StorageArea = new Storage();
|
||||||
$df = shell_exec( 'df '.$StorageArea->Path() );
|
$df = shell_exec( 'df '.escapeshellarg($StorageArea->Path() ));
|
||||||
$space = -1;
|
$space = -1;
|
||||||
if ( preg_match( '/\s(\d+)\s+\d+\s+\d+%/ms', $df, $matches ) )
|
if ( preg_match( '/\s(\d+)\s+\d+\s+\d+%/ms', $df, $matches ) )
|
||||||
$space = $matches[1];
|
$space = $matches[1];
|
||||||
|
@ -2097,23 +2101,50 @@ function validHtmlStr( $input ) {
|
||||||
return( htmlspecialchars( $input, ENT_QUOTES ) );
|
return( htmlspecialchars( $input, ENT_QUOTES ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStreamHTML( $monitor, $scale=100, $mode='stream' ) {
|
function getStreamHTML( $monitor, $options = array() ) {
|
||||||
|
|
||||||
|
if ( isset($options['scale']) ) {
|
||||||
|
$options['width'] = reScale( $monitor->Width(), $options['scale'] );
|
||||||
|
$options['height'] = reScale( $monitor->Height(), $options['scale'] );
|
||||||
|
}
|
||||||
|
if ( ! isset($options['mode'] ) ) {
|
||||||
|
$options['mode'] = 'stream';
|
||||||
|
}
|
||||||
|
$options['maxfps'] = ZM_WEB_VIDEO_MAXFPS;
|
||||||
|
if ( $monitor->StreamReplayBuffer() )
|
||||||
|
$options['buffer'] = $monitor->StreamReplayBuffer();
|
||||||
|
|
||||||
//FIXME, the width and height of the image need to be scaled.
|
//FIXME, the width and height of the image need to be scaled.
|
||||||
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) {
|
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) {
|
||||||
$streamSrc = $monitor->getStreamSrc( array( 'mode=mpeg', 'scale='.$scale, 'bitrate='.ZM_WEB_VIDEO_BITRATE, 'maxfps='.ZM_WEB_VIDEO_MAXFPS, 'format='.ZM_MPEG_LIVE_FORMAT ) );
|
$streamSrc = $monitor->getStreamSrc( array( 'mode'=>'mpeg', 'scale'=>$options['scale'], 'bitrate'=>ZM_WEB_VIDEO_BITRATE, 'maxfps'=>ZM_WEB_VIDEO_MAXFPS, 'format' => ZM_MPEG_LIVE_FORMAT ) );
|
||||||
return getVideoStream( 'liveStream'.$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), ZM_MPEG_LIVE_FORMAT, $monitor->Name() );
|
|
||||||
} else if ( $mode == 'stream' and canStream() ) {
|
return getVideoStream( 'liveStream'.$monitor->Id(), $streamSrc, $options, ZM_MPEG_LIVE_FORMAT, $monitor->Name() );
|
||||||
$streamSrc = $monitor->getStreamSrc( array( 'mode=jpeg', 'scale='.$scale, 'maxfps='.ZM_WEB_VIDEO_MAXFPS, 'buffer='.$monitor->StreamReplayBuffer() ) );
|
} else if ( $options['mode'] == 'stream' and canStream() ) {
|
||||||
|
$options['mode'] = 'jpeg';
|
||||||
|
$streamSrc = $monitor->getStreamSrc( $options );
|
||||||
|
|
||||||
if ( canStreamNative() )
|
if ( canStreamNative() )
|
||||||
return getImageStream( 'liveStream'.$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
return getImageStream( 'liveStream'.$monitor->Id(), $streamSrc,
|
||||||
|
( isset($options['width']) ? $options['width'] : NULL ),
|
||||||
|
( isset($options['height']) ? $options['height'] : NULL ),
|
||||||
|
$monitor->Name()
|
||||||
|
);
|
||||||
elseif ( canStreamApplet() )
|
elseif ( canStreamApplet() )
|
||||||
return getHelperStream( 'liveStream'.$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
return getHelperStream( 'liveStream'.$monitor->Id(), $streamSrc,
|
||||||
|
( isset($options['width']) ? $options['width'] : NULL ),
|
||||||
|
( isset($options['height']) ? $options['height'] : NULL ),
|
||||||
|
$monitor->Name()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$streamSrc = $monitor->getStreamSrc( array( 'mode=single', 'scale='.$scale ) );
|
$streamSrc = $monitor->getStreamSrc( $options );
|
||||||
if ( $mode == 'stream' ) {
|
if ( $mode == 'stream' ) {
|
||||||
Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
|
Info( 'The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.' );
|
||||||
}
|
}
|
||||||
return getImageStill( 'liveStream'.$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
return getImageStill( 'liveStream'.$monitor->Id(), $streamSrc,
|
||||||
|
( isset($options['width']) ? $options['width'] : NULL ),
|
||||||
|
( isset($options['height']) ? $options['height'] : NULL ),
|
||||||
|
$monitor->Name()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} // end function getStreamHTML
|
} // end function getStreamHTML
|
||||||
|
|
||||||
|
@ -2143,4 +2174,8 @@ function human_filesize($bytes, $decimals = 2) {
|
||||||
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor];
|
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function csrf_startup() {
|
||||||
|
csrf_conf('rewrite-js', 'includes/csrf/csrf-magic.js');
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -146,19 +146,10 @@ if ( ZM_OPT_USE_AUTH ) {
|
||||||
|
|
||||||
require_once( 'includes/lang.php' );
|
require_once( 'includes/lang.php' );
|
||||||
require_once( 'includes/functions.php' );
|
require_once( 'includes/functions.php' );
|
||||||
|
require_once( 'includes/csrf/csrf-magic.php' );
|
||||||
|
|
||||||
# Running is global but only do the daemonCheck if it is actually needed
|
# Running is global but only do the daemonCheck if it is actually needed
|
||||||
$running = null;
|
$running = null;
|
||||||
#= daemonCheck();
|
|
||||||
#$states = dbFetchAll( 'SELECT * FROM States' );
|
|
||||||
#foreach ( $states as $state ) {
|
|
||||||
#if ( $state['IsActive'] == 1 ) {
|
|
||||||
#$run_state = $state['Name'];
|
|
||||||
#break;
|
|
||||||
#}
|
|
||||||
#}
|
|
||||||
#$status = $running?translate('Running'):translate('Stopped');
|
|
||||||
#$run_state = dbFetchOne('SELECT Name FROM States WHERE IsActive = 1', 'Name' );
|
|
||||||
|
|
||||||
# Add Cross domain access headers
|
# Add Cross domain access headers
|
||||||
CORSHeaders();
|
CORSHeaders();
|
||||||
|
@ -168,9 +159,13 @@ if ( !is_writable(ZM_DIR_EVENTS) || !is_writable(ZM_DIR_IMAGES) ) {
|
||||||
Error( "Cannot write to content dirs('".ZM_DIR_EVENTS."','".ZM_DIR_IMAGES."'). Check that these exist and are owned by the web account user");
|
Error( "Cannot write to content dirs('".ZM_DIR_EVENTS."','".ZM_DIR_IMAGES."'). Check that these exist and are owned by the web account user");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Globals
|
||||||
|
$redirect = null;
|
||||||
|
$view = null;
|
||||||
if ( isset($_REQUEST['view']) )
|
if ( isset($_REQUEST['view']) )
|
||||||
$view = detaintPath($_REQUEST['view']);
|
$view = detaintPath($_REQUEST['view']);
|
||||||
|
|
||||||
|
$request = null;
|
||||||
if ( isset($_REQUEST['request']) )
|
if ( isset($_REQUEST['request']) )
|
||||||
$request = detaintPath($_REQUEST['request']);
|
$request = detaintPath($_REQUEST['request']);
|
||||||
|
|
||||||
|
@ -191,11 +186,25 @@ if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS ) {
|
||||||
if ( isset($_REQUEST['action']) ) {
|
if ( isset($_REQUEST['action']) ) {
|
||||||
$action = detaintPath($_REQUEST['action']);
|
$action = detaintPath($_REQUEST['action']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The only variable we really need to set is action. The others are informal.
|
||||||
|
isset($view) || $view = NULL;
|
||||||
|
isset($request) || $request = NULL;
|
||||||
|
isset($action) || $action = NULL;
|
||||||
|
|
||||||
|
if ( ZM_ENABLE_CSRF_MAGIC && $action != 'login' ) {
|
||||||
|
Debug("Calling csrf_check with the following values: \$request = \"$request\", \$view = \"$view\", \$action = \"$action\"");
|
||||||
|
if ( ! csrf_check() ) {
|
||||||
|
Warning( "Failed csrf_check()" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Need to include actions because it does auth
|
# Need to include actions because it does auth
|
||||||
require_once( 'includes/actions.php' );
|
require_once( 'includes/actions.php' );
|
||||||
|
|
||||||
# If I put this here, it protects all views and popups, but it has to go after actions.php because actions.php does the actual logging in.
|
# If I put this here, it protects all views and popups, but it has to go after actions.php because actions.php does the actual logging in.
|
||||||
if ( ZM_OPT_USE_AUTH && ! isset($user) && $view != 'login' ) {
|
if ( ZM_OPT_USE_AUTH && ! isset($user) ) {
|
||||||
$view = 'login';
|
$view = 'login';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +212,11 @@ if ( ZM_OPT_USE_AUTH && ! isset($user) && $view != 'login' ) {
|
||||||
# Any file/page that sets session variables must re-open it.
|
# Any file/page that sets session variables must re-open it.
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
|
||||||
|
if ( $redirect ) {
|
||||||
|
header('Location: /index.php?view='.$view);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $_REQUEST['request'] ) ) {
|
if ( isset( $_REQUEST['request'] ) ) {
|
||||||
foreach ( getSkinIncludes( 'ajax/'.$request.'.php', true, true ) as $includeFile ) {
|
foreach ( getSkinIncludes( 'ajax/'.$request.'.php', true, true ) as $includeFile ) {
|
||||||
if ( !file_exists( $includeFile ) )
|
if ( !file_exists( $includeFile ) )
|
||||||
|
|
|
@ -618,6 +618,7 @@ $SLANG = array(
|
||||||
'Rewind' => 'Rewind',
|
'Rewind' => 'Rewind',
|
||||||
'RotateLeft' => 'Rotate Left',
|
'RotateLeft' => 'Rotate Left',
|
||||||
'RotateRight' => 'Rotate Right',
|
'RotateRight' => 'Rotate Right',
|
||||||
|
'RTSPTransport' => 'RTSP Transport Protocol',
|
||||||
'RunLocalUpdate' => 'Please run zmupdate.pl to update',
|
'RunLocalUpdate' => 'Please run zmupdate.pl to update',
|
||||||
'RunMode' => 'Run Mode',
|
'RunMode' => 'Run Mode',
|
||||||
'Running' => 'Running',
|
'Running' => 'Running',
|
||||||
|
@ -909,6 +910,13 @@ $OLANG = array(
|
||||||
"\"reorder_queue_size=nnn\" Set number of packets to buffer for handling of reordered packets~~~~".
|
"\"reorder_queue_size=nnn\" Set number of packets to buffer for handling of reordered packets~~~~".
|
||||||
"\"loglevel=debug\" Set verbosity of FFmpeg (quiet, panic, fatal, error, warning, info, verbose, debug)"
|
"\"loglevel=debug\" Set verbosity of FFmpeg (quiet, panic, fatal, error, warning, info, verbose, debug)"
|
||||||
),
|
),
|
||||||
|
'OPTIONS_RTSPTrans' => array(
|
||||||
|
'Help' => "This sets the RTSP Transport Protocol for FFmpeg.~~ ".
|
||||||
|
"TCP - Use TCP (interleaving within the RTSP control channel) as transport protocol.~~".
|
||||||
|
"UDP - Use UDP as transport protocol. Higher resolution cameras have experienced some 'smearing' while using UDP, if so try TCP~~".
|
||||||
|
"UDP Multicast - Use UDP Multicast as transport protocol~~".
|
||||||
|
"HTTP - Use HTTP tunneling as transport protocol, which is useful for passing proxies.~~"
|
||||||
|
),
|
||||||
'OPTIONS_LIBVLC' => array(
|
'OPTIONS_LIBVLC' => array(
|
||||||
'Help' => "Parameters in this field are passed on to libVLC. Multiple parameters can be separated by ,~~ ".
|
'Help' => "Parameters in this field are passed on to libVLC. Multiple parameters can be separated by ,~~ ".
|
||||||
"Examples (do not enter quotes)~~~~".
|
"Examples (do not enter quotes)~~~~".
|
||||||
|
|
|
@ -366,7 +366,6 @@ th.table-th-sort-rev span.table-th-sort-span {
|
||||||
}
|
}
|
||||||
|
|
||||||
#headerControl {
|
#headerControl {
|
||||||
width: 50%;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ScaleDiv,
|
||||||
|
#SpeedDiv{
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-flex;
|
||||||
|
border: 1px solid black;
|
||||||
|
width: 25%;
|
||||||
|
padding: 9px;
|
||||||
|
}
|
||||||
|
#ScaleDiv label,
|
||||||
|
#SpeedDiv label {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#scaleslideroutput,
|
||||||
|
#speedslideroutput {
|
||||||
|
min-width: 75px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timelinediv {
|
||||||
|
margin: 2px auto;
|
||||||
|
position:relative;
|
||||||
|
width:93%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timeline {
|
||||||
|
border:1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#monitors {
|
||||||
|
position:relative;
|
||||||
|
background-color:black;
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ScaleDiv,
|
||||||
|
#SpeedDiv{
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-flex;
|
||||||
|
border: 1px solid black;
|
||||||
|
width: 25%;
|
||||||
|
padding: 9px;
|
||||||
|
}
|
||||||
|
#ScaleDiv label,
|
||||||
|
#SpeedDiv label {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#scaleslideroutput,
|
||||||
|
#speedslideroutput {
|
||||||
|
min-width: 75px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timelinediv {
|
||||||
|
margin: 2px auto;
|
||||||
|
position:relative;
|
||||||
|
width:93%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timeline {
|
||||||
|
border:1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#monitors {
|
||||||
|
position:relative;
|
||||||
|
background-color:black;
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ScaleDiv,
|
||||||
|
#SpeedDiv{
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-flex;
|
||||||
|
border: 1px solid black;
|
||||||
|
width: 25%;
|
||||||
|
padding: 9px;
|
||||||
|
}
|
||||||
|
#ScaleDiv label,
|
||||||
|
#SpeedDiv label {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#scaleslideroutput,
|
||||||
|
#speedslideroutput {
|
||||||
|
min-width: 75px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timelinediv {
|
||||||
|
margin: 2px auto;
|
||||||
|
position:relative;
|
||||||
|
width:93%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timeline {
|
||||||
|
border:1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#monitors {
|
||||||
|
position:relative;
|
||||||
|
background-color:black;
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
}
|
|
@ -19,93 +19,94 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
$rates = array(
|
$rates = array(
|
||||||
"10000" => "100x",
|
'10000' => '100x',
|
||||||
"5000" => "50x",
|
'5000' => '50x',
|
||||||
"2500" => "25x",
|
'2500' => '25x',
|
||||||
"1000" => "10x",
|
'1000' => '10x',
|
||||||
"400" => "4x",
|
'400' => '4x',
|
||||||
"200" => "2x",
|
'200' => '2x',
|
||||||
"100" => translate('Real'),
|
'100' => translate('Real'),
|
||||||
"50" => "1/2x",
|
'50' => "1/2x",
|
||||||
"25" => "1/4x",
|
'25' => "1/4x",
|
||||||
);
|
);
|
||||||
|
|
||||||
$scales = array(
|
$scales = array(
|
||||||
"400" => "4x",
|
'' => translate('Fixed Width/Height'),
|
||||||
"300" => "3x",
|
'400' => '4x',
|
||||||
"200" => "2x",
|
'300' => '3x',
|
||||||
"150" => "1.5x",
|
'200' => '2x',
|
||||||
"100" => translate('Actual'),
|
'150' => "1.5x",
|
||||||
"75" => "3/4x",
|
'100' => translate('Actual'),
|
||||||
"50" => "1/2x",
|
'75' => "3/4x",
|
||||||
"33" => "1/3x",
|
'50' => "1/2x",
|
||||||
"25" => "1/4x",
|
'33' => "1/3x",
|
||||||
|
'25' => "1/4x",
|
||||||
"12.5" => "1/8x",
|
"12.5" => "1/8x",
|
||||||
);
|
);
|
||||||
|
|
||||||
$bwArray = array(
|
$bwArray = array(
|
||||||
"high" => translate('High'),
|
'high' => translate('High'),
|
||||||
"medium" => translate('Medium'),
|
'medium' => translate('Medium'),
|
||||||
"low" => translate('Low')
|
'low' => translate('Low')
|
||||||
);
|
);
|
||||||
|
|
||||||
switch ( $_COOKIE['zmBandwidth'] )
|
switch ( $_COOKIE['zmBandwidth'] )
|
||||||
{
|
{
|
||||||
case "high" :
|
case 'high' :
|
||||||
{
|
{
|
||||||
define( "ZM_WEB_REFRESH_MAIN", ZM_WEB_H_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
define( 'ZM_WEB_REFRESH_MAIN', ZM_WEB_H_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
||||||
define( "ZM_WEB_REFRESH_CYCLE", ZM_WEB_H_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
define( 'ZM_WEB_REFRESH_CYCLE', ZM_WEB_H_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
||||||
define( "ZM_WEB_REFRESH_IMAGE", ZM_WEB_H_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
define( 'ZM_WEB_REFRESH_IMAGE', ZM_WEB_H_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
||||||
define( "ZM_WEB_REFRESH_STATUS", ZM_WEB_H_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
define( 'ZM_WEB_REFRESH_STATUS', ZM_WEB_H_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
||||||
define( "ZM_WEB_REFRESH_EVENTS", ZM_WEB_H_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
define( 'ZM_WEB_REFRESH_EVENTS', ZM_WEB_H_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
||||||
define( "ZM_WEB_CAN_STREAM", ZM_WEB_H_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
define( 'ZM_WEB_CAN_STREAM', ZM_WEB_H_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
||||||
define( "ZM_WEB_STREAM_METHOD", ZM_WEB_H_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
define( 'ZM_WEB_STREAM_METHOD', ZM_WEB_H_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
||||||
define( "ZM_WEB_DEFAULT_SCALE", ZM_WEB_H_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
define( 'ZM_WEB_DEFAULT_SCALE', ZM_WEB_H_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
||||||
define( "ZM_WEB_DEFAULT_RATE", ZM_WEB_H_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
define( 'ZM_WEB_DEFAULT_RATE', ZM_WEB_H_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
||||||
define( "ZM_WEB_VIDEO_BITRATE", ZM_WEB_H_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
define( 'ZM_WEB_VIDEO_BITRATE', ZM_WEB_H_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
||||||
define( "ZM_WEB_VIDEO_MAXFPS", ZM_WEB_H_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
define( 'ZM_WEB_VIDEO_MAXFPS', ZM_WEB_H_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
||||||
define( "ZM_WEB_SCALE_THUMBS", ZM_WEB_H_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
define( 'ZM_WEB_SCALE_THUMBS', ZM_WEB_H_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
||||||
define( "ZM_WEB_EVENTS_VIEW", ZM_WEB_H_EVENTS_VIEW ); // What the default view of multiple events should be.
|
define( 'ZM_WEB_EVENTS_VIEW', ZM_WEB_H_EVENTS_VIEW ); // What the default view of multiple events should be.
|
||||||
define( "ZM_WEB_SHOW_PROGRESS", ZM_WEB_H_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
define( 'ZM_WEB_SHOW_PROGRESS', ZM_WEB_H_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
||||||
define( "ZM_WEB_AJAX_TIMEOUT", ZM_WEB_H_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
define( 'ZM_WEB_AJAX_TIMEOUT', ZM_WEB_H_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "medium" :
|
case 'medium' :
|
||||||
{
|
{
|
||||||
define( "ZM_WEB_REFRESH_MAIN", ZM_WEB_M_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
define( 'ZM_WEB_REFRESH_MAIN', ZM_WEB_M_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
||||||
define( "ZM_WEB_REFRESH_CYCLE", ZM_WEB_M_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
define( 'ZM_WEB_REFRESH_CYCLE', ZM_WEB_M_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
||||||
define( "ZM_WEB_REFRESH_IMAGE", ZM_WEB_M_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
define( 'ZM_WEB_REFRESH_IMAGE', ZM_WEB_M_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
||||||
define( "ZM_WEB_REFRESH_STATUS", ZM_WEB_M_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
define( 'ZM_WEB_REFRESH_STATUS', ZM_WEB_M_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
||||||
define( "ZM_WEB_REFRESH_EVENTS", ZM_WEB_M_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
define( 'ZM_WEB_REFRESH_EVENTS', ZM_WEB_M_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
||||||
define( "ZM_WEB_CAN_STREAM", ZM_WEB_M_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
define( 'ZM_WEB_CAN_STREAM', ZM_WEB_M_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
||||||
define( "ZM_WEB_STREAM_METHOD", ZM_WEB_M_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
define( 'ZM_WEB_STREAM_METHOD', ZM_WEB_M_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
||||||
define( "ZM_WEB_DEFAULT_SCALE", ZM_WEB_M_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
define( 'ZM_WEB_DEFAULT_SCALE', ZM_WEB_M_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
||||||
define( "ZM_WEB_DEFAULT_RATE", ZM_WEB_M_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
define( 'ZM_WEB_DEFAULT_RATE', ZM_WEB_M_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
||||||
define( "ZM_WEB_VIDEO_BITRATE", ZM_WEB_M_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
define( 'ZM_WEB_VIDEO_BITRATE', ZM_WEB_M_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
||||||
define( "ZM_WEB_VIDEO_MAXFPS", ZM_WEB_M_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
define( 'ZM_WEB_VIDEO_MAXFPS', ZM_WEB_M_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
||||||
define( "ZM_WEB_SCALE_THUMBS", ZM_WEB_M_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
define( 'ZM_WEB_SCALE_THUMBS', ZM_WEB_M_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
||||||
define( "ZM_WEB_EVENTS_VIEW", ZM_WEB_M_EVENTS_VIEW ); // What the default view of multiple events should be.
|
define( 'ZM_WEB_EVENTS_VIEW', ZM_WEB_M_EVENTS_VIEW ); // What the default view of multiple events should be.
|
||||||
define( "ZM_WEB_SHOW_PROGRESS", ZM_WEB_M_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
define( 'ZM_WEB_SHOW_PROGRESS', ZM_WEB_M_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
||||||
define( "ZM_WEB_AJAX_TIMEOUT", ZM_WEB_M_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
define( 'ZM_WEB_AJAX_TIMEOUT', ZM_WEB_M_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "low" :
|
case 'low' :
|
||||||
{
|
{
|
||||||
define( "ZM_WEB_REFRESH_MAIN", ZM_WEB_L_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
define( 'ZM_WEB_REFRESH_MAIN', ZM_WEB_L_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
||||||
define( "ZM_WEB_REFRESH_CYCLE", ZM_WEB_L_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
define( 'ZM_WEB_REFRESH_CYCLE', ZM_WEB_L_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
||||||
define( "ZM_WEB_REFRESH_IMAGE", ZM_WEB_L_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
define( 'ZM_WEB_REFRESH_IMAGE', ZM_WEB_L_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
||||||
define( "ZM_WEB_REFRESH_STATUS", ZM_WEB_L_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
define( 'ZM_WEB_REFRESH_STATUS', ZM_WEB_L_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
||||||
define( "ZM_WEB_REFRESH_EVENTS", ZM_WEB_L_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
define( 'ZM_WEB_REFRESH_EVENTS', ZM_WEB_L_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
||||||
define( "ZM_WEB_CAN_STREAM", ZM_WEB_L_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
define( 'ZM_WEB_CAN_STREAM', ZM_WEB_L_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
||||||
define( "ZM_WEB_STREAM_METHOD", ZM_WEB_L_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
define( 'ZM_WEB_STREAM_METHOD', ZM_WEB_L_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
||||||
define( "ZM_WEB_DEFAULT_SCALE", ZM_WEB_L_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
define( 'ZM_WEB_DEFAULT_SCALE', ZM_WEB_L_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
||||||
define( "ZM_WEB_DEFAULT_RATE", ZM_WEB_L_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
define( 'ZM_WEB_DEFAULT_RATE', ZM_WEB_L_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
||||||
define( "ZM_WEB_VIDEO_BITRATE", ZM_WEB_L_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
define( 'ZM_WEB_VIDEO_BITRATE', ZM_WEB_L_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
||||||
define( "ZM_WEB_VIDEO_MAXFPS", ZM_WEB_L_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
define( 'ZM_WEB_VIDEO_MAXFPS', ZM_WEB_L_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
||||||
define( "ZM_WEB_SCALE_THUMBS", ZM_WEB_L_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
define( 'ZM_WEB_SCALE_THUMBS', ZM_WEB_L_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
||||||
define( "ZM_WEB_EVENTS_VIEW", ZM_WEB_L_EVENTS_VIEW ); // What the default view of multiple events should be.
|
define( 'ZM_WEB_EVENTS_VIEW', ZM_WEB_L_EVENTS_VIEW ); // What the default view of multiple events should be.
|
||||||
define( "ZM_WEB_SHOW_PROGRESS", ZM_WEB_L_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
define( 'ZM_WEB_SHOW_PROGRESS', ZM_WEB_L_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
||||||
define( "ZM_WEB_AJAX_TIMEOUT", ZM_WEB_L_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
define( 'ZM_WEB_AJAX_TIMEOUT', ZM_WEB_L_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,6 @@ var popupSizes = {
|
||||||
'video': { 'width': 420, 'height': 360 },
|
'video': { 'width': 420, 'height': 360 },
|
||||||
'videoview': { 'addWidth': 48, 'addHeight': 80 },
|
'videoview': { 'addWidth': 48, 'addHeight': 80 },
|
||||||
'watch': { 'addWidth': 96, 'minWidth': 420, 'addHeight': 384 },
|
'watch': { 'addWidth': 96, 'minWidth': 420, 'addHeight': 384 },
|
||||||
'zone': { 'addWidth': 450, 'addHeight': 200, 'minHeight': 450 },
|
'zone': { 'addWidth': 520, 'addHeight': 260, 'minHeight': 600 },
|
||||||
'zones': { 'addWidth': 72, 'addHeight': 232 }
|
'zones': { 'addWidth': 72, 'addHeight': 232 }
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,23 +49,23 @@ var popupSizes = {
|
||||||
'login': { 'width': 720, 'height': 480 },
|
'login': { 'width': 720, 'height': 480 },
|
||||||
'logout': { 'width': 260, 'height': 150 },
|
'logout': { 'width': 260, 'height': 150 },
|
||||||
'monitor': { 'width': 800, 'height': 780 },
|
'monitor': { 'width': 800, 'height': 780 },
|
||||||
'monitorpreset':{ 'width': 440, 'height': 200 },
|
'monitorpreset':{ 'width': 440, 'height': 210 },
|
||||||
'monitorprobe': { 'width': 500, 'height': 240 },
|
'monitorprobe': { 'width': 500, 'height': 275 },
|
||||||
'monitorselect':{ 'width': 160, 'height': 200 },
|
'monitorselect':{ 'width': 160, 'height': 200 },
|
||||||
'montage': { 'width': -1, 'height': -1 },
|
'montage': { 'width': -1, 'height': -1 },
|
||||||
'onvifprobe': { 'width': 700, 'height': 550 },
|
'onvifprobe': { 'width': 700, 'height': 550 },
|
||||||
'optionhelp': { 'width': 400, 'height': 320 },
|
'optionhelp': { 'width': 400, 'height': 320 },
|
||||||
'options': { 'width': 1000, 'height': 660 },
|
'options': { 'width': 1000, 'height': 660 },
|
||||||
'preset': { 'width': 300, 'height': 120 },
|
'preset': { 'width': 300, 'height': 120 },
|
||||||
'settings': { 'width': 220, 'height': 225 },
|
'settings': { 'width': 220, 'height': 235 },
|
||||||
'state': { 'width': 400, 'height': 170 },
|
'state': { 'width': 400, 'height': 170 },
|
||||||
'stats': { 'width': 840, 'height': 200 },
|
'stats': { 'width': 840, 'height': 200 },
|
||||||
'timeline': { 'width': 760, 'height': 540 },
|
'timeline': { 'width': 760, 'height': 540 },
|
||||||
'user': { 'width': 360, 'height': 420 },
|
'user': { 'width': 360, 'height': 420 },
|
||||||
'version': { 'width': 360, 'height': 140 },
|
'version': { 'width': 360, 'height': 185 },
|
||||||
'video': { 'width': 420, 'height': 360 },
|
'video': { 'width': 420, 'height': 360 },
|
||||||
'videoview': { 'addWidth': 48, 'addHeight': 80 },
|
'videoview': { 'addWidth': 48, 'addHeight': 80 },
|
||||||
'watch': { 'addWidth': 96, 'minWidth': 420, 'addHeight': 384 },
|
'watch': { 'addWidth': 96, 'minWidth': 420, 'addHeight': 384 },
|
||||||
'zone': { 'addWidth': 520, 'addHeight': 240, 'minHeight': 600 },
|
'zone': { 'addWidth': 520, 'addHeight': 260, 'minHeight': 600 },
|
||||||
'zones': { 'addWidth': 72, 'addHeight': 232 }
|
'zones': { 'addWidth': 72, 'addHeight': 232 }
|
||||||
};
|
};
|
||||||
|
|
|
@ -186,10 +186,13 @@ function refreshWindow()
|
||||||
window.location.reload( true );
|
window.location.reload( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshParentWindow()
|
function refreshParentWindow() {
|
||||||
{
|
if ( window.opener ) {
|
||||||
if ( window.opener )
|
if ( refreshParent == true )
|
||||||
window.opener.location.reload( true );
|
window.opener.location.reload( true );
|
||||||
|
else
|
||||||
|
window.opener.location.href = refreshParent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Shows a message if there is an error in the streamObj or the stream doesn't exist. Returns true if error, false otherwise.
|
//Shows a message if there is an error in the streamObj or the stream doesn't exist. Returns true if error, false otherwise.
|
||||||
|
@ -270,20 +273,18 @@ function configureDeleteButton( element )
|
||||||
form.deleteBtn.disabled = !checked;
|
form.deleteBtn.disabled = !checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmDelete( message )
|
function confirmDelete( message ) {
|
||||||
{
|
|
||||||
return( confirm( message?message:'Are you sure you wish to delete?' ) );
|
return( confirm( message?message:'Are you sure you wish to delete?' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( refreshParent )
|
if ( refreshParent ) {
|
||||||
{
|
|
||||||
refreshParentWindow();
|
refreshParentWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( focusWindow )
|
if ( focusWindow ) {
|
||||||
{
|
|
||||||
windowToFront();
|
windowToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEvent( 'domready', checkSize);
|
window.addEvent( 'domready', checkSize);
|
||||||
|
|
||||||
function convertLabelFormat(LabelFormat, monitorName){
|
function convertLabelFormat(LabelFormat, monitorName){
|
||||||
|
|
|
@ -35,7 +35,18 @@ var canViewSystem = <?php echo canView('System' )?'true':'false' ?>;
|
||||||
|
|
||||||
var canEditGroups = <?php echo canEdit('Groups' )?'true':'false' ?>;
|
var canEditGroups = <?php echo canEdit('Groups' )?'true':'false' ?>;
|
||||||
|
|
||||||
var refreshParent = <?php echo !empty($refreshParent)?'true':'false' ?>;
|
var refreshParent = <?php
|
||||||
|
if ( ! empty($refreshParent) ) {
|
||||||
|
if ( $refreshParent == true ) {
|
||||||
|
echo 'true';
|
||||||
|
return;
|
||||||
|
} else if ( $refreshParent ) {
|
||||||
|
echo "'$refreshParent'";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo 'false';
|
||||||
|
?>;
|
||||||
|
|
||||||
var focusWindow = <?php echo !empty($focusWindow)?'true':'false' ?>;
|
var focusWindow = <?php echo !empty($focusWindow)?'true':'false' ?>;
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ xhtmlHeaders( __FILE__, translate('Console') );
|
||||||
<?php for ( $i = 0; $i < count($eventCounts); $i++ ) { ?>
|
<?php for ( $i = 0; $i < count($eventCounts); $i++ ) { ?>
|
||||||
<th class="colEvents"><?php echo $eventCounts[$i]['title'] ?></th>
|
<th class="colEvents"><?php echo $eventCounts[$i]['title'] ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<th class="colZones"><?php echo translate('Zones') ?></th>
|
<th class="colZones"><a href="<?php echo $_SERVER['PHP_SELF'] ?>?view=zones_overview"><?php echo translate('Zones') ?></a></th>
|
||||||
<?php if ( canEdit('Monitors') ) { ?>
|
<?php if ( canEdit('Monitors') ) { ?>
|
||||||
<th class="colMark"><?php echo translate('Mark') ?></th>
|
<th class="colMark"><?php echo translate('Mark') ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
|
@ -82,7 +82,7 @@ xhtmlHeaders(__FILE__, translate('CycleWatch') );
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div id="imageFeed">
|
<div id="imageFeed">
|
||||||
<?php echo getStreamHTML( $monitor, $scale, $mode ); ?>
|
<?php echo getStreamHTML( $monitor, array( 'scale'=>$scale, 'mode'=>$mode ) ); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,13 +26,13 @@ $selectName = 'Id';
|
||||||
$filterNames = array( ''=>translate('ChooseFilter') );
|
$filterNames = array( ''=>translate('ChooseFilter') );
|
||||||
$dbFilter = NULL;
|
$dbFilter = NULL;
|
||||||
|
|
||||||
foreach ( dbFetchAll( "select * from Filters order by Name" ) as $row ) {
|
foreach ( dbFetchAll( 'SELECT * FROM Filters ORDER BY Name' ) as $row ) {
|
||||||
$filterNames[$row['Id']] = $row['Name'];
|
$filterNames[$row['Id']] = $row['Name'];
|
||||||
if ( $row['Background'] )
|
if ( $row['Background'] )
|
||||||
$filterNames[$row['Id']] .= "*";
|
$filterNames[$row['Id']] .= '*';
|
||||||
if ( $row['Concurrent'] )
|
if ( $row['Concurrent'] )
|
||||||
$filterNames[$row['Id']] .= "&";
|
$filterNames[$row['Id']] .= '&';
|
||||||
if ( !empty($_REQUEST['reload']) && isset($_REQUEST['Id']) && $_REQUEST['Id'] == $row['Id'] ) {
|
if ( isset($_REQUEST['Id']) && $_REQUEST['Id'] == $row['Id'] ) {
|
||||||
$dbFilter = $row;
|
$dbFilter = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,12 @@ $backgroundStr = '';
|
||||||
if ( $dbFilter ) {
|
if ( $dbFilter ) {
|
||||||
if ( $dbFilter['Background'] )
|
if ( $dbFilter['Background'] )
|
||||||
$backgroundStr = '['.strtolower(translate('Background')).']';
|
$backgroundStr = '['.strtolower(translate('Background')).']';
|
||||||
|
if ( $dbFilter['Concurrent'] )
|
||||||
|
$backgroundStr .= '['.strtolower(translate('Concurrent')).']';
|
||||||
$_REQUEST['filter'] = jsonDecode( $dbFilter['Query'] );
|
$_REQUEST['filter'] = jsonDecode( $dbFilter['Query'] );
|
||||||
$_REQUEST['sort_field'] = isset($_REQUEST['filter']['sort_field'])?$_REQUEST['filter']['sort_field']:"DateTime";
|
$_REQUEST['sort_field'] = isset($_REQUEST['filter']['sort_field'])?$_REQUEST['filter']['sort_field']:'DateTime';
|
||||||
$_REQUEST['sort_asc'] = isset($_REQUEST['filter']['sort_asc'])?$_REQUEST['filter']['sort_asc']:"1";
|
$_REQUEST['sort_asc'] = isset($_REQUEST['filter']['sort_asc'])?$_REQUEST['filter']['sort_asc']:'1';
|
||||||
$_REQUEST['limit'] = isset($_REQUEST['filter']['limit'])?$_REQUEST['filter']['limit']:"";
|
$_REQUEST['limit'] = isset($_REQUEST['filter']['limit'])?$_REQUEST['filter']['limit']:'';
|
||||||
unset( $_REQUEST['filter']['sort_field'] );
|
unset( $_REQUEST['filter']['sort_field'] );
|
||||||
unset( $_REQUEST['filter']['sort_asc'] );
|
unset( $_REQUEST['filter']['sort_asc'] );
|
||||||
unset( $_REQUEST['filter']['limit'] );
|
unset( $_REQUEST['filter']['limit'] );
|
||||||
|
@ -71,8 +73,8 @@ $obracketTypes = array();
|
||||||
$cbracketTypes = array();
|
$cbracketTypes = array();
|
||||||
if ( isset($_REQUEST['filter']['terms']) ) {
|
if ( isset($_REQUEST['filter']['terms']) ) {
|
||||||
for ( $i = 0; $i <= count($_REQUEST['filter']['terms'])-2; $i++ ) {
|
for ( $i = 0; $i <= count($_REQUEST['filter']['terms'])-2; $i++ ) {
|
||||||
$obracketTypes[$i] = str_repeat( "(", $i );
|
$obracketTypes[$i] = str_repeat( '(', $i );
|
||||||
$cbracketTypes[$i] = str_repeat( ")", $i );
|
$cbracketTypes[$i] = str_repeat( ')', $i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,21 +18,18 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canEdit( 'Events' ) )
|
if ( !canEdit( 'Events' ) ) {
|
||||||
{
|
$view = 'error';
|
||||||
$view = "error";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectName = "Id";
|
$selectName = 'Id';
|
||||||
$newSelectName = "newFilterName";
|
$newSelectName = 'newFilterName';
|
||||||
foreach ( dbFetchAll( "select * from Filters order by Name" ) as $row )
|
foreach ( dbFetchAll( 'SELECT * FROM Filters ORDER BY Name' ) as $row ) {
|
||||||
{
|
$filterNames[$row['Id']] = $row['Name'];
|
||||||
$filterNames[$row['Id']] = $row['Name'];
|
if ( $_REQUEST['Id'] == $row['Id'] ) {
|
||||||
if ( $_REQUEST['Id'] == $row['Id'] )
|
$filterData = $row;
|
||||||
{
|
}
|
||||||
$filterData = $row;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$focusWindow = true;
|
$focusWindow = true;
|
||||||
|
@ -64,13 +61,14 @@ xhtmlHeaders(__FILE__, translate('SaveFilter') );
|
||||||
<input type="hidden" name="AutoExecute" value="<?php echo requestVar( 'AutoExecute' ) ?>"/>
|
<input type="hidden" name="AutoExecute" value="<?php echo requestVar( 'AutoExecute' ) ?>"/>
|
||||||
<input type="hidden" name="AutoExecuteCmd" value="<?php echo requestVar( 'AutoExecuteCmd' ) ?>"/>
|
<input type="hidden" name="AutoExecuteCmd" value="<?php echo requestVar( 'AutoExecuteCmd' ) ?>"/>
|
||||||
<input type="hidden" name="AutoDelete" value="<?php echo requestVar( 'AutoDelete' ) ?>"/>
|
<input type="hidden" name="AutoDelete" value="<?php echo requestVar( 'AutoDelete' ) ?>"/>
|
||||||
|
<input type="hidden" name="Id" value="<?php echo $filterData['Id'] ?>"/>
|
||||||
<?php if ( count($filterNames) ) { ?>
|
<?php if ( count($filterNames) ) { ?>
|
||||||
<p>
|
<p>
|
||||||
<label for="<?php echo $selectName ?>"><?php echo translate('SaveAs') ?></label><?php echo buildSelect( $selectName, $filterNames ); ?><label for="<?php echo $newSelectName ?>"><?php echo translate('OrEnterNewName') ?></label><input type="text" size="32" id="<?php echo $newSelectName ?>" name="<?php echo $newSelectName ?>" value="<?php echo requestVar('filterName') ?>"/>
|
<label for="<?php echo $selectName ?>"><?php echo translate('SaveAs') ?></label><?php echo buildSelect( $selectName, $filterNames ); ?><label for="<?php echo $newSelectName ?>"><?php echo translate('OrEnterNewName') ?></label><input type="text" size="32" id="<?php echo $newSelectName ?>" name="<?php echo $newSelectName ?>" value="<?php echo requestVar('filterName') ?>"/>
|
||||||
</p>
|
</p>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<p>
|
<p>
|
||||||
<label for="<?php echo $newSelectName ?>"><?php echo translate('EnterNewFilterName') ?></label><input type="text" size="32" id="<?php echo $newSelectName ?>" name="<?php echo $newSelectName ?>" value="">
|
<label for="<?php echo $newSelectName ?>"><?php echo translate('EnterNewFilterName') ?></label><input type="text" id="<?php echo $newSelectName ?>" name="<?php echo $newSelectName ?>" />
|
||||||
</p>
|
</p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -85,7 +85,7 @@ function deleteFilter( element, id, name )
|
||||||
{
|
{
|
||||||
var form = element.form;
|
var form = element.form;
|
||||||
form.action.value = 'delete';
|
form.action.value = 'delete';
|
||||||
submitToFilter( element, 1 );
|
submitToFilter( element, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,26 +130,71 @@ function selectLayout( element )
|
||||||
Cookie.write( 'zmMontageLayout', $(element).get('value'), { duration: 10*365 } );
|
Cookie.write( 'zmMontageLayout', $(element).get('value'), { duration: 10*365 } );
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeScale()
|
function changeWidth() {
|
||||||
{
|
var width = $('width').get('value');
|
||||||
|
|
||||||
|
for ( var x = 0; x < monitors.length; x++ ) {
|
||||||
|
var monitor = monitors[x];
|
||||||
|
/*Stream could be an applet so can't use moo tools*/
|
||||||
|
var streamImg = document.getElementById( 'liveStream'+monitor.id );
|
||||||
|
if ( streamImg ) {
|
||||||
|
streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
|
||||||
|
streamImg.style.width = width + "px";
|
||||||
|
streamImg.style.height = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('scale').set('value', '' );
|
||||||
|
Cookie.write( 'zmMontageScale', '', { duration: 10*365 } );
|
||||||
|
Cookie.write( 'zmMontageWidth', width, { duration: 10*365 } );
|
||||||
|
} // end function changeWidth()
|
||||||
|
|
||||||
|
function changeHeight() {
|
||||||
|
var height = $('height').get('value');
|
||||||
|
|
||||||
|
for ( var x = 0; x < monitors.length; x++ ) {
|
||||||
|
var monitor = monitors[x];
|
||||||
|
/*Stream could be an applet so can't use moo tools*/
|
||||||
|
var streamImg = document.getElementById( 'liveStream'+monitor.id );
|
||||||
|
if ( streamImg ) {
|
||||||
|
streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
|
||||||
|
streamImg.style.height = height + "px";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('scale').set('value', '' );
|
||||||
|
Cookie.write( 'zmMontageHeight', height, { duration: 10*365 } );
|
||||||
|
Cookie.write( 'zmMontageScale', '', { duration: 10*365 } );
|
||||||
|
} // end function changeHeight()
|
||||||
|
|
||||||
|
function changeScale() {
|
||||||
var scale = $('scale').get('value');
|
var scale = $('scale').get('value');
|
||||||
|
|
||||||
for ( var x = 0; x < monitors.length; x++ )
|
for ( var x = 0; x < monitors.length; x++ ) {
|
||||||
{
|
|
||||||
var monitor = monitors[x];
|
var monitor = monitors[x];
|
||||||
var newWidth = ( monitorData[x].width * scale ) / SCALE_BASE;
|
var newWidth = ( monitorData[x].width * scale ) / SCALE_BASE;
|
||||||
var newHeight = ( monitorData[x].height * scale ) / SCALE_BASE;
|
var newHeight = ( monitorData[x].height * scale ) / SCALE_BASE;
|
||||||
/*Stream could be an applet so can't use moo tools*/
|
/*Stream could be an applet so can't use moo tools*/
|
||||||
var streamImg = document.getElementById( 'liveStream'+monitor.id );
|
var streamImg = document.getElementById( 'liveStream'+monitor.id );
|
||||||
if ( streamImg ) {
|
if ( streamImg ) {
|
||||||
streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
|
var src = streamImg.src;
|
||||||
|
streamImg.src='';
|
||||||
|
|
||||||
streamImg.style.width = newWidth + "px";
|
streamImg.style.width = newWidth + "px";
|
||||||
streamImg.style.height = newHeight + "px";
|
streamImg.style.height = newHeight + "px";
|
||||||
|
//src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
|
||||||
|
src = src.replace(/scale=[\.\d]+/i,'scale='+ scale );
|
||||||
|
src = src.replace(/width=[\.\d]+/i,'width='+newWidth );
|
||||||
|
src = src.replace(/height=[\.\d]+/i,'height='+newHeight );
|
||||||
|
streamImg.src = src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$('width').set('value', '');
|
||||||
|
$('height').set('value', '');
|
||||||
Cookie.write( 'zmMontageScale', scale, { duration: 10*365 } );
|
Cookie.write( 'zmMontageScale', scale, { duration: 10*365 } );
|
||||||
|
Cookie.write( 'zmMontageWidth', '', { duration: 10*365 } );
|
||||||
|
Cookie.write( 'zmMontageHeight', '', { duration: 10*365 } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var monitors = new Array();
|
var monitors = new Array();
|
||||||
function initPage()
|
function initPage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
?>
|
?>
|
||||||
|
|
||||||
(
|
(
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
// Append '?(GET query)' to URL if the GET query is not empty.
|
// Append '?(GET query)' to URL if the GET query is not empty.
|
||||||
var querySuffix = "<?php
|
var querySuffix = "<?php
|
||||||
if (!empty($_POST["postLoginQuery"]))
|
if (!empty($_POST["postLoginQuery"])) {
|
||||||
echo "?".$_POST["postLoginQuery"];
|
parse_str($_POST["postLoginQuery"], $queryParams);
|
||||||
|
echo "?" . http_build_query($queryParams);
|
||||||
|
}
|
||||||
?>";
|
?>";
|
||||||
|
|
||||||
var newUrl = thisUrl + querySuffix;
|
var newUrl = thisUrl + querySuffix;
|
||||||
|
|
|
@ -111,7 +111,7 @@ function previewEvent( eventId, frameId )
|
||||||
if ( event['frames'][frameId] )
|
if ( event['frames'][frameId] )
|
||||||
{
|
{
|
||||||
showEventDetail( event['frames'][frameId]['html'] );
|
showEventDetail( event['frames'][frameId]['html'] );
|
||||||
var imagePath = event.frames[frameId].Image.imagePath;
|
var imagePath = '/index.php?view=image&eid='+eventId+'&fid='+frameId;
|
||||||
var videoName = event.DefaultVideo;
|
var videoName = event.DefaultVideo;
|
||||||
loadEventImage( imagePath, eventId, frameId, event.Width, event.Height, event.Frames/event.Length, videoName, event.Length, event.StartTime, monitors[event.MonitorId]);
|
loadEventImage( imagePath, eventId, frameId, event.Width, event.Height, event.Frames/event.Length, videoName, event.Length, event.StartTime, monitors[event.MonitorId]);
|
||||||
return;
|
return;
|
||||||
|
@ -125,11 +125,10 @@ function loadEventImage( imagePath, eid, fid, width, height, fps, videoName, dur
|
||||||
{
|
{
|
||||||
var vid= $('preview');
|
var vid= $('preview');
|
||||||
var imageSrc = $('imageSrc');
|
var imageSrc = $('imageSrc');
|
||||||
if(videoName)
|
if ( videoName && vid ) {
|
||||||
{
|
|
||||||
vid.show();
|
vid.show();
|
||||||
imageSrc.hide();
|
imageSrc.hide();
|
||||||
var newsource=imagePrefix+imagePath.slice(0,imagePath.lastIndexOf('/'))+"/"+videoName;
|
var newsource=imagePath.slice(0,imagePath.lastIndexOf('/'))+"/"+videoName;
|
||||||
//console.log(newsource);
|
//console.log(newsource);
|
||||||
//console.log(sources[0].src.slice(-newsource.length));
|
//console.log(sources[0].src.slice(-newsource.length));
|
||||||
if(newsource!=vid.currentSrc.slice(-newsource.length) || vid.readyState==0)
|
if(newsource!=vid.currentSrc.slice(-newsource.length) || vid.readyState==0)
|
||||||
|
@ -154,9 +153,9 @@ function loadEventImage( imagePath, eid, fid, width, height, fps, videoName, dur
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vid.hide();
|
if ( vid ) vid.hide();
|
||||||
imageSrc.show();
|
imageSrc.show();
|
||||||
imageSrc.setProperty( 'src', imagePrefix+imagePath );
|
imageSrc.setProperty( 'src', imagePath );
|
||||||
imageSrc.removeEvent( 'click' );
|
imageSrc.removeEvent( 'click' );
|
||||||
imageSrc.addEvent( 'click', showEvent.pass( [ eid, fid, width, height ] ) );
|
imageSrc.addEvent( 'click', showEvent.pass( [ eid, fid, width, height ] ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,89 +1,60 @@
|
||||||
function validateForm( form )
|
function validateForm( form ) {
|
||||||
{
|
|
||||||
var errors = new Array();
|
var errors = new Array();
|
||||||
if ( selfIntersecting )
|
if ( selfIntersecting ) {
|
||||||
{
|
|
||||||
errors[errors.length] = selfIntersectingString;
|
errors[errors.length] = selfIntersectingString;
|
||||||
}
|
}
|
||||||
if ( form.elements['newZone[Type]'].value != 'Inactive' && form.elements['newZone[Type]'].value != 'Privacy' )
|
if ( form.elements['newZone[Type]'].value != 'Inactive' && form.elements['newZone[Type]'].value != 'Privacy' ) {
|
||||||
{
|
if ( !form.newAlarmRgbR.value || !form.newAlarmRgbG.value || !form.newAlarmRgbB.value ) {
|
||||||
if ( !form.newAlarmRgbR.value || !form.newAlarmRgbG.value || !form.newAlarmRgbB.value )
|
|
||||||
{
|
|
||||||
errors[errors.length] = alarmRGBUnsetString;
|
errors[errors.length] = alarmRGBUnsetString;
|
||||||
}
|
}
|
||||||
form.elements['newZone[AlarmRGB]'].value = (form.newAlarmRgbR.value<<16)|(form.newAlarmRgbG.value<<8)|form.newAlarmRgbB.value;
|
form.elements['newZone[AlarmRGB]'].value = (form.newAlarmRgbR.value<<16)|(form.newAlarmRgbG.value<<8)|form.newAlarmRgbB.value;
|
||||||
if ( !form.elements['newZone[MinPixelThreshold]'].value || (parseInt(form.elements['newZone[MinPixelThreshold]'].value) <= 0 ) )
|
if ( !form.elements['newZone[MinPixelThreshold]'].value || (parseInt(form.elements['newZone[MinPixelThreshold]'].value) <= 0 ) ) {
|
||||||
{
|
|
||||||
errors[errors.length] = minPixelThresUnsetString;
|
errors[errors.length] = minPixelThresUnsetString;
|
||||||
}
|
} else if ( (parseInt(form.elements['newZone[MinPixelThreshold]'].value) >= parseInt(form.elements['newZone[MaxPixelThreshold]'].value)) && (parseInt(form.elements['newZone[MaxPixelThreshold]'].value) > 0) ) {
|
||||||
else if ( (parseInt(form.elements['newZone[MinPixelThreshold]'].value) >= parseInt(form.elements['newZone[MaxPixelThreshold]'].value)) && (parseInt(form.elements['newZone[MaxPixelThreshold]'].value) > 0) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minPixelThresLtMaxString;
|
errors[errors.length] = minPixelThresLtMaxString;
|
||||||
}
|
}
|
||||||
if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' || form.elements['newZone[CheckMethod]'].value == 'Blobs' )
|
if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' || form.elements['newZone[CheckMethod]'].value == 'Blobs' ) {
|
||||||
{
|
if ( !form.elements['newZone[FilterX]'].value || !form.elements['newZone[FilterY]'].value ) {
|
||||||
if ( !form.elements['newZone[FilterX]'].value || !form.elements['newZone[FilterY]'].value )
|
|
||||||
{
|
|
||||||
errors[errors.length] = filterUnsetString;
|
errors[errors.length] = filterUnsetString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !form.elements['newZone[MinAlarmPixels]'].value || (parseFloat(form.elements['newZone[MinAlarmPixels]'].value) <= 0 ) )
|
if ( !form.elements['newZone[MinAlarmPixels]'].value || (parseFloat(form.elements['newZone[MinAlarmPixels]'].value) <= 0 ) ) {
|
||||||
{
|
|
||||||
errors[errors.length] = minAlarmAreaUnsetString;
|
errors[errors.length] = minAlarmAreaUnsetString;
|
||||||
}
|
} else if ( (parseFloat(form.elements['newZone[MinAlarmPixels]'].value) >= parseFloat(form.elements['newZone[MaxAlarmPixels]'].value)) && (parseFloat(form.elements['newZone[MaxAlarmPixels]'].value) > 0) ) {
|
||||||
else if ( (parseFloat(form.elements['newZone[MinAlarmPixels]'].value) >= parseFloat(form.elements['newZone[MaxAlarmPixels]'].value)) && (parseFloat(form.elements['newZone[MaxAlarmPixels]'].value) > 0) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minAlarmAreaLtMaxString;
|
errors[errors.length] = minAlarmAreaLtMaxString;
|
||||||
}
|
}
|
||||||
if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' || form.elements['newZone[CheckMethod]'].value == 'Blobs' )
|
if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' || form.elements['newZone[CheckMethod]'].value == 'Blobs' ) {
|
||||||
{
|
if ( !form.elements['newZone[MinFilterPixels]'].value || (parseFloat(form.elements['newZone[MinFilterPixels]'].value) <= 0 ) ) {
|
||||||
if ( !form.elements['newZone[MinFilterPixels]'].value || (parseFloat(form.elements['newZone[MinFilterPixels]'].value) <= 0 ) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minFilterAreaUnsetString;
|
errors[errors.length] = minFilterAreaUnsetString;
|
||||||
}
|
} else if ( (parseFloat(form.elements['newZone[MinFilterPixels]'].value) >= parseFloat(form.elements['newZone[MaxFilterPixels]'].value)) && (parseFloat(form.elements['newZone[MaxFilterPixels]'].value) > 0) ) {
|
||||||
else if ( (parseFloat(form.elements['newZone[MinFilterPixels]'].value) >= parseFloat(form.elements['newZone[MaxFilterPixels]'].value)) && (parseFloat(form.elements['newZone[MaxFilterPixels]'].value) > 0) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minFilterAreaLtMaxString;
|
errors[errors.length] = minFilterAreaLtMaxString;
|
||||||
}
|
} else if ( parseFloat(form.elements['newZone[MinAlarmPixels]'].value) < parseFloat(form.elements['newZone[MinFilterPixels]'].value) ) {
|
||||||
else if ( parseFloat(form.elements['newZone[MinAlarmPixels]'].value) < parseFloat(form.elements['newZone[MinFilterPixels]'].value) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minFilterLtMinAlarmString;
|
errors[errors.length] = minFilterLtMinAlarmString;
|
||||||
}
|
}
|
||||||
if ( form.elements['newZone[CheckMethod]'].value == 'Blobs' )
|
if ( form.elements['newZone[CheckMethod]'].value == 'Blobs' ) {
|
||||||
{
|
if ( !form.elements['newZone[MinBlobPixels]'].value || (parseFloat(form.elements['newZone[MinBlobPixels]'].value) <= 0 ) ) {
|
||||||
if ( !form.elements['newZone[MinBlobPixels]'].value || (parseFloat(form.elements['newZone[MinBlobPixels]'].value) <= 0 ) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minBlobAreaUnsetString;
|
errors[errors.length] = minBlobAreaUnsetString;
|
||||||
}
|
} else if ( (parseFloat(form.elements['newZone[MinBlobPixels]'].value) >= parseFloat(form.elements['newZone[MaxBlobPixels]'].value)) && (parseFloat(form.elements['newZone[MaxBlobPixels]'].value) > 0) ) {
|
||||||
else if ( (parseFloat(form.elements['newZone[MinBlobPixels]'].value) >= parseFloat(form.elements['newZone[MaxBlobPixels]'].value)) && (parseFloat(form.elements['newZone[MaxBlobPixels]'].value) > 0) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minBlobAreaLtMaxString;
|
errors[errors.length] = minBlobAreaLtMaxString;
|
||||||
}
|
} else if ( parseFloat(form.elements['newZone[MinFilterPixels]'].value) < parseFloat(form.elements['newZone[MinBlobPixels]'].value) ) {
|
||||||
else if ( parseFloat(form.elements['newZone[MinFilterPixels]'].value) < parseFloat(form.elements['newZone[MinBlobPixels]'].value) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minBlobLtMinFilterString;
|
errors[errors.length] = minBlobLtMinFilterString;
|
||||||
}
|
}
|
||||||
if ( !form.elements['newZone[MinBlobs]'].value || (parseInt(form.elements['newZone[MinBlobs]'].value) <= 0 ) )
|
if ( !form.elements['newZone[MinBlobs]'].value || (parseInt(form.elements['newZone[MinBlobs]'].value) <= 0 ) ) {
|
||||||
{
|
|
||||||
errors[errors.length] = minBlobsUnsetString;
|
errors[errors.length] = minBlobsUnsetString;
|
||||||
}
|
} else if ( (parseInt(form.elements['newZone[MinBlobs]'].value) >= parseInt(form.elements['newZone[MaxBlobs]'].value)) && (parseInt(form.elements['newZone[MaxBlobs]'].value) > 0) ) {
|
||||||
else if ( (parseInt(form.elements['newZone[MinBlobs]'].value) >= parseInt(form.elements['newZone[MaxBlobs]'].value)) && (parseInt(form.elements['newZone[MaxBlobs]'].value) > 0) )
|
|
||||||
{
|
|
||||||
errors[errors.length] = minBlobsLtMaxString;
|
errors[errors.length] = minBlobsLtMaxString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( errors.length )
|
if ( errors.length ) {
|
||||||
{
|
|
||||||
alert( errors.join( "\n" ) );
|
alert( errors.join( "\n" ) );
|
||||||
return( false );
|
return( false );
|
||||||
}
|
}
|
||||||
return( true );
|
return( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitForm( form )
|
function submitForm( form ) {
|
||||||
{
|
|
||||||
form.elements['newZone[AlarmRGB]'].value = (form.newAlarmRgbR.value<<16)|(form.newAlarmRgbG.value<<8)|form.newAlarmRgbB.value;
|
form.elements['newZone[AlarmRGB]'].value = (form.newAlarmRgbR.value<<16)|(form.newAlarmRgbG.value<<8)|form.newAlarmRgbB.value;
|
||||||
form.elements['newZone[NumCoords]'].value = zone['Points'].length;
|
form.elements['newZone[NumCoords]'].value = zone['Points'].length;
|
||||||
form.elements['newZone[Coords]'].value = getCoordString();
|
form.elements['newZone[Coords]'].value = getCoordString();
|
||||||
|
@ -92,11 +63,9 @@ function submitForm( form )
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyZoneType()
|
function applyZoneType() {
|
||||||
{
|
|
||||||
var form = document.zoneForm;
|
var form = document.zoneForm;
|
||||||
if ( form.elements['newZone[Type]'].value == 'Inactive' || form.elements['newZone[Type]'].value == 'Privacy' )
|
if ( form.elements['newZone[Type]'].value == 'Inactive' || form.elements['newZone[Type]'].value == 'Privacy' ) {
|
||||||
{
|
|
||||||
form.presetSelector.disabled = true;
|
form.presetSelector.disabled = true;
|
||||||
form.newAlarmRgbR.disabled = true;
|
form.newAlarmRgbR.disabled = true;
|
||||||
form.newAlarmRgbG.disabled = true;
|
form.newAlarmRgbG.disabled = true;
|
||||||
|
@ -116,9 +85,7 @@ function applyZoneType()
|
||||||
form.elements['newZone[MaxBlobs]'].disabled = true;
|
form.elements['newZone[MaxBlobs]'].disabled = true;
|
||||||
form.elements['newZone[OverloadFrames]'].disabled = true;
|
form.elements['newZone[OverloadFrames]'].disabled = true;
|
||||||
form.elements['newZone[ExtendAlarmFrames]'].disabled = true;
|
form.elements['newZone[ExtendAlarmFrames]'].disabled = true;
|
||||||
}
|
} else if ( form.elements['newZone[Type]'].value == 'Preclusive' ) {
|
||||||
else if ( form.elements['newZone[Type]'].value == 'Preclusive' )
|
|
||||||
{
|
|
||||||
form.presetSelector.disabled = false;
|
form.presetSelector.disabled = false;
|
||||||
form.newAlarmRgbR.disabled = true;
|
form.newAlarmRgbR.disabled = true;
|
||||||
form.newAlarmRgbG.disabled = true;
|
form.newAlarmRgbG.disabled = true;
|
||||||
|
@ -131,9 +98,7 @@ function applyZoneType()
|
||||||
form.elements['newZone[OverloadFrames]'].disabled = false;
|
form.elements['newZone[OverloadFrames]'].disabled = false;
|
||||||
form.elements['newZone[ExtendAlarmFrames]'].disabled = false;
|
form.elements['newZone[ExtendAlarmFrames]'].disabled = false;
|
||||||
applyCheckMethod();
|
applyCheckMethod();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
form.presetSelector.disabled = false;
|
form.presetSelector.disabled = false;
|
||||||
form.newAlarmRgbR.disabled = false;
|
form.newAlarmRgbR.disabled = false;
|
||||||
form.newAlarmRgbG.disabled = false;
|
form.newAlarmRgbG.disabled = false;
|
||||||
|
@ -149,11 +114,9 @@ function applyZoneType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyCheckMethod()
|
function applyCheckMethod() {
|
||||||
{
|
|
||||||
var form = document.zoneForm;
|
var form = document.zoneForm;
|
||||||
if ( form.elements['newZone[CheckMethod]'].value == 'AlarmedPixels' )
|
if ( form.elements['newZone[CheckMethod]'].value == 'AlarmedPixels' ) {
|
||||||
{
|
|
||||||
form.elements['newZone[FilterX]'].disabled = true;
|
form.elements['newZone[FilterX]'].disabled = true;
|
||||||
form.elements['newZone[FilterY]'].disabled = true;
|
form.elements['newZone[FilterY]'].disabled = true;
|
||||||
form.elements['newZone[MinFilterPixels]'].disabled = true;
|
form.elements['newZone[MinFilterPixels]'].disabled = true;
|
||||||
|
@ -162,9 +125,7 @@ function applyCheckMethod()
|
||||||
form.elements['newZone[MaxBlobPixels]'].disabled = true;
|
form.elements['newZone[MaxBlobPixels]'].disabled = true;
|
||||||
form.elements['newZone[MinBlobs]'].disabled = true;
|
form.elements['newZone[MinBlobs]'].disabled = true;
|
||||||
form.elements['newZone[MaxBlobs]'].disabled = true;
|
form.elements['newZone[MaxBlobs]'].disabled = true;
|
||||||
}
|
} else if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' ) {
|
||||||
else if ( form.elements['newZone[CheckMethod]'].value == 'FilteredPixels' )
|
|
||||||
{
|
|
||||||
form.elements['newZone[FilterX]'].disabled = false;
|
form.elements['newZone[FilterX]'].disabled = false;
|
||||||
form.elements['newZone[FilterY]'].disabled = false;
|
form.elements['newZone[FilterY]'].disabled = false;
|
||||||
form.elements['newZone[MinFilterPixels]'].disabled = false;
|
form.elements['newZone[MinFilterPixels]'].disabled = false;
|
||||||
|
@ -173,9 +134,7 @@ function applyCheckMethod()
|
||||||
form.elements['newZone[MaxBlobPixels]'].disabled = true;
|
form.elements['newZone[MaxBlobPixels]'].disabled = true;
|
||||||
form.elements['newZone[MinBlobs]'].disabled = true;
|
form.elements['newZone[MinBlobs]'].disabled = true;
|
||||||
form.elements['newZone[MaxBlobs]'].disabled = true;
|
form.elements['newZone[MaxBlobs]'].disabled = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
form.elements['newZone[FilterX]'].disabled = false;
|
form.elements['newZone[FilterX]'].disabled = false;
|
||||||
form.elements['newZone[FilterY]'].disabled = false;
|
form.elements['newZone[FilterY]'].disabled = false;
|
||||||
form.elements['newZone[MinFilterPixels]'].disabled = false;
|
form.elements['newZone[MinFilterPixels]'].disabled = false;
|
||||||
|
@ -187,13 +146,11 @@ function applyCheckMethod()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyPreset()
|
function applyPreset() {
|
||||||
{
|
|
||||||
var form = document.zoneForm;
|
var form = document.zoneForm;
|
||||||
var presetId = $('presetSelector').get('value');
|
var presetId = $('presetSelector').get('value');
|
||||||
|
|
||||||
if ( presets[presetId] )
|
if ( presets[presetId] ) {
|
||||||
{
|
|
||||||
var preset = presets[presetId];
|
var preset = presets[presetId];
|
||||||
|
|
||||||
form.elements['newZone[Units]'].selectedIndex = preset['UnitsIndex'];
|
form.elements['newZone[Units]'].selectedIndex = preset['UnitsIndex'];
|
||||||
|
@ -218,25 +175,21 @@ function applyPreset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toPixels( field, maxValue )
|
function toPixels( field, maxValue ) {
|
||||||
{
|
|
||||||
if ( field.value != '' )
|
if ( field.value != '' )
|
||||||
field.value = Math.round((field.value*maxValue)/100);
|
field.value = Math.round((field.value*maxValue)/100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toPercent( field, maxValue )
|
function toPercent( field, maxValue ) {
|
||||||
{
|
|
||||||
if ( field.value != '' )
|
if ( field.value != '' )
|
||||||
field.value = Math.round((100*100*field.value)/maxValue)/100;
|
field.value = Math.round((100*100*field.value)/maxValue)/100;
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyZoneUnits()
|
function applyZoneUnits() {
|
||||||
{
|
|
||||||
var area = zone.Area;
|
var area = zone.Area;
|
||||||
|
|
||||||
var form = document.zoneForm;
|
var form = document.zoneForm;
|
||||||
if ( form.elements['newZone[Units]'].value == 'Pixels' )
|
if ( form.elements['newZone[Units]'].value == 'Pixels' ) {
|
||||||
{
|
|
||||||
form.elements['newZone[TempArea]'].value = area;
|
form.elements['newZone[TempArea]'].value = area;
|
||||||
toPixels( form.elements['newZone[MinAlarmPixels]'], area );
|
toPixels( form.elements['newZone[MinAlarmPixels]'], area );
|
||||||
toPixels( form.elements['newZone[MaxAlarmPixels]'], area );
|
toPixels( form.elements['newZone[MaxAlarmPixels]'], area );
|
||||||
|
@ -244,9 +197,7 @@ function applyZoneUnits()
|
||||||
toPixels( form.elements['newZone[MaxFilterPixels]'], area );
|
toPixels( form.elements['newZone[MaxFilterPixels]'], area );
|
||||||
toPixels( form.elements['newZone[MinBlobPixels]'], area );
|
toPixels( form.elements['newZone[MinBlobPixels]'], area );
|
||||||
toPixels( form.elements['newZone[MaxBlobPixels]'], area );
|
toPixels( form.elements['newZone[MaxBlobPixels]'], area );
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
form.elements['newZone[TempArea]'].value = Math.round( area/monitorArea * 100 );
|
form.elements['newZone[TempArea]'].value = Math.round( area/monitorArea * 100 );
|
||||||
toPercent( form.elements['newZone[MinAlarmPixels]'], area );
|
toPercent( form.elements['newZone[MinAlarmPixels]'], area );
|
||||||
toPercent( form.elements['newZone[MaxAlarmPixels]'], area );
|
toPercent( form.elements['newZone[MaxAlarmPixels]'], area );
|
||||||
|
@ -257,63 +208,54 @@ function applyZoneUnits()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function limitRange( field, minValue, maxValue )
|
function limitRange( field, minValue, maxValue ) {
|
||||||
{
|
if ( field.value != '' )
|
||||||
field.value = constrainValue( parseInt(field.value), parseInt(minValue), parseInt(maxValue) );
|
field.value = constrainValue( parseInt(field.value), parseInt(minValue), parseInt(maxValue) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function limitFilter( field )
|
function limitFilter( field ) {
|
||||||
{
|
|
||||||
field.value = (Math.floor((field.value-1)/2)*2) + 1;
|
field.value = (Math.floor((field.value-1)/2)*2) + 1;
|
||||||
field.value = constrainValue(parseInt(field.value), 3, 15);
|
field.value = constrainValue(parseInt(field.value), 3, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
function limitArea( field )
|
function limitArea( field ) {
|
||||||
{
|
|
||||||
var minValue = 0;
|
var minValue = 0;
|
||||||
var maxValue = zone.Area;
|
var maxValue = zone.Area;
|
||||||
if ( document.zoneForm.elements['newZone[Units]'].value == "Percent" )
|
if ( document.zoneForm.elements['newZone[Units]'].value == "Percent" ) {
|
||||||
{
|
|
||||||
maxValue = 100;
|
maxValue = 100;
|
||||||
}
|
}
|
||||||
limitRange( field, minValue, maxValue );
|
limitRange( field, minValue, maxValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlightOn( index )
|
function highlightOn( index ) {
|
||||||
{
|
|
||||||
$('row'+index).addClass( 'highlight' );
|
$('row'+index).addClass( 'highlight' );
|
||||||
$('point'+index).addClass( 'highlight' );
|
$('point'+index).addClass( 'highlight' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlightOff( index )
|
function highlightOff( index ) {
|
||||||
{
|
|
||||||
$('row'+index).removeClass( 'highlight' );
|
$('row'+index).removeClass( 'highlight' );
|
||||||
$('point'+index).removeClass( 'highlight' );
|
$('point'+index).removeClass( 'highlight' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function setActivePoint( index )
|
function setActivePoint( index ) {
|
||||||
{
|
|
||||||
highlightOff( index );
|
highlightOff( index );
|
||||||
$('row'+index).addClass( 'active' );
|
$('row'+index).addClass( 'active' );
|
||||||
$('point'+index).addClass( 'active' );
|
$('point'+index).addClass( 'active' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsetActivePoint( index )
|
function unsetActivePoint( index ) {
|
||||||
{
|
|
||||||
$('row'+index).removeClass( 'active' );
|
$('row'+index).removeClass( 'active' );
|
||||||
$('point'+index).removeClass( 'active' );
|
$('point'+index).removeClass( 'active' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCoordString()
|
function getCoordString() {
|
||||||
{
|
|
||||||
var coords = new Array();
|
var coords = new Array();
|
||||||
for ( var i = 0; i < zone['Points'].length; i++ )
|
for ( var i = 0; i < zone['Points'].length; i++ )
|
||||||
coords[coords.length] = zone['Points'][i].x+','+zone['Points'][i].y;
|
coords[coords.length] = zone['Points'][i].x+','+zone['Points'][i].y;
|
||||||
return( coords.join( " " ) );
|
return( coords.join( " " ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateZoneImage()
|
function updateZoneImage() {
|
||||||
{
|
|
||||||
var SVG = $('zoneSVG');
|
var SVG = $('zoneSVG');
|
||||||
var Poly = $('zonePoly');
|
var Poly = $('zonePoly');
|
||||||
Poly.points.clear();
|
Poly.points.clear();
|
||||||
|
@ -325,15 +267,13 @@ function updateZoneImage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixActivePoint( index )
|
function fixActivePoint( index ) {
|
||||||
{
|
|
||||||
updateActivePoint( index );
|
updateActivePoint( index );
|
||||||
unsetActivePoint( index );
|
unsetActivePoint( index );
|
||||||
updateZoneImage();
|
updateZoneImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
function constrainValue( value, loVal, hiVal )
|
function constrainValue( value, loVal, hiVal ) {
|
||||||
{
|
|
||||||
if ( value < loVal ) {
|
if ( value < loVal ) {
|
||||||
return loVal;
|
return loVal;
|
||||||
}
|
}
|
||||||
|
@ -343,8 +283,7 @@ function constrainValue( value, loVal, hiVal )
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateActivePoint( index )
|
function updateActivePoint( index ) {
|
||||||
{
|
|
||||||
var point = $('point'+index);
|
var point = $('point'+index);
|
||||||
var x = constrainValue( point.getStyle( 'left' ).toInt(), 0, maxX );
|
var x = constrainValue( point.getStyle( 'left' ).toInt(), 0, maxX );
|
||||||
var y = constrainValue( point.getStyle( 'top' ).toInt(), 0, maxY );
|
var y = constrainValue( point.getStyle( 'top' ).toInt(), 0, maxY );
|
||||||
|
@ -359,8 +298,7 @@ function updateActivePoint( index )
|
||||||
updateArea();
|
updateArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPoint( index )
|
function addPoint( index ) {
|
||||||
{
|
|
||||||
var nextIndex = index+1;
|
var nextIndex = index+1;
|
||||||
if ( index >= (zone['Points'].length-1) )
|
if ( index >= (zone['Points'].length-1) )
|
||||||
nextIndex = 0;
|
nextIndex = 0;
|
||||||
|
@ -376,15 +314,13 @@ function addPoint( index )
|
||||||
//setActivePoint( nextIndex );
|
//setActivePoint( nextIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
function delPoint( index )
|
function delPoint( index ) {
|
||||||
{
|
|
||||||
zone['Points'].splice( index, 1 );
|
zone['Points'].splice( index, 1 );
|
||||||
drawZonePoints();
|
drawZonePoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
function limitPointValue( point, loVal, hiVal )
|
function limitPointValue( point, loVal, hiVal ) {
|
||||||
{
|
point.value = constrainValue(point.value, loVal, hiVal);
|
||||||
point.value = constrainValue(point.value, loVal, hiVal)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateArea( ) {
|
function updateArea( ) {
|
||||||
|
@ -402,8 +338,7 @@ function updateArea( ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateX( index )
|
function updateX( index ) {
|
||||||
{
|
|
||||||
limitPointValue( $('newZone[Points]['+index+'][x]'), 0, maxX );
|
limitPointValue( $('newZone[Points]['+index+'][x]'), 0, maxX );
|
||||||
|
|
||||||
var point = $('point'+index);
|
var point = $('point'+index);
|
||||||
|
@ -415,8 +350,7 @@ function updateX( index )
|
||||||
Point.x = x;
|
Point.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateY( index )
|
function updateY( index ) {
|
||||||
{
|
|
||||||
limitPointValue( $('newZone[Points]['+index+'][y]'), 0, maxY );
|
limitPointValue( $('newZone[Points]['+index+'][y]'), 0, maxY );
|
||||||
|
|
||||||
var point = $('point'+index);
|
var point = $('point'+index);
|
||||||
|
@ -428,14 +362,11 @@ function updateY( index )
|
||||||
Point.y = y;
|
Point.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveChanges( element )
|
function saveChanges( element ) {
|
||||||
{
|
|
||||||
var form = element.form;
|
var form = element.form;
|
||||||
if ( validateForm( form ) )
|
if ( validateForm( form ) ) {
|
||||||
{
|
|
||||||
submitForm( form );
|
submitForm( form );
|
||||||
if ( form.elements['newZone[Type]'].value == 'Privacy' )
|
if ( form.elements['newZone[Type]'].value == 'Privacy' ) {
|
||||||
{
|
|
||||||
alert( 'Capture process for this monitor will be restarted for the Privacy zone changes to take effect.' );
|
alert( 'Capture process for this monitor will be restarted for the Privacy zone changes to take effect.' );
|
||||||
}
|
}
|
||||||
return( true );
|
return( true );
|
||||||
|
@ -443,22 +374,24 @@ function saveChanges( element )
|
||||||
return( false );
|
return( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawZonePoints()
|
function drawZonePoints() {
|
||||||
{
|
|
||||||
$('imageFrame').getElements( 'div.zonePoint' ).each( function( element ) { element.destroy(); } );
|
$('imageFrame').getElements( 'div.zonePoint' ).each( function( element ) { element.destroy(); } );
|
||||||
for ( var i = 0; i < zone['Points'].length; i++ )
|
for ( var i = 0; i < zone['Points'].length; i++ ) {
|
||||||
{
|
|
||||||
var div = new Element( 'div', { 'id': 'point'+i, 'class': 'zonePoint', 'title': 'Point '+(i+1), 'styles': { 'left': zone['Points'][i].x, 'top': zone['Points'][i].y } } );
|
var div = new Element( 'div', { 'id': 'point'+i, 'class': 'zonePoint', 'title': 'Point '+(i+1), 'styles': { 'left': zone['Points'][i].x, 'top': zone['Points'][i].y } } );
|
||||||
div.addEvent( 'mouseover', highlightOn.pass( i ) );
|
div.addEvent( 'mouseover', highlightOn.pass( i ) );
|
||||||
div.addEvent( 'mouseout', highlightOff.pass( i ) );
|
div.addEvent( 'mouseout', highlightOff.pass( i ) );
|
||||||
div.inject( $('imageFrame') );
|
div.inject( $('imageFrame') );
|
||||||
div.makeDraggable( { 'container': $('imageFrame'), 'onStart': setActivePoint.pass( i ), 'onComplete': fixActivePoint.pass( i ), 'onDrag': updateActivePoint.pass( i ) } );
|
div.makeDraggable( {
|
||||||
|
'container': $('imageFrame'),
|
||||||
|
'onStart': setActivePoint.pass( i ),
|
||||||
|
'onComplete': fixActivePoint.pass( i ),
|
||||||
|
'onDrag': updateActivePoint.pass( i )
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
var tables = $('zonePoints').getElements( 'table' );
|
var tables = $('zonePoints').getElements( 'table' );
|
||||||
tables.each( function( table ) { table.getElement( 'tbody' ).empty(); } );
|
tables.each( function( table ) { table.getElement( 'tbody' ).empty(); } );
|
||||||
for ( var i = 0; i < zone['Points'].length; i++ )
|
for ( var i = 0; i < zone['Points'].length; i++ ) {
|
||||||
{
|
|
||||||
var row = new Element( 'tr', { 'id': 'row'+i } );
|
var row = new Element( 'tr', { 'id': 'row'+i } );
|
||||||
row.addEvents( { 'mouseover': highlightOn.pass( i ), 'mouseout': highlightOff.pass( i ) } );
|
row.addEvents( { 'mouseover': highlightOn.pass( i ), 'mouseout': highlightOff.pass( i ) } );
|
||||||
var cell = new Element( 'td' );
|
var cell = new Element( 'td' );
|
||||||
|
@ -647,17 +580,14 @@ function fetchImage( streamImage ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function appletRefresh() {
|
function appletRefresh() {
|
||||||
if ( streamStatus && (!streamStatus.paused && !streamStatus.delayed) )
|
if ( streamStatus && (!streamStatus.paused && !streamStatus.delayed) ) {
|
||||||
{
|
|
||||||
var streamImg = $('liveStream');
|
var streamImg = $('liveStream');
|
||||||
var parent = streamImg.getParent();
|
var parent = streamImg.getParent();
|
||||||
streamImg.dispose();
|
streamImg.dispose();
|
||||||
streamImg.inject( parent );
|
streamImg.inject( parent );
|
||||||
if ( appletRefreshTime )
|
if ( appletRefreshTime )
|
||||||
appletRefresh.delay( appletRefreshTime*1000 );
|
appletRefresh.delay( appletRefreshTime*1000 );
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
appletRefresh.delay( 15*1000 ); //if we are paused or delayed check every 15 seconds if we are live yet...
|
appletRefresh.delay( 15*1000 ); //if we are paused or delayed check every 15 seconds if we are live yet...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ xhtmlHeaders(__FILE__, translate('Login') );
|
||||||
<form class="center-block" name="loginForm" id="loginForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
<form class="center-block" name="loginForm" id="loginForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
||||||
<input type="hidden" name="action" value="login"/>
|
<input type="hidden" name="action" value="login"/>
|
||||||
<input type="hidden" name="view" value="postlogin"/>
|
<input type="hidden" name="view" value="postlogin"/>
|
||||||
<input type="hidden" name="postLoginQuery" value="<?php echo $_SERVER['QUERY_STRING'] ?>">
|
<input type="hidden" name="postLoginQuery" value="<?php echo htmlspecialchars($_SERVER['QUERY_STRING']) ?>">
|
||||||
|
|
||||||
<div id="loginError" class="hidden alarm" role="alert">
|
<div id="loginError" class="hidden alarm" role="alert">
|
||||||
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
||||||
|
|
|
@ -210,8 +210,8 @@ $sourceTypes = array(
|
||||||
'Libvlc' => translate('Libvlc'),
|
'Libvlc' => translate('Libvlc'),
|
||||||
'cURL' => "cURL (HTTP(S) only)"
|
'cURL' => "cURL (HTTP(S) only)"
|
||||||
);
|
);
|
||||||
if ( !ZM_HAS_V4L )
|
if ( !ZM_HAS_V4L )
|
||||||
unset($sourceTypes['Local']);
|
unset($sourceTypes['Local']);
|
||||||
|
|
||||||
$localMethods = array(
|
$localMethods = array(
|
||||||
'v4l2' => "Video For Linux version 2",
|
'v4l2' => "Video For Linux version 2",
|
||||||
|
@ -234,6 +234,13 @@ if ( !ZM_HAS_V4L1 )
|
||||||
"rtpRtspHttp" => "RTP/RTSP/HTTP"
|
"rtpRtspHttp" => "RTP/RTSP/HTTP"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$rtspFFMpegMethods = array(
|
||||||
|
"rtpRtsp" => "TCP",
|
||||||
|
"rtpUni" => "UDP",
|
||||||
|
"rtpMulti" => "UDP Multicast",
|
||||||
|
"rtpRtspHttp" => "HTTP Tunnel"
|
||||||
|
);
|
||||||
|
|
||||||
$httpMethods = array(
|
$httpMethods = array(
|
||||||
"simple" => "Simple",
|
"simple" => "Simple",
|
||||||
"regexp" => "Regexp",
|
"regexp" => "Regexp",
|
||||||
|
@ -722,7 +729,7 @@ switch ( $tab )
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td><?php echo translate('AnalysisFPS') ?></td><td><input type="text" name="newMonitor[AnalysisFPS]" value="<?php echo validHtmlStr($monitor->AnalysisFPS) ?>" size="6"/></td></tr>
|
<tr><td><?php echo translate('AnalysisFPS') ?></td><td><input type="text" name="newMonitor[AnalysisFPS]" value="<?php echo validHtmlStr($monitor->AnalysisFPS) ?>" size="6"/></td></tr>
|
||||||
<?php if ( $monitor->Type != "Local" && $monitor->Type != "File" ) { ?>
|
<?php if ( $monitor->Type() != "Local" && $monitor->Type() != "File" ) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo translate('MaximumFPS') ?> (<?php echo makePopupLink('?view=optionhelp&option=OPTIONS_MAXFPS', 'zmOptionHelp', 'optionhelp', '?' ) ?>)</td>
|
<td><?php echo translate('MaximumFPS') ?> (<?php echo makePopupLink('?view=optionhelp&option=OPTIONS_MAXFPS', 'zmOptionHelp', 'optionhelp', '?' ) ?>)</td>
|
||||||
<td><input type="text" onclick="document.getElementById('newMonitor[MaxFPS]').innerHTML= ' CAUTION: See the help text'" name="newMonitor[MaxFPS]" value="<?php echo validHtmlStr($monitor->MaxFPS) ?>" size="5"/><span id="newMonitor[MaxFPS]" style="color:red"></span></td>
|
<td><input type="text" onclick="document.getElementById('newMonitor[MaxFPS]').innerHTML= ' CAUTION: See the help text'" name="newMonitor[MaxFPS]" value="<?php echo validHtmlStr($monitor->MaxFPS) ?>" size="5"/><span id="newMonitor[MaxFPS]" style="color:red"></span></td>
|
||||||
|
@ -738,8 +745,18 @@ switch ( $tab )
|
||||||
}
|
}
|
||||||
if ( ZM_FAST_IMAGE_BLENDS ) {
|
if ( ZM_FAST_IMAGE_BLENDS ) {
|
||||||
?>
|
?>
|
||||||
<tr><td><?php echo translate('RefImageBlendPct') ?></td><td><select name="newMonitor[RefBlendPerc]"><?php foreach ( $fastblendopts as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->RefBlendPerc ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr>
|
||||||
<tr><td><?php echo translate('AlmRefImageBlendPct') ?></td><td><select name="newMonitor[AlarmRefBlendPerc]"><?php foreach ( $fastblendopts_alarm as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->AlarmRefBlendPerc ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<td><?php echo translate('RefImageBlendPct') ?></td>
|
||||||
|
<td><select name="newMonitor[RefBlendPerc]"><?php foreach ( $fastblendopts as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->RefBlendPerc() ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo translate('AlarmRefImageBlendPct') ?></td>
|
||||||
|
<td>
|
||||||
|
<select name="newMonitor[AlarmRefBlendPerc]">
|
||||||
|
<?php foreach ( $fastblendopts_alarm as $name => $value ) { ?>
|
||||||
|
<option value="<?php echo $value ?>"<?php if ( $value == $monitor->AlarmRefBlendPerc() ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
</select></td></tr>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
|
@ -751,22 +768,22 @@ switch ( $tab )
|
||||||
<tr><td><?php echo translate('Triggers') ?></td><td>
|
<tr><td><?php echo translate('Triggers') ?></td><td>
|
||||||
<?php
|
<?php
|
||||||
$optTriggers = getSetValues( 'Monitors', 'Triggers' );
|
$optTriggers = getSetValues( 'Monitors', 'Triggers' );
|
||||||
$breakCount = (int)(ceil(count($optTriggers)));
|
$breakCount = (int)(ceil(count($optTriggers)));
|
||||||
$breakCount = min( 3, $breakCount );
|
$breakCount = min( 3, $breakCount );
|
||||||
$optCount = 0;
|
$optCount = 0;
|
||||||
foreach( $optTriggers as $optTrigger )
|
foreach( $optTriggers as $optTrigger ) {
|
||||||
{
|
if ( ( ! ZM_OPT_X10 ) && ( $optTrigger == 'X10' ) )
|
||||||
if ( !ZM_OPT_X10 && $optTrigger == 'X10' )
|
continue;
|
||||||
continue;
|
if ( $optCount && ($optCount%$breakCount == 0) )
|
||||||
if ( $optCount && ($optCount%$breakCount == 0) )
|
echo '</br>';
|
||||||
echo "</br>";
|
echo '<input type="checkbox" name="newMonitor[Triggers][]" value="'. $optTrigger .'"';
|
||||||
?>
|
if ( isset($monitor->Triggers) && is_array( $monitor->Triggers ) and in_array( $optTrigger, $monitor->Triggers ) ) {
|
||||||
<input type="checkbox" name="newMonitor[Triggers][]" value="<?php echo $optTrigger ?>"<?php if ( isset($monitor->Triggers) && in_array( $optTrigger, $monitor->Triggers ) ) { ?> checked="checked"<?php } ?>/> <?php echo $optTrigger ?>
|
echo ' checked="checked"';
|
||||||
<?php
|
}
|
||||||
|
echo '/> '. $optTrigger ;
|
||||||
$optCount ++;
|
$optCount ++;
|
||||||
}
|
}
|
||||||
if ( !$optCount )
|
if ( !$optCount ) {
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
<em><?php echo translate('NoneAvailable') ?></em>
|
<em><?php echo translate('NoneAvailable') ?></em>
|
||||||
<?php
|
<?php
|
||||||
|
@ -780,23 +797,15 @@ switch ( $tab )
|
||||||
?>
|
?>
|
||||||
<tr><td><?php echo translate('DevicePath') ?></td><td><input type="text" name="newMonitor[Device]" value="<?php echo validHtmlStr($monitor->Device) ?>" size="24"/></td></tr>
|
<tr><td><?php echo translate('DevicePath') ?></td><td><input type="text" name="newMonitor[Device]" value="<?php echo validHtmlStr($monitor->Device) ?>" size="24"/></td></tr>
|
||||||
<tr><td><?php echo translate('CaptureMethod') ?></td><td><?php echo htmlSelect( "newMonitor[Method]", $localMethods, $monitor->Method(), "submitTab( '$tab' );" ); ?></td></tr>
|
<tr><td><?php echo translate('CaptureMethod') ?></td><td><?php echo htmlSelect( "newMonitor[Method]", $localMethods, $monitor->Method(), "submitTab( '$tab' );" ); ?></td></tr>
|
||||||
<?php
|
<?php if ( ZM_HAS_V4L1 && $monitor->Method == 'v4l1' ) { ?>
|
||||||
if ( ZM_HAS_V4L1 && $monitor->Method == 'v4l1' ) {
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('DeviceChannel') ?></td><td><select name="newMonitor[Channel]"><?php foreach ( $v4l1DeviceChannels as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Channel ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('DeviceChannel') ?></td><td><select name="newMonitor[Channel]"><?php foreach ( $v4l1DeviceChannels as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Channel ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<tr><td><?php echo translate('DeviceFormat') ?></td><td><select name="newMonitor[Format]"><?php foreach ( $v4l1DeviceFormats as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Format ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('DeviceFormat') ?></td><td><select name="newMonitor[Format]"><?php foreach ( $v4l1DeviceFormats as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Format ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<tr><td><?php echo translate('CapturePalette') ?></td><td><select name="newMonitor[Palette]"><?php foreach ( $v4l1LocalPalettes as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Palette ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('CapturePalette') ?></td><td><select name="newMonitor[Palette]"><?php foreach ( $v4l1LocalPalettes as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Palette ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<?php
|
<?php } else { ?>
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('DeviceChannel') ?></td><td><select name="newMonitor[Channel]"><?php foreach ( $v4l2DeviceChannels as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Channel ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('DeviceChannel') ?></td><td><select name="newMonitor[Channel]"><?php foreach ( $v4l2DeviceChannels as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Channel ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<tr><td><?php echo translate('DeviceFormat') ?></td><td><select name="newMonitor[Format]"><?php foreach ( $v4l2DeviceFormats as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Format ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('DeviceFormat') ?></td><td><select name="newMonitor[Format]"><?php foreach ( $v4l2DeviceFormats as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Format ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<tr><td><?php echo translate('CapturePalette') ?></td><td><select name="newMonitor[Palette]"><?php foreach ( $v4l2LocalPalettes as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Palette ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('CapturePalette') ?></td><td><select name="newMonitor[Palette]"><?php foreach ( $v4l2LocalPalettes as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Palette ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<?php
|
<?php } ?>
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('V4LMultiBuffer') ?></td><td>
|
<tr><td><?php echo translate('V4LMultiBuffer') ?></td><td>
|
||||||
<input type="radio" name="newMonitor[V4LMultiBuffer]" id="newMonitor[V4LMultiBuffer]1" value="1" <?php echo ( $monitor->V4LMultiBuffer == 1 ? 'checked="checked"' : '' ) ?>/>
|
<input type="radio" name="newMonitor[V4LMultiBuffer]" id="newMonitor[V4LMultiBuffer]1" value="1" <?php echo ( $monitor->V4LMultiBuffer == 1 ? 'checked="checked"' : '' ) ?>/>
|
||||||
<label for="newMonitor[V4LMultiBuffer]1">Yes</label>
|
<label for="newMonitor[V4LMultiBuffer]1">Yes</label>
|
||||||
|
@ -806,57 +815,34 @@ switch ( $tab )
|
||||||
<label for="newMonitor[V4LMultiBuffer]">Use Config Value</label>
|
<label for="newMonitor[V4LMultiBuffer]">Use Config Value</label>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td><?php echo translate('V4LCapturesPerFrame') ?></td><td><input type="number" name="newMonitor[V4LCapturesPerFrame]" value="<?php echo $monitor->V4LCapturesPerFrame ?>"/></td></tr>
|
<tr><td><?php echo translate('V4LCapturesPerFrame') ?></td><td><input type="number" name="newMonitor[V4LCapturesPerFrame]" value="<?php echo $monitor->V4LCapturesPerFrame ?>"/></td></tr>
|
||||||
<?php
|
<?php } elseif ( $monitor->Type == "Remote" ) { ?>
|
||||||
} elseif ( $monitor->Type == "Remote" ) {
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('RemoteProtocol') ?></td><td><?php echo htmlSelect( "newMonitor[Protocol]", $remoteProtocols, $monitor->Protocol(), "updateMethods( this );if(this.value=='rtsp'){\$('RTSPDescribe').setStyle('display','table-row');}else{\$('RTSPDescribe').hide();}" ); ?></td></tr>
|
<tr><td><?php echo translate('RemoteProtocol') ?></td><td><?php echo htmlSelect( "newMonitor[Protocol]", $remoteProtocols, $monitor->Protocol(), "updateMethods( this );if(this.value=='rtsp'){\$('RTSPDescribe').setStyle('display','table-row');}else{\$('RTSPDescribe').hide();}" ); ?></td></tr>
|
||||||
<?php
|
<?php if ( empty($monitor->Protocol) || $monitor->Protocol == "http" ) { ?>
|
||||||
if ( empty($monitor->Protocol) || $monitor->Protocol == "http" ) {
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('RemoteMethod') ?></td><td><?php echo htmlSelect( "newMonitor[Method]", $httpMethods, $monitor->Method() ); ?></td></tr>
|
<tr><td><?php echo translate('RemoteMethod') ?></td><td><?php echo htmlSelect( "newMonitor[Method]", $httpMethods, $monitor->Method() ); ?></td></tr>
|
||||||
<?php
|
<?php } else { ?>
|
||||||
} else {
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('RemoteMethod') ?></td><td><?php echo htmlSelect( "newMonitor[Method]", $rtspMethods, $monitor->Method() ); ?></td></tr>
|
<tr><td><?php echo translate('RemoteMethod') ?></td><td><?php echo htmlSelect( "newMonitor[Method]", $rtspMethods, $monitor->Method() ); ?></td></tr>
|
||||||
<?php
|
<?php } ?>
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('RemoteHostName') ?></td><td><input type="text" name="newMonitor[Host]" value="<?php echo validHtmlStr($monitor->Host) ?>" size="36"/></td></tr>
|
<tr><td><?php echo translate('RemoteHostName') ?></td><td><input type="text" name="newMonitor[Host]" value="<?php echo validHtmlStr($monitor->Host) ?>" size="36"/></td></tr>
|
||||||
<tr><td><?php echo translate('RemoteHostPort') ?></td><td><input type="text" name="newMonitor[Port]" value="<?php echo validHtmlStr($monitor->Port) ?>" size="6"/></td></tr>
|
<tr><td><?php echo translate('RemoteHostPort') ?></td><td><input type="text" name="newMonitor[Port]" value="<?php echo validHtmlStr($monitor->Port) ?>" size="6"/></td></tr>
|
||||||
<tr><td><?php echo translate('RemoteHostPath') ?></td><td><input type="text" name="newMonitor[Path]" value="<?php echo validHtmlStr($monitor->Path) ?>" size="36"/></td></tr>
|
<tr><td><?php echo translate('RemoteHostPath') ?></td><td><input type="text" name="newMonitor[Path]" value="<?php echo validHtmlStr($monitor->Path) ?>" size="36"/></td></tr>
|
||||||
<?php
|
<?php } elseif ( $monitor->Type == "File" ) { ?>
|
||||||
}
|
|
||||||
elseif ( $monitor->Type == "File" )
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('SourcePath') ?></td><td><input type="text" name="newMonitor[Path]" value="<?php echo validHtmlStr($monitor->Path) ?>" size="36"/></td></tr>
|
<tr><td><?php echo translate('SourcePath') ?></td><td><input type="text" name="newMonitor[Path]" value="<?php echo validHtmlStr($monitor->Path) ?>" size="36"/></td></tr>
|
||||||
<?php
|
<?php } elseif ( $monitor->Type == "cURL" ) { ?>
|
||||||
}
|
|
||||||
elseif ( $monitor->Type == "cURL" )
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo "URL" ?></td><td><input type="text" name="newMonitor[Path]" value="<?php echo validHtmlStr($monitor->Path) ?>" size="36"/></td></tr>
|
<tr><td><?php echo "URL" ?></td><td><input type="text" name="newMonitor[Path]" value="<?php echo validHtmlStr($monitor->Path) ?>" size="36"/></td></tr>
|
||||||
<tr><td><?php echo "Username" ?></td><td><input type="text" name="newMonitor[User]" value="<?php echo validHtmlStr($monitor->User) ?>" size="12"/></td></tr>
|
<tr><td><?php echo "Username" ?></td><td><input type="text" name="newMonitor[User]" value="<?php echo validHtmlStr($monitor->User) ?>" size="12"/></td></tr>
|
||||||
<tr><td><?php echo "Password" ?></td><td><input type="text" name="newMonitor[Pass]" value="<?php echo validHtmlStr($monitor->Pass) ?>" size="12"/></td></tr>
|
<tr><td><?php echo "Password" ?></td><td><input type="text" name="newMonitor[Pass]" value="<?php echo validHtmlStr($monitor->Pass) ?>" size="12"/></td></tr>
|
||||||
<?php
|
<?php } elseif ( $monitor->Type == "Ffmpeg" || $monitor->Type == "Libvlc") { ?>
|
||||||
}
|
|
||||||
elseif ( $monitor->Type == "Ffmpeg" || $monitor->Type == "Libvlc")
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('SourcePath') ?></td><td><input type="text" name="newMonitor[Path]" value="<?php echo validHtmlStr($monitor->Path) ?>" size="36"/></td></tr>
|
<tr><td><?php echo translate('SourcePath') ?></td><td><input type="text" name="newMonitor[Path]" value="<?php echo validHtmlStr($monitor->Path) ?>" size="36"/></td></tr>
|
||||||
<tr><td><?php echo translate('RemoteMethod') ?></td><td><?php echo htmlSelect( "newMonitor[Method]", $rtspMethods, $monitor->Method() ); ?></td></tr>
|
<tr><td><?php echo translate('RemoteMethod') ?> (<?php echo makePopupLink('?view=optionhelp&option=OPTIONS_RTSPTrans', 'zmOptionHelp', 'optionhelp', '?' ) ?>)</td><td><?php echo htmlSelect( "newMonitor[Method]", $rtspFFMpegMethods, $monitor->Method() ); ?></td></tr>
|
||||||
<tr><td><?php echo translate('Options') ?> (<?php echo makePopupLink( '?view=optionhelp&option=OPTIONS_'.strtoupper($monitor->Type), 'zmOptionHelp', 'optionhelp', '?' ) ?>)</td><td><input type="text" name="newMonitor[Options]" value="<?php echo validHtmlStr($monitor->Options) ?>" size="36"/></td></tr>
|
<tr><td><?php echo translate('Options') ?> (<?php echo makePopupLink( '?view=optionhelp&option=OPTIONS_'.strtoupper($monitor->Type), 'zmOptionHelp', 'optionhelp', '?' ) ?>)</td><td><input type="text" name="newMonitor[Options]" value="<?php echo validHtmlStr($monitor->Options) ?>" size="36"/></td></tr>
|
||||||
<?php
|
<?php } ?>
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr><td><?php echo translate('TargetColorspace') ?></td><td><select name="newMonitor[Colours]"><?php foreach ( $Colours as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Colours ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('TargetColorspace') ?></td><td><select name="newMonitor[Colours]"><?php foreach ( $Colours as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Colours ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<tr><td><?php echo translate('CaptureWidth') ?> (<?php echo translate('Pixels') ?>)</td><td><input type="text" name="newMonitor[Width]" value="<?php echo validHtmlStr($monitor->Width) ?>" size="4" onkeyup="updateMonitorDimensions(this);"/></td></tr>
|
<tr><td><?php echo translate('CaptureWidth') ?> (<?php echo translate('Pixels') ?>)</td><td><input type="text" name="newMonitor[Width]" value="<?php echo validHtmlStr($monitor->Width) ?>" size="4" onkeyup="updateMonitorDimensions(this);"/></td></tr>
|
||||||
<tr><td><?php echo translate('CaptureHeight') ?> (<?php echo translate('Pixels') ?>)</td><td><input type="text" name="newMonitor[Height]" value="<?php echo validHtmlStr($monitor->Height) ?>" size="4" onkeyup="updateMonitorDimensions(this);"/></td></tr>
|
<tr><td><?php echo translate('CaptureHeight') ?> (<?php echo translate('Pixels') ?>)</td><td><input type="text" name="newMonitor[Height]" value="<?php echo validHtmlStr($monitor->Height) ?>" size="4" onkeyup="updateMonitorDimensions(this);"/></td></tr>
|
||||||
<tr><td><?php echo translate('PreserveAspect') ?></td><td><input type="checkbox" name="preserveAspectRatio" value="1"/></td></tr>
|
<tr><td><?php echo translate('PreserveAspect') ?></td><td><input type="checkbox" name="preserveAspectRatio" value="1"/></td></tr>
|
||||||
<tr><td><?php echo translate('Orientation') ?></td><td><select name="newMonitor[Orientation]"><?php foreach ( $orientations as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Orientation ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('Orientation') ?></td><td><select name="newMonitor[Orientation]"><?php foreach ( $orientations as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Orientation ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<?php
|
<?php
|
||||||
if ( $monitor->Type == "Local" )
|
if ( $monitor->Type == "Local" ) {
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
<tr><td><?php echo translate('Deinterlacing') ?></td><td><select name="newMonitor[Deinterlacing]"><?php foreach ( $deinterlaceopts_v4l2 as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Deinterlacing ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
<tr><td><?php echo translate('Deinterlacing') ?></td><td><select name="newMonitor[Deinterlacing]"><?php foreach ( $deinterlaceopts_v4l2 as $name => $value ) { ?><option value="<?php echo $value ?>"<?php if ( $value == $monitor->Deinterlacing ) { ?> selected="selected"<?php } ?>><?php echo $name ?></option><?php } ?></select></td></tr>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -27,34 +27,55 @@ require_once( 'includes/Monitor.php' );
|
||||||
|
|
||||||
$groupSql = '';
|
$groupSql = '';
|
||||||
if ( !empty($_REQUEST['group']) ) {
|
if ( !empty($_REQUEST['group']) ) {
|
||||||
$row = dbFetchOne( 'select * from Groups where Id = ?', NULL, array($_REQUEST['group']) );
|
$row = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array($_REQUEST['group']) );
|
||||||
$sql = "select * from Monitors where Function != 'None' and find_in_set( Id, '".$row['MonitorIds']."' ) order by Sequence";
|
$sql = "SELECT * FROM Monitors WHERE Function != 'None' AND find_in_set( Id, '".$row['MonitorIds']."' ) ORDER BY Sequence";
|
||||||
} else {
|
} else {
|
||||||
$sql = "select * from Monitors where Function != 'None' order by Sequence";
|
$sql = "SELECT * FROM Monitors WHERE Function != 'None' ORDER BY Sequence";
|
||||||
}
|
}
|
||||||
|
|
||||||
$showControl = false;
|
$showControl = false;
|
||||||
$monitors = array();
|
$monitors = array();
|
||||||
|
$widths = array(
|
||||||
|
'' => 'auto',
|
||||||
|
160 => 160,
|
||||||
|
320 => 320,
|
||||||
|
352 => 352,
|
||||||
|
640 => 640,
|
||||||
|
1280 => 1280 );
|
||||||
|
$heights = array(
|
||||||
|
'' => 'auto',
|
||||||
|
240 => 240,
|
||||||
|
480 => 480,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach( dbFetchAll( $sql ) as $row ) {
|
foreach( dbFetchAll( $sql ) as $row ) {
|
||||||
if ( !visibleMonitor( $row['Id'] ) ) {
|
if ( !visibleMonitor( $row['Id'] ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $_REQUEST['scale'] ) )
|
$scale = null;
|
||||||
$scale = validInt($_REQUEST['scale']);
|
if ( isset( $_REQUEST['scale'] ) )
|
||||||
else if ( isset( $_COOKIE['zmMontageScale'] ) )
|
$scale = validInt($_REQUEST['scale']);
|
||||||
$scale = $_COOKIE['zmMontageScale'];
|
else if ( isset( $_COOKIE['zmMontageScale'] ) )
|
||||||
else
|
$scale = $_COOKIE['zmMontageScale'];
|
||||||
$scale = reScale( SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
#else
|
||||||
|
#$scale = reScale( SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||||
|
|
||||||
$row['Scale'] = $scale;
|
$row['Scale'] = $scale;
|
||||||
$row['PopupScale'] = reScale( SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
$row['PopupScale'] = reScale( SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||||
|
|
||||||
if ( ZM_OPT_CONTROL && $row['ControlId'] )
|
if ( ZM_OPT_CONTROL && $row['ControlId'] && $row['Controllable'] )
|
||||||
$showControl = true;
|
$showControl = true;
|
||||||
$row['connKey'] = generateConnKey();
|
$row['connKey'] = generateConnKey();
|
||||||
$monitors[] = new Monitor( $row );
|
$monitors[] = new Monitor( $row );
|
||||||
|
if ( ! isset( $widths[$row['Width']] ) ) {
|
||||||
|
$widths[$row['Width']] = $row['Width'];
|
||||||
|
}
|
||||||
|
if ( ! isset( $heights[$row['Height']] ) ) {
|
||||||
|
$heights[$row['Height']] = $row['Height'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$focusWindow = true;
|
$focusWindow = true;
|
||||||
|
@ -70,6 +91,18 @@ $layouts = array(
|
||||||
if ( isset($_COOKIE['zmMontageLayout']) )
|
if ( isset($_COOKIE['zmMontageLayout']) )
|
||||||
$layout = $_COOKIE['zmMontageLayout'];
|
$layout = $_COOKIE['zmMontageLayout'];
|
||||||
|
|
||||||
|
$options = array();
|
||||||
|
if ( isset($_COOKIE['zmMontageWidth']) and $_COOKIE['zmMontageWidth'] )
|
||||||
|
$options['width'] = $_COOKIE['zmMontageWidth'];
|
||||||
|
else
|
||||||
|
$options['width'] = '';
|
||||||
|
if ( isset($_COOKIE['zmMontageHeight']) and $_COOKIE['zmMontageHeight'] )
|
||||||
|
$options['height'] = $_COOKIE['zmMontageHeight'];
|
||||||
|
else
|
||||||
|
$options['height'] = '';
|
||||||
|
if ( $scale )
|
||||||
|
$options['scale'] = $scale;
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, translate('Montage') );
|
xhtmlHeaders(__FILE__, translate('Montage') );
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
|
@ -87,8 +120,10 @@ if ( $showControl ) {
|
||||||
</div>
|
</div>
|
||||||
<h2><?php echo translate('Montage') ?></h2>
|
<h2><?php echo translate('Montage') ?></h2>
|
||||||
<div id="headerControl">
|
<div id="headerControl">
|
||||||
<span id="scaleControl"><label><?php echo translate('Scale') ?></label>: <?php echo buildSelect( 'scale', $scales, 'changeScale(this);' ); ?></span>
|
<span id="widthControl"><label><?php echo translate('Width') ?>:</label><?php echo htmlSelect( 'width', $widths, $options['width'], 'changeWidth(this);' ); ?></span>
|
||||||
<label for="layout"><?php echo translate('Layout') ?>:</label><?php echo buildSelect( 'layout', $layouts, 'selectLayout(this);' )?>
|
<span id="heightControl"><label><?php echo translate('Height') ?>:</label><?php echo htmlSelect( 'height', $heights, $options['height'], 'changeHeight(this);' ); ?></span>
|
||||||
|
<span id="scaleControl"><label><?php echo translate('Scale') ?>:</label><?php echo htmlSelect( 'scale', $scales, $scale, 'changeScale(this);' ); ?></span>
|
||||||
|
<span id="layoutControl"><label for="layout"><?php echo translate('Layout') ?>:</label><?php echo htmlSelect( 'layout', $layouts, $layout, 'selectLayout(this);' )?></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
@ -100,7 +135,7 @@ foreach ( $monitors as $monitor ) {
|
||||||
<div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>">
|
<div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>">
|
||||||
<div id="monitor<?php echo $monitor->Id() ?>" class="monitor idle">
|
<div id="monitor<?php echo $monitor->Id() ?>" class="monitor idle">
|
||||||
<div id="imageFeed<?php echo $monitor->Id() ?>" class="imageFeed" onclick="createPopup( '?view=watch&mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );">
|
<div id="imageFeed<?php echo $monitor->Id() ?>" class="imageFeed" onclick="createPopup( '?view=watch&mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );">
|
||||||
<?php echo getStreamHTML( $monitor, $monitor->Scale() ); ?>
|
<?php echo getStreamHTML( $monitor, $options ); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
if ( !ZM_WEB_COMPACT_MONTAGE ) {
|
if ( !ZM_WEB_COMPACT_MONTAGE ) {
|
||||||
|
|
|
@ -94,39 +94,36 @@
|
||||||
// - Add auth tokens to zms call for those using authorization
|
// - Add auth tokens to zms call for those using authorization
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canView( 'Events' ) )
|
if ( !canView( 'Events' ) ) {
|
||||||
{
|
$view = 'error';
|
||||||
$view = "error";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once( 'includes/Monitor.php' );
|
require_once( 'includes/Monitor.php' );
|
||||||
|
|
||||||
if ( !empty($_REQUEST['group']) )
|
# FIXME THere is no way to select group at this time.
|
||||||
{
|
if ( !empty($_REQUEST['group']) ) {
|
||||||
$group = $_REQUEST['group'];
|
$group = $_REQUEST['group'];
|
||||||
$row = dbFetchOne( 'select * from Groups where Id = ?', NULL, array($_REQUEST['group']) );
|
$row = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array($_REQUEST['group']) );
|
||||||
$monitorsSql = "select * from Monitors where Function != 'None' and find_in_set( Id, '".$row['MonitorIds']."' ) ";
|
$monitorsSql = "SELECT * FROM Monitors WHERE Function != 'None' AND find_in_set( Id, '".$row['MonitorIds']."' ) ";
|
||||||
}
|
} else {
|
||||||
else
|
$monitorsSql = "SELECT * FROM Monitors WHERE 1>0";
|
||||||
{
|
$group = '';
|
||||||
$monitorsSql = "select * from Monitors ";
|
|
||||||
$group = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that this finds incomplete events as well, and any frame records written, but still cannot "see" to the end frame
|
// Note that this finds incomplete events as well, and any frame records written, but still cannot "see" to the end frame
|
||||||
// if the bulk record has not been written - to be able to include more current frames reduce bulk frame sizes (event size can be large)
|
// if the bulk record has not been written - to be able to include more current frames reduce bulk frame sizes (event size can be large)
|
||||||
// Note we round up just a bit on the end time as otherwise you get gaps, like 59.78 to 00 in the next second, which can give blank frames when moved through slowly.
|
// Note we round up just a bit on the end time as otherwise you get gaps, like 59.78 to 00 in the next second, which can give blank frames when moved through slowly.
|
||||||
|
|
||||||
$eventsSql = "
|
$eventsSql = '
|
||||||
select E.Id,E.Name,E.StorageId,UNIX_TIMESTAMP(E.StartTime) as StartTimeSecs,
|
SELECT E.Id,E.Name,E.StorageId,UNIX_TIMESTAMP(E.StartTime) AS StartTimeSecs,
|
||||||
case when E.EndTime is null then (Select UNIX_TIMESTAMP(DATE_ADD(E.StartTime, Interval max(Delta)+0.5 Second)) from Frames F where F.EventId=E.Id)
|
CASE WHEN E.EndTime IS NULL THEN (SELECT UNIX_TIMESTAMP(DATE_ADD(E.StartTime, Interval max(Delta)+0.5 Second)) FROM Frames F WHERE F.EventId=E.Id)
|
||||||
else UNIX_TIMESTAMP(E.EndTime)
|
ELSE UNIX_TIMESTAMP(E.EndTime)
|
||||||
end as CalcEndTimeSecs, E.Length,
|
END AS CalcEndTimeSecs, E.Length,
|
||||||
case when E.Frames is null then (Select count(*) from Frames F where F.EventId=E.Id) else E.Frames end as Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId
|
CASE WHEN E.Frames IS NULL THEN (Select count(*) FROM Frames F WHERE F.EventId=E.Id) ELSE E.Frames END AS Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId
|
||||||
from Events as E
|
FROM Events AS E
|
||||||
inner join Monitors as M on (E.MonitorId = M.Id)
|
INNER JOIN Monitors AS M ON (E.MonitorId = M.Id)
|
||||||
where not isnull(E.Frames) and not isnull(StartTime) ";
|
WHERE NOT isnull(E.Frames) AND NOT isnull(StartTime)';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,21 +134,20 @@ $eventsSql = "
|
||||||
// where not isnull(E.Frames) and not isnull(StartTime) ";
|
// where not isnull(E.Frames) and not isnull(StartTime) ";
|
||||||
|
|
||||||
// Note that the delta value seems more accurate than the time stamp for some reason.
|
// Note that the delta value seems more accurate than the time stamp for some reason.
|
||||||
$frameSql = "
|
$frameSql = '
|
||||||
select E.Id as eId, E.MonitorId, UNIX_TIMESTAMP(DATE_ADD(E.StartTime, Interval Delta Second)) as TimeStampSecs, max(F.Score) as Score
|
SELECT E.Id AS eId, E.MonitorId, UNIX_TIMESTAMP(DATE_ADD(E.StartTime, Interval Delta Second)) AS TimeStampSecs, max(F.Score) AS Score
|
||||||
from Events as E
|
FROM Events AS E
|
||||||
inner join Frames as F on (F.EventId = E.Id)
|
INNER JOIN Frames AS F ON (F.EventId = E.Id)
|
||||||
where not isnull(StartTime) and F.Score>0 ";
|
WHERE NOT isnull(StartTime) AND F.Score>0';
|
||||||
|
|
||||||
// This program only calls itself with the time range involved -- it does all monitors (the user can see, in the called group) all the time
|
// This program only calls itself with the time range involved -- it does all monitors (the user can see, in the called group) all the time
|
||||||
|
|
||||||
if ( !empty($user['MonitorIds']) )
|
if ( ! empty( $user['MonitorIds'] ) ) {
|
||||||
{
|
|
||||||
$monFilterSql = ' AND M.Id IN ('.$user['MonitorIds'].')';
|
$monFilterSql = ' AND M.Id IN ('.$user['MonitorIds'].')';
|
||||||
|
|
||||||
$eventsSql .= $monFilterSql;
|
$eventsSql .= $monFilterSql;
|
||||||
$monitorsSQL .= $monFilterSql;
|
$monitorsSql .= ' AND Id IN ('.$user['MonitorIds'].')';
|
||||||
$frameSql .= ' AND e.MonitorId IN ('.$user['MonitorIds'].')';
|
$frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse input parameters -- note for future, validate/clean up better in case we don't get called from self.
|
// Parse input parameters -- note for future, validate/clean up better in case we don't get called from self.
|
||||||
|
@ -160,87 +156,82 @@ if ( !empty($user['MonitorIds']) )
|
||||||
// The default (nothing at all specified) is for 1 hour so we do not read the whole database
|
// The default (nothing at all specified) is for 1 hour so we do not read the whole database
|
||||||
|
|
||||||
|
|
||||||
if ( !isset($_REQUEST['minTime']) && !isset($_REQUEST['maxTime']) )
|
if ( !isset($_REQUEST['minTime']) && !isset($_REQUEST['maxTime']) ) {
|
||||||
{
|
$maxTime = strftime("%c",time());
|
||||||
$maxTime=strftime("%c",time());
|
$minTime = strftime("%c",time() - 3600);
|
||||||
$minTime=strftime("%c",time() - 3600);
|
|
||||||
}
|
}
|
||||||
if ( isset($_REQUEST['minTime']) )
|
if ( isset($_REQUEST['minTime']) )
|
||||||
$minTime = validHtmlStr($_REQUEST['minTime']);
|
$minTime = validHtmlStr($_REQUEST['minTime']);
|
||||||
|
|
||||||
if ( isset($_REQUEST['maxTime']) )
|
if ( isset($_REQUEST['maxTime']) )
|
||||||
$maxTime = validHtmlStr($_REQUEST['maxTime']);
|
$maxTime = validHtmlStr($_REQUEST['maxTime']);
|
||||||
|
|
||||||
// AS a special case a "all" is passed in as an exterme interval - if so , clear them here and let the database query find them
|
// AS a special case a "all" is passed in as an exterme interval - if so , clear them here and let the database query find them
|
||||||
|
|
||||||
if ( (strtotime($maxTime) - strtotime($minTime))/(365*24*3600) > 30 ) // test years
|
if ( (strtotime($maxTime) - strtotime($minTime))/(365*24*3600) > 30 ) {
|
||||||
{
|
// test years
|
||||||
$minTime=null;
|
$minTime = null;
|
||||||
$maxTime=null;
|
$maxTime = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fitMode=1;
|
$fitMode=1;
|
||||||
if (isset($_REQUEST['fit']) && $_REQUEST['fit']=='0' )
|
if (isset($_REQUEST['fit']) && $_REQUEST['fit']=='0' )
|
||||||
$fitMode=0;
|
$fitMode = 0;
|
||||||
|
|
||||||
if ( isset($_REQUEST['scale']) )
|
if ( isset($_REQUEST['scale']) )
|
||||||
$defaultScale=validHtmlStr($_REQUEST['scale']);
|
$defaultScale = validHtmlStr($_REQUEST['scale']);
|
||||||
else
|
else
|
||||||
$defaultScale=1;
|
$defaultScale = 1;
|
||||||
|
|
||||||
$speeds=[0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.5, 2, 3, 5, 10, 20, 50];
|
$speeds=[0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.5, 2, 3, 5, 10, 20, 50];
|
||||||
|
|
||||||
if (isset($_REQUEST['speed']) )
|
if (isset($_REQUEST['speed']) )
|
||||||
$defaultSpeed=validHtmlStr($_REQUEST['speed']);
|
$defaultSpeed = validHtmlStr($_REQUEST['speed']);
|
||||||
else
|
else
|
||||||
$defaultSpeed=1;
|
$defaultSpeed = 1;
|
||||||
|
|
||||||
$speedIndex=5; // default to 1x
|
$speedIndex=5; // default to 1x
|
||||||
for ($i=0; $i<count($speeds); $i++)
|
for ($i=0; $i<count($speeds); $i++) {
|
||||||
if($speeds[$i]==$defaultSpeed)
|
if($speeds[$i]==$defaultSpeed) {
|
||||||
{
|
$speedIndex=$i;
|
||||||
$speedIndex=$i;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['current']) )
|
if (isset($_REQUEST['current']) )
|
||||||
$defaultCurrentTime=validHtmlStr($_REQUEST['current']);
|
$defaultCurrentTime=validHtmlStr($_REQUEST['current']);
|
||||||
|
|
||||||
|
|
||||||
$initialModeIsLive=1;
|
$initialModeIsLive=1;
|
||||||
if(isset($_REQUEST['live']) && $_REQUEST['live']=='0' )
|
if(isset($_REQUEST['live']) && $_REQUEST['live']=='0' )
|
||||||
$initialModeIsLive=0;
|
$initialModeIsLive=0;
|
||||||
|
|
||||||
$initialDisplayInterval=1000;
|
$initialDisplayInterval=1000;
|
||||||
if(isset($_REQUEST['displayinterval']))
|
if(isset($_REQUEST['displayinterval']))
|
||||||
$initialDisplayInterval=validHtmlStr($_REQUEST['displayinterval']);
|
$initialDisplayInterval=validHtmlStr($_REQUEST['displayinterval']);
|
||||||
|
|
||||||
$eventsSql .= "group by E.Id,E.Name,E.StartTime,E.Length,E.Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId ";
|
$eventsSql .= ' GROUP BY E.Id,E.Name,E.StartTime,E.Length,E.Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId';
|
||||||
|
|
||||||
if( isset($minTime) && isset($maxTime) )
|
if( isset($minTime) && isset($maxTime) ) {
|
||||||
{
|
$minTimeSecs = strtotime($minTime);
|
||||||
$minTimeSecs = strtotime($minTime);
|
$maxTimeSecs = strtotime($maxTime);
|
||||||
$maxTimeSecs = strtotime($maxTime);
|
$eventsSql .= " HAVING CalcEndTimeSecs > '" . $minTimeSecs . "' AND StartTimeSecs < '" . $maxTimeSecs . "'";
|
||||||
$eventsSql .= "having CalcEndTimeSecs > '" . $minTimeSecs . "' and StartTimeSecs < '" . $maxTimeSecs . "'";
|
$frameSql .= " AND TimeStamp > '" . $minTime . "' AND TimeStamp < '" . $maxTime . "'";
|
||||||
$frameSql .= "and TimeStamp > '" . $minTime . "' and TimeStamp < '" . $maxTime . "'";
|
|
||||||
}
|
}
|
||||||
$frameSql .= "group by E.Id, E.MonitorId, F.TimeStamp, F.Delta order by E.MonitorId, F.TimeStamp asc";
|
$frameSql .= ' GROUP BY E.Id, E.MonitorId, F.TimeStamp, F.Delta ORDER BY E.MonitorId, F.TimeStamp ASC';
|
||||||
|
|
||||||
// This loads all monitors the user can see - even if we don't have data for one we still show all for switch to live.
|
// This loads all monitors the user can see - even if we don't have data for one we still show all for switch to live.
|
||||||
|
|
||||||
$monitors = array();
|
$monitors = array();
|
||||||
$monitorsSql .= ' ORDER BY Sequence ASC ';
|
$monitorsSql .= ' ORDER BY Sequence ASC';
|
||||||
$index=0;
|
$index=0;
|
||||||
foreach( dbFetchAll( $monitorsSql ) as $row )
|
foreach( dbFetchAll( $monitorsSql ) as $row ) {
|
||||||
{
|
$monitors[$index] = $row;
|
||||||
$monitors[$index] = $row;
|
$index = $index + 1;
|
||||||
$index = $index + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are zoom ranges per visible monitor
|
// These are zoom ranges per visible monitor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, translate('MontageReview') );
|
xhtmlHeaders(__FILE__, translate('MontageReview') );
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
|
@ -256,29 +247,29 @@ input[type=range]::-ms-tooltip {
|
||||||
</div>
|
</div>
|
||||||
<h2><?php echo translate('MontageReview') ?></h2>
|
<h2><?php echo translate('MontageReview') ?></h2>
|
||||||
</div>
|
</div>
|
||||||
<div id="ScaleDiv" style="display: inline-flex; border: 1px solid black;">
|
<div id="ScaleDiv">
|
||||||
<label style="margin:5px;" for="scaleslider"><?php echo translate('Scale')?></label>
|
<label for="scaleslider"><?php echo translate('Scale')?></label>
|
||||||
<input id=scaleslider type=range min=0.1 max=1.0 value=<?php echo $defaultScale ?> step=0.10 width=20% onchange='setScale(this.value)' oninput='showScale(this.value)'/>
|
<input id="scaleslider" type="range" min="0.1" max="1.0" value="<?php echo $defaultScale ?>" step="0.10" onchange="setScale(this.value);" oninput="showScale(this.value);"/>
|
||||||
<span style='margin:5px;' id=scaleslideroutput><?php echo number_format((float)$defaultScale,2,'.','')?> x</span>
|
<span id="scaleslideroutput"><?php echo number_format((float)$defaultScale,2,'.','')?> x</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="SpeedDiv" style='display: inline-flex; border: 1px solid black;'>
|
<div id="SpeedDiv">
|
||||||
<label style='margin:5px;' for=speedslider><?php echo translate('Speed') ?></label>
|
<label for="speedslider"><?php echo translate('Speed') ?></label>
|
||||||
<input id=speedslider type=range min=0 max=<?php echo count($speeds)-1?> value=<?php echo $speedIndex ?> step=1 wdth=20% onchange='setSpeed(this.value)' oninput='showSpeed(this.value)'/>
|
<input id="speedslider" type="range" min="0" max="<?php echo count($speeds)-1?>" value="<?php echo $speedIndex ?>" step="1" onchange="setSpeed(this.value);" oninput="showSpeed(this.value);"/>
|
||||||
<span style='margin:5px;' id=speedslideroutput><?php echo $speeds[$speedIndex] ?> fps</span>
|
<span id="speedslideroutput"><?php echo $speeds[$speedIndex] ?> fps</span>
|
||||||
</div>
|
</div>
|
||||||
<div style='display: inline-flex; border: 1px solid black; flex-flow: row wrap;'>
|
<div style="display: inline-flex; border: 1px solid black; flex-flow: row wrap;">
|
||||||
<button type="button" id=panleft onclick='panleft() '>< <?php echo translate('Pan') ?></button>
|
<button type="button" id="panleft" onclick="panleft();" >< <?php echo translate('Pan') ?></button>
|
||||||
<button type="button" id=zoomin onclick='zoomin() '><?php echo translate('In +') ?></button>
|
<button type="button" id="zoomin" onclick="zoomin();" ><?php echo translate('In +') ?></button>
|
||||||
<button type="button" id=zoomout onclick='zoomout() '><?php echo translate('Out -') ?></button>
|
<button type="button" id="zoomout" onclick="zoomout();" ><?php echo translate('Out -') ?></button>
|
||||||
<button type="button" id=lasteight onclick='lastEight() '><?php echo translate('8 Hour') ?></button>
|
<button type="button" id="lasteight" onclick="lastEight();" ><?php echo translate('8 Hour') ?></button>
|
||||||
<button type="button" id=lasthour onclick='lastHour() '><?php echo translate('1 Hour') ?></button>
|
<button type="button" id="lasthour" onclick="lastHour();" ><?php echo translate('1 Hour') ?></button>
|
||||||
<button type="button" id=allof onclick='allof() '><?php echo translate('All Events') ?></button>
|
<button type="button" id="allof" onclick="allof();" ><?php echo translate('All Events') ?></button>
|
||||||
<button type="button" id=live onclick='setLive(1-liveMode)'><?php echo translate('Live') ?></button>
|
<button type="button" id="live" onclick="setLive(1-liveMode);"><?php echo translate('Live') ?></button>
|
||||||
<button type="button" id=fit onclick='setFit(1-fitMode) '><?php echo translate('Fit') ?></button>
|
<button type="button" id="fit" onclick="setFit(1-fitMode);" ><?php echo translate('Fit') ?></button>
|
||||||
<button type="button" id=panright onclick='panright() '><?php echo translate('Pan') ?> ></button>
|
<button type="button" id="panright" onclick="panright();" ><?php echo translate('Pan') ?> ></button>
|
||||||
</div>
|
</div>
|
||||||
<div id="timelinediv" style="position:relative; width:93%;">
|
<div id="timelinediv">
|
||||||
<canvas id="timeline" style="border:1px solid;" onmousemove="mmove(event);" ontouchmove="tmove(event);" onmousedown="mdown(event);" onmouseup="mup(event);" onmouseout="mout(event);"></canvas>
|
<canvas id="timeline" onmousemove="mmove(event);" ontouchmove="tmove(event);" onmousedown="mdown(event);" onmouseup="mup(event);" onmouseout="mout(event);"></canvas>
|
||||||
<span id="scrubleft"></span>
|
<span id="scrubleft"></span>
|
||||||
<span id="scrubright"></span>
|
<span id="scrubright"></span>
|
||||||
<span id="scruboutput"></span>
|
<span id="scruboutput"></span>
|
||||||
|
@ -286,14 +277,13 @@ input[type=range]::-ms-tooltip {
|
||||||
<?php
|
<?php
|
||||||
// Monitor images - these had to be loaded after the monitors used were determined (after loading events)
|
// Monitor images - these had to be loaded after the monitors used were determined (after loading events)
|
||||||
|
|
||||||
echo "<div id='monitors' style='position:relative; background-color:black;' width='100%' height='100%'>\n";
|
echo '<div id="monitors">';
|
||||||
foreach ($monitors as $m) {
|
foreach ($monitors as $m) {
|
||||||
echo "<canvas width='" . $m['Width'] * $defaultScale . "px' height='" . $m['Height'] * $defaultScale . "px' id='Monitor" . $m['Id'] . "' style='border:3px solid " . $m['WebColour'] . "' onclick='clickMonitor(event," . $m['Id'] . ")'>No Canvas Support!!</canvas>\n";
|
echo '<canvas width="' . $m['Width'] * $defaultScale . 'px" height="' . $m['Height'] * $defaultScale . 'px" id="Monitor' . $m['Id'] . '" style="border:3px solid ' . $m['WebColour'] . '" onclick="clickMonitor(event,' . $m['Id'] . ')">No Canvas Support!!</canvas>';
|
||||||
}
|
}
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
echo "<p id='fps'>evaluating fps</p>\n";
|
echo "<p id=\"fps\">evaluating fps</p>\n";
|
||||||
echo "<script>\n";
|
echo "<script type=\"text/javascript\">\n";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
var currentScale=<?php echo $defaultScale?>;
|
var currentScale=<?php echo $defaultScale?>;
|
||||||
|
@ -329,19 +319,22 @@ $index=0;
|
||||||
$anyAlarms=false;
|
$anyAlarms=false;
|
||||||
|
|
||||||
foreach( dbFetchAll( $eventsSql ) as $event ) {
|
foreach( dbFetchAll( $eventsSql ) as $event ) {
|
||||||
if( $minTimeSecs > $event['StartTimeSecs']) $minTimeSecs=$event['StartTimeSecs'];
|
if( $minTimeSecs > $event['StartTimeSecs']) $minTimeSecs = $event['StartTimeSecs'];
|
||||||
if( $maxTimeSecs < $event['CalcEndTimeSecs']) $maxTimeSecs=$event['CalcEndTimeSecs'];
|
if( $maxTimeSecs < $event['CalcEndTimeSecs']) $maxTimeSecs = $event['CalcEndTimeSecs'];
|
||||||
echo "eMonId[$index]=" . $event['MonitorId'] . "; eId[$index]=" . $event['Id'] . "; ";
|
echo "eMonId[$index]=" . $event['MonitorId'] . ";
|
||||||
echo "eStartSecs[$index]=" . $event['StartTimeSecs'] . "; eEndSecs[$index]=" . $event['CalcEndTimeSecs'] . "; ";
|
eId[$index]=" . $event['Id'] . ";
|
||||||
echo "eventFrames[$index]=" . $event['Frames'] . "; ";
|
eStartSecs[$index]=" . $event['StartTimeSecs'] . ";
|
||||||
|
eEndSecs[$index]=" . $event['CalcEndTimeSecs'] . ";
|
||||||
|
eventFrames[$index]=" . $event['Frames'] . "; ";
|
||||||
|
|
||||||
|
// NO GOOD, need to use view=image
|
||||||
if ( ZM_USE_DEEP_STORAGE )
|
if ( ZM_USE_DEEP_STORAGE )
|
||||||
echo "ePath[$index] = \"events/" . $event['MonitorId'] . "/" . strftime("%y/%m/%d/%H/%M/%S", $event['StartTimeSecs']) . "/\";" ;
|
echo "ePath[$index] = \"events/" . $event['MonitorId'] . "/" . strftime("%y/%m/%d/%H/%M/%S", $event['StartTimeSecs']) . "/\";" ;
|
||||||
else
|
else
|
||||||
echo "ePath[$index] = \"events/" . $event['MonitorId'] . "/" . $event['Id'] . "/\";" ;
|
echo "ePath[$index] = \"events/" . $event['MonitorId'] . "/" . $event['Id'] . "/\";" ;
|
||||||
$index=$index+1;
|
$index = $index + 1;
|
||||||
if($event['MaxScore']>0)
|
if($event['MaxScore']>0)
|
||||||
$anyAlarms=true;
|
$anyAlarms = true;
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,13 +460,13 @@ echo "var minTimeSecs=" . $minTimeSecs . ";\n";
|
||||||
echo "var maxTimeSecs=" . $maxTimeSecs . ";\n";
|
echo "var maxTimeSecs=" . $maxTimeSecs . ";\n";
|
||||||
echo "var rangeTimeSecs=" . ( $maxTimeSecs - $minTimeSecs + 1) . ";\n";
|
echo "var rangeTimeSecs=" . ( $maxTimeSecs - $minTimeSecs + 1) . ";\n";
|
||||||
if(isset($defaultCurrentTime))
|
if(isset($defaultCurrentTime))
|
||||||
echo "var currentTimeSecs=" . strtotime($defaultCurrentTime) . ";\n";
|
echo "var currentTimeSecs=" . strtotime($defaultCurrentTime) . ";\n";
|
||||||
else
|
else
|
||||||
echo "var currentTimeSecs=" . ($minTimeSecs + $maxTimeSecs)/2 . ";\n";
|
echo "var currentTimeSecs=" . ($minTimeSecs + $maxTimeSecs)/2 . ";\n";
|
||||||
|
|
||||||
echo "var speeds=[";
|
echo "var speeds=[";
|
||||||
for ($i=0; $i<count($speeds); $i++)
|
for ($i=0; $i<count($speeds); $i++)
|
||||||
echo (($i>0)?", ":"") . $speeds[$i];
|
echo (($i>0)?", ":"") . $speeds[$i];
|
||||||
echo "];\n";
|
echo "];\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -485,24 +478,23 @@ var ctx=canvas.getContext('2d');
|
||||||
var underSlider; // use this to hold what is hidden by the slider
|
var underSlider; // use this to hold what is hidden by the slider
|
||||||
var underSliderX; // Where the above was taken from (left side, Y is zero)
|
var underSliderX; // Where the above was taken from (left side, Y is zero)
|
||||||
|
|
||||||
function evaluateLoadTimes()
|
function evaluateLoadTimes() {
|
||||||
{ // Only consider it a completed event if we load ALL monitors, then zero all and start again
|
// Only consider it a completed event if we load ALL monitors, then zero all and start again
|
||||||
var start=0;
|
var start=0;
|
||||||
var end=0;
|
var end=0;
|
||||||
if(liveMode!=1 && currentSpeed==0) return; // don't evaluate when we are not moving as we can do nothing really fast.
|
if(liveMode!=1 && currentSpeed==0) return; // don't evaluate when we are not moving as we can do nothing really fast.
|
||||||
for(var i=0; i<monitorIndex.length; i++)
|
for(var i=0; i<monitorIndex.length; i++) {
|
||||||
if( monitorName[i]>"")
|
if( monitorName[i]>"") {
|
||||||
{
|
|
||||||
if( monitorLoadEndTimems[i]==0) return; // if we have a monitor with no time yet just wait
|
if( monitorLoadEndTimems[i]==0) return; // if we have a monitor with no time yet just wait
|
||||||
if( start == 0 || start > monitorLoadStartTimems[i] ) start = monitorLoadStartTimems[i];
|
if( start == 0 || start > monitorLoadStartTimems[i] ) start = monitorLoadStartTimems[i];
|
||||||
if( end == 0 || end < monitorLoadEndTimems[i] ) end = monitorLoadEndTimems[i];
|
if( end == 0 || end < monitorLoadEndTimems[i] ) end = monitorLoadEndTimems[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(start==0 || end==0) return; // we really should not get here
|
if(start==0 || end==0) return; // we really should not get here
|
||||||
for(var i=0; i<numMonitors; i++)
|
for(var i=0; i<numMonitors; i++) {
|
||||||
{
|
monitorLoadStartTimems[monitorPtr[i]]=0;
|
||||||
monitorLoadStartTimems[monitorPtr[i]]=0;
|
monitorLoadEndTimems[monitorPtr[i]]=0;
|
||||||
monitorLoadEndTimems[monitorPtr[i]]=0;
|
}
|
||||||
}
|
|
||||||
freeTimeLastIntervals[imageLoadTimesEvaluated++] = 1 - ((end - start)/currentDisplayInterval);
|
freeTimeLastIntervals[imageLoadTimesEvaluated++] = 1 - ((end - start)/currentDisplayInterval);
|
||||||
if( imageLoadTimesEvaluated < imageLoadTimesNeeded ) return;
|
if( imageLoadTimesEvaluated < imageLoadTimesNeeded ) return;
|
||||||
var avgFrac=0;
|
var avgFrac=0;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canView( 'Events' ) ) {
|
if ( !canView( 'Events' ) ) {
|
||||||
$view = "error";
|
$view = 'error';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ foreach ( getSkinIncludes( 'includes/timeline_functions.php' ) as $includeFile )
|
||||||
//
|
//
|
||||||
|
|
||||||
// When the chart range is years
|
// When the chart range is years
|
||||||
define( "STRF_TL_AXIS_RANGE_YEAR1", "%b %Y" );
|
define( 'STRF_TL_AXIS_RANGE_YEAR1', '%b %Y' );
|
||||||
define( "STRF_TL_AXIS_RANGE_YEAR2", STRF_TL_AXIS_RANGE_YEAR1 );
|
define( 'STRF_TL_AXIS_RANGE_YEAR2', STRF_TL_AXIS_RANGE_YEAR1 );
|
||||||
|
|
||||||
// When the chart range is months
|
// When the chart range is months
|
||||||
define( "STRF_TL_AXIS_RANGE_MONTH1", "%b" );
|
define( "STRF_TL_AXIS_RANGE_MONTH1", "%b" );
|
||||||
|
@ -140,8 +140,8 @@ foreach( dbFetchAll( $monitorsSql ) as $row ) {
|
||||||
$monitors[$row['Id']] = $row;
|
$monitors[$row['Id']] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rangeSql = "select min(E.StartTime) as MinTime, max(E.EndTime) as MaxTime from Events as E inner join Monitors as M on (E.MonitorId = M.Id) where not isnull(E.StartTime) and not isnull(E.EndTime)";
|
$rangeSql = 'select min(E.StartTime) as MinTime, max(E.EndTime) as MaxTime from Events as E inner join Monitors as M on (E.MonitorId = M.Id) where not isnull(E.StartTime) and not isnull(E.EndTime)';
|
||||||
$eventsSql = "select E.Id,E.Name,E.StartTime,E.EndTime,E.Length,E.Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId from Events as E inner join Monitors as M on (E.MonitorId = M.Id) where not isnull(StartTime)";
|
$eventsSql = 'select E.* from Events as E inner join Monitors as M on (E.MonitorId = M.Id) where not isnull(StartTime)';
|
||||||
|
|
||||||
if ( !empty($user['MonitorIds']) ) {
|
if ( !empty($user['MonitorIds']) ) {
|
||||||
$monFilterSql = ' AND M.Id IN ('.$user['MonitorIds'].')';
|
$monFilterSql = ' AND M.Id IN ('.$user['MonitorIds'].')';
|
||||||
|
@ -706,10 +706,12 @@ xhtmlHeaders(__FILE__, translate('Timeline') );
|
||||||
//due to chrome bug, has to enable https://code.google.com/p/chromium/issues/detail?id=472300
|
//due to chrome bug, has to enable https://code.google.com/p/chromium/issues/detail?id=472300
|
||||||
//crossorigin has to be added below to make caption work in chrome
|
//crossorigin has to be added below to make caption work in chrome
|
||||||
?>
|
?>
|
||||||
|
<!--
|
||||||
<video id="preview" width="100%" controls crossorigin="anonymous">
|
<video id="preview" width="100%" controls crossorigin="anonymous">
|
||||||
<source src="" type="video/mp4">
|
<source src="" type="video/mp4">
|
||||||
Your browser does not support the video tag.
|
Your browser does not support the video tag.
|
||||||
</video>
|
</video>
|
||||||
|
o-->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -70,7 +70,7 @@ if ( canView( 'Control' ) && $monitor->Type() == 'Local' ) {
|
||||||
<div id="scaleControl"><?php echo translate('Scale') ?>: <?php echo buildSelect( "scale", $scales, "changeScale( this );" ); ?></div>
|
<div id="scaleControl"><?php echo translate('Scale') ?>: <?php echo buildSelect( "scale", $scales, "changeScale( this );" ); ?></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="imageFeed"><?php echo getStreamHTML( $monitor, $scale ); ?></div>
|
<div id="imageFeed"><?php echo getStreamHTML( $monitor, array('scale'=>$scale) ); ?></div>
|
||||||
<div id="monitorStatus">
|
<div id="monitorStatus">
|
||||||
<?php if ( canEdit( 'Monitors' ) ) { ?>
|
<?php if ( canEdit( 'Monitors' ) ) { ?>
|
||||||
<div id="enableDisableAlarms"><a id="enableAlarmsLink" href="#" onclick="cmdEnableAlarms(); return( false );" class="hidden"><?php echo translate('EnableAlarms') ?></a><a id="disableAlarmsLink" href="#" onclick="cmdDisableAlarms(); return( false );" class="hidden"><?php echo translate('DisableAlarms') ?></a></div>
|
<div id="enableDisableAlarms"><a id="enableAlarmsLink" href="#" onclick="cmdEnableAlarms(); return( false );" class="hidden"><?php echo translate('EnableAlarms') ?></a><a id="disableAlarmsLink" href="#" onclick="cmdDisableAlarms(); return( false );" class="hidden"><?php echo translate('DisableAlarms') ?></a></div>
|
||||||
|
|
|
@ -122,7 +122,7 @@ $connkey = generateConnKey();
|
||||||
$streamSrc = '';
|
$streamSrc = '';
|
||||||
$streamMode = '';
|
$streamMode = '';
|
||||||
# Have to do this here, because the .js.php references somethings figured out when generating the streamHTML
|
# Have to do this here, because the .js.php references somethings figured out when generating the streamHTML
|
||||||
$StreamHTML = getStreamHTML( $monitor, $scale );
|
$StreamHTML = getStreamHTML( $monitor, array('scale'=>$scale) );
|
||||||
|
|
||||||
xhtmlHeaders(__FILE__, translate('Zone') );
|
xhtmlHeaders(__FILE__, translate('Zone') );
|
||||||
?>
|
?>
|
||||||
|
@ -162,7 +162,13 @@ xhtmlHeaders(__FILE__, translate('Zone') );
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php echo translate('ZoneAlarmColour') ?></th>
|
<th scope="row"><?php echo translate('ZoneAlarmColour') ?></th>
|
||||||
<td colspan="2"><input type="text" name="newAlarmRgbR" value="<?php echo ($newZone['AlarmRGB']>>16)&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/> / <input type="text" name="newAlarmRgbG" value="<?php echo ($newZone['AlarmRGB']>>8)&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/> / <input type="text" name="newAlarmRgbB" value="<?php echo $newZone['AlarmRGB']&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/></td>
|
<td colspan="2">
|
||||||
|
<input type="text" name="newAlarmRgbR" value="<?php echo ($newZone['AlarmRGB']>>16)&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/>
|
||||||
|
/
|
||||||
|
<input type="text" name="newAlarmRgbG" value="<?php echo ($newZone['AlarmRGB']>>8)&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/>
|
||||||
|
/
|
||||||
|
<input type="text" name="newAlarmRgbB" value="<?php echo $newZone['AlarmRGB']&0xff ?>" size="3" onchange="limitRange( this, 0, 255 )"/>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php echo translate('CheckMethod') ?></th>
|
<th scope="row"><?php echo translate('CheckMethod') ?></th>
|
||||||
|
|
|
@ -48,21 +48,14 @@ xhtmlHeaders(__FILE__, translate('Zones') );
|
||||||
<h2><?php echo translate('Zones') ?></h2>
|
<h2><?php echo translate('Zones') ?></h2>
|
||||||
</div>
|
</div>
|
||||||
<div id="content" style="width:<?php echo $monitor->Width() ?>px; height:<?php echo $monitor->Height() ?>px; position:relative; margin: 0 auto;">
|
<div id="content" style="width:<?php echo $monitor->Width() ?>px; height:<?php echo $monitor->Height() ?>px; position:relative; margin: 0 auto;">
|
||||||
<?php echo getStreamHTML( $monitor ); ?>
|
|
||||||
<svg class="zones" width="<?php echo $monitor->Width() ?>" height="<?php echo $monitor->Height() ?>" style="position:absolute; top: 0; left: 0; background: none;">
|
|
||||||
<?php
|
|
||||||
foreach( array_reverse($zones) as $zone ) {
|
|
||||||
?>
|
|
||||||
<polygon points="<?php echo $zone['AreaCoords'] ?>" class="<?php echo $zone['Type']?>" onclick="streamCmdQuit( true ); createPopup( '?view=zone&mid=<?php echo $mid ?>&zid=<?php echo $zone['Id'] ?>', 'zmZone', 'zone', <?php echo $monitor->Width ?>, <?php echo $monitor->Height ?> ); return( false );"/>
|
|
||||||
<?php
|
|
||||||
} // end foreach zone
|
|
||||||
?>
|
|
||||||
Sorry, your browser does not support inline SVG
|
|
||||||
</svg>
|
|
||||||
<form name="contentForm" id="contentForm" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
<form name="contentForm" id="contentForm" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
||||||
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
||||||
<input type="hidden" name="action" value="delete"/>
|
<input type="hidden" name="action" value="delete"/>
|
||||||
<input type="hidden" name="mid" value="<?php echo $mid ?>"/>
|
<input type="hidden" name="mid" value="<?php echo $mid ?>"/>
|
||||||
|
<div id="contentButtons">
|
||||||
|
<input type="button" value="<?php echo translate('AddNewZone') ?>" onclick="createPopup( '?view=zone&mid=<?php echo $mid ?>&zid=0', 'zmZone', 'zone', <?php echo $monitor->Width() ?>, <?php echo $monitor->Height() ?> );"<?php if ( !canEdit( 'Monitors' ) ) { ?> disabled="disabled"<?php } ?>/>
|
||||||
|
<input type="submit" name="deleteBtn" value="<?php echo translate('Delete') ?>" disabled="disabled"/>
|
||||||
|
</div>
|
||||||
<table id="contentTable" class="major" cellspacing="0">
|
<table id="contentTable" class="major" cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -88,9 +81,18 @@ foreach( $zones as $zone )
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div id="contentButtons">
|
<div class="ZonesImage" style="position:relative; clear:both;">
|
||||||
<input type="button" value="<?php echo translate('AddNewZone') ?>" onclick="createPopup( '?view=zone&mid=<?php echo $mid ?>&zid=0', 'zmZone', 'zone', <?php echo $monitor->Width() ?>, <?php echo $monitor->Height() ?> );"<?php if ( !canEdit( 'Monitors' ) ) { ?> disabled="disabled"<?php } ?>/>
|
<?php echo getStreamHTML( $monitor ); ?>
|
||||||
<input type="submit" name="deleteBtn" value="<?php echo translate('Delete') ?>" disabled="disabled"/>
|
<svg class="zones" width="<?php echo $monitor->Width() ?>" height="<?php echo $monitor->Height() ?>" style="position:absolute; top: 0; left: 0; background: none;">
|
||||||
|
<?php
|
||||||
|
foreach( array_reverse($zones) as $zone ) {
|
||||||
|
?>
|
||||||
|
<polygon points="<?php echo $zone['AreaCoords'] ?>" class="<?php echo $zone['Type']?>" onclick="streamCmdQuit( true ); createPopup( '?view=zone&mid=<?php echo $mid ?>&zid=<?php echo $zone['Id'] ?>', 'zmZone', 'zone', <?php echo $monitor->Width ?>, <?php echo $monitor->Height ?> ); return( false );"/>
|
||||||
|
<?php
|
||||||
|
} // end foreach zone
|
||||||
|
?>
|
||||||
|
Sorry, your browser does not support inline SVG
|
||||||
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -56,6 +56,7 @@ $errorText = false;
|
||||||
$filename = '';
|
$filename = '';
|
||||||
$Frame = null;
|
$Frame = null;
|
||||||
$Event = null;
|
$Event = null;
|
||||||
|
$path = null;
|
||||||
|
|
||||||
if ( empty($_REQUEST['path']) ) {
|
if ( empty($_REQUEST['path']) ) {
|
||||||
if ( ! empty($_REQUEST['fid']) ) {
|
if ( ! empty($_REQUEST['fid']) ) {
|
||||||
|
@ -75,7 +76,9 @@ if ( empty($_REQUEST['path']) ) {
|
||||||
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$errorText = 'No image path';
|
Fatal("No Frame ID specified");
|
||||||
|
header("HTTP/1.0 404 Not Found");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! file_exists( $path ) ) {
|
if ( ! file_exists( $path ) ) {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canView( 'Events' ) ) {
|
if ( !canView( 'Events' ) ) {
|
||||||
$view = "error";
|
$view = 'error';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ if ( ! empty($_REQUEST['eid'] ) ) {
|
||||||
|
|
||||||
if ( $errorText ) {
|
if ( $errorText ) {
|
||||||
Error( $errorText );
|
Error( $errorText );
|
||||||
header ("HTTP/1.0 404 Not Found");
|
header ('HTTP/1.0 404 Not Found');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,8 @@ while( $length && ( ! feof( $fh ) ) && ( connection_status() == 0 ) ) {
|
||||||
|
|
||||||
print fread( $fh, $amount );
|
print fread( $fh, $amount );
|
||||||
$length -= $amount;
|
$length -= $amount;
|
||||||
usleep(100);
|
usleep(10);
|
||||||
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose( $fh );
|
fclose( $fh );
|
||||||
|
|
|
@ -69,7 +69,7 @@ if [ -n "$ZM_CONFIG" ]; then
|
||||||
elif [ -f "zm.conf" ]; then
|
elif [ -f "zm.conf" ]; then
|
||||||
echo "Using local zm.conf"
|
echo "Using local zm.conf"
|
||||||
source "zm.conf"
|
source "zm.conf"
|
||||||
elif [ -f "/etc/zm.conf"]; then
|
elif [ -f "/etc/zm.conf" ]; then
|
||||||
echo "Using system zm.conf"
|
echo "Using system zm.conf"
|
||||||
source "/etc/zm.conf"
|
source "/etc/zm.conf"
|
||||||
else
|
else
|
||||||
|
|
|
@ -53,8 +53,16 @@
|
||||||
#cmakedefine HAVE_LIBAVUTIL_MATHEMATICS_H 1
|
#cmakedefine HAVE_LIBAVUTIL_MATHEMATICS_H 1
|
||||||
#cmakedefine HAVE_LIBSWSCALE 1
|
#cmakedefine HAVE_LIBSWSCALE 1
|
||||||
#cmakedefine HAVE_LIBSWSCALE_SWSCALE_H 1
|
#cmakedefine HAVE_LIBSWSCALE_SWSCALE_H 1
|
||||||
|
#cmakedefine HAVE_LIBAVRESAMPLE 1
|
||||||
|
#cmakedefine HAVE_LIBAVRESAMPLE_AVRESAMPLE_H 1
|
||||||
#cmakedefine HAVE_LIBVLC 1
|
#cmakedefine HAVE_LIBVLC 1
|
||||||
#cmakedefine HAVE_VLC_VLC_H 1
|
#cmakedefine HAVE_VLC_VLC_H 1
|
||||||
|
#cmakedefine HAVE_LIBX264 1
|
||||||
|
#cmakedefine HAVE_X264_H 1
|
||||||
|
#cmakedefine HAVE_LIBMP4V2 1
|
||||||
|
#cmakedefine HAVE_MP4_H 1
|
||||||
|
#cmakedefine HAVE_MP4V2_H 1
|
||||||
|
#cmakedefine HAVE_MP4V2_MP4V2_H 1
|
||||||
|
|
||||||
/* Authenication checks */
|
/* Authenication checks */
|
||||||
#cmakedefine HAVE_MD5_OPENSSL 1
|
#cmakedefine HAVE_MD5_OPENSSL 1
|
||||||
|
|
Loading…
Reference in New Issue