Merge branch 'master' into fix_zone_edit
This commit is contained in:
commit
41776547cb
|
@ -373,7 +373,7 @@ UPDATE States SET IsActive = '1' WHERE Name = 'default';
|
||||||
-- If duplicate states existed while upgrading, that is
|
-- If duplicate states existed while upgrading, that is
|
||||||
-- very likely an error that ZM allowed earlier, so
|
-- very likely an error that ZM allowed earlier, so
|
||||||
-- we are picking up the first one and deleting the others
|
-- we are picking up the first one and deleting the others
|
||||||
ALTER IGNORE TABLE States ADD UNIQUE (Name);
|
ALTER TABLE States ADD UNIQUE (Name);
|
||||||
|
|
||||||
SET @s = (SELECT IF(
|
SET @s = (SELECT IF(
|
||||||
(SELECT COUNT(*)
|
(SELECT COUNT(*)
|
||||||
|
|
|
@ -1,9 +1,43 @@
|
||||||
zoneminder (1.28.1+1-vivid-SNAPSHOT2015081701) vivid; urgency=medium
|
zoneminder (1.29.0+dfsg-1) unstable; urgency=low
|
||||||
|
|
||||||
* include api, switch to cmake build
|
* New upstream release [February 2016] (Closes: #788317, #770851).
|
||||||
|
|
||||||
-- Isaac Connor <iconnor@connortechnology.com> Mon, 17 Aug 2015 10:29:23 -0400
|
[ Dmitry Smirnov <onlyjob@debian.org> ]
|
||||||
|
* copyright/Files-Excluded += "onvif/*" due to licensing uncertainty.
|
||||||
|
* Fixed FTBFS when built with dpkg-buildpackage -A (Closes: #806126).
|
||||||
|
* FFmpeg 2.9 support. Thanks, Andreas Cadhalpun. (Closes: #803850).
|
||||||
|
* Use "ffmpeg" instead of "avconv":
|
||||||
|
+ "libav_path.patch" replaced with "default_ffmpeg_path.patch".
|
||||||
|
* zoneminder/Depends:
|
||||||
|
- perl-modules (package-relation-with-perl-modules)
|
||||||
|
- libav-tools
|
||||||
|
* zoneminder/Recommends:
|
||||||
|
+ ffmpeg | libav-tools
|
||||||
|
* Updated Vcs URLs.
|
||||||
|
* Build/install new man pages.
|
||||||
|
* Removed obsolete lintian-overrides.
|
||||||
|
* README: grant "index" right to DB user.
|
||||||
|
* systemd: start after MySQL but do not require the latter.
|
||||||
|
* Added new patch with spelling corrections.
|
||||||
|
* Removed obsolete patches:
|
||||||
|
- 783.patch
|
||||||
|
- 980-fix-image-size.patch
|
||||||
|
- cmake-fix-confpath.patch
|
||||||
|
- cmake.patch
|
||||||
|
- cmake-gnutls.patch
|
||||||
|
- fix-html-export.patch
|
||||||
|
- format-hardening.patch
|
||||||
|
- libv4l1-videodev.h.patch
|
||||||
|
- pod_man_fixes.patch
|
||||||
|
- pod_name_fixes.patch
|
||||||
|
- pod_zmupdate-to-pod2usage.patch
|
||||||
|
- respect-privacy.patch
|
||||||
|
- zmtrigger-plus.patch
|
||||||
|
|
||||||
|
[ Vagrant Cascadian <vagrant@debian.org> ]
|
||||||
|
* Remove myself from Uploaders.
|
||||||
|
|
||||||
|
-- Dmitry Smirnov <onlyjob@debian.org> Tue, 09 Feb 2016 15:40:32 +1100
|
||||||
|
|
||||||
zoneminder (1.28.1-8) unstable; urgency=medium
|
zoneminder (1.28.1-8) unstable; urgency=medium
|
||||||
|
|
|
@ -5,7 +5,11 @@ Maintainer: Dmitry Smirnov <onlyjob@debian.org>
|
||||||
Uploaders: Vagrant Cascadian <vagrant@debian.org>
|
Uploaders: Vagrant Cascadian <vagrant@debian.org>
|
||||||
Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree
|
Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree
|
||||||
,cmake
|
,cmake
|
||||||
,libavcodec-ffmpeg-dev, libavformat-ffmpeg-dev, libswscale-ffmpeg-dev, libavutil-ffmpeg-dev, libavdevice-ffmpeg-dev
|
,libavdevice-dev (>= 6:10~)
|
||||||
|
,libavcodec-dev (>= 6:10~)
|
||||||
|
,libavformat-dev (>= 6:10~)
|
||||||
|
,libavutil-dev (>= 6:10~)
|
||||||
|
,libswscale-dev (>= 6:10~)
|
||||||
,libbz2-dev
|
,libbz2-dev
|
||||||
,libgcrypt-dev
|
,libgcrypt-dev
|
||||||
,libcurl4-gnutls-dev
|
,libcurl4-gnutls-dev
|
||||||
|
@ -57,14 +61,15 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
||||||
,libsys-cpu-perl, libsys-meminfo-perl
|
,libsys-cpu-perl, libsys-meminfo-perl
|
||||||
,mysql-client | virtual-mysql-client
|
,mysql-client | virtual-mysql-client
|
||||||
,perl-modules
|
,perl-modules
|
||||||
,php5-mysql, php5-gd
|
,php5-mysql | php-mysql, php5-gd | php-gd
|
||||||
,policykit-1
|
,policykit-1
|
||||||
,rsyslog | system-log-daemon
|
,rsyslog | system-log-daemon
|
||||||
,zip
|
,zip
|
||||||
Recommends: ${misc:Recommends}
|
Recommends: ${misc:Recommends}
|
||||||
,libapache2-mod-php5 | php5-fpm
|
,libapache2-mod-php5 | libapache2-mod-php | php5-fpm | php-fpm
|
||||||
,mysql-server | virtual-mysql-server
|
,mysql-server | virtual-mysql-server
|
||||||
,zoneminder-doc (>= ${source:Version})
|
,zoneminder-doc (>= ${source:Version})
|
||||||
|
,ffmpeg
|
||||||
Suggests: fcgiwrap, logrotate
|
Suggests: fcgiwrap, logrotate
|
||||||
Description: video camera security and surveillance solution
|
Description: video camera security and surveillance solution
|
||||||
ZoneMinder is intended for use in single or multi-camera video security
|
ZoneMinder is intended for use in single or multi-camera video security
|
162
src/zm_comms.cpp
162
src/zm_comms.cpp
|
@ -35,6 +35,8 @@
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
|
#include <arpa/inet.h> // for debug output
|
||||||
|
#include <stdio.h> // for snprintf
|
||||||
|
|
||||||
#ifdef SOLARIS
|
#ifdef SOLARIS
|
||||||
#include <sys/filio.h> // define FIONREAD
|
#include <sys/filio.h> // define FIONREAD
|
||||||
|
@ -516,6 +518,166 @@ bool Socket::setNoDelay( bool nodelay )
|
||||||
return( true );
|
return( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InetSocket::connect( const char *host, const char *serv )
|
||||||
|
{
|
||||||
|
struct addrinfo hints;
|
||||||
|
struct addrinfo *result, *rp;
|
||||||
|
int s;
|
||||||
|
char buf[255];
|
||||||
|
|
||||||
|
mAddressFamily = AF_UNSPEC;
|
||||||
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
|
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
|
||||||
|
hints.ai_socktype = getType();
|
||||||
|
hints.ai_flags = 0;
|
||||||
|
hints.ai_protocol = 0; /* Any protocol */
|
||||||
|
|
||||||
|
s = getaddrinfo(host, serv, &hints, &result);
|
||||||
|
if (s != 0) {
|
||||||
|
Error( "connect(): getaddrinfo: %s", gai_strerror(s) );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* getaddrinfo() returns a list of address structures.
|
||||||
|
* Try each address until we successfully connect(2).
|
||||||
|
* If socket(2) (or connect(2)) fails, we (close the socket
|
||||||
|
* and) try the next address. */
|
||||||
|
|
||||||
|
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||||
|
if (mSd != -1) {
|
||||||
|
if (::connect(mSd, rp->ai_addr, rp->ai_addrlen) != -1)
|
||||||
|
break; /* Success */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
memset(&buf, 0, sizeof(buf));
|
||||||
|
if (rp->ai_family == AF_INET) {
|
||||||
|
inet_ntop(AF_INET, &((struct sockaddr_in *)rp->ai_addr)->sin_addr, buf, sizeof(buf)-1);
|
||||||
|
}
|
||||||
|
else if (rp->ai_family == AF_INET6) {
|
||||||
|
inet_ntop(AF_INET6, &((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr, buf, sizeof(buf)-1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strncpy(buf, "n/a", sizeof(buf)-1);
|
||||||
|
}
|
||||||
|
Debug( 1, "connect(): Trying '%s', family '%d', proto '%d'", buf, rp->ai_family, rp->ai_protocol);
|
||||||
|
mSd = ::socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
||||||
|
if (mSd == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int val = 1;
|
||||||
|
|
||||||
|
(void)::setsockopt( mSd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val) );
|
||||||
|
(void)::setsockopt( mSd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val) );
|
||||||
|
mAddressFamily = rp->ai_family; /* save AF_ for ctrl and data connections */
|
||||||
|
|
||||||
|
if (::connect(mSd, rp->ai_addr, rp->ai_addrlen) != -1)
|
||||||
|
break; /* Success */
|
||||||
|
|
||||||
|
::close(mSd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rp == NULL) { /* No address succeeded */
|
||||||
|
Error( "connect(), Could not connect" );
|
||||||
|
mAddressFamily = AF_UNSPEC;
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
freeaddrinfo(result); /* No longer needed */
|
||||||
|
|
||||||
|
mState = CONNECTED;
|
||||||
|
|
||||||
|
return( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InetSocket::connect( const char *host, int port )
|
||||||
|
{
|
||||||
|
char serv[8];
|
||||||
|
snprintf(serv, sizeof(serv), "%d", port);
|
||||||
|
|
||||||
|
return connect( host, serv );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InetSocket::bind( const char * host, const char * serv )
|
||||||
|
{
|
||||||
|
struct addrinfo hints;
|
||||||
|
struct addrinfo *result, *rp;
|
||||||
|
int s;
|
||||||
|
char buf[255];
|
||||||
|
|
||||||
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
|
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
|
||||||
|
hints.ai_socktype = getType();
|
||||||
|
hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
|
||||||
|
hints.ai_protocol = 0; /* Any protocol */
|
||||||
|
hints.ai_canonname = NULL;
|
||||||
|
hints.ai_addr = NULL;
|
||||||
|
hints.ai_next = NULL;
|
||||||
|
|
||||||
|
s = getaddrinfo(host, serv, &hints, &result);
|
||||||
|
if (s != 0) {
|
||||||
|
Error( "bind(): getaddrinfo: %s", gai_strerror(s) );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* getaddrinfo() returns a list of address structures.
|
||||||
|
* Try each address until we successfully bind(2).
|
||||||
|
* If socket(2) (or bind(2)) fails, we (close the socket
|
||||||
|
* and) try the next address. */
|
||||||
|
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||||
|
memset(&buf, 0, sizeof(buf));
|
||||||
|
if (rp->ai_family == AF_INET) {
|
||||||
|
inet_ntop(AF_INET, &((struct sockaddr_in *)rp->ai_addr)->sin_addr, buf, sizeof(buf)-1);
|
||||||
|
}
|
||||||
|
else if (rp->ai_family == AF_INET6) {
|
||||||
|
inet_ntop(AF_INET6, &((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr, buf, sizeof(buf)-1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strncpy(buf, "n/a", sizeof(buf)-1);
|
||||||
|
}
|
||||||
|
Debug( 1, "bind(): Trying '%s', family '%d', proto '%d'", buf, rp->ai_family, rp->ai_protocol);
|
||||||
|
mSd = ::socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
||||||
|
if (mSd == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mState = DISCONNECTED;
|
||||||
|
if (::bind(mSd, rp->ai_addr, rp->ai_addrlen) == 0)
|
||||||
|
break; /* Success */
|
||||||
|
|
||||||
|
::close(mSd);
|
||||||
|
mSd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rp == NULL) { /* No address succeeded */
|
||||||
|
Error( "bind(), Could not bind" );
|
||||||
|
return( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
freeaddrinfo(result); /* No longer needed */
|
||||||
|
|
||||||
|
return( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InetSocket::bind( const char * serv )
|
||||||
|
{
|
||||||
|
return bind( NULL, serv);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InetSocket::bind( const char * host, int port )
|
||||||
|
{
|
||||||
|
char serv[8];
|
||||||
|
snprintf(serv, sizeof(serv), "%d", port);
|
||||||
|
|
||||||
|
return bind( host, serv );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InetSocket::bind( int port )
|
||||||
|
{
|
||||||
|
char serv[8];
|
||||||
|
snprintf(serv, sizeof(serv), "%d", port);
|
||||||
|
|
||||||
|
return bind( NULL, serv );
|
||||||
|
}
|
||||||
|
|
||||||
bool TcpInetServer::listen()
|
bool TcpInetServer::listen()
|
||||||
{
|
{
|
||||||
return( Socket::listen() );
|
return( Socket::listen() );
|
||||||
|
|
158
src/zm_comms.h
158
src/zm_comms.h
|
@ -399,103 +399,27 @@ public:
|
||||||
|
|
||||||
class InetSocket : virtual public Socket
|
class InetSocket : virtual public Socket
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
int mAddressFamily;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int getDomain() const
|
int getDomain() const
|
||||||
{
|
{
|
||||||
return( AF_INET );
|
return( mAddressFamily );
|
||||||
}
|
}
|
||||||
virtual socklen_t getAddrSize() const
|
virtual socklen_t getAddrSize() const
|
||||||
{
|
{
|
||||||
return( SockAddrInet::addrSize() );
|
return( SockAddrInet::addrSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool resolveLocal( const char *host, const char *serv, const char *proto )
|
bool connect( const char *host, const char *serv );
|
||||||
{
|
bool connect( const char *host, int port );
|
||||||
SockAddrInet *addr = new SockAddrInet;
|
|
||||||
mLocalAddr = addr;
|
|
||||||
return( addr->resolve( host, serv, proto ) );
|
|
||||||
}
|
|
||||||
bool resolveLocal( const char *host, int port, const char *proto )
|
|
||||||
{
|
|
||||||
SockAddrInet *addr = new SockAddrInet;
|
|
||||||
mLocalAddr = addr;
|
|
||||||
return( addr->resolve( host, port, proto ) );
|
|
||||||
}
|
|
||||||
bool resolveLocal( const char *serv, const char *proto )
|
|
||||||
{
|
|
||||||
SockAddrInet *addr = new SockAddrInet;
|
|
||||||
mLocalAddr = addr;
|
|
||||||
return( addr->resolve( serv, proto ) );
|
|
||||||
}
|
|
||||||
bool resolveLocal( int port, const char *proto )
|
|
||||||
{
|
|
||||||
SockAddrInet *addr = new SockAddrInet;
|
|
||||||
mLocalAddr = addr;
|
|
||||||
return( addr->resolve( port, proto ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool resolveRemote( const char *host, const char *serv, const char *proto )
|
bool bind( const char *host, const char *serv );
|
||||||
{
|
bool bind( const char *host, int port );
|
||||||
SockAddrInet *addr = new SockAddrInet;
|
bool bind( const char *serv );
|
||||||
mRemoteAddr = addr;
|
bool bind( int port );
|
||||||
return( addr->resolve( host, serv, proto ) );
|
|
||||||
}
|
|
||||||
bool resolveRemote( const char *host, int port, const char *proto )
|
|
||||||
{
|
|
||||||
SockAddrInet *addr = new SockAddrInet;
|
|
||||||
mRemoteAddr = addr;
|
|
||||||
return( addr->resolve( host, port, proto ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool bind( const SockAddrInet &addr )
|
|
||||||
{
|
|
||||||
mLocalAddr = new SockAddrInet( addr );
|
|
||||||
return( Socket::bind() );
|
|
||||||
}
|
|
||||||
bool bind( const char *host, const char *serv )
|
|
||||||
{
|
|
||||||
if ( !resolveLocal( host, serv, getProtocol() ) )
|
|
||||||
return( false );
|
|
||||||
return( Socket::bind() );
|
|
||||||
}
|
|
||||||
bool bind( const char *host, int port )
|
|
||||||
{
|
|
||||||
if ( !resolveLocal( host, port, getProtocol() ) )
|
|
||||||
return( false );
|
|
||||||
return( Socket::bind() );
|
|
||||||
}
|
|
||||||
bool bind( const char *serv )
|
|
||||||
{
|
|
||||||
if ( !resolveLocal( serv, getProtocol() ) )
|
|
||||||
return( false );
|
|
||||||
return( Socket::bind() );
|
|
||||||
}
|
|
||||||
bool bind( int port )
|
|
||||||
{
|
|
||||||
if ( !resolveLocal( port, getProtocol() ) )
|
|
||||||
return( false );
|
|
||||||
return( Socket::bind() );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool connect( const SockAddrInet &addr )
|
|
||||||
{
|
|
||||||
mRemoteAddr = new SockAddrInet( addr );
|
|
||||||
return( Socket::connect() );
|
|
||||||
}
|
|
||||||
bool connect( const char *host, const char *serv )
|
|
||||||
{
|
|
||||||
if ( !resolveRemote( host, serv, getProtocol() ) )
|
|
||||||
return( false );
|
|
||||||
return( Socket::connect() );
|
|
||||||
}
|
|
||||||
bool connect( const char *host, int port )
|
|
||||||
{
|
|
||||||
if ( !resolveRemote( host, port, getProtocol() ) )
|
|
||||||
return( false );
|
|
||||||
return( Socket::connect() );
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnixSocket : virtual public Socket
|
class UnixSocket : virtual public Socket
|
||||||
|
@ -591,10 +515,6 @@ public:
|
||||||
class UdpInetSocket : virtual public UdpSocket, virtual public InetSocket
|
class UdpInetSocket : virtual public UdpSocket, virtual public InetSocket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool bind( const SockAddrInet &addr )
|
|
||||||
{
|
|
||||||
return( InetSocket::bind( addr ) );
|
|
||||||
}
|
|
||||||
bool bind( const char *host, const char *serv )
|
bool bind( const char *host, const char *serv )
|
||||||
{
|
{
|
||||||
return( InetSocket::bind( host, serv ) );
|
return( InetSocket::bind( host, serv ) );
|
||||||
|
@ -612,10 +532,6 @@ public:
|
||||||
return( InetSocket::bind( port ) );
|
return( InetSocket::bind( port ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool connect( const SockAddrInet &addr )
|
|
||||||
{
|
|
||||||
return( InetSocket::connect( addr ) );
|
|
||||||
}
|
|
||||||
bool connect( const char *host, const char *serv )
|
bool connect( const char *host, const char *serv )
|
||||||
{
|
{
|
||||||
return( InetSocket::connect( host, serv ) );
|
return( InetSocket::connect( host, serv ) );
|
||||||
|
@ -642,33 +558,7 @@ public:
|
||||||
|
|
||||||
class UdpInetClient : public UdpInetSocket
|
class UdpInetClient : public UdpInetSocket
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
bool bind( const SockAddrInet &addr )
|
|
||||||
{
|
|
||||||
return( UdpInetSocket::bind( addr ) );
|
|
||||||
}
|
|
||||||
bool bind( const char *host, const char *serv )
|
|
||||||
{
|
|
||||||
return( UdpInetSocket::bind( host, serv ) );
|
|
||||||
}
|
|
||||||
bool bind( const char *host, int port )
|
|
||||||
{
|
|
||||||
return( UdpInetSocket::bind( host, port ) );
|
|
||||||
}
|
|
||||||
bool bind( const char *serv )
|
|
||||||
{
|
|
||||||
return( UdpInetSocket::bind( serv ) );
|
|
||||||
}
|
|
||||||
bool bind( int port )
|
|
||||||
{
|
|
||||||
return( UdpInetSocket::bind( port ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool connect( const SockAddrInet &addr )
|
|
||||||
{
|
|
||||||
return( UdpInetSocket::connect( addr ) );
|
|
||||||
}
|
|
||||||
bool connect( const char *host, const char *serv )
|
bool connect( const char *host, const char *serv )
|
||||||
{
|
{
|
||||||
return( UdpInetSocket::connect( host, serv ) );
|
return( UdpInetSocket::connect( host, serv ) );
|
||||||
|
@ -697,10 +587,6 @@ public:
|
||||||
class UdpInetServer : public UdpInetSocket
|
class UdpInetServer : public UdpInetSocket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool bind( const SockAddrInet &addr )
|
|
||||||
{
|
|
||||||
return( UdpInetSocket::bind( addr ) );
|
|
||||||
}
|
|
||||||
bool bind( const char *host, const char *serv )
|
bool bind( const char *host, const char *serv )
|
||||||
{
|
{
|
||||||
return( UdpInetSocket::bind( host, serv ) );
|
return( UdpInetSocket::bind( host, serv ) );
|
||||||
|
@ -812,18 +698,6 @@ public:
|
||||||
class TcpInetServer : public TcpInetSocket
|
class TcpInetServer : public TcpInetSocket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool bind( const char *host, const char *serv )
|
|
||||||
{
|
|
||||||
return( TcpInetSocket::bind( host, serv ) );
|
|
||||||
}
|
|
||||||
bool bind( const char *host, int port )
|
|
||||||
{
|
|
||||||
return( TcpInetSocket::bind( host, port ) );
|
|
||||||
}
|
|
||||||
bool bind( const char *serv )
|
|
||||||
{
|
|
||||||
return( TcpInetSocket::bind( serv ) );
|
|
||||||
}
|
|
||||||
bool bind( int port )
|
bool bind( int port )
|
||||||
{
|
{
|
||||||
return( TcpInetSocket::bind( port ) );
|
return( TcpInetSocket::bind( port ) );
|
||||||
|
|
|
@ -160,12 +160,20 @@ int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check the buffer sizes */
|
/* 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);
|
size_t insize = avpicture_get_size(in_pf, width, height);
|
||||||
|
#endif
|
||||||
if(insize != in_buffer_size) {
|
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);
|
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;
|
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);
|
size_t outsize = avpicture_get_size(out_pf, width, height);
|
||||||
|
#endif
|
||||||
if(outsize < out_buffer_size) {
|
if(outsize < out_buffer_size) {
|
||||||
Error("The output buffer is undersized for the output format. Required: %d Available: %d", outsize, out_buffer_size);
|
Error("The output buffer is undersized for the output format. Required: %d Available: %d", outsize, out_buffer_size);
|
||||||
return -5;
|
return -5;
|
||||||
|
|
|
@ -47,6 +47,10 @@ extern "C" {
|
||||||
#else
|
#else
|
||||||
#include <libavcodec/opt.h>
|
#include <libavcodec/opt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
#include <libavutil/imgutils.h>
|
||||||
|
#endif
|
||||||
#elif HAVE_FFMPEG_AVUTIL_H
|
#elif HAVE_FFMPEG_AVUTIL_H
|
||||||
#include <ffmpeg/avutil.h>
|
#include <ffmpeg/avutil.h>
|
||||||
#include <ffmpeg/base64.h>
|
#include <ffmpeg/base64.h>
|
||||||
|
|
|
@ -182,8 +182,13 @@ int FfmpegCamera::Capture( Image &image )
|
||||||
if ( frameComplete )
|
if ( frameComplete )
|
||||||
{
|
{
|
||||||
Debug( 3, "Got frame %d", frameCount );
|
Debug( 3, "Got frame %d", frameCount );
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height);
|
av_image_fill_arrays(mFrame->data, mFrame->linesize,
|
||||||
|
directbuffer, imagePixFormat, width, height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)mFrame, directbuffer,
|
||||||
|
imagePixFormat, width, height);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_LIBSWSCALE
|
#if HAVE_LIBSWSCALE
|
||||||
if(mConvertContext == NULL) {
|
if(mConvertContext == NULL) {
|
||||||
|
@ -354,7 +359,12 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||||
|
|
||||||
Debug ( 1, "Allocated frames" );
|
Debug ( 1, "Allocated frames" );
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int pSize = av_image_get_buffer_size( imagePixFormat, width, height,1 );
|
||||||
|
#else
|
||||||
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
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);
|
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,7 +626,11 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel,
|
||||||
if ( !tmpPicture )
|
if ( !tmpPicture )
|
||||||
Fatal( "Could not allocate temporary picture" );
|
Fatal( "Could not allocate temporary picture" );
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int pSize = av_image_get_buffer_size( imagePixFormat, width, height,1 );
|
||||||
|
#else
|
||||||
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
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);
|
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
||||||
}
|
}
|
||||||
|
@ -859,7 +863,18 @@ void LocalCamera::Initialise()
|
||||||
#endif
|
#endif
|
||||||
if ( !capturePictures[i] )
|
if ( !capturePictures[i] )
|
||||||
Fatal( "Could not allocate picture" );
|
Fatal( "Could not allocate picture" );
|
||||||
avpicture_fill( (AVPicture *)capturePictures[i], (uint8_t*)v4l2_data.buffers[i].start, capturePixFormat, v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(capturePictures[i]->data,
|
||||||
|
capturePictures[i]->linesize,
|
||||||
|
(uint8_t*)v4l2_data.buffers[i].start,capturePixFormat,
|
||||||
|
v4l2_data.fmt.fmt.pix.width,
|
||||||
|
v4l2_data.fmt.fmt.pix.height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)capturePictures[i],
|
||||||
|
(uint8_t*)v4l2_data.buffers[i].start, capturePixFormat,
|
||||||
|
v4l2_data.fmt.fmt.pix.width,
|
||||||
|
v4l2_data.fmt.fmt.pix.height );
|
||||||
|
#endif
|
||||||
#endif // HAVE_LIBSWSCALE
|
#endif // HAVE_LIBSWSCALE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,7 +1032,16 @@ void LocalCamera::Initialise()
|
||||||
#endif
|
#endif
|
||||||
if ( !capturePictures[i] )
|
if ( !capturePictures[i] )
|
||||||
Fatal( "Could not allocate picture" );
|
Fatal( "Could not allocate picture" );
|
||||||
avpicture_fill( (AVPicture *)capturePictures[i], (unsigned char *)v4l1_data.bufptr+v4l1_data.frames.offsets[i], capturePixFormat, width, height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(capturePictures[i]->data,
|
||||||
|
capturePictures[i]->linesize,
|
||||||
|
(unsigned char *)v4l1_data.bufptr+v4l1_data.frames.offsets[i],
|
||||||
|
capturePixFormat, width, height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)capturePictures[i],
|
||||||
|
(unsigned char *)v4l1_data.bufptr+v4l1_data.frames.offsets[i],
|
||||||
|
capturePixFormat, width, height );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif // HAVE_LIBSWSCALE
|
#endif // HAVE_LIBSWSCALE
|
||||||
|
|
||||||
|
@ -2113,7 +2137,14 @@ int LocalCamera::Capture( Image &image )
|
||||||
|
|
||||||
Debug( 9, "Calling sws_scale to perform the conversion" );
|
Debug( 9, "Calling sws_scale to perform the conversion" );
|
||||||
/* Use swscale to convert the image directly into the shared memory */
|
/* Use swscale to convert the image directly into the shared memory */
|
||||||
avpicture_fill( (AVPicture *)tmpPicture, directbuffer, imagePixFormat, width, height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(tmpPicture->data,
|
||||||
|
tmpPicture->linesize, directbuffer,
|
||||||
|
imagePixFormat, width, height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)tmpPicture, directbuffer,
|
||||||
|
imagePixFormat, width, height );
|
||||||
|
#endif
|
||||||
sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize );
|
sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -333,7 +333,13 @@ void VideoStream::OpenStream( )
|
||||||
Panic( "Could not allocate opicture" );
|
Panic( "Could not allocate opicture" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int size = av_image_get_buffer_size( c->pix_fmt, c->width,
|
||||||
|
c->height, 1 );
|
||||||
|
#else
|
||||||
int size = avpicture_get_size( c->pix_fmt, c->width, c->height );
|
int size = avpicture_get_size( c->pix_fmt, c->width, c->height );
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t *opicture_buf = (uint8_t *)av_malloc( size );
|
uint8_t *opicture_buf = (uint8_t *)av_malloc( size );
|
||||||
if ( !opicture_buf )
|
if ( !opicture_buf )
|
||||||
{
|
{
|
||||||
|
@ -344,7 +350,13 @@ void VideoStream::OpenStream( )
|
||||||
#endif
|
#endif
|
||||||
Panic( "Could not allocate opicture_buf" );
|
Panic( "Could not allocate opicture_buf" );
|
||||||
}
|
}
|
||||||
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt, c->width, c->height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(opicture->data, opicture->linesize,
|
||||||
|
opicture_buf, c->pix_fmt, c->width, c->height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt,
|
||||||
|
c->width, c->height );
|
||||||
|
#endif
|
||||||
|
|
||||||
/* if the output format is not identical to the input format, then a temporary
|
/* if the output format is not identical to the input format, then a temporary
|
||||||
picture is needed too. It is then converted to the required
|
picture is needed too. It is then converted to the required
|
||||||
|
@ -361,7 +373,12 @@ void VideoStream::OpenStream( )
|
||||||
{
|
{
|
||||||
Panic( "Could not allocate tmp_opicture" );
|
Panic( "Could not allocate tmp_opicture" );
|
||||||
}
|
}
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int size = av_image_get_buffer_size( pf, c->width,
|
||||||
|
c->height,1 );
|
||||||
|
#else
|
||||||
int size = avpicture_get_size( pf, c->width, c->height );
|
int size = avpicture_get_size( pf, c->width, c->height );
|
||||||
|
#endif
|
||||||
uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size );
|
uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size );
|
||||||
if ( !tmp_opicture_buf )
|
if ( !tmp_opicture_buf )
|
||||||
{
|
{
|
||||||
|
@ -372,7 +389,14 @@ void VideoStream::OpenStream( )
|
||||||
#endif
|
#endif
|
||||||
Panic( "Could not allocate tmp_opicture_buf" );
|
Panic( "Could not allocate tmp_opicture_buf" );
|
||||||
}
|
}
|
||||||
avpicture_fill( (AVPicture *)tmp_opicture, tmp_opicture_buf, pf, c->width, c->height );
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(tmp_opicture->data,
|
||||||
|
tmp_opicture->linesize, tmp_opicture_buf, pf,
|
||||||
|
c->width, c->height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)tmp_opicture,
|
||||||
|
tmp_opicture_buf, pf, c->width, c->height );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,14 +702,14 @@ double VideoStream::ActuallyEncodeFrame( const uint8_t *buffer, int buffer_size,
|
||||||
#endif
|
#endif
|
||||||
if ( got_packet )
|
if ( got_packet )
|
||||||
{
|
{
|
||||||
if ( c->coded_frame->key_frame )
|
// if ( c->coded_frame->key_frame )
|
||||||
{
|
// {
|
||||||
#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
|
//#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
// pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
#else
|
//#else
|
||||||
pkt->flags |= PKT_FLAG_KEY;
|
// pkt->flags |= PKT_FLAG_KEY;
|
||||||
#endif
|
//#endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ( pkt->pts != (int64_t)AV_NOPTS_VALUE )
|
if ( pkt->pts != (int64_t)AV_NOPTS_VALUE )
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,7 +214,12 @@ int RemoteCameraRtsp::PrimeCapture()
|
||||||
if(mRawFrame == NULL || mFrame == NULL)
|
if(mRawFrame == NULL || mFrame == NULL)
|
||||||
Fatal( "Unable to allocate frame(s)");
|
Fatal( "Unable to allocate frame(s)");
|
||||||
|
|
||||||
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
int pSize = av_image_get_buffer_size( imagePixFormat, width, height, 1 );
|
||||||
|
#else
|
||||||
int pSize = avpicture_get_size( imagePixFormat, width, height );
|
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);
|
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +335,13 @@ int RemoteCameraRtsp::Capture( Image &image )
|
||||||
|
|
||||||
Debug( 3, "Got frame %d", frameCount );
|
Debug( 3, "Got frame %d", frameCount );
|
||||||
|
|
||||||
avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height);
|
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
|
||||||
|
av_image_fill_arrays(mFrame->data, mFrame->linesize,
|
||||||
|
directbuffer, imagePixFormat, width, height, 1);
|
||||||
|
#else
|
||||||
|
avpicture_fill( (AVPicture *)mFrame, directbuffer,
|
||||||
|
imagePixFormat, width, height);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_LIBSWSCALE
|
#if HAVE_LIBSWSCALE
|
||||||
if(mConvertContext == NULL) {
|
if(mConvertContext == NULL) {
|
||||||
|
|
|
@ -279,20 +279,17 @@ int RtpCtrlThread::run()
|
||||||
UdpInetSocket rtpCtrlServer;
|
UdpInetSocket rtpCtrlServer;
|
||||||
if ( mRtpSource.getLocalHost() != "" )
|
if ( mRtpSource.getLocalHost() != "" )
|
||||||
{
|
{
|
||||||
localAddr.resolve( mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalCtrlPort(), "udp" );
|
if ( !rtpCtrlServer.bind( mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalCtrlPort() ) )
|
||||||
if ( !rtpCtrlServer.bind( localAddr ) )
|
|
||||||
Fatal( "Failed to bind RTCP server" );
|
Fatal( "Failed to bind RTCP server" );
|
||||||
sendReports = false;
|
sendReports = false;
|
||||||
Debug( 3, "Bound to %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalCtrlPort() );
|
Debug( 3, "Bound to %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalCtrlPort() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
localAddr.resolve( mRtpSource.getLocalCtrlPort(), "udp" );
|
if ( !rtpCtrlServer.bind( mRtspThread.getAddressFamily() == AF_INET6 ? "::" : "0.0.0.0", mRtpSource.getLocalCtrlPort() ) )
|
||||||
if ( !rtpCtrlServer.bind( localAddr ) )
|
|
||||||
Fatal( "Failed to bind RTCP server" );
|
Fatal( "Failed to bind RTCP server" );
|
||||||
Debug( 3, "Bound to %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalCtrlPort() );
|
Debug( 3, "Bound to %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalCtrlPort() );
|
||||||
remoteAddr.resolve( mRtpSource.getRemoteHost().c_str(), mRtpSource.getRemoteCtrlPort(), "udp" );
|
if ( !rtpCtrlServer.connect( mRtpSource.getRemoteHost().c_str(), mRtpSource.getRemoteCtrlPort() ) )
|
||||||
if ( !rtpCtrlServer.connect( remoteAddr ) )
|
|
||||||
Fatal( "Failed to connect RTCP server" );
|
Fatal( "Failed to connect RTCP server" );
|
||||||
Debug( 3, "Connected to %s:%d", mRtpSource.getRemoteHost().c_str(), mRtpSource.getRemoteCtrlPort() );
|
Debug( 3, "Connected to %s:%d", mRtpSource.getRemoteHost().c_str(), mRtpSource.getRemoteCtrlPort() );
|
||||||
sendReports = true;
|
sendReports = true;
|
||||||
|
|
|
@ -67,13 +67,17 @@ int RtpDataThread::run()
|
||||||
|
|
||||||
SockAddrInet localAddr;
|
SockAddrInet localAddr;
|
||||||
UdpInetServer rtpDataSocket;
|
UdpInetServer rtpDataSocket;
|
||||||
if ( mRtpSource.getLocalHost() != "" )
|
if ( mRtpSource.getLocalHost() != "" ) {
|
||||||
localAddr.resolve( mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalDataPort(), "udp" );
|
if ( !rtpDataSocket.bind( mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalDataPort() ) )
|
||||||
else
|
|
||||||
localAddr.resolve( mRtpSource.getLocalDataPort(), "udp" );
|
|
||||||
if ( !rtpDataSocket.bind( localAddr ) )
|
|
||||||
Fatal( "Failed to bind RTP server" );
|
Fatal( "Failed to bind RTP server" );
|
||||||
Debug( 3, "Bound to %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalDataPort() );
|
Debug( 3, "Bound to %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalDataPort() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !rtpDataSocket.bind( mRtspThread.getAddressFamily() == AF_INET6 ? "::" : "0.0.0.0", mRtpSource.getLocalDataPort() ) )
|
||||||
|
Fatal( "Failed to bind RTP server" );
|
||||||
|
Debug( 3, "Bound to %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalDataPort() );
|
||||||
|
}
|
||||||
|
|
||||||
Select select( 3 );
|
Select select( 3 );
|
||||||
select.addReader( &rtpDataSocket );
|
select.addReader( &rtpDataSocket );
|
||||||
|
|
|
@ -234,7 +234,7 @@ int RtspThread::run()
|
||||||
|
|
||||||
response.reserve( ZM_NETWORK_BUFSIZ );
|
response.reserve( ZM_NETWORK_BUFSIZ );
|
||||||
|
|
||||||
if ( !mRtspSocket.connect( mHost.c_str(), strtol( mPort.c_str(), NULL, 10 ) ) )
|
if ( !mRtspSocket.connect( mHost.c_str(), mPort.c_str() ) )
|
||||||
Fatal( "Unable to connect RTSP socket" );
|
Fatal( "Unable to connect RTSP socket" );
|
||||||
//Select select( 0.25 );
|
//Select select( 0.25 );
|
||||||
//select.addReader( &mRtspSocket );
|
//select.addReader( &mRtspSocket );
|
||||||
|
@ -248,7 +248,7 @@ int RtspThread::run()
|
||||||
bool authTried = false;
|
bool authTried = false;
|
||||||
if ( mMethod == RTP_RTSP_HTTP )
|
if ( mMethod == RTP_RTSP_HTTP )
|
||||||
{
|
{
|
||||||
if ( !mRtspSocket2.connect( mHost.c_str(), strtol( mPort.c_str(), NULL, 10 ) ) )
|
if ( !mRtspSocket2.connect( mHost.c_str(), mPort.c_str() ) )
|
||||||
Fatal( "Unable to connect auxiliary RTSP/HTTP socket" );
|
Fatal( "Unable to connect auxiliary RTSP/HTTP socket" );
|
||||||
//Select select( 0.25 );
|
//Select select( 0.25 );
|
||||||
//select.addReader( &mRtspSocket2 );
|
//select.addReader( &mRtspSocket2 );
|
||||||
|
@ -306,7 +306,7 @@ int RtspThread::run()
|
||||||
mAuthenticator->checkAuthResponse(response);
|
mAuthenticator->checkAuthResponse(response);
|
||||||
Debug(2, "Processed 401 response");
|
Debug(2, "Processed 401 response");
|
||||||
mRtspSocket.close();
|
mRtspSocket.close();
|
||||||
if ( !mRtspSocket.connect( mHost.c_str(), strtol( mPort.c_str(), NULL, 10 ) ) )
|
if ( !mRtspSocket.connect( mHost.c_str(), mPort.c_str() ) )
|
||||||
Fatal( "Unable to reconnect RTSP socket" );
|
Fatal( "Unable to reconnect RTSP socket" );
|
||||||
Debug(2, "connection should be reopened now");
|
Debug(2, "connection should be reopened now");
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,10 @@ public:
|
||||||
{
|
{
|
||||||
return( mStop );
|
return( mStop );
|
||||||
}
|
}
|
||||||
|
int getAddressFamily ()
|
||||||
|
{
|
||||||
|
return mRtspSocket.getDomain();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ZM_RTSP_H
|
#endif // ZM_RTSP_H
|
||||||
|
|
|
@ -112,7 +112,7 @@ SessionDescriptor::ConnInfo::ConnInfo( const std::string &connInfo ) :
|
||||||
if ( mNetworkType != "IN" )
|
if ( mNetworkType != "IN" )
|
||||||
throw Exception( "Invalid SDP network type '"+mNetworkType+"' in connection info '"+connInfo+"'" );
|
throw Exception( "Invalid SDP network type '"+mNetworkType+"' in connection info '"+connInfo+"'" );
|
||||||
mAddressType = tokens[1];
|
mAddressType = tokens[1];
|
||||||
if ( mAddressType != "IP4" )
|
if ( mAddressType != "IP4" && mAddressType != "IP6" )
|
||||||
throw Exception( "Invalid SDP address type '"+mAddressType+"' in connection info '"+connInfo+"'" );
|
throw Exception( "Invalid SDP address type '"+mAddressType+"' in connection info '"+connInfo+"'" );
|
||||||
StringVector addressTokens = split( tokens[2], "/" );
|
StringVector addressTokens = split( tokens[2], "/" );
|
||||||
if ( addressTokens.size() < 1 )
|
if ( addressTokens.size() < 1 )
|
||||||
|
|
|
@ -49,7 +49,7 @@ git submodule update --init --recursive
|
||||||
if [ $DISTRO == "trusty" ]; then
|
if [ $DISTRO == "trusty" ]; then
|
||||||
ln -sf distros/ubuntu1204 debian
|
ln -sf distros/ubuntu1204 debian
|
||||||
else
|
else
|
||||||
ln -sf distros/ubuntu1504 debian
|
ln -sf distros/ubuntu1604 debian
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
# Auto-install all ZoneMinder's depedencies using the Debian control file
|
# Auto-install all ZoneMinder's depedencies using the Debian control file
|
||||||
|
|
|
@ -253,11 +253,20 @@ public function beforeFilter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// format expected:
|
||||||
|
// you can changed AlarmFrames to any other named params
|
||||||
|
// consoleEvents/1 hour/AlarmFrames >=: 1/AlarmFrames <=: 20.json
|
||||||
|
|
||||||
public function consoleEvents($interval = null) {
|
public function consoleEvents($interval = null) {
|
||||||
$this->Event->recursive = -1;
|
$this->Event->recursive = -1;
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$query = $this->Event->query("select MonitorId, COUNT(*) AS Count from Events WHERE StartTime >= (DATE_SUB(NOW(), interval $interval)) GROUP BY MonitorId;");
|
$moreconditions ="";
|
||||||
|
foreach ($this->request->params['named'] as $name => $param) {
|
||||||
|
$moreconditions = $moreconditions . " AND ".$name.$param;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->Event->query("select MonitorId, COUNT(*) AS Count from Events WHERE (StartTime >= (DATE_SUB(NOW(), interval $interval)) $moreconditions) GROUP BY MonitorId;");
|
||||||
|
|
||||||
foreach ($query as $result) {
|
foreach ($query as $result) {
|
||||||
$results[$result['Events']['MonitorId']] = $result[0]['Count'];
|
$results[$result['Events']['MonitorId']] = $result[0]['Count'];
|
||||||
|
|
|
@ -138,7 +138,8 @@ public function beforeFilter() {
|
||||||
'_serialize' => array('message')
|
'_serialize' => array('message')
|
||||||
));
|
));
|
||||||
// - restart this monitor after change
|
// - restart this monitor after change
|
||||||
$this->daemonControl($this->Monitor->id, 'restart', $this->request->data);
|
// We don't pass the request data as the monitor object because it may be a subset of the full monitor array
|
||||||
|
$this->daemonControl( $this->Monitor->id, 'restart' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,6 +184,78 @@ public function beforeFilter() {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// arm/disarm alarms
|
||||||
|
// expected format: http(s):/portal-api-url/monitors/alarm/id:M/command:C.json
|
||||||
|
// where M=monitorId
|
||||||
|
// where C=on|off
|
||||||
|
public function alarm()
|
||||||
|
{
|
||||||
|
$id = $this->request->params['named']['id'];
|
||||||
|
$cmd = strtolower($this->request->params['named']['command']);
|
||||||
|
if (!$this->Monitor->exists($id)) {
|
||||||
|
throw new NotFoundException(__('Invalid monitor'));
|
||||||
|
}
|
||||||
|
if ( $cmd != 'on' && $cmd != 'off')
|
||||||
|
{
|
||||||
|
throw new BadRequestException(__('Invalid command'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->Session->Read('systemPermission') != 'Edit')
|
||||||
|
{
|
||||||
|
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$zm_path_bin = Configure::read('ZM_PATH_BIN');
|
||||||
|
$q = ($cmd == 'on') ? '-a':'-c';
|
||||||
|
|
||||||
|
// form auth key based on auth credentials
|
||||||
|
$this->loadModel('Config');
|
||||||
|
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH'));
|
||||||
|
$config = $this->Config->find('first', $options);
|
||||||
|
$zmOptAuth = $config['Config']['Value'];
|
||||||
|
|
||||||
|
|
||||||
|
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY'));
|
||||||
|
$config = $this->Config->find('first', $options);
|
||||||
|
$zmAuthRelay = $config['Config']['Value'];
|
||||||
|
|
||||||
|
$auth="";
|
||||||
|
if ($zmOptAuth)
|
||||||
|
{
|
||||||
|
if ($zmAuthRelay == 'hashed')
|
||||||
|
{
|
||||||
|
$options = array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_SECRET'));
|
||||||
|
$config = $this->Config->find('first', $options);
|
||||||
|
$zmAuthHashSecret = $config['Config']['Value'];
|
||||||
|
|
||||||
|
$time = localtime();
|
||||||
|
$ak = $zmAuthHashSecret.$this->Session->Read('username').$this->Session->Read('passwordHash').$time[2].$time[3].$time[4].$time[5];
|
||||||
|
$ak = md5($ak);
|
||||||
|
$auth = " -A ".$ak;
|
||||||
|
}
|
||||||
|
elseif ($zmAuthRelay == 'plain')
|
||||||
|
{
|
||||||
|
$auth = " -U " .$this->Session->Read('username')." -P ".$this->Session->Read('password');
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($zmAuthRelay == 'none')
|
||||||
|
{
|
||||||
|
$auth = " -U " .$this->Session->Read('username');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$shellcmd = escapeshellcmd("$zm_path_bin/zmu -v -m$id $q $auth");
|
||||||
|
$status = exec ($shellcmd);
|
||||||
|
|
||||||
|
$this->set(array(
|
||||||
|
'status' => $status,
|
||||||
|
'_serialize' => array('status'),
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Check if a daemon is running for the monitor id
|
// Check if a daemon is running for the monitor id
|
||||||
public function daemonStatus() {
|
public function daemonStatus() {
|
||||||
$id = $this->request->params['named']['id'];
|
$id = $this->request->params['named']['id'];
|
||||||
|
|
Loading…
Reference in New Issue