Merge branch 'storageareas' into work_on_zms
This commit is contained in:
commit
98590b99f8
|
@ -26,9 +26,10 @@ addons:
|
|||
env:
|
||||
matrix:
|
||||
- OS=el DIST=6
|
||||
- OS=el DIST=6 ARCH=i386 DOCKER_REPO=knnniggett/packpack
|
||||
- OS=el DIST=7
|
||||
- OS=fedora DIST=24
|
||||
- OS=fedora DIST=25
|
||||
- OS=fedora DIST=26 DOCKER_REPO=knnniggett/packpack
|
||||
- OS=ubuntu DIST=trusty
|
||||
- OS=ubuntu DIST=xenial
|
||||
- OS=ubuntu DIST=trusty ARCH=i386
|
||||
|
|
|
@ -69,20 +69,38 @@ 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")
|
||||
|
||||
# Arm neon support only tested on Linux. If your arm hardware is running a non-Linux distro and is using gcc then contact us.
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ZM_SYSTEM_PROC)
|
||||
IF((ZM_SYSTEM_PROC STREQUAL "") OR (ZM_SYSTEM_PROC STREQUAL "unknown"))
|
||||
execute_process(COMMAND uname -m OUTPUT_VARIABLE ZM_SYSTEM_PROC ERROR_VARIABLE ZM_SYSTEM_PROC_ERR)
|
||||
|
||||
# maybe make the following error checks fatal
|
||||
IF(ZM_SYSTEM_PROC_ERR)
|
||||
message(WARNING "\nAn error occurred while attempting to determine the system processor:\n${ZM_SYSTEM_PROC_ERR}")
|
||||
ENDIF(ZM_SYSTEM_PROC_ERR)
|
||||
IF(NOT ZM_SYSTEM_PROC)
|
||||
message(WARNING "\nUnable to determine the system processor. This may cause a build failure.\n")
|
||||
ENDIF(ZM_SYSTEM_PROC)
|
||||
|
||||
ENDIF((ZM_SYSTEM_PROC STREQUAL "") OR (ZM_SYSTEM_PROC STREQUAL "unknown"))
|
||||
|
||||
IF(ZM_SYSTEM_PROC MATCHES "^arm")
|
||||
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(ZM_SYSTEM_PROC MATCHES "^arm")
|
||||
ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
||||
# Modules that we need:
|
||||
include (GNUInstallDirs)
|
||||
|
@ -137,11 +155,11 @@ set(ZM_WEB_USER "" CACHE STRING
|
|||
set(ZM_WEB_GROUP "" CACHE STRING
|
||||
"The group apache or the local web server runs on,
|
||||
Leave empty to be the same as the web user")
|
||||
set(ZM_DIR_EVENTS "events" CACHE PATH
|
||||
"Location where events are recorded to, default: events")
|
||||
set(ZM_DIR_IMAGES "events" CACHE PATH
|
||||
set(ZM_DIR_EVENTS "${ZM_CONTENTDIR}/events" CACHE PATH
|
||||
"Location where events are recorded to, default: ZM_CONTENTDIR/events")
|
||||
set(ZM_DIR_IMAGES "${ZM_CONTENTDIR}/images" CACHE PATH
|
||||
"Location where images, not directly associated with events,
|
||||
are recorded to, default: images")
|
||||
are recorded to, default: ZM_CONTENTDIR/images")
|
||||
set(ZM_DIR_SOUNDS "sounds" CACHE PATH
|
||||
"Location to look for optional sound files, default: sounds")
|
||||
set(ZM_PATH_ZMS "/cgi-bin/nph-zms" CACHE PATH
|
||||
|
@ -154,7 +172,7 @@ set(ZM_PATH_ARP "" CACHE PATH
|
|||
"Full path to compatible arp binary. Leave empty for automatic detection.")
|
||||
set(ZM_CONFIG_DIR "/${CMAKE_INSTALL_SYSCONFDIR}" CACHE PATH
|
||||
"Location of ZoneMinder configuration, default system config directory")
|
||||
set(ZM_CONFIG_SUBDIR "${ZM_CONFIG_DIR}/conf.d" CACHE PATH
|
||||
set(ZM_CONFIG_SUBDIR "${ZM_CONFIG_DIR}/zm/conf.d" CACHE PATH
|
||||
"Location of ZoneMinder configuration subfolder, default: ZM_CONFIG_DIR/conf.d")
|
||||
set(ZM_EXTRA_LIBS "" CACHE STRING
|
||||
"A list of optional libraries, separated by semicolons, e.g. ssl;theora")
|
||||
|
@ -557,6 +575,7 @@ if(NOT ZM_NO_FFMPEG)
|
|||
mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR)
|
||||
check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H)
|
||||
check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H)
|
||||
check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H)
|
||||
set(optlibsfound "${optlibsfound} AVUtil")
|
||||
else(AVUTIL_LIBRARIES)
|
||||
set(optlibsnotfound "${optlibsnotfound} AVUtil")
|
||||
|
@ -801,11 +820,12 @@ endif(ZM_PERL_SEARCH_PATH)
|
|||
|
||||
# If this is an out-of-source build, copy the files we need to the binary directory
|
||||
if(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR))
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/conf.d" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conf.d")
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/conf.d" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" PATTERN "*.in" EXCLUDE)
|
||||
endif(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR))
|
||||
|
||||
# Generate files from the .in files
|
||||
configure_file(zm.conf.in "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" @ONLY)
|
||||
configure_file(conf.d/01-system-paths.conf.in "${CMAKE_CURRENT_BINARY_DIR}/conf.d/01-system-paths.conf" @ONLY)
|
||||
configure_file(zoneminder-config.cmake "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
|
||||
configure_file(zmconfgen.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmconfgen.pl" @ONLY)
|
||||
configure_file(zmlinkcontent.sh.in "${CMAKE_CURRENT_BINARY_DIR}/zmlinkcontent.sh" @ONLY)
|
||||
|
@ -850,18 +870,7 @@ endif(zmconfgen_result EQUAL 0)
|
|||
|
||||
# Install zm.conf
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" DESTINATION "${ZM_CONFIG_DIR}")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/conf.d/" DESTINATION "${ZM_CONFIG_SUBDIR}")
|
||||
#install(CODE "
|
||||
#if (NOT EXISTS \"${ZM_CONFIG_DIR}/zm.conf\")
|
||||
#message(STATUS \"No zm.conf at ${CMAKE_CURRENT_BINARY_DIR}/zm.conf. Will install a new zm.conf\")
|
||||
#install(FILES \"${CMAKE_CURRENT_BINARY_DIR}/zm.conf\" DESTINATION \"${ZM_CONFIG_DIR}\")
|
||||
#else (NOT EXISTS \"${ZM_CONFIG_DIR}/zm.conf\")
|
||||
#message(STATUS \"Found zm.conf at ${CMAKE_CURRENT_BINARY_DIR}/zm.conf. Not overwriting. Installing zm.conf.new instead.\")
|
||||
#file(RENAME \"${CMAKE_CURRENT_BINARY_DIR}/zm.conf\" \"${CMAKE_CURRENT_BINARY_DIR}/zm.conf.new\")
|
||||
#install(FILES \"${CMAKE_CURRENT_BINARY_DIR}/zm.conf.new\" DESTINATION \"${ZM_CONFIG_DIR}\")
|
||||
#endif(NOT EXISTS \"${ZM_CONFIG_DIR}/zm.conf\")
|
||||
#")
|
||||
|
||||
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/conf.d/" DESTINATION "${ZM_CONFIG_SUBDIR}" PATTERN "*.in" EXCLUDE)
|
||||
|
||||
# Uninstall target
|
||||
configure_file(
|
||||
|
|
11
INSTALL
11
INSTALL
|
@ -45,9 +45,20 @@ Possible configuration options:
|
|||
ZM_DB_NAME Name of ZoneMinder database, default: zm
|
||||
ZM_DB_USER Name of ZoneMinder database user, default: zmuser
|
||||
ZM_DB_PASS Password of ZoneMinder database user, default: zmpass
|
||||
ZM_DB_SSL_CA_CERT Path to SSL CA certificate, default: empty; SSL not enabled
|
||||
ZM_DB_SSL_CLIENT_KEY Path to SSL client key, default: empty; SSL not enabled
|
||||
ZM_DB_SSL_CLIENT_CERT Path to SSL client certificate, default: empty; SSL not enabled
|
||||
ZM_WEB_USER The user apache or the local web server runs on. Leave empty for automatic detection. If that fails, you can use this variable to force
|
||||
ZM_WEB_GROUP The group apache or the local web server runs on, Leave empty to be the same as the web user
|
||||
ZM_DIR_EVENTS Location where events are recorded to, default: ZM_CONTENTDIR/events
|
||||
ZM_DIR_IMAGES Location where images, not directly associated with events, are recorded to, default: ZM_CONTENTDIR/images
|
||||
ZM_DIR_SOUNDS Location to look for optional sound files, default: sounds
|
||||
ZM_PATH_ZMS Web url to zms streaming server, default: /cgi-bin/nph-zms
|
||||
Advanced:
|
||||
ZM_PATH_MAP Location to save mapped memory files, default: /dev/shm
|
||||
ZM_PATH_ARP Full path to compatible arp binary. Leave empty for automatic detection.
|
||||
ZM_CONFIG_DIR Location of the main ZoneMinder config file, zm.conf. default: /etc/zm
|
||||
ZM_CONFIG_SUBDIR Location of custom config files. default: ZM_CONFIG_DIR/conf.d
|
||||
ZM_EXTRA_LIBS A list of optional libraries, separated by semicolons, e.g. ssl;theora
|
||||
ZM_MYSQL_ENGINE MySQL engine to use with database, default: InnoDB
|
||||
ZM_NO_MMAP Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF
|
||||
|
|
|
@ -27,8 +27,8 @@ This is the recommended method to install ZoneMinder onto your system. ZoneMinde
|
|||
|
||||
- Ubuntu via [Iconnor's PPA](https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder)
|
||||
- Debian from their [default repository](https://packages.debian.org/search?searchon=names&keywords=zoneminder)
|
||||
- RHEL/CentOS and clones via [zmrepo](http://zmrepo.zoneminder.com/)
|
||||
- Fedora via [zmrepo](http://zmrepo.zoneminder.com/)
|
||||
- RHEL/CentOS and clones via [RPM Fusion](http://rpmfusion.org)
|
||||
- Fedora via [RPM Fusion](http://rpmfusion.org)
|
||||
- OpenSuse via [third party repository](http://www.zoneminder.com/wiki/index.php/Installing_using_ZoneMinder_RPMs_for_SuSE)
|
||||
- Mageia from their default repository
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@ echo "Database host : $ZM_DB_HOST"
|
|||
echo "Database name : $ZM_DB_NAME"
|
||||
echo "Database user : $ZM_DB_USER"
|
||||
echo "Database password : Not shown"
|
||||
echo "Database SSL CA Cert : $ZM_DB_SSL_CA_CERT"
|
||||
echo "Database SSL Client Key : $ZM_DB_SSL_CLIENT_KEY"
|
||||
echo "Database SSL Client Cert : $ZM_DB_SSL_CLIENT_CERT"
|
||||
|
||||
|
||||
CMPATH="CACHE PATH \"Imported by cmakecacheimport.sh\" FORCE"
|
||||
|
@ -72,6 +75,9 @@ echo "set(ZM_DB_HOST \"$ZM_DB_HOST\" $CMSTRING)">>zm_conf.cmake
|
|||
echo "set(ZM_DB_NAME \"$ZM_DB_NAME\" $CMSTRING)">>zm_conf.cmake
|
||||
echo "set(ZM_DB_USER \"$ZM_DB_USER\" $CMSTRING)">>zm_conf.cmake
|
||||
echo "set(ZM_DB_PASS \"$ZM_DB_PASS\" $CMSTRING)">>zm_conf.cmake
|
||||
echo "set(ZM_DB_SSL_CA_CERT \"$ZM_DB_SSL_CA_CERT\" $CMSTRING)">>zm_conf.cmake
|
||||
echo "set(ZM_DB_SSL_CLIENT_KEY \"$ZM_DB_SSL_CLIENT_KEY\" $CMSTRING)">>zm_conf.cmake
|
||||
echo "set(ZM_DB_SSL_CLIENT_CERT \"$ZM_DB_SSL_CLIENT_CERT\" $CMSTRING)">>zm_conf.cmake
|
||||
|
||||
echo ""
|
||||
echo "Wrote zm_conf.cmake"
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder System Paths Configuration
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
# This config file contains the variables previously found under Options -> Paths
|
||||
#
|
||||
# *** DO NOT EDIT THIS FILE ***
|
||||
#
|
||||
# To make custom changes to the variables below, create a new configuration
|
||||
# file, with an extention of .conf, containing your desired modifications.
|
||||
#
|
||||
|
||||
# Full path to the folder events are recorded to.
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_DIR_EVENTS=@ZM_DIR_EVENTS@
|
||||
|
||||
# Full path to the folder images, not directly associated with events,
|
||||
# are recorded to.
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_DIR_IMAGES=@ZM_DIR_IMAGES@
|
||||
|
||||
# Foldername under the webroot where ZoneMinder looks for optional sound files
|
||||
# to play when an alarm is detected.
|
||||
ZM_DIR_SOUNDS=@ZM_DIR_SOUNDS@
|
||||
|
||||
# Full path to the folder where exported archives are stored
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_DIR_EXPORTS=@ZM_TMPDIR@
|
||||
|
||||
# ZoneMinder url path to the zms streaming server
|
||||
ZM_PATH_ZMS=@ZM_PATH_ZMS@
|
||||
|
||||
# Full Path to ZoneMinder's mapped memory files
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_PATH_MAP=@ZM_PATH_MAP@
|
||||
|
||||
# Full Path to ZoneMinder's socket folder
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_PATH_SOCKS=@ZM_SOCKDIR@
|
||||
|
||||
# Full path to ZoneMinder's log folder
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_PATH_LOGS=@ZM_LOGDIR@
|
||||
|
||||
# Full path to ZoneMinder's swap folder
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_PATH_SWAP=@ZM_TMPDIR@
|
||||
|
||||
# Full path to optional arp binary
|
||||
# ZoneMinder will find the arp binary automatically on most systems
|
||||
ZM_PATH_ARP=@ZM_PATH_ARP@
|
|
@ -0,0 +1,12 @@
|
|||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder Multiserver Configuration
|
||||
#
|
||||
# ==========================================================================
|
||||
# Do NOT set ZM_SERVER_HOST if you are not using Multi-Server
|
||||
# You have been warned
|
||||
#
|
||||
# The name specified here must have a corresponding entry
|
||||
# in the Servers tab under Options
|
||||
#ZM_SERVER_HOST=
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# Do NOT set ZM_SERVER_HOST if you are not using Multi-Server
|
||||
# You have been warned
|
||||
#
|
||||
# The name specified here must have a corresponding entry
|
||||
# in the Servers tab under Options
|
||||
ZM_SERVER_HOST=
|
||||
|
|
@ -18,7 +18,6 @@ override_dh_auto_configure:
|
|||
-DZM_TMPDIR=/var/tmp/zm \
|
||||
-DZM_LOGDIR=/var/log/zm \
|
||||
-DZM_WEBDIR=/usr/share/zoneminder/www \
|
||||
-DZM_CONTENTDIR=/var/cache/zoneminder \
|
||||
-DZM_CGIDIR=/usr/lib/zoneminder/cgi-bin \
|
||||
-DZM_WEB_USER=www-data \
|
||||
-DZM_WEB_GROUP=www-data \
|
||||
|
|
|
@ -9,15 +9,15 @@ else(ZM_TARGET_DISTRO MATCHES "^el")
|
|||
message([WARNING] "Unknown Build Option Detected" ...)
|
||||
endif(ZM_TARGET_DISTRO MATCHES "^el")
|
||||
|
||||
if((ZM_TARGET_DISTRO STREQUAL "el6") AND (ZM_WEB_USER STREQUAL "nginx"))
|
||||
message([FATAL_ERROR] "Nginx is Not a Supported Build Option on EL6 Target Distro" ...)
|
||||
endif((ZM_TARGET_DISTRO STREQUAL "el6") AND (ZM_WEB_USER STREQUAL "nginx"))
|
||||
if((NOT ZM_TARGET_DISTRO MATCHES "^fc") AND (ZM_WEB_USER STREQUAL "nginx"))
|
||||
message([FATAL_ERROR] "Experimental Nginx support is currently only supported on Fedora" ...)
|
||||
endif((NOT ZM_TARGET_DISTRO MATCHES "^fc") AND (ZM_WEB_USER STREQUAL "nginx"))
|
||||
|
||||
# Configure the zoneminder service files
|
||||
if(ZM_TARGET_DISTRO STREQUAL "el6")
|
||||
configure_file(sysvinit/zoneminder.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.sysvinit @ONLY)
|
||||
configure_file(sysvinit/zoneminder.logrotate.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.logrotate @ONLY)
|
||||
configure_file(sysvinit/zoneminder.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.conf @ONLY)
|
||||
configure_file(apache/zoneminder.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.conf @ONLY)
|
||||
else(ZM_TARGET_DISTRO STREQUAL "el6")
|
||||
configure_file(systemd/zoneminder.logrotate.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.logrotate @ONLY)
|
||||
if(ZM_WEB_USER STREQUAL "nginx")
|
||||
|
@ -28,7 +28,7 @@ else(ZM_TARGET_DISTRO STREQUAL "el6")
|
|||
configure_file(nginx/README.Fedora ${CMAKE_CURRENT_SOURCE_DIR}/readme/README.Fedora COPYONLY)
|
||||
else(ZM_WEB_USER STREQUAL "nginx")
|
||||
configure_file(systemd/zoneminder.service.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY)
|
||||
configure_file(systemd/zoneminder.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.conf @ONLY)
|
||||
configure_file(apache/zoneminder.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.conf @ONLY)
|
||||
configure_file(systemd/zoneminder.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.tmpfiles @ONLY)
|
||||
endif(ZM_WEB_USER STREQUAL "nginx")
|
||||
endif(ZM_TARGET_DISTRO STREQUAL "el6")
|
||||
|
@ -55,10 +55,7 @@ install(DIRECTORY zoneminder DESTINATION /var/run DIRECTORY_PERMISSIONS OWNER_WR
|
|||
install(DIRECTORY zoneminder-upload DESTINATION /var/spool DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(DIRECTORY events images temp DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
|
||||
# Create symlinks
|
||||
install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/events \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/events\")")
|
||||
install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/images \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/images\")")
|
||||
install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/temp \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/temp\")")
|
||||
# Symlink the cake php temp folder to the ZoneMinder temp folder
|
||||
install(CODE "execute_process(COMMAND ln -sf ../../../../../../var/lib/zoneminder/temp \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/api/app/tmp\")")
|
||||
|
||||
# Link to Cambozola
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# ZoneMinder systemd unit file for CentOS 7
|
||||
# ZoneMinder systemd unit file for RedHat distros and clones
|
||||
|
||||
[Unit]
|
||||
Description=ZoneMinder CCTV recording and security system
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
#
|
||||
# ZoneMinder Apache configuration file
|
||||
# With SSLRequire and HTTPS auto redirect
|
||||
# Modify this configuration to suit your requirements
|
||||
#
|
||||
|
||||
# Auto Redirect HTTP requests to HTTPS
|
||||
RewriteEngine On
|
||||
RewriteCond %{HTTPS} !=on
|
||||
RewriteRule ^/?(zm)(.*) https://%{SERVER_NAME}/$1$2 [R,L]
|
||||
|
||||
Alias /zm "@ZM_WEBDIR@"
|
||||
<Directory "@ZM_WEBDIR@">
|
||||
# explicitly set index.php as the only directoryindex
|
||||
DirectoryIndex disabled
|
||||
DirectoryIndex index.php
|
||||
SSLRequireSSL
|
||||
Options -Indexes +MultiViews +FollowSymLinks
|
||||
AllowOverride None
|
||||
<IfModule mod_authz_core.c>
|
||||
# Apache 2.4
|
||||
Require all granted
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
# Apache 2.2
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
ScriptAlias /cgi-bin-zm "@ZM_CGIDIR@"
|
||||
<Directory "@ZM_CGIDIR@">
|
||||
SSLRequireSSL
|
||||
AllowOverride None
|
||||
Options +ExecCGI +FollowSymLinks
|
||||
<IfModule mod_authz_core.c>
|
||||
# Apache 2.4
|
||||
Require all granted
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
# Apache 2.2
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
# For better visibility, the following directives have been migrated from the
|
||||
# default .htaccess files included with the CakePHP project.
|
||||
# Parameters not set here are inherited from the parent directive above.
|
||||
<Directory "@ZM_WEBDIR@/api">
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ app/webroot/ [L]
|
||||
RewriteRule (.*) app/webroot/$1 [L]
|
||||
RewriteBase /zm/api
|
||||
</Directory>
|
||||
|
||||
<Directory "@ZM_WEBDIR@/api/app">
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
RewriteBase /zm/api
|
||||
</Directory>
|
||||
|
||||
<Directory "@ZM_WEBDIR@/api/app/webroot">
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
RewriteBase /zm/api
|
||||
</Directory>
|
||||
|
|
@ -286,12 +286,18 @@ rm -rf %{_docdir}/%{name}-%{version}
|
|||
%files
|
||||
%license COPYING
|
||||
%doc AUTHORS README.md distros/redhat/readme/README.%{readme_suffix} distros/redhat/readme/README.https distros/redhat/jscalendar-doc
|
||||
|
||||
# We want these two folders to have "normal" read permission
|
||||
# compared to the folder contents
|
||||
%dir %{_sysconfdir}/zm
|
||||
%dir %{_sysconfdir}/zm/conf.d
|
||||
|
||||
# Config folder contents contain sensitive info
|
||||
# and should not be readable by normal users
|
||||
%{_sysconfdir}/zm/conf.d/README
|
||||
# Always overwrite zm.conf now that ZoneMinder supports conf.d folder
|
||||
%attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/zm.conf
|
||||
%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/zm.conf
|
||||
%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/*.conf
|
||||
%ghost %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/zmcustom.conf
|
||||
|
||||
%config(noreplace) %attr(644,root,root) %{wwwconfdir}/zoneminder.conf
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/zoneminder
|
||||
|
|
|
@ -25,7 +25,6 @@ override_dh_auto_configure:
|
|||
-DZM_SOCKDIR="/var/run/zm" \
|
||||
-DZM_TMPDIR="/tmp/zm" \
|
||||
-DZM_CGIDIR="/usr/lib/zoneminder/cgi-bin" \
|
||||
-DZM_CONTENTDIR="/var/cache/zoneminder" \
|
||||
-DZM_DIR_EVENTS="/var/cache/zoneminder/events" \
|
||||
-DZM_DIR_IMAGES="/var/cache/zoneminder/images" \
|
||||
-DZM_PATH_ZMS="/zm/cgi-bin/nph-zms" \
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
/var/cache/zoneminder/events /usr/share/zoneminder/www/events
|
||||
/var/cache/zoneminder/images /usr/share/zoneminder/www/images
|
||||
/var/cache/zoneminder/temp /usr/share/zoneminder/www/temp
|
||||
/tmp/zm /usr/share/zoneminder/www/api/app/tmp
|
||||
|
|
|
@ -58,7 +58,6 @@ override_dh_auto_configure:
|
|||
-DZM_TMPDIR=/var/tmp/zm \
|
||||
-DZM_LOGDIR=/var/log/zm \
|
||||
-DZM_WEBDIR=/usr/share/zoneminder \
|
||||
-DZM_CONTENTDIR=/var/cache/zoneminder \
|
||||
-DZM_CGIDIR=/usr/lib/cgi-bin \
|
||||
-DZM_WEB_USER=www-data \
|
||||
-DZM_WEB_GROUP=www-data \
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
var/cache/zoneminder/events usr/share/zoneminder/www/events
|
||||
var/cache/zoneminder/images usr/share/zoneminder/www/images
|
||||
var/cache/zoneminder/temp usr/share/zoneminder/www/temp
|
|
@ -1 +0,0 @@
|
|||
usr/lib/cgi-bin usr/share/zoneminder/cgi-bin
|
|
@ -25,7 +25,6 @@ override_dh_auto_configure:
|
|||
-DZM_SOCKDIR="/var/run/zm" \
|
||||
-DZM_TMPDIR="/tmp/zm" \
|
||||
-DZM_CGIDIR="/usr/lib/zoneminder/cgi-bin" \
|
||||
-DZM_CONTENTDIR="/var/cache/zoneminder" \
|
||||
-DZM_DIR_EVENTS="/var/cache/zoneminder/events" \
|
||||
-DZM_DIR_IMAGES="/var/cache/zoneminder/images" \
|
||||
-DZM_PATH_ZMS="/zm/cgi-bin/nph-zms"
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
/var/cache/zoneminder/events /usr/share/zoneminder/www/events
|
||||
/var/cache/zoneminder/images /usr/share/zoneminder/www/images
|
||||
/var/cache/zoneminder/temp /usr/share/zoneminder/www/temp
|
||||
/var/tmp /usr/share/zoneminder/www/api/app/tmp
|
||||
|
|
17
docs/faq.rst
17
docs/faq.rst
|
@ -61,7 +61,7 @@ In *general* a good estimate of memory required would be:
|
|||
|
||||
::
|
||||
|
||||
Min Memory = 1.2 * ((image-width*image-height*image buffer size*target color space*number of cameras/8/1024/1024 )
|
||||
Min Bits of Memory = 20% overhead * (image-width*image-height*image buffer size*target color space*number of cameras)
|
||||
|
||||
Where:
|
||||
* image-width and image-height are the width and height of images that your camera is configured for (in my case, 1280x960). This value is in the Source tab for each monitor
|
||||
|
@ -69,11 +69,18 @@ Where:
|
|||
* target color space is the color depth - 8bit, 24bit or 32bit. It's again in the source tab of each monitor
|
||||
The 1.2 at the start is basically adding 20% on top of the calculation to account for image/stream overheads (this is an estimate)
|
||||
|
||||
So let's do the math. If we have 4 cameras running at 1280x960 with 32bit color space and one camera running at 640x480 with 8bit greyscale color space, the system would require:
|
||||
The math breakdown for 4 cameras running at 1280x960 capture, 50 frame buffer, 24 bit color space:
|
||||
::
|
||||
1280*960 = 1,228,800 (bits)
|
||||
1,228,800 * 24 = 2,359,296,000 (bits)
|
||||
2,359,296,000 * 50 = 5,898,240,000 (bits)
|
||||
5,898,240,000 * 4 = 7,077,888,000 (bits)
|
||||
7,077,888,000 / 8 = 884,736,000 (bytes)
|
||||
884,736,000 / 1000 = 884,736 (Kilobytes)
|
||||
884,736 / 1000 = 864 (Megabytes)
|
||||
864 / 1000 = 0.9 (Gigabyte)
|
||||
|
||||
``1.2 * ((1280*960*50*32*4/8/1024/1024 ) + (640 *480 *50*8/8 /1024/1024))``
|
||||
|
||||
Or, around 900MB of memory.
|
||||
Around 900MB of memory.
|
||||
|
||||
So if you have 2GB of memory, you should be all set. Right? **Not, really**:
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ Contents:
|
|||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
packpack
|
||||
ubuntu
|
||||
debian
|
||||
redhat
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
All Distros - A Simpler Way to Build ZoneMinder
|
||||
===============================================
|
||||
|
||||
.. contents::
|
||||
|
||||
These instructions represent an alternative way to build ZoneMinder for any supported distro.
|
||||
|
||||
Advantages:
|
||||
|
||||
- Fewer steps and therefore much simpler
|
||||
- Target distro agnostic - the steps are the same regardless of the target distro
|
||||
- Host distro agnostic - the steps described here should work on any host Linux distro capable of running Bash and Docker
|
||||
|
||||
Background
|
||||
------------------------------------
|
||||
|
||||
These instructions leverage the power of the automated build system recently implemented in the ZoneMinder project. Behind the scenes, a project called `packpack <https://github.com/packpack/packpack>`_ is utilized, to build ZoneMinder inside a Docker container.
|
||||
|
||||
Procedure
|
||||
------------------------------------
|
||||
|
||||
**Step 1:** Verify the target distro.
|
||||
|
||||
- Open the project's `.travis.yml file <https://github.com/ZoneMinder/ZoneMinder/blob/master/.travis.yml#L27>`_ and verify the distro you want to build ZoneMinder for appears in the build matrix. The distros shown in the matrix are those known to build on ZoneMinder. If the distro you desire is in the list then continue to step two.
|
||||
|
||||
- If the desired distro is not in the first list, then open the `packpack project README <https://github.com/packpack/packpack/blob/master/README.md>`_ and check if the desired distro is theoretically supported. If it is, then continue to step 2 with the understanding that you are heading out into uncharted territory. There could be problems.
|
||||
|
||||
- If the desired distro does not appear in either list, then unfortuantely you cannot use the procedure described here.
|
||||
|
||||
**Step 2:** Install Docker.
|
||||
|
||||
You need to have a working installation of Docker so head over to the `Docker site <https://docs.docker.com/engine/installation/>`_ and get it working. Before continuing to the next step, verify you can run the Docker "Hello World" container as a normal user. To run a Docker container as a normal user, issue the following:
|
||||
|
||||
::
|
||||
|
||||
sudo gpasswd -a <username> docker
|
||||
newgrp docker
|
||||
|
||||
Where <username> is, you guessed it, the user name you log in with.
|
||||
|
||||
**Step 3:** Git clone the ZoneMinder project.
|
||||
|
||||
Clone the ZoneMinder project if you have not done so already.
|
||||
|
||||
::
|
||||
|
||||
git clone ZoneMinder
|
||||
cd ZoneMinder
|
||||
|
||||
Alternatively, if you have already cloned the repo and wish to update it, do the following.
|
||||
|
||||
::
|
||||
|
||||
cd ZoneMinder
|
||||
git checkout master
|
||||
git pull origin master
|
||||
|
||||
**Step 4:** Checkout the revision of ZoneMinder you wish to build.
|
||||
|
||||
A freshly cloned ZoneMinder git repo already points to the most recent commit in the master branch. If you want the latest development code then continue to the next step. If instead, you want to build a stable release then perform the following step.
|
||||
|
||||
::
|
||||
|
||||
git checkout <releasename>
|
||||
|
||||
Where <releasename> is one of the official ZoneMinder releases shown on the `releases page <https://github.com/ZoneMinder/ZoneMinder/releases>`_, such as 1.30.4.
|
||||
|
||||
**Step 5:** Build ZoneMinder
|
||||
|
||||
To start the build, simply execute the following command from the root folder of the local git repo:
|
||||
|
||||
::
|
||||
|
||||
OS=<distroname> DIST=<distrorel> utils/packpack/startpackpack.sh
|
||||
|
||||
Where <distroname> is the name of the distro you wish to build on, such as fedora, and <distrorev> is release name or number of the distro you wish to build on. Redhat distros expect a number for <distrorev> while Debian and Ubuntu distros expect a name. For example:
|
||||
|
||||
::
|
||||
|
||||
OS=fedora DIST=25 utils/packpack/startpackpack.sh
|
||||
|
||||
::
|
||||
|
||||
OS=ubuntu DIST=xenial utils/packpack/startpackpack.sh
|
||||
|
||||
Once you enter the appropriate command, go get a coffee while a ZoneMinder package is built. When the build finished, you can find the resulting packages under a subfolder called "build".
|
||||
|
||||
Note that this will build packages with x86_64 architecture. This build method can also build on some distros (debian & ubuntu only at the moment) using i386 architecture. You can do that by adding "ARCH=i386" parameter.
|
||||
|
||||
::
|
||||
|
||||
OS=ubuntu DIST=xenial ARCH=i386 utils/packpack/startpackpack.sh
|
||||
|
||||
For advanced users who really want to go out into uncharted waters, it is theoretically possible to build arm packages as well, as long as the host architecture is compatible.
|
||||
|
||||
::
|
||||
|
||||
OS=ubuntu DIST=xenial ARCH=armhfp utils/packpack/startpackpack.sh
|
||||
|
||||
Building arm packages in this manner has not been tested by us, however.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ Background: RHEL, CentOS, and Clones
|
|||
|
||||
These distributions are classified as enterprise operating systems and have a long operating lifetime of many years. By design, they will not have the latest and greatest versions of any package. Instead, stable packages are the emphasis.
|
||||
|
||||
Replacing any core package in these distributions with a newer package from a third party is expressly verboten. The ZoneMinder development team will not do this, and neither should you. If you have the perception that you've got to have a newer version of mysql, gnome, apache, etc. then, rather than upgrade these packages, you should instead consider using a different distribution such as Fedora.
|
||||
Replacing any core package in these distributions with a newer package from a third party is expressly verboten. The ZoneMinder development team will not do this, and neither should you. If you have the perception that you've got to have a newer version of php, mysql, gnome, apache, etc. then, rather than upgrade these packages, you should instead consider using a different distribution such as Fedora.
|
||||
|
||||
The ZoneMinder team will not provide support for systems which have had any core package replaced with a package from a third party.
|
||||
|
||||
|
@ -23,39 +23,77 @@ Fedora has a short life-cycle of just 6 months. However, Fedora, and consequentl
|
|||
|
||||
If you desire newer packages than what is available in RHEL or CentOS, you should consider using Fedora.
|
||||
|
||||
Zmrepo – A ZoneMinder RPM Repository
|
||||
------------------------------------
|
||||
How To Avoid Known Installation Problems
|
||||
----------------------------------------
|
||||
|
||||
Zmrepo is a turn key solution. It will install all of ZoneMinder's dependencies for you. This is the easiest and the recommended way to install ZoneMinder on any system running a Redhat based distribution.
|
||||
The following notes are based on real problems which have occurred by those who came before you:
|
||||
|
||||
Zmrepo supports the two most recent, major releases of each Redhat based distro.
|
||||
|
||||
The following notes are based on real problems which have occurred:
|
||||
|
||||
- Zmrepo assumes you have installed the underlying distribution **using the official installation media for that distro**. Third party "Spins" are not supported and may not work correctly.
|
||||
- Zmrepo assumes you have installed the underlying distribution **using the official installation media for that distro**. Third party "Spins" may not work correctly.
|
||||
|
||||
- ZoneMinder is intended to be installed in an environment dedicated to ZoneMinder. While ZoneMinder will play well with many applications, some invariably will not. Asterisk is one such example.
|
||||
|
||||
- Be advised that you need to start with a clean system before using zmrepo.
|
||||
- Be advised that you need to start with a clean system before installing ZoneMinder.
|
||||
|
||||
- If you have previously installed ZoneMinder from-source, then your system is **NOT** clean. You must manually search for and delete all ZoneMinder related files before using zmrepo (look under /usr/local). Make uninstall helps, but it will not do this for you correctly. You **WILL** have problems if you ignore this step.
|
||||
- If you have previously installed ZoneMinder from-source, then your system is **NOT** clean. You must manually search for and delete all ZoneMinder related files first (look under /usr/local). Issuing a "make uninstall" helps, but it will not do this for you correctly. You **WILL** have problems if you ignore this step.
|
||||
|
||||
- It is not necessary, and not recommended, to install a LAMP stack ahead of time.
|
||||
- Unlike Debian/Ubuntu distros, it is not necessary, and not recommended, to install a LAMP stack ahead of time.
|
||||
|
||||
- Disable other third party repos and uninstall any of ZoneMinder's third party dependencies, which might already be on the system, especially ffmpeg and vlc. Attempting to install dependencies yourself often causes problems.
|
||||
- Disable any other third party repos and uninstall any of ZoneMinder's third party dependencies, which might already be on the system, especially ffmpeg and vlc. Attempting to install dependencies yourself often causes problems.
|
||||
|
||||
- Each ZoneMinder rpm includes a README file under /usr/share/doc. You must follow the all steps in this README file, precisely, each and every time ZoneMinder is installed or upgraded. **Failure to do so is guaranteed to result in a non-functional system.**
|
||||
- Each ZoneMinder rpm includes a README file under /usr/share/doc. You must follow all the steps in this README file, precisely, each and every time ZoneMinder is installed or upgraded. **Failure to do so is guaranteed to result in a non-functional system.**
|
||||
|
||||
To begin the installation of ZoneMinder on your Redhat based distro, please navigate to: http://zmrepo.zoneminder.com
|
||||
How to Install ZoneMinder
|
||||
-------------------------
|
||||
|
||||
How to Build a (Custom) ZoneMinder Package
|
||||
These instructions apply to all redhat distros and compatible clones, except for RHEL/CentOS 6.
|
||||
|
||||
ZoneMinder releases are now being hosted at RPM Fusion. New users should navigate the `RPM Fusion site <https://rpmfusion.org>`_ then follow the instructions to enable that repo. RHEL/CentOS users must also navaigate to the `EPEL Site <https://fedoraproject.org/wiki/EPEL>`_ and enable that repo as well. Once enabled, install ZoneMinder from the commandline:
|
||||
|
||||
::
|
||||
|
||||
sudo dnf install zoneminder
|
||||
|
||||
Note that RHEL/CentOS 7 users should use yum instead of dnf.
|
||||
|
||||
Once ZoneMinder has been installed, it is critically important that you read the README file under /usr/share/doc/zoneminder. ZoneMinder will not run without completing the steps outlined in the README.
|
||||
|
||||
How to Install ZoneMinder on RHEL/CentOS 6
|
||||
------------------------------------------
|
||||
|
||||
If you are looking to do development or the packages in zmrepo just don't suit you, then you should follow these steps to learn how to build your own ZoneMinder RPM.
|
||||
We continue to encounter build problems, caused by the age of this distro. It is unforuntate, but we can see the writing on the wall. We do not have a date set, but the end of the line for this distros is near.
|
||||
|
||||
Please be advised that we do not recommend any new ZoneMinder installations using CentOS 6. However, for the time being, ZoneMinder rpms will continue to be hosted at `zmrepo <https://www.zoneminder.com>`_.
|
||||
|
||||
How to Install Nightly Development Builds
|
||||
-----------------------------------------
|
||||
|
||||
ZoneMinder development packages, which represent the most recent build from our master branch, are available from `zmrepo <https://www.zoneminder.com>`_.
|
||||
|
||||
The feedback we get from those who use these development packages is extremely helpful. However, please understand these packages are intended for testing the latest master branch only. They are not intended to be used on any production system. There will be new bugs, and new features may not be documented. This is bleeding edge, and there might be breakage. Please keep that in mind when using this repo. We know from our user forum that this can't be stated enough.
|
||||
|
||||
How to Change from Zmrepo to RPM Fusion
|
||||
---------------------------------------
|
||||
|
||||
As mentioned above, the place to get the latest ZoneMinder release is now `RPM Fusion <https://rpmfusion.org>`_. If you are currently using ZoneMinder release packages from Zmrepo, then the following steps will change you over to RPM Fusion:
|
||||
|
||||
- Navigate to the `RPM Fusion site <https://rpmfusion.org>`_ and enable RPM Fusion on your system
|
||||
- Now issue the following from the command line:
|
||||
|
||||
::
|
||||
|
||||
sudo dnf remove zmrepo
|
||||
sudo dnf update
|
||||
|
||||
Note that RHEL/CentOS 7 users should use yum instead of dnf.
|
||||
|
||||
How to Build Your Own ZoneMinder Package
|
||||
------------------------------------------
|
||||
|
||||
If you are looking to do development or the available packages just don't suit you, then you can follow these steps to build your own ZoneMinder RPM.
|
||||
|
||||
Background
|
||||
**********
|
||||
The following method documents how to build ZoneMinder into an RPM package, compatible with Fedora, Redhat, CentOS, and other compatible clones. This is exactly how the RPMS in zmrepo are built.
|
||||
The following method documents how to build ZoneMinder into an RPM package, for Fedora, Redhat, CentOS, and other compatible clones. This is exactly how the RPMS in zmrepo are built.
|
||||
|
||||
The method documented below was chosen because:
|
||||
|
||||
|
@ -67,22 +105,20 @@ The method documented below was chosen because:
|
|||
|
||||
- Troubleshooting becomes easier if we are all building ZoneMinder the same way.
|
||||
|
||||
The build instructions below make use of a custom script called "buildzm.sh". Advanced users are encouraged to view the contents of this script. Notice that the script doesn't really do a whole lot. The goal of the script is to simply make the process a little easier for the first time user. Once you become familar with the build process, you can issue the mock commands found in the buildzm.sh script yourself if you so desire.
|
||||
|
||||
***IMPORTANT***
|
||||
Certain commands in these instructions require root privileges while other commands do not. Pay close attention to this. If the instructions below state to issue a command without a “sudo” prefix, then you should *not* be root while issuing the command. Getting this incorrect will result in a failed build.
|
||||
Certain commands in these instructions require root privileges while other commands do not. Pay close attention to this. If the instructions below state to issue a command without a “sudo” prefix, then you should *not* be root while issuing the command. Getting this incorrect will result in a failed build, or worse a broken system.
|
||||
|
||||
Set Up Your Environment
|
||||
***********************
|
||||
Before you begin, set up an rpmbuild environment by following `this guide <http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment>`_ by the CentOS developers.
|
||||
|
||||
Next, navigate to `Zmrepo <http://zmrepo.zoneminder.com/>`_, and follow the instructions to enable zmrepo on your system.
|
||||
In addition, make sure RPM Fusion is enabled as described in the previous section `How to Install ZoneMinder`_.
|
||||
|
||||
With zmrepo enabled, issue the following command:
|
||||
With RPM Fusion enabled, issue the following command:
|
||||
|
||||
::
|
||||
|
||||
sudo yum install zmrepo-mock-configs mock
|
||||
sudo yum install mock-rpmfusion-free mock
|
||||
|
||||
|
||||
Add your user account to the group mock:
|
||||
|
@ -96,73 +132,67 @@ Your build environment is now set up.
|
|||
|
||||
Build from SRPM
|
||||
***************
|
||||
To continue, you need a ZoneMinder SRPM. For starters, let's use one of the SRPMS from zmrepo. Go browse the `Zmrepo <http://zmrepo.zoneminder.com/>`_ site and choose an appropriate SRPM and place it into the ~/rpmbuild/SRPMS folder.
|
||||
To continue, you need a ZoneMinder SRPM. If you wish to rebuild a ZoneMinder release, then browse the `RPM Fusion site <https://rpmfusion.org/>`_. If instead you wish to rebuild the latest source rpm from our master branch then browse the `Zmrepo site <http://zmrepo.zoneminder.com/>`_.
|
||||
|
||||
For CentOS 7, I have chosen the following SRPM:
|
||||
For this example, I'll use one of the source rpms from zmrepo:
|
||||
|
||||
::
|
||||
|
||||
wget -P ~/rpmbuild/SRPMS http://zmrepo.zoneminder.com/el/7/SRPMS/zoneminder-1.28.1-2.el7.centos.src.rpm
|
||||
wget -P ~/rpmbuild/SRPMS http://zmrepo.zoneminder.com/el/7/SRPMS/zoneminder-1.31.1-1.el7.centos.src.rpm
|
||||
|
||||
|
||||
Now comes the fun part. To build ZoneMinder, issue the following command:
|
||||
|
||||
::
|
||||
|
||||
buildzm.sh zmrepo-el7-x86_64 ~/rpmbuild/SRPMS/zoneminder-1.28.1-2.el7.centos.src.rpm
|
||||
mock -r epel-7-x86_64-rpmfusion_free ~/rpmbuild/SRPMS/zoneminder-1.31.1-1.el7.centos.src.rpm
|
||||
|
||||
|
||||
Want to build ZoneMinder for Fedora, instead of CentOS, from the same host? Once you download the Fedora SRPM, issue the following:
|
||||
|
||||
::
|
||||
|
||||
buildzm.sh zmrepo-f21-x86_64 ~/rpmbuild/SRPMS/zoneminder-1.28.1-1.fc21.src.rpm
|
||||
mock -r fedora-26-x86_64-rpmfusion_free ~/rpmbuild/SRPMS/zoneminder-1.31.1-1.el7.centos.src.rpm
|
||||
|
||||
Notice that the buildzm.sh tool requires the following parameters:
|
||||
Notice that the mock tool requires the following parameters:
|
||||
|
||||
::
|
||||
|
||||
buildzm.sh MOCKCONFIG ZONEMINDER_SRPM
|
||||
mock -r MOCKCONFIG ZONEMINDER_SRPM
|
||||
|
||||
The list of available Mock config files are available here:
|
||||
|
||||
::
|
||||
|
||||
ls /etc/mock/zmrepo*.cfg
|
||||
ls /etc/mock/*rpmfusion_free.cfg
|
||||
|
||||
|
||||
You choose the config file based on the desired distro (e.g. el6, el7, f20, f21) and basearch (e.g. x86, x86_64, arhmhfp). Notice that, when specifying the Mock config as a commandline parameter, you should leave off the ".cfg" filename extension.
|
||||
|
||||
Installation
|
||||
************
|
||||
Once the build completes, you will be presented with a folder containing the RPM's that were built. Copy the newly built ZoneMinder RPM to the desired system, enable zmrepo per the instruction on the `Zmrepo <http://zmrepo.zoneminder.com/>`_
|
||||
website, and then install the rpm by issuing the appropriate yum install command. Finish the installation by following the zoneminder setup instructions in the distro specific readme file, named README.{distroname}, which will be installed into the /usr/share/doc/zoneminder* folder.
|
||||
|
||||
Finally, you may want to consider editing the zmrepo repo file under /etc/yum.repos.d and placing an “exclude=zoneminder*” line into the config file. This will prevent your system from overwriting your manually built RPM with the ZoneMinder RPM found in the repo.
|
||||
|
||||
How to Modify the Source Prior to Build
|
||||
***************************************
|
||||
Before attempting this part of the instructions, make sure and follow the previous instructions for building one of the unmodified SRPMS from zmrepo. Knowing this part works will assist in troubleshooting should something go wrong.
|
||||
|
||||
These instructions may vary depending on what exactly you want to do. The following example assumes you want to build a development snapshot from the master branch.
|
||||
|
||||
From the previous instructions, we downloaded a CentOS 7 ZoneMinder SRPM and placed it into ~/rpmbuild/SRPMS. For this example, install it onto your system:
|
||||
Once the build completes, you will be presented with a message stating where the newly built rpms can be found. It will look similar to this:
|
||||
|
||||
::
|
||||
|
||||
rpm -ivh ~/rpmbuild/SRPMS/zoneminder-1.28.1-2.el7.centos.src.rpm
|
||||
INFO: Results and/or logs in: /var/lib/mock/fedora-26-x86_64/result
|
||||
|
||||
Copy the newly built ZoneMinder RPMs to the desired system, enable RPM Fusion as described in `How to Install ZoneMinder`_, and then install the rpm by issuing the appropriate yum/dnf install command. Finish the installation by following the zoneminder setup instructions in the distro specific readme file, named README.{distroname}, which will be installed into the /usr/share/doc/zoneminder* folder.
|
||||
|
||||
IMPORTANT: This operation must be done with your normal user account. Do *not* perform this command as root.
|
||||
Finally, you may want to consider editing the rpmfusion repo file under /etc/yum.repos.d and placing an “exclude=zoneminder*” line into the config file. This will prevent your system from overwriting your manually built RPM with the ZoneMinder RPM found in the repo.
|
||||
|
||||
Make sure you have git installed:
|
||||
How to Create Your Own Source RPM
|
||||
*********************************
|
||||
In the previous section we described how to rebuild an existing ZoneMinder SRPM. The instructions which follow show how to build the ZoneMinder git source tree into a source rpm, which can be used in the previous section to build an rpm.
|
||||
|
||||
Make sure git and rpmdevtools are installed:
|
||||
|
||||
::
|
||||
|
||||
sudo yum install git
|
||||
sudo yum install git rpmdevtools
|
||||
|
||||
|
||||
Now clone the ZoneMinder git repository:
|
||||
Now clone the ZoneMinder git repository from your home folder:
|
||||
|
||||
::
|
||||
|
||||
|
@ -170,32 +200,62 @@ Now clone the ZoneMinder git repository:
|
|||
git clone https://github.com/ZoneMinder/ZoneMinder
|
||||
cd ZoneMinder
|
||||
|
||||
This will create a sub-folder called ZoneMinder, which will contain the latest development.
|
||||
This will create a sub-folder called ZoneMinder, which will contain the latest development source code.
|
||||
|
||||
We want to turn this into a tarball, but first we need to figure out what to name it. Look here:
|
||||
If you have previsouly cloned the ZoneMinder git repo and wish to update it to the most recent, then issue these commands instead:
|
||||
|
||||
::
|
||||
|
||||
ls ~/rpmbuild/SOURCES
|
||||
|
||||
The tarball from the previsouly installed SRPM should be there. This is the name we will use. For this example, the name is ZoneMinder-1.28.1.tar.gz. From the root folder of the local ZoneMinder git repository, execute the following:
|
||||
cd ~\ZoneMinder
|
||||
git pull origin master
|
||||
|
||||
Get the crud submodule tarball:
|
||||
|
||||
::
|
||||
|
||||
git archive --prefix=ZoneMinder-1.28.1/ -o ~/rpmbuild/SOURCES/zoneminder-1.28.1.tar.gz HEAD
|
||||
spectool -f -g -R -s 1 ~/ZoneMinder/distros/redhat/zoneminder.spec
|
||||
|
||||
Note that we are overwriting the original tarball. If you wish to keep the original tarball then create a copy prior to creating the new tarball.
|
||||
At this point, you can make changes to the source code. Depending on what you want to do with those changes, you generally want to create a new branch first:
|
||||
|
||||
::
|
||||
|
||||
cd ~\ZoneMinder
|
||||
git checkout -b mynewbranch
|
||||
|
||||
Again, depending on what you want to do with those changes, you may want to commit your changes:
|
||||
|
||||
::
|
||||
|
||||
cd ~\ZoneMinder
|
||||
git add .
|
||||
git commit
|
||||
|
||||
Once you have made your changes, it is time to turn your work into a new tarball, but first we need to look in the rpm specfile:
|
||||
|
||||
::
|
||||
|
||||
less ~/ZoneMinder/distros/redhat/zoneminder.spec
|
||||
|
||||
Scroll down until you see the Version field. Note the value, which will be in the format x.xx.x. Now create the tarball with the following command:
|
||||
|
||||
::
|
||||
|
||||
cd ~\ZoneMinder
|
||||
git archive --prefix=ZoneMinder-1.31.1/ -o ~/rpmbuild/SOURCES/zoneminder-1.31.1.tar.gz HEAD
|
||||
|
||||
Replace "1.31.1" with the Version shown in the rpm specfile.
|
||||
|
||||
From the root of the local ZoneMinder git repo, execute the following:
|
||||
|
||||
::
|
||||
|
||||
cd ~\ZoneMinder
|
||||
rpmbuild -bs --nodeps distros/redhat/zoneminder.spec
|
||||
|
||||
Notice we used the rpm specfile that is part of the latest master branch you just downloaded, rather than the one that may be in your ~/rpmbbuild/SOURCES folder.
|
||||
|
||||
This step will overwrite the SRPM you originally downloaded, so you may want to back it up prior to completing this step. Note that the name of the specfile will vary slightly depending on the target distro.
|
||||
|
||||
You should now have a new SRPM under ~/rpmbuild/SRPMS. In our example, the SRPM is called zoneminder-1.28.1-2.el7.centos.src.rpm. Now follow the previous instructions that describe how to use the buildzm script, using ~/rpmbuild/SRPMS/zoneminder-1.28.1-2.el7.centos.src.rpm as the path to your SRPM.
|
||||
This step will create a source rpm and it will tell you where it was saved. For example:
|
||||
|
||||
::
|
||||
|
||||
Wrote: /home/abauer/rpmbuild/SRPMS/zoneminder-1.31.1-1.fc26.src.rpm
|
||||
|
||||
Now follow the previous instructions `Build from SRPM`_ which describe how to build that source rpm into an rpm.
|
||||
|
|
|
@ -16,6 +16,7 @@ configure_file(lib/ZoneMinder/Base.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMi
|
|||
configure_file(lib/ZoneMinder/Config.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Config.pm" @ONLY)
|
||||
configure_file(lib/ZoneMinder/Memory.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Memory.pm" @ONLY)
|
||||
configure_file(lib/ZoneMinder/ConfigData.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ConfigData.pm" @ONLY)
|
||||
configure_file(lib/ZoneMinder/ONVIF.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ONVIF.pm" @ONLY)
|
||||
|
||||
if(CMAKE_VERBOSE_MAKEFILE)
|
||||
set(MAKEMAKER_NOECHO_COMMAND "")
|
||||
|
|
|
@ -101,8 +101,17 @@ BEGIN {
|
|||
} else {
|
||||
$socket = ";host=".$Config{ZM_DB_HOST};
|
||||
}
|
||||
my $sslOptions = "";
|
||||
if ( $Config{ZM_DB_SSL_CA_CERT} ) {
|
||||
$sslOptions = ';'.join(';',
|
||||
"mysql_ssl=1",
|
||||
"mysql_ssl_ca_file=".$Config{ZM_DB_SSL_CA_CERT},
|
||||
"mysql_ssl_client_key=".$Config{ZM_DB_SSL_CLIENT_KEY},
|
||||
"mysql_ssl_client_cert=".$Config{ZM_DB_SSL_CLIENT_CERT}
|
||||
);
|
||||
}
|
||||
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
|
||||
.$socket
|
||||
.$socket.$sslOptions
|
||||
, $Config{ZM_DB_USER}
|
||||
, $Config{ZM_DB_PASS}
|
||||
) or croak( "Can't connect to db" );
|
||||
|
|
|
@ -715,6 +715,25 @@ our @options = (
|
|||
type => $types{boolean},
|
||||
category => 'config',
|
||||
},
|
||||
{
|
||||
name => 'ZM_TIMESTAMP_CODE_CHAR',
|
||||
default => '%',
|
||||
description => 'Character to used to identify timestamp codes',
|
||||
help => q`
|
||||
There are a few codes one can use to tell ZoneMinder to insert
|
||||
data into the timestamp of each image. Traditionally, the
|
||||
percent (%) character has been used to identify these codes since
|
||||
the current character codes do not conflict with the strftime
|
||||
codes, which can also be used in the timestamp. While this works
|
||||
well for Linux, this does not work well for BSD operating systems.
|
||||
Changing the default character to something else, such as an
|
||||
exclamation point (!), resolves the issue. Note this only affects
|
||||
the timestamp codes built into ZoneMinder. It has no effect on
|
||||
the family of strftime codes one can use.
|
||||
`,
|
||||
type => $types{string},
|
||||
category => 'config',
|
||||
},
|
||||
{
|
||||
name => 'ZM_CPU_EXTENSIONS',
|
||||
default => 'yes',
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
|
|
|
@ -90,8 +90,19 @@ sub zmDbConnect {
|
|||
} else {
|
||||
$socket = ";host=".$Config{ZM_DB_HOST};
|
||||
}
|
||||
|
||||
my $sslOptions = "";
|
||||
if ( $Config{ZM_DB_SSL_CA_CERT} ) {
|
||||
$sslOptions = ';'.join(';',
|
||||
"mysql_ssl=1",
|
||||
"mysql_ssl_ca_file=".$Config{ZM_DB_SSL_CA_CERT},
|
||||
"mysql_ssl_client_key=".$Config{ZM_DB_SSL_CLIENT_KEY},
|
||||
"mysql_ssl_client_cert=".$Config{ZM_DB_SSL_CLIENT_CERT}
|
||||
);
|
||||
}
|
||||
|
||||
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
|
||||
.$socket . ($options?';'.join(';', map { $_.'='.$$options{$_} } keys %{$options} ) : '' )
|
||||
.$socket . $sslOptions . ($options?';'.join(';', map { $_.'='.$$options{$_} } keys %{$options} ) : '' )
|
||||
, $Config{ZM_DB_USER}
|
||||
, $Config{ZM_DB_PASS}
|
||||
);
|
||||
|
|
|
@ -238,6 +238,11 @@ sub GenerateVideo {
|
|||
|
||||
sub delete {
|
||||
my $event = $_[0];
|
||||
if ( ! ( $event->{Id} and $event->{MonitorId} and $event->{StartTime} ) ) {
|
||||
my ( $caller, undef, $line ) = caller;
|
||||
Warning( "Can't Delete event $event->{Id} from Monitor $event->{MonitorId} $event->{StartTime} from $caller:$line\n" );
|
||||
return;
|
||||
}
|
||||
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
|
||||
|
|
|
@ -438,8 +438,17 @@ sub databaseLevel {
|
|||
} else {
|
||||
$socket = ";host=".$Config{ZM_DB_HOST};
|
||||
}
|
||||
my $sslOptions = "";
|
||||
if ( $Config{ZM_DB_SSL_CA_CERT} ) {
|
||||
$sslOptions = ';'.join(';',
|
||||
"mysql_ssl=1",
|
||||
"mysql_ssl_ca_file=".$Config{ZM_DB_SSL_CA_CERT},
|
||||
"mysql_ssl_client_key=".$Config{ZM_DB_SSL_CLIENT_KEY},
|
||||
"mysql_ssl_client_cert=".$Config{ZM_DB_SSL_CLIENT_CERT}
|
||||
);
|
||||
}
|
||||
$this->{dbh} = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
|
||||
.$socket
|
||||
.$socket.$sslOptions
|
||||
, $Config{ZM_DB_USER}
|
||||
, $Config{ZM_DB_PASS}
|
||||
);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
|
|
|
@ -48,6 +48,8 @@ our $VERSION = $ZoneMinder::Base::VERSION;
|
|||
use Getopt::Std;
|
||||
use Data::UUID;
|
||||
|
||||
use vars qw( $verbose $soap_version );
|
||||
|
||||
require ONVIF::Client;
|
||||
|
||||
require WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort;
|
||||
|
@ -77,33 +79,35 @@ sub deserialize_message {
|
|||
|
||||
# Try deserializing response - there may be some,
|
||||
# even if transport did not succeed (got a 500 response)
|
||||
if ( $response ) {
|
||||
if ( ! $response ) {
|
||||
return;
|
||||
}
|
||||
|
||||
# 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 ($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"
|
||||
});
|
||||
} # end sub deserialize_message
|
||||
|
||||
sub interpret_messages {
|
||||
my ($svc_discover, $services, @responses ) = @_;
|
||||
|
||||
my @results;
|
||||
|
@ -167,6 +171,7 @@ ub interpret_messages {
|
|||
# functions
|
||||
|
||||
sub discover {
|
||||
my ( $soap_version ) = @_;
|
||||
my @results;
|
||||
|
||||
## collect all responses
|
||||
|
@ -246,6 +251,8 @@ sub discover {
|
|||
}
|
||||
|
||||
sub profiles {
|
||||
my ( $client ) = @_;
|
||||
|
||||
my $result = $client->get_endpoint('media')->GetProfiles( { } ,, );
|
||||
die $result if not $result;
|
||||
if($verbose) {
|
||||
|
@ -293,7 +300,7 @@ sub profiles {
|
|||
}
|
||||
|
||||
sub move {
|
||||
my ($dir) = @_;
|
||||
my ($client, $dir) = @_;
|
||||
|
||||
my $result = $client->get_endpoint('ptz')->GetNodes( { } ,, );
|
||||
|
||||
|
@ -302,6 +309,7 @@ sub move {
|
|||
} # end sub move
|
||||
|
||||
sub metadata {
|
||||
my ( $client ) = @_;
|
||||
my $result = $client->get_endpoint('media')->GetMetadataConfigurations( { } ,, );
|
||||
die $result if not $result;
|
||||
print $result . "\n";
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
|
|
|
@ -144,15 +144,16 @@ MAIN: while( $loop ) {
|
|||
# After a long sleep, we may need to reconnect to the db
|
||||
while ( ! ( $dbh and $dbh->ping() ) ) {
|
||||
$dbh = zmDbConnect();
|
||||
|
||||
if ( $continuous ) {
|
||||
Error('Unable to connect to database');
|
||||
# if we are running continuously, then just skip to the next
|
||||
# interval, otherwise we are a one off run, so wait a second and
|
||||
# retry until someone kills us.
|
||||
sleep( $Config{ZM_AUDIT_CHECK_INTERVAL} );
|
||||
} else {
|
||||
Fatal('Unable to connect to database');
|
||||
if ( ! $dbh ) {
|
||||
if ( $continuous ) {
|
||||
Error('Unable to connect to database');
|
||||
# if we are running continuously, then just skip to the next
|
||||
# interval, otherwise we are a one off run, so wait a second and
|
||||
# retry until someone kills us.
|
||||
sleep( $Config{ZM_AUDIT_CHECK_INTERVAL} );
|
||||
} else {
|
||||
Fatal('Unable to connect to database');
|
||||
} # end if
|
||||
} # end if
|
||||
} # end while can't connect to the db
|
||||
|
||||
|
@ -270,7 +271,7 @@ MAIN: while( $loop ) {
|
|||
} # end foreach event
|
||||
chdir( $Storage->Path() );
|
||||
} # if USE_DEEP_STORAGE
|
||||
Debug( 'Got '.int(keys(%$fs_events))." events for monitor $monitor_dir\n" );
|
||||
Debug( 'Got '.int(keys(%$fs_events))." filesystem events for monitor $monitor_dir\n" );
|
||||
|
||||
#delete_empty_directories( $monitor_dir );
|
||||
} # end foreach monitor
|
||||
|
@ -349,7 +350,11 @@ MAIN: while( $loop ) {
|
|||
while ( my ( $db_event, $age ) = each( %$db_events ) ) {
|
||||
if ( ! defined( $fs_events->{$db_event} ) ) {
|
||||
Debug("Event $db_event is not in fs.");
|
||||
my $Event = new ZoneMinder::Event( $db_event );
|
||||
my $Event = ZoneMinder::Event->find_one( Id=>$db_event );
|
||||
if ( ! $Event ) {
|
||||
Debug("Event $db_event is no longer in db. Filter probably deleted it while we were auditing.");
|
||||
next;
|
||||
}
|
||||
if ( ! $Event->StartTime() ) {
|
||||
Debug("Event $$Event{Id} has no start time. deleting it.");
|
||||
if ( confirm() ) {
|
||||
|
|
|
@ -143,11 +143,11 @@ while( 1 ) {
|
|||
if ( !defined($image_time) ) {
|
||||
# Can't read from shared data
|
||||
$restart = 1;
|
||||
Error( "Error reading shared data for $$monitor{id} $$monitor{Name}\n");
|
||||
Error( "Error reading shared data for $$monitor{Id} $$monitor{Name}\n");
|
||||
} elsif ( !$image_time ) {
|
||||
# We can't get the last capture time so can't be sure it's died.
|
||||
$restart = 1;
|
||||
Error( "Error getting last capture time for $$monitor{id} $$monitor{Name}\n");
|
||||
Error( "Error getting last capture time for $$monitor{Id} $$monitor{Name}\n");
|
||||
} else {
|
||||
|
||||
my $max_image_delay = ( $monitor->{MaxFPS}
|
||||
|
@ -159,7 +159,7 @@ while( 1 ) {
|
|||
my $image_delay = $now-$image_time;
|
||||
Debug( "Monitor $monitor->{Id} last analysed $image_delay seconds ago, max is $max_image_delay\n" );
|
||||
if ( $image_delay > $max_image_delay ) {
|
||||
Info( "Analysis daemon for $$monitor{id} $$monitor{Name} needs restarting,"
|
||||
Info( "Analysis daemon for $$monitor{Id} $$monitor{Name} needs restarting,"
|
||||
." time since last analysis $image_delay seconds ($now-$image_time)\n"
|
||||
);
|
||||
$restart = 1;
|
||||
|
@ -167,7 +167,7 @@ while( 1 ) {
|
|||
}
|
||||
|
||||
if ( $restart ) {
|
||||
Info( "Restarting analysis daemon for $$monitor{id} $$monitor{Name}\n");
|
||||
Info( "Restarting analysis daemon for $$monitor{Id} $$monitor{Name}\n");
|
||||
my $command = "zmdc.pl restart zma -m ".$monitor->{Id};
|
||||
runCommand( $command );
|
||||
} # end if restart
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
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)
|
||||
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_eventstream.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_input.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)
|
||||
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_eventstream.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_input.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_swscale.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.
|
||||
add_library(zm STATIC ${ZM_BIN_SRC_FILES})
|
||||
|
|
|
@ -153,6 +153,12 @@ void process_configfile( char* configFile) {
|
|||
staticConfig.DB_USER = std::string(val_ptr);
|
||||
else if ( strcasecmp( name_ptr, "ZM_DB_PASS" ) == 0 )
|
||||
staticConfig.DB_PASS = std::string(val_ptr);
|
||||
else if ( strcasecmp( name_ptr, "ZM_DB_SSL_CA_CERT" ) == 0 )
|
||||
staticConfig.DB_SSL_CA_CERT = std::string(val_ptr);
|
||||
else if ( strcasecmp( name_ptr, "ZM_DB_SSL_CLIENT_KEY" ) == 0 )
|
||||
staticConfig.DB_SSL_CLIENT_KEY = std::string(val_ptr);
|
||||
else if ( strcasecmp( name_ptr, "ZM_DB_SSL_CLIENT_CERT" ) == 0 )
|
||||
staticConfig.DB_SSL_CLIENT_CERT = std::string(val_ptr);
|
||||
else if ( strcasecmp( name_ptr, "ZM_PATH_WEB" ) == 0 )
|
||||
staticConfig.PATH_WEB = std::string(val_ptr);
|
||||
else if ( strcasecmp( name_ptr, "ZM_SERVER_HOST" ) == 0 )
|
||||
|
@ -288,8 +294,10 @@ Config::~Config() {
|
|||
if ( items ) {
|
||||
for ( int i = 0; i < n_items; i++ ) {
|
||||
delete items[i];
|
||||
items[i] = NULL;
|
||||
}
|
||||
delete[] items;
|
||||
items = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,9 @@ struct StaticConfig
|
|||
std::string DB_NAME;
|
||||
std::string DB_USER;
|
||||
std::string DB_PASS;
|
||||
std::string DB_SSL_CA_CERT;
|
||||
std::string DB_SSL_CLIENT_KEY;
|
||||
std::string DB_SSL_CLIENT_CERT;
|
||||
std::string PATH_WEB;
|
||||
std::string SERVER_NAME;
|
||||
unsigned int SERVER_ID;
|
||||
|
|
|
@ -38,6 +38,8 @@ void zmDbConnect() {
|
|||
my_bool reconnect = 1;
|
||||
if ( mysql_options( &dbconn, MYSQL_OPT_RECONNECT, &reconnect ) )
|
||||
Fatal( "Can't set database auto reconnect option: %s", mysql_error( &dbconn ) );
|
||||
if ( !staticConfig.DB_SSL_CA_CERT.empty() )
|
||||
mysql_ssl_set( &dbconn, staticConfig.DB_SSL_CLIENT_KEY.c_str(), staticConfig.DB_SSL_CLIENT_CERT.c_str(), staticConfig.DB_SSL_CA_CERT.c_str(), NULL, NULL );
|
||||
std::string::size_type colonIndex = staticConfig.DB_HOST.find( ":" );
|
||||
if ( colonIndex == std::string::npos ) {
|
||||
if ( !mysql_real_connect( &dbconn, staticConfig.DB_HOST.c_str(), staticConfig.DB_USER.c_str(), staticConfig.DB_PASS.c_str(), NULL, 0, NULL, 0 ) ) {
|
||||
|
|
|
@ -204,6 +204,7 @@ bool EventStream::loadEventData( int event_id ) {
|
|||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
mysql_free_result( result );
|
||||
//for ( int i = 0; i < 250; i++ )
|
||||
//{
|
||||
//Info( "%d -> %d @ %f (%d)", i+1, event_data->frames[i].timestamp, event_data->frames[i].delta, event_data->frames[i].in_db );
|
||||
|
@ -213,13 +214,13 @@ bool EventStream::loadEventData( int event_id ) {
|
|||
char filepath[PATH_MAX];
|
||||
snprintf( filepath, sizeof(filepath), "%s/%s", event_data->path, event_data->video_file );
|
||||
ffmpeg_input = new FFmpeg_Input();
|
||||
if ( ! ffmpeg_input->Open( filepath ) ) {
|
||||
if ( 0 > ffmpeg_input->Open( filepath ) ) {
|
||||
Warning("Unable to open ffmpeg_input %s/%s", event_data->path, event_data->video_file );
|
||||
delete ffmpeg_input;
|
||||
ffmpeg_input = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
mysql_free_result( result );
|
||||
|
||||
if ( forceEventChange || mode == MODE_ALL_GAPLESS ) {
|
||||
if ( replay_rate > 0 )
|
||||
|
@ -230,7 +231,7 @@ bool EventStream::loadEventData( int event_id ) {
|
|||
Debug( 2, "Event:%ld, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration );
|
||||
|
||||
return( true );
|
||||
}
|
||||
} // bool EventStream::loadEventData( int event_id )
|
||||
|
||||
void EventStream::processCommand( const CmdMsg *msg ) {
|
||||
Debug( 2, "Got message, type %d, msg %d", msg->msg_type, msg->msg_data[0] );
|
||||
|
@ -412,6 +413,7 @@ void EventStream::processCommand( const CmdMsg *msg ) {
|
|||
}
|
||||
send_frame = true;
|
||||
break;
|
||||
send_frame = true;
|
||||
}
|
||||
case CMD_PAN :
|
||||
{
|
||||
|
@ -598,8 +600,9 @@ bool EventStream::sendFrame( int delta_us ) {
|
|||
} else if ( monitor->GetOptSaveJPEGs() & 2 ) {
|
||||
snprintf( filepath, sizeof(filepath), Event::analyse_file_format, event_data->path, curr_frame_id );
|
||||
if ( stat( filepath, &filestat ) < 0 ) {
|
||||
Debug(1, "%s not found, dalling back to capture");
|
||||
Debug(1, "analyze file %s not found will try to stream from other", filepath);
|
||||
snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id );
|
||||
filepath[0] = 0;
|
||||
}
|
||||
} else if ( ! ffmpeg_input ) {
|
||||
Fatal("JPEGS not saved.zms is not capable of streaming jpegs from mp4 yet");
|
||||
|
@ -666,12 +669,40 @@ bool EventStream::sendFrame( int delta_us ) {
|
|||
int img_buffer_size = 0;
|
||||
uint8_t *img_buffer = temp_img_buffer;
|
||||
|
||||
bool send_raw = ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE)) && filepath[0];
|
||||
|
||||
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
||||
|
||||
if ( type != STREAM_JPEG )
|
||||
send_raw = false;
|
||||
|
||||
if ( send_raw ) {
|
||||
if ( ! send_file( filepath ) ) {
|
||||
Error( "Can't send %s: %s", filepath, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
} else {
|
||||
Image *image = NULL;
|
||||
|
||||
if ( filepath[0] ) {
|
||||
image = new Image( filepath );
|
||||
} else if ( ffmpeg_input ) {
|
||||
// Get the frame from the mp4 input
|
||||
Debug(1,"Getting frame from ffmpeg");
|
||||
AVFrame *frame = ffmpeg_input->get_frame( ffmpeg_input->get_video_stream_id() );
|
||||
if ( frame ) {
|
||||
image = new Image( frame );
|
||||
av_frame_free(&frame);
|
||||
} else {
|
||||
Error("Failed getting a frame.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Error("Unable to get a frame");
|
||||
return false;
|
||||
}
|
||||
|
||||
Image *send_image = prepareImage( image );
|
||||
|
||||
switch( type ) {
|
||||
case STREAM_JPEG :
|
||||
|
@ -692,25 +723,74 @@ bool EventStream::sendFrame( int delta_us ) {
|
|||
default:
|
||||
Fatal( "Unexpected frame type %d", type );
|
||||
break;
|
||||
} // end switch type
|
||||
send_buffer( img_buffer, img_buffer_size );
|
||||
}
|
||||
delete image;
|
||||
image = NULL;
|
||||
}
|
||||
|
||||
switch( type ) {
|
||||
case STREAM_JPEG :
|
||||
fprintf( stdout, "Content-Type: image/jpeg\r\n" );
|
||||
break;
|
||||
case STREAM_RAW :
|
||||
fprintf( stdout, "Content-Type: image/x-rgb\r\n" );
|
||||
break;
|
||||
case STREAM_ZIP :
|
||||
fprintf( stdout, "Content-Type: image/x-rgbz\r\n" );
|
||||
break;
|
||||
default :
|
||||
Fatal( "Unexpected frame type %d", type );
|
||||
break;
|
||||
}
|
||||
|
||||
} // endif send_raw or not
|
||||
} // mpeg_output or jpeg
|
||||
|
||||
fprintf( stdout, "\r\n\r\n" );
|
||||
fflush( stdout );
|
||||
if ( send_raw ) {
|
||||
#if HAVE_SENDFILE
|
||||
fprintf( stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size );
|
||||
if ( zm_sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size) != (int)filestat.st_size ) {
|
||||
/* sendfile() failed, use standard way instead */
|
||||
img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj );
|
||||
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
|
||||
Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno));
|
||||
return( false );
|
||||
}
|
||||
}
|
||||
#else
|
||||
fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size );
|
||||
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
|
||||
Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno));
|
||||
return( false );
|
||||
}
|
||||
#endif
|
||||
fclose(fdj); /* Close the file handle */
|
||||
} else {
|
||||
Debug(3, "Content length: %d", img_buffer_size );
|
||||
fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size );
|
||||
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
|
||||
Error( "Unable to send stream frame: %s", strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
}
|
||||
|
||||
fprintf( stdout, "\r\n\r\n" );
|
||||
fflush( stdout );
|
||||
}
|
||||
last_frame_sent = TV_2_FLOAT( now );
|
||||
return( true );
|
||||
}
|
||||
|
||||
void EventStream::runStream() {
|
||||
Event::Initialise();
|
||||
Debug(3, "Initialized");
|
||||
|
||||
openComms();
|
||||
Debug(3, "Comms open");
|
||||
|
||||
checkInitialised();
|
||||
|
||||
Debug(3, "frame rate is: (%f)", (double)event_data->frame_count/event_data->duration );
|
||||
updateFrameRate( (double)event_data->frame_count/event_data->duration );
|
||||
|
||||
if ( type == STREAM_JPEG )
|
||||
|
@ -733,6 +813,7 @@ void EventStream::runStream() {
|
|||
if ( step != 0 )
|
||||
curr_frame_id += step;
|
||||
|
||||
// Detects when we hit end of event and will load the next event or previous event
|
||||
checkEventLoaded();
|
||||
|
||||
// Get current frame data
|
||||
|
@ -771,6 +852,7 @@ void EventStream::runStream() {
|
|||
}
|
||||
|
||||
// Figure out if we should send this frame
|
||||
|
||||
// If we are streaming and this frame is due to be sent
|
||||
if ( ((curr_frame_id-1)%frame_mod) == 0 ) {
|
||||
delta_us = (unsigned int)(frame_data->delta * 1000000);
|
||||
|
@ -784,7 +866,7 @@ void EventStream::runStream() {
|
|||
// We are paused and are just stepping forward or backward one frame
|
||||
step = 0;
|
||||
send_frame = true;
|
||||
} else {
|
||||
} else if ( !send_frame ) {
|
||||
// We are paused, and doing nothing
|
||||
double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent;
|
||||
if ( actual_delta_time > MAX_STREAM_DELAY ) {
|
||||
|
|
|
@ -130,181 +130,6 @@ int av_dict_parse_string(AVDictionary **pm, const char *str,
|
|||
#endif
|
||||
#endif // HAVE_LIBAVUTIL
|
||||
|
||||
#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
SWScale::SWScale() : gotdefaults(false), swscale_ctx(NULL), input_avframe(NULL), output_avframe(NULL) {
|
||||
Debug(4,"SWScale object created");
|
||||
|
||||
/* Allocate AVFrame for the input */
|
||||
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
|
||||
input_avframe = av_frame_alloc();
|
||||
#else
|
||||
input_avframe = avcodec_alloc_frame();
|
||||
#endif
|
||||
if(input_avframe == NULL) {
|
||||
Fatal("Failed allocating AVFrame for the input");
|
||||
}
|
||||
|
||||
/* Allocate AVFrame for the output */
|
||||
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
|
||||
output_avframe = av_frame_alloc();
|
||||
#else
|
||||
output_avframe = avcodec_alloc_frame();
|
||||
#endif
|
||||
if(output_avframe == NULL) {
|
||||
Fatal("Failed allocating AVFrame for the output");
|
||||
}
|
||||
}
|
||||
|
||||
SWScale::~SWScale() {
|
||||
|
||||
/* Free up everything */
|
||||
av_frame_free( &input_avframe );
|
||||
//input_avframe = NULL;
|
||||
|
||||
av_frame_free( &output_avframe );
|
||||
//output_avframe = NULL;
|
||||
|
||||
if(swscale_ctx) {
|
||||
sws_freeContext(swscale_ctx);
|
||||
swscale_ctx = NULL;
|
||||
}
|
||||
|
||||
Debug(4,"SWScale object destroyed");
|
||||
}
|
||||
|
||||
int SWScale::SetDefaults(enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
|
||||
|
||||
/* Assign the defaults */
|
||||
default_input_pf = in_pf;
|
||||
default_output_pf = out_pf;
|
||||
default_width = width;
|
||||
default_height = height;
|
||||
|
||||
gotdefaults = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
|
||||
/* Parameter checking */
|
||||
if(in_buffer == NULL || out_buffer == NULL) {
|
||||
Error("NULL Input or output buffer");
|
||||
return -1;
|
||||
}
|
||||
// if(in_pf == 0 || out_pf == 0) {
|
||||
// Error("Invalid input or output pixel formats");
|
||||
// return -2;
|
||||
// }
|
||||
if (!width || !height) {
|
||||
Error("Invalid width or height");
|
||||
return -3;
|
||||
}
|
||||
|
||||
#if LIBSWSCALE_VERSION_CHECK(0, 8, 0, 8, 0)
|
||||
/* Warn if the input or output pixelformat is not supported */
|
||||
if(!sws_isSupportedInput(in_pf)) {
|
||||
Warning("swscale does not support the input format: %c%c%c%c",(in_pf)&0xff,((in_pf)&0xff),((in_pf>>16)&0xff),((in_pf>>24)&0xff));
|
||||
}
|
||||
if(!sws_isSupportedOutput(out_pf)) {
|
||||
Warning("swscale does not support the output format: %c%c%c%c",(out_pf)&0xff,((out_pf>>8)&0xff),((out_pf>>16)&0xff),((out_pf>>24)&0xff));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check the buffer sizes */
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
size_t insize = av_image_get_buffer_size(in_pf, width, height,1);
|
||||
#else
|
||||
size_t insize = avpicture_get_size(in_pf, width, height);
|
||||
#endif
|
||||
if(insize != in_buffer_size) {
|
||||
Error("The input buffer size does not match the expected size for the input format. Required: %d Available: %d", insize, in_buffer_size);
|
||||
return -4;
|
||||
}
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
size_t outsize = av_image_get_buffer_size(out_pf, width, height,1);
|
||||
#else
|
||||
size_t outsize = avpicture_get_size(out_pf, width, height);
|
||||
#endif
|
||||
|
||||
if(outsize < out_buffer_size) {
|
||||
Error("The output buffer is undersized for the output format. Required: %d Available: %d", outsize, out_buffer_size);
|
||||
return -5;
|
||||
}
|
||||
|
||||
/* Get the context */
|
||||
swscale_ctx = sws_getCachedContext( swscale_ctx, width, height, in_pf, width, height, out_pf, SWS_FAST_BILINEAR, NULL, NULL, NULL );
|
||||
if(swscale_ctx == NULL) {
|
||||
Error("Failed getting swscale context");
|
||||
return -6;
|
||||
}
|
||||
|
||||
/* Fill in the buffers */
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
if (av_image_fill_arrays(input_avframe->data, input_avframe->linesize,
|
||||
(uint8_t*) in_buffer, in_pf, width, height, 1) <= 0) {
|
||||
#else
|
||||
if (avpicture_fill((AVPicture*) input_avframe, (uint8_t*) in_buffer,
|
||||
in_pf, width, height) <= 0) {
|
||||
#endif
|
||||
Error("Failed filling input frame with input buffer");
|
||||
return -7;
|
||||
}
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
if (av_image_fill_arrays(output_avframe->data, output_avframe->linesize,
|
||||
out_buffer, out_pf, width, height, 1) <= 0) {
|
||||
#else
|
||||
if (avpicture_fill((AVPicture*) output_avframe, out_buffer, out_pf, width,
|
||||
height) <= 0) {
|
||||
#endif
|
||||
Error("Failed filling output frame with output buffer");
|
||||
return -8;
|
||||
}
|
||||
|
||||
/* Do the conversion */
|
||||
if(!sws_scale(swscale_ctx, input_avframe->data, input_avframe->linesize, 0, height, output_avframe->data, output_avframe->linesize ) ) {
|
||||
Error("swscale conversion failed");
|
||||
return -10;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SWScale::Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
|
||||
if(img->Width() != width) {
|
||||
Error("Source image width differs. Source: %d Output: %d",img->Width(), width);
|
||||
return -12;
|
||||
}
|
||||
|
||||
if(img->Height() != height) {
|
||||
Error("Source image height differs. Source: %d Output: %d",img->Height(), height);
|
||||
return -13;
|
||||
}
|
||||
|
||||
return Convert(img->Buffer(),img->Size(),out_buffer,out_buffer_size,in_pf,out_pf,width,height);
|
||||
}
|
||||
|
||||
int SWScale::ConvertDefaults(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size) {
|
||||
|
||||
if(!gotdefaults) {
|
||||
Error("Defaults are not set");
|
||||
return -24;
|
||||
}
|
||||
|
||||
return Convert(img,out_buffer,out_buffer_size,default_input_pf,default_output_pf,default_width,default_height);
|
||||
}
|
||||
|
||||
int SWScale::ConvertDefaults(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size) {
|
||||
|
||||
if(!gotdefaults) {
|
||||
Error("Defaults are not set");
|
||||
return -24;
|
||||
}
|
||||
|
||||
return Convert(in_buffer,in_buffer_size,out_buffer,out_buffer_size,default_input_pf,default_output_pf,default_width,default_height);
|
||||
}
|
||||
#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
|
||||
|
||||
#endif // HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE
|
||||
|
||||
#if HAVE_LIBAVUTIL
|
||||
|
@ -560,5 +385,3 @@ bool is_audio_stream( AVStream * stream ) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@
|
|||
#define ZM_FFMPEG_H
|
||||
#include <stdint.h>
|
||||
#include "zm.h"
|
||||
#include "zm_image.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// AVUTIL
|
||||
#if HAVE_LIBAVUTIL_AVUTIL_H
|
||||
|
@ -207,31 +204,6 @@ void FFMPEGInit();
|
|||
enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder);
|
||||
#endif // HAVE_LIBAVUTIL
|
||||
|
||||
|
||||
/* SWScale wrapper class to make our life easier and reduce code reuse */
|
||||
#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
class SWScale {
|
||||
public:
|
||||
SWScale();
|
||||
~SWScale();
|
||||
int SetDefaults(enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
|
||||
int ConvertDefaults(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size);
|
||||
int ConvertDefaults(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size);
|
||||
int Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
|
||||
int Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
|
||||
|
||||
protected:
|
||||
bool gotdefaults;
|
||||
struct SwsContext* swscale_ctx;
|
||||
AVFrame* input_avframe;
|
||||
AVFrame* output_avframe;
|
||||
enum _AVPIXELFORMAT default_input_pf;
|
||||
enum _AVPIXELFORMAT default_output_pf;
|
||||
unsigned int default_width;
|
||||
unsigned int default_height;
|
||||
};
|
||||
#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
|
||||
#if !LIBAVCODEC_VERSION_CHECK(54, 25, 0, 51, 100)
|
||||
#define AV_CODEC_ID_NONE CODEC_ID_NONE
|
||||
#define AV_CODEC_ID_PCM_MULAW CODEC_ID_PCM_MULAW
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
|
||||
extern "C" {
|
||||
#include "libavutil/time.h"
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/hwcontext_qsv.h"
|
||||
#endif
|
||||
}
|
||||
#ifndef AV_ERROR_MAX_STRING_SIZE
|
||||
#define AV_ERROR_MAX_STRING_SIZE 64
|
||||
|
@ -36,6 +40,47 @@ extern "C" {
|
|||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
static AVPixelFormat get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) {
|
||||
while (*pix_fmts != AV_PIX_FMT_NONE) {
|
||||
if (*pix_fmts == AV_PIX_FMT_QSV) {
|
||||
DecodeContext *decode = (DecodeContext *)avctx->opaque;
|
||||
AVHWFramesContext *frames_ctx;
|
||||
AVQSVFramesContext *frames_hwctx;
|
||||
int ret;
|
||||
|
||||
/* create a pool of surfaces to be used by the decoder */
|
||||
avctx->hw_frames_ctx = av_hwframe_ctx_alloc(decode->hw_device_ref);
|
||||
if (!avctx->hw_frames_ctx)
|
||||
return AV_PIX_FMT_NONE;
|
||||
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
|
||||
frames_hwctx = (AVQSVFramesContext*)frames_ctx->hwctx;
|
||||
|
||||
frames_ctx->format = AV_PIX_FMT_QSV;
|
||||
frames_ctx->sw_format = avctx->sw_pix_fmt;
|
||||
frames_ctx->width = FFALIGN(avctx->coded_width, 32);
|
||||
frames_ctx->height = FFALIGN(avctx->coded_height, 32);
|
||||
frames_ctx->initial_pool_size = 32;
|
||||
|
||||
frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
|
||||
|
||||
ret = av_hwframe_ctx_init(avctx->hw_frames_ctx);
|
||||
if (ret < 0)
|
||||
return AV_PIX_FMT_NONE;
|
||||
|
||||
return AV_PIX_FMT_QSV;
|
||||
}
|
||||
|
||||
pix_fmts++;
|
||||
}
|
||||
|
||||
Error( "The QSV pixel format not offered in get_format()");
|
||||
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) :
|
||||
Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
|
||||
mPath( p_path ),
|
||||
|
@ -46,6 +91,12 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri
|
|||
Initialise();
|
||||
}
|
||||
|
||||
hwaccel = false;
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
decode = { NULL };
|
||||
hwFrame = NULL;
|
||||
#endif
|
||||
|
||||
mFormatContext = NULL;
|
||||
mVideoStreamId = -1;
|
||||
mAudioStreamId = -1;
|
||||
|
@ -63,18 +114,19 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri
|
|||
mReopenThread = 0;
|
||||
videoStore = NULL;
|
||||
video_last_pts = 0;
|
||||
have_video_keyframe = false;
|
||||
|
||||
#if HAVE_LIBSWSCALE
|
||||
mConvertContext = NULL;
|
||||
#endif
|
||||
/* Has to be located inside the constructor so other components such as zma will receive correct colours and subpixel order */
|
||||
if(colours == ZM_COLOUR_RGB32) {
|
||||
if ( colours == ZM_COLOUR_RGB32 ) {
|
||||
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
|
||||
imagePixFormat = AV_PIX_FMT_RGBA;
|
||||
} else if(colours == ZM_COLOUR_RGB24) {
|
||||
} else if ( colours == ZM_COLOUR_RGB24 ) {
|
||||
subpixelorder = ZM_SUBPIX_ORDER_RGB;
|
||||
imagePixFormat = AV_PIX_FMT_RGB24;
|
||||
} else if(colours == ZM_COLOUR_GRAY8) {
|
||||
} else if ( colours == ZM_COLOUR_GRAY8 ) {
|
||||
subpixelorder = ZM_SUBPIX_ORDER_NONE;
|
||||
imagePixFormat = AV_PIX_FMT_GRAY8;
|
||||
} else {
|
||||
|
@ -93,6 +145,7 @@ FfmpegCamera::~FfmpegCamera() {
|
|||
if ( capture ) {
|
||||
Terminate();
|
||||
}
|
||||
avformat_network_deinit();
|
||||
}
|
||||
|
||||
void FfmpegCamera::Initialise() {
|
||||
|
@ -113,30 +166,36 @@ int FfmpegCamera::PrimeCapture() {
|
|||
mAudioStreamId = -1;
|
||||
Info( "Priming capture from %s", mPath.c_str() );
|
||||
|
||||
if (OpenFfmpeg() != 0){
|
||||
#if THREAD
|
||||
if ( OpenFfmpeg() != 0 ) {
|
||||
ReopenFfmpeg();
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
return OpenFfmpeg();
|
||||
#endif
|
||||
}
|
||||
|
||||
int FfmpegCamera::PreCapture()
|
||||
{
|
||||
int FfmpegCamera::PreCapture() {
|
||||
// If Reopen was called, then ffmpeg is closed and we need to reopen it.
|
||||
if ( ! mCanCapture )
|
||||
return OpenFfmpeg();
|
||||
// Nothing to do here
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int FfmpegCamera::Capture( Image &image ) {
|
||||
if (!mCanCapture){
|
||||
if ( ! mCanCapture ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If the reopen thread has a value, but mCanCapture != 0, then we have just reopened the connection to the ffmpeg device, and we can clean up the thread.
|
||||
if (mReopenThread != 0) {
|
||||
if ( mReopenThread != 0 ) {
|
||||
void *retval = 0;
|
||||
int ret;
|
||||
|
||||
ret = pthread_join(mReopenThread, &retval);
|
||||
if (ret != 0){
|
||||
if ( ret != 0 ) {
|
||||
Error("Could not join reopen thread.");
|
||||
}
|
||||
|
||||
|
@ -164,9 +223,14 @@ int FfmpegCamera::Capture( Image &image ) {
|
|||
Error( "Unable to read packet from stream %d: error %d \"%s\".", packet.stream_index, avResult, errbuf );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
int keyframe = packet.flags & AV_PKT_FLAG_KEY;
|
||||
if ( keyframe )
|
||||
have_video_keyframe = true;
|
||||
|
||||
Debug( 5, "Got packet from stream %d dts (%d) pts(%d)", packet.stream_index, packet.pts, packet.dts );
|
||||
// What about audio stream? Maybe someday we could do sound detection...
|
||||
if ( packet.stream_index == mVideoStreamId ) {
|
||||
if ( ( packet.stream_index == mVideoStreamId ) && ( keyframe || have_video_keyframe ) ) {
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
ret = avcodec_send_packet( mVideoCodecContext, &packet );
|
||||
if ( ret < 0 ) {
|
||||
|
@ -175,13 +239,37 @@ int FfmpegCamera::Capture( Image &image ) {
|
|||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
ret = avcodec_receive_frame( mVideoCodecContext, mRawFrame );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
if ( hwaccel ) {
|
||||
ret = avcodec_receive_frame( mVideoCodecContext, hwFrame );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
ret = av_hwframe_transfer_data(mRawFrame, hwFrame, 0);
|
||||
if (ret < 0) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to transfer frame at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
ret = avcodec_receive_frame( mVideoCodecContext, mRawFrame );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
}
|
||||
#endif
|
||||
|
||||
frameComplete = 1;
|
||||
# else
|
||||
ret = zm_avcodec_decode_video( mVideoCodecContext, mRawFrame, &frameComplete, &packet );
|
||||
|
@ -202,7 +290,7 @@ int FfmpegCamera::Capture( Image &image ) {
|
|||
|
||||
/* Request a writeable buffer of the target image */
|
||||
directbuffer = image.WriteBuffer(width, height, colours, subpixelorder);
|
||||
if(directbuffer == NULL) {
|
||||
if ( directbuffer == NULL ) {
|
||||
Error("Failed requesting writeable buffer for the captured image.");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -216,21 +304,10 @@ int FfmpegCamera::Capture( Image &image ) {
|
|||
#endif
|
||||
|
||||
#if HAVE_LIBSWSCALE
|
||||
if(mConvertContext == NULL) {
|
||||
mConvertContext = sws_getContext(mVideoCodecContext->width,
|
||||
mVideoCodecContext->height,
|
||||
mVideoCodecContext->pix_fmt,
|
||||
width, height, imagePixFormat,
|
||||
SWS_BICUBIC, NULL, NULL, NULL);
|
||||
|
||||
if(mConvertContext == NULL)
|
||||
Fatal( "Unable to create conversion context for %s", mPath.c_str() );
|
||||
}
|
||||
|
||||
if (sws_scale(mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mVideoCodecContext->height, mFrame->data, mFrame->linesize) < 0)
|
||||
if ( sws_scale(mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mVideoCodecContext->height, mFrame->data, mFrame->linesize) < 0 )
|
||||
Fatal("Unable to convert raw format %u to target format %u at frame %d", mVideoCodecContext->pix_fmt, imagePixFormat, frameCount);
|
||||
#else // HAVE_LIBSWSCALE
|
||||
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
|
||||
|
||||
frameCount++;
|
||||
|
@ -256,39 +333,47 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
|
||||
mOpenStart = time(NULL);
|
||||
mIsOpening = true;
|
||||
have_video_keyframe = false;
|
||||
|
||||
// Open the input, not necessarily a file
|
||||
#if !LIBAVFORMAT_VERSION_CHECK(53, 2, 0, 4, 0)
|
||||
Debug ( 1, "Calling av_open_input_file" );
|
||||
if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=0 )
|
||||
if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) != 0 )
|
||||
#else
|
||||
// Handle options
|
||||
AVDictionary *opts = 0;
|
||||
ret = av_dict_parse_string(&opts, Options().c_str(), "=", ",", 0);
|
||||
if (ret < 0) {
|
||||
if ( ret < 0 ) {
|
||||
Warning("Could not parse ffmpeg input options list '%s'\n", Options().c_str());
|
||||
}
|
||||
|
||||
// Set transport method as specified by method field, rtpUni is default
|
||||
if (Method() == "rtpMulti") {
|
||||
const std::string method = Method();
|
||||
if ( method == "rtpMulti" ) {
|
||||
ret = av_dict_set(&opts, "rtsp_transport", "udp_multicast", 0);
|
||||
} else if (Method() == "rtpRtsp") {
|
||||
} else if ( method == "rtpRtsp" ) {
|
||||
ret = av_dict_set(&opts, "rtsp_transport", "tcp", 0);
|
||||
} else if (Method() == "rtpRtspHttp") {
|
||||
} else if ( method == "rtpRtspHttp" ) {
|
||||
ret = av_dict_set(&opts, "rtsp_transport", "http", 0);
|
||||
} else {
|
||||
Warning("Unknown method (%s)", method.c_str() );
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
Warning("Could not set rtsp_transport method '%s'\n", Method().c_str());
|
||||
if ( ret < 0 ) {
|
||||
Warning("Could not set rtsp_transport method '%s'\n", method.c_str());
|
||||
}
|
||||
|
||||
Debug ( 1, "Calling avformat_open_input" );
|
||||
Debug ( 1, "Calling avformat_open_input for %s", mPath.c_str() );
|
||||
|
||||
mFormatContext = avformat_alloc_context( );
|
||||
mFormatContext->interrupt_callback.callback = FfmpegInterruptCallback;
|
||||
mFormatContext->interrupt_callback.opaque = this;
|
||||
//mFormatContext->interrupt_callback.callback = FfmpegInterruptCallback;
|
||||
//mFormatContext->interrupt_callback.opaque = this;
|
||||
// Speed up find_stream_info
|
||||
//FIXME can speed up initial analysis but need sensible parameters...
|
||||
//mFormatContext->probesize = 32;
|
||||
//mFormatContext->max_analyze_duration = 32;
|
||||
|
||||
if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, &opts ) !=0 )
|
||||
if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, &opts ) != 0 )
|
||||
#endif
|
||||
{
|
||||
mIsOpening = false;
|
||||
|
@ -297,7 +382,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
}
|
||||
|
||||
AVDictionaryEntry *e;
|
||||
if ((e = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX)) != NULL) {
|
||||
if ( (e = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX)) != NULL ) {
|
||||
Warning( "Option %s not recognized by ffmpeg", e->key);
|
||||
}
|
||||
|
||||
|
@ -306,10 +391,6 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
|
||||
Info( "Stream open %s", mPath.c_str() );
|
||||
|
||||
//FIXME can speed up initial analysis but need sensible parameters...
|
||||
//mFormatContext->probesize = 32;
|
||||
//mFormatContext->max_analyze_duration = 32;
|
||||
// Locate stream info from avformat_open_input
|
||||
#if !LIBAVFORMAT_VERSION_CHECK(53, 6, 0, 6, 0)
|
||||
Debug ( 1, "Calling av_find_stream_info" );
|
||||
if ( av_find_stream_info( mFormatContext ) < 0 )
|
||||
|
@ -326,7 +407,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
// The one we want Might not be the first
|
||||
mVideoStreamId = -1;
|
||||
mAudioStreamId = -1;
|
||||
for (unsigned int i=0; i < mFormatContext->nb_streams; i++ ) {
|
||||
for ( unsigned int i=0; i < mFormatContext->nb_streams; i++ ) {
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
if ( mFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ) {
|
||||
#else
|
||||
|
@ -379,8 +460,47 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
//mVideoCodecContext->flags2 |= CODEC_FLAG2_FAST | CODEC_FLAG2_CHUNKS | CODEC_FLAG_LOW_DELAY; // Enable faster H264 decode.
|
||||
mVideoCodecContext->flags2 |= CODEC_FLAG2_FAST | CODEC_FLAG_LOW_DELAY;
|
||||
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
if ( mVideoCodecContext->codec_id == AV_CODEC_ID_H264 ) {
|
||||
|
||||
//vaapi_decoder = new VAAPIDecoder();
|
||||
//mVideoCodecContext->opaque = vaapi_decoder;
|
||||
//mVideoCodec = vaapi_decoder->openCodec( mVideoCodecContext );
|
||||
|
||||
if ( ! mVideoCodec ) {
|
||||
// Try to open an hwaccel codec.
|
||||
if ( (mVideoCodec = avcodec_find_decoder_by_name("h264_vaapi")) == NULL ) {
|
||||
Debug(1, "Failed to find decoder (h264_vaapi)" );
|
||||
} else {
|
||||
Debug(1, "Success finding decoder (h264_vaapi)" );
|
||||
}
|
||||
}
|
||||
if ( ! mVideoCodec ) {
|
||||
// Try to open an hwaccel codec.
|
||||
if ( (mVideoCodec = avcodec_find_decoder_by_name("h264_qsv")) == NULL ) {
|
||||
Debug(1, "Failed to find decoder (h264_qsv)" );
|
||||
} else {
|
||||
Debug(1, "Success finding decoder (h264_qsv)" );
|
||||
/* open the hardware device */
|
||||
ret = av_hwdevice_ctx_create(&decode.hw_device_ref, AV_HWDEVICE_TYPE_QSV,
|
||||
"auto", NULL, 0);
|
||||
if (ret < 0) {
|
||||
Error("Failed to open the hardware device");
|
||||
mVideoCodec = NULL;
|
||||
} else {
|
||||
mVideoCodecContext->opaque = &decode;
|
||||
mVideoCodecContext->get_format = get_format;
|
||||
hwaccel = true;
|
||||
hwFrame = zm_av_frame_alloc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end if h264
|
||||
#endif
|
||||
|
||||
if ( (!mVideoCodec) and ( (mVideoCodec = avcodec_find_decoder(mVideoCodecContext->codec_id)) == NULL ) ) {
|
||||
// Try and get the codec from the codec context
|
||||
if ((mVideoCodec = avcodec_find_decoder(mVideoCodecContext->codec_id)) == NULL) {
|
||||
Fatal("Can't find codec for video stream from %s", mPath.c_str());
|
||||
} else {
|
||||
Debug(1, "Video Found decoder");
|
||||
|
@ -388,14 +508,30 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
// Open the codec
|
||||
#if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0)
|
||||
Debug ( 1, "Calling avcodec_open" );
|
||||
if (avcodec_open(mVideoCodecContext, mVideoCodec) < 0)
|
||||
if ( avcodec_open(mVideoCodecContext, mVideoCodec) < 0 ){
|
||||
#else
|
||||
Debug ( 1, "Calling avcodec_open2" );
|
||||
if (avcodec_open2(mVideoCodecContext, mVideoCodec, 0) < 0)
|
||||
if ( avcodec_open2(mVideoCodecContext, mVideoCodec, &opts) < 0 ) {
|
||||
#endif
|
||||
AVDictionaryEntry *e;
|
||||
if ( (e = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX)) != NULL ) {
|
||||
Warning( "Option %s not recognized by ffmpeg", e->key);
|
||||
}
|
||||
Fatal( "Unable to open codec for video stream from %s", mPath.c_str() );
|
||||
} else {
|
||||
|
||||
AVDictionaryEntry *e;
|
||||
if ( (e = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX)) != NULL ) {
|
||||
Warning( "Option %s not recognized by ffmpeg", e->key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mVideoCodecContext->hwaccel != NULL) {
|
||||
Debug(1, "HWACCEL in use");
|
||||
} else {
|
||||
Debug(1, "HWACCEL not in use");
|
||||
}
|
||||
if ( mAudioStreamId >= 0 ) {
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
mAudioCodecContext = avcodec_alloc_context3( NULL );
|
||||
|
@ -403,7 +539,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
#else
|
||||
mAudioCodecContext = mFormatContext->streams[mAudioStreamId]->codec;
|
||||
#endif
|
||||
if ((mAudioCodec = avcodec_find_decoder(mAudioCodecContext->codec_id)) == NULL) {
|
||||
if ( (mAudioCodec = avcodec_find_decoder(mAudioCodecContext->codec_id)) == NULL ) {
|
||||
Debug(1, "Can't find codec for audio stream from %s", mPath.c_str());
|
||||
} else {
|
||||
Debug(1, "Audio Found decoder");
|
||||
|
@ -411,10 +547,10 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
// Open the codec
|
||||
#if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0)
|
||||
Debug ( 1, "Calling avcodec_open" );
|
||||
if (avcodec_open(mAudioCodecContext, mAudioCodec) < 0)
|
||||
if ( avcodec_open(mAudioCodecContext, mAudioCodec) < 0 )
|
||||
#else
|
||||
Debug ( 1, "Calling avcodec_open2" );
|
||||
if (avcodec_open2(mAudioCodecContext, mAudioCodec, 0) < 0)
|
||||
if ( avcodec_open2(mAudioCodecContext, mAudioCodec, 0) < 0 )
|
||||
#endif
|
||||
Fatal( "Unable to open codec for video stream from %s", mPath.c_str() );
|
||||
}
|
||||
|
@ -428,7 +564,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
// Allocate space for the converted video frame
|
||||
mFrame = zm_av_frame_alloc();
|
||||
|
||||
if(mRawFrame == NULL || mFrame == NULL)
|
||||
if ( mRawFrame == NULL || mFrame == NULL )
|
||||
Fatal( "Unable to allocate frame for %s", mPath.c_str() );
|
||||
|
||||
Debug ( 1, "Allocated frames" );
|
||||
|
@ -439,7 +575,7 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
||||
#endif
|
||||
|
||||
if( (unsigned int)pSize != imagesize) {
|
||||
if ( (unsigned int)pSize != imagesize ) {
|
||||
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
||||
}
|
||||
|
||||
|
@ -447,11 +583,11 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
|
||||
#if HAVE_LIBSWSCALE
|
||||
Debug ( 1, "Calling sws_isSupportedInput" );
|
||||
if (!sws_isSupportedInput(mVideoCodecContext->pix_fmt)) {
|
||||
if ( !sws_isSupportedInput(mVideoCodecContext->pix_fmt) ) {
|
||||
Fatal("swscale does not support the codec format: %c%c%c%c", (mVideoCodecContext->pix_fmt)&0xff, ((mVideoCodecContext->pix_fmt >> 8)&0xff), ((mVideoCodecContext->pix_fmt >> 16)&0xff), ((mVideoCodecContext->pix_fmt >> 24)&0xff));
|
||||
}
|
||||
|
||||
if(!sws_isSupportedOutput(imagePixFormat)) {
|
||||
if ( !sws_isSupportedOutput(imagePixFormat) ) {
|
||||
Fatal("swscale does not support the target format: %c%c%c%c",(imagePixFormat)&0xff,((imagePixFormat>>8)&0xff),((imagePixFormat>>16)&0xff),((imagePixFormat>>24)&0xff));
|
||||
}
|
||||
|
||||
|
@ -480,23 +616,35 @@ int FfmpegCamera::ReopenFfmpeg() {
|
|||
|
||||
Debug(2, "ReopenFfmpeg called.");
|
||||
|
||||
#if THREAD
|
||||
mCanCapture = false;
|
||||
if (pthread_create( &mReopenThread, NULL, ReopenFfmpegThreadCallback, (void*) this) != 0){
|
||||
if ( pthread_create( &mReopenThread, NULL, ReopenFfmpegThreadCallback, (void*) this) != 0 ) {
|
||||
// Log a fatal error and exit the process.
|
||||
Fatal( "ReopenFfmpeg failed to create worker thread." );
|
||||
}
|
||||
#else
|
||||
CloseFfmpeg();
|
||||
OpenFfmpeg();
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FfmpegCamera::CloseFfmpeg(){
|
||||
int FfmpegCamera::CloseFfmpeg() {
|
||||
|
||||
Debug(2, "CloseFfmpeg called.");
|
||||
|
||||
mCanCapture = false;
|
||||
|
||||
av_frame_free( &mFrame );
|
||||
av_frame_free( &mRawFrame );
|
||||
if ( mFrame ) {
|
||||
av_frame_free( &mFrame );
|
||||
mFrame = NULL;
|
||||
}
|
||||
if ( mRawFrame ) {
|
||||
av_frame_free( &mRawFrame );
|
||||
mRawFrame = NULL;
|
||||
}
|
||||
|
||||
#if HAVE_LIBSWSCALE
|
||||
if ( mConvertContext ) {
|
||||
|
@ -505,12 +653,14 @@ int FfmpegCamera::CloseFfmpeg(){
|
|||
}
|
||||
#endif
|
||||
|
||||
if (mVideoCodecContext) {
|
||||
if ( mVideoCodecContext ) {
|
||||
avcodec_close(mVideoCodecContext);
|
||||
//av_free(mVideoCodecContext);
|
||||
mVideoCodecContext = NULL; // Freed by av_close_input_file
|
||||
}
|
||||
if (mAudioCodecContext) {
|
||||
if ( mAudioCodecContext ) {
|
||||
avcodec_close(mAudioCodecContext);
|
||||
//av_free(mAudioCodecContext);
|
||||
mAudioCodecContext = NULL; // Freed by av_close_input_file
|
||||
}
|
||||
|
||||
|
@ -527,11 +677,12 @@ int FfmpegCamera::CloseFfmpeg(){
|
|||
}
|
||||
|
||||
int FfmpegCamera::FfmpegInterruptCallback(void *ctx) {
|
||||
Debug(3,"FfmpegInteruptCallback");
|
||||
FfmpegCamera* camera = reinterpret_cast<FfmpegCamera*>(ctx);
|
||||
if (camera->mIsOpening){
|
||||
if ( camera->mIsOpening ) {
|
||||
int now = time(NULL);
|
||||
if ((now - camera->mOpenStart) > config.ffmpeg_open_timeout) {
|
||||
Error ( "Open video took more than %d seconds.", config.ffmpeg_open_timeout );
|
||||
if ( (now - camera->mOpenStart) > config.ffmpeg_open_timeout ) {
|
||||
Error( "Open video took more than %d seconds.", config.ffmpeg_open_timeout );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -540,23 +691,24 @@ int FfmpegCamera::FfmpegInterruptCallback(void *ctx) {
|
|||
}
|
||||
|
||||
void *FfmpegCamera::ReopenFfmpegThreadCallback(void *ctx){
|
||||
if (ctx == NULL) return NULL;
|
||||
Debug(3,"FfmpegReopenThreadtCallback");
|
||||
if ( ctx == NULL ) return NULL;
|
||||
|
||||
FfmpegCamera* camera = reinterpret_cast<FfmpegCamera*>(ctx);
|
||||
|
||||
while (1){
|
||||
while (1) {
|
||||
// Close current stream.
|
||||
camera->CloseFfmpeg();
|
||||
|
||||
// Sleep if necessary to not reconnect too fast.
|
||||
int wait = config.ffmpeg_open_timeout - (time(NULL) - camera->mOpenStart);
|
||||
wait = wait < 0 ? 0 : wait;
|
||||
if (wait > 0){
|
||||
if ( wait > 0 ) {
|
||||
Debug( 1, "Sleeping %d seconds before reopening stream.", wait );
|
||||
sleep(wait);
|
||||
}
|
||||
|
||||
if (camera->OpenFfmpeg() == 0){
|
||||
if ( camera->OpenFfmpeg() == 0 ) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -584,7 +736,15 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
}
|
||||
|
||||
if ( mVideoCodecContext->codec_id != AV_CODEC_ID_H264 ) {
|
||||
Error( "Input stream is not h264. The stored event file may not be viewable in browser." );
|
||||
#ifdef AV_CODEC_ID_H265
|
||||
if ( mVideoCodecContext->codec_id == AV_CODEC_ID_H265 ) {
|
||||
Debug( 1, "Input stream appears to be h265. The stored event file may not be viewable in browser." );
|
||||
} else {
|
||||
#endif
|
||||
Error( "Input stream is not h264. The stored event file may not be viewable in browser." );
|
||||
#ifdef AV_CODEC_ID_H265
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int frameComplete = false;
|
||||
|
@ -608,11 +768,11 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
return( -1 );
|
||||
}
|
||||
|
||||
int key_frame = packet.flags & AV_PKT_FLAG_KEY;
|
||||
int keyframe = packet.flags & AV_PKT_FLAG_KEY;
|
||||
|
||||
Debug( 4, "Got packet from stream %d packet pts (%d) dts(%d), key?(%d)",
|
||||
Debug( 4, "Got packet from stream %d packet pts (%u) dts(%u), key?(%d)",
|
||||
packet.stream_index, packet.pts, packet.dts,
|
||||
key_frame
|
||||
keyframe
|
||||
);
|
||||
|
||||
//Video recording
|
||||
|
@ -638,6 +798,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
|
||||
delete videoStore;
|
||||
videoStore = NULL;
|
||||
have_video_keyframe = false;
|
||||
|
||||
monitor->SetVideoWriterEventId( 0 );
|
||||
} // end if videoStore
|
||||
|
@ -646,8 +807,8 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
if ( last_event_id and ! videoStore ) {
|
||||
//Instantiate the video storage module
|
||||
|
||||
if (record_audio) {
|
||||
if (mAudioStreamId == -1) {
|
||||
if ( record_audio ) {
|
||||
if ( mAudioStreamId == -1 ) {
|
||||
Debug(3, "Record Audio on but no audio stream found");
|
||||
videoStore = new VideoStore((const char *) event_file, "mp4",
|
||||
mFormatContext->streams[mVideoStreamId],
|
||||
|
@ -690,6 +851,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
Debug(2, "Writing queued packet stream: %d KEY %d, remaining (%d)", avp->stream_index, avp->flags & AV_PKT_FLAG_KEY, packetqueue.size() );
|
||||
if ( avp->stream_index == mVideoStreamId ) {
|
||||
ret = videoStore->writeVideoFramePacket( avp );
|
||||
have_video_keyframe = true;
|
||||
} else if ( avp->stream_index == mAudioStreamId ) {
|
||||
ret = videoStore->writeAudioFramePacket( avp );
|
||||
} else {
|
||||
|
@ -710,13 +872,14 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
Info("Deleting videoStore instance");
|
||||
delete videoStore;
|
||||
videoStore = NULL;
|
||||
have_video_keyframe = false;
|
||||
monitor->SetVideoWriterEventId( 0 );
|
||||
}
|
||||
|
||||
// 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 ( key_frame ) {
|
||||
if ( keyframe ) {
|
||||
Debug(3, "Clearing queue");
|
||||
packetqueue.clearQueue( monitor->GetPreEventCount(), mVideoStreamId );
|
||||
}
|
||||
|
@ -739,82 +902,113 @@ else if ( packet.pts && video_last_pts > packet.pts ) {
|
|||
packetqueue.queuePacket( &packet );
|
||||
}
|
||||
} else if ( packet.stream_index == mVideoStreamId ) {
|
||||
if ( key_frame || packetqueue.size() ) // it's a keyframe or we already have something in the queue
|
||||
if ( keyframe || packetqueue.size() ) // it's a keyframe or we already have something in the queue
|
||||
packetqueue.queuePacket( &packet );
|
||||
}
|
||||
} // end if recording or not
|
||||
|
||||
if ( packet.stream_index == mVideoStreamId ) {
|
||||
if ( videoStore ) {
|
||||
//Write the packet to our video store
|
||||
int ret = videoStore->writeVideoFramePacket( &packet );
|
||||
if ( ret < 0 ) { //Less than zero and we skipped a frame
|
||||
zm_av_packet_unref( &packet );
|
||||
return 0;
|
||||
// only do decode if we have had a keyframe, should save a few cycles.
|
||||
if ( have_video_keyframe || keyframe ) {
|
||||
|
||||
if ( videoStore ) {
|
||||
|
||||
//Write the packet to our video store
|
||||
int ret = videoStore->writeVideoFramePacket( &packet );
|
||||
if ( ret < 0 ) { //Less than zero and we skipped a frame
|
||||
zm_av_packet_unref( &packet );
|
||||
return 0;
|
||||
}
|
||||
have_video_keyframe = true;
|
||||
}
|
||||
}
|
||||
Debug(4, "about to decode video" );
|
||||
|
||||
} // end if keyframe or have_video_keyframe
|
||||
|
||||
Debug(4, "about to decode video" );
|
||||
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
ret = avcodec_send_packet( mVideoCodecContext, &packet );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
ret = avcodec_receive_frame( mVideoCodecContext, mRawFrame );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Debug( 1, "Unable to send packet at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
frameComplete = 1;
|
||||
# else
|
||||
ret = zm_avcodec_decode_video( mVideoCodecContext, mRawFrame, &frameComplete, &packet );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to decode frame at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
Debug( 4, "Decoded video packet at frame %d", frameCount );
|
||||
|
||||
if ( frameComplete ) {
|
||||
Debug( 4, "Got frame %d", frameCount );
|
||||
|
||||
uint8_t* directbuffer;
|
||||
|
||||
/* Request a writeable buffer of the target image */
|
||||
directbuffer = image.WriteBuffer(width, height, colours, subpixelorder);
|
||||
if ( directbuffer == NULL ) {
|
||||
Error("Failed requesting writeable buffer for the captured image.");
|
||||
ret = avcodec_send_packet( mVideoCodecContext, &packet );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
return (-1);
|
||||
continue;
|
||||
}
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
if ( hwaccel ) {
|
||||
ret = avcodec_receive_frame( mVideoCodecContext, hwFrame );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
ret = av_hwframe_transfer_data(mRawFrame, hwFrame, 0);
|
||||
if (ret < 0) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to transfer frame at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
ret = avcodec_receive_frame( mVideoCodecContext, mRawFrame );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
}
|
||||
#endif
|
||||
|
||||
frameComplete = 1;
|
||||
# else
|
||||
ret = zm_avcodec_decode_video( mVideoCodecContext, mRawFrame, &frameComplete, &packet );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to decode frame at frame %d: %s, continuing", frameCount, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
Debug( 4, "Decoded video packet at frame %d", frameCount );
|
||||
|
||||
if ( frameComplete ) {
|
||||
Debug( 4, "Got frame %d", frameCount );
|
||||
|
||||
uint8_t* directbuffer;
|
||||
|
||||
/* Request a writeable buffer of the target image */
|
||||
directbuffer = image.WriteBuffer(width, height, colours, subpixelorder);
|
||||
if ( directbuffer == NULL ) {
|
||||
Error("Failed requesting writeable buffer for the captured image.");
|
||||
zm_av_packet_unref( &packet );
|
||||
return (-1);
|
||||
}
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
av_image_fill_arrays(mFrame->data, mFrame->linesize, directbuffer, imagePixFormat, width, height, 1);
|
||||
av_image_fill_arrays(mFrame->data, mFrame->linesize, directbuffer, imagePixFormat, width, height, 1);
|
||||
#else
|
||||
avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height);
|
||||
avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height);
|
||||
#endif
|
||||
|
||||
|
||||
if (sws_scale(mConvertContext, mRawFrame->data, mRawFrame->linesize,
|
||||
0, mVideoCodecContext->height, mFrame->data, mFrame->linesize) < 0) {
|
||||
Fatal("Unable to convert raw format %u to target format %u at frame %d",
|
||||
if (sws_scale(mConvertContext, mRawFrame->data, mRawFrame->linesize,
|
||||
0, mVideoCodecContext->height, mFrame->data, mFrame->linesize) < 0) {
|
||||
Fatal("Unable to convert raw format %u to target format %u at frame %d",
|
||||
mVideoCodecContext->pix_fmt, imagePixFormat, frameCount);
|
||||
}
|
||||
}
|
||||
|
||||
frameCount++;
|
||||
} else {
|
||||
Debug( 3, "Not framecomplete after av_read_frame" );
|
||||
} // end if frameComplete
|
||||
frameCount++;
|
||||
} else {
|
||||
Debug( 3, "Not framecomplete after av_read_frame" );
|
||||
} // end if frameComplete
|
||||
} else if ( packet.stream_index == mAudioStreamId ) { //FIXME best way to copy all other streams
|
||||
if ( videoStore ) {
|
||||
if ( record_audio ) {
|
||||
if ( have_video_keyframe ) {
|
||||
Debug(3, "Recording audio packet streamindex(%d) packetstreamindex(%d)", mAudioStreamId, packet.stream_index );
|
||||
//Write the packet to our video store
|
||||
//FIXME no relevance of last key frame
|
||||
|
@ -824,6 +1018,9 @@ else if ( packet.pts && video_last_pts > packet.pts ) {
|
|||
zm_av_packet_unref( &packet );
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
Debug(3, "Not recording audio yet because we don't have a video keyframe yet");
|
||||
}
|
||||
} else {
|
||||
Debug(4, "Not doing recording of audio packet" );
|
||||
}
|
||||
|
@ -836,14 +1033,14 @@ else if ( packet.pts && video_last_pts > packet.pts ) {
|
|||
#else
|
||||
Debug( 3, "Some other stream index %d", packet.stream_index );
|
||||
#endif
|
||||
}
|
||||
//if ( videoStore ) {
|
||||
} // end if is video or audio or something else
|
||||
|
||||
// the packet contents are ref counted... when queuing, we allocate another packet and reference it with that one, so we should always need to unref here, which should not affect the queued version.
|
||||
zm_av_packet_unref( &packet );
|
||||
//}
|
||||
// the packet contents are ref counted... when queuing, we allocate another packet and reference it with that one, so we should always need to unref here, which should not affect the queued version.
|
||||
zm_av_packet_unref( &packet );
|
||||
} // end while ! frameComplete
|
||||
return (frameCount);
|
||||
} // end FfmpegCamera::CaptureAndRecord
|
||||
|
||||
|
||||
|
||||
#endif // HAVE_LIBAVFORMAT
|
||||
|
|
|
@ -23,11 +23,15 @@
|
|||
#include "zm_camera.h"
|
||||
|
||||
#include "zm_buffer.h"
|
||||
//#include "zm_utils.h"
|
||||
#include "zm_ffmpeg.h"
|
||||
#include "zm_videostore.h"
|
||||
#include "zm_packetqueue.h"
|
||||
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
typedef struct DecodeContext {
|
||||
AVBufferRef *hw_device_ref;
|
||||
} DecodeContext;
|
||||
#endif
|
||||
//
|
||||
// Class representing 'ffmpeg' cameras, i.e. those which are
|
||||
// accessed using ffmpeg multimedia framework
|
||||
|
@ -52,6 +56,12 @@ class FfmpegCamera : public Camera {
|
|||
AVFrame *mFrame;
|
||||
_AVPIXELFORMAT imagePixFormat;
|
||||
|
||||
bool hwaccel;
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
AVFrame *hwFrame;
|
||||
DecodeContext decode;
|
||||
#endif
|
||||
|
||||
// Need to keep track of these because apparently the stream can start with values for pts/dts and then subsequent packets start at zero.
|
||||
int64_t audio_last_pts;
|
||||
int64_t audio_last_dts;
|
||||
|
@ -78,6 +88,7 @@ class FfmpegCamera : public Camera {
|
|||
char oldDirectory[4096];
|
||||
unsigned int old_event_id;
|
||||
zm_packetqueue packetqueue;
|
||||
bool have_video_keyframe;
|
||||
|
||||
#if HAVE_LIBSWSCALE
|
||||
struct SwsContext *mConvertContext;
|
||||
|
|
|
@ -7,6 +7,9 @@ FFmpeg_Input::FFmpeg_Input() {
|
|||
input_format_context = NULL;
|
||||
video_stream_id = -1;
|
||||
audio_stream_id = -1;
|
||||
av_register_all();
|
||||
avcodec_register_all();
|
||||
|
||||
}
|
||||
|
||||
FFmpeg_Input::~FFmpeg_Input() {
|
||||
|
@ -17,7 +20,7 @@ int FFmpeg_Input::Open( const char *filepath ) {
|
|||
int error;
|
||||
|
||||
/** Open the input file to read from it. */
|
||||
if ((error = avformat_open_input( &input_format_context, filepath, NULL, NULL)) < 0) {
|
||||
if ( (error = avformat_open_input( &input_format_context, filepath, NULL, NULL)) < 0 ) {
|
||||
|
||||
Error("Could not open input file '%s' (error '%s')\n",
|
||||
filepath, av_make_error_string(error).c_str() );
|
||||
|
@ -26,7 +29,7 @@ int FFmpeg_Input::Open( const char *filepath ) {
|
|||
}
|
||||
|
||||
/** Get information on the input file (number of streams etc.). */
|
||||
if ((error = avformat_find_stream_info( input_format_context, NULL)) < 0) {
|
||||
if ( (error = avformat_find_stream_info(input_format_context, NULL)) < 0 ) {
|
||||
Error( "Could not open find stream info (error '%s')\n",
|
||||
av_make_error_string(error).c_str() );
|
||||
avformat_close_input(&input_format_context);
|
||||
|
@ -35,15 +38,14 @@ int FFmpeg_Input::Open( const char *filepath ) {
|
|||
|
||||
for ( unsigned int i = 0; i < input_format_context->nb_streams; i += 1 ) {
|
||||
if ( is_video_stream( input_format_context->streams[i] ) ) {
|
||||
zm_dump_stream_format(input_format_context, i, 0, 0);
|
||||
if ( video_stream_id == -1 ) {
|
||||
video_stream_id = i;
|
||||
// if we break, then we won't find the audio stream
|
||||
continue;
|
||||
} else {
|
||||
Warning( "Have another video stream." );
|
||||
}
|
||||
}
|
||||
if ( is_audio_stream( input_format_context->streams[i] ) ) {
|
||||
} else if ( is_audio_stream( input_format_context->streams[i] ) ) {
|
||||
if ( audio_stream_id == -1 ) {
|
||||
audio_stream_id = i;
|
||||
} else {
|
||||
|
@ -51,6 +53,7 @@ int FFmpeg_Input::Open( const char *filepath ) {
|
|||
}
|
||||
}
|
||||
|
||||
streams[i].frame_count = 0;
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
streams[i].context = avcodec_alloc_context3( NULL );
|
||||
avcodec_parameters_to_context( streams[i].context, input_format_context->streams[i]->codecpar );
|
||||
|
@ -58,30 +61,123 @@ int FFmpeg_Input::Open( const char *filepath ) {
|
|||
streams[i].context = input_format_context->streams[i]->codec;
|
||||
#endif
|
||||
|
||||
/** Find a decoder for the audio stream. */
|
||||
if (!(streams[i].codec = avcodec_find_decoder(input_format_context->streams[i]->codecpar->codec_id))) {
|
||||
if ( !(streams[i].codec = avcodec_find_decoder(streams[i].context->codec_id)) ) {
|
||||
Error( "Could not find input codec\n");
|
||||
avformat_close_input(&input_format_context);
|
||||
return AVERROR_EXIT;
|
||||
} else {
|
||||
Debug(1, "Using codec (%s) for stream %d", streams[i].codec->name, i );
|
||||
}
|
||||
|
||||
/** Open the decoder for the audio stream to use it later. */
|
||||
if ((error = avcodec_open2( streams[i].context, streams[i].codec, NULL)) < 0) {
|
||||
Error( "Could not open input codec (error '%s')\n",
|
||||
av_make_error_string(error).c_str() );
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
avcodec_free_context( &streams[i].context );
|
||||
#endif
|
||||
avformat_close_input(&input_format_context);
|
||||
return error;
|
||||
}
|
||||
|
||||
} // end foreach stream
|
||||
|
||||
if ( video_stream_id == -1 )
|
||||
Error( "Unable to locate video stream in %s", filepath );
|
||||
if ( audio_stream_id == -1 )
|
||||
Debug( 3, "Unable to locate audio stream in %s", filepath );
|
||||
|
||||
return 0;
|
||||
} // end int FFmpeg::Open( const char * filepath )
|
||||
} // end int FFmpeg_Input::Open( const char * filepath )
|
||||
|
||||
AVFrame *FFmpeg_Input::get_frame( int stream_id ) {
|
||||
Debug(1, "Getting frame from stream %d", stream_id );
|
||||
|
||||
int frameComplete = false;
|
||||
AVPacket packet;
|
||||
av_init_packet( &packet );
|
||||
AVFrame *frame = zm_av_frame_alloc();
|
||||
char errbuf[AV_ERROR_MAX_STRING_SIZE];
|
||||
|
||||
while ( !frameComplete ) {
|
||||
int ret = av_read_frame( input_format_context, &packet );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror(ret, errbuf, AV_ERROR_MAX_STRING_SIZE);
|
||||
if (
|
||||
// Check if EOF.
|
||||
(ret == AVERROR_EOF || (input_format_context->pb && input_format_context->pb->eof_reached)) ||
|
||||
// Check for Connection failure.
|
||||
(ret == -110)
|
||||
) {
|
||||
Info( "av_read_frame returned %s.", errbuf );
|
||||
return NULL;
|
||||
}
|
||||
Error( "Unable to read packet from stream %d: error %d \"%s\".", packet.stream_index, ret, errbuf );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( (stream_id < 0 ) || ( packet.stream_index == stream_id ) ) {
|
||||
Debug(1,"Packet is for our stream (%d)", packet.stream_index );
|
||||
|
||||
AVCodecContext *context = streams[packet.stream_index].context;
|
||||
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
ret = avcodec_send_packet( context, &packet );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", streams[packet.stream_index].frame_count, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
} else {
|
||||
Debug(1, "Success getting a packet");
|
||||
}
|
||||
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
if ( hwaccel ) {
|
||||
ret = avcodec_receive_frame( context, hwFrame );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to receive frame %d: %s, continuing", streams[packet.stream_index].frame_count, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
ret = av_hwframe_transfer_data(frame, hwFrame, 0);
|
||||
if (ret < 0) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to transfer frame at frame %d: %s, continuing", streams[packet.stream_index].frame_count, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
Debug(1,"Getting a frame?");
|
||||
ret = avcodec_receive_frame( context, frame );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to send packet at frame %d: %s, continuing", streams[packet.stream_index].frame_count, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
|
||||
#if HAVE_AVUTIL_HWCONTEXT_H
|
||||
}
|
||||
#endif
|
||||
|
||||
frameComplete = 1;
|
||||
# else
|
||||
ret = zm_avcodec_decode_video( streams[packet.stream_index].context, frame, &frameComplete, &packet );
|
||||
if ( ret < 0 ) {
|
||||
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
|
||||
Error( "Unable to decode frame at frame %d: %s, continuing", streams[packet.stream_index].frame_count, errbuf );
|
||||
zm_av_packet_unref( &packet );
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
} // end if it's the right stream
|
||||
|
||||
zm_av_packet_unref( &packet );
|
||||
|
||||
} // end while ! frameComplete
|
||||
return frame;
|
||||
} // end AVFrame *FFmpeg_Input::get_frame
|
||||
|
||||
AVPacket * FFmpeg_Input::read_packet() {
|
||||
AVPacket *packet = new AVPacket();
|
||||
|
@ -153,4 +249,4 @@ int FFmpeg_Input::decode_packet( AVPacket *packet, AVFrame *frame ) {
|
|||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
} // int FFmpeg_Input::decode_packet( AVPacket *packet, AVFrame *frame );
|
||||
|
|
|
@ -21,6 +21,13 @@ class FFmpeg_Input {
|
|||
|
||||
int Open( const char *filename );
|
||||
int Close();
|
||||
AVFrame *get_frame( int stream_id=-1 );
|
||||
int get_video_stream_id() {
|
||||
return video_stream_id;
|
||||
}
|
||||
int get_audio_stream_id() {
|
||||
return audio_stream_id;
|
||||
}
|
||||
|
||||
AVPacket * read_packet();
|
||||
int read_packet( AVPacket *packet );
|
||||
|
@ -31,6 +38,7 @@ class FFmpeg_Input {
|
|||
typedef struct {
|
||||
AVCodecContext *context;
|
||||
AVCodec *codec;
|
||||
int frame_count;
|
||||
} stream;
|
||||
|
||||
stream streams[2];
|
||||
|
|
130
src/zm_image.cpp
130
src/zm_image.cpp
|
@ -22,6 +22,7 @@
|
|||
#include "zm_image.h"
|
||||
#include "zm_utils.h"
|
||||
#include "zm_rgb.h"
|
||||
#include "zm_ffmpeg.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
@ -107,8 +108,7 @@ Image::Image( const char *filename ) {
|
|||
text[0] = '\0';
|
||||
}
|
||||
|
||||
Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer )
|
||||
{
|
||||
Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer ) {
|
||||
if ( !initialised )
|
||||
Initialise();
|
||||
width = p_width;
|
||||
|
@ -119,21 +119,57 @@ Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uin
|
|||
size = pixels*colours;
|
||||
buffer = 0;
|
||||
holdbuffer = 0;
|
||||
if ( p_buffer )
|
||||
{
|
||||
if ( p_buffer ) {
|
||||
allocation = size;
|
||||
buffertype = ZM_BUFTYPE_DONTFREE;
|
||||
buffer = p_buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AllocImgBuffer(size);
|
||||
}
|
||||
text[0] = '\0';
|
||||
}
|
||||
|
||||
Image::Image( const Image &p_image )
|
||||
{
|
||||
Image::Image( const AVFrame *frame ) {
|
||||
AVFrame *dest_frame = zm_av_frame_alloc();
|
||||
|
||||
width = frame->width;
|
||||
height = frame->height;
|
||||
pixels = width*height;
|
||||
colours = ZM_COLOUR_RGB32;
|
||||
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
|
||||
size = pixels*colours;
|
||||
buffer = 0;
|
||||
holdbuffer = 0;
|
||||
AllocImgBuffer(size);
|
||||
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
av_image_fill_arrays(dest_frame->data, dest_frame->linesize,
|
||||
buffer, AV_PIX_FMT_RGBA, width, height, 1);
|
||||
#else
|
||||
avpicture_fill( (AVPicture *)dest_frame, buffer,
|
||||
AV_PIX_FMT_RGBA, width, height);
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBSWSCALE
|
||||
struct SwsContext *mConvertContext = sws_getContext(
|
||||
width,
|
||||
height,
|
||||
(AVPixelFormat)frame->format,
|
||||
width, height,
|
||||
AV_PIX_FMT_RGBA, SWS_BICUBIC, NULL,
|
||||
NULL, NULL);
|
||||
if ( mConvertContext == NULL )
|
||||
Fatal( "Unable to create conversion context" );
|
||||
|
||||
if ( sws_scale(mConvertContext, frame->data, frame->linesize, 0, frame->height, dest_frame->data, dest_frame->linesize) < 0 )
|
||||
Fatal("Unable to convert raw format %u to target format %u", frame->format, AV_PIX_FMT_RGBA);
|
||||
#else // HAVE_LIBSWSCALE
|
||||
Fatal("You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras");
|
||||
#endif // HAVE_LIBSWSCALE
|
||||
av_frame_free( &dest_frame );
|
||||
}
|
||||
|
||||
Image::Image( const Image &p_image ) {
|
||||
if ( !initialised )
|
||||
Initialise();
|
||||
width = p_image.width;
|
||||
|
@ -170,8 +206,7 @@ void Image::Deinitialise() {
|
|||
delete readjpg_dcinfo;
|
||||
readjpg_dcinfo = 0;
|
||||
}
|
||||
if ( decodejpg_dcinfo )
|
||||
{
|
||||
if ( decodejpg_dcinfo ) {
|
||||
jpeg_destroy_decompress( decodejpg_dcinfo );
|
||||
delete decodejpg_dcinfo;
|
||||
decodejpg_dcinfo = 0;
|
||||
|
@ -186,14 +221,13 @@ void Image::Deinitialise() {
|
|||
}
|
||||
}
|
||||
|
||||
void Image::Initialise()
|
||||
{
|
||||
void Image::Initialise() {
|
||||
/* Assign the blend pointer to function */
|
||||
if(config.fast_image_blends) {
|
||||
if(config.cpu_extensions && sseversion >= 20) {
|
||||
if ( config.fast_image_blends ) {
|
||||
if ( config.cpu_extensions && sseversion >= 20 ) {
|
||||
fptr_blend = &sse2_fastblend; /* SSE2 fast blend */
|
||||
Debug(4,"Blend: Using SSE2 fast blend function");
|
||||
} else if(config.cpu_extensions && neonversion >= 1) {
|
||||
} else if ( config.cpu_extensions && neonversion >= 1 ) {
|
||||
#if defined(__aarch64__)
|
||||
fptr_blend = &neon64_armv8_fastblend; /* ARM Neon (AArch64) fast blend */
|
||||
Debug(4,"Blend: Using ARM Neon (AArch64) fast blend function");
|
||||
|
@ -236,8 +270,8 @@ void Image::Initialise()
|
|||
(*fptr_blend)(blend1,blend2,blendres,128,12.0);
|
||||
|
||||
/* Compare results with expected results */
|
||||
for(int i=0;i<128;i++) {
|
||||
if(abs(blendexp[i] - blendres[i]) > 3) {
|
||||
for ( int i=0; i < 128; i ++ ) {
|
||||
if ( abs(blendexp[i] - blendres[i]) > 3 ) {
|
||||
Panic("Blend function failed self-test: Results differ from the expected results. Column %u Expected %u Got %u",i,blendexp[i],blendres[i]);
|
||||
}
|
||||
}
|
||||
|
@ -246,8 +280,8 @@ void Image::Initialise()
|
|||
fptr_delta8_bgr = &std_delta8_bgr;
|
||||
|
||||
/* Assign the delta functions */
|
||||
if(config.cpu_extensions) {
|
||||
if(sseversion >= 35) {
|
||||
if ( config.cpu_extensions ) {
|
||||
if ( sseversion >= 35 ) {
|
||||
/* SSSE3 available */
|
||||
fptr_delta8_rgba = &ssse3_delta8_rgba;
|
||||
fptr_delta8_bgra = &ssse3_delta8_bgra;
|
||||
|
@ -255,7 +289,7 @@ void Image::Initialise()
|
|||
fptr_delta8_abgr = &ssse3_delta8_abgr;
|
||||
fptr_delta8_gray8 = &sse2_delta8_gray8;
|
||||
Debug(4,"Delta: Using SSSE3 delta functions");
|
||||
} else if(sseversion >= 20) {
|
||||
} else if ( sseversion >= 20 ) {
|
||||
/* SSE2 available */
|
||||
fptr_delta8_rgba = &sse2_delta8_rgba;
|
||||
fptr_delta8_bgra = &sse2_delta8_bgra;
|
||||
|
@ -263,7 +297,7 @@ void Image::Initialise()
|
|||
fptr_delta8_abgr = &sse2_delta8_abgr;
|
||||
fptr_delta8_gray8 = &sse2_delta8_gray8;
|
||||
Debug(4,"Delta: Using SSE2 delta functions");
|
||||
} else if(neonversion >= 1) {
|
||||
} else if ( neonversion >= 1 ) {
|
||||
/* ARM Neon available */
|
||||
#if defined(__aarch64__)
|
||||
fptr_delta8_rgba = &neon64_armv8_delta8_rgba;
|
||||
|
@ -329,8 +363,8 @@ void Image::Initialise()
|
|||
(*fptr_delta8_gray8)(delta8_1,delta8_2,delta8_gray8_res,128);
|
||||
|
||||
/* Compare results with expected results */
|
||||
for(int i=0;i<128;i++) {
|
||||
if(abs(delta8_gray8_exp[i] - delta8_gray8_res[i]) > 7) {
|
||||
for ( int i=0; i < 128; i++ ) {
|
||||
if ( abs(delta8_gray8_exp[i] - delta8_gray8_res[i]) > 7 ) {
|
||||
Panic("Delta grayscale function failed self-test: Results differ from the expected results. Column %u Expected %u Got %u",i,delta8_gray8_exp[i],delta8_gray8_res[i]);
|
||||
}
|
||||
}
|
||||
|
@ -339,8 +373,8 @@ void Image::Initialise()
|
|||
(*fptr_delta8_rgba)(delta8_1,delta8_2,delta8_rgba_res,32);
|
||||
|
||||
/* Compare results with expected results */
|
||||
for(int i=0;i<32;i++) {
|
||||
if(abs(delta8_rgba_exp[i] - delta8_rgba_res[i]) > 7) {
|
||||
for ( int i=0; i < 32; i++ ) {
|
||||
if ( abs(delta8_rgba_exp[i] - delta8_rgba_res[i]) > 7 ) {
|
||||
Panic("Delta RGBA function failed self-test: Results differ from the expected results. Column %u Expected %u Got %u",i,delta8_rgba_exp[i],delta8_rgba_res[i]);
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +393,7 @@ void Image::Initialise()
|
|||
|
||||
#if defined(__i386__) && !defined(__x86_64__)
|
||||
/* Use SSE2 aligned memory copy? */
|
||||
if(config.cpu_extensions && sseversion >= 20) {
|
||||
if ( config.cpu_extensions && sseversion >= 20 ) {
|
||||
fptr_imgbufcpy = &sse2_aligned_memcpy;
|
||||
Debug(4,"Image buffer copy: Using SSE2 aligned memcpy");
|
||||
} else {
|
||||
|
@ -425,24 +459,24 @@ void Image::Initialise()
|
|||
uint8_t* Image::WriteBuffer(const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder) {
|
||||
unsigned int newsize;
|
||||
|
||||
if(p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32) {
|
||||
if ( p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32 ) {
|
||||
Error("WriteBuffer called with unexpected colours: %d",p_colours);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!p_height || !p_width) {
|
||||
if ( !p_height || !p_width ) {
|
||||
Error("WriteBuffer called with invalid width or height: %d %d",p_width,p_height);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(p_width != width || p_height != height || p_colours != colours || p_subpixelorder != subpixelorder) {
|
||||
if ( p_width != width || p_height != height || p_colours != colours || p_subpixelorder != subpixelorder ) {
|
||||
newsize = (p_width * p_height) * p_colours;
|
||||
|
||||
if(buffer == NULL) {
|
||||
if ( buffer == NULL ) {
|
||||
AllocImgBuffer(newsize);
|
||||
} else {
|
||||
if(allocation < newsize) {
|
||||
if(holdbuffer) {
|
||||
if ( allocation < newsize ) {
|
||||
if ( holdbuffer ) {
|
||||
Error("Held buffer is undersized for requested buffer");
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -467,30 +501,30 @@ uint8_t* Image::WriteBuffer(const unsigned int p_width, const unsigned int p_hei
|
|||
|
||||
/* Assign an existing buffer to the image instead of copying from a source buffer. The goal is to reduce the amount of memory copying and increase efficiency and buffer reusing. */
|
||||
void Image::AssignDirect( const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder, uint8_t *new_buffer, const size_t buffer_size, const int p_buffertype) {
|
||||
if(new_buffer == NULL) {
|
||||
if ( new_buffer == NULL ) {
|
||||
Error("Attempt to directly assign buffer from a NULL pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!p_height || !p_width) {
|
||||
if ( !p_height || !p_width ) {
|
||||
Error("Attempt to directly assign buffer with invalid width or height: %d %d",p_width,p_height);
|
||||
return;
|
||||
}
|
||||
|
||||
if(p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32) {
|
||||
if ( p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32 ) {
|
||||
Error("Attempt to directly assign buffer with unexpected colours per pixel: %d",p_colours);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int new_buffer_size = ((p_width*p_height)*p_colours);
|
||||
|
||||
if(buffer_size < new_buffer_size) {
|
||||
if ( buffer_size < new_buffer_size ) {
|
||||
Error("Attempt to directly assign buffer from an undersized buffer of size: %zu, needed %dx%d*%d colours = %zu",buffer_size, p_width, p_height, p_colours, new_buffer_size );
|
||||
return;
|
||||
}
|
||||
|
||||
if(holdbuffer && buffer) {
|
||||
if(new_buffer_size > allocation) {
|
||||
if ( holdbuffer && buffer ) {
|
||||
if ( new_buffer_size > allocation ) {
|
||||
Error("Held buffer is undersized for assigned buffer");
|
||||
return;
|
||||
} else {
|
||||
|
@ -502,7 +536,7 @@ void Image::AssignDirect( const unsigned int p_width, const unsigned int p_heigh
|
|||
size = new_buffer_size; // was pixels*colours, but we already calculated it above as new_buffer_size
|
||||
|
||||
/* Copy into the held buffer */
|
||||
if(new_buffer != buffer)
|
||||
if ( new_buffer != buffer )
|
||||
(*fptr_imgbufcpy)(buffer, new_buffer, size);
|
||||
|
||||
/* Free the new buffer */
|
||||
|
@ -529,35 +563,35 @@ void Image::AssignDirect( const unsigned int p_width, const unsigned int p_heigh
|
|||
void Image::Assign(const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size) {
|
||||
unsigned int new_size = (p_width * p_height) * p_colours;
|
||||
|
||||
if(new_buffer == NULL) {
|
||||
if ( new_buffer == NULL ) {
|
||||
Error("Attempt to assign buffer from a NULL pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
if(buffer_size < new_size) {
|
||||
if ( buffer_size < new_size ) {
|
||||
Error("Attempt to assign buffer from an undersized buffer of size: %zu",buffer_size);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!p_height || !p_width) {
|
||||
if ( !p_height || !p_width ) {
|
||||
Error("Attempt to assign buffer with invalid width or height: %d %d",p_width,p_height);
|
||||
return;
|
||||
}
|
||||
|
||||
if(p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32) {
|
||||
if ( p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32 ) {
|
||||
Error("Attempt to assign buffer with unexpected colours per pixel: %d",p_colours);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !buffer || p_width != width || p_height != height || p_colours != colours || p_subpixelorder != subpixelorder) {
|
||||
if ( !buffer || p_width != width || p_height != height || p_colours != colours || p_subpixelorder != subpixelorder ) {
|
||||
|
||||
if (holdbuffer && buffer) {
|
||||
if (new_size > allocation) {
|
||||
if ( holdbuffer && buffer ) {
|
||||
if ( new_size > allocation ) {
|
||||
Error("Held buffer is undersized for assigned buffer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(new_size > allocation || !buffer) {
|
||||
if ( new_size > allocation || !buffer ) {
|
||||
DumpImgBuffer();
|
||||
AllocImgBuffer(new_size);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
#define ZM_IMAGE_H
|
||||
|
||||
#include "zm.h"
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include "zm_jpeg.h"
|
||||
}
|
||||
#include "zm_rgb.h"
|
||||
|
@ -32,6 +31,9 @@ extern "C"
|
|||
#include "zm_mem_utils.h"
|
||||
#include "zm_utils.h"
|
||||
|
||||
class Image;
|
||||
#include "zm_ffmpeg.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if HAVE_ZLIB_H
|
||||
|
@ -55,23 +57,26 @@ extern imgbufcpy_fptr_t fptr_imgbufcpy;
|
|||
/* Should be called from Image class functions */
|
||||
inline static uint8_t* AllocBuffer(size_t p_bufsize) {
|
||||
uint8_t* buffer = (uint8_t*)zm_mallocaligned(64,p_bufsize);
|
||||
if(buffer == NULL)
|
||||
if ( buffer == NULL )
|
||||
Fatal("Memory allocation failed: %s",strerror(errno));
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
inline static void DumpBuffer(uint8_t* buffer, int buffertype) {
|
||||
if (buffer && buffertype != ZM_BUFTYPE_DONTFREE) {
|
||||
if(buffertype == ZM_BUFTYPE_ZM)
|
||||
zm_freealigned(buffer);
|
||||
else if(buffertype == ZM_BUFTYPE_MALLOC)
|
||||
free(buffer);
|
||||
else if(buffertype == ZM_BUFTYPE_NEW)
|
||||
delete buffer;
|
||||
if ( buffer && buffertype != ZM_BUFTYPE_DONTFREE ) {
|
||||
if ( buffertype == ZM_BUFTYPE_ZM ) {
|
||||
zm_freealigned(buffer);
|
||||
} else if ( buffertype == ZM_BUFTYPE_MALLOC ) {
|
||||
free(buffer);
|
||||
} else if ( buffertype == ZM_BUFTYPE_NEW ) {
|
||||
delete buffer;
|
||||
/*else if(buffertype == ZM_BUFTYPE_AVMALLOC)
|
||||
av_free(buffer);
|
||||
*/
|
||||
} else {
|
||||
Error( "Unknown buffer type in DumpBuffer(%d)", buffertype );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,27 +85,23 @@ inline static void DumpBuffer(uint8_t* buffer, int buffertype) {
|
|||
// This is image class, and represents a frame captured from a
|
||||
// camera in raw form.
|
||||
//
|
||||
class Image
|
||||
{
|
||||
class Image {
|
||||
protected:
|
||||
|
||||
struct Edge
|
||||
{
|
||||
struct Edge {
|
||||
int min_y;
|
||||
int max_y;
|
||||
double min_x;
|
||||
double _1_m;
|
||||
|
||||
static int CompareYX( const void *p1, const void *p2 )
|
||||
{
|
||||
static int CompareYX( const void *p1, const void *p2 ) {
|
||||
const Edge *e1 = (const Edge *)p1, *e2 = (const Edge *)p2;
|
||||
if ( e1->min_y == e2->min_y )
|
||||
return( int(e1->min_x - e2->min_x) );
|
||||
else
|
||||
return( int(e1->min_y - e2->min_y) );
|
||||
}
|
||||
static int CompareX( const void *p1, const void *p2 )
|
||||
{
|
||||
static int CompareX( const void *p1, const void *p2 ) {
|
||||
const Edge *e1 = (const Edge *)p1, *e2 = (const Edge *)p2;
|
||||
return( int(e1->min_x - e2->min_x) );
|
||||
}
|
||||
|
@ -113,7 +114,7 @@ protected:
|
|||
}
|
||||
|
||||
inline void AllocImgBuffer(size_t p_bufsize) {
|
||||
if(buffer)
|
||||
if ( buffer )
|
||||
DumpImgBuffer();
|
||||
|
||||
buffer = AllocBuffer(p_bufsize);
|
||||
|
@ -149,12 +150,12 @@ protected:
|
|||
int holdbuffer; /* Hold the buffer instead of replacing it with new one */
|
||||
char text[1024];
|
||||
|
||||
|
||||
public:
|
||||
Image();
|
||||
Image( const char *filename );
|
||||
Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer=0);
|
||||
Image( const Image &p_image );
|
||||
Image( const AVFrame *frame );
|
||||
~Image();
|
||||
static void Initialise();
|
||||
static void Deinitialise();
|
||||
|
@ -176,27 +177,24 @@ public:
|
|||
inline void HoldBuffer(int tohold) { holdbuffer = tohold; }
|
||||
|
||||
inline void Empty() {
|
||||
if(!holdbuffer)
|
||||
DumpImgBuffer();
|
||||
|
||||
width = height = colours = size = pixels = subpixelorder = 0;
|
||||
if ( !holdbuffer )
|
||||
DumpImgBuffer();
|
||||
|
||||
width = height = colours = size = pixels = subpixelorder = 0;
|
||||
}
|
||||
|
||||
void Assign( unsigned int p_width, unsigned int p_height, unsigned int p_colours, unsigned int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size);
|
||||
void Assign( const Image &image );
|
||||
void AssignDirect( const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder, uint8_t *new_buffer, const size_t buffer_size, const int p_buffertype);
|
||||
|
||||
inline void CopyBuffer( const Image &image )
|
||||
{
|
||||
inline void CopyBuffer( const Image &image ) {
|
||||
Assign(image);
|
||||
}
|
||||
inline Image &operator=( const Image &image )
|
||||
{
|
||||
inline Image &operator=( const Image &image ) {
|
||||
Assign(image);
|
||||
return *this;
|
||||
}
|
||||
inline Image &operator=( const unsigned char *new_buffer )
|
||||
{
|
||||
inline Image &operator=( const unsigned char *new_buffer ) {
|
||||
(*fptr_imgbufcpy)(buffer, new_buffer, size);
|
||||
return( *this );
|
||||
}
|
||||
|
@ -207,9 +205,9 @@ public:
|
|||
bool ReadJpeg( const char *filename, unsigned int p_colours, unsigned int p_subpixelorder);
|
||||
|
||||
bool WriteJpeg ( const char *filename) const;
|
||||
bool WriteJpeg ( const char *filename, int quality_override ) const;
|
||||
bool WriteJpeg ( const char *filename, struct timeval timestamp ) const;
|
||||
bool WriteJpeg ( const char *filename, int quality_override, struct timeval timestamp ) const;
|
||||
bool WriteJpeg ( const char *filename, int quality_override ) const;
|
||||
bool WriteJpeg ( const char *filename, struct timeval timestamp ) const;
|
||||
bool WriteJpeg ( const char *filename, int quality_override, struct timeval timestamp ) const;
|
||||
|
||||
bool DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, unsigned int p_colours, unsigned int p_subpixelorder);
|
||||
bool EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override=0 ) const;
|
||||
|
@ -232,7 +230,7 @@ public:
|
|||
void Delta( const Image &image, Image* targetimage) const;
|
||||
|
||||
const Coord centreCoord( const char *text ) const;
|
||||
void MaskPrivacy( const unsigned char *p_bitmask, const Rgb pixel_colour=0x00222222 );
|
||||
void MaskPrivacy( const unsigned char *p_bitmask, const Rgb pixel_colour=0x00222222 );
|
||||
void Annotate( const char *p_text, const Coord &coord, const unsigned int size=1, const Rgb fg_colour=RGB_WHITE, const Rgb bg_colour=RGB_BLACK );
|
||||
Image *HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p_subpixelorder, const Box *limits=0 );
|
||||
//Image *HighlightEdges( Rgb colour, const Polygon &polygon );
|
||||
|
|
|
@ -112,6 +112,16 @@ Logger::Logger() :
|
|||
|
||||
Logger::~Logger() {
|
||||
terminate();
|
||||
smCodes.clear();
|
||||
smSyslogPriorities.clear();
|
||||
#if 0
|
||||
for ( StringMap::iterator itr = smCodes.begin(); itr != smCodes.end(); itr ++ ) {
|
||||
smCodes.erase( itr );
|
||||
}
|
||||
for ( IntMap::iterator itr = smSyslogPriorities.begin(); itr != smSyslogPriorities.end(); itr ++ ) {
|
||||
smSyslogPriorities.erase(itr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Logger::initialise( const std::string &id, const Options &options ) {
|
||||
|
@ -414,124 +424,128 @@ void Logger::closeSyslog() {
|
|||
}
|
||||
|
||||
void Logger::logPrint( bool hex, const char * const filepath, const int line, const int level, const char *fstring, ... ) {
|
||||
if ( level <= mEffectiveLevel ) {
|
||||
char timeString[64];
|
||||
char logString[8192];
|
||||
va_list argPtr;
|
||||
struct timeval timeVal;
|
||||
if ( level > mEffectiveLevel )
|
||||
return;
|
||||
char timeString[64];
|
||||
char logString[8192];
|
||||
va_list argPtr;
|
||||
struct timeval timeVal;
|
||||
|
||||
char *filecopy = strdup(filepath);
|
||||
const char * const file = basename(filecopy);
|
||||
const char *classString = smCodes[level].c_str();
|
||||
char *filecopy = strdup(filepath);
|
||||
const char * const file = basename(filecopy);
|
||||
const char *classString = smCodes[level].c_str();
|
||||
|
||||
if ( level < PANIC || level > DEBUG9 )
|
||||
Panic( "Invalid logger level %d", level );
|
||||
if ( level < PANIC || level > DEBUG9 )
|
||||
Panic( "Invalid logger level %d", level );
|
||||
|
||||
gettimeofday( &timeVal, NULL );
|
||||
gettimeofday( &timeVal, NULL );
|
||||
|
||||
#if 0
|
||||
if ( logRuntime ) {
|
||||
static struct timeval logStart;
|
||||
if ( logRuntime ) {
|
||||
static struct timeval logStart;
|
||||
|
||||
subtractTime( &timeVal, &logStart );
|
||||
subtractTime( &timeVal, &logStart );
|
||||
|
||||
snprintf( timeString, sizeof(timeString), "%ld.%03ld", timeVal.tv_sec, timeVal.tv_usec/1000 );
|
||||
} else {
|
||||
snprintf( timeString, sizeof(timeString), "%ld.%03ld", timeVal.tv_sec, timeVal.tv_usec/1000 );
|
||||
} else {
|
||||
#endif
|
||||
char *timePtr = timeString;
|
||||
timePtr += strftime( timePtr, sizeof(timeString), "%x %H:%M:%S", localtime(&timeVal.tv_sec) );
|
||||
snprintf( timePtr, sizeof(timeString)-(timePtr-timeString), ".%06ld", timeVal.tv_usec );
|
||||
char *timePtr = timeString;
|
||||
timePtr += strftime( timePtr, sizeof(timeString), "%x %H:%M:%S", localtime(&timeVal.tv_sec) );
|
||||
snprintf( timePtr, sizeof(timeString)-(timePtr-timeString), ".%06ld", timeVal.tv_usec );
|
||||
#if 0
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pid_t tid;
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
|
||||
if (tid < 0 ) // Thread/Process id
|
||||
if (tid < 0 ) // Thread/Process id
|
||||
#else
|
||||
#ifdef HAVE_SYSCALL
|
||||
#ifdef __FreeBSD_kernel__
|
||||
if ( (syscall(SYS_thr_self, &tid)) < 0 ) // Thread/Process id
|
||||
if ( (syscall(SYS_thr_self, &tid)) < 0 ) // Thread/Process id
|
||||
|
||||
# else
|
||||
// SOLARIS doesn't have SYS_gettid; don't assume
|
||||
// SOLARIS doesn't have SYS_gettid; don't assume
|
||||
#ifdef SYS_gettid
|
||||
if ( (tid = syscall(SYS_gettid)) < 0 ) // Thread/Process id
|
||||
if ( (tid = syscall(SYS_gettid)) < 0 ) // Thread/Process id
|
||||
#endif // SYS_gettid
|
||||
#endif
|
||||
#endif // HAVE_SYSCALL
|
||||
#endif
|
||||
tid = getpid(); // Process id
|
||||
tid = getpid(); // Process id
|
||||
|
||||
char *logPtr = logString;
|
||||
logPtr += snprintf( logPtr, sizeof(logString), "%s %s[%d].%s-%s/%d [",
|
||||
timeString,
|
||||
mId.c_str(),
|
||||
tid,
|
||||
classString,
|
||||
file,
|
||||
line
|
||||
);
|
||||
char *syslogStart = logPtr;
|
||||
char *logPtr = logString;
|
||||
logPtr += snprintf( logPtr, sizeof(logString), "%s %s[%d].%s-%s/%d [",
|
||||
timeString,
|
||||
mId.c_str(),
|
||||
tid,
|
||||
classString,
|
||||
file,
|
||||
line
|
||||
);
|
||||
char *syslogStart = logPtr;
|
||||
|
||||
va_start( argPtr, fstring );
|
||||
if ( hex ) {
|
||||
unsigned char *data = va_arg( argPtr, unsigned char * );
|
||||
int len = va_arg( argPtr, int );
|
||||
int i;
|
||||
logPtr += snprintf( logPtr, sizeof(logString)-(logPtr-logString), "%d:", len );
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
logPtr += snprintf( logPtr, sizeof(logString)-(logPtr-logString), " %02x", data[i] );
|
||||
}
|
||||
} else {
|
||||
logPtr += vsnprintf( logPtr, sizeof(logString)-(logPtr-logString), fstring, argPtr );
|
||||
va_start( argPtr, fstring );
|
||||
if ( hex ) {
|
||||
unsigned char *data = va_arg( argPtr, unsigned char * );
|
||||
int len = va_arg( argPtr, int );
|
||||
int i;
|
||||
logPtr += snprintf( logPtr, sizeof(logString)-(logPtr-logString), "%d:", len );
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
logPtr += snprintf( logPtr, sizeof(logString)-(logPtr-logString), " %02x", data[i] );
|
||||
}
|
||||
va_end(argPtr);
|
||||
char *syslogEnd = logPtr;
|
||||
strncpy( logPtr, "]\n", sizeof(logString)-(logPtr-logString) );
|
||||
} else {
|
||||
logPtr += vsnprintf( logPtr, sizeof(logString)-(logPtr-logString), fstring, argPtr );
|
||||
}
|
||||
va_end(argPtr);
|
||||
char *syslogEnd = logPtr;
|
||||
strncpy( logPtr, "]\n", sizeof(logString)-(logPtr-logString) );
|
||||
|
||||
if ( level <= mTermLevel ) {
|
||||
printf( "%s", logString );
|
||||
fflush( stdout );
|
||||
}
|
||||
if ( level <= mFileLevel ) {
|
||||
fprintf( mLogFileFP, "%s", logString );
|
||||
if ( level <= mTermLevel ) {
|
||||
puts( logString );
|
||||
fflush( stdout );
|
||||
}
|
||||
if ( level <= mFileLevel ) {
|
||||
if ( mLogFileFP ) {
|
||||
fputs( logString, mLogFileFP );
|
||||
if ( mFlush )
|
||||
fflush( mLogFileFP );
|
||||
} else {
|
||||
puts("Logging to file, but file not open\n");
|
||||
}
|
||||
*syslogEnd = '\0';
|
||||
if ( level <= mDatabaseLevel ) {
|
||||
char sql[ZM_SQL_MED_BUFSIZ];
|
||||
char escapedString[(strlen(syslogStart)*2)+1];
|
||||
}
|
||||
*syslogEnd = '\0';
|
||||
if ( level <= mDatabaseLevel ) {
|
||||
char sql[ZM_SQL_MED_BUFSIZ];
|
||||
char escapedString[(strlen(syslogStart)*2)+1];
|
||||
|
||||
mysql_real_escape_string( &dbconn, escapedString, syslogStart, strlen(syslogStart) );
|
||||
mysql_real_escape_string( &dbconn, escapedString, syslogStart, strlen(syslogStart) );
|
||||
|
||||
snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, %d, '%s', '%s', '%s', %d )", timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString, file, line );
|
||||
if ( mysql_query( &dbconn, sql ) ) {
|
||||
Level tempDatabaseLevel = mDatabaseLevel;
|
||||
databaseLevel( NOLOG );
|
||||
Error( "Can't insert log entry: sql(%s) error(%s)", sql, mysql_error( &dbconn ) );
|
||||
databaseLevel(tempDatabaseLevel);
|
||||
}
|
||||
}
|
||||
if ( level <= mSyslogLevel ) {
|
||||
int priority = smSyslogPriorities[level];
|
||||
//priority |= LOG_DAEMON;
|
||||
syslog( priority, "%s [%s] [%s]", classString, mId.c_str(), syslogStart );
|
||||
snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, %d, '%s', '%s', '%s', %d )", timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString, file, line );
|
||||
if ( mysql_query( &dbconn, sql ) ) {
|
||||
Level tempDatabaseLevel = mDatabaseLevel;
|
||||
databaseLevel( NOLOG );
|
||||
Error( "Can't insert log entry: sql(%s) error(%s)", sql, mysql_error( &dbconn ) );
|
||||
databaseLevel(tempDatabaseLevel);
|
||||
}
|
||||
}
|
||||
if ( level <= mSyslogLevel ) {
|
||||
int priority = smSyslogPriorities[level];
|
||||
//priority |= LOG_DAEMON;
|
||||
syslog( priority, "%s [%s] [%s]", classString, mId.c_str(), syslogStart );
|
||||
}
|
||||
|
||||
free(filecopy);
|
||||
if ( level <= FATAL ) {
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
if ( level <= PANIC )
|
||||
abort();
|
||||
exit( -1 );
|
||||
}
|
||||
free(filecopy);
|
||||
if ( level <= FATAL ) {
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
if ( level <= PANIC )
|
||||
abort();
|
||||
exit( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -544,6 +558,8 @@ void logInit( const char *name, const Logger::Options &options ) {
|
|||
}
|
||||
|
||||
void logTerm() {
|
||||
if ( Logger::smInstance )
|
||||
if ( Logger::smInstance ) {
|
||||
delete Logger::smInstance;
|
||||
Logger::smInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
#endif // HAVE_SYS_SYSCALL_H
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
class Logger
|
||||
{
|
||||
class Logger {
|
||||
public:
|
||||
enum {
|
||||
NOOPT=-6,
|
||||
|
|
|
@ -397,8 +397,10 @@ Monitor::Monitor(
|
|||
|
||||
if ( purpose == CAPTURE ) {
|
||||
|
||||
this->connect();
|
||||
if ( ! mem_ptr ) exit(-1);
|
||||
if ( ! this->connect() ) {
|
||||
Error("unable to connect, but doing capture");
|
||||
exit(-1);
|
||||
}
|
||||
memset( mem_ptr, 0, mem_size );
|
||||
shared_data->size = sizeof(SharedData);
|
||||
shared_data->active = enabled;
|
||||
|
@ -487,38 +489,53 @@ bool Monitor::connect() {
|
|||
#if ZM_MEM_MAPPED
|
||||
snprintf( mem_file, sizeof(mem_file), "%s/zm.mmap.%d", staticConfig.PATH_MAP.c_str(), id );
|
||||
map_fd = open( mem_file, O_RDWR|O_CREAT, (mode_t)0600 );
|
||||
if ( map_fd < 0 )
|
||||
if ( map_fd < 0 ) {
|
||||
Fatal( "Can't open memory map file %s, probably not enough space free: %s", mem_file, strerror(errno) );
|
||||
} else {
|
||||
Debug(3, "Success opening mmap file at (%s)", mem_file );
|
||||
}
|
||||
|
||||
struct stat map_stat;
|
||||
if ( fstat( map_fd, &map_stat ) < 0 )
|
||||
Fatal( "Can't stat memory map file %s: %s, is the zmc process for this monitor running?", mem_file, strerror(errno) );
|
||||
if ( map_stat.st_size != mem_size && purpose == CAPTURE ) {
|
||||
// Allocate the size
|
||||
if ( ftruncate( map_fd, mem_size ) < 0 ) {
|
||||
Fatal( "Can't extend memory map file %s to %d bytes: %s", mem_file, mem_size, strerror(errno) );
|
||||
}
|
||||
} else if ( map_stat.st_size == 0 ) {
|
||||
Error( "Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size, mem_size );
|
||||
return false;
|
||||
} else if ( map_stat.st_size != mem_size ) {
|
||||
Error( "Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size );
|
||||
return false;
|
||||
} else {
|
||||
#ifdef MAP_LOCKED
|
||||
mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0 );
|
||||
if ( mem_ptr == MAP_FAILED ) {
|
||||
if ( errno == EAGAIN ) {
|
||||
Debug( 1, "Unable to map file %s (%d bytes) to locked memory, trying unlocked", mem_file, mem_size );
|
||||
#endif
|
||||
mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0 );
|
||||
Debug( 1, "Mapped file %s (%d bytes) to locked memory, unlocked", mem_file, mem_size );
|
||||
#ifdef MAP_LOCKED
|
||||
|
||||
if ( map_stat.st_size != mem_size ) {
|
||||
if ( purpose == CAPTURE ) {
|
||||
// Allocate the size
|
||||
if ( ftruncate( map_fd, mem_size ) < 0 ) {
|
||||
Fatal( "Can't extend memory map file %s to %d bytes: %s", mem_file, mem_size, strerror(errno) );
|
||||
}
|
||||
} else if ( map_stat.st_size == 0 ) {
|
||||
Error( "Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size, mem_size );
|
||||
return false;
|
||||
} else {
|
||||
Error( "Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Debug(3, "MMap file size is %ld", map_stat.st_size );
|
||||
#ifdef MAP_LOCKED
|
||||
mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0 );
|
||||
if ( mem_ptr == MAP_FAILED ) {
|
||||
if ( errno == EAGAIN ) {
|
||||
Debug( 1, "Unable to map file %s (%d bytes) to locked memory, trying unlocked", mem_file, mem_size );
|
||||
|
||||
#endif
|
||||
if ( mem_ptr == MAP_FAILED )
|
||||
Fatal( "Can't map file %s (%d bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno );
|
||||
mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0 );
|
||||
Debug( 1, "Mapped file %s (%d bytes) to unlocked memory", mem_file, mem_size );
|
||||
#ifdef MAP_LOCKED
|
||||
} else {
|
||||
Error( "Unable to map file %s (%d bytes) to locked memory (%s)", mem_file, mem_size , strerror(errno) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if ( mem_ptr == MAP_FAILED )
|
||||
Fatal( "Can't map file %s (%d bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno );
|
||||
if ( mem_ptr == NULL ) {
|
||||
Error( "mmap gave a null address:" );
|
||||
} else {
|
||||
Debug(3, "mmapped to %p", mem_ptr );
|
||||
}
|
||||
#else // ZM_MEM_MAPPED
|
||||
shm_id = shmget( (config.shm_key&0xffff0000)|id, mem_size, IPC_CREAT|0700 );
|
||||
|
@ -537,26 +554,26 @@ bool Monitor::connect() {
|
|||
video_store_data = (VideoStoreData *)((char *)trigger_data + sizeof(TriggerData));
|
||||
struct timeval *shared_timestamps = (struct timeval *)((char *)video_store_data + sizeof(VideoStoreData));
|
||||
unsigned char *shared_images = (unsigned char *)((char *)shared_timestamps + (image_buffer_count*sizeof(struct timeval)));
|
||||
|
||||
|
||||
if(((unsigned long)shared_images % 64) != 0) {
|
||||
if ( ((unsigned long)shared_images % 64) != 0 ) {
|
||||
/* Align images buffer to nearest 64 byte boundary */
|
||||
Debug(3,"Aligning shared memory images to the next 64 byte boundary");
|
||||
shared_images = (uint8_t*)((unsigned long)shared_images + (64 - ((unsigned long)shared_images % 64)));
|
||||
}
|
||||
Debug(3, "Allocating %d image buffers", image_buffer_count );
|
||||
image_buffer = new Snapshot[image_buffer_count];
|
||||
for ( int i = 0; i < image_buffer_count; i++ ) {
|
||||
image_buffer[i].timestamp = &(shared_timestamps[i]);
|
||||
image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) );
|
||||
image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */
|
||||
}
|
||||
if ( (deinterlacing & 0xff) == 4) {
|
||||
/* Four field motion adaptive deinterlacing in use */
|
||||
/* Allocate a buffer for the next image */
|
||||
next_buffer.image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
||||
next_buffer.timestamp = new struct timeval;
|
||||
}
|
||||
|
||||
Debug(3, "Allocating %d image buffers", image_buffer_count );
|
||||
image_buffer = new Snapshot[image_buffer_count];
|
||||
for ( int i = 0; i < image_buffer_count; i++ ) {
|
||||
image_buffer[i].timestamp = &(shared_timestamps[i]);
|
||||
image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) );
|
||||
image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */
|
||||
}
|
||||
if ( (deinterlacing & 0xff) == 4) {
|
||||
/* Four field motion adaptive deinterlacing in use */
|
||||
/* Allocate a buffer for the next image */
|
||||
next_buffer.image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
||||
next_buffer.timestamp = new struct timeval;
|
||||
}
|
||||
if ( ( purpose == ANALYSIS ) && analysis_fps ) {
|
||||
// Size of pre event buffer must be greater than pre_event_count
|
||||
// if alarm_frame_count > 1, because in this case the buffer contains
|
||||
|
@ -568,7 +585,7 @@ bool Monitor::connect() {
|
|||
pre_event_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
||||
}
|
||||
}
|
||||
|
||||
Debug(3, "Success connecting");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1320,14 +1337,15 @@ bool Monitor::Analyse() {
|
|||
score += motion_score;
|
||||
}
|
||||
noteSetMap[MOTION_CAUSE] = zoneSet;
|
||||
|
||||
}
|
||||
} // end if motion_score
|
||||
shared_data->active = signal;
|
||||
}
|
||||
} // end if signal change
|
||||
|
||||
if ( (!signal_change && signal) && n_linked_monitors > 0 ) {
|
||||
bool first_link = true;
|
||||
Event::StringSet noteSet;
|
||||
for ( int i = 0; i < n_linked_monitors; i++ ) {
|
||||
// TODO: Shouldn't we try to connect?
|
||||
if ( linked_monitors[i]->isConnected() ) {
|
||||
if ( linked_monitors[i]->hasAlarmed() ) {
|
||||
if ( !event ) {
|
||||
|
@ -1353,11 +1371,12 @@ bool Monitor::Analyse() {
|
|||
if ( (!signal_change && signal) && (function == RECORD || function == MOCORD) ) {
|
||||
if ( event ) {
|
||||
//TODO: We shouldn't have to do this every time. Not sure why it clears itself if this isn't here??
|
||||
snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile());
|
||||
//snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile());
|
||||
Debug( 3, "Detected new event at (%d.%d)", timestamp->tv_sec,timestamp->tv_usec );
|
||||
|
||||
if ( section_length ) {
|
||||
int section_mod = timestamp->tv_sec%section_length;
|
||||
// TODO: Wouldn't this be clearer if we just did something like if now - event->start > section_length ?
|
||||
int section_mod = timestamp->tv_sec % section_length;
|
||||
Debug( 3, "Section length (%d) Last Section Mod(%d), new section mod(%d)", section_length, last_section_mod, section_mod );
|
||||
if ( section_mod < last_section_mod ) {
|
||||
//if ( state == IDLE || state == TAPE || event_close_mode == CLOSE_TIME ) {
|
||||
|
@ -1375,8 +1394,8 @@ bool Monitor::Analyse() {
|
|||
} else {
|
||||
last_section_mod = section_mod;
|
||||
}
|
||||
}
|
||||
} // end if section_length
|
||||
} // end if section_length
|
||||
} // end if event
|
||||
|
||||
if ( ! event ) {
|
||||
|
||||
|
@ -2978,7 +2997,7 @@ void Monitor::TimestampImage( Image *ts_image, const struct timeval *ts_time ) c
|
|||
const char *s_ptr = label_time_text;
|
||||
char *d_ptr = label_text;
|
||||
while ( *s_ptr && ((d_ptr-label_text) < (unsigned int)sizeof(label_text)) ) {
|
||||
if ( *s_ptr == '%' ) {
|
||||
if ( *s_ptr == config.timestamp_code_char[0] ) {
|
||||
bool found_macro = false;
|
||||
switch ( *(s_ptr+1) ) {
|
||||
case 'N' :
|
||||
|
|
|
@ -484,7 +484,10 @@ void MonitorStream::runStream() {
|
|||
|
||||
openComms();
|
||||
|
||||
checkInitialised();
|
||||
if ( ! checkInitialised() ) {
|
||||
Error("Not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
updateFrameRate( monitor->GetFPS() );
|
||||
|
||||
|
@ -732,8 +735,9 @@ void MonitorStream::runStream() {
|
|||
if ( rmdir( swap_path ) < 0 ) {
|
||||
Error( "Can't rmdir '%s': %s", swap_path, strerror(errno) );
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end if checking for swap_path
|
||||
} // end if buffered_playback
|
||||
|
||||
if ( swap_path ) free( swap_path );
|
||||
closeComms();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "zm_packet.h"
|
||||
#include "zm_ffmpeg.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
ZMPacket::ZMPacket( AVPacket *p ) {
|
||||
|
|
|
@ -19,18 +19,17 @@
|
|||
|
||||
#include "zm_packetqueue.h"
|
||||
#include "zm_ffmpeg.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
#define VIDEO_QUEUESIZE 200
|
||||
#define AUDIO_QUEUESIZE 50
|
||||
|
||||
using namespace std;
|
||||
|
||||
zm_packetqueue::zm_packetqueue(){
|
||||
|
||||
}
|
||||
|
||||
zm_packetqueue::~zm_packetqueue() {
|
||||
|
||||
clearQueue();
|
||||
}
|
||||
|
||||
bool zm_packetqueue::queuePacket( ZMPacket* zm_packet ) {
|
||||
|
@ -68,7 +67,7 @@ unsigned int zm_packetqueue::clearQueue( unsigned int frames_to_keep, int stream
|
|||
return 0;
|
||||
}
|
||||
|
||||
list<ZMPacket *>::reverse_iterator it;
|
||||
std::list<ZMPacket *>::reverse_iterator it;
|
||||
ZMPacket *packet = NULL;
|
||||
|
||||
for ( it = pktQueue.rbegin(); it != pktQueue.rend() && frames_to_keep; ++it ) {
|
||||
|
@ -121,7 +120,7 @@ void zm_packetqueue::clear_unwanted_packets( timeval *recording_started, int mVi
|
|||
|
||||
// Step 1 - find keyframe < recording_started.
|
||||
// Step 2 - pop packets until we get to the packet in step 2
|
||||
list<ZMPacket *>::reverse_iterator it;
|
||||
std::list<ZMPacket *>::reverse_iterator it;
|
||||
|
||||
Debug(3, "Looking for keyframe after start recording stream id (%d)", mVideoStreamId );
|
||||
for ( it = pktQueue.rbegin(); it != pktQueue.rend(); ++ it ) {
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* ZoneMinder FFMPEG 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_ffmpeg.h"
|
||||
#include "zm_image.h"
|
||||
#include "zm_rgb.h"
|
||||
|
||||
#include "zm_swscale.h"
|
||||
|
||||
#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
SWScale::SWScale() : gotdefaults(false), swscale_ctx(NULL), input_avframe(NULL), output_avframe(NULL) {
|
||||
Debug(4,"SWScale object created");
|
||||
|
||||
/* Allocate AVFrame for the input */
|
||||
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
|
||||
input_avframe = av_frame_alloc();
|
||||
#else
|
||||
input_avframe = avcodec_alloc_frame();
|
||||
#endif
|
||||
if(input_avframe == NULL) {
|
||||
Fatal("Failed allocating AVFrame for the input");
|
||||
}
|
||||
|
||||
/* Allocate AVFrame for the output */
|
||||
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
|
||||
output_avframe = av_frame_alloc();
|
||||
#else
|
||||
output_avframe = avcodec_alloc_frame();
|
||||
#endif
|
||||
if(output_avframe == NULL) {
|
||||
Fatal("Failed allocating AVFrame for the output");
|
||||
}
|
||||
}
|
||||
|
||||
SWScale::~SWScale() {
|
||||
|
||||
/* Free up everything */
|
||||
av_frame_free( &input_avframe );
|
||||
//input_avframe = NULL;
|
||||
|
||||
av_frame_free( &output_avframe );
|
||||
//output_avframe = NULL;
|
||||
|
||||
if(swscale_ctx) {
|
||||
sws_freeContext(swscale_ctx);
|
||||
swscale_ctx = NULL;
|
||||
}
|
||||
|
||||
Debug(4,"SWScale object destroyed");
|
||||
}
|
||||
|
||||
int SWScale::SetDefaults(enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
|
||||
|
||||
/* Assign the defaults */
|
||||
default_input_pf = in_pf;
|
||||
default_output_pf = out_pf;
|
||||
default_width = width;
|
||||
default_height = height;
|
||||
|
||||
gotdefaults = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
|
||||
/* Parameter checking */
|
||||
if(in_buffer == NULL || out_buffer == NULL) {
|
||||
Error("NULL Input or output buffer");
|
||||
return -1;
|
||||
}
|
||||
// if(in_pf == 0 || out_pf == 0) {
|
||||
// Error("Invalid input or output pixel formats");
|
||||
// return -2;
|
||||
// }
|
||||
if (!width || !height) {
|
||||
Error("Invalid width or height");
|
||||
return -3;
|
||||
}
|
||||
|
||||
#if LIBSWSCALE_VERSION_CHECK(0, 8, 0, 8, 0)
|
||||
/* Warn if the input or output pixelformat is not supported */
|
||||
if(!sws_isSupportedInput(in_pf)) {
|
||||
Warning("swscale does not support the input format: %c%c%c%c",(in_pf)&0xff,((in_pf)&0xff),((in_pf>>16)&0xff),((in_pf>>24)&0xff));
|
||||
}
|
||||
if(!sws_isSupportedOutput(out_pf)) {
|
||||
Warning("swscale does not support the output format: %c%c%c%c",(out_pf)&0xff,((out_pf>>8)&0xff),((out_pf>>16)&0xff),((out_pf>>24)&0xff));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check the buffer sizes */
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
size_t insize = av_image_get_buffer_size(in_pf, width, height,1);
|
||||
#else
|
||||
size_t insize = avpicture_get_size(in_pf, width, height);
|
||||
#endif
|
||||
if(insize != in_buffer_size) {
|
||||
Error("The input buffer size does not match the expected size for the input format. Required: %d Available: %d", insize, in_buffer_size);
|
||||
return -4;
|
||||
}
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
size_t outsize = av_image_get_buffer_size(out_pf, width, height,1);
|
||||
#else
|
||||
size_t outsize = avpicture_get_size(out_pf, width, height);
|
||||
#endif
|
||||
|
||||
if(outsize < out_buffer_size) {
|
||||
Error("The output buffer is undersized for the output format. Required: %d Available: %d", outsize, out_buffer_size);
|
||||
return -5;
|
||||
}
|
||||
|
||||
/* Get the context */
|
||||
swscale_ctx = sws_getCachedContext( swscale_ctx, width, height, in_pf, width, height, out_pf, SWS_FAST_BILINEAR, NULL, NULL, NULL );
|
||||
if(swscale_ctx == NULL) {
|
||||
Error("Failed getting swscale context");
|
||||
return -6;
|
||||
}
|
||||
|
||||
/* Fill in the buffers */
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
if (av_image_fill_arrays(input_avframe->data, input_avframe->linesize,
|
||||
(uint8_t*) in_buffer, in_pf, width, height, 1) <= 0) {
|
||||
#else
|
||||
if (avpicture_fill((AVPicture*) input_avframe, (uint8_t*) in_buffer,
|
||||
in_pf, width, height) <= 0) {
|
||||
#endif
|
||||
Error("Failed filling input frame with input buffer");
|
||||
return -7;
|
||||
}
|
||||
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||
if (av_image_fill_arrays(output_avframe->data, output_avframe->linesize,
|
||||
out_buffer, out_pf, width, height, 1) <= 0) {
|
||||
#else
|
||||
if (avpicture_fill((AVPicture*) output_avframe, out_buffer, out_pf, width,
|
||||
height) <= 0) {
|
||||
#endif
|
||||
Error("Failed filling output frame with output buffer");
|
||||
return -8;
|
||||
}
|
||||
|
||||
/* Do the conversion */
|
||||
if(!sws_scale(swscale_ctx, input_avframe->data, input_avframe->linesize, 0, height, output_avframe->data, output_avframe->linesize ) ) {
|
||||
Error("swscale conversion failed");
|
||||
return -10;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SWScale::Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
|
||||
if(img->Width() != width) {
|
||||
Error("Source image width differs. Source: %d Output: %d",img->Width(), width);
|
||||
return -12;
|
||||
}
|
||||
|
||||
if(img->Height() != height) {
|
||||
Error("Source image height differs. Source: %d Output: %d",img->Height(), height);
|
||||
return -13;
|
||||
}
|
||||
|
||||
return Convert(img->Buffer(),img->Size(),out_buffer,out_buffer_size,in_pf,out_pf,width,height);
|
||||
}
|
||||
|
||||
int SWScale::ConvertDefaults(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size) {
|
||||
|
||||
if(!gotdefaults) {
|
||||
Error("Defaults are not set");
|
||||
return -24;
|
||||
}
|
||||
|
||||
return Convert(img,out_buffer,out_buffer_size,default_input_pf,default_output_pf,default_width,default_height);
|
||||
}
|
||||
|
||||
int SWScale::ConvertDefaults(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size) {
|
||||
|
||||
if(!gotdefaults) {
|
||||
Error("Defaults are not set");
|
||||
return -24;
|
||||
}
|
||||
|
||||
return Convert(in_buffer,in_buffer_size,out_buffer,out_buffer_size,default_input_pf,default_output_pf,default_width,default_height);
|
||||
}
|
||||
#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef ZM_SWSCALE_H
|
||||
#define ZM_SWSCALE_H
|
||||
|
||||
#include "zm_image.h"
|
||||
#include "zm_ffmpeg.h"
|
||||
|
||||
/* SWScale wrapper class to make our life easier and reduce code reuse */
|
||||
#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
class SWScale {
|
||||
public:
|
||||
SWScale();
|
||||
~SWScale();
|
||||
int SetDefaults(enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
|
||||
int ConvertDefaults(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size);
|
||||
int ConvertDefaults(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size);
|
||||
int Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
|
||||
int Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
|
||||
|
||||
protected:
|
||||
bool gotdefaults;
|
||||
struct SwsContext* swscale_ctx;
|
||||
AVFrame* input_avframe;
|
||||
AVFrame* output_avframe;
|
||||
enum _AVPIXELFORMAT default_input_pf;
|
||||
enum _AVPIXELFORMAT default_output_pf;
|
||||
unsigned int default_width;
|
||||
unsigned int default_height;
|
||||
};
|
||||
#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
|
||||
|
||||
#endif
|
|
@ -21,6 +21,7 @@
|
|||
#include "zm_utils.h"
|
||||
#include "zm_ffmpeg.h"
|
||||
#include "zm_buffer.h"
|
||||
#include "zm_swscale.h"
|
||||
|
||||
/*
|
||||
#define HAVE_LIBX264 1
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,35 +18,35 @@ class VideoStore {
|
|||
private:
|
||||
unsigned int packets_written;
|
||||
|
||||
AVOutputFormat *output_format;
|
||||
AVOutputFormat *out_format;
|
||||
AVFormatContext *oc;
|
||||
AVStream *video_output_stream;
|
||||
AVStream *audio_output_stream;
|
||||
AVCodecContext *video_output_context;
|
||||
AVStream *video_out_stream;
|
||||
AVStream *audio_out_stream;
|
||||
AVCodecContext *video_out_ctx;
|
||||
|
||||
AVStream *video_input_stream;
|
||||
AVStream *audio_input_stream;
|
||||
AVStream *video_in_stream;
|
||||
AVStream *audio_in_stream;
|
||||
|
||||
// Move this into the object so that we aren't constantly allocating/deallocating it on the stack
|
||||
AVPacket opkt;
|
||||
// we are transcoding
|
||||
AVFrame *input_frame;
|
||||
AVFrame *output_frame;
|
||||
AVFrame *in_frame;
|
||||
AVFrame *out_frame;
|
||||
|
||||
AVCodecContext *video_input_context;
|
||||
AVCodecContext *audio_input_context;
|
||||
AVCodecContext *video_in_ctx;
|
||||
AVCodecContext *audio_in_ctx;
|
||||
int ret;
|
||||
|
||||
// The following are used when encoding the audio stream to AAC
|
||||
AVCodec *audio_output_codec;
|
||||
AVCodecContext *audio_output_context;
|
||||
AVCodec *audio_out_codec;
|
||||
AVCodecContext *audio_out_ctx;
|
||||
int data_present;
|
||||
AVAudioFifo *fifo;
|
||||
int output_frame_size;
|
||||
int out_frame_size;
|
||||
#ifdef HAVE_LIBAVRESAMPLE
|
||||
AVAudioResampleContext* resample_context;
|
||||
AVAudioResampleContext* resample_ctx;
|
||||
#endif
|
||||
uint8_t *converted_input_samples;
|
||||
uint8_t *converted_in_samples;
|
||||
|
||||
const char *filename;
|
||||
const char *format;
|
||||
|
@ -54,24 +54,30 @@ AVAudioResampleContext* resample_context;
|
|||
bool keyframeMessage;
|
||||
int keyframeSkipNumber;
|
||||
|
||||
// These are for input
|
||||
// These are for in
|
||||
int64_t video_last_pts;
|
||||
int64_t video_last_dts;
|
||||
int64_t audio_last_pts;
|
||||
int64_t audio_last_dts;
|
||||
|
||||
// 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 video_previous_pts;
|
||||
int64_t video_previous_dts;
|
||||
int64_t audio_previous_pts;
|
||||
int64_t audio_previous_dts;
|
||||
// These are for out, should start at zero. We assume they do not wrap because we just aren't going to save files that big.
|
||||
int64_t video_next_pts;
|
||||
int64_t video_next_dts;
|
||||
int64_t audio_next_pts;
|
||||
int64_t audio_next_dts;
|
||||
|
||||
int64_t filter_in_rescale_delta_last;
|
||||
|
||||
bool setup_resampler();
|
||||
|
||||
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_in_stream,
|
||||
AVStream *audio_in_stream,
|
||||
int64_t nStartTime,
|
||||
Monitor * p_monitor);
|
||||
~VideoStore();
|
||||
|
||||
int writeVideoFramePacket( AVPacket *pkt );
|
||||
|
|
|
@ -68,7 +68,7 @@ void Zone::Setup(
|
|||
overload_frames = p_overload_frames;
|
||||
extend_alarm_frames = p_extend_alarm_frames;
|
||||
|
||||
Debug( 1, "Initialised zone %d/%s - %d - %dx%d - Rgb:%06x, CM:%d, MnAT:%d, MxAT:%d, MnAP:%d, MxAP:%d, FB:%dx%d, MnFP:%d, MxFP:%d, MnBS:%d, MxBS:%d, MnB:%d, MxB:%d, OF: %d, AF: %d", id, label, type, polygon.Width(), polygon.Height(), alarm_rgb, check_method, min_pixel_threshold, max_pixel_threshold, min_alarm_pixels, max_alarm_pixels, filter_box.X(), filter_box.Y(), min_filter_pixels, max_filter_pixels, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs, overload_frames, extend_alarm_frames );
|
||||
//Debug( 1, "Initialised zone %d/%s - %d - %dx%d - Rgb:%06x, CM:%d, MnAT:%d, MxAT:%d, MnAP:%d, MxAP:%d, FB:%dx%d, MnFP:%d, MxFP:%d, MnBS:%d, MxBS:%d, MnB:%d, MxB:%d, OF: %d, AF: %d", id, label, type, polygon.Width(), polygon.Height(), alarm_rgb, check_method, min_pixel_threshold, max_pixel_threshold, min_alarm_pixels, max_alarm_pixels, filter_box.X(), filter_box.Y(), min_filter_pixels, max_filter_pixels, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs, overload_frames, extend_alarm_frames );
|
||||
|
||||
alarmed = false;
|
||||
was_alarmed = false;
|
||||
|
|
10
src/zms.cpp
10
src/zms.cpp
|
@ -52,7 +52,7 @@ int main( int argc, const char *argv[] ) {
|
|||
|
||||
srand( getpid() * time( 0 ) );
|
||||
|
||||
enum { ZMS_MONITOR, ZMS_EVENT } source = ZMS_MONITOR;
|
||||
enum { ZMS_UNKNOWN, ZMS_MONITOR, ZMS_EVENT } source = ZMS_UNKNOWN;
|
||||
enum { ZMS_JPEG, ZMS_MPEG, ZMS_RAW, ZMS_ZIP, ZMS_SINGLE } mode = ZMS_JPEG;
|
||||
char format[32] = "";
|
||||
int monitor_id = 0;
|
||||
|
@ -121,12 +121,16 @@ int main( int argc, const char *argv[] ) {
|
|||
strncpy( format, value, sizeof(format) );
|
||||
} else if ( !strcmp( name, "monitor" ) ) {
|
||||
monitor_id = atoi( value );
|
||||
if ( source == ZMS_UNKNOWN )
|
||||
source = ZMS_MONITOR;
|
||||
} else if ( !strcmp( name, "time" ) ) {
|
||||
event_time = atoi( value );
|
||||
} else if ( !strcmp( name, "event" ) ) {
|
||||
event_id = strtoull( value, (char **)NULL, 10 );
|
||||
source = ZMS_EVENT;
|
||||
} else if ( !strcmp( name, "frame" ) ) {
|
||||
frame_id = strtoull( value, (char **)NULL, 10 );
|
||||
source = ZMS_EVENT;
|
||||
} else if ( !strcmp( name, "scale" ) ) {
|
||||
scale = atoi( value );
|
||||
} else if ( !strcmp( name, "rate" ) ) {
|
||||
|
@ -264,6 +268,7 @@ int main( int argc, const char *argv[] ) {
|
|||
if ( ! event_id ) {
|
||||
Fatal( "Can't view an event without specifying an event_id." );
|
||||
}
|
||||
Debug(3,"Doing event stream scale(%d)", scale );
|
||||
EventStream stream;
|
||||
stream.setStreamScale( scale );
|
||||
stream.setStreamReplayRate( rate );
|
||||
|
@ -273,6 +278,7 @@ int main( int argc, const char *argv[] ) {
|
|||
if ( monitor_id && event_time ) {
|
||||
stream.setStreamStart( monitor_id, event_time );
|
||||
} else {
|
||||
Debug(3, "Setting stream start to frame (%d)", frame_id);
|
||||
stream.setStreamStart( event_id, frame_id );
|
||||
}
|
||||
if ( mode == ZMS_JPEG ) {
|
||||
|
@ -291,6 +297,8 @@ int main( int argc, const char *argv[] ) {
|
|||
#endif // HAVE_LIBAVCODEC
|
||||
} // end if jpeg or mpeg
|
||||
stream.runStream();
|
||||
} else {
|
||||
Error("Neither a monitor or event was specified.");
|
||||
} // end if monitor or event
|
||||
|
||||
logTerm();
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
redhat_package: redhat_bootstrap package
|
||||
|
||||
redhat_bootstrap:
|
||||
sudo yum install -y --nogpgcheck build/zmrepo.noarch.rpm
|
||||
sudo yum install -y --nogpgcheck build/external-repo.noarch.rpm
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# General sanity checks
|
||||
checksanity () {
|
||||
# Check to see if this script has access to all the commands it needs
|
||||
for CMD in set echo curl repoquery git ln mkdir rmdir cat patch; do
|
||||
for CMD in set echo curl git ln mkdir rmdir cat patch; do
|
||||
type $CMD 2>&1 > /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
|
@ -20,6 +20,19 @@ checksanity () {
|
|||
fi
|
||||
done
|
||||
|
||||
if [ "${OS}" == "el" ] && [ "${DIST}" == "6" ]; then
|
||||
type repoquery 2>&1 > /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo
|
||||
echo "ERROR: The script cannot find the required command \"reqoquery\"."
|
||||
echo "This command is required in order to build ZoneMinder on el6."
|
||||
echo "Please install the \"yum-utils\" package then try again."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Verify OS & DIST environment variables have been set before calling this script
|
||||
if [ -z "${OS}" ] || [ -z "${DIST}" ]; then
|
||||
echo "ERROR: both OS and DIST environment variables must be set"
|
||||
|
@ -211,6 +224,26 @@ zoneminder ($VERSION-${DIST}-1) unstable; urgency=low
|
|||
EOF
|
||||
}
|
||||
|
||||
# start packpack, filter the output if we are running in travis
|
||||
execpackpack () {
|
||||
|
||||
if [ "${OS}" == "el" ] || [ "${OS}" == "fedora" ]; then
|
||||
parms="-f utils/packpack/redhat_package.mk redhat_package"
|
||||
else
|
||||
parms=""
|
||||
fi
|
||||
|
||||
if [ "${TRAVIS}" == "true" ]; then
|
||||
utils/packpack/heartbeat.sh &
|
||||
mypid=$!
|
||||
packpack/packpack $parms > buildlog.txt 2>&1
|
||||
kill $mypid
|
||||
tail -n 3000 buildlog.txt | grep -v ONVIF
|
||||
else
|
||||
packpack/packpack $parms
|
||||
fi
|
||||
}
|
||||
|
||||
################
|
||||
# MAIN PROGRAM #
|
||||
################
|
||||
|
@ -235,31 +268,31 @@ if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${TRAVIS}" != "true" ]; then
|
|||
rm -rf web/api/app/Plugin/Crud
|
||||
mkdir web/api/app/Plugin/Crud
|
||||
|
||||
if [ "${OS}" == "el" ]; then
|
||||
zmrepodistro=${OS}
|
||||
# We use zmrepo to build el6 only. All other redhat distros use rpm fusion
|
||||
if [ "${OS}" == "el" ] && [ "${DIST}" == "6" ]; then
|
||||
baseurl="https://zmrepo.zoneminder.com/el/${DIST}/x86_64/"
|
||||
reporpm="zmrepo"
|
||||
# Let repoquery determine the full url and filename to the latest zmrepo package
|
||||
dlurl=`repoquery --archlist=noarch --repofrompath=zmpackpack,${baseurl} --repoid=zmpackpack --qf="%{location}" ${reporpm} 2> /dev/null`
|
||||
else
|
||||
zmrepodistro="f"
|
||||
reporpm="rpmfusion-free-release"
|
||||
dlurl="https://download1.rpmfusion.org/free/${OS}/${reporpm}-${DIST}.noarch.rpm"
|
||||
fi
|
||||
|
||||
# Let repoquery determine the full url and filename of the zmrepo rpm we are interested in
|
||||
result=`repoquery --repofrompath=zmpackpack,https://zmrepo.zoneminder.com/${zmrepodistro}/"${DIST}"/x86_64/ --repoid=zmpackpack --qf="%{location}" zmrepo 2> /dev/null`
|
||||
|
||||
if [ -n "$result" ] && [ $? -eq 0 ]; then
|
||||
echo "Retrieving ZMREPO rpm..."
|
||||
curl $result > build/zmrepo.noarch.rpm
|
||||
# Give our downloaded repo rpm a common name so redhat_package.mk can find it
|
||||
if [ -n "$dlurl" ] && [ $? -eq 0 ]; then
|
||||
echo "Retrieving ${reporpm} repo rpm..."gd
|
||||
curl $dlurl > build/external-repo.noarch.rpm
|
||||
else
|
||||
echo "ERROR: Failed to retrieve zmrepo rpm..."
|
||||
echo "ERROR: Failed to retrieve ${reporpm} repo rpm..."
|
||||
echo "Download url was: $dlurl"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
setrpmchangelog
|
||||
|
||||
echo "Starting packpack..."
|
||||
utils/packpack/heartbeat.sh &
|
||||
mypid=$!
|
||||
packpack/packpack -f utils/packpack/redhat_package.mk redhat_package > buildlog.txt 2>&1
|
||||
kill $mypid
|
||||
tail -n 3000 buildlog.txt | grep -v ONVIF
|
||||
execpackpack
|
||||
|
||||
# Steps common to Debian based distros
|
||||
elif [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ]; then
|
||||
|
@ -279,11 +312,7 @@ if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${TRAVIS}" != "true" ]; then
|
|||
setdebchangelog
|
||||
|
||||
echo "Starting packpack..."
|
||||
utils/packpack/heartbeat.sh &
|
||||
mypid=$!
|
||||
packpack/packpack > buildlog.txt 2>&1
|
||||
kill $mypid
|
||||
tail -n 3000 buildlog.txt | grep -v ONVIF
|
||||
execpackpack
|
||||
|
||||
if [ "${OS}" == "ubuntu" ] && [ "${DIST}" == "trusty" ] && [ "${ARCH}" == "x86_64" ] && [ "${TRAVIS}" == "true" ]; then
|
||||
installtrusty
|
||||
|
@ -303,11 +332,7 @@ elif [ "${OS}" == "ubuntu" ] && [ "${DIST}" == "trusty" ] && [ "${ARCH}" == "x86
|
|||
setdebchangelog
|
||||
|
||||
echo "Starting packpack..."
|
||||
utils/packpack/heartbeat.sh &
|
||||
mypid=$!
|
||||
packpack/packpack > buildlog.txt 2>&1
|
||||
kill $mypid
|
||||
tail -n 3000 buildlog.txt | grep -v ONVIF
|
||||
execpackpack
|
||||
|
||||
# If we are running inside Travis then attempt to install the deb we just built
|
||||
if [ "${TRAVIS}" == "true" ]; then
|
||||
|
|
|
@ -138,15 +138,15 @@ if ( is_dir($configSubFolder) ) {
|
|||
# Now that our array our finalized, define each key => value
|
||||
# pair in the array as a constant
|
||||
foreach( $configvals as $key => $value) {
|
||||
define( $key, $value );
|
||||
Configure::write( $matches[1], $matches[2] );
|
||||
define( $key, $value );
|
||||
Configure::write( $key, $value );
|
||||
}
|
||||
|
||||
function process_configfile($configFile) {
|
||||
if ( is_readable( $configFile ) ) {
|
||||
$configvals = array();
|
||||
|
||||
$cfg = fopen( $configFile, "r") or die("Could not open config file.");
|
||||
$cfg = fopen( $configFile, 'r') or die('Could not open config file.');
|
||||
while ( !feof($cfg) ) {
|
||||
$str = fgets( $cfg, 256 );
|
||||
if ( preg_match( '/^\s*$/', $str ))
|
||||
|
|
|
@ -70,6 +70,9 @@ class DATABASE_CONFIG {
|
|||
'login' => ZM_DB_USER,
|
||||
'password' => ZM_DB_PASS,
|
||||
'database' => ZM_DB_NAME,
|
||||
'ssl_ca' => ZM_DB_SSL_CA_CERT,
|
||||
'ssl_key' => ZM_DB_SSL_CLIENT_KEY,
|
||||
'ssl_cert' => ZM_DB_SSL_CLIENT_CERT,
|
||||
'prefix' => '',
|
||||
'encoding' => 'utf8',
|
||||
);
|
||||
|
|
|
@ -131,7 +131,7 @@ class Event {
|
|||
} # end Event->delete
|
||||
|
||||
public function getStreamSrc( $args=array(), $querySep='&' ) {
|
||||
if ( $this->{'DefaultVideo'} ) {
|
||||
if ( $this->{'DefaultVideo'} and $args['mode'] != 'jpeg' ) {
|
||||
return ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php?view=view_video&eid='.$this->{'Id'};
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ class Event {
|
|||
|
||||
// frame is an array representing the db row for a frame.
|
||||
function getImageSrc( $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
||||
$Storage = new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL );
|
||||
$Storage = new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL );
|
||||
$Event = $this;
|
||||
$eventPath = $Event->Path();
|
||||
|
||||
|
@ -217,28 +217,31 @@ class Event {
|
|||
$captImage = 'snapshot.jpg';
|
||||
Debug("Frame not specified, using snapshot");
|
||||
} else {
|
||||
$captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-capture.jpg', $frame['FrameId'] );
|
||||
$captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId'] );
|
||||
if ( ! file_exists( $eventPath.'/'.$captImage ) ) {
|
||||
# Generate the frame JPG
|
||||
if ( $Event->DefaultVideo() ) {
|
||||
$videoPath = $eventPath.'/'.$Event->DefaultVideo();
|
||||
$captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-capture.jpg', $frame['FrameId'] );
|
||||
if ( ! file_exists( $eventPath.'/'.$captImage ) ) {
|
||||
# Generate the frame JPG
|
||||
if ( $Event->DefaultVideo() ) {
|
||||
$videoPath = $eventPath.'/'.$Event->DefaultVideo();
|
||||
|
||||
if ( ! file_exists( $videoPath ) ) {
|
||||
Error("Event claims to have a video file, but it does not seem to exist at $videoPath" );
|
||||
return '';
|
||||
}
|
||||
|
||||
#$command ='ffmpeg -v 0 -i '.$videoPath.' -vf "select=gte(n\\,'.$frame['FrameId'].'),setpts=PTS-STARTPTS" '.$eventPath.'/'.$captImage;
|
||||
$command ='ffmpeg -ss '. $frame['Delta'] .' -i '.$videoPath.' -frames:v 1 '.$eventPath.'/'.$captImage;
|
||||
Logger::Debug( "Running $command" );
|
||||
$output = array();
|
||||
$retval = 0;
|
||||
exec( $command, $output, $retval );
|
||||
Logger::Debug("Retval: $retval, output: " . implode("\n", $output));
|
||||
} else {
|
||||
Error("Can't create frame images from video becuase there is no video file for this event (".$Event->DefaultVideo() );
|
||||
}
|
||||
}
|
||||
if ( ! file_exists( $videoPath ) ) {
|
||||
Error("Event claims to have a video file, but it does not seem to exist at $videoPath" );
|
||||
return '';
|
||||
}
|
||||
|
||||
#$command ='ffmpeg -v 0 -i '.$videoPath.' -vf "select=gte(n\\,'.$frame['FrameId'].'),setpts=PTS-STARTPTS" '.$eventPath.'/'.$captImage;
|
||||
$command ='ffmpeg -ss '. $frame['Delta'] .' -i '.$videoPath.' -frames:v 1 '.$eventPath.'/'.$captImage;
|
||||
Logger::Debug( "Running $command" );
|
||||
$output = array();
|
||||
$retval = 0;
|
||||
exec( $command, $output, $retval );
|
||||
Logger::Debug("Retval: $retval, output: " . implode("\n", $output));
|
||||
} else {
|
||||
Error("Can't create frame images from video becuase there is no video file for this event (".$Event->DefaultVideo() );
|
||||
}
|
||||
} // end if capture file exists
|
||||
} // end if analyze file exists
|
||||
}
|
||||
|
||||
$captPath = $eventPath.'/'.$captImage;
|
||||
|
|
|
@ -435,11 +435,11 @@ Warning("Addterm");
|
|||
# If we change anything that changes the shared mem size, zma can complain. So let's stop first.
|
||||
zmaControl( $monitor, 'stop' );
|
||||
zmcControl( $monitor, 'stop' );
|
||||
dbQuery( 'UPDATE Monitors SET '.implode( ", ", $changes ).' WHERE Id =?', array($mid) );
|
||||
dbQuery( 'UPDATE Monitors SET '.implode( ', ', $changes ).' WHERE Id=?', array($mid) );
|
||||
if ( isset($changes['Name']) ) {
|
||||
$saferOldName = basename( $monitor['Name'] );
|
||||
$saferNewName = basename( $_REQUEST['newMonitor']['Name'] );
|
||||
rename( ZM_DIR_EVENTS."/".$saferOldName, ZM_DIR_EVENTS."/".$saferNewName);
|
||||
rename( ZM_DIR_EVENTS.'/'.$saferOldName, ZM_DIR_EVENTS.'/'.$saferNewName);
|
||||
}
|
||||
if ( isset($changes['Width']) || isset($changes['Height']) ) {
|
||||
$newW = $_REQUEST['newMonitor']['Width'];
|
||||
|
@ -493,7 +493,7 @@ Warning("Addterm");
|
|||
Error("Users with Monitors restrictions cannot create new monitors.");
|
||||
}
|
||||
$restart = true;
|
||||
}
|
||||
} # end if count(changes)
|
||||
|
||||
if ( ZM_OPT_X10 ) {
|
||||
$x10Changes = getFormChanges( $x10Monitor, $_REQUEST['newX10Monitor'] );
|
||||
|
@ -521,7 +521,7 @@ Warning("Addterm");
|
|||
zmcControl( $new_monitor, 'start' );
|
||||
zmaControl( $new_monitor, 'start' );
|
||||
|
||||
if ( $monitor['Controllable'] ) {
|
||||
if ( $new_monitor['Controllable'] ) {
|
||||
require_once( 'control_functions.php' );
|
||||
sendControlCommand( $mid, 'quit' );
|
||||
}
|
||||
|
@ -530,8 +530,7 @@ Warning("Addterm");
|
|||
$refreshParent = true;
|
||||
} // end if restart
|
||||
$view = 'none';
|
||||
}
|
||||
if ( $action == 'delete' ) {
|
||||
} elseif ( $action == 'delete' ) {
|
||||
if ( isset($_REQUEST['markMids']) && !$user['MonitorIds'] ) {
|
||||
foreach( $_REQUEST['markMids'] as $markMid ) {
|
||||
if ( canEdit( 'Monitors', $markMid ) ) {
|
||||
|
@ -541,6 +540,18 @@ Warning("Addterm");
|
|||
zmcControl( $monitor, 'stop' );
|
||||
}
|
||||
|
||||
// If fast deletes are on, then zmaudit will clean everything else up later
|
||||
// If fast deletes are off and there are lots of events then this step may
|
||||
// well time out before completing, in which case zmaudit will still tidy up
|
||||
if ( !ZM_OPT_FAST_DELETE ) {
|
||||
$markEids = dbFetchAll( 'SELECT Id FROM Events WHERE MonitorId=?', 'Id', array($markMid) );
|
||||
foreach( $markEids as $markEid )
|
||||
deleteEvent( $markEid );
|
||||
|
||||
deletePath( ZM_DIR_EVENTS.'/'.basename($monitor['Name']) );
|
||||
deletePath( ZM_DIR_EVENTS.'/'.$monitor['Id'] ); // I'm trusting the Id.
|
||||
} // end if ZM_OPT_FAST_DELETE
|
||||
|
||||
// This is the important stuff
|
||||
dbQuery( 'DELETE FROM Monitors WHERE Id = ?', array($markMid) );
|
||||
dbQuery( 'DELETE FROM Zones WHERE MonitorId = ?', array($markMid) );
|
||||
|
@ -549,18 +560,6 @@ Warning("Addterm");
|
|||
|
||||
fixSequences();
|
||||
|
||||
// If fast deletes are on, then zmaudit will clean everything else up later
|
||||
// If fast deletes are off and there are lots of events then this step may
|
||||
// well time out before completing, in which case zmaudit will still tidy up
|
||||
if ( !ZM_OPT_FAST_DELETE ) {
|
||||
// Slight hack, we maybe should load *, but we happen to know that the deleteEvent function uses Id and StartTime.
|
||||
$markEids = dbFetchAll( 'SELECT Id,StartTime FROM Events WHERE MonitorId=?', NULL, array($markMid) );
|
||||
foreach( $markEids as $markEid )
|
||||
deleteEvent( $markEid, $markMid );
|
||||
|
||||
deletePath( ZM_DIR_EVENTS.'/'.basename($monitor['Name']) );
|
||||
deletePath( ZM_DIR_EVENTS.'/'.$monitor['Id'] ); // I'm trusting the Id.
|
||||
} // end if ZM_OPT_FAST_DELETE
|
||||
} // end if found the monitor in the db
|
||||
} // end if canedit this monitor
|
||||
} // end foreach monitor in MarkMid
|
||||
|
|
|
@ -29,13 +29,12 @@ define( "ZM_DIR_TEMP", "@ZM_TMPDIR@" );
|
|||
|
||||
$configFile = ZM_CONFIG;
|
||||
$localConfigFile = basename($configFile);
|
||||
if ( file_exists( $localConfigFile ) && filesize( $localConfigFile ) > 0 )
|
||||
{
|
||||
if ( php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']) )
|
||||
print( "Warning, overriding installed $localConfigFile file with local copy\n" );
|
||||
else
|
||||
error_log( "Warning, overriding installed $localConfigFile file with local copy" );
|
||||
$configFile = $localConfigFile;
|
||||
if ( file_exists( $localConfigFile ) && filesize( $localConfigFile ) > 0 ) {
|
||||
if ( php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']) )
|
||||
print( "Warning, overriding installed $localConfigFile file with local copy\n" );
|
||||
else
|
||||
error_log( "Warning, overriding installed $localConfigFile file with local copy" );
|
||||
$configFile = $localConfigFile;
|
||||
}
|
||||
|
||||
# Process name, value pairs from the main config file first
|
||||
|
@ -45,19 +44,19 @@ $configvals = process_configfile($configFile);
|
|||
# update our config value array with those values
|
||||
$configSubFolder = ZM_CONFIG_SUBDIR;
|
||||
if ( is_dir($configSubFolder) ) {
|
||||
if ( is_readable($configSubFolder) ) {
|
||||
foreach ( glob("$configSubFolder/*.conf") as $filename ) {
|
||||
$configvals = array_replace($configvals, process_configfile($filename) );
|
||||
}
|
||||
} else {
|
||||
error_log( "WARNING: ZoneMinder configuration subfolder found but is not readable. Check folder permissions on $configSubFolder." );
|
||||
if ( is_readable($configSubFolder) ) {
|
||||
foreach ( glob("$configSubFolder/*.conf") as $filename ) {
|
||||
$configvals = array_replace($configvals, process_configfile($filename) );
|
||||
}
|
||||
} else {
|
||||
error_log( "WARNING: ZoneMinder configuration subfolder found but is not readable. Check folder permissions on $configSubFolder." );
|
||||
}
|
||||
}
|
||||
|
||||
# Now that our array our finalized, define each key => value
|
||||
# pair in the array as a constant
|
||||
foreach( $configvals as $key => $value) {
|
||||
define( $key, $value );
|
||||
define( $key, $value );
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -135,91 +134,87 @@ require_once( 'database.php' );
|
|||
loadConfig();
|
||||
|
||||
$GLOBALS['defaultUser'] = array(
|
||||
"Username" => "admin",
|
||||
"Password" => "",
|
||||
"Language" => "",
|
||||
"Enabled" => 1,
|
||||
"Stream" => 'View',
|
||||
"Events" => 'Edit',
|
||||
"Control" => 'Edit',
|
||||
"Monitors" => 'Edit',
|
||||
"Groups" => 'Edit',
|
||||
"Devices" => 'Edit',
|
||||
"System" => 'Edit',
|
||||
"MaxBandwidth" => "",
|
||||
"MonitorIds" => false
|
||||
"Username" => "admin",
|
||||
"Password" => "",
|
||||
"Language" => "",
|
||||
"Enabled" => 1,
|
||||
"Stream" => 'View',
|
||||
"Events" => 'Edit',
|
||||
"Control" => 'Edit',
|
||||
"Monitors" => 'Edit',
|
||||
"Groups" => 'Edit',
|
||||
"Devices" => 'Edit',
|
||||
"System" => 'Edit',
|
||||
"MaxBandwidth" => "",
|
||||
"MonitorIds" => false
|
||||
);
|
||||
|
||||
function loadConfig( $defineConsts=true )
|
||||
{
|
||||
global $config;
|
||||
global $configCats;
|
||||
global $dbConn;
|
||||
function loadConfig( $defineConsts=true ) {
|
||||
global $config;
|
||||
global $configCats;
|
||||
global $dbConn;
|
||||
|
||||
$config = array();
|
||||
$configCat = array();
|
||||
$config = array();
|
||||
$configCat = array();
|
||||
|
||||
$result = $dbConn->query( 'select * from Config order by Id asc' );
|
||||
if ( !$result )
|
||||
echo mysql_error();
|
||||
$monitors = array();
|
||||
while( $row = dbFetchNext( $result ) )
|
||||
{
|
||||
if ( $defineConsts )
|
||||
define( $row['Name'], $row['Value'] );
|
||||
$config[$row['Name']] = $row;
|
||||
if ( !($configCat = &$configCats[$row['Category']]) )
|
||||
{
|
||||
$configCats[$row['Category']] = array();
|
||||
$configCat = &$configCats[$row['Category']];
|
||||
}
|
||||
$configCat[$row['Name']] = $row;
|
||||
$result = $dbConn->query( 'select * from Config order by Id asc' );
|
||||
if ( !$result )
|
||||
echo mysql_error();
|
||||
$monitors = array();
|
||||
while( $row = dbFetchNext( $result ) ) {
|
||||
if ( $defineConsts )
|
||||
define( $row['Name'], $row['Value'] );
|
||||
$config[$row['Name']] = $row;
|
||||
if ( !($configCat = &$configCats[$row['Category']]) ) {
|
||||
$configCats[$row['Category']] = array();
|
||||
$configCat = &$configCats[$row['Category']];
|
||||
}
|
||||
//print_r( $config );
|
||||
//print_r( $configCats );
|
||||
$configCat[$row['Name']] = $row;
|
||||
}
|
||||
//print_r( $config );
|
||||
//print_r( $configCats );
|
||||
}
|
||||
|
||||
require_once( 'logger.php' );
|
||||
// For Human-readability, user ZM_SERVER in zm.conf, and convert it here to a ZM_SERVER_ID
|
||||
if ( ! defined('ZM_SERVER_ID') ) {
|
||||
if ( defined('ZM_SERVER_NAME') and ZM_SERVER_NAME ) {
|
||||
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME));
|
||||
if ( ! $server_id ) {
|
||||
Error("Invalid Multi-Server configration detected. ZM_SERVER_NAME set to " . ZM_SERVER_NAME . " in zm.conf, but no corresponding entry found in Servers table.");
|
||||
} else {
|
||||
define( 'ZM_SERVER_ID', $server_id );
|
||||
}
|
||||
} else if ( defined('ZM_SERVER_HOST') and ZM_SERVER_HOST ) {
|
||||
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_HOST));
|
||||
if ( ! $server_id ) {
|
||||
Error("Invalid Multi-Server configration detected. ZM_SERVER_HOST set to " . ZM_SERVER_HOST . " in zm.conf, but no corresponding entry found in Servers table.");
|
||||
} else {
|
||||
define( 'ZM_SERVER_ID', $server_id );
|
||||
}
|
||||
}
|
||||
if ( defined('ZM_SERVER_NAME') and ZM_SERVER_NAME ) {
|
||||
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME));
|
||||
if ( ! $server_id ) {
|
||||
Error("Invalid Multi-Server configration detected. ZM_SERVER_NAME set to " . ZM_SERVER_NAME . " in zm.conf, but no corresponding entry found in Servers table.");
|
||||
} else {
|
||||
define( 'ZM_SERVER_ID', $server_id );
|
||||
}
|
||||
} else if ( defined('ZM_SERVER_HOST') and ZM_SERVER_HOST ) {
|
||||
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_HOST));
|
||||
if ( ! $server_id ) {
|
||||
Error("Invalid Multi-Server configration detected. ZM_SERVER_HOST set to " . ZM_SERVER_HOST . " in zm.conf, but no corresponding entry found in Servers table.");
|
||||
} else {
|
||||
define( 'ZM_SERVER_ID', $server_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function process_configfile($configFile) {
|
||||
if ( is_readable( $configFile ) ) {
|
||||
$configvals = array();
|
||||
if ( is_readable( $configFile ) ) {
|
||||
$configvals = array();
|
||||
|
||||
$cfg = fopen( $configFile, "r") or die("Could not open config file.");
|
||||
while ( !feof($cfg) )
|
||||
{
|
||||
$str = fgets( $cfg, 256 );
|
||||
if ( preg_match( '/^\s*$/', $str ))
|
||||
continue;
|
||||
elseif ( preg_match( '/^\s*#/', $str ))
|
||||
continue;
|
||||
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches ))
|
||||
$configvals[$matches[1]] = $matches[2];
|
||||
}
|
||||
fclose( $cfg );
|
||||
return( $configvals );
|
||||
} else {
|
||||
error_log( "WARNING: ZoneMinder configuration file found but is not readable. Check file permissions on $configFile." );
|
||||
return( false );
|
||||
$cfg = fopen( $configFile, 'r') or Error("Could not open config file: $configFile.");
|
||||
while ( !feof($cfg) ) {
|
||||
$str = fgets( $cfg, 256 );
|
||||
if ( preg_match( '/^\s*$/', $str ))
|
||||
continue;
|
||||
elseif ( preg_match( '/^\s*#/', $str ))
|
||||
continue;
|
||||
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches ))
|
||||
$configvals[$matches[1]] = $matches[2];
|
||||
}
|
||||
fclose( $cfg );
|
||||
return( $configvals );
|
||||
} else {
|
||||
error_log( "WARNING: ZoneMinder configuration file found but is not readable. Check file permissions on $configFile." );
|
||||
return( false );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
define( "DB_LOG_OFF", 0 );
|
||||
define( "DB_LOG_ONLY", 1 );
|
||||
define( "DB_LOG_DEBUG", 2 );
|
||||
define( 'DB_LOG_OFF', 0 );
|
||||
define( 'DB_LOG_ONLY', 1 );
|
||||
define( 'DB_LOG_DEBUG', 2 );
|
||||
|
||||
$GLOBALS['dbLogLevel'] = DB_LOG_OFF;
|
||||
|
||||
|
@ -42,11 +42,23 @@ function dbConnect() {
|
|||
}
|
||||
|
||||
try {
|
||||
$dbConn = new PDO( ZM_DB_TYPE . $socket . ';dbname='.ZM_DB_NAME, ZM_DB_USER, ZM_DB_PASS );
|
||||
$dbOptions = null;
|
||||
if ( defined( 'ZM_DB_SSL_CA_CERT' ) and ZM_DB_SSL_CA_CERT ) {
|
||||
$dbOptions = array(
|
||||
PDO::MYSQL_ATTR_SSL_CA => ZM_DB_SSL_CA_CERT,
|
||||
PDO::MYSQL_ATTR_SSL_KEY => ZM_DB_SSL_CLIENT_KEY,
|
||||
PDO::MYSQL_ATTR_SSL_CERT => ZM_DB_SSL_CLIENT_CERT,
|
||||
);
|
||||
$dbConn = new PDO( ZM_DB_TYPE . $socket . ';dbname='.ZM_DB_NAME, ZM_DB_USER, ZM_DB_PASS, $dbOptions );
|
||||
} else {
|
||||
$dbConn = new PDO( ZM_DB_TYPE . $socket . ';dbname='.ZM_DB_NAME, ZM_DB_USER, ZM_DB_PASS );
|
||||
}
|
||||
|
||||
$dbConn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch(PDOException $ex ) {
|
||||
echo "Unable to connect to ZM db." . $ex->getMessage();
|
||||
echo 'Unable to connect to ZM db.' . $ex->getMessage();
|
||||
error_log('Unable to connect to ZM DB ' . $ex->getMessage() );
|
||||
$dbConn = null;
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +103,7 @@ function dbError( $sql ) {
|
|||
|
||||
function dbEscape( $string ) {
|
||||
global $dbConn;
|
||||
if ( version_compare( phpversion(), "4.3.0", "<") )
|
||||
if ( version_compare( phpversion(), '4.3.0', '<') )
|
||||
if ( get_magic_quotes_gpc() )
|
||||
return( $dbConn->quote( stripslashes( $string ) ) );
|
||||
else
|
||||
|
@ -217,7 +229,7 @@ function getTableColumns( $table, $asString=1 ) {
|
|||
}
|
||||
|
||||
function getTableAutoInc( $table ) {
|
||||
$row = dbFetchOne( "show table status where Name=?", NULL, array($table) );
|
||||
$row = dbFetchOne( 'show table status where Name=?', NULL, array($table) );
|
||||
return( $row['Auto_increment'] );
|
||||
}
|
||||
|
||||
|
@ -329,11 +341,11 @@ function getTableDescription( $table, $asString=1 ) {
|
|||
}
|
||||
|
||||
function dbFetchMonitor( $mid ) {
|
||||
return( dbFetchOne( "select * from Monitors where Id = ?", NULL, array($mid) ) );
|
||||
return( dbFetchOne( 'select * from Monitors where Id = ?', NULL, array($mid) ) );
|
||||
}
|
||||
|
||||
function dbFetchGroup( $gid ) {
|
||||
return( dbFetchOne( "select * from Groups where Id = ?", NULL, array($gid) ) );
|
||||
return( dbFetchOne( 'select * from Groups where Id = ?', NULL, array($gid) ) );
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -194,7 +194,7 @@ isset($view) || $view = NULL;
|
|||
isset($request) || $request = NULL;
|
||||
isset($action) || $action = NULL;
|
||||
|
||||
if ( ZM_ENABLE_CSRF_MAGIC && $action != 'login' && $view != 'view_video' && $request != 'control' ) {
|
||||
if ( ZM_ENABLE_CSRF_MAGIC && $action != 'login' && $view != 'view_video' && $view != 'video' && $request != 'control' ) {
|
||||
require_once( 'includes/csrf/csrf-magic.php' );
|
||||
Logger::Debug("Calling csrf_check with the following values: \$request = \"$request\", \$view = \"$view\", \$action = \"$action\"");
|
||||
csrf_check();
|
||||
|
|
|
@ -52,15 +52,15 @@
|
|||
}
|
||||
|
||||
#imageFrame div {
|
||||
background-image: url(../../../graphics/point-g.gif);
|
||||
background-image: url(../../../graphics/point-g.png);
|
||||
}
|
||||
|
||||
#imageFrame div.highlight {
|
||||
background-image: url(../../../graphics/point-o.gif);
|
||||
background-image: url(../../../graphics/point-o.png);
|
||||
}
|
||||
|
||||
#imageFrame div.active {
|
||||
background-image: url(../../../graphics/point-r.gif);
|
||||
background-image: url(../../../graphics/point-r.png);
|
||||
}
|
||||
|
||||
#zonePoints {
|
||||
|
|
|
@ -52,15 +52,15 @@
|
|||
}
|
||||
|
||||
#imageFrame div {
|
||||
background-image: url(../../../graphics/point-g.gif);
|
||||
background-image: url(../../../graphics/point-g.png);
|
||||
}
|
||||
|
||||
#imageFrame div.highlight {
|
||||
background-image: url(../../../graphics/point-o.gif);
|
||||
background-image: url(../../../graphics/point-o.png);
|
||||
}
|
||||
|
||||
#imageFrame div.active {
|
||||
background-image: url(../../../graphics/point-r.gif);
|
||||
background-image: url(../../../graphics/point-r.png);
|
||||
}
|
||||
|
||||
#zonePoints {
|
||||
|
|
|
@ -52,15 +52,15 @@
|
|||
}
|
||||
|
||||
#imageFrame div {
|
||||
background-image: url(../../../graphics/point-g.gif);
|
||||
background-image: url(../../../graphics/point-g.png);
|
||||
}
|
||||
|
||||
#imageFrame div.highlight {
|
||||
background-image: url(../../../graphics/point-o.gif);
|
||||
background-image: url(../../../graphics/point-o.png);
|
||||
}
|
||||
|
||||
#imageFrame div.active {
|
||||
background-image: url(../../../graphics/point-r.gif);
|
||||
background-image: url(../../../graphics/point-r.png);
|
||||
}
|
||||
|
||||
#zonePoints {
|
||||
|
|
|
@ -51,7 +51,7 @@ $eventCounts = array(
|
|||
'filter' => array(
|
||||
'Query' => array(
|
||||
'terms' => array(
|
||||
array( 'attr' => "DateTime", 'op' => '>=', 'val' => '-1 day' ),
|
||||
array( 'attr' => 'DateTime', 'op' => '>=', 'val' => '-1 day' ),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -62,7 +62,7 @@ $eventCounts = array(
|
|||
'filter' => array(
|
||||
'Query' => array(
|
||||
'terms' => array(
|
||||
array( 'attr' => "DateTime", 'op' => '>=', 'val' => '-7 day' ),
|
||||
array( 'attr' => 'DateTime', 'op' => '>=', 'val' => '-7 day' ),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -73,7 +73,7 @@ $eventCounts = array(
|
|||
'filter' => array(
|
||||
'Query' => array(
|
||||
'terms' => array(
|
||||
array( 'attr' => "DateTime", 'op' => '>=', 'val' => '-1 month' ),
|
||||
array( 'attr' => 'DateTime', 'op' => '>=', 'val' => '-1 month' ),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -84,7 +84,7 @@ $eventCounts = array(
|
|||
'filter' => array(
|
||||
'Query' => array(
|
||||
'terms' => array(
|
||||
array( 'attr' => "Archived", 'op' => '=', 'val' => '1' ),
|
||||
array( 'attr' => 'Archived', 'op' => '=', 'val' => '1' ),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -107,7 +107,7 @@ for( $i = 0; $i < count($displayMonitors); $i += 1 ) {
|
|||
for ( $j = 0; $j < count($eventCounts); $j += 1 ) {
|
||||
$filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['Query']['terms']), array( 'cnj' => 'and', 'attr' => 'MonitorId', 'op' => '=', 'val' => $monitor['Id'] ) );
|
||||
parseFilter( $filter );
|
||||
$counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j";
|
||||
$counts[] = 'count(if(1'.$filter['sql'].",1,NULL)) as EventCount$j";
|
||||
$monitor['eventCounts'][$j]['filter'] = $filter;
|
||||
}
|
||||
$sql = 'select '.join($counts,', ').' from Events as E where MonitorId = ?';
|
||||
|
@ -203,45 +203,27 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
|||
<td class="colServer"><?php $Server = new Server( $monitor['ServerId'] ); echo $Server->Name(); ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$source = '';
|
||||
if ( $monitor['Type'] == 'Local' ) {
|
||||
?>
|
||||
<td class="colSource"><?php echo makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$dclass.'">'.$monitor['Device'].' ('.$monitor['Channel'].')</span>', canEdit( 'Monitors' ) ) ?></td>
|
||||
<?php
|
||||
$source = $monitor['Device'].' ('.$monitor['Channel'].')';
|
||||
} elseif ( $monitor['Type'] == 'Remote' ) {
|
||||
?>
|
||||
<td class="colSource"><?php echo makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$dclass.'">'.preg_replace( '/^.*@/', '', $monitor['Host'] ).'</span>', canEdit( 'Monitors' ) ) ?></td>
|
||||
<?php
|
||||
} elseif ( $monitor['Type'] == 'File' ) {
|
||||
?>
|
||||
<td class="colSource"><?php echo makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$dclass.'">'.preg_replace( '/^.*\//', '', $monitor['Path'] ).'</span>', canEdit( 'Monitors' ) ) ?></td>
|
||||
<?php
|
||||
$source = preg_replace( '/^.*@/', '', $monitor['Host'] );
|
||||
} elseif ( $monitor['Type'] == 'File' || $monitor['Type'] == 'cURL' ) {
|
||||
$source = preg_replace( '/^.*\//', '', $monitor['Path'] );
|
||||
} elseif ( $monitor['Type'] == 'Ffmpeg' || $monitor['Type'] == 'Libvlc' ) {
|
||||
$domain = parse_url( $monitor['Path'], PHP_URL_HOST );
|
||||
$shortpath = $domain ? $domain : preg_replace( '/^.*\//', '', $monitor['Path'] );
|
||||
if ( $shortpath == '' ) {
|
||||
$shortpath = 'Monitor ' . $monitor['Id'];
|
||||
}
|
||||
?>
|
||||
<td class="colSource"><?php echo makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$dclass.'">'.$shortpath.'</span>', canEdit( 'Monitors' ) ) ?></td>
|
||||
<?php
|
||||
} elseif ( $monitor['Type'] == 'cURL' ) {
|
||||
?>
|
||||
<td class="colSource"><?php echo makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$dclass.'">'.preg_replace( '/^.*\//', '', $monitor['Path'] ).'</span>', canEdit( 'Monitors' ) ) ?></td>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<td class="colSource"> </td>
|
||||
<?php
|
||||
$source = $domain ? $domain : preg_replace( '/^.*\//', '', $monitor['Path'] );
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if ( $source == '' ) {
|
||||
$source = 'Monitor ' . $monitor['Id'];
|
||||
}
|
||||
echo '<td class="colSource">'. makePopupLink( '?view=monitor&mid='.$monitor['Id'], 'zmMonitor'.$monitor['Id'], 'monitor', '<span class="'.$dclass.'">'.$source.'</span>', canEdit( 'Monitors' ) ).'</td>';
|
||||
if ( $show_storage_areas ) {
|
||||
?>
|
||||
<td class="colStorage"><?php $Storage = new Storage( $monitor['StorageId'] ); echo $Storage->Name(); ?></td>
|
||||
<?php
|
||||
}
|
||||
|
||||
for ( $i = 0; $i < count($eventCounts); $i++ ) {
|
||||
?>
|
||||
<td class="colEvents"><?php echo makePopupLink( '?view='.$eventsView.'&page=1'.$monitor['eventCounts'][$i]['filter']['query'], $eventsWindow, $eventsView, $monitor['EventCount'.$i], canView( 'Events' ) ) ?></td>
|
||||
|
|
|
@ -193,7 +193,9 @@ foreach ( $events as $event ) {
|
|||
<tr>
|
||||
<td class="colId"><?php echo makePopupLink( '?view=event&eid='.$event->Id().$filterQuery.$sortQuery.'&page=1', 'zmEvent', array( 'event', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ), $event->Id().($event->Archived()?'*':'') ) ?></td>
|
||||
<td class="colName"><?php echo makePopupLink( '?view=event&eid='.$event->Id().$filterQuery.$sortQuery.'&page=1', 'zmEvent', array( 'event', reScale( $event->Width(), $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ), reScale( $event->Height(), $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ) ), validHtmlStr($event->Name()).($event->Archived()?'*':'' ) ) ?></td>
|
||||
<td class="colMonitorName"><?php echo $event->MonitorName() ?></td>
|
||||
<td class="colMonitorName"><?php echo
|
||||
makePopupLink( '?view=monitor&mid='.$event->MonitorId(), 'zmMonitor'.$event->Monitorid(), 'monitor', $event->MonitorName(), canEdit( 'Monitors' ) )
|
||||
?></td>
|
||||
<td class="colCause"><?php echo makePopupLink( '?view=eventdetail&eid='.$event->Id(), 'zmEventDetail', 'eventdetail', validHtmlStr($event->Cause()), canEdit( 'Events' ), 'title="'.htmlspecialchars($event->Notes()).'"' ) ?></td>
|
||||
<td class="colTime"><?php echo strftime( STRF_FMT_DATETIME_SHORTER, strtotime($event->StartTime()) ) ?></td>
|
||||
<td class="colDuration"><?php echo gmdate("H:i:s", $event->Length() ) ?></td>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
if ( !canView( 'Events' ) )
|
||||
|
|
|
@ -88,7 +88,7 @@ $j( function() {
|
|||
function applySort(event, ui) {
|
||||
var monitor_ids = $j(this).sortable('toArray');
|
||||
var ajax = new Request.JSON( {
|
||||
url: '/index.php?request=console',
|
||||
url: '?request=console',
|
||||
data: { monitor_ids: monitor_ids, action: 'sort' },
|
||||
method: 'post',
|
||||
timeout: AJAX_TIMEOUT
|
||||
|
|
|
@ -31,7 +31,7 @@ function changeScale() {
|
|||
Cookie.write( 'zmWatchScale'+monitorId, scale, { duration: 10*365 } );
|
||||
|
||||
/*Stream could be an applet so can't use moo tools*/
|
||||
var streamImg = $('#liveStream'+monitorId);
|
||||
var streamImg = $('liveStream'+monitorId);
|
||||
if ( streamImg ) {
|
||||
streamImg.style.width = newWidth + "px";
|
||||
streamImg.style.height = newHeight + "px";
|
||||
|
@ -197,7 +197,7 @@ function getStreamCmdResponse( respObj, respText ) {
|
|||
var streamImg = $('liveStream'+monitorId);
|
||||
if ( streamImg ) {
|
||||
streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
|
||||
console.log("Changing lviestream src to " + streamImg.src);
|
||||
console.log("Changing livestream src to " + streamImg.src);
|
||||
} else {
|
||||
console.log("Unable to find streamImg liveStream");
|
||||
}
|
||||
|
@ -357,7 +357,14 @@ function statusCmdQuery() {
|
|||
var alarmCmdParms = "view=request&request=alarm&id="+monitorId;
|
||||
if ( auth_hash )
|
||||
alarmCmdParms += '&auth='+auth_hash;
|
||||
var alarmCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getAlarmCmdResponse, onTimeout: streamCmdQuery } );
|
||||
var alarmCmdReq = new Request.JSON( {
|
||||
url: monitorUrl+thisUrl,
|
||||
method: 'post',
|
||||
timeout: AJAX_TIMEOUT,
|
||||
link: 'cancel',
|
||||
onSuccess: getAlarmCmdResponse,
|
||||
onTimeout: streamCmdQuery
|
||||
} );
|
||||
var alarmCmdFirst = true;
|
||||
|
||||
function getAlarmCmdResponse( respObj, respText ) {
|
||||
|
@ -378,11 +385,13 @@ function cmdForceAlarm() {
|
|||
|
||||
function cmdCancelForcedAlarm() {
|
||||
alarmCmdReq.send( alarmCmdParms+"&command=cancelForcedAlarm" );
|
||||
return false;
|
||||
}
|
||||
|
||||
function getActResponse( respObj, respText ) {
|
||||
if ( respObj.result == 'Ok' ) {
|
||||
if ( respObj.refreshParent ) {
|
||||
console.log('refreshing');
|
||||
window.opener.location.reload();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,14 +155,14 @@ function fourcc( $a, $b, $c, $d ) {
|
|||
}
|
||||
|
||||
if ( isset( $_REQUEST['newMonitor'] ) ) {
|
||||
# Update the monitor object with whatever has been set so far.
|
||||
# Update the monitor object with whatever has been set so far.
|
||||
$monitor->set( $_REQUEST['newMonitor'] );
|
||||
|
||||
if ( ZM_OPT_X10 )
|
||||
$newX10Monitor = $_REQUEST['newX10Monitor'];
|
||||
} else {
|
||||
# FIXME: Triggers in the db is a comma separated string. Needs to be an array.
|
||||
#$monitor->Triggers()= explode( ',', isset($monitor->Triggers())?$monitor->Triggers:"" );
|
||||
# FIXME: Triggers in the db is a comma separated string. Needs to be an array.
|
||||
#$monitor->Triggers()= explode( ',', isset($monitor->Triggers())?$monitor->Triggers:"" );
|
||||
if ( ZM_OPT_X10 )
|
||||
$newX10Monitor = $x10Monitor;
|
||||
}
|
||||
|
@ -178,9 +178,9 @@ if ( $monitor->AlarmMaxFPS() == '0.00' )
|
|||
if ( !empty($_REQUEST['preset']) ) {
|
||||
$preset = dbFetchOne( 'SELECT Type, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Palette, MaxFPS, Controllable, ControlId, ControlDevice, ControlAddress, DefaultRate, DefaultScale FROM MonitorPresets WHERE Id = ?', NULL, array($_REQUEST['preset']) );
|
||||
foreach ( $preset as $name=>$value ) {
|
||||
# Does isset handle NULL's? I don't think this code is correct.
|
||||
# Does isset handle NULL's? I don't think this code is correct.
|
||||
if ( isset($value) ) {
|
||||
$monitor->$name = $value;
|
||||
$monitor->$name = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,17 +188,17 @@ if ( !empty($_REQUEST['probe']) ) {
|
|||
$probe = unserialize(base64_decode($_REQUEST['probe']));
|
||||
foreach ( $probe as $name=>$value ) {
|
||||
if ( isset($value) ) {
|
||||
# Does isset handle NULL's? I don't think this code is correct.
|
||||
$monitor->$name = $value;
|
||||
# Does isset handle NULL's? I don't think this code is correct.
|
||||
$monitor->$name = $value;
|
||||
}
|
||||
}
|
||||
if ( ZM_HAS_V4L && $monitor->Type() == 'Local' ) {
|
||||
$monitor->Palette( fourCC( substr($monitor->Palette,0,1), substr($monitor->Palette,1,1), substr($monitor->Palette,2,1), substr($monitor->Palette,3,1) ) );
|
||||
if ( $monitor->Format() == 'PAL' )
|
||||
$monitor->Format( 0x000000ff );
|
||||
elseif ( $monitor->Format() == 'NTSC' )
|
||||
$monitor->Format( 0x0000b000 );
|
||||
}
|
||||
if ( ZM_HAS_V4L && $monitor->Type() == 'Local' ) {
|
||||
$monitor->Palette( fourCC( substr($monitor->Palette,0,1), substr($monitor->Palette,1,1), substr($monitor->Palette,2,1), substr($monitor->Palette,3,1) ) );
|
||||
if ( $monitor->Format() == 'PAL' )
|
||||
$monitor->Format( 0x000000ff );
|
||||
elseif ( $monitor->Format() == 'NTSC' )
|
||||
$monitor->Format( 0x0000b000 );
|
||||
}
|
||||
}
|
||||
|
||||
$sourceTypes = array(
|
||||
|
@ -683,19 +683,19 @@ switch ( $tab ) {
|
|||
</td></tr>
|
||||
<tr><td><?php echo translate('StorageArea') ?></td><td>
|
||||
<?php
|
||||
$storage_areas = array(0=>'Default');
|
||||
$result = dbQuery( 'SELECT * FROM Storage ORDER BY Name');
|
||||
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Storage' );
|
||||
foreach ( $results as $row => $storage_obj ) {
|
||||
$storage_areas[$storage_obj->Id] = $storage_obj->Name();
|
||||
}
|
||||
echo htmlSelect( 'newMonitor[StorageId]', $storage_areas, $monitor->StorageId() );
|
||||
$storage_areas = array(0=>'Default');
|
||||
$result = dbQuery( 'SELECT * FROM Storage ORDER BY Name');
|
||||
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Storage' );
|
||||
foreach ( $results as $row => $storage_obj ) {
|
||||
$storage_areas[$storage_obj->Id] = $storage_obj->Name();
|
||||
}
|
||||
echo htmlSelect( 'newMonitor[StorageId]', $storage_areas, $monitor->StorageId() );
|
||||
?>
|
||||
</td></tr>
|
||||
<tr><td><?php echo translate('SourceType') ?></td><td><?php echo htmlSelect( "newMonitor[Type]", $sourceTypes, $monitor->Type() ); ?></td></tr>
|
||||
<tr><td><?php echo translate('Function') ?></td><td><select name="newMonitor[Function]">
|
||||
<?php
|
||||
foreach ( getEnumValues( 'Monitors', 'Function' ) as $optFunction ) {
|
||||
foreach ( getEnumValues( 'Monitors', 'Function' ) as $optFunction ) {
|
||||
?>
|
||||
<option value="<?php echo $optFunction ?>"<?php if ( $optFunction == $monitor->Function()) { ?> selected="selected"<?php } ?>><?php echo translate('Fn'.$optFunction) ?></option>
|
||||
<?php
|
||||
|
@ -704,25 +704,25 @@ switch ( $tab ) {
|
|||
</select></td></tr>
|
||||
<tr><td><?php echo translate('Enabled') ?></td><td><input type="checkbox" name="newMonitor[Enabled]" value="1"<?php if ( !empty($monitor->Enabled()) ) { ?> checked="checked"<?php } ?>/></td></tr>
|
||||
<tr>
|
||||
<td><?php echo translate('LinkedMonitors') ?></td>
|
||||
<td>
|
||||
<select name="monitorIds" size="4" multiple="multiple" onchange="updateLinkedMonitors( this )">
|
||||
<td><?php echo translate('LinkedMonitors') ?></td>
|
||||
<td>
|
||||
<select name="monitorIds" size="4" multiple="multiple" onchange="updateLinkedMonitors( this )">
|
||||
<?php
|
||||
$monitors = dbFetchAll( 'select Id,Name from Monitors order by Sequence asc' );
|
||||
if ( !empty($monitor->LinkedMonitors()) )
|
||||
$monitorIds = array_flip( explode( ',', $monitor->LinkedMonitors()) );
|
||||
else
|
||||
$monitorIds = array();
|
||||
foreach ( $monitors as $linked_monitor ) {
|
||||
if ( (empty($monitor->Id()) || ($monitor->Id()!= $linked_monitor['Id'])) && visibleMonitor( $linked_monitor['Id'] ) ) {
|
||||
$monitors = dbFetchAll( 'select Id,Name from Monitors order by Sequence asc' );
|
||||
if ( !empty($monitor->LinkedMonitors()) )
|
||||
$monitorIds = array_flip( explode( ',', $monitor->LinkedMonitors()) );
|
||||
else
|
||||
$monitorIds = array();
|
||||
foreach ( $monitors as $linked_monitor ) {
|
||||
if ( (empty($monitor->Id()) || ($monitor->Id()!= $linked_monitor['Id'])) && visibleMonitor( $linked_monitor['Id'] ) ) {
|
||||
?>
|
||||
<option value="<?php echo $linked_monitor['Id'] ?>"<?php if ( array_key_exists( $linked_monitor['Id'], $monitorIds ) ) { ?> selected="selected"<?php } ?>><?php echo validHtmlStr($linked_monitor['Name']) ?></option>
|
||||
<option value="<?php echo $linked_monitor['Id'] ?>"<?php if ( array_key_exists( $linked_monitor['Id'], $monitorIds ) ) { ?> selected="selected"<?php } ?>><?php echo validHtmlStr($linked_monitor['Name']) ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</select>
|
||||
</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
|
||||
|
@ -800,25 +800,25 @@ switch ( $tab ) {
|
|||
<?php
|
||||
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('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('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('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
|
||||
} 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('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('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('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
|
||||
}
|
||||
}
|
||||
?>
|
||||
<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"' : '' ) ?>/>
|
||||
<label for="newMonitor[V4LMultiBuffer]1">Yes</label>
|
||||
<input type="radio" name="newMonitor[V4LMultiBuffer]" id="newMonitor[V4LMultiBuffer]0" value="0" <?php echo ( $monitor->V4LMultiBuffer() == 0 ? 'checked="checked"' : '' ) ?>/>
|
||||
<label for="newMonitor[V4LMultiBuffer]0">No</label>
|
||||
<input type="radio" name="newMonitor[V4LMultiBuffer]" id="newMonitor[V4LMultiBuffer]" value="" <?php echo ( empty($monitor->V4LMultiBuffer()) ? 'checked="checked"' : '' ) ?>/>
|
||||
<label for="newMonitor[V4LMultiBuffer]">Use Config Value</label>
|
||||
<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>
|
||||
<input type="radio" name="newMonitor[V4LMultiBuffer]" id="newMonitor[V4LMultiBuffer]0" value="0" <?php echo ( $monitor->V4LMultiBuffer() == 0 ? 'checked="checked"' : '' ) ?>/>
|
||||
<label for="newMonitor[V4LMultiBuffer]0">No</label>
|
||||
<input type="radio" name="newMonitor[V4LMultiBuffer]" id="newMonitor[V4LMultiBuffer]" value="" <?php echo ( empty($monitor->V4LMultiBuffer()) ? 'checked="checked"' : '' ) ?>/>
|
||||
<label for="newMonitor[V4LMultiBuffer]">Use Config Value</label>
|
||||
</td></tr>
|
||||
<tr><td><?php echo translate('V4LCapturesPerFrame') ?></td><td><input type="number" name="newMonitor[V4LCapturesPerFrame]" value="<?php echo $monitor->V4LCapturesPerFrame()?>"/></td></tr>
|
||||
<?php
|
||||
|
@ -826,9 +826,9 @@ switch ( $tab ) {
|
|||
?>
|
||||
<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
|
||||
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
|
||||
} else {
|
||||
?>
|
||||
|
@ -870,7 +870,7 @@ switch ( $tab ) {
|
|||
<?php
|
||||
} else {
|
||||
?>
|
||||
<tr><td><?php echo translate('Deinterlacing') ?></td><td><select name="newMonitor[Deinterlacing]"><?php foreach ( $deinterlaceopts 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 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
|
||||
}
|
||||
?>
|
||||
|
@ -954,41 +954,41 @@ switch ( $tab ) {
|
|||
<tr><td><?php echo translate('FPSReportInterval') ?></td><td><input type="text" name="newMonitor[FPSReportInterval]" value="<?php echo validHtmlStr($monitor->FPSReportInterval()) ?>" size="6"/></td></tr>
|
||||
<tr><td><?php echo translate('DefaultView') ?></td><td><select name="newMonitor[DefaultView]">
|
||||
<?php
|
||||
foreach ( getEnumValues( 'Monitors', 'DefaultView' ) as $opt_view ) {
|
||||
if ( $opt_view == 'Control' && ( !ZM_OPT_CONTROL || !$monitor->Controllable()) )
|
||||
continue;
|
||||
foreach ( getEnumValues( 'Monitors', 'DefaultView' ) as $opt_view ) {
|
||||
if ( $opt_view == 'Control' && ( !ZM_OPT_CONTROL || !$monitor->Controllable()) )
|
||||
continue;
|
||||
?>
|
||||
<option value="<?php echo $opt_view ?>"<?php if ( $opt_view == $monitor->DefaultView()) { ?> selected="selected"<?php } ?>><?php echo $opt_view ?></option>
|
||||
<option value="<?php echo $opt_view ?>"<?php if ( $opt_view == $monitor->DefaultView()) { ?> selected="selected"<?php } ?>><?php echo $opt_view ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select></td></tr>
|
||||
</select></td></tr>
|
||||
<tr><td><?php echo translate('DefaultRate') ?></td><td><?php echo htmlSelect( "newMonitor[DefaultRate]", $rates, $monitor->DefaultRate() ); ?></td></tr>
|
||||
<tr><td><?php echo translate('DefaultScale') ?></td><td><?php echo htmlSelect( "newMonitor[DefaultScale]", $scales, $monitor->DefaultScale() ); ?></td></tr>
|
||||
<?php
|
||||
if ( ZM_HAS_V4L && $monitor->Type() == 'Local' ) {
|
||||
if ( ZM_HAS_V4L && $monitor->Type() == 'Local' ) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo translate('SignalCheckColour') ?></td>
|
||||
<td>
|
||||
<input type="text" name="newMonitor[SignalCheckColour]" value="<?php echo validHtmlStr($monitor->SignalCheckColour()) ?>" size="10" onchange="$('SignalCheckSwatch').setStyle( 'backgroundColor', this.value )"/>
|
||||
<span id="SignalCheckSwatch" class="swatch" style="background-color: <?php echo $monitor->SignalCheckColour()?>;"> </span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo translate('SignalCheckColour') ?></td>
|
||||
<td>
|
||||
<input type="text" name="newMonitor[SignalCheckColour]" value="<?php echo validHtmlStr($monitor->SignalCheckColour()) ?>" size="10" onchange="$('SignalCheckSwatch').setStyle( 'backgroundColor', this.value )"/>
|
||||
<span id="SignalCheckSwatch" class="swatch" style="background-color: <?php echo $monitor->SignalCheckColour()?>;"> </span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo translate('WebColour') ?></td>
|
||||
<td>
|
||||
<input type="text" name="newMonitor[WebColour]" value="<?php echo validHtmlStr($monitor->WebColour()) ?>" size="10" onchange="$('WebSwatch').setStyle( 'backgroundColor', this.value )"/>
|
||||
<span id="WebSwatch" class="swatch" style="background-color: <?php echo validHtmlStr($monitor->WebColour()) ?>;"> </span>
|
||||
</td>
|
||||
</tr>
|
||||
<td><?php echo translate('WebColour') ?></td>
|
||||
<td>
|
||||
<input type="text" name="newMonitor[WebColour]" value="<?php echo validHtmlStr($monitor->WebColour()) ?>" size="10" onchange="$('WebSwatch').setStyle( 'backgroundColor', this.value )"/>
|
||||
<span id="WebSwatch" class="swatch" style="background-color: <?php echo validHtmlStr($monitor->WebColour()) ?>;"> </span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo translate('Exif') ?> (<?php echo makePopupLink( '?view=optionhelp&option=OPTIONS_EXIF', 'zmOptionHelp', 'optionhelp', '?' ) ?>) </td>
|
||||
<td><input type="checkbox" name="newMonitor[Exif]" value="1"<?php if ( !empty($monitor->Exif()) ) { ?> checked="checked"<?php } ?>/></td>
|
||||
</tr>
|
||||
<td><?php echo translate('Exif') ?> (<?php echo makePopupLink( '?view=optionhelp&option=OPTIONS_EXIF', 'zmOptionHelp', 'optionhelp', '?' ) ?>) </td>
|
||||
<td><input type="checkbox" name="newMonitor[Exif]" value="1"<?php if ( !empty($monitor->Exif()) ) { ?> checked="checked"<?php } ?>/></td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -18,10 +18,9 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
if ( !canView( 'Events' ) )
|
||||
{
|
||||
$view = "error";
|
||||
return;
|
||||
if ( !canView( 'Events' ) ) {
|
||||
$view = "error";
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('includes/Event.php');
|
||||
|
@ -32,80 +31,69 @@ $sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultRate,M.DefaultScale FROM Event
|
|||
$sql_values = array( $eid );
|
||||
|
||||
if ( $user['MonitorIds'] ) {
|
||||
$monitor_ids = explode( ',', $user['MonitorIds'] );
|
||||
$sql .= ' AND MonitorId IN (' .implode( ',', array_fill(0,count($monitor_ids),'?') ) . ')';
|
||||
$sql_values = array_merge( $sql_values, $monitor_ids );
|
||||
$monitor_ids = explode( ',', $user['MonitorIds'] );
|
||||
$sql .= ' AND MonitorId IN (' .implode( ',', array_fill(0,count($monitor_ids),'?') ) . ')';
|
||||
$sql_values = array_merge( $sql_values, $monitor_ids );
|
||||
}
|
||||
$event = dbFetchOne( $sql, NULL, $sql_values );
|
||||
|
||||
if ( isset( $_REQUEST['rate'] ) )
|
||||
$rate = validInt($_REQUEST['rate']);
|
||||
$rate = validInt($_REQUEST['rate']);
|
||||
else
|
||||
$rate = reScale( RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE );
|
||||
$rate = reScale( RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE );
|
||||
if ( isset( $_REQUEST['scale'] ) )
|
||||
$scale = validInt($_REQUEST['scale']);
|
||||
$scale = validInt($_REQUEST['scale']);
|
||||
else
|
||||
$scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||
$scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||
|
||||
$Event = new Event( $event['Id'] );
|
||||
$eventPath = $Event->Path();
|
||||
|
||||
$videoFormats = array();
|
||||
$ffmpegFormats = preg_split( '/\s+/', ZM_FFMPEG_FORMATS );
|
||||
foreach ( $ffmpegFormats as $ffmpegFormat )
|
||||
{
|
||||
if ( preg_match( '/^([^*]+)(\*\*?)$/', $ffmpegFormat, $matches ) )
|
||||
{
|
||||
$videoFormats[$matches[1]] = $matches[1];
|
||||
if ( !isset($videoFormat) && $matches[2] == "*" )
|
||||
{
|
||||
$videoFormat = $matches[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$videoFormats[$ffmpegFormat] = $ffmpegFormat;
|
||||
foreach ( $ffmpegFormats as $ffmpegFormat ) {
|
||||
if ( preg_match( '/^([^*]+)(\*\*?)$/', $ffmpegFormat, $matches ) ) {
|
||||
$videoFormats[$matches[1]] = $matches[1];
|
||||
if ( !isset($videoFormat) && $matches[2] == '*' ) {
|
||||
$videoFormat = $matches[1];
|
||||
}
|
||||
} else {
|
||||
$videoFormats[$ffmpegFormat] = $ffmpegFormat;
|
||||
}
|
||||
}
|
||||
|
||||
$videoFiles = array();
|
||||
if ( $dir = opendir( $eventPath ) )
|
||||
{
|
||||
while ( ($file = readdir( $dir )) !== false )
|
||||
{
|
||||
$file = $eventPath.'/'.$file;
|
||||
if ( is_file( $file ) )
|
||||
{
|
||||
if ( preg_match( '/\.(?:'.join( '|', $videoFormats ).')$/', $file ) )
|
||||
{
|
||||
$videoFiles[] = $file;
|
||||
}
|
||||
}
|
||||
if ( $dir = opendir( $eventPath ) ) {
|
||||
while ( ($file = readdir( $dir )) !== false ) {
|
||||
$file = $eventPath.'/'.$file;
|
||||
if ( is_file( $file ) ) {
|
||||
if ( preg_match( '/\.(?:'.join( '|', $videoFormats ).')$/', $file ) ) {
|
||||
$videoFiles[] = $file;
|
||||
}
|
||||
}
|
||||
closedir( $dir );
|
||||
}
|
||||
closedir( $dir );
|
||||
}
|
||||
|
||||
if ( isset($_REQUEST['deleteIndex']) )
|
||||
{
|
||||
$deleteIndex = validInt($_REQUEST['deleteIndex']);
|
||||
unlink( $videoFiles[$deleteIndex] );
|
||||
unset( $videoFiles[$deleteIndex] );
|
||||
if ( isset($_REQUEST['deleteIndex']) ) {
|
||||
$deleteIndex = validInt($_REQUEST['deleteIndex']);
|
||||
unlink( $videoFiles[$deleteIndex] );
|
||||
unset( $videoFiles[$deleteIndex] );
|
||||
}
|
||||
|
||||
if ( isset($_REQUEST['downloadIndex']) )
|
||||
{
|
||||
$downloadIndex = validInt($_REQUEST['downloadIndex']);
|
||||
header( "Pragma: public" );
|
||||
header( "Expires: 0" );
|
||||
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
|
||||
header( "Cache-Control: private", false ); // required by certain browsers
|
||||
header( "Content-Description: File Transfer" );
|
||||
header( 'Content-disposition: attachment; filename="'.basename($videoFiles[$downloadIndex]).'"' ); // basename is required because the video index contains the path and firefox doesn't strip the path but simply replaces the slashes with an underscore.
|
||||
header( "Content-Transfer-Encoding: binary" );
|
||||
header( "Content-Type: application/force-download" );
|
||||
header( "Content-Length: ".filesize($videoFiles[$downloadIndex]) );
|
||||
readfile( $videoFiles[$downloadIndex] );
|
||||
exit;
|
||||
if ( isset($_REQUEST['downloadIndex']) ) {
|
||||
$downloadIndex = validInt($_REQUEST['downloadIndex']);
|
||||
header( 'Pragma: public' );
|
||||
header( 'Expires: 0' );
|
||||
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
|
||||
header( 'Cache-Control: private', false ); // required by certain browsers
|
||||
header( 'Content-Description: File Transfer' );
|
||||
header( 'Content-disposition: attachment; filename="'.basename($videoFiles[$downloadIndex]).'"' ); // basename is required because the video index contains the path and firefox doesn't strip the path but simply replaces the slashes with an underscore.
|
||||
header( 'Content-Transfer-Encoding: binary' );
|
||||
header( 'Content-Type: application/force-download' );
|
||||
header( 'Content-Length: '.filesize($videoFiles[$downloadIndex]) );
|
||||
readfile( $videoFiles[$downloadIndex] );
|
||||
exit;
|
||||
}
|
||||
|
||||
$focusWindow = true;
|
||||
|
@ -122,19 +110,16 @@ xhtmlHeaders(__FILE__, translate('Video') );
|
|||
</div>
|
||||
<div id="content">
|
||||
<?php
|
||||
if ( isset($_REQUEST['showIndex']) )
|
||||
{
|
||||
$showIndex = validInt($_REQUEST['showIndex']);
|
||||
preg_match( '/([^\/]+)\.([^.]+)$/', $videoFiles[$showIndex], $matches );
|
||||
$name = $matches[1];
|
||||
$videoFormat = $matches[2];
|
||||
if ( isset($_REQUEST['showIndex']) ) {
|
||||
$showIndex = validInt($_REQUEST['showIndex']);
|
||||
preg_match( '/([^\/]+)\.([^.]+)$/', $videoFiles[$showIndex], $matches );
|
||||
$name = $matches[1];
|
||||
$videoFormat = $matches[2];
|
||||
?>
|
||||
<h3 id="videoFile"><?php echo substr( $videoFiles[$showIndex], strlen(ZM_DIR_EVENTS)+1 ) ?></h3>
|
||||
<div id="imageFeed"><?php outputVideoStream( 'videoStream', $videoFiles[$showIndex], validInt($_REQUEST['width']), validInt($_REQUEST['height']), $videoFormat, $name ) ?></div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
?>
|
||||
<form name="contentForm" id="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
||||
<input type="hidden" name="id" value="<?php echo $event['Id'] ?>"/>
|
||||
|
@ -161,29 +146,23 @@ else
|
|||
<input type="button" value="<?php echo translate('GenerateVideo') ?>" onclick="generateVideo( this.form );"<?php if ( !ZM_OPT_FFMPEG ) { ?> disabled="disabled"<?php } ?>/>
|
||||
</form>
|
||||
<?php
|
||||
if ( isset($_REQUEST['generated']) )
|
||||
{
|
||||
if ( isset($_REQUEST['generated']) ) {
|
||||
?>
|
||||
<h2 id="videoProgress" class="<?php echo $_REQUEST['generated']?'infoText':'errorText' ?>"><span id="videoProgressText"><?php echo $_REQUEST['generated']?translate('VideoGenSucceeded'):translate('VideoGenFailed') ?></span><span id="videoProgressTicker"></span></h2>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
?>
|
||||
<h2 id="videoProgress" class="hidden warnText"><span id="videoProgressText"><?php echo translate('GeneratingVideo') ?></span><span id="videoProgressTicker"></span></h2>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h2 id="videoFilesHeader"><?php echo translate('VideoGenFiles') ?></h2>
|
||||
<?php
|
||||
if ( count($videoFiles) == 0 )
|
||||
{
|
||||
if ( count($videoFiles) == 0 ) {
|
||||
?>
|
||||
<h3 id="videoNoFiles"><?php echo translate('VideoGenNoFiles') ?></h3>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
?>
|
||||
<table id="videoTable" class="major" cellspacing="0">
|
||||
<thead>
|
||||
|
@ -197,32 +176,24 @@ else
|
|||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$index = 0;
|
||||
foreach ( $videoFiles as $file )
|
||||
{
|
||||
if ( filesize( $file ) > 0 )
|
||||
{
|
||||
preg_match( '/^(.+)-((?:r[_\d]+)|(?:F[_\d]+))-((?:s[_\d]+)|(?:S[0-9a-z]+))\.([^.]+)$/', $file, $matches );
|
||||
if ( preg_match( '/^r(.+)$/', $matches[2], $temp_matches ) )
|
||||
{
|
||||
$rate = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) );
|
||||
$rateText = isset($rates[$rate])?$rates[$rate]:($rate."x");
|
||||
}
|
||||
elseif ( preg_match( '/^F(.+)$/', $matches[2], $temp_matches ) )
|
||||
{
|
||||
$rateText = $temp_matches[1]."fps";
|
||||
}
|
||||
if ( preg_match( '/^s(.+)$/', $matches[3], $temp_matches ) )
|
||||
{
|
||||
$scale = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) );
|
||||
$scaleText = isset($scales[$scale])?$scales[$scale]:($scale."x");
|
||||
}
|
||||
elseif ( preg_match( '/^S(.+)$/', $matches[3], $temp_matches ) )
|
||||
{
|
||||
$scaleText = $temp_matches[1];
|
||||
}
|
||||
$width = $scale?reScale( $event['Width'], $scale ):$event['Width'];
|
||||
$height = $scale?reScale( $event['Height'], $scale ):$event['Height'];
|
||||
$index = 0;
|
||||
foreach ( $videoFiles as $file ) {
|
||||
if ( filesize( $file ) > 0 ) {
|
||||
preg_match( '/^(.+)-((?:r[_\d]+)|(?:F[_\d]+))-((?:s[_\d]+)|(?:S[0-9a-z]+))\.([^.]+)$/', $file, $matches );
|
||||
if ( preg_match( '/^r(.+)$/', $matches[2], $temp_matches ) ) {
|
||||
$rate = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) );
|
||||
$rateText = isset($rates[$rate])?$rates[$rate]:($rate."x");
|
||||
} elseif ( preg_match( '/^F(.+)$/', $matches[2], $temp_matches ) ) {
|
||||
$rateText = $temp_matches[1]."fps";
|
||||
}
|
||||
if ( preg_match( '/^s(.+)$/', $matches[3], $temp_matches ) ) {
|
||||
$scale = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) );
|
||||
$scaleText = isset($scales[$scale])?$scales[$scale]:($scale."x");
|
||||
} elseif ( preg_match( '/^S(.+)$/', $matches[3], $temp_matches ) ) {
|
||||
$scaleText = $temp_matches[1];
|
||||
}
|
||||
$width = $scale?reScale( $event['Width'], $scale ):$event['Width'];
|
||||
$height = $scale?reScale( $event['Height'], $scale ):$event['Height'];
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $matches[4] ?></td>
|
||||
|
@ -232,14 +203,14 @@ else
|
|||
<td><?php echo makePopupLink( '?view='.$view.'&eid='.$event['Id'].'&width='.$width.'&height='.$height.'&showIndex='.$index, 'zmVideo'.$event['Id'].'-'.$scale, array( 'videoview', $width, $height ), translate('View') ); ?> / <a href="<?php echo substr( $file, strlen(ZM_DIR_EVENTS)+1 ) ?>" onclick="downloadVideo( <?php echo $index ?> ); return( false );"><?php echo translate('Download') ?></a> / <a href="#" onclick="deleteVideo( <?php echo $index ?> ); return( false );"><?php echo translate('Delete') ?></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -59,7 +59,11 @@ xhtmlHeaders( __FILE__, $monitor->Name()." - ".translate('Feed') );
|
|||
<div id="content">
|
||||
<div id="menuBar">
|
||||
<div id="monitorName"><?php echo $monitor->Name() ?></div>
|
||||
<div id="closeControl"><a href="#" onclick="closeWindow(); return( false );"><?php echo translate('Close') ?></a></div>
|
||||
<script type="text/javascript">
|
||||
if ( window.opener ) {
|
||||
document.write('<div id="closeControl"><a href="#" onclick="closeWindow(); return( false );"><?php echo translate('Close') ?></a></div>');
|
||||
}
|
||||
</script>
|
||||
<div id="menuControls">
|
||||
<?php
|
||||
if ( canView( 'Control' ) && $monitor->Type() == 'Local' ) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
// Calling sequence: ... /zm/index.php?view=video&event_id=123
|
||||
|
|
59
zm.conf.in
59
zm.conf.in
|
@ -1,16 +1,15 @@
|
|||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder Base Configuration File
|
||||
# ZoneMinder Base Configuration
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
# *** DO NOT EDIT THIS FILE ***
|
||||
# Changes made directly to this configuration file are no longer supported.
|
||||
# They will be overwritten during an upgrade.
|
||||
#
|
||||
# Instead, create a custom configuration file, with an extention of ".conf"
|
||||
# under the @ZM_CONFIG_SUBDIR@ subfolder containing your desired modifications.
|
||||
#
|
||||
# To make custom changes to the variables below, create a new configuration
|
||||
# file, with an extention of .conf, under the @ZM_CONFIG_SUBDIR@
|
||||
# folder, containing your desired modifications.
|
||||
#
|
||||
|
||||
# Path to installed data directory, used mostly for finding DB upgrade scripts
|
||||
ZM_PATH_DATA=@PKGDATADIR@
|
||||
|
@ -50,43 +49,19 @@ ZM_DB_USER=@ZM_DB_USER@
|
|||
# ZoneMinder database password
|
||||
ZM_DB_PASS=@ZM_DB_PASS@
|
||||
|
||||
# Full path to the folder events are recorded to.
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_DIR_EVENTS=@ZM_DIR_EVENTS@
|
||||
# SSL CA certificate for ZoneMinder database
|
||||
ZM_DB_SSL_CA_CERT=@ZM_DB_SSL_CA_CERT@
|
||||
|
||||
# Full path to the folder images, not directly associated with events,
|
||||
# are recorded to.
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_DIR_IMAGES=@ZM_DIR_IMAGES@
|
||||
# SSL client key for ZoneMinder database
|
||||
ZM_DB_SSL_CLIENT_KEY=@ZM_DB_SSL_CLIENT_KEY@
|
||||
|
||||
# Foldername under the webroot where ZoneMinder looks for optional sound files
|
||||
# to play when an alarm is detected.
|
||||
ZM_DIR_SOUNDS=@ZM_DIR_SOUNDS@
|
||||
# SSL client cert for ZoneMinder database
|
||||
ZM_DB_SSL_CLIENT_CERT=@ZM_DB_SSL_CLIENT_CERT@
|
||||
|
||||
# Full path to the folder where exported archives are stored
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_DIR_EXPORTS=@ZM_TMPDIR@
|
||||
|
||||
# ZoneMinder url path to the zms streaming server
|
||||
ZM_PATH_ZMS=@ZM_PATH_ZMS@
|
||||
|
||||
# Full Path to ZoneMinder's mapped memory files
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_PATH_MAP=@ZM_PATH_MAP@
|
||||
|
||||
# Full Path to ZoneMinder's socket folder
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_PATH_SOCKS=@ZM_SOCKDIR@
|
||||
|
||||
# Full path to ZoneMinder's log folder
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_PATH_LOGS=@ZM_LOGDIR@
|
||||
|
||||
# Full path to ZoneMinder's swap folder
|
||||
# The web account user must have full read/write permission to this folder.
|
||||
ZM_PATH_SWAP=@ZM_TMPDIR@
|
||||
|
||||
# Full path to optional arp binary
|
||||
# ZoneMinder will find the arp binary automatically on most systems
|
||||
ZM_PATH_ARP=@ZM_PATH_ARP@
|
||||
# Do NOT set ZM_SERVER_HOST if you are not using Multi-Server
|
||||
# You have been warned
|
||||
#
|
||||
# The name specified here must have a corresponding entry
|
||||
# in the Servers tab under Options
|
||||
ZM_SERVER_HOST=
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#cmakedefine HAVE_LIBAVUTIL 1
|
||||
#cmakedefine HAVE_LIBAVUTIL_AVUTIL_H 1
|
||||
#cmakedefine HAVE_LIBAVUTIL_MATHEMATICS_H 1
|
||||
#cmakedefine HAVE_LIBAVUTIL_HWCONTEXT_H 0
|
||||
#cmakedefine HAVE_LIBSWSCALE 1
|
||||
#cmakedefine HAVE_LIBSWSCALE_SWSCALE_H 1
|
||||
#cmakedefine HAVE_LIBAVRESAMPLE 1
|
||||
|
|
Loading…
Reference in New Issue