Converted to use dynamic configuration.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@593 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
22c107ddc8
commit
06c13211c7
|
@ -37,13 +37,28 @@
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
use constant ZM_PATH_BIN => "<from zmconfig>";
|
use constant ZM_PATH_BIN => "<from zmconfig>";
|
||||||
use constant ZM_PATH_WEB => "<from zmconfig>";
|
use constant ZM_PATH_WEB => "<from zmconfig>";
|
||||||
use constant ZM_PATH_LOGS => "<from zmconfig>";
|
|
||||||
use constant ZM_DB_SERVER => "<from zmconfig>";
|
use constant ZM_DB_SERVER => "<from zmconfig>";
|
||||||
use constant ZM_DB_NAME => "<from zmconfig>";
|
use constant ZM_DB_NAME => "<from zmconfig>";
|
||||||
use constant ZM_DB_USERA => "<from zmconfig>";
|
use constant ZM_DB_USERA => "<from zmconfig>";
|
||||||
use constant ZM_DB_PASSA => "<from zmconfig>";
|
use constant ZM_DB_PASSA => "<from zmconfig>";
|
||||||
use constant ZM_DIR_IMAGES => "<from zmconfig>";
|
|
||||||
use constant ZM_DIR_EVENTS => "<from zmconfig>";
|
# Load the config from the database into the symbol table
|
||||||
|
BEGIN
|
||||||
|
{
|
||||||
|
use DBI;
|
||||||
|
no strict 'refs';
|
||||||
|
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
|
||||||
|
|
||||||
|
my $sql = "select * from Config";
|
||||||
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
|
while( my $config = $sth->fetchrow_hashref() )
|
||||||
|
{
|
||||||
|
*{$config->{Name}} = sub { $config->{Value} };
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
$dbh->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
use constant IMAGE_PATH => ZM_PATH_WEB.'/'.ZM_DIR_IMAGES;
|
use constant IMAGE_PATH => ZM_PATH_WEB.'/'.ZM_DIR_IMAGES;
|
||||||
use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
|
use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
|
||||||
|
|
|
@ -34,9 +34,31 @@
|
||||||
#
|
#
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
|
|
||||||
|
|
||||||
use constant ZM_PATH_BIN => "<from zmconfig>";
|
use constant ZM_PATH_BIN => "<from zmconfig>";
|
||||||
use constant ZM_PATH_SOCKS => "<from zmconfig>";
|
use constant ZM_PATH_WEB => "<from zmconfig>";
|
||||||
use constant ZM_PATH_LOGS => "<from zmconfig>";
|
use constant ZM_DB_SERVER => "<from zmconfig>";
|
||||||
|
use constant ZM_DB_NAME => "<from zmconfig>";
|
||||||
|
use constant ZM_DB_USERA => "<from zmconfig>";
|
||||||
|
use constant ZM_DB_PASSA => "<from zmconfig>";
|
||||||
|
|
||||||
|
# Load the config from the database into the symbol table
|
||||||
|
BEGIN
|
||||||
|
{
|
||||||
|
use DBI;
|
||||||
|
no strict 'refs';
|
||||||
|
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
|
||||||
|
|
||||||
|
my $sql = "select * from Config";
|
||||||
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
|
while( my $config = $sth->fetchrow_hashref() )
|
||||||
|
{
|
||||||
|
*{$config->{Name}} = sub { $config->{Value} };
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
$dbh->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
use constant DC_SOCK_FILE => ZM_PATH_SOCKS.'/zmdc.sock';
|
use constant DC_SOCK_FILE => ZM_PATH_SOCKS.'/zmdc.sock';
|
||||||
use constant DC_LOG_FILE => ZM_PATH_LOGS.'/zmdc.log';
|
use constant DC_LOG_FILE => ZM_PATH_LOGS.'/zmdc.log';
|
||||||
|
|
|
@ -35,33 +35,28 @@ use strict;
|
||||||
use constant ZM_PATH_BIN => "<from zmconfig>";
|
use constant ZM_PATH_BIN => "<from zmconfig>";
|
||||||
use constant ZM_PATH_WEB => "<from zmconfig>";
|
use constant ZM_PATH_WEB => "<from zmconfig>";
|
||||||
use constant ZM_PATH_CGI => "<from zmconfig>";
|
use constant ZM_PATH_CGI => "<from zmconfig>";
|
||||||
use constant ZM_PATH_LOGS => "<from zmconfig>";
|
|
||||||
use constant ZM_DB_SERVER => "<from zmconfig>";
|
use constant ZM_DB_SERVER => "<from zmconfig>";
|
||||||
use constant ZM_DB_NAME => "<from zmconfig>";
|
use constant ZM_DB_NAME => "<from zmconfig>";
|
||||||
use constant ZM_DB_USERA => "<from zmconfig>";
|
use constant ZM_DB_USERA => "<from zmconfig>";
|
||||||
use constant ZM_DB_PASSA => "<from zmconfig>";
|
use constant ZM_DB_PASSA => "<from zmconfig>";
|
||||||
use constant ZM_DIR_EVENTS => "<from zmconfig>";
|
|
||||||
use constant ZM_SHM_KEY => <from zmconfig>;
|
# Load the config from the database into the symbol table
|
||||||
use constant ZM_FILTER_RELOAD_DELAY => <from zmconfig>;
|
BEGIN
|
||||||
use constant ZM_OPT_UPLOAD => <from zmconfig>;
|
{
|
||||||
use constant ZM_UPLOAD_ARCH_FORMAT => <from zmconfig>;
|
use DBI;
|
||||||
use constant ZM_UPLOAD_ARCH_COMPRESS => <from zmconfig>;
|
no strict 'refs';
|
||||||
use constant ZM_UPLOAD_ARCH_ANALYSE => <from zmconfig>;
|
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
|
||||||
use constant ZM_UPLOAD_FTP_HOST => "<from zmconfig>";
|
|
||||||
use constant ZM_UPLOAD_FTP_USER => "<from zmconfig>";
|
my $sql = "select * from Config";
|
||||||
use constant ZM_UPLOAD_FTP_PASS => "<from zmconfig>";
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
use constant ZM_UPLOAD_FTP_LOC_DIR => "<from zmconfig>";
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
use constant ZM_UPLOAD_FTP_REM_DIR => "<from zmconfig>";
|
while( my $config = $sth->fetchrow_hashref() )
|
||||||
use constant ZM_UPLOAD_FTP_TIMEOUT => <from zmconfig>;
|
{
|
||||||
use constant ZM_UPLOAD_FTP_PASSIVE => <from zmconfig>;
|
*{$config->{Name}} = sub { $config->{Value} };
|
||||||
use constant ZM_UPLOAD_FTP_DEBUG => <from zmconfig>;
|
}
|
||||||
use constant ZM_OPT_EMAIL => <from zmconfig>;
|
$sth->finish();
|
||||||
use constant ZM_EMAIL_ADDRESS => <from zmconfig>;
|
$dbh->disconnect();
|
||||||
use constant ZM_OPT_MESSAGE => <from zmconfig>;
|
}
|
||||||
use constant ZM_MESSAGE_ADDRESS => <from zmconfig>;
|
|
||||||
use constant ZM_URL => <from zmconfig>;
|
|
||||||
use constant ZM_FROM_EMAIL => <from zmconfig>;
|
|
||||||
use constant ZM_OPT_MPEG => <from zmconfig>;
|
|
||||||
|
|
||||||
use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
|
use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
|
||||||
use constant LOG_FILE => ZM_PATH_LOGS.'/zmfilter-%d.log';
|
use constant LOG_FILE => ZM_PATH_LOGS.'/zmfilter-%d.log';
|
||||||
|
@ -89,9 +84,7 @@ if ( ZM_OPT_EMAIL )
|
||||||
{
|
{
|
||||||
use MIME::Entity;
|
use MIME::Entity;
|
||||||
|
|
||||||
use constant ZM_EMAIL_FORMAT => "<from zmconfig>"; # File containing the contents of the email
|
( $email_subject, $email_body ) = ZM_EMAIL_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
|
||||||
|
|
||||||
( $email_subject, $email_body ) = ZM_EMAIL_FORMAT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $message_subject;
|
my $message_subject;
|
||||||
|
@ -100,9 +93,7 @@ if ( ZM_OPT_MESSAGE )
|
||||||
{
|
{
|
||||||
use MIME::Entity;
|
use MIME::Entity;
|
||||||
|
|
||||||
use constant ZM_MESSAGE_FORMAT => "<from zmconfig>"; # File containing the contents of the message
|
( $message_subject, $message_body ) = ZM_MESSAGE_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
|
||||||
|
|
||||||
( $message_subject, $message_body ) = ZM_MESSAGE_FORMAT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
|
@ -202,7 +193,7 @@ my $filters = GetFilters( $monitor );
|
||||||
my $last_action = 0;
|
my $last_action = 0;
|
||||||
|
|
||||||
my $size = 24; # We only need the first 16 bytes really for the last event count
|
my $size = 24; # We only need the first 16 bytes really for the last event count
|
||||||
my $key = ZM_SHM_KEY|$monitor;
|
my $key = hex(ZM_SHM_KEY)|$monitor;
|
||||||
my $shmid = shmget( $key, $size, 0 ) || die( "Can't get shared memory id: $!" );
|
my $shmid = shmget( $key, $size, 0 ) || die( "Can't get shared memory id: $!" );
|
||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
|
@ -402,7 +393,7 @@ sub uploadArchFile
|
||||||
my $event = shift;
|
my $event = shift;
|
||||||
|
|
||||||
my $arch_file = ZM_UPLOAD_FTP_LOC_DIR.'/'.$filter->{MonitorName}.'-'.$event->{Id};
|
my $arch_file = ZM_UPLOAD_FTP_LOC_DIR.'/'.$filter->{MonitorName}.'-'.$event->{Id};
|
||||||
my $arch_image_path = "$filter->{MonitorName}/$event->{Id}/".(ZM_UPLOAD_ARCH_ANALYSE?'*':'capture*').".jpg";
|
my $arch_image_path = "$filter->{MonitorName}/$event->{Id}/".((ZM_UPLOAD_ARCH_ANALYSE)?'*':'capture*').".jpg";
|
||||||
my $arch_error;
|
my $arch_error;
|
||||||
|
|
||||||
if ( ZM_UPLOAD_ARCH_FORMAT eq "zip" )
|
if ( ZM_UPLOAD_ARCH_FORMAT eq "zip" )
|
||||||
|
@ -417,7 +408,7 @@ sub uploadArchFile
|
||||||
print( "Adding $image_file\n" );
|
print( "Adding $image_file\n" );
|
||||||
my $member = $zip->addFile( $image_file );
|
my $member = $zip->addFile( $image_file );
|
||||||
last unless ( $member );
|
last unless ( $member );
|
||||||
$member->desiredCompressionMethod( ZM_UPLOAD_ARCH_COMPRESS?COMPRESSION_DEFLATED:COMPRESSION_STORED );
|
$member->desiredCompressionMethod( (ZM_UPLOAD_ARCH_COMPRESS)?COMPRESSION_DEFLATED:COMPRESSION_STORED );
|
||||||
}
|
}
|
||||||
$status = $zip->writeToFileNamed( $arch_file );
|
$status = $zip->writeToFileNamed( $arch_file );
|
||||||
|
|
||||||
|
|
|
@ -34,17 +34,30 @@ use strict;
|
||||||
use constant ZM_PATH_BIN => "<from zmconfig>";
|
use constant ZM_PATH_BIN => "<from zmconfig>";
|
||||||
use constant ZM_PATH_WEB => "<from zmconfig>";
|
use constant ZM_PATH_WEB => "<from zmconfig>";
|
||||||
use constant ZM_PATH_CGI => "<from zmconfig>";
|
use constant ZM_PATH_CGI => "<from zmconfig>";
|
||||||
use constant ZM_PATH_LOGS => "<from zmconfig>";
|
|
||||||
use constant ZM_WEB_USER => "<from zmconfig>";
|
use constant ZM_WEB_USER => "<from zmconfig>";
|
||||||
use constant ZM_WEB_GROUP => "<from zmconfig>";
|
use constant ZM_WEB_GROUP => "<from zmconfig>";
|
||||||
use constant ZM_DB_SERVER => "<from zmconfig>";
|
use constant ZM_DB_SERVER => "<from zmconfig>";
|
||||||
use constant ZM_DB_NAME => "<from zmconfig>";
|
use constant ZM_DB_NAME => "<from zmconfig>";
|
||||||
use constant ZM_DB_USERA => "<from zmconfig>";
|
use constant ZM_DB_USERA => "<from zmconfig>";
|
||||||
use constant ZM_DB_PASSA => "<from zmconfig>";
|
use constant ZM_DB_PASSA => "<from zmconfig>";
|
||||||
use constant ZM_SHM_KEY => "<from zmconfig>";
|
|
||||||
use constant ZM_OPT_FAST_DELETE => "<from zmconfig>";
|
# Load the config from the database into the symbol table
|
||||||
use constant ZM_OPT_X10 => "<from zmconfig>";
|
BEGIN
|
||||||
use constant ZM_OPT_FRAME_SERVER => "<from zmconfig>";
|
{
|
||||||
|
use DBI;
|
||||||
|
no strict 'refs';
|
||||||
|
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
|
||||||
|
|
||||||
|
my $sql = "select * from Config";
|
||||||
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
|
while( my $config = $sth->fetchrow_hashref() )
|
||||||
|
{
|
||||||
|
*{$config->{Name}} = sub { $config->{Value} };
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
$dbh->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
use constant LOG_FILE => ZM_PATH_LOGS.'/zmpkg.log';
|
use constant LOG_FILE => ZM_PATH_LOGS.'/zmpkg.log';
|
||||||
use constant VERBOSE => 0; # Whether to output more verbose debug
|
use constant VERBOSE => 0; # Whether to output more verbose debug
|
||||||
|
@ -73,7 +86,7 @@ sub remove_shm
|
||||||
{
|
{
|
||||||
print( STDERR "Removing shared memory\n" );
|
print( STDERR "Removing shared memory\n" );
|
||||||
# Find ZoneMinder shared memory
|
# Find ZoneMinder shared memory
|
||||||
my $command = "ipcs -m | grep '^".substr( sprintf( "0x%x", ZM_SHM_KEY ), 0, -2 )."'";
|
my $command = "ipcs -m | grep '^".substr( sprintf( "0x%x", hex(ZM_SHM_KEY) ), 0, -2 )."'";
|
||||||
print( "Checking for shared memory with '$command'\n" ) if ( VERBOSE );
|
print( "Checking for shared memory with '$command'\n" ) if ( VERBOSE );
|
||||||
open( CMD, "$command |" ) or die( "Can't execute '$command': $!" );
|
open( CMD, "$command |" ) or die( "Can't execute '$command': $!" );
|
||||||
while( <CMD> )
|
while( <CMD> )
|
||||||
|
|
|
@ -34,18 +34,28 @@ use strict;
|
||||||
use constant ZM_PATH_BIN => "<from zmconfig>";
|
use constant ZM_PATH_BIN => "<from zmconfig>";
|
||||||
use constant ZM_PATH_WEB => "<from zmconfig>";
|
use constant ZM_PATH_WEB => "<from zmconfig>";
|
||||||
use constant ZM_PATH_CGI => "<from zmconfig>";
|
use constant ZM_PATH_CGI => "<from zmconfig>";
|
||||||
use constant ZM_PATH_LOGS => "<from zmconfig>";
|
|
||||||
use constant ZM_PATH_NETPBM => "<from zmconfig>";
|
|
||||||
use constant ZM_OPT_MPEG => "<from zmconfig>";
|
|
||||||
use constant ZM_PATH_MPEG_ENCODE => "<from zmconfig>";
|
|
||||||
use constant ZM_PATH_FFMPEG => "<from zmconfig>";
|
|
||||||
use constant ZM_FFMPEG_OPTIONS => "<from zmconfig>";
|
|
||||||
use constant ZM_DB_SERVER => "<from zmconfig>";
|
use constant ZM_DB_SERVER => "<from zmconfig>";
|
||||||
use constant ZM_DB_NAME => "<from zmconfig>";
|
use constant ZM_DB_NAME => "<from zmconfig>";
|
||||||
use constant ZM_DB_USERB => "<from zmconfig>";
|
use constant ZM_DB_USERB => "<from zmconfig>";
|
||||||
use constant ZM_DB_PASSB => "<from zmconfig>";
|
use constant ZM_DB_PASSB => "<from zmconfig>";
|
||||||
use constant ZM_DIR_EVENTS => "<from zmconfig>";
|
|
||||||
use constant ZM_COLOUR_JPEG_FILES => "<from zmconfig>";
|
# Load the config from the database into the symbol table
|
||||||
|
BEGIN
|
||||||
|
{
|
||||||
|
use DBI;
|
||||||
|
no strict 'refs';
|
||||||
|
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
|
||||||
|
|
||||||
|
my $sql = "select * from Config";
|
||||||
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
|
while( my $config = $sth->fetchrow_hashref() )
|
||||||
|
{
|
||||||
|
*{$config->{Name}} = sub { $config->{Value} };
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
$dbh->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
use constant LOG_FILE => ZM_PATH_LOGS.'/zmvideo.log';
|
use constant LOG_FILE => ZM_PATH_LOGS.'/zmvideo.log';
|
||||||
use constant VERBOSE => 0; # Whether to output more verbose debug
|
use constant VERBOSE => 0; # Whether to output more verbose debug
|
||||||
|
|
|
@ -33,13 +33,28 @@
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
|
|
||||||
use constant ZM_PATH_BIN => "<from zmconfig>";
|
use constant ZM_PATH_BIN => "<from zmconfig>";
|
||||||
use constant ZM_PATH_LOGS => "<from zmconfig>";
|
|
||||||
use constant ZM_DB_SERVER => "<from zmconfig>";
|
use constant ZM_DB_SERVER => "<from zmconfig>";
|
||||||
use constant ZM_DB_NAME => "<from zmconfig>";
|
use constant ZM_DB_NAME => "<from zmconfig>";
|
||||||
use constant ZM_DB_USERA => "<from zmconfig>";
|
use constant ZM_DB_USERA => "<from zmconfig>";
|
||||||
use constant ZM_DB_PASSA => "<from zmconfig>";
|
use constant ZM_DB_PASSA => "<from zmconfig>";
|
||||||
use constant ZM_WATCH_CHECK_INTERVAL => <from zmconfig>;
|
|
||||||
use constant ZM_WATCH_MAX_DELAY => <from zmconfig>;
|
# Load the config from the database into the symbol table
|
||||||
|
BEGIN
|
||||||
|
{
|
||||||
|
use DBI;
|
||||||
|
no strict 'refs';
|
||||||
|
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
|
||||||
|
|
||||||
|
my $sql = "select * from Config";
|
||||||
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
|
while( my $config = $sth->fetchrow_hashref() )
|
||||||
|
{
|
||||||
|
*{$config->{Name}} = sub { $config->{Value} };
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
$dbh->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
use constant WATCH_LOG_FILE => ZM_PATH_LOGS.'/zmwatch.log';
|
use constant WATCH_LOG_FILE => ZM_PATH_LOGS.'/zmwatch.log';
|
||||||
use constant START_DELAY => 30; # To give everything else time to start
|
use constant START_DELAY => 30; # To give everything else time to start
|
||||||
|
|
|
@ -32,17 +32,28 @@
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
|
|
||||||
use constant ZM_PATH_BIN => "<from zmconfig>";
|
use constant ZM_PATH_BIN => "<from zmconfig>";
|
||||||
use constant ZM_PATH_SOCKS => "<from zmconfig>";
|
|
||||||
use constant ZM_PATH_LOGS => "<from zmconfig>";
|
|
||||||
use constant ZM_DB_SERVER => "<from zmconfig>";
|
use constant ZM_DB_SERVER => "<from zmconfig>";
|
||||||
use constant ZM_DB_NAME => "<from zmconfig>";
|
use constant ZM_DB_NAME => "<from zmconfig>";
|
||||||
use constant ZM_DB_USERA => "<from zmconfig>";
|
use constant ZM_DB_USERA => "<from zmconfig>";
|
||||||
use constant ZM_DB_PASSA => "<from zmconfig>";
|
use constant ZM_DB_PASSA => "<from zmconfig>";
|
||||||
use constant ZM_DIR_EVENTS => "<from zmconfig>";
|
|
||||||
use constant ZM_X10_DB_RELOAD_INTERVAL => 60;
|
# Load the config from the database into the symbol table
|
||||||
use constant ZM_X10_DEVICE => '/dev/ttyS1';
|
BEGIN
|
||||||
use constant ZM_X10_HOUSE_CODE => 'K';
|
{
|
||||||
use constant ZM_SHM_KEY => 0x7a6d2000;
|
use DBI;
|
||||||
|
no strict 'refs';
|
||||||
|
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
|
||||||
|
|
||||||
|
my $sql = "select * from Config";
|
||||||
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
|
while( my $config = $sth->fetchrow_hashref() )
|
||||||
|
{
|
||||||
|
*{$config->{Name}} = sub { $config->{Value} };
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
$dbh->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
use constant X10_SOCK_FILE => ZM_PATH_SOCKS.'/zmx10.sock';
|
use constant X10_SOCK_FILE => ZM_PATH_SOCKS.'/zmx10.sock';
|
||||||
use constant X10_LOG_FILE => ZM_PATH_LOGS.'/zmx10.log';
|
use constant X10_LOG_FILE => ZM_PATH_LOGS.'/zmx10.log';
|
||||||
|
@ -193,7 +204,7 @@ sub runServer
|
||||||
#print( "F:".fileno(SERVER)."\n" );
|
#print( "F:".fileno(SERVER)."\n" );
|
||||||
my $reload = undef;
|
my $reload = undef;
|
||||||
my $reload_count = 0;
|
my $reload_count = 0;
|
||||||
my $reload_limit = main::ZM_X10_DB_RELOAD_INTERVAL/$timeout;
|
my $reload_limit = (main::ZM_X10_DB_RELOAD_INTERVAL)/$timeout;
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
my $nfound = select( my $rout = $rin, undef, undef, $timeout );
|
my $nfound = select( my $rout = $rin, undef, undef, $timeout );
|
||||||
|
@ -439,7 +450,7 @@ sub loadTasks
|
||||||
$monitor_hash{$monitor->{Id}} = $monitor;
|
$monitor_hash{$monitor->{Id}} = $monitor;
|
||||||
|
|
||||||
my $size = 4; # We only need the first 4 bytes really for the alarm state
|
my $size = 4; # We only need the first 4 bytes really for the alarm state
|
||||||
$monitor->{ShmKey} = main::ZM_SHM_KEY|$monitor->{Id};
|
$monitor->{ShmKey} = hex(main::ZM_SHM_KEY)|$monitor->{Id};
|
||||||
if ( !($monitor->{ShmId} = shmget( $monitor->{ShmKey}, $size, 0 )) )
|
if ( !($monitor->{ShmId} = shmget( $monitor->{ShmKey}, $size, 0 )) )
|
||||||
{
|
{
|
||||||
print( "Can't get shared memory id: $!\n" );
|
print( "Can't get shared memory id: $!\n" );
|
||||||
|
|
|
@ -28,34 +28,6 @@
|
||||||
#define ZM_DB_USERB "<from zmconfig>" // Unprivileged DB user name, need just select privilege.
|
#define ZM_DB_USERB "<from zmconfig>" // Unprivileged DB user name, need just select privilege.
|
||||||
#define ZM_DB_PASSB "<from zmconfig>" // Unprivileged DB user password
|
#define ZM_DB_PASSB "<from zmconfig>" // Unprivileged DB user password
|
||||||
|
|
||||||
#define ZM_HTTP_VERSION "<from zmconfig>" // The version of HTTP that ZoneMinder will use to connect
|
|
||||||
#define ZM_HTTP_UA "<from zmconfig>" // The user agent that ZoneMinder uses to identify itself
|
|
||||||
#define ZM_HTTP_TIMEOUT <from zmconfig> // How long ZoneMinder waits before giving up on images (millseconds)
|
|
||||||
|
|
||||||
#define ZM_SHM_KEY <from zmconfig> // Shared memory key to use, only change if it clashes with another application
|
|
||||||
|
|
||||||
#define ZM_PATH_SOCKS "<from zmconfig>" // Path to the various Unix domain socket files that ZoneMinder uses
|
|
||||||
|
|
||||||
#define ZM_DIR_EVENTS "<from zmconfig>" // Local path to where events directory lives
|
|
||||||
|
|
||||||
#define ZM_FORCED_ALARM_SCORE <from zmconfig> // Score to give X10 forced alarms
|
|
||||||
|
|
||||||
#define ZM_RECORD_EVENT_STATS <from zmconfig> // Whether to record event statistical information, change to no if too slow
|
|
||||||
|
|
||||||
#define ZM_STRICT_VIDEO_CONFIG <from zmconfig> // Whether to allow errors in setting video config to be fatal
|
|
||||||
#define ZM_LOCAL_BGR_INVERT <from zmconfig> // Invert BGR colours to RGB
|
|
||||||
#define ZM_FAST_RGB_DIFFS <from zmconfig> // Whether we use a rough RGB difference algorithm
|
|
||||||
#define ZM_COLOUR_JPEG_FILES <from zmconfig> // Colourise greyscale JPEG files
|
|
||||||
|
|
||||||
#define ZM_JPEG_FILE_QUALITY <from zmconfig> // Set the JPEG quality setting for the saved event files
|
|
||||||
#define ZM_JPEG_IMAGE_QUALITY <from zmconfig> // Set the JPEG quality setting for the streamed 'live' images
|
|
||||||
|
|
||||||
#define ZM_BLEND_ALARMED_IMAGES <from zmconfig> // Whether alarmed images are blended to update the reference image
|
|
||||||
|
|
||||||
#define ZM_NO_MAX_FPS_ON_ALARM <from zmconfig> // Should any Maximum FPS be ignored if an alarm occurs
|
|
||||||
#define ZM_OPT_ADAPTIVE_SKIP <from zmconfig> // Whether we use the adaptive skip algorithm
|
|
||||||
#define ZM_OPT_FRAME_SERVER <from zmconfig> // Whether we use the frame server to speed things up
|
|
||||||
|
|
||||||
#define ZM_MAX_IMAGE_WIDTH 2048 // The largest image we imagine ever handling
|
#define ZM_MAX_IMAGE_WIDTH 2048 // The largest image we imagine ever handling
|
||||||
#define ZM_MAX_IMAGE_HEIGHT 1536 // The largest image we imagine ever handling
|
#define ZM_MAX_IMAGE_HEIGHT 1536 // The largest image we imagine ever handling
|
||||||
#define ZM_MAX_IMAGE_COLOURS 3 // The largest image we imagine ever handling
|
#define ZM_MAX_IMAGE_COLOURS 3 // The largest image we imagine ever handling
|
||||||
|
@ -117,7 +89,7 @@ public:
|
||||||
~Config();
|
~Config();
|
||||||
|
|
||||||
void Load();
|
void Load();
|
||||||
const ConfigItem &GetItem( int id );
|
const ConfigItem &Item( int id );
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Config config;
|
extern Config config;
|
||||||
|
|
|
@ -47,7 +47,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time ) : monitor( p_mon
|
||||||
alarm_frames = 0;
|
alarm_frames = 0;
|
||||||
tot_score = 0;
|
tot_score = 0;
|
||||||
max_score = 0;
|
max_score = 0;
|
||||||
sprintf( path, ZM_DIR_EVENTS "/%s/%d", monitor->Name(), id );
|
sprintf( path, "%s/%s/%d", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Name(), id );
|
||||||
|
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -113,7 +113,7 @@ bool Event::OpenFrameSocket( int monitor_id )
|
||||||
}
|
}
|
||||||
|
|
||||||
char sock_path[PATH_MAX] = "";
|
char sock_path[PATH_MAX] = "";
|
||||||
sprintf( sock_path, FILE_SOCK_FILE, monitor_id );
|
sprintf( sock_path, "%s/zmf-%d.sock", (const char *)config.Item( ZM_PATH_SOCKS ), monitor_id );
|
||||||
|
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ bool Event::SendFrameImage( const Image *image, bool alarm_frame )
|
||||||
|
|
||||||
bool Event::WriteFrameImage( const Image *image, const char *event_file, bool alarm_frame )
|
bool Event::WriteFrameImage( const Image *image, const char *event_file, bool alarm_frame )
|
||||||
{
|
{
|
||||||
if ( !ZM_OPT_FRAME_SERVER || !SendFrameImage( image, alarm_frame) )
|
if ( !(bool)config.Item( ZM_OPT_FRAME_SERVER ) || !SendFrameImage( image, alarm_frame) )
|
||||||
{
|
{
|
||||||
image->WriteJpeg( event_file );
|
image->WriteJpeg( event_file );
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ void Image::ReadJpeg( const char *filename )
|
||||||
|
|
||||||
void Image::WriteJpeg( const char *filename ) const
|
void Image::WriteJpeg( const char *filename ) const
|
||||||
{
|
{
|
||||||
if ( ZM_COLOUR_JPEG_FILES && colours == 1 )
|
if ( (bool)config.Item( ZM_COLOUR_JPEG_FILES ) && colours == 1 )
|
||||||
{
|
{
|
||||||
Image temp_image( *this );
|
Image temp_image( *this );
|
||||||
temp_image.Colourise();
|
temp_image.Colourise();
|
||||||
|
@ -136,7 +136,7 @@ void Image::WriteJpeg( const char *filename ) const
|
||||||
}
|
}
|
||||||
jpeg_set_defaults(&cinfo);
|
jpeg_set_defaults(&cinfo);
|
||||||
cinfo.dct_method = JDCT_FASTEST;
|
cinfo.dct_method = JDCT_FASTEST;
|
||||||
jpeg_set_quality(&cinfo, ZM_JPEG_FILE_QUALITY, false);
|
jpeg_set_quality(&cinfo, (int)config.Item( ZM_JPEG_FILE_QUALITY ), false);
|
||||||
jpeg_start_compress(&cinfo, TRUE);
|
jpeg_start_compress(&cinfo, TRUE);
|
||||||
|
|
||||||
JSAMPROW row_pointer; /* pointer to a single row */
|
JSAMPROW row_pointer; /* pointer to a single row */
|
||||||
|
@ -211,7 +211,7 @@ void Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size ) const
|
||||||
}
|
}
|
||||||
jpeg_set_defaults(&cinfo);
|
jpeg_set_defaults(&cinfo);
|
||||||
cinfo.dct_method = JDCT_FASTEST;
|
cinfo.dct_method = JDCT_FASTEST;
|
||||||
jpeg_set_quality(&cinfo, ZM_JPEG_IMAGE_QUALITY, false);
|
jpeg_set_quality(&cinfo, (int)config.Item( ZM_JPEG_IMAGE_QUALITY ), false);
|
||||||
jpeg_start_compress(&cinfo, TRUE);
|
jpeg_start_compress(&cinfo, TRUE);
|
||||||
|
|
||||||
JSAMPROW row_pointer; /* pointer to a single row */
|
JSAMPROW row_pointer; /* pointer to a single row */
|
||||||
|
@ -467,7 +467,7 @@ Image *Image::Delta( const Image &image ) const
|
||||||
static long red, green, blue;
|
static long red, green, blue;
|
||||||
while( psrc < (buffer+size) )
|
while( psrc < (buffer+size) )
|
||||||
{
|
{
|
||||||
if ( ZM_FAST_RGB_DIFFS )
|
if ( (bool)config.Item( ZM_FAST_RGB_DIFFS ) )
|
||||||
{
|
{
|
||||||
red = abs(*psrc++ - *pref++);
|
red = abs(*psrc++ - *pref++);
|
||||||
green = abs(*psrc++ - *pref++);
|
green = abs(*psrc++ - *pref++);
|
||||||
|
|
|
@ -83,7 +83,7 @@ void LocalCamera::Initialise()
|
||||||
if( ioctl( m_videohandle, VIDIOCSWIN, &vid_win ) )
|
if( ioctl( m_videohandle, VIDIOCSWIN, &vid_win ) )
|
||||||
{
|
{
|
||||||
Error(( "Failed to set window attributes: %s", strerror(errno) ));
|
Error(( "Failed to set window attributes: %s", strerror(errno) ));
|
||||||
if ( ZM_STRICT_VIDEO_CONFIG ) exit(-1);
|
if ( (bool)config.Item( ZM_STRICT_VIDEO_CONFIG ) ) exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct video_picture vid_pic;
|
struct video_picture vid_pic;
|
||||||
|
@ -125,7 +125,7 @@ void LocalCamera::Initialise()
|
||||||
if( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) )
|
if( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) )
|
||||||
{
|
{
|
||||||
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
|
Error(( "Failed to set picture attributes: %s", strerror(errno) ));
|
||||||
if ( ZM_STRICT_VIDEO_CONFIG ) exit(-1);
|
if ( (bool)config.Item( ZM_STRICT_VIDEO_CONFIG ) ) exit(-1);
|
||||||
}
|
}
|
||||||
if(!ioctl(m_videohandle, VIDIOCGMBUF, &m_vmb))
|
if(!ioctl(m_videohandle, VIDIOCGMBUF, &m_vmb))
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ void LocalCamera::Initialise()
|
||||||
if(ioctl(m_videohandle, VIDIOCSCHAN, &vid_src))
|
if(ioctl(m_videohandle, VIDIOCSCHAN, &vid_src))
|
||||||
{
|
{
|
||||||
Error(( "Failed to set camera source %d: %s", channel, strerror(errno) ));
|
Error(( "Failed to set camera source %d: %s", channel, strerror(errno) ));
|
||||||
if ( ZM_STRICT_VIDEO_CONFIG ) exit(-1);
|
if ( (bool)config.Item( ZM_STRICT_VIDEO_CONFIG ) ) exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !ioctl( m_videohandle, VIDIOCGWIN, &vid_win))
|
if( !ioctl( m_videohandle, VIDIOCGWIN, &vid_win))
|
||||||
|
@ -669,7 +669,7 @@ int LocalCamera::PostCapture( Image &image )
|
||||||
}
|
}
|
||||||
case VIDEO_PALETTE_RGB24 :
|
case VIDEO_PALETTE_RGB24 :
|
||||||
{
|
{
|
||||||
if ( ZM_LOCAL_BGR_INVERT )
|
if ( (bool)config.Item( ZM_LOCAL_BGR_INVERT ) )
|
||||||
{
|
{
|
||||||
int size = width*height*3;
|
int size = width*height*3;
|
||||||
unsigned char *s_ptr = buffer;
|
unsigned char *s_ptr = buffer;
|
||||||
|
|
|
@ -84,7 +84,7 @@ void Monitor::Initialise()
|
||||||
|
|
||||||
int shared_data_size = sizeof(SharedData)+(image_buffer_count*sizeof(time_t))+(image_buffer_count*camera->ImageSize());
|
int shared_data_size = sizeof(SharedData)+(image_buffer_count*sizeof(time_t))+(image_buffer_count*camera->ImageSize());
|
||||||
Info(( "shm.size=%d", shared_data_size ));
|
Info(( "shm.size=%d", shared_data_size ));
|
||||||
shmid = shmget( ZM_SHM_KEY|id, shared_data_size, IPC_CREAT|0777 );
|
shmid = shmget( (int)config.Item( ZM_SHM_KEY )|id, shared_data_size, IPC_CREAT|0777 );
|
||||||
if ( shmid < 0 )
|
if ( shmid < 0 )
|
||||||
{
|
{
|
||||||
Error(( "Can't shmget: %s", strerror(errno)));
|
Error(( "Can't shmget: %s", strerror(errno)));
|
||||||
|
@ -141,13 +141,13 @@ void Monitor::Initialise()
|
||||||
Info(( "Monitor %s LBF = '%s', LBX = %d, LBY = %d", name, label_format, label_coord.X(), label_coord.Y() ));
|
Info(( "Monitor %s LBF = '%s', LBX = %d, LBY = %d", name, label_format, label_coord.X(), label_coord.Y() ));
|
||||||
Info(( "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, FRI = %d, RBP = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, fps_report_interval, ref_blend_perc ));
|
Info(( "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, FRI = %d, RBP = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, fps_report_interval, ref_blend_perc ));
|
||||||
|
|
||||||
record_event_stats = ZM_RECORD_EVENT_STATS;
|
record_event_stats = (bool)config.Item( ZM_RECORD_EVENT_STATS );
|
||||||
|
|
||||||
if ( mode == ANALYSIS )
|
if ( mode == ANALYSIS )
|
||||||
{
|
{
|
||||||
static char path[PATH_MAX];
|
static char path[PATH_MAX];
|
||||||
|
|
||||||
sprintf( path, ZM_DIR_EVENTS );
|
strcpy( path, (const char *)config.Item( ZM_DIR_EVENTS ) );
|
||||||
|
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -160,7 +160,7 @@ void Monitor::Initialise()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf( path, ZM_DIR_EVENTS "/%s", name );
|
sprintf( path, "%s/%s", (const char *)config.Item( ZM_DIR_EVENTS ), name );
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
stat( path, &statbuf );
|
stat( path, &statbuf );
|
||||||
|
@ -469,7 +469,7 @@ bool Monitor::Analyse()
|
||||||
}
|
}
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
if ( ZM_OPT_ADAPTIVE_SKIP )
|
if ( (bool)config.Item( ZM_OPT_ADAPTIVE_SKIP ) )
|
||||||
{
|
{
|
||||||
int read_margin = shared_data->last_read_index - shared_data->last_write_index;
|
int read_margin = shared_data->last_read_index - shared_data->last_write_index;
|
||||||
if ( read_margin < 0 ) read_margin += image_buffer_count;
|
if ( read_margin < 0 ) read_margin += image_buffer_count;
|
||||||
|
@ -512,7 +512,7 @@ bool Monitor::Analyse()
|
||||||
if ( shared_data->force_state != FORCE_OFF )
|
if ( shared_data->force_state != FORCE_OFF )
|
||||||
score = Compare( *image );
|
score = Compare( *image );
|
||||||
if ( shared_data->force_state == FORCE_ON )
|
if ( shared_data->force_state == FORCE_ON )
|
||||||
score = ZM_FORCED_ALARM_SCORE;
|
score = (int)config.Item( ZM_FORCED_ALARM_SCORE );
|
||||||
|
|
||||||
if ( score )
|
if ( score )
|
||||||
{
|
{
|
||||||
|
@ -579,7 +579,7 @@ bool Monitor::Analyse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ZM_BLEND_ALARMED_IMAGES || state != ALARM )
|
if ( (bool)config.Item( ZM_BLEND_ALARMED_IMAGES ) || state != ALARM )
|
||||||
{
|
{
|
||||||
ref_image.Blend( *image, ref_blend_perc );
|
ref_image.Blend( *image, ref_blend_perc );
|
||||||
//DumpImage( image );
|
//DumpImage( image );
|
||||||
|
|
|
@ -95,16 +95,16 @@ void RemoteCamera::Initialise()
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf( request, "GET %s %s\n", path, "HTTP/" ZM_HTTP_VERSION );
|
sprintf( request, "GET %s HTTP/%s\n", path, (const char *)config.Item( ZM_HTTP_VERSION ) );
|
||||||
sprintf( &(request[strlen(request)]), "Host: %s\n", host );
|
sprintf( &(request[strlen(request)]), "Host: %s\n", host );
|
||||||
sprintf( &(request[strlen(request)]), "User-Agent: %s/%s\n", ZM_HTTP_UA, ZM_VERSION );
|
sprintf( &(request[strlen(request)]), "User-Agent: %s/%s\n", (const char *)config.Item( ZM_HTTP_UA ), ZM_VERSION );
|
||||||
sprintf( &(request[strlen(request)]), "Connection: Keep-Alive\n\n" );
|
sprintf( &(request[strlen(request)]), "Connection: Keep-Alive\n\n" );
|
||||||
Debug( 2, ( "Request: %s", request ));
|
Debug( 2, ( "Request: %s", request ));
|
||||||
}
|
}
|
||||||
if ( !timeout.tv_sec )
|
if ( !timeout.tv_sec )
|
||||||
{
|
{
|
||||||
timeout.tv_sec = ZM_HTTP_TIMEOUT/1000;
|
timeout.tv_sec = (int)config.Item( ZM_HTTP_TIMEOUT )/1000;
|
||||||
timeout.tv_usec = ZM_HTTP_TIMEOUT%1000;
|
timeout.tv_usec = (int)config.Item( ZM_HTTP_TIMEOUT )%1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
Info(( "Warming up" ));
|
Info(( "Warming up" ));
|
||||||
|
|
||||||
if ( ZM_OPT_FRAME_SERVER )
|
if ( (bool)config.Item( ZM_OPT_FRAME_SERVER ) )
|
||||||
{
|
{
|
||||||
Event::OpenFrameSocket( monitor->Id() );
|
Event::OpenFrameSocket( monitor->Id() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ int main( int argc, char *argv[] )
|
||||||
for ( int i = 0; i < n_monitors; i++ )
|
for ( int i = 0; i < n_monitors; i++ )
|
||||||
{
|
{
|
||||||
long min_delay = MAXINT;
|
long min_delay = MAXINT;
|
||||||
if ( ZM_NO_MAX_FPS_ON_ALARM && monitors[i]->GetState() == Monitor::ALARM )
|
if ( (bool)config.Item( ZM_NO_MAX_FPS_ON_ALARM ) && monitors[i]->GetState() == Monitor::ALARM )
|
||||||
{
|
{
|
||||||
next_delays[i] = 0;
|
next_delays[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ int OpenSocket( int monitor_id )
|
||||||
}
|
}
|
||||||
|
|
||||||
char sock_path[PATH_MAX] = "";
|
char sock_path[PATH_MAX] = "";
|
||||||
sprintf( sock_path, FILE_SOCK_FILE, monitor_id );
|
sprintf( sock_path, "%s/zmf-%d.sock", (const char *)config.Item( ZM_PATH_SOCKS ), monitor_id );
|
||||||
if ( unlink( sock_path ) < 0 )
|
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) ));
|
||||||
|
@ -241,7 +241,7 @@ int main( int argc, char *argv[] )
|
||||||
ReopenSocket( sd, monitor->Id() );
|
ReopenSocket( sd, monitor->Id() );
|
||||||
}
|
}
|
||||||
static char path[PATH_MAX] = "";
|
static char path[PATH_MAX] = "";
|
||||||
sprintf( path, ZM_DIR_EVENTS "/%s/%d/%s-%03d.jpg", monitor->Name(), frame_header.event_id, frame_header.alarm_frame?"analyse":"capture", frame_header.frame_id );
|
sprintf( path, "%s//%s/%d/%s-%03d.jpg", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Name(), frame_header.event_id, frame_header.alarm_frame?"analyse":"capture", frame_header.frame_id );
|
||||||
Debug( 1, ( "Got image, writing to %s", path ));
|
Debug( 1, ( "Got image, writing to %s", path ));
|
||||||
|
|
||||||
FILE *fd = 0;
|
FILE *fd = 0;
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
#ifndef ZMFILE_H
|
#ifndef ZMFILE_H
|
||||||
#define ZMFILE_H
|
#define ZMFILE_H
|
||||||
|
|
||||||
#define FILE_SOCK_FILE ZM_PATH_SOCKS "/zmf-%d.sock"
|
|
||||||
|
|
||||||
struct FrameHeader
|
struct FrameHeader
|
||||||
{
|
{
|
||||||
int event_id;
|
int event_id;
|
||||||
|
|
|
@ -25,61 +25,10 @@ define( "ZM_VERSION", "<from zmconfig>" ); // Version Number
|
||||||
define( "ZM_PATH_BIN", "<from zmconfig>" ); // Path to binaries
|
define( "ZM_PATH_BIN", "<from zmconfig>" ); // Path to binaries
|
||||||
define( "ZM_PATH_WEB", "<from zmconfig>" ); // Path to web files
|
define( "ZM_PATH_WEB", "<from zmconfig>" ); // Path to web files
|
||||||
define( "ZM_PATH_CGI", "<from zmconfig>" ); // Path to cgi files
|
define( "ZM_PATH_CGI", "<from zmconfig>" ); // Path to cgi files
|
||||||
define( "ZM_PATH_ZMS", "<from zmconfig>" ); // Web path to zms streaming server
|
|
||||||
define( "ZM_DB_SERVER", "<from zmconfig>" ); // Database server
|
define( "ZM_DB_SERVER", "<from zmconfig>" ); // Database server
|
||||||
define( "ZM_DB_NAME", "<from zmconfig>" ); // Database containing the tables
|
define( "ZM_DB_NAME", "<from zmconfig>" ); // Database containing the tables
|
||||||
define( "ZM_DB_USERA", "<from zmconfig>" ); // Database login
|
define( "ZM_DB_USERA", "<from zmconfig>" ); // Database login
|
||||||
define( "ZM_DB_PASSA", "<from zmconfig>" ); // Database password
|
define( "ZM_DB_PASSA", "<from zmconfig>" ); // Database password
|
||||||
define( "ZM_OPT_USE_AUTH", "<from zmconfig>" ); // Authenticate user logins to ZoneMinder
|
|
||||||
define( "ZM_DIR_EVENTS", "<from zmconfig>" ); // Directory where events live
|
|
||||||
define( "ZM_DIR_IMAGES", "<from zmconfig>" ); // Directory where images live
|
|
||||||
define( "ZM_DIR_SOUNDS", "<from zmconfig>" ); // Drectory where sounds live
|
|
||||||
define( "ZM_OPT_CAMBOZOLA", "<from zmconfig>" ); // Is the (optional) cambozola java streaming client installed (recommended)
|
|
||||||
define( "ZM_PATH_CAMBOZOLA", "<from zmconfig>" ); // Path to (optional) cambozola java streaming client (recommended)
|
|
||||||
define( "ZM_CAN_STREAM", "<from zmconfig>" ); // Override the detection of streaming capability by browser
|
|
||||||
define( "ZM_PATH_NETPBM", "<from zmconfig>" ); // Path to (optional) Netpbm utilities
|
|
||||||
define( "ZM_WEB_POPUP_ON_ALARM", <from zmconfig> ); // Whether the watch window jumps to front if an alarm occurs
|
|
||||||
define( "ZM_WEB_SOUND_ON_ALARM", <from zmconfig> ); // Whether the watch window jumps to front if an alarm occurs
|
|
||||||
define( "ZM_WEB_ALARM_SOUND", <from zmconfig> ); // A sound to play on alarm, put this in the sounds directory
|
|
||||||
define( "ZM_WEB_MONTAGE_MAX_COLS", <from zmconfig> ); // The maximum number of Monitor columns in the montage view
|
|
||||||
define( "ZM_RECORD_EVENT_STATS", <from zmconfig> ); // Whether to record event statistical information, switch off if too slow
|
|
||||||
define( "ZM_OPT_MPEG", "<from zmconfig>" ); // Is there an (optional) mpeg video encoder installed
|
|
||||||
define( "ZM_OPT_FAST_DELETE", <from zmconfig> ); // Whether we only delete event DB records and leave zmaudit to do the rest
|
|
||||||
define( "ZM_OPT_X10", <from zmconfig> ); // Whether we want to interface with X10 devices
|
|
||||||
define( "ZM_OPT_FRAME_SERVER", <from zmconfig> ); // Whether to use the frame server
|
|
||||||
define( "ZM_WEB_REFRESH_METHOD", <from zmconfig> ); // What method windows should use to refresh themselves
|
|
||||||
|
|
||||||
// Bandwidth specific ones from zmconfig.pl, again do not edit these directly as changes may be lost
|
|
||||||
//
|
|
||||||
define( "ZM_WEB_H_REFRESH_MAIN", <from zmconfig> ); // How often (in seconds) the main console window refreshes
|
|
||||||
define( "ZM_WEB_H_REFRESH_CYCLE", <from zmconfig> ); // How often the cycle watch windows swaps to the next monitor
|
|
||||||
define( "ZM_WEB_H_REFRESH_IMAGE", <from zmconfig> ); // How often the watched image is refreshed (if not streaming)
|
|
||||||
define( "ZM_WEB_H_REFRESH_STATUS", <from zmconfig> ); // How often the little status frame refreshes itself in the watch window
|
|
||||||
define( "ZM_WEB_H_REFRESH_EVENTS", <from zmconfig> ); // How often the event listing is refreshed in the watch window, only for recent events
|
|
||||||
define( "ZM_WEB_H_STREAM_IDLE_DELAY", <from zmconfig> );// How long (in milliseconds) between streamed frames in the watch window
|
|
||||||
define( "ZM_WEB_H_STREAM_FRAME_DELAY", <from zmconfig> );// How long (in milliseconds) to wait before looking for the next streamed frame
|
|
||||||
define( "ZM_WEB_H_STREAM_EVENT_DELAY", <from zmconfig> );// How long (in milliseconds) to wait between each frame when streaming events
|
|
||||||
define( "ZM_WEB_H_IMAGE_SCALING", <from zmconfig> ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
|
||||||
define( "ZM_WEB_M_REFRESH_MAIN", <from zmconfig> ); // How often (in seconds) the main console window refreshes
|
|
||||||
define( "ZM_WEB_M_REFRESH_CYCLE", <from zmconfig> ); // How often the cycle watch windows swaps to the next monitor
|
|
||||||
define( "ZM_WEB_M_REFRESH_IMAGE", <from zmconfig> ); // How often the watched image is refreshed (if not streaming)
|
|
||||||
define( "ZM_WEB_M_REFRESH_STATUS", <from zmconfig> ); // How often the little status frame refreshes itself in the watch window
|
|
||||||
define( "ZM_WEB_M_REFRESH_EVENTS", <from zmconfig> ); // How often the event listing is refreshed in the watch window, only for recent events
|
|
||||||
define( "ZM_WEB_M_STREAM_IDLE_DELAY", <from zmconfig> );// How long (in milliseconds) between streamed frames in the watch window
|
|
||||||
define( "ZM_WEB_M_STREAM_FRAME_DELAY", <from zmconfig> );// How long (in milliseconds) to wait before looking for the next streamed frame
|
|
||||||
define( "ZM_WEB_M_STREAM_EVENT_DELAY", <from zmconfig> );// How long (in milliseconds) to wait between each frame when streaming events
|
|
||||||
define( "ZM_WEB_M_IMAGE_SCALING", <from zmconfig> ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
|
||||||
define( "ZM_WEB_L_REFRESH_MAIN", <from zmconfig> ); // How often (in seconds) the main console window refreshes
|
|
||||||
define( "ZM_WEB_L_REFRESH_CYCLE", <from zmconfig> ); // How often the cycle watch windows swaps to the next monitor
|
|
||||||
define( "ZM_WEB_L_REFRESH_IMAGE", <from zmconfig> ); // How often the watched image is refreshed (if not streaming)
|
|
||||||
define( "ZM_WEB_L_REFRESH_STATUS", <from zmconfig> ); // How often the little status frame refreshes itself in the watch window
|
|
||||||
define( "ZM_WEB_L_REFRESH_EVENTS", <from zmconfig> ); // How often the event listing is refreshed in the watch window, only for recent events
|
|
||||||
define( "ZM_WEB_L_STREAM_IDLE_DELAY", <from zmconfig> );// How long (in milliseconds) between streamed frames in the watch window
|
|
||||||
define( "ZM_WEB_L_STREAM_FRAME_DELAY", <from zmconfig> );// How long (in milliseconds) to wait before looking for the next streamed frame
|
|
||||||
define( "ZM_WEB_L_STREAM_EVENT_DELAY", <from zmconfig> );// How long (in milliseconds) to wait between each frame when streaming events
|
|
||||||
define( "ZM_WEB_L_IMAGE_SCALING", <from zmconfig> ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
|
||||||
define( "ZM_WEB_P_REFRESH_MAIN", <from zmconfig> ); // How often (in seconds) the main console window refreshes
|
|
||||||
define( "ZM_WEB_P_REFRESH_IMAGE", <from zmconfig> ); // How often the watched image is refreshed (if not streaming)
|
|
||||||
|
|
||||||
// This section is options normally derived from other options or configuration
|
// This section is options normally derived from other options or configuration
|
||||||
//
|
//
|
||||||
|
@ -93,6 +42,9 @@ define( "MAX_EVENTS", 10 ); // The maximum number of events to show in th
|
||||||
define( "EVENT_HEADER_LINES", 25 ); // How many events are listed in the event window before a new header is inserted
|
define( "EVENT_HEADER_LINES", 25 ); // How many events are listed in the event window before a new header is inserted
|
||||||
define( "LEARN_MODE", false ); // Currently unimplemented, do not change
|
define( "LEARN_MODE", false ); // Currently unimplemented, do not change
|
||||||
|
|
||||||
|
require_once( 'zm_db.php' );
|
||||||
|
loadConfig();
|
||||||
|
|
||||||
switch ( $bandwidth )
|
switch ( $bandwidth )
|
||||||
{
|
{
|
||||||
case "high" :
|
case "high" :
|
||||||
|
@ -154,6 +106,7 @@ function loadConfig()
|
||||||
$monitors = array();
|
$monitors = array();
|
||||||
while( $row = mysql_fetch_assoc( $result ) )
|
while( $row = mysql_fetch_assoc( $result ) )
|
||||||
{
|
{
|
||||||
|
define( $row[Name], $row[Value] );
|
||||||
$config[$row[Name]] = $row;
|
$config[$row[Name]] = $row;
|
||||||
if ( !($config_cat = &$config_cats[$row[Category]]) )
|
if ( !($config_cat = &$config_cats[$row[Category]]) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,9 +31,6 @@ ini_set( "session.name", "ZMSESSID" );
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require_once( 'zm_config.php' );
|
require_once( 'zm_config.php' );
|
||||||
require_once( 'zm_db.php' );
|
|
||||||
|
|
||||||
loadConfig();
|
|
||||||
|
|
||||||
if ( ZM_OPT_USE_AUTH )
|
if ( ZM_OPT_USE_AUTH )
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,6 @@ session_start();
|
||||||
$bandwidth = "mobile";
|
$bandwidth = "mobile";
|
||||||
|
|
||||||
require_once( 'zm_config.php' );
|
require_once( 'zm_config.php' );
|
||||||
require_once( 'zm_db.php' );
|
|
||||||
require_once( 'zm_funcs.php' );
|
require_once( 'zm_funcs.php' );
|
||||||
require_once( 'zm_actions.php' );
|
require_once( 'zm_actions.php' );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue