Updated debug format
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2513 e3e1d417-86f3-4887-817a-d78f3d33393fpull/27/merge
parent
8cd38d5206
commit
ee44d4b274
|
@ -85,7 +85,7 @@ public:
|
|||
{
|
||||
if ( count > size )
|
||||
{
|
||||
Warning(( "Attempt to consume %d bytes of buffer, size is only %d bytes", count, size ));
|
||||
Warning( "Attempt to consume %d bytes of buffer, size is only %d bytes", count, size );
|
||||
count = size;
|
||||
}
|
||||
head += count;
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
{
|
||||
if ( count > size )
|
||||
{
|
||||
Warning(( "Attempt to shrink buffer by %d bytes, size is only %d bytes", count, size ));
|
||||
Warning( "Attempt to shrink buffer by %d bytes, size is only %d bytes", count, size );
|
||||
count = size;
|
||||
}
|
||||
size -= count;
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
{
|
||||
if ( p_size > size )
|
||||
{
|
||||
Warning(( "Attempt to extract %d bytes of buffer, size is only %d bytes", p_size, size ));
|
||||
Warning( "Attempt to extract %d bytes of buffer, size is only %d bytes", p_size, size );
|
||||
p_size = size;
|
||||
}
|
||||
unsigned char *old_head = head;
|
||||
|
|
|
@ -52,9 +52,9 @@ public:
|
|||
virtual ~Camera();
|
||||
|
||||
SourceType Type() const { return( type ); }
|
||||
bool IsLocal() const { return( type == LOCAL ); }
|
||||
bool IsRemote() const { return( type == REMOTE ); }
|
||||
bool IsFile() const { return( type == FILE ); }
|
||||
bool IsLocal() const { return( type == LOCAL_SRC ); }
|
||||
bool IsRemote() const { return( type == REMOTE_SRC ); }
|
||||
bool IsFile() const { return( type == FILE_SRC ); }
|
||||
unsigned int Width() const { return( width ); }
|
||||
unsigned int Height() const { return( height ); }
|
||||
unsigned int Palette() const { return( palette ); }
|
||||
|
|
|
@ -90,7 +90,7 @@ bool Pipe::Open()
|
|||
{
|
||||
if ( pipe( fd ) < 0 )
|
||||
{
|
||||
Error(( "pipe(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "pipe(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ bool Pipe::SetBlocking( bool blocking )
|
|||
/* Now set it for non-blocking I/O */
|
||||
if ( (flags = fcntl( fd[1], F_GETFL )) < 0 )
|
||||
{
|
||||
Error(( "fcntl(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "fcntl(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
if ( blocking )
|
||||
|
@ -126,7 +126,7 @@ bool Pipe::SetBlocking( bool blocking )
|
|||
}
|
||||
if ( fcntl( fd[1], F_SETFL, flags ) < 0 )
|
||||
{
|
||||
Error(( "fcntl(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "fcntl(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ bool SocketBase::Socket()
|
|||
{
|
||||
if ( (sd = ::socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 )
|
||||
{
|
||||
Error(( "socket(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "socket(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ int SocketBase::BytesToRead() const
|
|||
|
||||
if ( ioctl( sd, FIONREAD, &bytes_to_read ) < 0 )
|
||||
{
|
||||
Error(( "ioctl(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "ioctl(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
return( bytes_to_read );
|
||||
|
@ -174,7 +174,7 @@ bool SocketBase::GetBlocking( bool &blocking )
|
|||
|
||||
if ( (flags = fcntl( sd, F_GETFL )) < 0 )
|
||||
{
|
||||
Error(( "fcntl(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "fcntl(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
blocking = (flags & O_NONBLOCK);
|
||||
|
@ -188,7 +188,7 @@ bool SocketBase::SetBlocking( bool blocking )
|
|||
int ioctl_arg = !blocking;
|
||||
if ( ioctl( sd, FIONBIO, &ioctl_arg ) < 0 )
|
||||
{
|
||||
Error(( "ioctl(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "ioctl(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -199,7 +199,7 @@ bool SocketBase::SetBlocking( bool blocking )
|
|||
/* Now set it for non-blocking I/O */
|
||||
if ( (flags = fcntl( sd, F_GETFL )) < 0 )
|
||||
{
|
||||
Error(( "fcntl(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "fcntl(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
if ( blocking )
|
||||
|
@ -212,7 +212,7 @@ bool SocketBase::SetBlocking( bool blocking )
|
|||
}
|
||||
if ( fcntl( sd, F_SETFL, flags ) < 0 )
|
||||
{
|
||||
Error(( "fcntl(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "fcntl(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ bool SocketBase::GetSendBufferSize( int &buffersize ) const
|
|||
socklen_t optlen = sizeof(buffersize);
|
||||
if ( getsockopt( sd, SOL_SOCKET, SO_SNDBUF, &buffersize, &optlen ) < 0 )
|
||||
{
|
||||
Error(( "getsockopt(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "getsockopt(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
return( buffersize );
|
||||
|
@ -235,7 +235,7 @@ bool SocketBase::GetRecvBufferSize( int &buffersize ) const
|
|||
socklen_t optlen = sizeof(buffersize);
|
||||
if ( getsockopt( sd, SOL_SOCKET, SO_RCVBUF, &buffersize, &optlen ) < 0 )
|
||||
{
|
||||
Error(( "getsockopt(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "getsockopt(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
return( buffersize );
|
||||
|
@ -245,7 +245,7 @@ bool SocketBase::SetSendBufferSize( int buffersize )
|
|||
{
|
||||
if ( setsockopt( sd, SOL_SOCKET, SO_SNDBUF, (char *)&buffersize, sizeof(buffersize)) < 0 )
|
||||
{
|
||||
Error(( "setsockopt(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "setsockopt(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -255,7 +255,7 @@ bool SocketBase::SetRecvBufferSize( int buffersize )
|
|||
{
|
||||
if ( setsockopt( sd, SOL_SOCKET, SO_RCVBUF, (char *)&buffersize, sizeof(buffersize)) < 0 )
|
||||
{
|
||||
Error(( "setsockopt(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "setsockopt(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -267,7 +267,7 @@ bool SocketBase::GetRouting( bool &route ) const
|
|||
socklen_t optlen = sizeof(dontroute);
|
||||
if ( getsockopt( sd, SOL_SOCKET, SO_DONTROUTE, &dontroute, &optlen ) < 0 )
|
||||
{
|
||||
Error(( "getsockopt(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "getsockopt(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
route = !dontroute;
|
||||
|
@ -279,7 +279,7 @@ bool SocketBase::SetRouting( bool route )
|
|||
int dontroute = !route;
|
||||
if ( setsockopt( sd, SOL_SOCKET, SO_DONTROUTE, (char *)&dontroute, sizeof(dontroute)) < 0 )
|
||||
{
|
||||
Error(( "setsockopt(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "setsockopt(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -291,7 +291,7 @@ bool SocketBase::GetNoDelay( bool &nodelay ) const
|
|||
socklen_t optlen = sizeof(int_nodelay);
|
||||
if ( getsockopt( sd, IPPROTO_TCP, TCP_NODELAY, &int_nodelay, &optlen ) < 0 )
|
||||
{
|
||||
Error(( "getsockopt(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "getsockopt(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
nodelay = int_nodelay;
|
||||
|
@ -304,7 +304,7 @@ bool SocketBase::SetNoDelay( bool nodelay )
|
|||
|
||||
if ( setsockopt( sd, IPPROTO_TCP, TCP_NODELAY, (char *)&int_nodelay, sizeof(int_nodelay)) < 0 )
|
||||
{
|
||||
Error(( "setsockopt(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "setsockopt(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -317,7 +317,7 @@ bool SocketClient::SetupRemoteHost( const char *host )
|
|||
|
||||
if ( !(p_rem_host = ::gethostbyname( host ) ) )
|
||||
{
|
||||
Error(( "gethostbyname( %s ), h_errno = %d", host, h_errno ));
|
||||
Error( "gethostbyname( %s ), h_errno = %d", host, h_errno );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ bool SocketClient::SetupRemoteServ( const char *serv, const char *protocol )
|
|||
|
||||
if ( !(p_rem_serv = ::getservbyname( serv, protocol ) ) )
|
||||
{
|
||||
Error(( "getservbyname( %s ), errno = %d, error = %s", serv, errno, strerror(errno) ));
|
||||
Error( "getservbyname( %s ), errno = %d, error = %s", serv, errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ bool SocketClient::Open()
|
|||
|
||||
if ( ::connect( sd, (struct sockaddr *)&rem_addr, sizeof(rem_addr) ) == -1 )
|
||||
{
|
||||
Error(( "connect(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "connect(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
Close();
|
||||
return( false );
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ bool UDPSocket::Socket()
|
|||
{
|
||||
if ( (sd = ::socket( AF_INET, SOCK_DGRAM, 0 ) ) < 0 )
|
||||
{
|
||||
Error(( "socket(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "socket(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -440,7 +440,7 @@ bool TCPServer::SetupLocalHost()
|
|||
|
||||
if ( ::gethostname( host, sizeof(host) ) == -1 )
|
||||
{
|
||||
Error(( "gethostname(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "gethostname(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,7 @@ bool TCPServer::SetupLocalHost()
|
|||
|
||||
if ( !(p_loc_host = ::gethostbyname( host ) ) )
|
||||
{
|
||||
Error(( "gethostbyname( %s ), h_errno = %d", host, h_errno ));
|
||||
Error( "gethostbyname( %s ), h_errno = %d", host, h_errno );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ bool TCPServer::SetupLocalServ( const char *serv )
|
|||
|
||||
if ( !(p_loc_serv = ::getservbyname( serv, "tcp" ) ) )
|
||||
{
|
||||
Error(( "getservbyname( %s ), errno = %d, error = %s", serv, errno, strerror(errno) ));
|
||||
Error( "getservbyname( %s ), errno = %d, error = %s", serv, errno, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -520,14 +520,14 @@ bool TCPServer::Open()
|
|||
|
||||
if ( ::bind( sd, (struct sockaddr *)&loc_addr, sizeof(loc_addr) ) == -1 )
|
||||
{
|
||||
Error(( "bind(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "bind(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
Close();
|
||||
return( false );
|
||||
}
|
||||
|
||||
if ( ::listen( sd, SOMAXCONN ) == -1 )
|
||||
{
|
||||
Error(( "listen(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "listen(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
Close();
|
||||
return( false );
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ bool TCPServer::Accept()
|
|||
|
||||
if ( (new_sd = accept( sd, (struct sockaddr *)&rem_addr, &rem_addr_size )) == -1 )
|
||||
{
|
||||
Error(( "accept(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "accept(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
Close();
|
||||
return( false );
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ bool TCPServer::Accept( TCPServer *&server )
|
|||
|
||||
if ( (new_sd = accept( sd, (struct sockaddr *)&rem_addr, &rem_addr_size )) == -1 )
|
||||
{
|
||||
Error(( "connect(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Error( "connect(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
Close();
|
||||
return( false );
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void zmLoadConfig()
|
|||
char *val;
|
||||
if ( (cfg = fopen( ZM_CONFIG, "r")) == NULL )
|
||||
{
|
||||
Fatal(("Can't open %s: %s", ZM_CONFIG, strerror(errno) ));
|
||||
Fatal("Can't open %s: %s", ZM_CONFIG, strerror(errno) );
|
||||
}
|
||||
while ( fgets( line, sizeof(line), cfg ) != NULL )
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ void zmLoadConfig()
|
|||
temp_ptr = strchr( line_ptr, '=' );
|
||||
if ( !temp_ptr )
|
||||
{
|
||||
Warning(( "Invalid data in %s: '%s'", ZM_CONFIG, line ));
|
||||
Warning( "Invalid data in %s: '%s'", ZM_CONFIG, line );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ void zmLoadConfig()
|
|||
{
|
||||
// We ignore this now as there may be more parameters than the
|
||||
// c/c++ binaries are bothered about
|
||||
// Warning(( "Invalid parameter '%s' in %s", name_ptr, ZM_CONFIG ));
|
||||
// Warning( "Invalid parameter '%s' in %s", name_ptr, ZM_CONFIG );
|
||||
}
|
||||
}
|
||||
fclose( cfg);
|
||||
|
@ -113,7 +113,7 @@ ConfigItem::ConfigItem( const char *p_name, const char *p_value, const char *con
|
|||
type = new char[strlen(p_type)+1];
|
||||
strcpy( type, p_type );
|
||||
|
||||
//Info(( "Created new config item %s = %s (%s)\n", name, value, type ));
|
||||
//Info( "Created new config item %s = %s (%s)\n", name, value, type );
|
||||
|
||||
accessed = false;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ bool ConfigItem::BooleanValue() const
|
|||
|
||||
if ( cfg_type != CFG_BOOLEAN )
|
||||
{
|
||||
Error(( "Attempt to fetch boolean value for %s, actual type is %s. Try running 'zmupdate.pl -f' to reload config.", name, type ));
|
||||
Error( "Attempt to fetch boolean value for %s, actual type is %s. Try running 'zmupdate.pl -f' to reload config.", name, type );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ int ConfigItem::IntegerValue() const
|
|||
|
||||
if ( cfg_type != CFG_INTEGER )
|
||||
{
|
||||
Error(( "Attempt to fetch integer value for %s, actual type is %s. Try running 'zmupdate.pl -f' to reload config.", name, type ));
|
||||
Error( "Attempt to fetch integer value for %s, actual type is %s. Try running 'zmupdate.pl -f' to reload config.", name, type );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ double ConfigItem::DecimalValue() const
|
|||
|
||||
if ( cfg_type != CFG_DECIMAL )
|
||||
{
|
||||
Error(( "Attempt to fetch decimal value for %s, actual type is %s. Try running 'zmupdate.pl -f' to reload config.", name, type ));
|
||||
Error( "Attempt to fetch decimal value for %s, actual type is %s. Try running 'zmupdate.pl -f' to reload config.", name, type );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ const char *ConfigItem::StringValue() const
|
|||
|
||||
if ( cfg_type != CFG_STRING )
|
||||
{
|
||||
Error(( "Attempt to fetch string value for %s, actual type is %s. Try running 'zmupdate.pl -f' to reload config.", name, type ));
|
||||
Error( "Attempt to fetch string value for %s, actual type is %s. Try running 'zmupdate.pl -f' to reload config.", name, type );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -236,21 +236,21 @@ void Config::Load()
|
|||
strncpy( sql, "select Name, Value, Type from Config order by Id", sizeof(sql) );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
n_items = mysql_num_rows( result );
|
||||
|
||||
if ( n_items <= ZM_MAX_CFG_ID )
|
||||
{
|
||||
Error(( "Config mismatch, expected %d items, read %d. Try running 'zmupdate.pl -f' to reload config.", ZM_MAX_CFG_ID+1, n_items ));
|
||||
Error( "Config mismatch, expected %d items, read %d. Try running 'zmupdate.pl -f' to reload config.", ZM_MAX_CFG_ID+1, n_items );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -274,13 +274,13 @@ ZM_CFG_ASSIGN_LIST
|
|||
snprintf( extra_level_env, sizeof(extra_level_env), "ZM_DBG_LEVEL%s=%d", extra_debug_target, extra_debug_level );
|
||||
if ( putenv( extra_level_env ) < 0 )
|
||||
{
|
||||
Error(("Can't putenv %s: %s", extra_level_env, strerror(errno) ));
|
||||
Error("Can't putenv %s: %s", extra_level_env, strerror(errno) );
|
||||
}
|
||||
|
||||
snprintf( extra_log_env, sizeof(extra_log_env), "ZM_DBG_LOG%s=%s", extra_debug_target, extra_debug_log );
|
||||
if ( putenv( extra_log_env ) < 0 )
|
||||
{
|
||||
Error(("Can't putenv %s: %s", extra_log_env, strerror(errno) ));
|
||||
Error("Can't putenv %s: %s", extra_log_env, strerror(errno) );
|
||||
}
|
||||
|
||||
zmDbgReinit( extra_debug_target );
|
||||
|
@ -297,7 +297,7 @@ const ConfigItem &Config::Item( int id )
|
|||
|
||||
if ( id < 0 || id > ZM_MAX_CFG_ID )
|
||||
{
|
||||
Error(( "Attempt to access invalid config, id = %d. Try running 'zmupdate.pl -f' to reload config.", id ));
|
||||
Error( "Attempt to access invalid config, id = %d. Try running 'zmupdate.pl -f' to reload config.", id );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ const ConfigItem &Config::Item( int id )
|
|||
|
||||
if ( !item )
|
||||
{
|
||||
Error(( "Can't find config item %d", id ));
|
||||
Error( "Can't find config item %d", id );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ void zmDbConnect()
|
|||
{
|
||||
if ( !mysql_init( &dbconn ) )
|
||||
{
|
||||
Error(( "Can't initialise structure: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't initialise structure: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
char dbHost[256];
|
||||
|
@ -40,7 +40,7 @@ void zmDbConnect()
|
|||
char *dbPort = colon_ptr+1;
|
||||
if ( !mysql_real_connect( &dbconn, dbHost, ZM_DB_USER, ZM_DB_PASS, 0, atoi(dbPort), 0, 0 ) )
|
||||
{
|
||||
Error(( "Can't connect to server: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't connect to server: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
}
|
||||
|
@ -48,13 +48,13 @@ void zmDbConnect()
|
|||
{
|
||||
if ( !mysql_real_connect( &dbconn, ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS, 0, 0, 0, 0 ) )
|
||||
{
|
||||
Error(( "Can't connect to server: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't connect to server: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
}
|
||||
if ( mysql_select_db( &dbconn, ZM_DB_NAME ) )
|
||||
{
|
||||
Error(( "Can't select database: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't select database: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
}
|
||||
|
|
155
src/zm_debug.c
155
src/zm_debug.c
|
@ -30,18 +30,10 @@
|
|||
|
||||
#include "zm_debug.h"
|
||||
|
||||
static char zm_temp_dbg_string[4096];
|
||||
static char zm_dbg_string[4096+512];
|
||||
static const char *zm_dbg_file;
|
||||
static int zm_dbg_line;
|
||||
static int zm_dbg_code;
|
||||
static char zm_dbg_class[4];
|
||||
|
||||
char zm_dbg_syslog[64];
|
||||
char zm_dbg_name[64];
|
||||
char zm_dbg_id[64];
|
||||
int zm_dbg_level = 0;
|
||||
int zm_dbg_pid = -1;
|
||||
|
||||
char zm_dbg_log[PATH_MAX] = "";
|
||||
FILE *zm_dbg_log_fd = (FILE *)NULL;
|
||||
|
@ -69,7 +61,7 @@ void zmUsrHandler( int sig )
|
|||
zm_dbg_level--;
|
||||
}
|
||||
}
|
||||
Info(( "Debug Level Changed to %d", zm_dbg_level ));
|
||||
Info( "Debug Level Changed to %d", zm_dbg_level );
|
||||
}
|
||||
|
||||
int zmGetDebugEnv()
|
||||
|
@ -171,7 +163,7 @@ int zmDebugPrepareLog()
|
|||
fflush( zm_dbg_log_fd );
|
||||
if ( fclose(zm_dbg_log_fd) == -1 )
|
||||
{
|
||||
Error(( "fclose(), error = %s",strerror(errno)) );
|
||||
Error( "fclose(), error = %s",strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
zm_dbg_log_fd = (FILE *)NULL;
|
||||
|
@ -193,7 +185,7 @@ int zmDebugPrepareLog()
|
|||
|
||||
if( zm_dbg_log[0] && (zm_dbg_log_fd = fopen(zm_dbg_log,"w")) == (FILE *)NULL )
|
||||
{
|
||||
Error(("fopen() for %s, error = %s",zm_dbg_log,strerror(errno)));
|
||||
Error( "fopen() for %s, error = %s", zm_dbg_log, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
return( 0 );
|
||||
|
@ -202,9 +194,8 @@ int zmDebugPrepareLog()
|
|||
int zmDebugInitialise( const char *name, const char *id, int level )
|
||||
{
|
||||
int status;
|
||||
struct timezone tzp;
|
||||
|
||||
gettimeofday( &zm_dbg_start, &tzp );
|
||||
gettimeofday( &zm_dbg_start, NULL );
|
||||
|
||||
strncpy( zm_dbg_name, name, sizeof(zm_dbg_name) );
|
||||
strncpy( zm_dbg_id, id, sizeof(zm_dbg_id) );
|
||||
|
@ -220,21 +211,17 @@ int zmDebugInitialise( const char *name, const char *id, int level )
|
|||
|
||||
strncpy( zm_dbg_name, zm_dbg_syslog, sizeof(zm_dbg_name) );
|
||||
|
||||
zm_temp_dbg_string[0] = '\0';
|
||||
zm_dbg_class[0] = '\0';
|
||||
|
||||
zm_dbg_pid = getpid();
|
||||
zm_dbg_log_fd = (FILE *)NULL;
|
||||
|
||||
if( (status = zmGetDebugEnv() ) < 0)
|
||||
{
|
||||
Error(( "Debug Environment Error, status = %d", status ));
|
||||
Error( "Debug Environment Error, status = %d", status );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
zmDebugPrepareLog();
|
||||
|
||||
Info(( "Debug Level = %d, Debug Log = %s", zm_dbg_level,zm_dbg_log[0]?zm_dbg_log:"<none>" ));
|
||||
Info( "Debug Level = %d, Debug Log = %s", zm_dbg_level, zm_dbg_log[0]?zm_dbg_log:"<none>" );
|
||||
|
||||
{
|
||||
struct sigaction action;
|
||||
|
@ -244,12 +231,12 @@ int zmDebugInitialise( const char *name, const char *id, int level )
|
|||
|
||||
if ( sigaction( SIGUSR1, &action, 0 ) < 0 )
|
||||
{
|
||||
Error(("sigaction(), error = %s",strerror(errno)));
|
||||
Error( "sigaction(), error = %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
if ( sigaction( SIGUSR2, &action, 0 ) < 0)
|
||||
{
|
||||
Error(("sigaction(), error = %s",strerror(errno)));
|
||||
Error( "sigaction(), error = %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
@ -296,13 +283,13 @@ int zmDebugReinitialise( const char *target )
|
|||
{
|
||||
if ( (status = zmGetDebugEnv() ) < 0 )
|
||||
{
|
||||
Error(( "Debug Environment Error, status = %d", status ));
|
||||
Error( "Debug Environment Error, status = %d", status );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
zmDebugPrepareLog();
|
||||
|
||||
Info(( "New Debug Level = %d, New Debug Log = %s", zm_dbg_level, zm_dbg_log[0]?zm_dbg_log:"<none>" ));
|
||||
Info( "New Debug Level = %d, New Debug Log = %s", zm_dbg_level, zm_dbg_log[0]?zm_dbg_log:"<none>" );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
|
@ -315,11 +302,11 @@ int zmDbgReinit( const char *target )
|
|||
|
||||
int zmDebugTerminate()
|
||||
{
|
||||
Debug( 1,( "Terminating Debug" ));
|
||||
Debug( 1, "Terminating Debug" );
|
||||
fflush( zm_dbg_log_fd );
|
||||
if ( fclose(zm_dbg_log_fd) == -1 )
|
||||
{
|
||||
Error(( "fclose(), error = %s",strerror(errno)) );
|
||||
Error( "fclose(), error = %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
zm_dbg_log_fd = (FILE *)NULL;
|
||||
|
@ -348,52 +335,42 @@ void zmDbgSubtractTime( struct timeval * const tp1, struct timeval * const tp2 )
|
|||
}
|
||||
}
|
||||
|
||||
int zmDbgPrepare( const char * const file, const int line, const int level )
|
||||
{
|
||||
zm_dbg_file = file;
|
||||
zm_dbg_line = line;
|
||||
zm_dbg_code = level;
|
||||
switch(level)
|
||||
{
|
||||
case ZM_DBG_INF:
|
||||
strcpy( zm_dbg_class,"INF" );
|
||||
break;
|
||||
case ZM_DBG_WAR:
|
||||
strcpy( zm_dbg_class,"WAR" );
|
||||
break;
|
||||
case ZM_DBG_ERR:
|
||||
strcpy( zm_dbg_class,"ERR" );
|
||||
break;
|
||||
case ZM_DBG_FAT:
|
||||
strcpy( zm_dbg_class,"FAT" );
|
||||
break;
|
||||
default:
|
||||
if ( level > 0 && level <= 9 )
|
||||
{
|
||||
sprintf( zm_dbg_class, "DB%d", level );
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(( "Unknown Error Level %d", level ));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return( level );
|
||||
}
|
||||
|
||||
int zmDbgOutput( const char *fstring, ... )
|
||||
void zmDbgOutput( const char * const file, const int line, const int level, const char *fstring, ... )
|
||||
{
|
||||
char class_string[4];
|
||||
char time_string[64];
|
||||
char dbg_string[1024];
|
||||
va_list arg_ptr;
|
||||
int log_code;
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
|
||||
zm_temp_dbg_string[0] = '\0';
|
||||
va_start(arg_ptr,fstring);
|
||||
vsprintf(zm_temp_dbg_string,fstring,arg_ptr);
|
||||
switch ( level )
|
||||
{
|
||||
case ZM_DBG_INF:
|
||||
strncpy( class_string, "INF", sizeof(class_string) );
|
||||
break;
|
||||
case ZM_DBG_WAR:
|
||||
strncpy( class_string, "WAR", sizeof(class_string) );
|
||||
break;
|
||||
case ZM_DBG_ERR:
|
||||
strncpy( class_string, "ERR", sizeof(class_string) );
|
||||
break;
|
||||
case ZM_DBG_FAT:
|
||||
strncpy( class_string, "FAT", sizeof(class_string) );
|
||||
break;
|
||||
default:
|
||||
if ( level > 0 && level <= 9 )
|
||||
{
|
||||
snprintf( class_string, sizeof(class_string), "DB%d", level );
|
||||
}
|
||||
else
|
||||
{
|
||||
Error( "Unknown Error Level %d", level );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
gettimeofday( &tp, &tzp );
|
||||
gettimeofday( &tp, NULL );
|
||||
|
||||
if ( zm_dbg_runtime )
|
||||
{
|
||||
|
@ -403,41 +380,46 @@ int zmDbgOutput( const char *fstring, ... )
|
|||
}
|
||||
else
|
||||
{
|
||||
time_t the_time;
|
||||
|
||||
the_time = tp.tv_sec;
|
||||
|
||||
strftime(time_string,63,"%x %H:%M:%S",localtime(&the_time));
|
||||
sprintf(&(time_string[strlen(time_string)]), ".%06ld", tp.tv_usec);
|
||||
|
||||
char *time_ptr = time_string;
|
||||
time_ptr += strftime( time_ptr, sizeof(time_string), "%x %H:%M:%S", localtime(&tp.tv_sec) );
|
||||
snprintf( time_ptr, sizeof(time_string)-(time_ptr-time_string), ".%06ld", tp.tv_usec );
|
||||
}
|
||||
sprintf(zm_dbg_string,"%s %s[%d].%s-%s/%d [%s]\n",
|
||||
|
||||
char *dbg_ptr = dbg_string;
|
||||
dbg_ptr += snprintf( dbg_ptr, sizeof(dbg_string), "%s %s[%ld].%s-%s/%d [",
|
||||
time_string,
|
||||
zm_dbg_name,
|
||||
zm_dbg_pid,
|
||||
zm_dbg_class,
|
||||
zm_dbg_file,
|
||||
zm_dbg_line,
|
||||
zm_temp_dbg_string
|
||||
syscall(224),
|
||||
class_string,
|
||||
file,
|
||||
line
|
||||
);
|
||||
char *dbg_log_start = dbg_ptr;
|
||||
|
||||
va_start( arg_ptr, fstring );
|
||||
dbg_ptr += vsnprintf( dbg_ptr, sizeof(dbg_string)-(dbg_ptr-dbg_string), fstring, arg_ptr );
|
||||
va_end(arg_ptr);
|
||||
char *dbg_log_end = dbg_ptr;
|
||||
strncpy( dbg_ptr, "]\n", sizeof(dbg_string)-(dbg_ptr-dbg_string) );
|
||||
|
||||
if ( zm_dbg_print )
|
||||
{
|
||||
printf("%s", zm_dbg_string);
|
||||
fflush(stdout);
|
||||
printf( "%s", dbg_string );
|
||||
fflush( stdout );
|
||||
}
|
||||
if ( zm_dbg_log_fd != (FILE *)NULL )
|
||||
{
|
||||
fprintf( zm_dbg_log_fd, "%s", zm_dbg_string );
|
||||
fprintf( zm_dbg_log_fd, "%s", dbg_string );
|
||||
|
||||
if ( zm_dbg_flush )
|
||||
{
|
||||
fflush(zm_dbg_log_fd);
|
||||
fflush( zm_dbg_log_fd );
|
||||
}
|
||||
}
|
||||
/* For Info, Warning, Errors etc we want to log them */
|
||||
if ( zm_dbg_code <= ZM_DBG_SYSLOG )
|
||||
if ( level <= ZM_DBG_SYSLOG )
|
||||
{
|
||||
switch(zm_dbg_code)
|
||||
switch( level )
|
||||
{
|
||||
case ZM_DBG_INF:
|
||||
log_code = LOG_INFO;
|
||||
|
@ -456,13 +438,12 @@ int zmDbgOutput( const char *fstring, ... )
|
|||
break;
|
||||
}
|
||||
//log_code |= LOG_DAEMON;
|
||||
syslog( log_code, "%s [%s]", zm_dbg_class, zm_temp_dbg_string );
|
||||
*dbg_log_end = '\0';
|
||||
syslog( log_code, "%s [%s]", class_string, dbg_log_start );
|
||||
}
|
||||
va_end(arg_ptr);
|
||||
if ( zm_dbg_code == ZM_DBG_FAT )
|
||||
if ( level == ZM_DBG_FAT )
|
||||
{
|
||||
abort();
|
||||
exit( -1 );
|
||||
}
|
||||
return( strlen( zm_temp_dbg_string ) );
|
||||
}
|
||||
|
|
|
@ -37,29 +37,31 @@
|
|||
/* Define the level at which messages go through syslog */
|
||||
#define ZM_DBG_SYSLOG ZM_DBG_INF
|
||||
|
||||
#define zmDbgPrintf(level,params) {\
|
||||
#define zmDbgPrintf(level,params...) {\
|
||||
if (level <= zm_dbg_level)\
|
||||
{\
|
||||
(void) zmDbgPrepare(__FILE__,__LINE__,level);\
|
||||
(void) zmDbgOutput params;\
|
||||
}\
|
||||
zmDbgOutput( __FILE__, __LINE__, level, ##params );\
|
||||
}
|
||||
|
||||
#define zmDbgHexdump(level,data,len) {\
|
||||
if (level <= zm_dbg_level)\
|
||||
zmDbgOutput( __FILE__, __LINE__, level, ##params );\
|
||||
}
|
||||
|
||||
/* Turn off debug here */
|
||||
#ifndef ZM_DBG_OFF
|
||||
#define Debug(level,params) zmDbgPrintf(level,params)
|
||||
#define Debug(level,params...) zmDbgPrintf(level,##params)
|
||||
#define Hexdump(level,data,len) zmDbgHexdump(level,data,len)
|
||||
#else
|
||||
#define Debug(level,params)
|
||||
#define Debug(level,params...)
|
||||
#define Hexdump(level,data,len)
|
||||
#endif
|
||||
|
||||
#define Info(params) zmDbgPrintf(0, params)
|
||||
#define Warning(params) zmDbgPrintf(ZM_DBG_WAR,params)
|
||||
#define Error(params) zmDbgPrintf(ZM_DBG_ERR,params)
|
||||
#define Fatal(params) zmDbgPrintf(ZM_DBG_FAT,params)
|
||||
#define Entrypoint(params) zmDbgPrintf(9,params);
|
||||
#define Exitpoint(params) zmDbgPrintf(9,params);
|
||||
#define Mark() Info(("Mark/%s/%d", __FILE__, __LINE__ ))
|
||||
#define Log() Info(("Log"))
|
||||
#define Info(params...) zmDbgPrintf(ZM_DBG_INF,##params)
|
||||
#define Warning(params...) zmDbgPrintf(ZM_DBG_WAR,##params)
|
||||
#define Error(params...) zmDbgPrintf(ZM_DBG_ERR,##params)
|
||||
#define Fatal(params...) zmDbgPrintf(ZM_DBG_FAT,##params)
|
||||
#define Mark() Info("Mark/%s/%d",__FILE__,__LINE__)
|
||||
#define Log() Info("Log")
|
||||
#ifdef __GNUC__
|
||||
#define Enter(level) zmDbgPrintf(level,("Entering %s",__PRETTY_FUNCTION__))
|
||||
#define Exit(level) zmDbgPrintf(level,("Exiting %s",__PRETTY_FUNCTION__))
|
||||
|
@ -107,14 +109,13 @@ void zmDbgSubtractTime( struct timeval * const tp1, struct timeval * const tp2 )
|
|||
int zmDbgInit( const char *name, const char *id, int level );
|
||||
int zmDbgReinit( const char *target );
|
||||
int zmDbgTerm(void);
|
||||
int zmDbgPrepare( const char * const file, const int line, const int level );
|
||||
int zmDbgOutput( const char *fstring, ... ) __attribute__ ((format(printf, 1, 2)));
|
||||
void zmDbgOutput( const char * const file, const int line, const int level, const char *fstring, ... ) __attribute__ ((format(printf, 4, 5)));
|
||||
|
||||
#else
|
||||
int zmDbgInit();
|
||||
int zmDbgReinit();
|
||||
int zmDbgTerm();
|
||||
int zmDbgPrepare();
|
||||
int zmDbgOutput();
|
||||
void zmDbgOutput();
|
||||
#endif
|
||||
|
||||
extern int zm_dbg_level;
|
||||
|
|
162
src/zm_event.cpp
162
src/zm_event.cpp
|
@ -60,7 +60,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const char *p_cau
|
|||
snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', '%s', %d, %d, '%s', '%s' )", monitor->Id(), start_time_str, monitor->Width(), monitor->Height(), cause, text );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't insert event: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't insert event: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
id = mysql_insert_id( &dbconn );
|
||||
|
@ -97,7 +97,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const char *p_cau
|
|||
{
|
||||
if ( mkdir( path, 0755 ) )
|
||||
{
|
||||
Fatal(( "Can't mkdir %s: %s", path, strerror(errno)));
|
||||
Fatal( "Can't mkdir %s: %s", path, strerror(errno));
|
||||
}
|
||||
}
|
||||
if ( i == 2 )
|
||||
|
@ -109,13 +109,13 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const char *p_cau
|
|||
// Create event id symlink
|
||||
snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id );
|
||||
if ( symlink( time_path, id_file ) < 0 )
|
||||
Fatal(( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno)));
|
||||
Fatal( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno));
|
||||
// Create empty id tag file
|
||||
snprintf( id_file, sizeof(id_file), "%s/.%d", path, id );
|
||||
if ( FILE *id_fp = fopen( id_file, "w" ) )
|
||||
fclose( id_fp );
|
||||
else
|
||||
Fatal(( "Can't fopen %s: %s", id_file, strerror(errno)));
|
||||
Fatal( "Can't fopen %s: %s", id_file, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const char *p_cau
|
|||
{
|
||||
if ( mkdir( path, 0755 ) )
|
||||
{
|
||||
Error(( "Can't mkdir %s: %s", path, strerror(errno)));
|
||||
Error( "Can't mkdir %s: %s", path, strerror(errno));
|
||||
}
|
||||
}
|
||||
char id_file[PATH_MAX];
|
||||
|
@ -137,7 +137,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const char *p_cau
|
|||
if ( FILE *id_fp = fopen( id_file, "w" ) )
|
||||
fclose( id_fp );
|
||||
else
|
||||
Fatal(( "Can't fopen %s: %s", id_file, strerror(errno)));
|
||||
Fatal( "Can't fopen %s: %s", id_file, strerror(errno));
|
||||
}
|
||||
last_db_frame = 0;
|
||||
}
|
||||
|
@ -149,12 +149,12 @@ Event::~Event()
|
|||
struct DeltaTimeval delta_time;
|
||||
DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 );
|
||||
|
||||
Debug( 1, ( "Adding closing frame %d to DB", frames ));
|
||||
Debug( 1, "Adding closing frame %d to DB", frames );
|
||||
static char sql[BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %ld ), %s%ld.%02ld )", id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't insert frame: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't insert frame: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ Event::~Event()
|
|||
snprintf( sql, sizeof(sql), "update Events set Name='%s%d', EndTime = '%s', Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", monitor->EventPrefix(), id, end_time_str, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't update event: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't update event: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ bool Event::OpenFrameSocket( int monitor_id )
|
|||
sd = socket( AF_UNIX, SOCK_STREAM, 0);
|
||||
if ( sd < 0 )
|
||||
{
|
||||
Error(( "Can't create socket: %s", strerror(errno) ));
|
||||
Error( "Can't create socket: %s", strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ bool Event::OpenFrameSocket( int monitor_id )
|
|||
{
|
||||
if ( setsockopt( sd, SOL_SOCKET, SO_SNDBUF, &socket_buffer_size, sizeof(socket_buffer_size) ) < 0 )
|
||||
{
|
||||
Error(( "Can't get socket buffer size to %d, error = %s", socket_buffer_size, strerror(errno) ));
|
||||
Error( "Can't get socket buffer size to %d, error = %s", socket_buffer_size, strerror(errno) );
|
||||
close( sd );
|
||||
sd = -1;
|
||||
return( false );
|
||||
|
@ -206,7 +206,7 @@ bool Event::OpenFrameSocket( int monitor_id )
|
|||
int flags;
|
||||
if ( (flags = fcntl( sd, F_GETFL )) < 0 )
|
||||
{
|
||||
Error(( "Can't get socket flags, error = %s", strerror(errno) ));
|
||||
Error( "Can't get socket flags, error = %s", strerror(errno) );
|
||||
close( sd );
|
||||
sd = -1;
|
||||
return( false );
|
||||
|
@ -214,7 +214,7 @@ bool Event::OpenFrameSocket( int monitor_id )
|
|||
flags |= O_NONBLOCK;
|
||||
if ( fcntl( sd, F_SETFL, flags ) < 0 )
|
||||
{
|
||||
Error(( "Can't set socket flags, error = %s", strerror(errno) ));
|
||||
Error( "Can't set socket flags, error = %s", strerror(errno) );
|
||||
close( sd );
|
||||
sd = -1;
|
||||
return( false );
|
||||
|
@ -230,13 +230,13 @@ bool Event::OpenFrameSocket( int monitor_id )
|
|||
|
||||
if ( connect( sd, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0 )
|
||||
{
|
||||
Warning(( "Can't connect to frame server: %s", strerror(errno) ));
|
||||
Warning( "Can't connect to frame server: %s", strerror(errno) );
|
||||
close( sd );
|
||||
sd = -1;
|
||||
return( false );
|
||||
}
|
||||
|
||||
Debug( 1, ( "Opened connection to frame server" ));
|
||||
Debug( 1, "Opened connection to frame server" );
|
||||
return( true );
|
||||
}
|
||||
|
||||
|
@ -284,24 +284,24 @@ bool Event::SendFrameImage( const Image *image, bool alarm_frame )
|
|||
{
|
||||
if ( errno == EAGAIN )
|
||||
{
|
||||
Warning(( "Blocking write detected" ));
|
||||
Warning( "Blocking write detected" );
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(( "Can't write frame: %s", strerror(errno) ));
|
||||
Error( "Can't write frame: %s", strerror(errno) );
|
||||
close( sd );
|
||||
sd = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(( "Incomplete frame write: %d of %d bytes written", writev_result, writev_size ));
|
||||
Error( "Incomplete frame write: %d of %d bytes written", writev_result, writev_size );
|
||||
close( sd );
|
||||
sd = -1;
|
||||
}
|
||||
return( false );
|
||||
}
|
||||
Debug( 1, ( "Wrote frame image, %d bytes", jpg_buffer_size ));
|
||||
Debug( 1, "Wrote frame image, %d bytes", jpg_buffer_size );
|
||||
|
||||
return( true );
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps
|
|||
static char event_file[PATH_MAX];
|
||||
snprintf( event_file, sizeof(event_file), capture_file_format, path, frames );
|
||||
|
||||
Debug( 1, ( "Writing pre-capture frame %d", frames ));
|
||||
Debug( 1, "Writing pre-capture frame %d", frames );
|
||||
WriteFrameImage( images[i], *(timestamps[i]), event_file );
|
||||
|
||||
struct DeltaTimeval delta_time;
|
||||
|
@ -354,11 +354,11 @@ void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps
|
|||
snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
|
||||
}
|
||||
|
||||
Debug( 1, ( "Adding %d frames to DB", n_frames ));
|
||||
Debug( 1, "Adding %d frames to DB", n_frames );
|
||||
*(sql+strlen(sql)-2) = '\0';
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't insert frames: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't insert frames: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
|||
static char event_file[PATH_MAX];
|
||||
snprintf( event_file, sizeof(event_file), capture_file_format, path, frames );
|
||||
|
||||
Debug( 1, ( "Writing capture frame %d", frames ));
|
||||
Debug( 1, "Writing capture frame %d", frames );
|
||||
WriteFrameImage( image, timestamp, event_file );
|
||||
|
||||
struct DeltaTimeval delta_time;
|
||||
|
@ -384,12 +384,12 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
|||
{
|
||||
const char *frame_type = score>0?"Alarm":(score<0?"Bulk":"Normal");
|
||||
|
||||
Debug( 1, ( "Adding frame %d to DB", frames ));
|
||||
Debug( 1, "Adding frame %d to DB", frames );
|
||||
static char sql[BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type, timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't insert frame: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't insert frame: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
last_db_frame = frames;
|
||||
|
@ -400,7 +400,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
|||
snprintf( sql, sizeof(sql), "update Events set Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't update event: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't update event: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
|||
{
|
||||
snprintf( event_file, sizeof(event_file), analyse_file_format, path, frames );
|
||||
|
||||
Debug( 1, ( "Writing analysis frame %d", frames ));
|
||||
Debug( 1, "Writing analysis frame %d", frames );
|
||||
WriteFrameImage( alarm_image, timestamp, event_file, true );
|
||||
}
|
||||
}
|
||||
|
@ -436,11 +436,11 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
|||
{
|
||||
if ( glob_status < 0 )
|
||||
{
|
||||
Error(( "Can't glob '%s': %s", diag_glob, strerror(errno) ));
|
||||
Error( "Can't glob '%s': %s", diag_glob, strerror(errno) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug( 1, ( "Can't glob '%s': %d", diag_glob, glob_status ));
|
||||
Debug( 1, "Can't glob '%s': %d", diag_glob, glob_status );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -458,7 +458,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
|||
|
||||
if ( rename( diag_path, new_diag_path ) < 0 )
|
||||
{
|
||||
Error(( "Can't rename '%s' to '%s': %s", diag_path, new_diag_path, strerror(errno) ));
|
||||
Error( "Can't rename '%s' to '%s': %s", diag_path, new_diag_path, strerror(errno) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -475,21 +475,21 @@ bool EventStream::loadInitialEventData( int monitor_id, time_t event_time )
|
|||
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
MYSQL_ROW dbrow = mysql_fetch_row( result );
|
||||
|
||||
if ( mysql_errno( &dbconn ) )
|
||||
{
|
||||
Error(( "Can't fetch row: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't fetch row: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
|
@ -507,16 +507,16 @@ bool EventStream::loadInitialEventData( int monitor_id, time_t event_time )
|
|||
{
|
||||
for ( int i = 0; i < event_data->frame_count; i++ )
|
||||
{
|
||||
//Info(( "eft %d > et %d", event_data->frames[i].timestamp, event_time ));
|
||||
//Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time );
|
||||
if ( event_data->frames[i].timestamp >= event_time )
|
||||
{
|
||||
curr_frame_id = i+1;
|
||||
Debug( 3, ( "Set cst:%.2f", curr_stream_time ));
|
||||
Debug( 3, ( "Set cfid:%d", curr_frame_id ));
|
||||
Debug( 3, "Set cst:%.2f", curr_stream_time );
|
||||
Debug( 3, "Set cfid:%d", curr_frame_id );
|
||||
break;
|
||||
}
|
||||
}
|
||||
Debug( 3, ( "Skipping %ld frames", event_data->frame_count ));
|
||||
Debug( 3, "Skipping %ld frames", event_data->frame_count );
|
||||
}
|
||||
}
|
||||
return( true );
|
||||
|
@ -547,27 +547,27 @@ bool EventStream::loadEventData( int event_id )
|
|||
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
if ( !mysql_num_rows( result ) )
|
||||
{
|
||||
Fatal(( "Unable to load event %d, not found in DB", event_id ));
|
||||
Fatal( "Unable to load event %d, not found in DB", event_id );
|
||||
}
|
||||
|
||||
MYSQL_ROW dbrow = mysql_fetch_row( result );
|
||||
|
||||
if ( mysql_errno( &dbconn ) )
|
||||
{
|
||||
Error(( "Can't fetch row: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't fetch row: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
|
@ -595,14 +595,14 @@ bool EventStream::loadEventData( int event_id )
|
|||
snprintf( sql, sizeof(sql), "select FrameId, unix_timestamp( `TimeStamp` ), Delta from Frames where EventId = %d order by FrameId asc", event_id );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
|
@ -639,13 +639,13 @@ bool EventStream::loadEventData( int event_id )
|
|||
}
|
||||
if ( mysql_errno( &dbconn ) )
|
||||
{
|
||||
Error(( "Can't fetch row: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't fetch row: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
//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 ));
|
||||
//Info( "%d -> %d @ %f (%d)", i+1, event_data->frames[i].timestamp, event_data->frames[i].delta, event_data->frames[i].in_db );
|
||||
//}
|
||||
|
||||
mysql_free_result( result );
|
||||
|
@ -657,20 +657,20 @@ bool EventStream::loadEventData( int event_id )
|
|||
else
|
||||
curr_stream_time = event_data->frames[event_data->frame_count-1].timestamp;
|
||||
}
|
||||
Debug( 2, ( "Event:%ld, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration ));
|
||||
Debug( 2, "Event:%ld, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration );
|
||||
|
||||
return( true );
|
||||
}
|
||||
|
||||
void EventStream::processCommand( const CmdMsg *msg )
|
||||
{
|
||||
Debug( 2, ( "Got message, type %ld, msg %d", msg->msg_type, msg->msg_data[0] ))
|
||||
Debug( 2, "Got message, type %ld, msg %d", msg->msg_type, msg->msg_data[0] )
|
||||
// Check for incoming command
|
||||
switch( (MsgCommand)msg->msg_data[0] )
|
||||
{
|
||||
case CMD_PAUSE :
|
||||
{
|
||||
Debug( 1, ( "Got PAUSE command" ));
|
||||
Debug( 1, "Got PAUSE command" );
|
||||
|
||||
// Set paused flag
|
||||
paused = true;
|
||||
|
@ -680,7 +680,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
}
|
||||
case CMD_PLAY :
|
||||
{
|
||||
Debug( 1, ( "Got PLAY command" ));
|
||||
Debug( 1, "Got PLAY command" );
|
||||
if ( paused )
|
||||
{
|
||||
// Clear paused flag
|
||||
|
@ -691,7 +691,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
}
|
||||
case CMD_STOP :
|
||||
{
|
||||
Debug( 1, ( "Got STOP command" ));
|
||||
Debug( 1, "Got STOP command" );
|
||||
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
|
@ -699,7 +699,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
}
|
||||
case CMD_FASTFWD :
|
||||
{
|
||||
Debug( 1, ( "Got FAST FWD command" ));
|
||||
Debug( 1, "Got FAST FWD command" );
|
||||
if ( paused )
|
||||
{
|
||||
// Clear paused flag
|
||||
|
@ -729,7 +729,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
}
|
||||
case CMD_SLOWFWD :
|
||||
{
|
||||
Debug( 1, ( "Got SLOW FWD command" ));
|
||||
Debug( 1, "Got SLOW FWD command" );
|
||||
// Set paused flag
|
||||
paused = true;
|
||||
// Set play rate
|
||||
|
@ -740,7 +740,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
}
|
||||
case CMD_SLOWREV :
|
||||
{
|
||||
Debug( 1, ( "Got SLOW REV command" ));
|
||||
Debug( 1, "Got SLOW REV command" );
|
||||
// Set paused flag
|
||||
paused = true;
|
||||
// Set play rate
|
||||
|
@ -751,7 +751,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
}
|
||||
case CMD_FASTREV :
|
||||
{
|
||||
Debug( 1, ( "Got FAST REV command" ));
|
||||
Debug( 1, "Got FAST REV command" );
|
||||
if ( paused )
|
||||
{
|
||||
// Clear paused flag
|
||||
|
@ -783,7 +783,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
{
|
||||
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||
Debug( 1, ( "Got ZOOM IN command, to %d,%d", x, y ));
|
||||
Debug( 1, "Got ZOOM IN command, to %d,%d", x, y );
|
||||
switch ( zoom )
|
||||
{
|
||||
case 100:
|
||||
|
@ -807,7 +807,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
}
|
||||
case CMD_ZOOMOUT :
|
||||
{
|
||||
Debug( 1, ( "Got ZOOM OUT command" ));
|
||||
Debug( 1, "Got ZOOM OUT command" );
|
||||
switch ( zoom )
|
||||
{
|
||||
case 500:
|
||||
|
@ -833,18 +833,18 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
{
|
||||
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||
Debug( 1, ( "Got PAN command, to %d,%d", x, y ));
|
||||
Debug( 1, "Got PAN command, to %d,%d", x, y );
|
||||
break;
|
||||
}
|
||||
case CMD_SCALE :
|
||||
{
|
||||
scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
Debug( 1, ( "Got SCALE command, to %d", scale ));
|
||||
Debug( 1, "Got SCALE command, to %d", scale );
|
||||
break;
|
||||
}
|
||||
case CMD_PREV :
|
||||
{
|
||||
Debug( 1, ( "Got PREV command" ));
|
||||
Debug( 1, "Got PREV command" );
|
||||
if ( replay_rate >= 0 )
|
||||
curr_frame_id = 0;
|
||||
else
|
||||
|
@ -855,7 +855,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
}
|
||||
case CMD_NEXT :
|
||||
{
|
||||
Debug( 1, ( "Got NEXT command" ));
|
||||
Debug( 1, "Got NEXT command" );
|
||||
if ( replay_rate >= 0 )
|
||||
curr_frame_id = event_data->frame_count-1;
|
||||
else
|
||||
|
@ -868,12 +868,12 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
{
|
||||
int offset = ((unsigned char)msg->msg_data[1]<<24)|((unsigned char)msg->msg_data[2]<<16)|((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||
curr_frame_id = (int)(event_data->frame_count*offset/event_data->duration);
|
||||
Debug( 1, ( "Got SEEK command, to %d (new cfid: %d)", offset, curr_frame_id ));
|
||||
Debug( 1, "Got SEEK command, to %d (new cfid: %d)", offset, curr_frame_id );
|
||||
break;
|
||||
}
|
||||
case CMD_QUERY :
|
||||
{
|
||||
Debug( 1, ( "Got QUERY command, sending STATUS" ));
|
||||
Debug( 1, "Got QUERY command, sending STATUS" );
|
||||
break;
|
||||
}
|
||||
default :
|
||||
|
@ -894,13 +894,13 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
status_data.progress = event_data->frames[curr_frame_id-1].offset;
|
||||
status_data.rate = replay_rate;
|
||||
status_data.zoom = zoom;
|
||||
Debug( 2, ( "E:%d, P:%d, p:%ld R:%d, Z:%d",
|
||||
Debug( 2, "E:%d, P:%d, p:%ld R:%d, Z:%d",
|
||||
status_data.event,
|
||||
status_data.paused,
|
||||
status_data.progress,
|
||||
status_data.rate,
|
||||
status_data.zoom
|
||||
));
|
||||
);
|
||||
|
||||
DataMsg status_msg;
|
||||
status_msg.msg_type = MSG_DATA_EVENT;
|
||||
|
@ -909,7 +909,7 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
{
|
||||
//if ( errno != EAGAIN )
|
||||
{
|
||||
Error(( "Can't sendto on sd %d: %s", sd, strerror(errno) ));
|
||||
Error( "Can't sendto on sd %d: %s", sd, strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
}
|
||||
|
@ -977,40 +977,40 @@ mysql_free_result( $result );
|
|||
{
|
||||
if ( forceEventChange || mode != MODE_SINGLE )
|
||||
{
|
||||
//Info(( "SQL:%s", sql ));
|
||||
//Info( "SQL:%s", sql );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
MYSQL_ROW dbrow = mysql_fetch_row( result );
|
||||
|
||||
if ( mysql_errno( &dbconn ) )
|
||||
{
|
||||
Error(( "Can't fetch row: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't fetch row: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
if ( dbrow )
|
||||
{
|
||||
int event_id = atoi(dbrow[0]);
|
||||
Debug( 1, ( "Loading new event %d", event_id ));
|
||||
Debug( 1, "Loading new event %d", event_id );
|
||||
|
||||
loadEventData( event_id );
|
||||
|
||||
Debug( 2, ( "Current frame id = %d", curr_frame_id ));
|
||||
Debug( 2, "Current frame id = %d", curr_frame_id );
|
||||
if ( curr_frame_id <= 0 )
|
||||
curr_frame_id = event_data->frame_count;
|
||||
else
|
||||
curr_frame_id = 1;
|
||||
Debug( 2, ( "New frame id = %d", curr_frame_id ));
|
||||
Debug( 2, "New frame id = %d", curr_frame_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1036,7 +1036,7 @@ mysql_free_result( $result );
|
|||
|
||||
void EventStream::sendFrame( int delta_us )
|
||||
{
|
||||
Debug( 2, ( "Sending frame %d", curr_frame_id ));
|
||||
Debug( 2, "Sending frame %d", curr_frame_id );
|
||||
|
||||
static char filepath[PATH_MAX];
|
||||
snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id );
|
||||
|
@ -1081,7 +1081,7 @@ void EventStream::sendFrame( int delta_us )
|
|||
}
|
||||
else
|
||||
{
|
||||
Error(( "Can't open %s: %s", filepath, strerror(errno) ));
|
||||
Error( "Can't open %s: %s", filepath, strerror(errno) );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1105,7 +1105,7 @@ void EventStream::sendFrame( int delta_us )
|
|||
img_buffer_size = zip_buffer_size;
|
||||
break;
|
||||
default:
|
||||
Fatal(( "Unexpected frame type %d", type ));
|
||||
Fatal( "Unexpected frame type %d", type );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1122,7 +1122,7 @@ void EventStream::sendFrame( int delta_us )
|
|||
fprintf( stdout, "Content-Type: image/x-rgbz\r\n" );
|
||||
break;
|
||||
default :
|
||||
Fatal(( "Unexpected frame type %d", type ));
|
||||
Fatal( "Unexpected frame type %d", type );
|
||||
break;
|
||||
}
|
||||
fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size );
|
||||
|
@ -1167,9 +1167,9 @@ void EventStream::runStream()
|
|||
// Get current frame data
|
||||
FrameData *frame_data = &event_data->frames[curr_frame_id-1];
|
||||
|
||||
//Info(( "cst:%.2f", curr_stream_time ));
|
||||
//Info(( "cfid:%d", curr_frame_id ));
|
||||
//Info(( "fdt:%d", frame_data->timestamp ));
|
||||
//Info( "cst:%.2f", curr_stream_time );
|
||||
//Info( "cfid:%d", curr_frame_id );
|
||||
//Info( "fdt:%d", frame_data->timestamp );
|
||||
if ( !paused )
|
||||
{
|
||||
bool in_event = true;
|
||||
|
@ -1231,7 +1231,7 @@ void EventStream::runStream()
|
|||
if ( actual_delta_time > MAX_STREAM_DELAY )
|
||||
{
|
||||
// Send keepalive
|
||||
Debug( 2, ( "Sending keepalive frame" ));
|
||||
Debug( 2, "Sending keepalive frame" );
|
||||
send_frame = true;
|
||||
}
|
||||
}
|
||||
|
@ -1248,7 +1248,7 @@ void EventStream::runStream()
|
|||
curr_frame_id += replay_rate>0?1:-1;
|
||||
if ( send_frame && type != STREAM_MPEG )
|
||||
{
|
||||
Debug( 3, ( "dUs: %d", delta_us ));
|
||||
Debug( 3, "dUs: %d", delta_us );
|
||||
usleep( delta_us );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "zm.h"
|
||||
#include "zm_file_camera.h"
|
||||
|
||||
FileCamera::FileCamera( const char *p_path, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( FILE, p_width, p_height, p_palette, p_brightness, p_contrast, p_hue, p_colour, p_capture )
|
||||
FileCamera::FileCamera( const char *p_path, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( FILE_SRC, p_width, p_height, p_palette, p_brightness, p_contrast, p_hue, p_colour, p_capture )
|
||||
{
|
||||
strncpy( path, p_path, sizeof(path) );
|
||||
if ( capture )
|
||||
|
@ -55,7 +55,7 @@ void FileCamera::Initialise()
|
|||
{
|
||||
if ( !path[0] )
|
||||
{
|
||||
Error(( "No path specified for file image" ));
|
||||
Error( "No path specified for file image" );
|
||||
exit( -1 );
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ int FileCamera::PreCapture()
|
|||
struct stat statbuf;
|
||||
if ( stat( path, &statbuf ) < 0 )
|
||||
{
|
||||
Error(( "Can't stat %s: %s", path, strerror(errno) ));
|
||||
Error( "Can't stat %s: %s", path, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ void Image::Initialise()
|
|||
y_r_table[i] = (2990*abs(i))/10000;
|
||||
y_g_table[i] = (5670*abs(i))/10000;
|
||||
y_b_table[i] = (1140*abs(i))/10000;
|
||||
//Info(( "I:%d, R:%d, G:%d, B:%d", i, y_r_table[i], y_g_table[i], y_b_table[i] ));
|
||||
//Info( "I:%d, R:%d, G:%d, B:%d", i, y_r_table[i], y_g_table[i], y_b_table[i] );
|
||||
}
|
||||
for ( int i = 0; i <= 100; i++ )
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ Image::BlendTablePtr Image::GetBlendTable( int transparency )
|
|||
if ( !blend_ptr )
|
||||
{
|
||||
blend_ptr = blend_tables[transparency] = new BlendTable[1];
|
||||
//Info(( "Generating blend table for transparency %d", transparency ));
|
||||
//Info( "Generating blend table for transparency %d", transparency );
|
||||
int opacity = 100-transparency;
|
||||
//int round_up = 50/transparency;
|
||||
for ( int i = 0; i < 256; i++ )
|
||||
|
@ -220,7 +220,7 @@ Image *Image::HighlightEdges( Rgb colour, const Box *limits )
|
|||
{
|
||||
if ( colours != 1 )
|
||||
{
|
||||
Fatal(( "Attempt to highlight image edges when colours = %d", colours ));
|
||||
Fatal( "Attempt to highlight image edges when colours = %d", colours );
|
||||
}
|
||||
Image *high_image = new Image( width, height, 3 );
|
||||
int lo_x = limits?limits->Lo().X():0;
|
||||
|
@ -257,20 +257,20 @@ bool Image::ReadRaw( const char *filename )
|
|||
FILE *infile;
|
||||
if ( (infile = fopen( filename, "rb" )) == NULL )
|
||||
{
|
||||
Error(( "Can't open %s: %s", filename, strerror(errno) ));
|
||||
Error( "Can't open %s: %s", filename, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
struct stat statbuf;
|
||||
if ( fstat( fileno(infile), &statbuf ) < 0 )
|
||||
{
|
||||
Error(( "Can't fstat %s: %s", filename, strerror(errno) ));
|
||||
Error( "Can't fstat %s: %s", filename, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
if ( statbuf.st_size != size )
|
||||
{
|
||||
Error(( "Raw file size mismatch, expected %d bytes, found %ld", size, statbuf.st_size ));
|
||||
Error( "Raw file size mismatch, expected %d bytes, found %ld", size, statbuf.st_size );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ bool Image::WriteRaw( const char *filename ) const
|
|||
FILE *outfile;
|
||||
if ( (outfile = fopen( filename, "wb" )) == NULL )
|
||||
{
|
||||
Error(( "Can't open %s: %s", filename, strerror(errno) ));
|
||||
Error( "Can't open %s: %s", filename, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ bool Image::ReadJpeg( const char *filename )
|
|||
FILE *infile;
|
||||
if ( (infile = fopen( filename, "rb" )) == NULL )
|
||||
{
|
||||
Error(( "Can't open %s: %s", filename, strerror(errno) ));
|
||||
Error( "Can't open %s: %s", filename, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ bool Image::ReadJpeg( const char *filename )
|
|||
colours = cinfo->num_components;
|
||||
if ( !(colours == 1 || colours == 3) )
|
||||
{
|
||||
Error(( "Unexpected colours (%d) when reading jpeg image", colours ));
|
||||
Error( "Unexpected colours (%d) when reading jpeg image", colours );
|
||||
jpeg_abort_decompress( cinfo );
|
||||
fclose( infile );
|
||||
return( false );
|
||||
|
@ -392,7 +392,7 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const
|
|||
FILE *outfile;
|
||||
if ( (outfile = fopen( filename, "wb" )) == NULL )
|
||||
{
|
||||
Error(( "Can't open %s: %s", filename, strerror(errno) ));
|
||||
Error( "Can't open %s: %s", filename, strerror(errno) );
|
||||
return( false );
|
||||
}
|
||||
jpeg_stdio_dest( cinfo, outfile );
|
||||
|
@ -464,7 +464,7 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size )
|
|||
colours = cinfo->num_components;
|
||||
if ( !(colours == 1 || colours == 3) )
|
||||
{
|
||||
Error(( "Unexpected colours (%d) when decoding jpeg image", colours ));
|
||||
Error( "Unexpected colours (%d) when decoding jpeg image", colours );
|
||||
jpeg_abort_decompress( cinfo );
|
||||
return( false );
|
||||
}
|
||||
|
@ -552,12 +552,12 @@ bool Image::Unzip( const Bytef *inbuffer, unsigned long inbuffer_size )
|
|||
int result = uncompress( buffer, &zip_size, inbuffer, inbuffer_size );
|
||||
if ( result != Z_OK )
|
||||
{
|
||||
Error(( "Unzip failed, result = %d", result ));
|
||||
Error( "Unzip failed, result = %d", result );
|
||||
return( false );
|
||||
}
|
||||
if ( zip_size != size )
|
||||
{
|
||||
Error(( "Unzip failed, size mismatch, expected %d bytes, got %ld", size, zip_size ));
|
||||
Error( "Unzip failed, size mismatch, expected %d bytes, got %ld", size, zip_size );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -568,7 +568,7 @@ bool Image::Zip( Bytef *outbuffer, unsigned long *outbuffer_size, int compressio
|
|||
int result = compress2( outbuffer, outbuffer_size, buffer, size, compression_level );
|
||||
if ( result != Z_OK )
|
||||
{
|
||||
Error(( "Zip failed, result = %d", result ));
|
||||
Error( "Zip failed, result = %d", result );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -581,12 +581,12 @@ bool Image::Crop( int lo_x, int lo_y, int hi_x, int hi_y )
|
|||
|
||||
if ( lo_x > hi_x || lo_y > hi_y )
|
||||
{
|
||||
Error(( "Invalid or reversed crop region %d,%d -> %d,%d", lo_x, lo_y, hi_x, hi_y ));
|
||||
Error( "Invalid or reversed crop region %d,%d -> %d,%d", lo_x, lo_y, hi_x, hi_y );
|
||||
return( false );
|
||||
}
|
||||
if ( lo_x < 0 || hi_x > (width-1) || ( lo_y < 0 || hi_y > (height-1) ) )
|
||||
{
|
||||
Error(( "Attempting to crop outside image, %d,%d -> %d,%d not in %d,%d", lo_x, lo_y, hi_x, hi_y, width-1, height-1 ));
|
||||
Error( "Attempting to crop outside image, %d,%d -> %d,%d not in %d,%d", lo_x, lo_y, hi_x, hi_y, width-1, height-1 );
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -633,7 +633,7 @@ void Image::Overlay( const Image &image )
|
|||
{
|
||||
if ( !(width == image.width && height == image.height) )
|
||||
{
|
||||
Fatal(( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height ));
|
||||
Fatal( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height );
|
||||
}
|
||||
|
||||
unsigned char *pdest = buffer;
|
||||
|
@ -704,17 +704,17 @@ void Image::Overlay( const Image &image, int x, int y )
|
|||
{
|
||||
if ( !(width < image.width || height < image.height) )
|
||||
{
|
||||
Fatal(( "Attempt to overlay image too big for destination, %dx%d > %dx%d", image.width, image.height, width, height ));
|
||||
Fatal( "Attempt to overlay image too big for destination, %dx%d > %dx%d", image.width, image.height, width, height );
|
||||
}
|
||||
|
||||
if ( !(width < (x+image.width) || height < (y+image.height)) )
|
||||
{
|
||||
Fatal(( "Attempt to overlay image outside of destination bounds, %dx%d @ %dx%d > %dx%d", image.width, image.height, x, y, width, height ));
|
||||
Fatal( "Attempt to overlay image outside of destination bounds, %dx%d @ %dx%d > %dx%d", image.width, image.height, x, y, width, height );
|
||||
}
|
||||
|
||||
if ( !(colours == image.colours) )
|
||||
{
|
||||
Fatal(( "Attempt to partial overlay differently coloured images, expected %d, got %d", colours, image.colours ));
|
||||
Fatal( "Attempt to partial overlay differently coloured images, expected %d, got %d", colours, image.colours );
|
||||
}
|
||||
|
||||
int lo_x = x;
|
||||
|
@ -753,7 +753,7 @@ void Image::Blend( const Image &image, int transparency ) const
|
|||
{
|
||||
if ( !(width == image.width && height == image.height && colours == image.colours) )
|
||||
{
|
||||
Fatal(( "Attempt to blend different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours ));
|
||||
Fatal( "Attempt to blend different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours );
|
||||
}
|
||||
|
||||
if ( config.fast_image_blends )
|
||||
|
@ -808,7 +808,7 @@ Image *Image::Merge( int n_images, Image *images[] )
|
|||
{
|
||||
if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) )
|
||||
{
|
||||
Fatal(( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ));
|
||||
Fatal( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -842,7 +842,7 @@ Image *Image::Merge( int n_images, Image *images[], double weight )
|
|||
{
|
||||
if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) )
|
||||
{
|
||||
Fatal(( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ));
|
||||
Fatal( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -876,7 +876,7 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con
|
|||
{
|
||||
if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) )
|
||||
{
|
||||
Fatal(( "Attempt to highlight different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ));
|
||||
Fatal( "Attempt to highlight different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -909,7 +909,7 @@ Image *Image::Delta( const Image &image ) const
|
|||
{
|
||||
if ( !(width == image.width && height == image.height && colours == image.colours) )
|
||||
{
|
||||
Fatal(( "Attempt to get delta of different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours ));
|
||||
Fatal( "Attempt to get delta of different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours );
|
||||
}
|
||||
|
||||
Image *result = new Image( width, height, 1 );
|
||||
|
@ -936,14 +936,14 @@ Image *Image::Delta( const Image &image ) const
|
|||
{
|
||||
if ( config.y_image_deltas )
|
||||
{
|
||||
//Info(( "RS:%d, RR: %d", *psrc, *pref ));
|
||||
//Info( "RS:%d, RR: %d", *psrc, *pref );
|
||||
red = y_r_table[*psrc++ - *pref++];
|
||||
//Info(( "GS:%d, GR: %d", *psrc, *pref ));
|
||||
//Info( "GS:%d, GR: %d", *psrc, *pref );
|
||||
green = y_g_table[*psrc++ - *pref++];
|
||||
//Info(( "BS:%d, BR: %d", *psrc, *pref ));
|
||||
//Info( "BS:%d, BR: %d", *psrc, *pref );
|
||||
blue = y_b_table[*psrc++ - *pref++];
|
||||
|
||||
//Info(( "R:%d, G:%d, B:%d, D:%d", red, green, blue, abs_table[red + green + blue] ));
|
||||
//Info( "R:%d, G:%d, B:%d, D:%d", red, green, blue, abs_table[red + green + blue] );
|
||||
*pdiff++ = abs_table[red + green + blue];
|
||||
}
|
||||
else
|
||||
|
@ -1165,7 +1165,7 @@ void Image::Fill( Rgb colour, const Box *limits )
|
|||
{
|
||||
if ( !(colours == 1 || colours == 3 ) )
|
||||
{
|
||||
Fatal(( "Attempt to fill image with unexpected colours %d", colours ));
|
||||
Fatal( "Attempt to fill image with unexpected colours %d", colours );
|
||||
}
|
||||
int lo_x = limits?limits->Lo().X():0;
|
||||
int lo_y = limits?limits->Lo().Y():0;
|
||||
|
@ -1202,7 +1202,7 @@ void Image::Fill( Rgb colour, int density, const Box *limits )
|
|||
{
|
||||
if ( !(colours == 1 || colours == 3 ) )
|
||||
{
|
||||
Fatal(( "Attempt to fill image with unexpected colours %d", colours ));
|
||||
Fatal( "Attempt to fill image with unexpected colours %d", colours );
|
||||
}
|
||||
|
||||
int lo_x = limits?limits->Lo().X():0;
|
||||
|
@ -1235,7 +1235,7 @@ void Image::Outline( Rgb colour, const Polygon &polygon )
|
|||
{
|
||||
if ( !(colours == 1 || colours == 3 ) )
|
||||
{
|
||||
Fatal(( "Attempt to outline image with unexpected colours %d", colours ));
|
||||
Fatal( "Attempt to outline image with unexpected colours %d", colours );
|
||||
}
|
||||
int n_coords = polygon.getNumCoords();
|
||||
for ( int j = 0, i = n_coords-1; j < n_coords; i = j++ )
|
||||
|
@ -1253,10 +1253,10 @@ void Image::Outline( Rgb colour, const Polygon &polygon )
|
|||
|
||||
double grad;
|
||||
|
||||
Debug( 9, ( "dx: %.2lf, dy: %.2lf", dx, dy ));
|
||||
Debug( 9, "dx: %.2lf, dy: %.2lf", dx, dy );
|
||||
if ( fabs(dx) <= fabs(dy) )
|
||||
{
|
||||
Debug( 9, ( "dx <= dy" ));
|
||||
Debug( 9, "dx <= dy" );
|
||||
if ( y1 != y2 )
|
||||
grad = dx/dy;
|
||||
else
|
||||
|
@ -1267,10 +1267,10 @@ void Image::Outline( Rgb colour, const Polygon &polygon )
|
|||
grad *= yinc;
|
||||
if ( colours == 1 )
|
||||
{
|
||||
Debug( 9, ( "x1:%d, x2:%d, y1:%d, y2:%d, gr:%.2f", x1, x2, y1, y2, grad ));
|
||||
Debug( 9, "x1:%d, x2:%d, y1:%d, y2:%d, gr:%.2f", x1, x2, y1, y2, grad );
|
||||
for ( x = x1, y = y1; y != y2; y += yinc, x += grad )
|
||||
{
|
||||
Debug( 9, ( "x:%.2f, y:%d", x, y ));
|
||||
Debug( 9, "x:%.2f, y:%d", x, y );
|
||||
buffer[(y*width)+int(round(x))] = colour;
|
||||
}
|
||||
}
|
||||
|
@ -1287,22 +1287,22 @@ void Image::Outline( Rgb colour, const Polygon &polygon )
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug( 9, ( "dx > dy" ));
|
||||
Debug( 9, "dx > dy" );
|
||||
if ( x1 != x2 )
|
||||
grad = dy/dx;
|
||||
else
|
||||
grad = height;
|
||||
Debug( 9, ( "grad: %.2lf", grad ));
|
||||
Debug( 9, "grad: %.2lf", grad );
|
||||
|
||||
double y;
|
||||
int x, xinc = (x1<x2)?1:-1;
|
||||
grad *= xinc;
|
||||
if ( colours == 1 )
|
||||
{
|
||||
Debug( 9, ( "x1:%d, x2:%d, y1:%d, y2:%d, gr:%.2lf", x1, x2, y1, y2, grad ));
|
||||
Debug( 9, "x1:%d, x2:%d, y1:%d, y2:%d, gr:%.2lf", x1, x2, y1, y2, grad );
|
||||
for ( y = y1, x = x1; x != x2; x += xinc, y += grad )
|
||||
{
|
||||
Debug( 9, ( "x:%d, y:%.2f", x, y ));
|
||||
Debug( 9, "x:%d, y:%.2f", x, y );
|
||||
buffer[(int(round(y))*width)+x] = colour;
|
||||
}
|
||||
}
|
||||
|
@ -1324,7 +1324,7 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon )
|
|||
{
|
||||
if ( !(colours == 1 || colours == 3 ) )
|
||||
{
|
||||
Fatal(( "Attempt to fill image with unexpected colours %d", colours ));
|
||||
Fatal( "Attempt to fill image with unexpected colours %d", colours );
|
||||
}
|
||||
|
||||
int n_coords = polygon.getNumCoords();
|
||||
|
@ -1340,7 +1340,7 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon )
|
|||
int y1 = p1.Y();
|
||||
int y2 = p2.Y();
|
||||
|
||||
Debug( 9, ( "x1:%d,y1:%d x2:%d,y2:%d", x1, y1, x2, y2 ));
|
||||
Debug( 9, "x1:%d,y1:%d x2:%d,y2:%d", x1, y1, x2, y2 );
|
||||
if ( y1 == y2 )
|
||||
continue;
|
||||
|
||||
|
@ -1360,7 +1360,7 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon )
|
|||
{
|
||||
for ( int i = 0; i < n_global_edges; i++ )
|
||||
{
|
||||
Debug( 9, ( "%d: min_y: %d, max_y:%d, min_x:%.2f, 1/m:%.2f", i, global_edges[i].min_y, global_edges[i].max_y, global_edges[i].min_x, global_edges[i]._1_m ));
|
||||
Debug( 9, "%d: min_y: %d, max_y:%d, min_x:%.2f, 1/m:%.2f", i, global_edges[i].min_y, global_edges[i].max_y, global_edges[i].min_x, global_edges[i]._1_m );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1374,7 +1374,7 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon )
|
|||
{
|
||||
if ( global_edges[i].min_y == y )
|
||||
{
|
||||
Debug( 9, ( "Moving global edge" ));
|
||||
Debug( 9, "Moving global edge" );
|
||||
active_edges[n_active_edges++] = global_edges[i];
|
||||
if ( i < (n_global_edges-1) )
|
||||
{
|
||||
|
@ -1394,13 +1394,13 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon )
|
|||
{
|
||||
for ( int i = 0; i < n_active_edges; i++ )
|
||||
{
|
||||
Debug( 9, ( "%d - %d: min_y: %d, max_y:%d, min_x:%.2f, 1/m:%.2f", y, i, active_edges[i].min_y, active_edges[i].max_y, active_edges[i].min_x, active_edges[i]._1_m ));
|
||||
Debug( 9, "%d - %d: min_y: %d, max_y:%d, min_x:%.2f, 1/m:%.2f", y, i, active_edges[i].min_y, active_edges[i].max_y, active_edges[i].min_x, active_edges[i]._1_m );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if ( !(y%density) )
|
||||
{
|
||||
//Debug( 9, ( "%d", y ));
|
||||
//Debug( 9, "%d", y );
|
||||
for ( int i = 0; i < n_active_edges; )
|
||||
{
|
||||
int lo_x = int(round(active_edges[i++].min_x));
|
||||
|
@ -1410,7 +1410,7 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon )
|
|||
{
|
||||
if ( !(x%density) )
|
||||
{
|
||||
//Debug( 9, ( " %d", x ));
|
||||
//Debug( 9, " %d", x );
|
||||
if ( colours == 1 )
|
||||
{
|
||||
*p = colour;
|
||||
|
@ -1430,7 +1430,7 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon )
|
|||
{
|
||||
if ( y >= active_edges[i].max_y ) // Or >= as per sheets
|
||||
{
|
||||
Debug( 9, ( "Deleting active_edge" ));
|
||||
Debug( 9, "Deleting active_edge" );
|
||||
if ( i < (n_active_edges-1) )
|
||||
{
|
||||
memcpy( &active_edges[i], &active_edges[i+1], sizeof(*active_edges)*(n_active_edges-i) );
|
||||
|
@ -1632,7 +1632,7 @@ void Image::Scale( unsigned int factor )
|
|||
{
|
||||
if ( !factor )
|
||||
{
|
||||
Error(( "Bogus scale factor %d found", factor ));
|
||||
Error( "Bogus scale factor %d found", factor );
|
||||
return;
|
||||
}
|
||||
if ( factor == ZM_SCALE_BASE )
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
{
|
||||
if ( image.size != size )
|
||||
{
|
||||
Fatal(( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size ));
|
||||
Fatal( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size );
|
||||
}
|
||||
memcpy( buffer, image.buffer, size );
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ void zm_jpeg_error_exit( j_common_ptr cinfo )
|
|||
|
||||
(zmerr->pub.format_message)( cinfo, buffer );
|
||||
|
||||
Error(( "%s", buffer ));
|
||||
Error( "%s", buffer );
|
||||
if ( ++jpeg_err_count == MAX_JPEG_ERRS )
|
||||
{
|
||||
Fatal(( "Maximum number (%d) of JPEG errors reached, exiting", jpeg_err_count ));
|
||||
Fatal( "Maximum number (%d) of JPEG errors reached, exiting", jpeg_err_count );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ void zm_jpeg_emit_message( j_common_ptr cinfo, int msg_level )
|
|||
if ( zmerr->pub.num_warnings == 0 || zmerr->pub.trace_level >= 3 )
|
||||
{
|
||||
(zmerr->pub.format_message)( cinfo, buffer );
|
||||
Warning(( "%s", buffer ));
|
||||
Warning( "%s", buffer );
|
||||
}
|
||||
/* Always count warnings in num_warnings. */
|
||||
zmerr->pub.num_warnings++;
|
||||
|
|
|
@ -46,7 +46,7 @@ short *LocalCamera::g_v_table;
|
|||
short *LocalCamera::g_u_table;
|
||||
short *LocalCamera::b_u_table;
|
||||
|
||||
LocalCamera::LocalCamera( const char *p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( LOCAL, p_width, p_height, p_palette, p_brightness, p_contrast, p_hue, p_colour, p_capture ), channel( p_channel ), format( p_format )
|
||||
LocalCamera::LocalCamera( const char *p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( LOCAL_SRC, p_width, p_height, p_palette, p_brightness, p_contrast, p_hue, p_colour, p_capture ), channel( p_channel ), format( p_format )
|
||||
{
|
||||
strncpy( device, p_device, sizeof(device) );
|
||||
if ( !camera_count++ && capture )
|
||||
|
@ -77,7 +77,7 @@ void LocalCamera::Initialise()
|
|||
{
|
||||
if ( (m_videohandle=open(device, O_RDWR)) < 0 )
|
||||
{
|
||||
Error(( "Failed to open video device %s: %s", device, strerror(errno) ));
|
||||
Error( "Failed to open video device %s: %s", device, strerror(errno) );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -85,15 +85,15 @@ void LocalCamera::Initialise()
|
|||
memset( &vid_pic, 0, sizeof(vid_pic) );
|
||||
if ( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) < 0 )
|
||||
{
|
||||
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to get picture attributes: %s", strerror(errno) );
|
||||
exit(-1);
|
||||
}
|
||||
Debug( 1, ( "Old P:%d", vid_pic.palette ));
|
||||
Debug( 1, ( "Old D:%d", vid_pic.depth ));
|
||||
Debug( 1, ( "Old B:%d", vid_pic.brightness ));
|
||||
Debug( 1, ( "Old h:%d", vid_pic.hue ));
|
||||
Debug( 1, ( "Old Cl:%d", vid_pic.colour ));
|
||||
Debug( 1, ( "Old Cn:%d", vid_pic.contrast ));
|
||||
Debug( 1, "Old P:%d", vid_pic.palette );
|
||||
Debug( 1, "Old D:%d", vid_pic.depth );
|
||||
Debug( 1, "Old B:%d", vid_pic.brightness );
|
||||
Debug( 1, "Old h:%d", vid_pic.hue );
|
||||
Debug( 1, "Old Cl:%d", vid_pic.colour );
|
||||
Debug( 1, "Old Cn:%d", vid_pic.contrast );
|
||||
|
||||
switch (vid_pic.palette = palette)
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ void LocalCamera::Initialise()
|
|||
|
||||
if ( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) < 0 )
|
||||
{
|
||||
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to set picture attributes: %s", strerror(errno) );
|
||||
if ( config.strict_video_config )
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -134,13 +134,13 @@ void LocalCamera::Initialise()
|
|||
memset( &vid_win, 0, sizeof(vid_win) );
|
||||
if ( ioctl( m_videohandle, VIDIOCGWIN, &vid_win) < 0 )
|
||||
{
|
||||
Error(( "Failed to get window attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to get window attributes: %s", strerror(errno) );
|
||||
exit(-1);
|
||||
}
|
||||
Debug( 1, ( "Old X:%d", vid_win.x ));
|
||||
Debug( 1, ( "Old Y:%d", vid_win.y ));
|
||||
Debug( 1, ( "Old W:%d", vid_win.width ));
|
||||
Debug( 1, ( "Old H:%d", vid_win.height ));
|
||||
Debug( 1, "Old X:%d", vid_win.x );
|
||||
Debug( 1, "Old Y:%d", vid_win.y );
|
||||
Debug( 1, "Old W:%d", vid_win.width );
|
||||
Debug( 1, "Old H:%d", vid_win.height );
|
||||
|
||||
vid_win.x = 0;
|
||||
vid_win.y = 0;
|
||||
|
@ -152,19 +152,19 @@ void LocalCamera::Initialise()
|
|||
|
||||
if ( ioctl( m_videohandle, VIDIOCSWIN, &vid_win ) < 0 )
|
||||
{
|
||||
Error(( "Failed to set window attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to set window attributes: %s", strerror(errno) );
|
||||
if ( config.strict_video_config )
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ( ioctl(m_videohandle, VIDIOCGMBUF, &m_vmb) < 0 )
|
||||
{
|
||||
Error(( "Failed to setup memory: %s", strerror(errno) ));
|
||||
Error( "Failed to setup memory: %s", strerror(errno) );
|
||||
exit(-1);
|
||||
}
|
||||
m_vmm = new video_mmap[m_vmb.frames];
|
||||
Debug( 1, ( "vmb.frames = %d", m_vmb.frames ));
|
||||
Debug( 1, ( "vmb.size = %d", m_vmb.size ));
|
||||
Debug( 1, "vmb.frames = %d", m_vmb.frames );
|
||||
Debug( 1, "vmb.size = %d", m_vmb.size );
|
||||
|
||||
for ( int i=0; i < m_vmb.frames; i++)
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ void LocalCamera::Initialise()
|
|||
m_buffer = (unsigned char *)mmap( 0, m_vmb.size, PROT_READ|PROT_WRITE, MAP_SHARED, m_videohandle, 0 );
|
||||
if ( m_buffer == MAP_FAILED )
|
||||
{
|
||||
Error(( "Could not mmap video: %s", strerror(errno) ));
|
||||
Error( "Could not mmap video: %s", strerror(errno) );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -186,45 +186,45 @@ void LocalCamera::Initialise()
|
|||
vid_src.channel = channel;
|
||||
if ( ioctl( m_videohandle, VIDIOCGCHAN, &vid_src) < 0 )
|
||||
{
|
||||
Error(( "Failed to get camera source: %s", strerror(errno) ));
|
||||
Error( "Failed to get camera source: %s", strerror(errno) );
|
||||
exit(-1);
|
||||
}
|
||||
Debug( 1, ( "Old C:%d", vid_src.channel ));
|
||||
Debug( 1, ( "Old F:%d", vid_src.norm ));
|
||||
Debug( 1, ( "Old Fl:%x", vid_src.flags ));
|
||||
Debug( 1, ( "Old T:%d", vid_src.type ));
|
||||
Debug( 1, "Old C:%d", vid_src.channel );
|
||||
Debug( 1, "Old F:%d", vid_src.norm );
|
||||
Debug( 1, "Old Fl:%x", vid_src.flags );
|
||||
Debug( 1, "Old T:%d", vid_src.type );
|
||||
|
||||
vid_src.norm = format;
|
||||
vid_src.flags = 0;
|
||||
vid_src.type = VIDEO_TYPE_CAMERA;
|
||||
if ( ioctl( m_videohandle, VIDIOCSCHAN, &vid_src) < 0 )
|
||||
{
|
||||
Error(( "Failed to set camera source %d: %s", channel, strerror(errno) ));
|
||||
Error( "Failed to set camera source %d: %s", channel, strerror(errno) );
|
||||
if ( config.strict_video_config )
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ( ioctl( m_videohandle, VIDIOCGWIN, &vid_win) < 0 )
|
||||
{
|
||||
Error(( "Failed to get window data: %s", strerror(errno) ));
|
||||
Error( "Failed to get window data: %s", strerror(errno) );
|
||||
exit(-1);
|
||||
}
|
||||
Debug( 1, ( "New X:%d", vid_win.x ));
|
||||
Debug( 1, ( "New Y:%d", vid_win.y ));
|
||||
Debug( 1, ( "New W:%d", vid_win.width ));
|
||||
Debug( 1, ( "New H:%d", vid_win.height ));
|
||||
Debug( 1, "New X:%d", vid_win.x );
|
||||
Debug( 1, "New Y:%d", vid_win.y );
|
||||
Debug( 1, "New W:%d", vid_win.width );
|
||||
Debug( 1, "New H:%d", vid_win.height );
|
||||
|
||||
if ( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) < 0 )
|
||||
{
|
||||
Error(( "Failed to get window data: %s", strerror(errno) ));
|
||||
Error( "Failed to get window data: %s", strerror(errno) );
|
||||
exit(-1);
|
||||
}
|
||||
Debug( 1, ( "New P:%d", vid_pic.palette ));
|
||||
Debug( 1, ( "New D:%d", vid_pic.depth ));
|
||||
Debug( 1, ( "New B:%d", vid_pic.brightness ));
|
||||
Debug( 1, ( "New h:%d", vid_pic.hue ));
|
||||
Debug( 1, ( "New Cl:%d", vid_pic.colour ));
|
||||
Debug( 1, ( "New Cn:%d", vid_pic.contrast ));
|
||||
Debug( 1, "New P:%d", vid_pic.palette );
|
||||
Debug( 1, "New D:%d", vid_pic.depth );
|
||||
Debug( 1, "New B:%d", vid_pic.brightness );
|
||||
Debug( 1, "New h:%d", vid_pic.hue );
|
||||
Debug( 1, "New Cl:%d", vid_pic.colour );
|
||||
Debug( 1, "New Cn:%d", vid_pic.contrast );
|
||||
|
||||
y_table = new unsigned char[256];
|
||||
for ( int i = 0; i <= 255; i++ )
|
||||
|
@ -284,7 +284,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, bool ver
|
|||
sprintf( output, output+strlen(output), "Checking Video Device: %s\n", device );
|
||||
if ( (m_videohandle=open(device, O_RDWR)) <=0 )
|
||||
{
|
||||
Error(( "Failed to open video device %s: %s", device, strerror(errno) ));
|
||||
Error( "Failed to open video device %s: %s", device, strerror(errno) );
|
||||
if ( verbose )
|
||||
sprintf( output+strlen(output), "Error, failed to open video device %s: %s\n", device, strerror(errno) );
|
||||
else
|
||||
|
@ -295,7 +295,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, bool ver
|
|||
struct video_capability vid_cap;
|
||||
if ( ioctl( m_videohandle, VIDIOCGCAP, &vid_cap ) < 0 )
|
||||
{
|
||||
Error(( "Failed to get video capabilities: %s", strerror(errno) ));
|
||||
Error( "Failed to get video capabilities: %s", strerror(errno) );
|
||||
if ( verbose )
|
||||
sprintf( output, "Error, failed to get video capabilities %s: %s\n", device, strerror(errno) );
|
||||
else
|
||||
|
@ -344,7 +344,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, bool ver
|
|||
struct video_window vid_win;
|
||||
if ( ioctl( m_videohandle, VIDIOCGWIN, &vid_win ) < 0 )
|
||||
{
|
||||
Error(( "Failed to get window attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to get window attributes: %s", strerror(errno) );
|
||||
if ( verbose )
|
||||
sprintf( output, "Error, failed to get window attributes: %s\n", strerror(errno) );
|
||||
else
|
||||
|
@ -370,7 +370,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, bool ver
|
|||
struct video_picture vid_pic;
|
||||
if ( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic ) < 0 )
|
||||
{
|
||||
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to get picture attributes: %s", strerror(errno) );
|
||||
if ( verbose )
|
||||
sprintf( output, "Error, failed to get picture attributes: %s\n", strerror(errno) );
|
||||
else
|
||||
|
@ -424,7 +424,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, bool ver
|
|||
vid_src.channel = chan;
|
||||
if ( ioctl( m_videohandle, VIDIOCGCHAN, &vid_src ) < 0 )
|
||||
{
|
||||
Error(( "Failed to get channel %d attributes: %s", chan, strerror(errno) ));
|
||||
Error( "Failed to get channel %d attributes: %s", chan, strerror(errno) );
|
||||
if ( verbose )
|
||||
sprintf( output, "Error, failed to get channel %d attributes: %s\n", chan, strerror(errno) );
|
||||
else
|
||||
|
@ -468,7 +468,7 @@ int LocalCamera::Brightness( int p_brightness )
|
|||
struct video_picture vid_pic;
|
||||
if ( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) < 0 )
|
||||
{
|
||||
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to get picture attributes: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ int LocalCamera::Brightness( int p_brightness )
|
|||
vid_pic.brightness = p_brightness;
|
||||
if ( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) < 0 )
|
||||
{
|
||||
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to set picture attributes: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ int LocalCamera::Hue( int p_hue )
|
|||
struct video_picture vid_pic;
|
||||
if ( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) < 0 )
|
||||
{
|
||||
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to get picture attributes: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ int LocalCamera::Hue( int p_hue )
|
|||
vid_pic.hue = p_hue;
|
||||
if ( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) < 0 )
|
||||
{
|
||||
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to set picture attributes: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ int LocalCamera::Colour( int p_colour )
|
|||
struct video_picture vid_pic;
|
||||
if ( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) < 0 )
|
||||
{
|
||||
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to get picture attributes: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ int LocalCamera::Colour( int p_colour )
|
|||
vid_pic.colour = p_colour;
|
||||
if ( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) < 0 )
|
||||
{
|
||||
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to set picture attributes: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ int LocalCamera::Contrast( int p_contrast )
|
|||
struct video_picture vid_pic;
|
||||
if ( ioctl( m_videohandle, VIDIOCGPICT, &vid_pic) < 0 )
|
||||
{
|
||||
Error(( "Failed to get picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to get picture attributes: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ int LocalCamera::Contrast( int p_contrast )
|
|||
vid_pic.contrast = p_contrast;
|
||||
if ( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) < 0 )
|
||||
{
|
||||
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
|
||||
Error( "Failed to set picture attributes: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
@ -558,17 +558,17 @@ int LocalCamera::PrimeCapture()
|
|||
|
||||
int LocalCamera::PreCapture()
|
||||
{
|
||||
//Info(( "%s: Capturing image", id ));
|
||||
//Info( "%s: Capturing image", id );
|
||||
|
||||
if ( channel_count > 1 )
|
||||
{
|
||||
//Info(( "Switching" ));
|
||||
//Info( "Switching" );
|
||||
struct video_channel vid_src;
|
||||
memset( &vid_src, 0, sizeof(vid_src) );
|
||||
vid_src.channel = channel;
|
||||
if ( ioctl( m_videohandle, VIDIOCGCHAN, &vid_src) < 0 )
|
||||
{
|
||||
Error(( "Failed to get camera source %d: %s", channel, strerror(errno) ));
|
||||
Error( "Failed to get camera source %d: %s", channel, strerror(errno) );
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
@ -578,18 +578,18 @@ int LocalCamera::PreCapture()
|
|||
vid_src.type = VIDEO_TYPE_CAMERA;
|
||||
if ( ioctl( m_videohandle, VIDIOCSCHAN, &vid_src ) < 0 )
|
||||
{
|
||||
Error(( "Failed to set camera source %d: %s", channel, strerror(errno) ));
|
||||
Error( "Failed to set camera source %d: %s", channel, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( channel_count > 1 || channel_index == 0 )
|
||||
{
|
||||
//Info(( "Pre-Capture" ));
|
||||
//Info( "Pre-Capture" );
|
||||
m_cap_frame_active = m_cap_frame;
|
||||
if ( ioctl( m_videohandle, VIDIOCMCAPTURE, &m_vmm[m_cap_frame_active] ) < 0 )
|
||||
{
|
||||
Error(( "Capture failure for frame %d: %s", m_cap_frame_active, strerror(errno) ));
|
||||
Error( "Capture failure for frame %d: %s", m_cap_frame_active, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
m_cap_frame = (m_cap_frame+1)%m_vmb.frames;
|
||||
|
@ -601,18 +601,18 @@ int LocalCamera::PostCapture( Image &image )
|
|||
{
|
||||
static unsigned char *buffer = 0;
|
||||
|
||||
//Info(( "%s: Capturing image", id ));
|
||||
//Info( "%s: Capturing image", id );
|
||||
int captures_per_frame = 1;
|
||||
if ( channel_count > 1 )
|
||||
captures_per_frame = config.captures_per_frame;
|
||||
if ( channel_count > 1 || channel_index == 0 )
|
||||
{
|
||||
//Info(( "Post-Capture" ));
|
||||
//Info( "Post-Capture" );
|
||||
while ( captures_per_frame )
|
||||
{
|
||||
if ( ioctl( m_videohandle, VIDIOCSYNC, &m_sync_frame ) < 0 )
|
||||
{
|
||||
Error(( "Sync failure for frame %d buffer %d(%d): %s", m_sync_frame, m_cap_frame_active, captures_per_frame, strerror(errno) ));
|
||||
Error( "Sync failure for frame %d buffer %d(%d): %s", m_sync_frame, m_cap_frame_active, captures_per_frame, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
captures_per_frame--;
|
||||
|
@ -620,12 +620,12 @@ int LocalCamera::PostCapture( Image &image )
|
|||
{
|
||||
if ( ioctl( m_videohandle, VIDIOCMCAPTURE, &m_vmm[m_cap_frame_active] ) < 0 )
|
||||
{
|
||||
Error(( "Capture failure for buffer %d(%d): %s", m_cap_frame_active, captures_per_frame, strerror(errno) ));
|
||||
Error( "Capture failure for buffer %d(%d): %s", m_cap_frame_active, captures_per_frame, strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
//Info(( "Captured %d for %d into %d", m_sync_frame, channel, m_cap_frame_active));
|
||||
//Info( "Captured %d for %d into %d", m_sync_frame, channel, m_cap_frame_active);
|
||||
|
||||
buffer = m_buffer+(m_sync_frame*m_vmb.size/m_vmb.frames);
|
||||
m_sync_frame = (m_sync_frame+1)%m_vmb.frames;
|
||||
|
@ -861,9 +861,9 @@ int LocalCamera::PostCapture( Image &image )
|
|||
//for ( int i = 0; i < size; i++ )
|
||||
//{
|
||||
//if ( buffer[i] < 16 )
|
||||
//Info(( "Lo grey %d", buffer[i] ));
|
||||
//Info( "Lo grey %d", buffer[i] );
|
||||
//if ( buffer[i] > 235 )
|
||||
//Info(( "Hi grey %d", buffer[i] ));
|
||||
//Info( "Hi grey %d", buffer[i] );
|
||||
//}
|
||||
}
|
||||
default : // Everything else is straightforward, for now.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -49,19 +49,19 @@ void VideoStream::SetupFormat( const char *p_filename, const char *p_format )
|
|||
of = guess_format( format, NULL, NULL);
|
||||
if ( !of )
|
||||
{
|
||||
Warning(( "Could not deduce output format from file extension: using MPEG." ));
|
||||
Warning( "Could not deduce output format from file extension: using MPEG." );
|
||||
of = guess_format("mpeg", NULL, NULL);
|
||||
}
|
||||
if ( !of )
|
||||
{
|
||||
Fatal(( "Could not find suitable output format" ));
|
||||
Fatal( "Could not find suitable output format" );
|
||||
}
|
||||
|
||||
/* allocate the output media context */
|
||||
ofc = (AVFormatContext *)av_mallocz(sizeof(AVFormatContext));
|
||||
if ( !ofc )
|
||||
{
|
||||
Fatal(( "Memory error" ));
|
||||
Fatal( "Memory error" );
|
||||
}
|
||||
ofc->oformat = of;
|
||||
snprintf( ofc->filename, sizeof(ofc->filename), "%s", filename );
|
||||
|
@ -79,7 +79,7 @@ void VideoStream::SetupCodec( int colours, int width, int height, int bitrate, i
|
|||
ost = av_new_stream(ofc, 0);
|
||||
if (!ost)
|
||||
{
|
||||
Fatal(( "Could not alloc stream" ));
|
||||
Fatal( "Could not alloc stream" );
|
||||
}
|
||||
|
||||
#if ZM_FFMPEG_SVN
|
||||
|
@ -125,7 +125,7 @@ void VideoStream::SetParameters()
|
|||
parameters). */
|
||||
if ( av_set_parameters(ofc, NULL) < 0 )
|
||||
{
|
||||
Fatal(( "Invalid output format parameters" ));
|
||||
Fatal( "Invalid output format parameters" );
|
||||
}
|
||||
//dump_format(ofc, 0, filename, 1);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ const char *VideoStream::MimeType() const
|
|||
if ( !mime_type )
|
||||
{
|
||||
mime_type = "video/mpeg";
|
||||
Warning(( "Unable to determine mime type for '%s' format, using '%s' as default", format, mime_type ));
|
||||
Warning( "Unable to determine mime type for '%s' format, using '%s' as default", format, mime_type );
|
||||
}
|
||||
|
||||
return( mime_type );
|
||||
|
@ -165,27 +165,27 @@ void VideoStream::OpenStream()
|
|||
AVCodec *codec = avcodec_find_encoder(c->codec_id);
|
||||
if ( !codec )
|
||||
{
|
||||
Fatal(( "codec not found" ));
|
||||
Fatal( "codec not found" );
|
||||
}
|
||||
|
||||
/* open the codec */
|
||||
if ( avcodec_open(c, codec) < 0 )
|
||||
{
|
||||
Fatal(( "Could not open codec" ));
|
||||
Fatal( "Could not open codec" );
|
||||
}
|
||||
|
||||
/* allocate the encoded raw picture */
|
||||
opicture = avcodec_alloc_frame();
|
||||
if ( !opicture )
|
||||
{
|
||||
Fatal(( "Could not allocate opicture" ));
|
||||
Fatal( "Could not allocate opicture" );
|
||||
}
|
||||
int size = avpicture_get_size( c->pix_fmt, c->width, c->height);
|
||||
uint8_t *opicture_buf = (uint8_t *)malloc(size);
|
||||
if ( !opicture_buf )
|
||||
{
|
||||
av_free(opicture);
|
||||
Fatal(( "Could not allocate opicture" ));
|
||||
Fatal( "Could not allocate opicture" );
|
||||
}
|
||||
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt, c->width, c->height );
|
||||
|
||||
|
@ -198,14 +198,14 @@ void VideoStream::OpenStream()
|
|||
tmp_opicture = avcodec_alloc_frame();
|
||||
if ( !tmp_opicture )
|
||||
{
|
||||
Fatal(( "Could not allocate temporary opicture" ));
|
||||
Fatal( "Could not allocate temporary opicture" );
|
||||
}
|
||||
int size = avpicture_get_size( pf, c->width, c->height);
|
||||
uint8_t *tmp_opicture_buf = (uint8_t *)malloc(size);
|
||||
if (!tmp_opicture_buf)
|
||||
{
|
||||
av_free( tmp_opicture );
|
||||
Fatal(( "Could not allocate temporary opicture" ));
|
||||
Fatal( "Could not allocate temporary opicture" );
|
||||
}
|
||||
avpicture_fill( (AVPicture *)tmp_opicture, tmp_opicture_buf, pf, c->width, c->height );
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ void VideoStream::OpenStream()
|
|||
{
|
||||
if ( url_fopen(&ofc->pb, filename, URL_WRONLY) < 0 )
|
||||
{
|
||||
Fatal(( "Could not open '%s'", filename ));
|
||||
Fatal( "Could not open '%s'", filename );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ double VideoStream::EncodeFrame( uint8_t *buffer, int buffer_size, bool add_time
|
|||
{
|
||||
img_convert_ctx = sws_getContext( c->width, c->height, pf, c->width, c->height, c->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL );
|
||||
if ( !img_convert_ctx )
|
||||
Fatal(( "Unable to initialise image scaling context" ));
|
||||
Fatal( "Unable to initialise image scaling context" );
|
||||
}
|
||||
sws_scale( img_convert_ctx, tmp_opicture->data, tmp_opicture->linesize, 0, c->height, opicture->data, opicture->linesize );
|
||||
#else // HAVE_LIBSWSCALE
|
||||
|
@ -378,7 +378,7 @@ double VideoStream::EncodeFrame( uint8_t *buffer, int buffer_size, bool add_time
|
|||
}
|
||||
if ( ret != 0 )
|
||||
{
|
||||
Fatal(( "Error while writing video frame" ));
|
||||
Fatal( "Error while writing video frame" );
|
||||
}
|
||||
return( pts );
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@ RegExpr::RegExpr( const char *pattern, int flags, int p_max_matches ) : max_matc
|
|||
int erroffset = 0;
|
||||
if ( !(regex = pcre_compile( pattern, flags, &errstr, &erroffset, 0 )) )
|
||||
{
|
||||
Fatal(( "pcre_compile(%s): %s at %d", pattern, errstr, erroffset ));
|
||||
Fatal( "pcre_compile(%s): %s at %d", pattern, errstr, erroffset );
|
||||
}
|
||||
|
||||
regextra = pcre_study( regex, 0, &errstr );
|
||||
if ( errstr )
|
||||
{
|
||||
Fatal(( "pcre_study(%s): %s", pattern, errstr ));
|
||||
Fatal( "pcre_study(%s): %s", pattern, errstr );
|
||||
}
|
||||
|
||||
if ( ok = (bool)regex )
|
||||
|
@ -78,7 +78,7 @@ int RegExpr::Match( const char *subject_string, int subject_length, int flags )
|
|||
{
|
||||
if ( n_matches < PCRE_ERROR_NOMATCH )
|
||||
{
|
||||
Error(( "Error %d executing regular expression", n_matches ));
|
||||
Error( "Error %d executing regular expression", n_matches );
|
||||
}
|
||||
return( n_matches = 0 );
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "zm.h"
|
||||
#include "zm_remote_camera.h"
|
||||
|
||||
RemoteCamera::RemoteCamera( const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( REMOTE, p_width, p_height, p_palette, p_brightness, p_contrast, p_hue, p_colour, p_capture )
|
||||
RemoteCamera::RemoteCamera( const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( REMOTE_SRC, p_width, p_height, p_palette, p_brightness, p_contrast, p_hue, p_colour, p_capture )
|
||||
{
|
||||
strncpy( host, p_host, sizeof(host) );
|
||||
strncpy( port, p_port, sizeof(port) );
|
||||
|
@ -71,19 +71,19 @@ void RemoteCamera::Initialise()
|
|||
{
|
||||
if( !host )
|
||||
{
|
||||
Error(( "No host specified for remote get" ));
|
||||
Error( "No host specified for remote get" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
if( !port )
|
||||
{
|
||||
Error(( "No port specified for remote get" ));
|
||||
Error( "No port specified for remote get" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
if( !path )
|
||||
{
|
||||
Error(( "No path specified for remote get" ));
|
||||
Error( "No path specified for remote get" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ void RemoteCamera::Initialise()
|
|||
{
|
||||
if ( !(hp = gethostbyname(host)) )
|
||||
{
|
||||
Error(( "Can't gethostbyname(%s): %s", host, strerror(h_errno) ));
|
||||
Error( "Can't gethostbyname(%s): %s", host, strerror(h_errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
memcpy((char *)&sa.sin_addr, (char *)hp->h_addr, hp->h_length);
|
||||
|
@ -121,7 +121,7 @@ void RemoteCamera::Initialise()
|
|||
snprintf( &(request[strlen(request)]), sizeof(request)-strlen(request), "Authorization: Basic %s\r\n", auth64 );
|
||||
}
|
||||
snprintf( &(request[strlen(request)]), sizeof(request)-strlen(request), "\r\n" );
|
||||
Debug( 2, ( "Request: %s", request ));
|
||||
Debug( 2, "Request: %s", request );
|
||||
}
|
||||
if ( !timeout.tv_sec )
|
||||
{
|
||||
|
@ -145,18 +145,18 @@ int RemoteCamera::Connect()
|
|||
sd = socket( hp->h_addrtype, SOCK_STREAM, 0 );
|
||||
if ( sd < 0 )
|
||||
{
|
||||
Error(( "Can't create socket: %s", strerror(errno) ));
|
||||
Error( "Can't create socket: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if ( connect( sd, (struct sockaddr *)&sa, sizeof(sa) ) < 0 )
|
||||
{
|
||||
Error(( "Can't connect to remote camera: %s", strerror(errno) ));
|
||||
Error( "Can't connect to remote camera: %s", strerror(errno) );
|
||||
Disconnect();
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
Debug( 3, ( "Connected to host, socket = %d", sd ));
|
||||
Debug( 3, "Connected to host, socket = %d", sd );
|
||||
return( sd );
|
||||
}
|
||||
|
||||
|
@ -171,13 +171,13 @@ int RemoteCamera::SendRequest()
|
|||
{
|
||||
if ( write( sd, request, strlen(request) ) < 0 )
|
||||
{
|
||||
Error(( "Can't write: %s", strerror(errno) ));
|
||||
Error( "Can't write: %s", strerror(errno) );
|
||||
Disconnect();
|
||||
return( -1 );
|
||||
}
|
||||
format = UNDEF;
|
||||
state = HEADER;
|
||||
Debug( 3, ( "Request sent" ));
|
||||
Debug( 3, "Request sent" );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
@ -192,12 +192,12 @@ int RemoteCamera::ReadData( Buffer &buffer, int bytes_expected )
|
|||
int n_found = select( sd+1, &rfds, NULL, NULL, &temp_timeout );
|
||||
if( n_found == 0 )
|
||||
{
|
||||
Error(( "Select timed out" ));
|
||||
Error( "Select timed out" );
|
||||
return( -1 );
|
||||
}
|
||||
else if ( n_found < 0)
|
||||
{
|
||||
Error(( "Select error: %s", strerror(errno) ));
|
||||
Error( "Select error: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -211,18 +211,18 @@ int RemoteCamera::ReadData( Buffer &buffer, int bytes_expected )
|
|||
{
|
||||
if ( ioctl( sd, FIONREAD, &total_bytes_to_read ) < 0 )
|
||||
{
|
||||
Error(( "Can't ioctl(): %s", strerror(errno) ));
|
||||
Error( "Can't ioctl(): %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if ( total_bytes_to_read == 0 )
|
||||
{
|
||||
Debug( 3, ( "Socket closed" ));
|
||||
Debug( 3, "Socket closed" );
|
||||
Disconnect();
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
Debug( 3, ( "Expecting %d bytes", total_bytes_to_read ));
|
||||
Debug( 3, "Expecting %d bytes", total_bytes_to_read );
|
||||
|
||||
int total_bytes_read = 0;
|
||||
do
|
||||
|
@ -233,21 +233,21 @@ int RemoteCamera::ReadData( Buffer &buffer, int bytes_expected )
|
|||
|
||||
if ( bytes_read < 0)
|
||||
{
|
||||
Error(( "Read error: %s", strerror(errno) ));
|
||||
Error( "Read error: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
else if ( bytes_read == 0)
|
||||
{
|
||||
Debug( 3, ( "Socket closed" ));
|
||||
Debug( 3, "Socket closed" );
|
||||
Disconnect();
|
||||
return( 0 );
|
||||
}
|
||||
else if ( bytes_read < bytes_to_read )
|
||||
{
|
||||
Error(( "Incomplete read, expected %d, got %d", bytes_to_read, bytes_read ));
|
||||
Error( "Incomplete read, expected %d, got %d", bytes_to_read, bytes_read );
|
||||
return( -1 );
|
||||
}
|
||||
Debug( 3, ( "Read %d bytes", bytes_read ));
|
||||
Debug( 3, "Read %d bytes", bytes_read );
|
||||
buffer.Append( temp_buffer, bytes_read );
|
||||
total_bytes_read += bytes_read;
|
||||
total_bytes_to_read -= bytes_read;
|
||||
|
@ -291,7 +291,7 @@ int RemoteCamera::GetResponse()
|
|||
int buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
{
|
||||
Error(( "Unable to read header data" ));
|
||||
Error( "Unable to read header data" );
|
||||
return( -1 );
|
||||
}
|
||||
if ( !header_expr )
|
||||
|
@ -300,13 +300,13 @@ int RemoteCamera::GetResponse()
|
|||
{
|
||||
header = header_expr->MatchString( 1 );
|
||||
header_len = header_expr->MatchLength( 1 );
|
||||
Debug( 4, ( "Captured header (%d bytes):\n'%s'", header_len, header ));
|
||||
Debug( 4, "Captured header (%d bytes):\n'%s'", header_len, header );
|
||||
|
||||
if ( !status_expr )
|
||||
status_expr = new RegExpr( "^HTTP/(1\\.[01]) +([0-9]+) +(.+?)\r?\n", PCRE_CASELESS );
|
||||
if ( status_expr->Match( header, header_len ) < 4 )
|
||||
{
|
||||
Error(( "Unable to extract HTTP status from header" ));
|
||||
Error( "Unable to extract HTTP status from header" );
|
||||
return( -1 );
|
||||
}
|
||||
http_version = status_expr->MatchString( 1 );
|
||||
|
@ -315,17 +315,17 @@ int RemoteCamera::GetResponse()
|
|||
|
||||
if ( status_code < 200 || status_code > 299 )
|
||||
{
|
||||
Error(( "Invalid response status %d: %s", status_code, status_mesg ));
|
||||
Error( "Invalid response status %d: %s", status_code, status_mesg );
|
||||
return( -1 );
|
||||
}
|
||||
Debug( 3, ( "Got status '%d' (%s), http version %s", status_code, status_mesg, http_version ));
|
||||
Debug( 3, "Got status '%d' (%s), http version %s", status_code, status_mesg, http_version );
|
||||
|
||||
if ( !connection_expr )
|
||||
connection_expr = new RegExpr( "Connection: ?(.+?)\r?\n", PCRE_CASELESS );
|
||||
if ( connection_expr->Match( header, header_len ) == 2 )
|
||||
{
|
||||
connection_type = connection_expr->MatchString( 1 );
|
||||
Debug( 3, ( "Got connection '%s'", connection_type ));
|
||||
Debug( 3, "Got connection '%s'", connection_type );
|
||||
}
|
||||
|
||||
if ( !content_length_expr )
|
||||
|
@ -333,7 +333,7 @@ int RemoteCamera::GetResponse()
|
|||
if ( content_length_expr->Match( header, header_len ) == 2 )
|
||||
{
|
||||
content_length = atoi( content_length_expr->MatchString( 1 ) );
|
||||
Debug( 3, ( "Got content length '%d'", content_length ));
|
||||
Debug( 3, "Got content length '%d'", content_length );
|
||||
}
|
||||
|
||||
if ( !content_type_expr )
|
||||
|
@ -341,11 +341,11 @@ int RemoteCamera::GetResponse()
|
|||
if ( content_type_expr->Match( header, header_len ) >= 2 )
|
||||
{
|
||||
content_type = content_type_expr->MatchString( 1 );
|
||||
Debug( 3, ( "Got content type '%s'\n", content_type ));
|
||||
Debug( 3, "Got content type '%s'\n", content_type );
|
||||
if ( content_type_expr->MatchCount() > 2 )
|
||||
{
|
||||
content_boundary = content_type_expr->MatchString( 2 );
|
||||
Debug( 3, ( "Got content boundary '%s'", content_boundary ));
|
||||
Debug( 3, "Got content boundary '%s'", content_boundary );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ int RemoteCamera::GetResponse()
|
|||
// Image stream, so start processing
|
||||
if ( !content_boundary[0] )
|
||||
{
|
||||
Error(( "No content boundary found in header '%s'", header ));
|
||||
Error( "No content boundary found in header '%s'", header );
|
||||
return( -1 );
|
||||
}
|
||||
mode = MULTI_IMAGE;
|
||||
|
@ -387,14 +387,14 @@ int RemoteCamera::GetResponse()
|
|||
//}
|
||||
else
|
||||
{
|
||||
Error(( "Unrecognised content type '%s'", content_type ));
|
||||
Error( "Unrecognised content type '%s'", content_type );
|
||||
return( -1 );
|
||||
}
|
||||
buffer.Consume( header_len );
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug( 3, ( "Unable to extract header from stream, retrying" ));
|
||||
Debug( 3, "Unable to extract header from stream, retrying" );
|
||||
//return( -1 );
|
||||
}
|
||||
break;
|
||||
|
@ -415,14 +415,14 @@ int RemoteCamera::GetResponse()
|
|||
{
|
||||
subheader = subheader_expr->MatchString( 1 );
|
||||
subheader_len = subheader_expr->MatchLength( 1 );
|
||||
Debug( 4, ( "Captured subheader (%d bytes):'%s'", subheader_len, subheader ));
|
||||
Debug( 4, "Captured subheader (%d bytes):'%s'", subheader_len, subheader );
|
||||
|
||||
if ( !subcontent_length_expr )
|
||||
subcontent_length_expr = new RegExpr( "Content-length: ?([0-9]+)\r?\n", PCRE_CASELESS );
|
||||
if ( subcontent_length_expr->Match( subheader, subheader_len ) == 2 )
|
||||
{
|
||||
content_length = atoi( subcontent_length_expr->MatchString( 1 ) );
|
||||
Debug( 3, ( "Got subcontent length '%d'", content_length ));
|
||||
Debug( 3, "Got subcontent length '%d'", content_length );
|
||||
}
|
||||
|
||||
if ( !subcontent_type_expr )
|
||||
|
@ -430,7 +430,7 @@ int RemoteCamera::GetResponse()
|
|||
if ( subcontent_type_expr->Match( subheader, subheader_len ) == 2 )
|
||||
{
|
||||
content_type = subcontent_type_expr->MatchString( 1 );
|
||||
Debug( 3, ( "Got subcontent type '%s'", content_type ));
|
||||
Debug( 3, "Got subcontent type '%s'", content_type );
|
||||
}
|
||||
|
||||
buffer.Consume( subheader_len );
|
||||
|
@ -438,7 +438,7 @@ int RemoteCamera::GetResponse()
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug( 3, ( "Unable to extract subheader from stream, retrying" ));
|
||||
Debug( 3, "Unable to extract subheader from stream, retrying" );
|
||||
int buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
{
|
||||
|
@ -463,7 +463,7 @@ int RemoteCamera::GetResponse()
|
|||
}
|
||||
else
|
||||
{
|
||||
Error(( "Found unsupported content type '%s'", content_type ));
|
||||
Error( "Found unsupported content type '%s'", content_type );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -474,11 +474,11 @@ int RemoteCamera::GetResponse()
|
|||
int buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
{
|
||||
Error(( "Unable to read content" ));
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
Debug( 3, ( "Got end of image by length, content-length = %d", content_length ));
|
||||
Debug( 3, "Got end of image by length, content-length = %d", content_length );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -487,7 +487,7 @@ int RemoteCamera::GetResponse()
|
|||
int buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
{
|
||||
Error(( "Unable to read content" ));
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
static RegExpr *content_expr = 0;
|
||||
|
@ -504,14 +504,14 @@ int RemoteCamera::GetResponse()
|
|||
if ( content_expr->Match( buffer, buffer.Size() ) == 2 )
|
||||
{
|
||||
content_length = content_expr->MatchLength( 1 );
|
||||
Debug( 3, ( "Got end of image by pattern, content-length = %d", content_length ));
|
||||
Debug( 3, "Got end of image by pattern, content-length = %d", content_length );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
content_length = buffer.Size();
|
||||
Debug( 3, ( "Got end of image by closure, content-length = %d", content_length ));
|
||||
Debug( 3, "Got end of image by closure, content-length = %d", content_length );
|
||||
if ( mode == SINGLE_IMAGE )
|
||||
{
|
||||
if ( !content_expr )
|
||||
|
@ -521,7 +521,7 @@ int RemoteCamera::GetResponse()
|
|||
if ( content_expr->Match( buffer, buffer.Size() ) == 2 )
|
||||
{
|
||||
content_length = content_expr->MatchLength( 1 );
|
||||
Debug( 3, ( "Trimmed end of image, new content-length = %d", content_length ));
|
||||
Debug( 3, "Trimmed end of image, new content-length = %d", content_length );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -536,12 +536,12 @@ int RemoteCamera::GetResponse()
|
|||
{
|
||||
state = SUBHEADER;
|
||||
}
|
||||
Debug( 3, ( "Returning %d (%d) bytes of captured content", content_length, buffer.Size() ));
|
||||
Debug( 3, "Returning %d (%d) bytes of captured content", content_length, buffer.Size() );
|
||||
return( content_length );
|
||||
}
|
||||
default :
|
||||
{
|
||||
Error(( "Unexpected content parsing state %d", state ));
|
||||
Error( "Unexpected content parsing state %d", state );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ int RemoteCamera::GetResponse()
|
|||
{
|
||||
if ( config.netcam_regexps )
|
||||
{
|
||||
Warning(( "Unable to use netcam regexps as not compiled with libpcre" ));
|
||||
Warning( "Unable to use netcam regexps as not compiled with libpcre" );
|
||||
}
|
||||
static const char *http_match = "HTTP/";
|
||||
static const char *connection_match = "Connection:";
|
||||
|
@ -627,7 +627,7 @@ int RemoteCamera::GetResponse()
|
|||
int buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
{
|
||||
Error(( "Unable to read header" ));
|
||||
Error( "Unable to read header" );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -664,7 +664,7 @@ int RemoteCamera::GetResponse()
|
|||
}
|
||||
}
|
||||
|
||||
Debug( 6, ( header_ptr ));
|
||||
Debug( 6, header_ptr );
|
||||
if ( ( crlf = mempbrk( header_ptr, "\r\n", header_len ) ) )
|
||||
{
|
||||
headers[n_headers++] = header_ptr;
|
||||
|
@ -672,26 +672,26 @@ int RemoteCamera::GetResponse()
|
|||
if ( !http_header && (strncasecmp( header_ptr, http_match, http_match_len ) == 0) )
|
||||
{
|
||||
http_header = header_ptr+http_match_len;
|
||||
Debug( 6, ( "Got http header '%s'", header_ptr ));
|
||||
Debug( 6, "Got http header '%s'", header_ptr );
|
||||
}
|
||||
else if ( !connection_header && (strncasecmp( header_ptr, connection_match, connection_match_len) == 0) )
|
||||
{
|
||||
connection_header = header_ptr+connection_match_len;
|
||||
Debug( 6, ( "Got connection header '%s'", header_ptr ));
|
||||
Debug( 6, "Got connection header '%s'", header_ptr );
|
||||
}
|
||||
else if ( !content_length_header && (strncasecmp( header_ptr, content_length_match, content_length_match_len) == 0) )
|
||||
{
|
||||
content_length_header = header_ptr+content_length_match_len;
|
||||
Debug( 6, ( "Got content length header '%s'", header_ptr ));
|
||||
Debug( 6, "Got content length header '%s'", header_ptr );
|
||||
}
|
||||
else if ( !content_type_header && (strncasecmp( header_ptr, content_type_match, content_type_match_len) == 0) )
|
||||
{
|
||||
content_type_header = header_ptr+content_type_match_len;
|
||||
Debug( 6, ( "Got content type header '%s'", header_ptr ));
|
||||
Debug( 6, "Got content type header '%s'", header_ptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug( 6, ( "Got ignored header '%s'", header_ptr ));
|
||||
Debug( 6, "Got ignored header '%s'", header_ptr );
|
||||
}
|
||||
header_ptr = crlf;
|
||||
header_len -= buffer.Consume( header_ptr-(char *)buffer );
|
||||
|
@ -709,7 +709,7 @@ int RemoteCamera::GetResponse()
|
|||
|
||||
if ( !http_header )
|
||||
{
|
||||
Error(( "Unable to extract HTTP status from header" ));
|
||||
Error( "Unable to extract HTTP status from header" );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -733,23 +733,23 @@ int RemoteCamera::GetResponse()
|
|||
|
||||
if ( status < 200 || status > 299 )
|
||||
{
|
||||
Error(( "Invalid response status %s: %s", status_code, status_mesg ));
|
||||
Error( "Invalid response status %s: %s", status_code, status_mesg );
|
||||
return( -1 );
|
||||
}
|
||||
Debug( 3, ( "Got status '%d' (%s), http version %s", status, status_mesg, http_version ));
|
||||
Debug( 3, "Got status '%d' (%s), http version %s", status, status_mesg, http_version );
|
||||
|
||||
if ( connection_header )
|
||||
{
|
||||
memset( connection_type, 0, sizeof(connection_type) );
|
||||
start_ptr = connection_header + strspn( connection_header, " " );
|
||||
strcpy( connection_type, start_ptr );
|
||||
Debug( 3, ( "Got connection '%s'", connection_type ));
|
||||
Debug( 3, "Got connection '%s'", connection_type );
|
||||
}
|
||||
if ( content_length_header )
|
||||
{
|
||||
start_ptr = content_length_header + strspn( content_length_header, " " );
|
||||
content_length = atoi( start_ptr );
|
||||
Debug( 3, ( "Got content length '%d'", content_length ));
|
||||
Debug( 3, "Got content length '%d'", content_length );
|
||||
}
|
||||
if ( content_type_header )
|
||||
{
|
||||
|
@ -758,7 +758,7 @@ int RemoteCamera::GetResponse()
|
|||
if ( ( end_ptr = strchr( start_ptr, ';' ) ) )
|
||||
{
|
||||
strncpy( content_type, start_ptr, end_ptr-start_ptr );
|
||||
Debug( 3, ( "Got content type '%s'", content_type ));
|
||||
Debug( 3, "Got content type '%s'", content_type );
|
||||
|
||||
start_ptr = end_ptr + strspn( end_ptr, "; " );
|
||||
|
||||
|
@ -767,17 +767,17 @@ int RemoteCamera::GetResponse()
|
|||
start_ptr += boundary_match_len;
|
||||
start_ptr += strspn( start_ptr, "-" );
|
||||
content_boundary_len = sprintf( content_boundary, "--%s", start_ptr );
|
||||
Debug( 3, ( "Got content boundary '%s'", content_boundary ));
|
||||
Debug( 3, "Got content boundary '%s'", content_boundary );
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(( "No content boundary found in header '%s'", content_type_header ));
|
||||
Error( "No content boundary found in header '%s'", content_type_header );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy( content_type, start_ptr );
|
||||
Debug( 3, ( "Got content type '%s'", content_type ));
|
||||
Debug( 3, "Got content type '%s'", content_type );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,7 @@ int RemoteCamera::GetResponse()
|
|||
// Image stream, so start processing
|
||||
if ( !content_boundary[0] )
|
||||
{
|
||||
Error(( "No content boundary found in header '%s'", content_type_header ));
|
||||
Error( "No content boundary found in header '%s'", content_type_header );
|
||||
return( -1 );
|
||||
}
|
||||
mode = MULTI_IMAGE;
|
||||
|
@ -819,13 +819,13 @@ int RemoteCamera::GetResponse()
|
|||
//}
|
||||
else
|
||||
{
|
||||
Error(( "Unrecognised content type '%s'", content_type ));
|
||||
Error( "Unrecognised content type '%s'", content_type );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug( 3, ( "Unable to extract entire header from stream, continuing" ));
|
||||
Debug( 3, "Unable to extract entire header from stream, continuing" );
|
||||
state = HEADERCONT;
|
||||
//return( -1 );
|
||||
}
|
||||
|
@ -875,7 +875,7 @@ int RemoteCamera::GetResponse()
|
|||
}
|
||||
}
|
||||
|
||||
Debug( 6, ( "%d: %s", subheader_len, subheader_ptr ));
|
||||
Debug( 6, "%d: %s", subheader_len, subheader_ptr );
|
||||
|
||||
if ( ( crlf = mempbrk( subheader_ptr, "\r\n", subheader_len ) ) )
|
||||
{
|
||||
|
@ -884,23 +884,23 @@ int RemoteCamera::GetResponse()
|
|||
if ( !boundary_header && (strncasecmp( subheader_ptr, content_boundary, content_boundary_len ) == 0) )
|
||||
{
|
||||
boundary_header = subheader_ptr;
|
||||
Debug( 4, ( "Got boundary subheader '%s'", subheader_ptr ));
|
||||
Debug( 4, "Got boundary subheader '%s'", subheader_ptr );
|
||||
}
|
||||
else if ( !subcontent_length_header[0] && (strncasecmp( subheader_ptr, content_length_match, content_length_match_len) == 0) )
|
||||
{
|
||||
strncpy( subcontent_length_header, subheader_ptr+content_length_match_len, sizeof(subcontent_length_header) );
|
||||
*(subcontent_length_header+strcspn( subcontent_length_header, "\r\n" )) = '\0';
|
||||
Debug( 4, ( "Got content length subheader '%s'", subcontent_length_header ));
|
||||
Debug( 4, "Got content length subheader '%s'", subcontent_length_header );
|
||||
}
|
||||
else if ( !subcontent_type_header[0] && (strncasecmp( subheader_ptr, content_type_match, content_type_match_len) == 0) )
|
||||
{
|
||||
strncpy( subcontent_type_header, subheader_ptr+content_type_match_len, sizeof(subcontent_type_header) );
|
||||
*(subcontent_type_header+strcspn( subcontent_type_header, "\r\n" )) = '\0';
|
||||
Debug( 4, ( "Got content type subheader '%s'", subcontent_type_header ));
|
||||
Debug( 4, "Got content type subheader '%s'", subcontent_type_header );
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug( 6, ( "Got ignored subheader '%s' found", subheader_ptr ));
|
||||
Debug( 6, "Got ignored subheader '%s' found", subheader_ptr );
|
||||
}
|
||||
subheader_ptr = crlf;
|
||||
subheader_len -= buffer.Consume( subheader_ptr-(char *)buffer );
|
||||
|
@ -916,30 +916,30 @@ int RemoteCamera::GetResponse()
|
|||
{
|
||||
char *start_ptr;
|
||||
|
||||
Debug( 3, ( "Got boundary '%s'", boundary_header ));
|
||||
Debug( 3, "Got boundary '%s'", boundary_header );
|
||||
|
||||
if ( subcontent_length_header )
|
||||
{
|
||||
start_ptr = subcontent_length_header + strspn( subcontent_length_header, " " );
|
||||
content_length = atoi( start_ptr );
|
||||
Debug( 3, ( "Got subcontent length '%d'", content_length ));
|
||||
Debug( 3, "Got subcontent length '%d'", content_length );
|
||||
}
|
||||
if ( subcontent_type_header )
|
||||
{
|
||||
memset( content_type, 0, sizeof(content_type) );
|
||||
start_ptr = subcontent_type_header + strspn( subcontent_type_header, " " );
|
||||
strcpy( content_type, start_ptr );
|
||||
Debug( 3, ( "Got subcontent type '%s'", content_type ));
|
||||
Debug( 3, "Got subcontent type '%s'", content_type );
|
||||
}
|
||||
state = CONTENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug( 3, ( "Unable to extract subheader from stream, retrying" ));
|
||||
Debug( 3, "Unable to extract subheader from stream, retrying" );
|
||||
int buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
{
|
||||
Error(( "Unable to read subheader" ));
|
||||
Error( "Unable to read subheader" );
|
||||
return( -1 );
|
||||
}
|
||||
state = SUBHEADERCONT;
|
||||
|
@ -962,7 +962,7 @@ int RemoteCamera::GetResponse()
|
|||
}
|
||||
else
|
||||
{
|
||||
Error(( "Found unsupported content type '%s'", content_type ));
|
||||
Error( "Found unsupported content type '%s'", content_type );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -970,7 +970,7 @@ int RemoteCamera::GetResponse()
|
|||
{
|
||||
if ( buffer[0] != 0xff || buffer[1] != 0xd8 )
|
||||
{
|
||||
Error(( "Found bogus jpeg header '%02x%02x'", buffer[0], buffer[1] ));
|
||||
Error( "Found bogus jpeg header '%02x%02x'", buffer[0], buffer[1] );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
@ -983,11 +983,11 @@ int RemoteCamera::GetResponse()
|
|||
int buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
{
|
||||
Error(( "Unable to read content" ));
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
Debug( 3, ( "Got end of image by length, content-length = %d", content_length ));
|
||||
Debug( 3, "Got end of image by length, content-length = %d", content_length );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -998,7 +998,7 @@ int RemoteCamera::GetResponse()
|
|||
int buffer_size = buffer.Size();
|
||||
if ( buffer_len < 0 )
|
||||
{
|
||||
Error(( "Unable to read content" ));
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
if ( buffer_len )
|
||||
|
@ -1008,7 +1008,7 @@ int RemoteCamera::GetResponse()
|
|||
while ( char *start_ptr = (char *)memstr( (char *)buffer+content_pos, "\r\n--", buffer_size-content_pos ) )
|
||||
{
|
||||
content_length = start_ptr - (char *)buffer;
|
||||
Debug( 3, ( "Got end of image by pattern (crlf--), content-length = %d", content_length ));
|
||||
Debug( 3, "Got end of image by pattern (crlf--), content-length = %d", content_length );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1016,7 +1016,7 @@ int RemoteCamera::GetResponse()
|
|||
else
|
||||
{
|
||||
content_length = buffer_size;
|
||||
Debug( 3, ( "Got end of image by closure, content-length = %d", content_length ));
|
||||
Debug( 3, "Got end of image by closure, content-length = %d", content_length );
|
||||
if ( mode == SINGLE_IMAGE )
|
||||
{
|
||||
char *end_ptr = (char *)buffer+buffer_size;
|
||||
|
@ -1029,7 +1029,7 @@ int RemoteCamera::GetResponse()
|
|||
|
||||
if ( end_ptr != ((char *)buffer+buffer_size) )
|
||||
{
|
||||
Debug( 3, ( "Trimmed end of image, new content-length = %d", content_length ));
|
||||
Debug( 3, "Trimmed end of image, new content-length = %d", content_length );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1049,12 +1049,12 @@ int RemoteCamera::GetResponse()
|
|||
{
|
||||
if ( buffer[0] != 0xff || buffer[1] != 0xd8 )
|
||||
{
|
||||
Error(( "Found bogus jpeg header '%02x%02x'", buffer[0], buffer[1] ));
|
||||
Error( "Found bogus jpeg header '%02x%02x'", buffer[0], buffer[1] );
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
Debug( 3, ( "Returning %d (%d) bytes of captured content", content_length, buffer.Size() ));
|
||||
Debug( 3, "Returning %d (%d) bytes of captured content", content_length, buffer.Size() );
|
||||
return( content_length );
|
||||
}
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ int RemoteCamera::PreCapture()
|
|||
Connect();
|
||||
if ( sd < 0 )
|
||||
{
|
||||
Error(( "Unable to connect to camera" ));
|
||||
Error( "Unable to connect to camera" );
|
||||
return( -1 );
|
||||
}
|
||||
mode = SINGLE_IMAGE;
|
||||
|
@ -1080,7 +1080,7 @@ int RemoteCamera::PreCapture()
|
|||
{
|
||||
if ( SendRequest() < 0 )
|
||||
{
|
||||
Error(( "Unable to send request" ));
|
||||
Error( "Unable to send request" );
|
||||
Disconnect();
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -1093,7 +1093,7 @@ int RemoteCamera::PostCapture( Image &image )
|
|||
int content_length = GetResponse();
|
||||
if ( content_length < 0 )
|
||||
{
|
||||
Error(( "Unable to get response" ));
|
||||
Error( "Unable to get response" );
|
||||
Disconnect();
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -1103,7 +1103,7 @@ int RemoteCamera::PostCapture( Image &image )
|
|||
{
|
||||
if ( !image.DecodeJpeg( buffer.Extract( content_length ), content_length ) )
|
||||
{
|
||||
Error(( "Unable to decode jpeg" ));
|
||||
Error( "Unable to decode jpeg" );
|
||||
Disconnect();
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -1113,7 +1113,7 @@ int RemoteCamera::PostCapture( Image &image )
|
|||
{
|
||||
if ( content_length != image.Size() )
|
||||
{
|
||||
Error(( "Image length mismatch, expected %d bytes, content length was %d", image.Size(), content_length ));
|
||||
Error( "Image length mismatch, expected %d bytes, content length was %d", image.Size(), content_length );
|
||||
Disconnect();
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -1124,7 +1124,7 @@ int RemoteCamera::PostCapture( Image &image )
|
|||
{
|
||||
if ( !image.Unzip( buffer.Extract( content_length ), content_length ) )
|
||||
{
|
||||
Error(( "Unable to unzip RGB image" ));
|
||||
Error( "Unable to unzip RGB image" );
|
||||
Disconnect();
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -1133,7 +1133,7 @@ int RemoteCamera::PostCapture( Image &image )
|
|||
}
|
||||
default :
|
||||
{
|
||||
Error(( "Unexpected image format encountered" ));
|
||||
Error( "Unexpected image format encountered" );
|
||||
Disconnect();
|
||||
return( -1 );
|
||||
}
|
||||
|
|
|
@ -33,10 +33,10 @@ RETSIGTYPE zm_hup_handler( int signal )
|
|||
char * errorString =(char *) malloc(errorStringSize + 1); // plus 1 for termination char.
|
||||
(void) snprintf(errorString, errorStringSize, "Got signal (%s), reloading.", error);
|
||||
|
||||
Info(( (const char *)errorString ));
|
||||
Info( (const char *)errorString );
|
||||
free(errorString);
|
||||
#else // HAVE_DECL_STRSIGNAL
|
||||
Info(( "Got HUP signal, reloading" ));
|
||||
Info( "Got HUP signal, reloading" );
|
||||
#endif // HAVE_DECL_STRSIGNAL
|
||||
zm_reload = true;
|
||||
}
|
||||
|
@ -51,10 +51,10 @@ RETSIGTYPE zm_term_handler( int signal )
|
|||
char * errorString =(char *) malloc(errorStringSize + 1); // plus 1 for termination char.
|
||||
(void) snprintf(errorString, errorStringSize, "Got signal (%s), exiting.", error);
|
||||
|
||||
Info(( (const char *)errorString ));
|
||||
Info( (const char *)errorString );
|
||||
free(errorString);
|
||||
#else // HAVE_DECL_STRSIGNAL
|
||||
Info(( "Got TERM signal, exiting" ));
|
||||
Info( "Got TERM signal, exiting" );
|
||||
#endif // HAVE_DECL_STRSIGNAL
|
||||
zm_terminate = true;
|
||||
}
|
||||
|
@ -74,10 +74,10 @@ RETSIGTYPE zm_die_handler( int signal )
|
|||
char* errorString =(char *)malloc(errorStringSize+1); // plus 1 for termination char.
|
||||
snprintf(errorString, errorStringSize, "Got signal (%s), crashing.", error );
|
||||
|
||||
Error(( (const char *)errorString ));
|
||||
Error( (const char *)errorString );
|
||||
free(errorString);
|
||||
#else // HAVE_DECL_STRSIGNAL
|
||||
Error(( "Got signal %d, crashing", signal ));
|
||||
Error( "Got signal %d, crashing", signal );
|
||||
#endif // HAVE_DECL_STRSIGNAL
|
||||
|
||||
#ifndef ZM_NO_CRASHTRACE
|
||||
|
@ -86,13 +86,13 @@ RETSIGTYPE zm_die_handler( int signal )
|
|||
int trace_size = 0;
|
||||
|
||||
#if HAVE_STRUCT_SIGCONTEXT_EIP
|
||||
Error(( "Signal address is %p, from %p\n", (void *)context.cr2, (void *)context.eip ));
|
||||
Error( "Signal address is %p, from %p\n", (void *)context.cr2, (void *)context.eip );
|
||||
|
||||
trace_size = backtrace( trace, 16 );
|
||||
// overwrite sigaction with caller's address
|
||||
trace[1] = (void *)context.eip;
|
||||
#elif HAVE_STRUCT_SIGCONTEXT
|
||||
Error(( "Signal address is %p, no eip\n", context.cr2 ));
|
||||
Error( "Signal address is %p, no eip\n", context.cr2 );
|
||||
|
||||
trace_size = backtrace( trace, 16 );
|
||||
#else // HAVE_STRUCT_SIGCONTEXT
|
||||
|
@ -100,7 +100,7 @@ RETSIGTYPE zm_die_handler( int signal )
|
|||
{
|
||||
ucontext_t *uc = (ucontext_t *)context;
|
||||
|
||||
Error(( "Signal address is %p, from %p\n", info->si_addr, uc->uc_mcontext.gregs[REG_EIP] ));
|
||||
Error( "Signal address is %p, from %p\n", info->si_addr, uc->uc_mcontext.gregs[REG_EIP] );
|
||||
|
||||
trace_size = backtrace( trace, 16 );
|
||||
// overwrite sigaction with caller's address
|
||||
|
@ -113,8 +113,8 @@ RETSIGTYPE zm_die_handler( int signal )
|
|||
messages = backtrace_symbols( trace, trace_size );
|
||||
// skip first stack frame (points here)
|
||||
for ( int i=1; i < trace_size; ++i )
|
||||
Error(( "Backtrace: %s", messages[i] ));
|
||||
Info(( "Backtrace complete" ));
|
||||
Error( "Backtrace: %s", messages[i] );
|
||||
Info( "Backtrace complete" );
|
||||
#endif // HAVE_DECL_BACKTRACE
|
||||
#endif // ( HAVE_SIGINFO_T && HAVE_UCONTEXT_T ) || HAVE_STRUCT_SIGCONTEXT
|
||||
#endif // ZM_NO_CRASHTRACE
|
||||
|
|
|
@ -34,7 +34,7 @@ bool StreamBase::loadMonitor( int monitor_id )
|
|||
{
|
||||
if ( !(monitor = Monitor::Load( monitor_id, false, Monitor::QUERY )) )
|
||||
{
|
||||
Fatal(( "Unable to load monitor id %d for streaming", monitor_id ));
|
||||
Fatal( "Unable to load monitor id %d for streaming", monitor_id );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -44,7 +44,7 @@ bool StreamBase::checkInitialised()
|
|||
{
|
||||
if ( !monitor )
|
||||
{
|
||||
Fatal(( "Cannot stream, not initialised" ));
|
||||
Fatal( "Cannot stream, not initialised" );
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -55,14 +55,14 @@ void StreamBase::updateFrameRate( double fps )
|
|||
base_fps = (int)(fps);
|
||||
effective_fps = (base_fps*abs(replay_rate))/ZM_RATE_BASE;
|
||||
frame_mod = 1;
|
||||
Debug( 3, ( "FPS:%.2f, MXFPS:%d, BFPS:%d, EFPS:%d, FM:%d", fps, maxfps, base_fps, effective_fps, frame_mod ));
|
||||
Debug( 3, "FPS:%.2f, MXFPS:%d, BFPS:%d, EFPS:%d, FM:%d", fps, maxfps, base_fps, effective_fps, frame_mod );
|
||||
// Min frame repeat?
|
||||
while( effective_fps > maxfps )
|
||||
{
|
||||
effective_fps /= 2;
|
||||
frame_mod *= 2;
|
||||
}
|
||||
Debug( 3, ( "aEFPS:%d, aFM:%d", effective_fps, frame_mod ));
|
||||
Debug( 3, "aEFPS:%d, aFM:%d", effective_fps, frame_mod );
|
||||
}
|
||||
|
||||
bool StreamBase::checkCommandQueue()
|
||||
|
@ -76,12 +76,12 @@ bool StreamBase::checkCommandQueue()
|
|||
{
|
||||
if ( errno != EAGAIN )
|
||||
{
|
||||
Fatal(( "recvfrom(), errno = %d, error = %s", errno, strerror(errno) ));
|
||||
Fatal( "recvfrom(), errno = %d, error = %s", errno, strerror(errno) );
|
||||
}
|
||||
}
|
||||
//else if ( (nbytes != sizeof(msg)) )
|
||||
//{
|
||||
//Error(( "Partial message received, expected %d bytes, got %d", sizeof(msg), nbytes ));
|
||||
//Error( "Partial message received, expected %d bytes, got %d", sizeof(msg), nbytes );
|
||||
//}
|
||||
else
|
||||
{
|
||||
|
@ -108,42 +108,42 @@ Image *StreamBase::prepareImage( Image *image )
|
|||
|
||||
int mag = (scale * zoom) / ZM_SCALE_BASE;
|
||||
int act_mag = mag > ZM_SCALE_BASE?ZM_SCALE_BASE:mag;
|
||||
Debug( 3, ( "Scaling by %d, zooming by %d = magnifying by %d(%d)", scale, zoom, mag, act_mag ));
|
||||
Debug( 3, "Scaling by %d, zooming by %d = magnifying by %d(%d)", scale, zoom, mag, act_mag );
|
||||
|
||||
int last_mag = (last_scale * last_zoom) / ZM_SCALE_BASE;
|
||||
int last_act_mag = last_mag > ZM_SCALE_BASE?ZM_SCALE_BASE:last_mag;
|
||||
Debug( 3, ( "Last scaling by %d, zooming by %d = magnifying by %d(%d)", last_scale, last_zoom, last_mag, last_act_mag ));
|
||||
Debug( 3, "Last scaling by %d, zooming by %d = magnifying by %d(%d)", last_scale, last_zoom, last_mag, last_act_mag );
|
||||
|
||||
int base_image_width = image->Width(), base_image_height = image->Height();
|
||||
Debug( 3, ( "Base image width = %d, height = %d", base_image_width, base_image_height ));
|
||||
Debug( 3, "Base image width = %d, height = %d", base_image_width, base_image_height );
|
||||
|
||||
int virt_image_width = (base_image_width * mag) / ZM_SCALE_BASE, virt_image_height = (base_image_height * mag) / ZM_SCALE_BASE;
|
||||
Debug( 3, ( "Virtual image width = %d, height = %d", virt_image_width, virt_image_height ));
|
||||
Debug( 3, "Virtual image width = %d, height = %d", virt_image_width, virt_image_height );
|
||||
|
||||
int last_virt_image_width = (base_image_width * last_mag) / ZM_SCALE_BASE, last_virt_image_height = (base_image_height * last_mag) / ZM_SCALE_BASE;
|
||||
Debug( 3, ( "Last virtual image width = %d, height = %d", last_virt_image_width, last_virt_image_height ));
|
||||
Debug( 3, "Last virtual image width = %d, height = %d", last_virt_image_width, last_virt_image_height );
|
||||
|
||||
int act_image_width = (base_image_width * act_mag ) / ZM_SCALE_BASE, act_image_height = (base_image_height * act_mag ) / ZM_SCALE_BASE;
|
||||
Debug( 3, ( "Actual image width = %d, height = %d", act_image_width, act_image_height ));
|
||||
Debug( 3, "Actual image width = %d, height = %d", act_image_width, act_image_height );
|
||||
|
||||
int last_act_image_width = (base_image_width * last_act_mag ) / ZM_SCALE_BASE, last_act_image_height = (base_image_height * last_act_mag ) / ZM_SCALE_BASE;
|
||||
Debug( 3, ( "Last actual image width = %d, height = %d", last_act_image_width, last_act_image_height ));
|
||||
Debug( 3, "Last actual image width = %d, height = %d", last_act_image_width, last_act_image_height );
|
||||
|
||||
int disp_image_width = (image->Width() * scale) / ZM_SCALE_BASE, disp_image_height = (image->Height() * scale) / ZM_SCALE_BASE;
|
||||
Debug( 3, ( "Display image width = %d, height = %d", disp_image_width, disp_image_height ));
|
||||
Debug( 3, "Display image width = %d, height = %d", disp_image_width, disp_image_height );
|
||||
|
||||
int last_disp_image_width = (image->Width() * last_scale) / ZM_SCALE_BASE, last_disp_image_height = (image->Height() * last_scale) / ZM_SCALE_BASE;
|
||||
Debug( 3, ( "Last display image width = %d, height = %d", last_disp_image_width, last_disp_image_height ));
|
||||
Debug( 3, "Last display image width = %d, height = %d", last_disp_image_width, last_disp_image_height );
|
||||
|
||||
int send_image_width = (disp_image_width * act_mag ) / mag, send_image_height = (disp_image_height * act_mag ) / mag;
|
||||
Debug( 3, ( "Send image width = %d, height = %d", send_image_width, send_image_height ));
|
||||
Debug( 3, "Send image width = %d, height = %d", send_image_width, send_image_height );
|
||||
|
||||
int last_send_image_width = (last_disp_image_width * last_act_mag ) / last_mag, last_send_image_height = (last_disp_image_height * last_act_mag ) / last_mag;
|
||||
Debug( 3, ( "Last send image width = %d, height = %d", last_send_image_width, last_send_image_height ));
|
||||
Debug( 3, "Last send image width = %d, height = %d", last_send_image_width, last_send_image_height );
|
||||
|
||||
if ( mag != ZM_SCALE_BASE )
|
||||
{
|
||||
Debug( 3, ( "Magnifying by %d", mag ));
|
||||
Debug( 3, "Magnifying by %d", mag );
|
||||
if ( act_mag < ZM_SCALE_BASE )
|
||||
{
|
||||
if ( !image_copied )
|
||||
|
@ -157,11 +157,11 @@ Image *StreamBase::prepareImage( Image *image )
|
|||
}
|
||||
}
|
||||
|
||||
Debug( 3, ( "Real image width = %d, height = %d", image->Width(), image->Height() ));
|
||||
Debug( 3, "Real image width = %d, height = %d", image->Width(), image->Height() );
|
||||
|
||||
if ( disp_image_width < virt_image_width || disp_image_height < virt_image_height )
|
||||
{
|
||||
Debug( 3, ( "Got click at %d,%d", x, y ));
|
||||
Debug( 3, "Got click at %d,%d", x, y );
|
||||
static Box last_crop;
|
||||
|
||||
if ( mag != last_mag || x != last_x || y != last_y )
|
||||
|
@ -172,18 +172,18 @@ Image *StreamBase::prepareImage( Image *image )
|
|||
if ( !(last_disp_image_width < last_virt_image_width || last_disp_image_height < last_virt_image_height) )
|
||||
last_crop = Box();
|
||||
|
||||
Debug( 3, ( "Recalculating crop" ));
|
||||
Debug( 3, "Recalculating crop" );
|
||||
// Recalculate crop parameters, as %ges
|
||||
int click_x = (last_crop.LoX() * 100 ) / last_act_image_width; // Initial crop offset from last image
|
||||
click_x += ( x * 100 ) / last_virt_image_width;
|
||||
int click_y = (last_crop.LoY() * 100 ) / last_act_image_height; // Initial crop offset from last image
|
||||
click_y += ( y * 100 ) / last_virt_image_height;
|
||||
Debug( 3, ( "Got adjusted click at %d%%,%d%%", click_x, click_y ));
|
||||
Debug( 3, "Got adjusted click at %d%%,%d%%", click_x, click_y );
|
||||
|
||||
// Convert the click locations to the current image pixels
|
||||
click_x = ( click_x * act_image_width ) / 100;
|
||||
click_y = ( click_y * act_image_height ) / 100;
|
||||
Debug( 3, ( "Got readjusted click at %d,%d", click_x, click_y ));
|
||||
Debug( 3, "Got readjusted click at %d,%d", click_x, click_y );
|
||||
|
||||
int lo_x = click_x - (send_image_width/2);
|
||||
if ( lo_x < 0 )
|
||||
|
@ -206,7 +206,7 @@ Image *StreamBase::prepareImage( Image *image )
|
|||
}
|
||||
last_crop = Box( lo_x, lo_y, hi_x, hi_y );
|
||||
}
|
||||
Debug( 3, ( "Cropping to %d,%d -> %d,%d", last_crop.LoX(), last_crop.LoY(), last_crop.HiX(), last_crop.HiY() ));
|
||||
Debug( 3, "Cropping to %d,%d -> %d,%d", last_crop.LoX(), last_crop.LoY(), last_crop.HiX(), last_crop.HiY() );
|
||||
if ( !image_copied )
|
||||
{
|
||||
static Image copy_image;
|
||||
|
@ -226,7 +226,7 @@ Image *StreamBase::prepareImage( Image *image )
|
|||
|
||||
void StreamBase::sendTextFrame( const char *frame_text )
|
||||
{
|
||||
Debug( 2, ( "Sending text frame '%s'", frame_text ));
|
||||
Debug( 2, "Sending text frame '%s'", frame_text );
|
||||
|
||||
Image image( monitor->Width(), monitor->Height(), monitor->Colours() );
|
||||
image.Annotate( frame_text, image.centreCoord( frame_text ) );
|
||||
|
@ -271,7 +271,7 @@ void StreamBase::openComms()
|
|||
sd = socket( AF_UNIX, SOCK_DGRAM, 0 );
|
||||
if ( sd < 0 )
|
||||
{
|
||||
Fatal(( "Can't create socket: %s", strerror(errno) ));
|
||||
Fatal( "Can't create socket: %s", strerror(errno) );
|
||||
}
|
||||
|
||||
snprintf( loc_sock_path, sizeof(loc_sock_path), "%s/zms-%06ds.sock", config.path_socks, connkey );
|
||||
|
@ -281,7 +281,7 @@ void StreamBase::openComms()
|
|||
loc_addr.sun_family = AF_UNIX;
|
||||
if ( bind( sd, (struct sockaddr *)&loc_addr, strlen(loc_addr.sun_path)+sizeof(loc_addr.sun_family)) < 0 )
|
||||
{
|
||||
Fatal(( "Can't bind: %s", strerror(errno) ));
|
||||
Fatal( "Can't bind: %s", strerror(errno) );
|
||||
}
|
||||
|
||||
snprintf( rem_sock_path, sizeof(rem_sock_path), "%s/zms-%06dw.sock", config.path_socks, connkey );
|
||||
|
|
|
@ -116,28 +116,28 @@ User *zmLoadUser( const char *username, const char *password )
|
|||
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
int n_users = mysql_num_rows( result );
|
||||
|
||||
if ( n_users != 1 )
|
||||
{
|
||||
Warning(( "Unable to authenticate user %s", username ));
|
||||
Warning( "Unable to authenticate user %s", username );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MYSQL_ROW dbrow = mysql_fetch_row( result );
|
||||
|
||||
User *user = new User( dbrow );
|
||||
Info(( "Authenticated user '%s'", user->getUsername() ));
|
||||
Info( "Authenticated user '%s'", user->getUsername() );
|
||||
|
||||
mysql_free_result( result );
|
||||
|
||||
|
@ -154,32 +154,32 @@ User *zmLoadAuthUser( const char *auth, bool use_remote_addr )
|
|||
remote_addr = getenv( "REMOTE_ADDR" );
|
||||
if ( !remote_addr )
|
||||
{
|
||||
Warning(( "Can't determine remote address, using null" ));
|
||||
Warning( "Can't determine remote address, using null" );
|
||||
remote_addr = "";
|
||||
}
|
||||
}
|
||||
|
||||
Debug( 1, ( "Attempting to authenticate user from auth string '%s'", auth ));
|
||||
Debug( 1, "Attempting to authenticate user from auth string '%s'", auth );
|
||||
char sql[BUFSIZ] = "";
|
||||
snprintf( sql, sizeof(sql), "select Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds from Users where Enabled = 1" );
|
||||
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
int n_users = mysql_num_rows( result );
|
||||
|
||||
if ( n_users < 1 )
|
||||
{
|
||||
Warning(( "Unable to authenticate user" ));
|
||||
Warning( "Unable to authenticate user" );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
@ -216,19 +216,19 @@ User *zmLoadAuthUser( const char *auth, bool use_remote_addr )
|
|||
{
|
||||
sprintf( &auth_md5[2*j], "%02x", md5sum[j] );
|
||||
}
|
||||
Debug( 1, ( "Checking auth_key '%s' -> auth_md5 '%s'", auth_key, auth_md5 ));
|
||||
Debug( 1, "Checking auth_key '%s' -> auth_md5 '%s'", auth_key, auth_md5 );
|
||||
|
||||
if ( !strcmp( auth, auth_md5 ) )
|
||||
{
|
||||
// We have a match
|
||||
User *user = new User( dbrow );
|
||||
Info(( "Authenticated user '%s'", user->getUsername() ));
|
||||
Info( "Authenticated user '%s'", user->getUsername() );
|
||||
return( user );
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // HAVE_DECL_MD5
|
||||
Error(( "You need to build with gnutls or openssl installed to use hash based authentication" ));
|
||||
Error( "You need to build with gnutls or openssl installed to use hash based authentication" );
|
||||
#endif // HAVE_DECL_MD5
|
||||
return( 0 );
|
||||
}
|
||||
|
|
114
src/zm_zone.cpp
114
src/zm_zone.cpp
|
@ -47,7 +47,7 @@ void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_
|
|||
max_blobs = p_max_blobs;
|
||||
overload_frames = p_overload_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", 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 ));
|
||||
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", 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 );
|
||||
|
||||
alarmed = false;
|
||||
pixel_diff = 0;
|
||||
|
@ -108,7 +108,7 @@ void Zone::RecordStats( const Event *event )
|
|||
snprintf( sql, sizeof(sql), "insert into Stats set MonitorId=%d, ZoneId=%d, EventId=%d, FrameId=%d, PixelDiff=%d, AlarmPixels=%d, FilterPixels=%d, BlobPixels=%d, Blobs=%d, MinBlobSize=%d, MaxBlobSize=%d, MinX=%d, MinY=%d, MaxX=%d, MaxY=%d, Score=%d", monitor->Id(), id, event->Id(), event->Frames()+1, pixel_diff, alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, min_blob_size, max_blob_size, alarm_box.LoX(), alarm_box.LoY(), alarm_box.HiX(), alarm_box.HiY(), score );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't insert event stats: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't insert event stats: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
}
|
||||
|
@ -121,8 +121,8 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
|
||||
if ( overload_count )
|
||||
{
|
||||
Info(( "In overload mode, %d frames of %d remaining", overload_count, overload_frames ));
|
||||
Debug( 4, ( "In overload mode, %d frames of %d remaining", overload_count, overload_frames ));
|
||||
Info( "In overload mode, %d frames of %d remaining", overload_count, overload_frames );
|
||||
Debug( 4, "In overload mode, %d frames of %d remaining", overload_count, overload_frames );
|
||||
overload_count--;
|
||||
return( false );
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
int lo_x;
|
||||
int hi_x;
|
||||
|
||||
Debug( 4, ( "Checking alarms for zone %d/%s in lines %d -> %d", id, label, lo_y, hi_y ));
|
||||
Debug( 4, "Checking alarms for zone %d/%s in lines %d -> %d", id, label, lo_y, hi_y );
|
||||
|
||||
Debug( 5, ( "Checking for alarmed pixels" ));
|
||||
Debug( 5, "Checking for alarmed pixels" );
|
||||
unsigned char *pdiff, *ppoly;
|
||||
// Create an upper margin
|
||||
if ( lo_y > 0 )
|
||||
|
@ -168,7 +168,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
lo_x = ranges[py].lo_x;
|
||||
hi_x = ranges[py].hi_x;
|
||||
|
||||
Debug( 7, ( "Checking line %d from %d -> %d", y, lo_x, hi_x ));
|
||||
Debug( 7, "Checking line %d from %d -> %d", y, lo_x, hi_x );
|
||||
pdiff = diff_image->Buffer( lo_x, y );
|
||||
ppoly = pg_image->Buffer( ranges[py].off_x, py );
|
||||
// Left margin
|
||||
|
@ -211,7 +211,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
}
|
||||
if ( pixel_diff_count && alarm_pixels )
|
||||
pixel_diff = pixel_diff_count/alarm_pixels;
|
||||
Debug( 5, ( "Got %d alarmed pixels, need %d -> %d, avg pixel diff %d", alarm_pixels, min_alarm_pixels, max_alarm_pixels, pixel_diff ));
|
||||
Debug( 5, "Got %d alarmed pixels, need %d -> %d, avg pixel diff %d", alarm_pixels, min_alarm_pixels, max_alarm_pixels, pixel_diff );
|
||||
if ( config.record_diag_images )
|
||||
{
|
||||
static char diag_path[PATH_MAX] = "";
|
||||
|
@ -236,7 +236,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
return( false );
|
||||
}
|
||||
score = (100*alarm_pixels)/polygon.Area();
|
||||
Debug( 5, ( "Current score is %d", score ));
|
||||
Debug( 5, "Current score is %d", score );
|
||||
|
||||
if ( check_method >= FILTERED_PIXELS )
|
||||
{
|
||||
|
@ -245,7 +245,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
int bx1 = bx-1;
|
||||
int by1 = by-1;
|
||||
|
||||
Debug( 5, ( "Checking for filtered pixels" ));
|
||||
Debug( 5, "Checking for filtered pixels" );
|
||||
if ( bx > 1 || by > 1 )
|
||||
{
|
||||
// Now remove any pixels smaller than our filter size
|
||||
|
@ -311,7 +311,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
}
|
||||
diff_image->WriteJpeg( diag_path );
|
||||
}
|
||||
Debug( 5, ( "Got %d filtered pixels, need %d -> %d", alarm_filter_pixels, min_filter_pixels, max_filter_pixels ));
|
||||
Debug( 5, "Got %d filtered pixels, need %d -> %d", alarm_filter_pixels, min_filter_pixels, max_filter_pixels );
|
||||
|
||||
if ( !alarm_filter_pixels )
|
||||
{
|
||||
|
@ -328,11 +328,11 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
}
|
||||
|
||||
score = (100*alarm_filter_pixels)/(polygon.Area());
|
||||
Debug( 5, ( "Current score is %d", score ));
|
||||
Debug( 5, "Current score is %d", score );
|
||||
|
||||
if ( check_method >= BLOBS )
|
||||
{
|
||||
Debug( 5, ( "Checking for blob pixels" ));
|
||||
Debug( 5, "Checking for blob pixels" );
|
||||
typedef struct { unsigned char tag; int count; int lo_x; int hi_x; int lo_y; int hi_y; } BlobStats;
|
||||
BlobStats blob_stats[256];
|
||||
memset( blob_stats, 0, sizeof(BlobStats)*256 );
|
||||
|
@ -350,7 +350,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
{
|
||||
if ( *pdiff == WHITE )
|
||||
{
|
||||
Debug( 9, ( "Got white pixel at %d,%d (%p)", x, y, pdiff ));
|
||||
Debug( 9, "Got white pixel at %d,%d (%p)", x, y, pdiff );
|
||||
//last_x = (x>lo_x)?*(pdiff-1):0;
|
||||
//last_y = (y>lo_y&&x>=last_lo_x&&x<=last_hi_x)?*(pdiff-diff_width):0;
|
||||
last_x = x>0?*(pdiff-1):0;
|
||||
|
@ -358,15 +358,15 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
|
||||
if ( last_x )
|
||||
{
|
||||
Debug( 9, ( "Left neighbour is %d", last_x ));
|
||||
Debug( 9, "Left neighbour is %d", last_x );
|
||||
bsx = &blob_stats[last_x];
|
||||
if ( last_y )
|
||||
{
|
||||
Debug( 9, ( "Top neighbour is %d", last_y ));
|
||||
Debug( 9, "Top neighbour is %d", last_y );
|
||||
bsy = &blob_stats[last_y];
|
||||
if ( last_x == last_y )
|
||||
{
|
||||
Debug( 9, ( "Matching neighbours, setting to %d", last_x ));
|
||||
Debug( 9, "Matching neighbours, setting to %d", last_x );
|
||||
// Add to the blob from the x side (either side really)
|
||||
*pdiff = last_x;
|
||||
bsx->count++;
|
||||
|
@ -379,9 +379,9 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
bsm = bsx->count>=bsy->count?bsx:bsy;
|
||||
bss = bsm==bsx?bsy:bsx;
|
||||
|
||||
Debug( 9, ( "Different neighbours, setting pixels of %d to %d", bss->tag, bsm->tag ));
|
||||
Debug( 9, ( "Master blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bsm->tag, bsm->count, bsm->lo_x, bsm->hi_x, bsm->lo_y, bsm->hi_y ));
|
||||
Debug( 9, ( "Slave blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bss->tag, bss->count, bss->lo_x, bss->hi_x, bss->lo_y, bss->hi_y ));
|
||||
Debug( 9, "Different neighbours, setting pixels of %d to %d", bss->tag, bsm->tag );
|
||||
Debug( 9, "Master blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bsm->tag, bsm->count, bsm->lo_x, bsm->hi_x, bsm->lo_y, bsm->hi_y );
|
||||
Debug( 9, "Slave blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bss->tag, bss->count, bss->lo_x, bss->hi_x, bss->lo_y, bss->hi_y );
|
||||
// Now change all those pixels to the other setting
|
||||
int changed = 0;
|
||||
for ( int sy = bss->lo_y, psy = bss->lo_y-lo_y; sy <= bss->hi_y; sy++, psy++ )
|
||||
|
@ -389,15 +389,15 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
int lo_sx = bss->lo_x>=ranges[psy].lo_x?bss->lo_x:ranges[psy].lo_x;
|
||||
int hi_sx = bss->hi_x<=ranges[psy].hi_x?bss->hi_x:ranges[psy].hi_x;
|
||||
|
||||
Debug( 9, ( "Changing %d(%d), %d->%d", sy, psy, lo_sx, hi_sx ));
|
||||
Debug( 9, ( "Range %d(%d), %d->%d", sy, psy, ranges[psy].lo_x, ranges[psy].hi_x ));
|
||||
Debug( 9, "Changing %d(%d), %d->%d", sy, psy, lo_sx, hi_sx );
|
||||
Debug( 9, "Range %d(%d), %d->%d", sy, psy, ranges[psy].lo_x, ranges[psy].hi_x );
|
||||
spdiff = diff_image->Buffer( lo_sx, sy );
|
||||
for ( int sx = lo_sx; sx <= hi_sx; sx++, spdiff++ )
|
||||
{
|
||||
Debug( 9, ( "Pixel at %d,%d (%p) is %d", sx, sy, spdiff, *spdiff ));
|
||||
Debug( 9, "Pixel at %d,%d (%p) is %d", sx, sy, spdiff, *spdiff );
|
||||
if ( *spdiff == bss->tag )
|
||||
{
|
||||
Debug( 9, ( "Setting pixel" ));
|
||||
Debug( 9, "Setting pixel" );
|
||||
*spdiff = bsm->tag;
|
||||
changed++;
|
||||
}
|
||||
|
@ -406,9 +406,9 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
*pdiff = bsm->tag;
|
||||
if ( !changed )
|
||||
{
|
||||
Info(( "Master blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bsm->tag, bsm->count, bsm->lo_x, bsm->hi_x, bsm->lo_y, bsm->hi_y ));
|
||||
Info(( "Slave blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bss->tag, bss->count, bss->lo_x, bss->hi_x, bss->lo_y, bss->hi_y ));
|
||||
Error(( "No pixels changed, exiting" ));
|
||||
Info( "Master blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bsm->tag, bsm->count, bsm->lo_x, bsm->hi_x, bsm->lo_y, bsm->hi_y );
|
||||
Info( "Slave blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bss->tag, bss->count, bss->lo_x, bss->hi_x, bss->lo_y, bss->hi_y );
|
||||
Error( "No pixels changed, exiting" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
|
||||
alarm_blobs--;
|
||||
|
||||
Debug( 6, ( "Merging blob %d with %d at %d,%d, %d current blobs", bss->tag, bsm->tag, x, y, alarm_blobs ));
|
||||
Debug( 6, "Merging blob %d with %d at %d,%d, %d current blobs", bss->tag, bsm->tag, x, y, alarm_blobs );
|
||||
|
||||
// Clear out the old blob
|
||||
bss->tag = 0;
|
||||
|
@ -436,7 +436,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug( 9, ( "Setting to left neighbour %d", last_x ));
|
||||
Debug( 9, "Setting to left neighbour %d", last_x );
|
||||
// Add to the blob from the x side
|
||||
*pdiff = last_x;
|
||||
bsx->count++;
|
||||
|
@ -448,7 +448,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
{
|
||||
if ( last_y )
|
||||
{
|
||||
Debug( 9, ( "Setting to top neighbour %d", last_y ));
|
||||
Debug( 9, "Setting to top neighbour %d", last_y );
|
||||
|
||||
// Add to the blob from the y side
|
||||
BlobStats *bsy = &blob_stats[last_y];
|
||||
|
@ -487,7 +487,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
alarm_blobs--;
|
||||
alarm_blob_pixels -= bs->count;
|
||||
|
||||
Debug( 6, ( "Eliminated blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs ));
|
||||
Debug( 6, "Eliminated blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs );
|
||||
|
||||
bs->tag = 0;
|
||||
bs->count = 0;
|
||||
|
@ -499,7 +499,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
}
|
||||
if ( !bs->count )
|
||||
{
|
||||
Debug( 9, ( "Creating new blob %d", i ));
|
||||
Debug( 9, "Creating new blob %d", i );
|
||||
*pdiff = i;
|
||||
bs->tag = i;
|
||||
bs->count++;
|
||||
|
@ -507,13 +507,13 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
bs->lo_y = bs->hi_y = y;
|
||||
alarm_blobs++;
|
||||
|
||||
Debug( 6, ( "Created blob %d at %d,%d, %d current blobs", bs->tag, x, y, alarm_blobs ));
|
||||
Debug( 6, "Created blob %d at %d,%d, %d current blobs", bs->tag, x, y, alarm_blobs );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == 0 )
|
||||
{
|
||||
Warning(( "Max blob count reached. Unable to allocate new blobs so terminating. Zone settings may be too sensitive." ));
|
||||
Warning( "Max blob count reached. Unable to allocate new blobs so terminating. Zone settings may be too sensitive." );
|
||||
x = hi_x+1;
|
||||
y = hi_y+1;
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
return( false );
|
||||
}
|
||||
alarm_blob_pixels = alarm_filter_pixels;
|
||||
Debug( 5, ( "Got %d raw blob pixels, %d raw blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs ));
|
||||
Debug( 5, "Got %d raw blob pixels, %d raw blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs );
|
||||
|
||||
// Now eliminate blobs under the threshold
|
||||
for ( int i = 1; i < WHITE; i++ )
|
||||
|
@ -564,7 +564,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
alarm_blobs--;
|
||||
alarm_blob_pixels -= bs->count;
|
||||
|
||||
Debug( 6, ( "Eliminated blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs ));
|
||||
Debug( 6, "Eliminated blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs );
|
||||
|
||||
bs->tag = 0;
|
||||
bs->count = 0;
|
||||
|
@ -575,7 +575,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug( 6, ( "Preserved blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs ));
|
||||
Debug( 6, "Preserved blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs );
|
||||
if ( !min_blob_size || bs->count < min_blob_size ) min_blob_size = bs->count;
|
||||
if ( !max_blob_size || bs->count > max_blob_size ) max_blob_size = bs->count;
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
}
|
||||
diff_image->WriteJpeg( diag_path );
|
||||
}
|
||||
Debug( 5, ( "Got %d blob pixels, %d blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs ));
|
||||
Debug( 5, "Got %d blob pixels, %d blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs );
|
||||
|
||||
if ( !alarm_blobs )
|
||||
{
|
||||
|
@ -651,7 +651,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
}
|
||||
}
|
||||
score = ((100*alarm_blob_pixels)/int(sqrt((double)alarm_blobs)))/(polygon.Area());
|
||||
Debug( 5, ( "Current score is %d", score ));
|
||||
Debug( 5, "Current score is %d", score );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -669,7 +669,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
score *= 2;
|
||||
}
|
||||
|
||||
Debug( 5, ( "Adjusted score is %d", score ));
|
||||
Debug( 5, "Adjusted score is %d", score );
|
||||
|
||||
// Now outline the changed region
|
||||
if ( score )
|
||||
|
@ -748,14 +748,14 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
|||
image = 0;
|
||||
}
|
||||
|
||||
Debug( 1, ( "%s: Pixel Diff: %d, Alarm Pixels: %d, Filter Pixels: %d, Blob Pixels: %d, Blobs: %d, Score: %d", Label(), pixel_diff, alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, score ));
|
||||
Debug( 1, "%s: Pixel Diff: %d, Alarm Pixels: %d, Filter Pixels: %d, Blob Pixels: %d, Blobs: %d, Score: %d", Label(), pixel_diff, alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, score );
|
||||
}
|
||||
return( true );
|
||||
}
|
||||
|
||||
bool Zone::ParsePolygonString( const char *poly_string, Polygon &polygon )
|
||||
{
|
||||
Debug( 3, ( "Parsing polygon string '%s'", poly_string ));
|
||||
Debug( 3, "Parsing polygon string '%s'", poly_string );
|
||||
|
||||
char *str_ptr = new char[strlen(poly_string)+1];
|
||||
char *str = str_ptr;
|
||||
|
@ -779,7 +779,7 @@ bool Zone::ParsePolygonString( const char *poly_string, Polygon &polygon )
|
|||
char *cp = strchr( str, ',' );
|
||||
if ( !cp )
|
||||
{
|
||||
Error(( "Bogus coordinate %s found in polygon string", str ));
|
||||
Error( "Bogus coordinate %s found in polygon string", str );
|
||||
delete[] coords;
|
||||
delete[] str_ptr;
|
||||
return( false );
|
||||
|
@ -793,7 +793,7 @@ bool Zone::ParsePolygonString( const char *poly_string, Polygon &polygon )
|
|||
int x = atoi(xp);
|
||||
int y = atoi(yp);
|
||||
|
||||
Debug( 3, ( "Got coordinate %d,%d from polygon string", x, y ));
|
||||
Debug( 3, "Got coordinate %d,%d from polygon string", x, y );
|
||||
#if 0
|
||||
if ( x < 0 )
|
||||
x = 0;
|
||||
|
@ -813,7 +813,7 @@ bool Zone::ParsePolygonString( const char *poly_string, Polygon &polygon )
|
|||
}
|
||||
polygon = Polygon( n_coords, coords );
|
||||
|
||||
Debug( 3, ( "Successfully parsed polygon string" ));
|
||||
Debug( 3, "Successfully parsed polygon string" );
|
||||
//printf( "Area: %d\n", pg.Area() );
|
||||
//printf( "Centre: %d,%d\n", pg.Centre().X(), pg.Centre().Y() );
|
||||
|
||||
|
@ -825,7 +825,7 @@ bool Zone::ParsePolygonString( const char *poly_string, Polygon &polygon )
|
|||
|
||||
bool Zone::ParseZoneString( const char *zone_string, int &zone_id, int &colour, Polygon &polygon )
|
||||
{
|
||||
Debug( 3, ( "Parsing zone string '%s'", zone_string ));
|
||||
Debug( 3, "Parsing zone string '%s'", zone_string );
|
||||
|
||||
char *str_ptr = new char[strlen(zone_string)+1];
|
||||
char *str = str_ptr;
|
||||
|
@ -834,10 +834,10 @@ bool Zone::ParseZoneString( const char *zone_string, int &zone_id, int &colour,
|
|||
char *ws = strchr( str, ' ' );
|
||||
if ( !ws )
|
||||
{
|
||||
Debug( 3, ( "No whitespace found in zone string '%s', finishing", zone_string ));
|
||||
Debug( 3, "No whitespace found in zone string '%s', finishing", zone_string );
|
||||
}
|
||||
zone_id = strtol( str, 0, 10 );
|
||||
Debug( 3, ( "Got zone %d from zone string", zone_id ));
|
||||
Debug( 3, "Got zone %d from zone string", zone_id );
|
||||
if ( !ws )
|
||||
{
|
||||
delete str_ptr;
|
||||
|
@ -850,13 +850,13 @@ bool Zone::ParseZoneString( const char *zone_string, int &zone_id, int &colour,
|
|||
ws = strchr( str, ' ' );
|
||||
if ( !ws )
|
||||
{
|
||||
Error(( "No whitespace found in zone string '%s'", zone_string ));
|
||||
Error( "No whitespace found in zone string '%s'", zone_string );
|
||||
delete[] str_ptr;
|
||||
return( false );
|
||||
}
|
||||
*ws = '\0';
|
||||
colour = strtol( str, 0, 16 );
|
||||
Debug( 3, ( "Got colour %06x from zone string", colour ));
|
||||
Debug( 3, "Got colour %06x from zone string", colour );
|
||||
str = ws+1;
|
||||
|
||||
bool result = ParsePolygonString( str, polygon );
|
||||
|
@ -875,18 +875,18 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
|||
snprintf( sql, sizeof(sql), "select Id,Name,Type+0,Units,NumCoords,Coords,AlarmRGB,CheckMethod+0,MinPixelThreshold,MaxPixelThreshold,MinAlarmPixels,MaxAlarmPixels,FilterX,FilterY,MinFilterPixels,MaxFilterPixels,MinBlobPixels,MaxBlobPixels,MinBlobs,MaxBlobs,OverloadFrames from Zones where MonitorId = %d order by Type, Id", monitor->Id() );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
int n_zones = mysql_num_rows( result );
|
||||
Debug( 1, ( "Got %d zones for monitor %s", n_zones, monitor->Name() ));
|
||||
Debug( 1, "Got %d zones for monitor %s", n_zones, monitor->Name() );
|
||||
delete[] zones;
|
||||
zones = new Zone *[n_zones];
|
||||
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
||||
|
@ -915,13 +915,13 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
|||
int MaxBlobs = dbrow[col]?atoi(dbrow[col]):0; col++;
|
||||
int OverloadFrames = dbrow[col]?atoi(dbrow[col]):0; col++;
|
||||
|
||||
Debug( 5, ( "Parsing polygon %s", Coords ));
|
||||
Debug( 5, "Parsing polygon %s", Coords );
|
||||
Polygon polygon;
|
||||
if ( !ParsePolygonString( Coords, polygon ) )
|
||||
Fatal(( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s", Coords, Id, Name, monitor->Name() ));
|
||||
Fatal( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s", Coords, Id, Name, monitor->Name() );
|
||||
|
||||
if ( polygon.LoX() < 0 || polygon.HiX() >= monitor->Width() || polygon.LoY() < 0 || polygon.HiY() >= monitor->Height() )
|
||||
Fatal(( "Zone %d/%s for monitor %s extends outside of image dimensions", Id, Name, monitor->Name() ));
|
||||
Fatal( "Zone %d/%s for monitor %s extends outside of image dimensions", Id, Name, monitor->Name() );
|
||||
|
||||
if ( false && !strcmp( Units, "Percent" ) )
|
||||
{
|
||||
|
@ -944,7 +944,7 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
|||
}
|
||||
if ( mysql_errno( &dbconn ) )
|
||||
{
|
||||
Error(( "Can't fetch row: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't fetch row: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
// Yadda yadda
|
||||
|
|
|
@ -96,7 +96,7 @@ int main( int argc, char *argv[] )
|
|||
|
||||
if ( monitor )
|
||||
{
|
||||
Info(( "In mode %d/%d, warming up", monitor->GetFunction(), monitor->Enabled() ));
|
||||
Info( "In mode %d/%d, warming up", monitor->GetFunction(), monitor->Enabled() );
|
||||
|
||||
if ( config.opt_frame_server )
|
||||
{
|
||||
|
|
10
src/zmc.cpp
10
src/zmc.cpp
|
@ -176,11 +176,11 @@ int main( int argc, char *argv[] )
|
|||
|
||||
if ( !n_monitors )
|
||||
{
|
||||
Error(( "No monitors found" ));
|
||||
Error( "No monitors found" );
|
||||
exit ( -1 );
|
||||
}
|
||||
|
||||
Info(( "Starting Capture" ));
|
||||
Info( "Starting Capture" );
|
||||
|
||||
zmSetDefaultTermHandler();
|
||||
zmSetDefaultDieHandler();
|
||||
|
@ -193,7 +193,7 @@ int main( int argc, char *argv[] )
|
|||
|
||||
if ( monitors[0]->PrimeCapture() < 0 )
|
||||
{
|
||||
Error(( "Failed to prime capture of initial monitor" ));
|
||||
Error( "Failed to prime capture of initial monitor" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
@ -244,12 +244,12 @@ int main( int argc, char *argv[] )
|
|||
{
|
||||
if ( monitors[i]->PreCapture() < 0 )
|
||||
{
|
||||
Error(( "Failed to pre-capture monitor %d", i ));
|
||||
Error( "Failed to pre-capture monitor %d", i );
|
||||
exit( -1 );
|
||||
}
|
||||
if ( monitors[i]->PostCapture() < 0 )
|
||||
{
|
||||
Error(( "Failed to post-capture monitor %d", i ));
|
||||
Error( "Failed to post-capture monitor %d", i );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
|
|
36
src/zmf.cpp
36
src/zmf.cpp
|
@ -43,7 +43,7 @@ int OpenSocket( int monitor_id )
|
|||
int sd = socket( AF_UNIX, SOCK_STREAM, 0);
|
||||
if ( sd < 0 )
|
||||
{
|
||||
Error(( "Can't create socket: %s", strerror(errno) ));
|
||||
Error( "Can't create socket: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ int OpenSocket( int monitor_id )
|
|||
snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", config.path_socks, monitor_id );
|
||||
if ( unlink( sock_path ) < 0 )
|
||||
{
|
||||
Warning(( "Can't unlink '%s': %s", sock_path, strerror(errno) ));
|
||||
Warning( "Can't unlink '%s': %s", sock_path, strerror(errno) );
|
||||
}
|
||||
|
||||
struct sockaddr_un addr;
|
||||
|
@ -61,13 +61,13 @@ int OpenSocket( int monitor_id )
|
|||
|
||||
if ( bind( sd, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0 )
|
||||
{
|
||||
Error(( "Can't bind: %s", strerror(errno) ));
|
||||
Error( "Can't bind: %s", strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
if ( listen( sd, SOMAXCONN ) < 0 )
|
||||
{
|
||||
Error(( "Can't listen: %s", strerror(errno) ));
|
||||
Error( "Can't listen: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -76,14 +76,14 @@ int OpenSocket( int monitor_id )
|
|||
int new_sd = -1;
|
||||
if ( (new_sd = accept( sd, (struct sockaddr *)&rem_addr, &rem_addr_len )) < 0 )
|
||||
{
|
||||
Error(( "Can't accept: %s", strerror(errno) ));
|
||||
Error( "Can't accept: %s", strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
close( sd );
|
||||
|
||||
sd = new_sd;
|
||||
|
||||
Info(( "Frame server socket open, awaiting images" ));
|
||||
Info( "Frame server socket open, awaiting images" );
|
||||
return( sd );
|
||||
}
|
||||
|
||||
|
@ -197,12 +197,12 @@ int main( int argc, char *argv[] )
|
|||
int n_found = select( sd+1, &rfds, NULL, NULL, &temp_timeout );
|
||||
if( n_found == 0 )
|
||||
{
|
||||
Debug( 1, ( "Select timed out" ));
|
||||
Debug( 1, "Select timed out" );
|
||||
continue;
|
||||
}
|
||||
else if ( n_found < 0)
|
||||
{
|
||||
Error(( "Select error: %s", strerror(errno) ));
|
||||
Error( "Select error: %s", strerror(errno) );
|
||||
ReopenSocket( sd, monitor->Id() );
|
||||
continue;
|
||||
}
|
||||
|
@ -214,35 +214,35 @@ int main( int argc, char *argv[] )
|
|||
{
|
||||
if ( n_bytes < 0 )
|
||||
{
|
||||
Error(( "Can't read frame header: %s", strerror(errno) ));
|
||||
Error( "Can't read frame header: %s", strerror(errno) );
|
||||
}
|
||||
else if ( n_bytes > 0 )
|
||||
{
|
||||
Error(( "Incomplete read of frame header, %d bytes only", n_bytes ));
|
||||
Error( "Incomplete read of frame header, %d bytes only", n_bytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning(( "Socket closed at remote end" ));
|
||||
Warning( "Socket closed at remote end" );
|
||||
}
|
||||
ReopenSocket( sd, monitor->Id() );
|
||||
continue;
|
||||
}
|
||||
Debug( 1, ( "Read frame header, expecting %ld bytes of image", frame_header.image_length ));
|
||||
Debug( 1, "Read frame header, expecting %ld bytes of image", frame_header.image_length );
|
||||
static unsigned char image_data[ZM_MAX_IMAGE_SIZE];
|
||||
n_bytes = read( sd, image_data, frame_header.image_length );
|
||||
if ( n_bytes != (ssize_t)frame_header.image_length )
|
||||
{
|
||||
if ( n_bytes < 0 )
|
||||
{
|
||||
Error(( "Can't read frame image data: %s", strerror(errno) ));
|
||||
Error( "Can't read frame image data: %s", strerror(errno) );
|
||||
}
|
||||
else if ( n_bytes > 0 )
|
||||
{
|
||||
Error(( "Incomplete read of frame image data, %d bytes only", n_bytes ));
|
||||
Error( "Incomplete read of frame image data, %d bytes only", n_bytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning(( "Socket closed at remote end" ));
|
||||
Warning( "Socket closed at remote end" );
|
||||
}
|
||||
ReopenSocket( sd, monitor->Id() );
|
||||
continue;
|
||||
|
@ -259,17 +259,17 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
static char path[PATH_MAX] = "";
|
||||
snprintf( path, sizeof(path), frame_header.alarm_frame?anal_path:capt_path, subpath, frame_header.frame_id );
|
||||
Debug( 1, ( "Got image, writing to %s", path ));
|
||||
Debug( 1, "Got image, writing to %s", path );
|
||||
|
||||
FILE *fd = 0;
|
||||
if ( (fd = fopen( path, "w" )) < 0 )
|
||||
{
|
||||
Error(( "Can't fopen '%s': %s", path, strerror(errno) ));
|
||||
Error( "Can't fopen '%s': %s", path, strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
if ( 0 == fwrite( image_data, frame_header.image_length, 1, fd ) )
|
||||
{
|
||||
Error(( "Can't fwrite image data: %s", strerror(errno) ));
|
||||
Error( "Can't fwrite image data: %s", strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
fclose( fd );
|
||||
|
|
|
@ -37,7 +37,7 @@ bool fixDevice( const char *device_path )
|
|||
|
||||
if ( stat( device_path, &stat_buf ) < 0 )
|
||||
{
|
||||
Error(( "Can't stat %s: %s", device_path, strerror(errno)));
|
||||
Error( "Can't stat %s: %s", device_path, strerror(errno));
|
||||
return( false );
|
||||
}
|
||||
|
||||
|
@ -64,15 +64,15 @@ bool fixDevice( const char *device_path )
|
|||
mode_t mode = stat_buf.st_mode;
|
||||
if ( (mode & mask) == mask )
|
||||
{
|
||||
Debug( 1, ( "Permissions on %s are ok at %o", device_path, mode ));
|
||||
Debug( 1, "Permissions on %s are ok at %o", device_path, mode );
|
||||
return( true );
|
||||
}
|
||||
mode |= mask;
|
||||
|
||||
Info(( "Resetting permissions on %s to %o", device_path, mode ));
|
||||
Info( "Resetting permissions on %s to %o", device_path, mode );
|
||||
if ( chmod( device_path, mode ) < 0 )
|
||||
{
|
||||
Error(( "Can't chmod %s to %o: %s", device_path, mode, strerror(errno)));
|
||||
Error( "Can't chmod %s to %o: %s", device_path, mode, strerror(errno));
|
||||
return( false );
|
||||
}
|
||||
return( true );
|
||||
|
@ -89,14 +89,14 @@ int main( int argc, char *argv[] )
|
|||
snprintf( sql, sizeof(sql), "select distinct Device from Monitors where not isnull(Device) and Type = 'Local'" );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ int main( int argc, char *argv[] )
|
|||
|
||||
if ( mysql_errno( &dbconn ) )
|
||||
{
|
||||
Error(( "Can't fetch row: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't fetch row: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
// Yadda yadda
|
||||
|
@ -116,14 +116,14 @@ int main( int argc, char *argv[] )
|
|||
snprintf( sql, sizeof(sql), "select distinct ControlDevice from Monitors where not isnull(ControlDevice)" );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ int main( int argc, char *argv[] )
|
|||
|
||||
if ( mysql_errno( &dbconn ) )
|
||||
{
|
||||
Error(( "Can't fetch row: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't fetch row: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
// Yadda yadda
|
||||
|
|
10
src/zms.cpp
10
src/zms.cpp
|
@ -44,7 +44,7 @@ bool ValidateAccess( User *user, int mon_id )
|
|||
}
|
||||
if ( !allowed )
|
||||
{
|
||||
Error(( "Error, insufficient privileges for requested action" ));
|
||||
Error( "Error, insufficient privileges for requested action" );
|
||||
exit( -1 );
|
||||
}
|
||||
return( allowed );
|
||||
|
@ -88,7 +88,7 @@ int main( int argc, const char *argv[] )
|
|||
const char *query = getenv( "QUERY_STRING" );
|
||||
if ( query )
|
||||
{
|
||||
Debug( 1, ( "Query: %s", query ));
|
||||
Debug( 1, "Query: %s", query );
|
||||
|
||||
char temp_query[1024];
|
||||
strncpy( temp_query, query, sizeof(temp_query) );
|
||||
|
@ -209,7 +209,7 @@ int main( int argc, const char *argv[] )
|
|||
}
|
||||
if ( !user )
|
||||
{
|
||||
Error(( "Unable to authenticate user" ));
|
||||
Error( "Unable to authenticate user" );
|
||||
return( -1 );
|
||||
}
|
||||
ValidateAccess( user, monitor_id );
|
||||
|
@ -270,7 +270,7 @@ int main( int argc, const char *argv[] )
|
|||
stream.setStreamBitrate( bitrate );
|
||||
stream.setStreamType( MonitorStream::STREAM_MPEG );
|
||||
#else // HAVE_LIBAVCODEC
|
||||
Error(( "MPEG streaming of '%s' attempted while disabled", query ));
|
||||
Error( "MPEG streaming of '%s' attempted while disabled", query );
|
||||
fprintf( stderr, "MPEG streaming is disabled.\nYou should configure with the --with-ffmpeg option and rebuild to use this functionality.\n" );
|
||||
return( -1 );
|
||||
#endif // HAVE_LIBAVCODEC
|
||||
|
@ -304,7 +304,7 @@ int main( int argc, const char *argv[] )
|
|||
stream.setStreamBitrate( bitrate );
|
||||
stream.setStreamType( EventStream::STREAM_MPEG );
|
||||
#else // HAVE_LIBAVCODEC
|
||||
Error(( "MPEG streaming of '%s' attempted while disabled", query ));
|
||||
Error( "MPEG streaming of '%s' attempted while disabled", query );
|
||||
fprintf( stderr, "MPEG streaming is disabled.\nYou should configure with the --with-ffmpeg option and rebuild to use this functionality.\n" );
|
||||
return( -1 );
|
||||
#endif // HAVE_LIBAVCODEC
|
||||
|
|
|
@ -678,18 +678,18 @@ int main( int argc, char *argv[] )
|
|||
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error(( "Can't use query result: %s", mysql_error( &dbconn ) ));
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
int n_monitors = mysql_num_rows( result );
|
||||
Debug( 1, ( "Got %d monitors", n_monitors ));
|
||||
Debug( 1, "Got %d monitors", n_monitors );
|
||||
|
||||
printf( "%4s%5s%6s%9s%14s%6s%6s%8s%8s\n", "Id", "Func", "State", "TrgState", "LastImgTim", "RdIdx", "WrIdx", "LastEvt", "FrmRate" );
|
||||
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
||||
|
|
Loading…
Reference in New Issue