Added simplified direct config interface.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1406 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-05-16 09:27:06 +00:00
parent f03079af6e
commit f089f28bd4
20 changed files with 145 additions and 166 deletions

View File

@ -99,6 +99,7 @@ void zmLoadConfig()
fclose( cfg); fclose( cfg);
zmDbConnect(); zmDbConnect();
config.Load(); config.Load();
config.Assign();
} }
ConfigItem::ConfigItem( const char *p_name, const char *p_value, const char *const p_type ) ConfigItem::ConfigItem( const char *p_name, const char *p_value, const char *const p_type )
@ -237,6 +238,11 @@ void Config::Load()
} }
} }
void Config::Assign()
{
ZM_CFG_ASSIGN_LIST
}
const ConfigItem &Config::Item( int id ) const ConfigItem &Config::Item( int id )
{ {
if ( !n_items ) if ( !n_items )

View File

@ -88,6 +88,9 @@ public:
class Config class Config
{ {
public:
ZM_CFG_DECLARE_LIST
private: private:
int n_items; int n_items;
ConfigItem **items; ConfigItem **items;
@ -97,6 +100,7 @@ public:
~Config(); ~Config();
void Load(); void Load();
void Assign();
const ConfigItem &Item( int id ); const ConfigItem &Item( int id );
}; };

View File

@ -33,8 +33,6 @@
#include "zmf.h" #include "zmf.h"
bool Event::initialised = false; bool Event::initialised = false;
bool Event::timestamp_on_capture;
int Event::bulk_frame_interval;
char Event::capture_file_format[PATH_MAX]; char Event::capture_file_format[PATH_MAX];
char Event::analyse_file_format[PATH_MAX]; char Event::analyse_file_format[PATH_MAX];
char Event::general_file_format[PATH_MAX]; char Event::general_file_format[PATH_MAX];
@ -63,7 +61,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const char *event
alarm_frames = 0; alarm_frames = 0;
tot_score = 0; tot_score = 0;
max_score = 0; max_score = 0;
snprintf( path, sizeof(path), "%s/%d/%d", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Id(), id ); snprintf( path, sizeof(path), "%s/%d/%d", config.dir_events, monitor->Id(), id );
struct stat statbuf; struct stat statbuf;
errno = 0; errno = 0;
@ -128,7 +126,7 @@ bool Event::OpenFrameSocket( int monitor_id )
return( false ); return( false );
} }
int socket_buffer_size = (int)config.Item( ZM_FRAME_SOCKET_SIZE ); int socket_buffer_size = config.frame_socket_size;
if ( socket_buffer_size > 0 ) if ( socket_buffer_size > 0 )
{ {
if ( setsockopt( sd, SOL_SOCKET, SO_SNDBUF, &socket_buffer_size, sizeof(socket_buffer_size) ) < 0 ) if ( setsockopt( sd, SOL_SOCKET, SO_SNDBUF, &socket_buffer_size, sizeof(socket_buffer_size) ) < 0 )
@ -158,7 +156,7 @@ bool Event::OpenFrameSocket( int monitor_id )
} }
char sock_path[PATH_MAX] = ""; char sock_path[PATH_MAX] = "";
snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", (const char *)config.Item( ZM_PATH_SOCKS ), monitor_id ); snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", config.path_socks, monitor_id );
struct sockaddr_un addr; struct sockaddr_un addr;
@ -243,9 +241,9 @@ bool Event::SendFrameImage( const Image *image, bool alarm_frame )
bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame ) bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame )
{ {
if ( timestamp_on_capture ) if ( config.timestamp_on_capture )
{ {
if ( !(bool)config.Item( ZM_OPT_FRAME_SERVER ) || !SendFrameImage( image, alarm_frame) ) if ( !config.opt_frame_server || !SendFrameImage( image, alarm_frame) )
{ {
image->WriteJpeg( event_file ); image->WriteJpeg( event_file );
} }
@ -254,7 +252,7 @@ bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char
{ {
Image ts_image( *image ); Image ts_image( *image );
monitor->TimestampImage( &ts_image, timestamp.tv_sec ); monitor->TimestampImage( &ts_image, timestamp.tv_sec );
if ( !(bool)config.Item( ZM_OPT_FRAME_SERVER ) || !SendFrameImage( &ts_image, alarm_frame) ) if ( !config.opt_frame_server || !SendFrameImage( &ts_image, alarm_frame) )
{ {
ts_image.WriteJpeg( event_file ); ts_image.WriteJpeg( event_file );
} }
@ -307,7 +305,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
struct DeltaTimeval delta_time; struct DeltaTimeval delta_time;
DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 ); DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 );
bool db_frame = (score>=0) || ((frames%bulk_frame_interval)==0) || !frames; bool db_frame = (score>=0) || ((frames%config.bulk_frame_interval)==0) || !frames;
if ( db_frame ) if ( db_frame )
{ {
@ -343,11 +341,11 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
} }
} }
if ( (bool)config.Item( ZM_RECORD_DIAG_IMAGES ) ) if ( config.record_diag_images )
{ {
char diag_glob[PATH_MAX] = ""; char diag_glob[PATH_MAX] = "";
snprintf( diag_glob, sizeof(diag_glob), "%s/%d/diag-*.jpg", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Id() ); snprintf( diag_glob, sizeof(diag_glob), "%s/%d/diag-*.jpg", config.dir_events, monitor->Id() );
glob_t pglob; glob_t pglob;
int glob_status = glob( diag_glob, 0, 0, &pglob ); int glob_status = glob( diag_glob, 0, 0, &pglob );
if ( glob_status != 0 ) if ( glob_status != 0 )
@ -414,7 +412,7 @@ void Event::StreamEvent( int event_id, int scale, int rate, int maxfps )
exit( mysql_errno( &dbconn ) ); exit( mysql_errno( &dbconn ) );
} }
snprintf( eventpath, sizeof(eventpath), "%s/%s/%d/%d", ZM_PATH_WEB, (const char *)config.Item( ZM_DIR_EVENTS ), atoi( dbrow[0] ), event_id ); snprintf( eventpath, sizeof(eventpath), "%s/%s/%d/%d", ZM_PATH_WEB, config.dir_events, atoi( dbrow[0] ), event_id );
int frames = atoi(dbrow[2]); int frames = atoi(dbrow[2]);
double duration = atof(dbrow[3]); double duration = atof(dbrow[3]);
@ -538,8 +536,6 @@ void Event::StreamMpeg( int event_id, const char *format, int scale, int rate, i
if ( !initialised ) if ( !initialised )
Initialise(); Initialise();
bool timed_frames = (bool)config.Item( ZM_VIDEO_TIMED_FRAMES );
snprintf( sql, sizeof(sql), "select M.Id, M.Name, E.Frames, max(F.Delta)-min(F.Delta) as Duration from Events as E inner join Monitors as M on E.MonitorId = M.Id inner join Frames as F on E.Id = F.EventId where E.Id = %d group by E.Id", event_id ); snprintf( sql, sizeof(sql), "select M.Id, M.Name, E.Frames, max(F.Delta)-min(F.Delta) as Duration from Events as E inner join Monitors as M on E.MonitorId = M.Id inner join Frames as F on E.Id = F.EventId where E.Id = %d group by E.Id", event_id );
if ( mysql_query( &dbconn, sql ) ) if ( mysql_query( &dbconn, sql ) )
{ {
@ -561,7 +557,7 @@ void Event::StreamMpeg( int event_id, const char *format, int scale, int rate, i
exit( mysql_errno( &dbconn ) ); exit( mysql_errno( &dbconn ) );
} }
snprintf( eventpath, sizeof(eventpath), "%s/%s/%d/%d", ZM_PATH_WEB, (const char *)config.Item( ZM_DIR_EVENTS ), atoi( dbrow[0] ), event_id ); snprintf( eventpath, sizeof(eventpath), "%s/%s/%d/%d", ZM_PATH_WEB, config.dir_events, atoi( dbrow[0] ), event_id );
int frames = atoi(dbrow[2]); int frames = atoi(dbrow[2]);
double duration = atof(dbrow[3]); double duration = atof(dbrow[3]);
@ -633,7 +629,7 @@ void Event::StreamMpeg( int event_id, const char *format, int scale, int rate, i
delta_ms = (unsigned int)((last_delta+temp_delta)*1000); delta_ms = (unsigned int)((last_delta+temp_delta)*1000);
if ( rate != ZM_RATE_SCALE ) if ( rate != ZM_RATE_SCALE )
delta_ms = (delta_ms*ZM_RATE_SCALE)/rate; delta_ms = (delta_ms*ZM_RATE_SCALE)/rate;
double pts = vid_stream->EncodeFrame( image.Buffer(), image.Size(), timed_frames, delta_ms ); double pts = vid_stream->EncodeFrame( image.Buffer(), image.Size(), config.video_timed_frames, delta_ms );
Debug( 2, ( "I:%d, DI:%d, LI:%d, DD:%lf, LD:%lf, TD:%lf, DM:%d, PTS:%lf", id, db_id, last_id, db_delta, last_delta, temp_delta, delta_ms, pts )); Debug( 2, ( "I:%d, DI:%d, LI:%d, DD:%lf, LD:%lf, TD:%lf, DM:%d, PTS:%lf", id, db_id, last_id, db_delta, last_delta, temp_delta, delta_ms, pts ));

View File

@ -45,8 +45,6 @@ class Event
{ {
protected: protected:
static bool initialised; static bool initialised;
static bool timestamp_on_capture;
static int bulk_frame_interval;
static char capture_file_format[PATH_MAX]; static char capture_file_format[PATH_MAX];
static char analyse_file_format[PATH_MAX]; static char analyse_file_format[PATH_MAX];
static char general_file_format[PATH_MAX]; static char general_file_format[PATH_MAX];
@ -85,11 +83,9 @@ protected:
{ {
initialised = true; initialised = true;
timestamp_on_capture = (bool)config.Item( ZM_TIMESTAMP_ON_CAPTURE ); snprintf( capture_file_format, sizeof(capture_file_format), "%%s/%%0%dd-capture.jpg", config.event_image_digits );
bulk_frame_interval = (int)config.Item( ZM_BULK_FRAME_INTERVAL ); snprintf( analyse_file_format, sizeof(analyse_file_format), "%%s/%%0%dd-analyse.jpg", config.event_image_digits );
snprintf( capture_file_format, sizeof(capture_file_format), "%%s/%%0%dd-capture.jpg", (int)config.Item( ZM_EVENT_IMAGE_DIGITS ) ); snprintf( general_file_format, sizeof(general_file_format), "%%s/%%0%dd-%%s", config.event_image_digits );
snprintf( analyse_file_format, sizeof(analyse_file_format), "%%s/%%0%dd-analyse.jpg", (int)config.Item( ZM_EVENT_IMAGE_DIGITS ) );
snprintf( general_file_format, sizeof(general_file_format), "%%s/%%0%dd-%%s", (int)config.Item( ZM_EVENT_IMAGE_DIGITS ) );
} }
public: public:

View File

@ -23,9 +23,6 @@
#define ABSDIFF(a,b) (((a)<(b))?((b)-(a)):((a)-(b))) #define ABSDIFF(a,b) (((a)<(b))?((b)-(a)):((a)-(b)))
bool Image::initialised = false; bool Image::initialised = false;
bool Image::y_image_deltas;
bool Image::fast_image_blends;
bool Image::colour_jpeg_files;
unsigned char *Image::abs_table; unsigned char *Image::abs_table;
unsigned char *Image::y_r_table; unsigned char *Image::y_r_table;
unsigned char *Image::y_g_table; unsigned char *Image::y_g_table;
@ -36,9 +33,6 @@ void Image::Initialise()
{ {
initialised = true; initialised = true;
y_image_deltas = (bool)config.Item( ZM_Y_IMAGE_DELTAS );
fast_image_blends = (bool)config.Item( ZM_FAST_IMAGE_BLENDS );
colour_jpeg_files = (bool)config.Item( ZM_COLOUR_JPEG_FILES );
abs_table = new unsigned char[(6*255)+1]; abs_table = new unsigned char[(6*255)+1];
abs_table += (3*255); abs_table += (3*255);
y_r_table = new unsigned char[511]; y_r_table = new unsigned char[511];
@ -164,7 +158,7 @@ void Image::ReadJpeg( const char *filename )
void Image::WriteJpeg( const char *filename ) const void Image::WriteJpeg( const char *filename ) const
{ {
if ( colour_jpeg_files && colours == 1 ) if ( config.colour_jpeg_files && colours == 1 )
{ {
Image temp_image( *this ); Image temp_image( *this );
temp_image.Colourise(); temp_image.Colourise();
@ -199,7 +193,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, (int)config.Item( ZM_JPEG_FILE_QUALITY ), false); jpeg_set_quality(&cinfo, config.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 */
@ -254,7 +248,7 @@ void Image::DecodeJpeg( JOCTET *inbuffer, int inbuffer_size )
void Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size ) const void Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size ) const
{ {
if ( colour_jpeg_files && colours == 1 ) if ( config.colour_jpeg_files && colours == 1 )
{ {
Image temp_image( *this ); Image temp_image( *this );
temp_image.Colourise(); temp_image.Colourise();
@ -282,7 +276,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, (int)config.Item( ZM_JPEG_IMAGE_QUALITY ), false); jpeg_set_quality(&cinfo, config.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 */
@ -371,7 +365,7 @@ void Image::Blend( const Image &image, int transparency ) const
{ {
assert( width == image.width && height == image.height && colours == image.colours ); assert( width == image.width && height == image.height && colours == image.colours );
if ( fast_image_blends ) if ( config.fast_image_blends )
{ {
BlendTablePtr blend_ptr = GetBlendTable( transparency ); BlendTablePtr blend_ptr = GetBlendTable( transparency );
@ -540,7 +534,7 @@ Image *Image::Delta( const Image &image ) const
register int red, green, blue; register int red, green, blue;
while( psrc < (buffer+size) ) while( psrc < (buffer+size) )
{ {
if ( y_image_deltas ) 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++]; red = y_r_table[*psrc++ - *pref++];

View File

@ -50,9 +50,6 @@ protected:
protected: protected:
static bool initialised; static bool initialised;
static bool y_image_deltas;
static bool fast_image_blends;
static bool colour_jpeg_files;
static unsigned char *abs_table; static unsigned char *abs_table;
static unsigned char *y_r_table; static unsigned char *y_r_table;
static unsigned char *y_g_table; static unsigned char *y_g_table;

View File

@ -114,7 +114,8 @@ void LocalCamera::Initialise()
if ( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) < 0 ) 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 ( (bool)config.Item( ZM_STRICT_VIDEO_CONFIG ) ) exit(-1); if ( config.strict_video_config )
exit(-1);
} }
struct video_window vid_win; struct video_window vid_win;
@ -140,7 +141,8 @@ void LocalCamera::Initialise()
if ( ioctl( m_videohandle, VIDIOCSWIN, &vid_win ) < 0 ) 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 ( (bool)config.Item( ZM_STRICT_VIDEO_CONFIG ) ) exit(-1); if ( config.strict_video_config )
exit(-1);
} }
if ( ioctl(m_videohandle, VIDIOCGMBUF, &m_vmb) < 0 ) if ( ioctl(m_videohandle, VIDIOCGMBUF, &m_vmb) < 0 )
@ -186,7 +188,8 @@ void LocalCamera::Initialise()
if ( ioctl( m_videohandle, VIDIOCSCHAN, &vid_src) < 0 ) 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 ( (bool)config.Item( ZM_STRICT_VIDEO_CONFIG ) ) exit(-1); if ( config.strict_video_config )
exit(-1);
} }
if ( ioctl( m_videohandle, VIDIOCGWIN, &vid_win) < 0 ) if ( ioctl( m_videohandle, VIDIOCGWIN, &vid_win) < 0 )
@ -785,7 +788,7 @@ int LocalCamera::PostCapture( Image &image )
} }
case VIDEO_PALETTE_RGB24 : case VIDEO_PALETTE_RGB24 :
{ {
if ( (bool)config.Item( ZM_LOCAL_BGR_INVERT ) ) if ( config.local_bgr_invert )
{ {
int size = width*height*3; int size = width*height*3;
unsigned char *s_ptr = buffer; unsigned char *s_ptr = buffer;

View File

@ -27,17 +27,6 @@
#include "zm_local_camera.h" #include "zm_local_camera.h"
#include "zm_remote_camera.h" #include "zm_remote_camera.h"
bool Monitor::initialised = false;
bool Monitor::record_event_stats;
bool Monitor::record_diag_images;
bool Monitor::opt_adaptive_skip;
bool Monitor::create_analysis_images;
bool Monitor::blend_alarmed_images;
bool Monitor::timestamp_on_capture;
int Monitor::bulk_frame_interval;
bool Monitor::opt_control;
const char *Monitor::dir_events;
Monitor::Monitor( Monitor::Monitor(
int p_id, int p_id,
char *p_name, char *p_name,
@ -219,9 +208,6 @@ Monitor::~Monitor()
void Monitor::Setup() void Monitor::Setup()
{ {
if ( !initialised )
Initialise();
fps = 0.0; fps = 0.0;
event_count = 0; event_count = 0;
image_count = 0; image_count = 0;
@ -240,7 +226,7 @@ void Monitor::Setup()
int shared_data_size = sizeof(SharedData)+sizeof(TriggerData)+(image_buffer_count*sizeof(time_t))+(image_buffer_count*camera->ImageSize()); int shared_data_size = sizeof(SharedData)+sizeof(TriggerData)+(image_buffer_count*sizeof(time_t))+(image_buffer_count*camera->ImageSize());
Debug( 1, ( "shm.size=%d", shared_data_size )); Debug( 1, ( "shm.size=%d", shared_data_size ));
shmid = shmget( (int)config.Item( ZM_SHM_KEY )|id, shared_data_size, IPC_CREAT|0700 ); shmid = shmget( config.shm_key|id, shared_data_size, IPC_CREAT|0700 );
if ( shmid < 0 ) if ( shmid < 0 )
{ {
Error(( "Can't shmget, probably not enough shared memory space free: %s", strerror(errno))); Error(( "Can't shmget, probably not enough shared memory space free: %s", strerror(errno)));
@ -310,7 +296,7 @@ void Monitor::Setup()
{ {
static char path[PATH_MAX]; static char path[PATH_MAX];
strncpy( path, dir_events, sizeof(path) ); strncpy( path, config.dir_events, sizeof(path) );
struct stat statbuf; struct stat statbuf;
errno = 0; errno = 0;
@ -323,7 +309,7 @@ void Monitor::Setup()
} }
} }
snprintf( path, sizeof(path), "%s/%d", dir_events, id ); snprintf( path, sizeof(path), "%s/%d", config.dir_events, id );
errno = 0; errno = 0;
stat( path, &statbuf ); stat( path, &statbuf );
@ -335,7 +321,7 @@ void Monitor::Setup()
} }
char temp_path[PATH_MAX]; char temp_path[PATH_MAX];
snprintf( temp_path, sizeof(temp_path), "%d", id ); snprintf( temp_path, sizeof(temp_path), "%d", id );
chdir( dir_events ); chdir( config.dir_events );
symlink( temp_path, name ); symlink( temp_path, name );
chdir( ".." ); chdir( ".." );
} }
@ -376,7 +362,7 @@ int Monitor::GetImage( int index, int scale ) const
static char filename[PATH_MAX]; static char filename[PATH_MAX];
snprintf( filename, sizeof(filename), "%s.jpg", name ); snprintf( filename, sizeof(filename), "%s.jpg", name );
if ( !timestamp_on_capture ) if ( !config.timestamp_on_capture )
{ {
TimestampImage( &snap_image, snap->timestamp->tv_sec ); TimestampImage( &snap_image, snap->timestamp->tv_sec );
} }
@ -673,7 +659,7 @@ bool Monitor::Analyse()
} }
int index; int index;
if ( opt_adaptive_skip ) if ( config.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;
@ -787,7 +773,7 @@ bool Monitor::Analyse()
Info(( "%s: %03d - Starting new event %d", name, image_count, event->Id() )); Info(( "%s: %03d - Starting new event %d", name, image_count, event->Id() ));
//if ( (bool)config.Item( ZM_OVERLAP_TIMED_EVENTS ) ) //if ( config.overlap_timed_events )
if ( true ) if ( true )
{ {
int pre_index = ((index+image_buffer_count)-pre_event_count)%image_buffer_count; int pre_index = ((index+image_buffer_count)-pre_event_count)%image_buffer_count;
@ -807,7 +793,7 @@ bool Monitor::Analyse()
} }
if ( score ) if ( score )
{ {
if ( opt_control && track_motion && (activity_state != ACTIVE) ) if ( config.opt_control && track_motion && (activity_state != ACTIVE) )
{ {
// Do nothing // Do nothing
} }
@ -864,7 +850,7 @@ bool Monitor::Analyse()
} }
else else
{ {
if ( opt_control && track_motion && (activity_state != ACTIVE) ) if ( config.opt_control && track_motion && (activity_state != ACTIVE) )
{ {
// Do nothing // Do nothing
} }
@ -909,7 +895,7 @@ bool Monitor::Analyse()
{ {
if ( state == PREALARM || state == ALARM ) if ( state == PREALARM || state == ALARM )
{ {
if ( create_analysis_images ) if ( config.create_analysis_images )
{ {
bool got_anal_image = false; bool got_anal_image = false;
Image alarm_image( *snap_image ); Image alarm_image( *snap_image );
@ -922,7 +908,7 @@ bool Monitor::Analyse()
alarm_image.Overlay( *(zones[i]->AlarmImage()) ); alarm_image.Overlay( *(zones[i]->AlarmImage()) );
got_anal_image = true; got_anal_image = true;
} }
if ( record_event_stats && state == ALARM ) if ( config.record_event_stats && state == ALARM )
{ {
zones[i]->RecordStats( event ); zones[i]->RecordStats( event );
} }
@ -959,7 +945,7 @@ bool Monitor::Analyse()
{ {
if ( !(image_count%(frame_skip+1)) ) if ( !(image_count%(frame_skip+1)) )
{ {
if ( bulk_frame_interval > 1 ) if ( config.bulk_frame_interval > 1 )
{ {
event->AddFrame( snap_image, *timestamp, -1 ); event->AddFrame( snap_image, *timestamp, -1 );
} }
@ -991,7 +977,7 @@ bool Monitor::Analyse()
} }
} }
if ( (function == MODECT || function == MOCORD) && (blend_alarmed_images || state != ALARM) ) if ( (function == MODECT || function == MOCORD) && (config.blend_alarmed_images || state != ALARM) )
{ {
ref_image.Blend( *snap_image, ref_blend_perc ); ref_image.Blend( *snap_image, ref_blend_perc );
} }
@ -1335,7 +1321,7 @@ void Monitor::StreamImages( int scale, int maxfps, time_t ttl )
snap_image = &scaled_image; snap_image = &scaled_image;
} }
if ( !timestamp_on_capture ) if ( !config.timestamp_on_capture )
{ {
TimestampImage( snap_image, snap->timestamp->tv_sec ); TimestampImage( snap_image, snap->timestamp->tv_sec );
} }
@ -1378,7 +1364,7 @@ void Monitor::SingleImage( int scale)
scaled_image.Scale( scale ); scaled_image.Scale( scale );
snap_image = &scaled_image; snap_image = &scaled_image;
} }
if ( !timestamp_on_capture ) if ( !config.timestamp_on_capture )
{ {
TimestampImage( snap_image, snap->timestamp->tv_sec ); TimestampImage( snap_image, snap->timestamp->tv_sec );
} }
@ -1393,8 +1379,6 @@ void Monitor::SingleImage( int scale)
void Monitor::StreamMpeg( const char *format, int scale, int maxfps, int bitrate ) void Monitor::StreamMpeg( const char *format, int scale, int maxfps, int bitrate )
{ {
bool timed_frames = (bool)config.Item( ZM_VIDEO_TIMED_FRAMES );
int fps = int(GetFPS()); int fps = int(GetFPS());
if ( !fps ) if ( !fps )
fps = 5; fps = 5;
@ -1450,7 +1434,7 @@ void Monitor::StreamMpeg( const char *format, int scale, int maxfps, int bitrate
snap_image = &scaled_image; snap_image = &scaled_image;
} }
if ( !timestamp_on_capture ) if ( !config.timestamp_on_capture )
{ {
TimestampImage( snap_image, snap->timestamp->tv_sec ); TimestampImage( snap_image, snap->timestamp->tv_sec );
} }
@ -1460,7 +1444,7 @@ void Monitor::StreamMpeg( const char *format, int scale, int maxfps, int bitrate
base_time = *(snap->timestamp); base_time = *(snap->timestamp);
} }
DELTA_TIMEVAL( delta_time, *(snap->timestamp), base_time, DT_PREC_3 ); DELTA_TIMEVAL( delta_time, *(snap->timestamp), base_time, DT_PREC_3 );
double pts = vid_stream.EncodeFrame( snap_image->Buffer(), snap_image->Size(), timed_frames, delta_time.delta ); double pts = vid_stream.EncodeFrame( snap_image->Buffer(), snap_image->Size(), config.video_timed_frames, delta_time.delta );
//Info(( "FC:%d, DTD:%d, PTS:%lf", frame_count, delta_time.delta, pts )); //Info(( "FC:%d, DTD:%d, PTS:%lf", frame_count, delta_time.delta, pts ));
} }
frame_count++; frame_count++;
@ -1528,24 +1512,24 @@ unsigned int Monitor::Compare( const Image &comp_image )
if ( n_zones <= 0 ) return( alarm ); if ( n_zones <= 0 ) return( alarm );
if ( record_diag_images ) if ( config.record_diag_images )
{ {
static char diag_path[PATH_MAX] = ""; static char diag_path[PATH_MAX] = "";
if ( !diag_path[0] ) if ( !diag_path[0] )
{ {
snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-r.jpg", dir_events, id ); snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-r.jpg", config.dir_events, id );
} }
ref_image.WriteJpeg( diag_path ); ref_image.WriteJpeg( diag_path );
} }
Image *delta_image = ref_image.Delta( comp_image ); Image *delta_image = ref_image.Delta( comp_image );
if ( record_diag_images ) if ( config.record_diag_images )
{ {
static char diag_path[PATH_MAX] = ""; static char diag_path[PATH_MAX] = "";
if ( !diag_path[0] ) if ( !diag_path[0] )
{ {
snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-d.jpg", dir_events, id ); snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-d.jpg", config.dir_events, id );
} }
delta_image->WriteJpeg( diag_path ); delta_image->WriteJpeg( diag_path );
} }
@ -1608,7 +1592,7 @@ unsigned int Monitor::Compare( const Image &comp_image )
score += zone->Score(); score += zone->Score();
zone->SetAlarm(); zone->SetAlarm();
Debug( 3, ( "Zone is alarmed, zone score = %d", zone->Score() )); Debug( 3, ( "Zone is alarmed, zone score = %d", zone->Score() ));
if ( opt_control && track_motion ) if ( config.opt_control && track_motion )
{ {
if ( (int)zone->Score() > top_score ) if ( (int)zone->Score() > top_score )
{ {
@ -1635,7 +1619,7 @@ unsigned int Monitor::Compare( const Image &comp_image )
score += zone->Score(); score += zone->Score();
zone->SetAlarm(); zone->SetAlarm();
Debug( 3, ( "Zone is alarmed, zone score = %d", zone->Score() )); Debug( 3, ( "Zone is alarmed, zone score = %d", zone->Score() ));
if ( opt_control && track_motion ) if ( config.opt_control && track_motion )
{ {
if ( zone->Score() > top_score ) if ( zone->Score() > top_score )
{ {

View File

@ -65,18 +65,6 @@ public:
typedef enum { ACTIVE, SUSPENDED, RESUMING } ActivityState; typedef enum { ACTIVE, SUSPENDED, RESUMING } ActivityState;
protected:
static bool initialised;
static bool record_event_stats;
static bool record_diag_images;
static bool opt_adaptive_skip;
static bool create_analysis_images;
static bool blend_alarmed_images;
static bool timestamp_on_capture;
static int bulk_frame_interval;
static bool opt_control;
static const char *dir_events;
protected: protected:
// These are read from the DB and thereafter remain unchanged // These are read from the DB and thereafter remain unchanged
int id; int id;
@ -168,22 +156,6 @@ protected:
Camera *camera; Camera *camera;
protected:
static void Initialise()
{
initialised = true;
record_event_stats = (bool)config.Item( ZM_RECORD_EVENT_STATS );
record_diag_images = (bool)config.Item( ZM_RECORD_DIAG_IMAGES );
opt_adaptive_skip = (bool)config.Item( ZM_OPT_ADAPTIVE_SKIP );
create_analysis_images = (bool)config.Item( ZM_CREATE_ANALYSIS_IMAGES );
blend_alarmed_images = (bool)config.Item( ZM_BLEND_ALARMED_IMAGES );
timestamp_on_capture = (bool)config.Item( ZM_TIMESTAMP_ON_CAPTURE );
bulk_frame_interval = (int)config.Item( ZM_BULK_FRAME_INTERVAL );
opt_control = (bool)config.Item( ZM_OPT_CONTROL );
dir_events = (const char *)config.Item( ZM_DIR_EVENTS );
}
public: public:
Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, int p_brightness, int p_contrast, int p_hue, int p_colour, char *p_event_prefix, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_track_motion, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 ); Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, int p_brightness, int p_contrast, int p_hue, int p_colour, char *p_event_prefix, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_track_motion, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, int p_brightness, int p_contrast, int p_hue, int p_colour, char *p_event_prefix, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_track_motion, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 ); Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, int p_brightness, int p_contrast, int p_hue, int p_colour, char *p_event_prefix, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_track_motion, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
@ -283,7 +255,7 @@ public:
} }
gettimeofday( image_buffer[index].timestamp, &dummy_tz ); gettimeofday( image_buffer[index].timestamp, &dummy_tz );
if ( timestamp_on_capture ) if ( config.timestamp_on_capture )
{ {
TimestampImage( &image, image_buffer[index].timestamp->tv_sec ); TimestampImage( &image, image_buffer[index].timestamp->tv_sec );
} }

View File

@ -38,8 +38,6 @@
#include "zm.h" #include "zm.h"
#include "zm_remote_camera.h" #include "zm_remote_camera.h"
bool RemoteCamera::netcam_regexps = false;
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 ), host( p_host ), port( p_port ), path( p_path ) 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 ), host( p_host ), port( p_port ), path( p_path )
{ {
auth = 0; auth = 0;
@ -67,8 +65,6 @@ RemoteCamera::~RemoteCamera()
void RemoteCamera::Initialise() void RemoteCamera::Initialise()
{ {
netcam_regexps = (bool)config.Item( ZM_NETCAM_REGEXPS );
if( !host ) if( !host )
{ {
Error(( "No host specified for remote get" )); Error(( "No host specified for remote get" ));
@ -112,8 +108,8 @@ void RemoteCamera::Initialise()
if ( !request[0] ) if ( !request[0] )
{ {
snprintf( request, sizeof(request), "GET %s HTTP/%s\n", path, (const char *)config.Item( ZM_HTTP_VERSION ) ); snprintf( request, sizeof(request), "GET %s HTTP/%s\n", path, config.http_version );
snprintf( &(request[strlen(request)]), sizeof(request)-strlen(request), "User-Agent: %s/%s\n", (const char *)config.Item( ZM_HTTP_UA ), ZM_VERSION ); snprintf( &(request[strlen(request)]), sizeof(request)-strlen(request), "User-Agent: %s/%s\n", config.http_ua, ZM_VERSION );
snprintf( &(request[strlen(request)]), sizeof(request)-strlen(request), "Host: %s\n", host ); snprintf( &(request[strlen(request)]), sizeof(request)-strlen(request), "Host: %s\n", host );
snprintf( &(request[strlen(request)]), sizeof(request)-strlen(request), "Connection: Keep-Alive\n" ); snprintf( &(request[strlen(request)]), sizeof(request)-strlen(request), "Connection: Keep-Alive\n" );
if ( auth ) if ( auth )
@ -125,8 +121,8 @@ void RemoteCamera::Initialise()
} }
if ( !timeout.tv_sec ) if ( !timeout.tv_sec )
{ {
timeout.tv_sec = (int)config.Item( ZM_HTTP_TIMEOUT )/1000; timeout.tv_sec = config.http_timeout/1000;
timeout.tv_usec = (int)config.Item( ZM_HTTP_TIMEOUT )%1000; timeout.tv_usec = config.http_timeout%1000;
} }
int max_size = width*height*colours; int max_size = width*height*colours;
@ -258,7 +254,7 @@ int RemoteCamera::ReadData( Buffer &buffer, int bytes_expected )
int RemoteCamera::GetResponse() int RemoteCamera::GetResponse()
{ {
#if HAVE_LIBPCRE #if HAVE_LIBPCRE
if ( netcam_regexps ) if ( config.netcam_regexps )
{ {
const char *header = 0; const char *header = 0;
int header_len = 0; int header_len = 0;

View File

@ -188,7 +188,7 @@ User *zmLoadAuthUser( const char *auth, bool use_remote_addr )
struct tm *now_tm = localtime( &now ); struct tm *now_tm = localtime( &now );
snprintf( auth_key, sizeof(auth_key), "%s%s%s%s%d%d%d%d", snprintf( auth_key, sizeof(auth_key), "%s%s%s%s%d%d%d%d",
(const char *)config.Item( ZM_AUTH_SECRET ), config.auth_secret,
user, user,
pass, pass,
remote_addr, remote_addr,

View File

@ -23,15 +23,8 @@
#include "zm_image.h" #include "zm_image.h"
#include "zm_monitor.h" #include "zm_monitor.h"
bool Zone::initialised = false;
bool Zone::record_diag_images;
bool Zone::create_analysis_images;
void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Box &p_limits, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold, int p_max_pixel_threshold, int p_min_alarm_pixels, int p_max_alarm_pixels, const Coord &p_filter_box, int p_min_filter_pixels, int p_max_filter_pixels, int p_min_blob_pixels, int p_max_blob_pixels, int p_min_blobs, int p_max_blobs ) void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Box &p_limits, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold, int p_max_pixel_threshold, int p_min_alarm_pixels, int p_max_alarm_pixels, const Coord &p_filter_box, int p_min_filter_pixels, int p_max_filter_pixels, int p_min_blob_pixels, int p_max_blob_pixels, int p_min_blobs, int p_max_blobs )
{ {
if ( !initialised )
Initialise();
monitor = p_monitor; monitor = p_monitor;
id = p_id; id = p_id;
@ -123,12 +116,12 @@ bool Zone::CheckAlarms( const Image *delta_image )
} }
} }
} }
if ( record_diag_images ) if ( config.record_diag_images )
{ {
static char diag_path[PATH_MAX] = ""; static char diag_path[PATH_MAX] = "";
if ( !diag_path[0] ) if ( !diag_path[0] )
{ {
snprintf( diag_path, sizeof(diag_path), "%s/%s/diag-%d-%d.jpg", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Name(), id, 1 ); snprintf( diag_path, sizeof(diag_path), "%s/%s/diag-%d-%d.jpg", config.dir_events, monitor->Name(), id, 1 );
} }
diff_image->WriteJpeg( diag_path ); diff_image->WriteJpeg( diag_path );
} }
@ -199,12 +192,12 @@ bool Zone::CheckAlarms( const Image *delta_image )
{ {
alarm_filter_pixels = alarm_pixels; alarm_filter_pixels = alarm_pixels;
} }
if ( record_diag_images ) if ( config.record_diag_images )
{ {
static char diag_path[PATH_MAX] = ""; static char diag_path[PATH_MAX] = "";
if ( !diag_path[0] ) if ( !diag_path[0] )
{ {
snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Id(), id, 2 ); snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", config.dir_events, monitor->Id(), id, 2 );
} }
diff_image->WriteJpeg( diag_path ); diff_image->WriteJpeg( diag_path );
} }
@ -347,12 +340,12 @@ bool Zone::CheckAlarms( const Image *delta_image )
} }
} }
} }
if ( record_diag_images ) if ( config.record_diag_images )
{ {
static char diag_path[PATH_MAX] = ""; static char diag_path[PATH_MAX] = "";
if ( !diag_path[0] ) if ( !diag_path[0] )
{ {
snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Id(), id, 3 ); snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", config.dir_events, monitor->Id(), id, 3 );
} }
diff_image->WriteJpeg( diag_path ); diff_image->WriteJpeg( diag_path );
} }
@ -398,12 +391,12 @@ bool Zone::CheckAlarms( const Image *delta_image )
} }
} }
} }
if ( record_diag_images ) if ( config.record_diag_images )
{ {
static char diag_path[PATH_MAX] = ""; static char diag_path[PATH_MAX] = "";
if ( !diag_path[0] ) if ( !diag_path[0] )
{ {
snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Id(), id, 4 ); snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", config.dir_events, monitor->Id(), id, 4 );
} }
diff_image->WriteJpeg( diag_path ); diff_image->WriteJpeg( diag_path );
} }
@ -483,7 +476,7 @@ bool Zone::CheckAlarms( const Image *delta_image )
alarm_centre = alarm_box.Centre(); alarm_centre = alarm_box.Centre();
} }
if ( (type < PRECLUSIVE) && check_method >= BLOBS && create_analysis_images ) if ( (type < PRECLUSIVE) && check_method >= BLOBS && config.create_analysis_images )
{ {
image = diff_image->HighlightEdges( alarm_rgb, &limits ); image = diff_image->HighlightEdges( alarm_rgb, &limits );
// Only need to delete this when 'image' becomes detached and points somewhere else // Only need to delete this when 'image' becomes detached and points somewhere else

View File

@ -38,11 +38,6 @@ public:
typedef enum { ACTIVE=1, INCLUSIVE, EXCLUSIVE, PRECLUSIVE, INACTIVE } ZoneType; typedef enum { ACTIVE=1, INCLUSIVE, EXCLUSIVE, PRECLUSIVE, INACTIVE } ZoneType;
typedef enum { ALARMED_PIXELS=1, FILTERED_PIXELS, BLOBS } CheckMethod; typedef enum { ALARMED_PIXELS=1, FILTERED_PIXELS, BLOBS } CheckMethod;
protected:
static bool initialised;
static bool record_diag_images;
static bool create_analysis_images;
protected: protected:
// Inputs // Inputs
Monitor *monitor; Monitor *monitor;
@ -83,13 +78,6 @@ protected:
Image *image; Image *image;
protected: protected:
static void Initialise()
{
initialised = true;
record_diag_images = (bool)config.Item( ZM_RECORD_DIAG_IMAGES );
create_analysis_images = (bool)config.Item( ZM_CREATE_ANALYSIS_IMAGES );
}
void Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Box &p_limits, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold, int p_max_pixel_threshold, int p_min_alarm_pixels, int p_max_alarm_pixels, const Coord &p_filter_box, int p_min_filter_pixels, int p_max_filter_pixels, int p_min_blob_pixels, int p_max_blob_pixels, int p_min_blobs, int p_max_blobs ); void Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Box &p_limits, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold, int p_max_pixel_threshold, int p_min_alarm_pixels, int p_max_alarm_pixels, const Coord &p_filter_box, int p_min_filter_pixels, int p_max_filter_pixels, int p_min_blob_pixels, int p_max_blob_pixels, int p_min_blobs, int p_max_blobs );
public: public:

View File

@ -131,7 +131,7 @@ int main( int argc, char *argv[] )
{ {
Info(( "Warming up" )); Info(( "Warming up" ));
if ( (bool)config.Item( ZM_OPT_FRAME_SERVER ) ) if ( config.opt_frame_server )
{ {
Event::OpenFrameSocket( monitor->Id() ); Event::OpenFrameSocket( monitor->Id() );
} }

View File

@ -198,8 +198,6 @@ int main( int argc, char *argv[] )
capture_delays[i] = monitors[i]->GetCaptureDelay(); capture_delays[i] = monitors[i]->GetCaptureDelay();
} }
bool no_max_fps = (bool)config.Item( ZM_NO_MAX_FPS_ON_ALARM );
struct timeval now; struct timeval now;
struct DeltaTimeval delta_time; struct DeltaTimeval delta_time;
while( !zmc_terminate ) while( !zmc_terminate )
@ -209,7 +207,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 ( no_max_fps && (monitors[i]->GetState() == Monitor::ALARM) ) if ( config.no_max_fps_on_alarm && (monitors[i]->GetState() == Monitor::ALARM) )
{ {
next_delays[i] = 0; next_delays[i] = 0;
} }

View File

@ -80,7 +80,7 @@ int OpenSocket( int monitor_id )
} }
char sock_path[PATH_MAX] = ""; char sock_path[PATH_MAX] = "";
snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", (const char *)config.Item( ZM_PATH_SOCKS ), monitor_id ); snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", config.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) ));
@ -202,8 +202,8 @@ int main( int argc, char *argv[] )
char capt_path[PATH_MAX]; char capt_path[PATH_MAX];
char anal_path[PATH_MAX]; char anal_path[PATH_MAX];
snprintf( capt_path, sizeof(capt_path), "%s/%d/%%d/%%0%dd-capture.jpg", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Id(), (int)config.Item( ZM_EVENT_IMAGE_DIGITS ) ); snprintf( capt_path, sizeof(capt_path), "%s/%d/%%d/%%0%dd-capture.jpg", config.dir_events, monitor->Id(), config.event_image_digits );
snprintf( anal_path, sizeof(anal_path), "%s/%d/%%d/%%0%dd-analyse.jpg", (const char *)config.Item( ZM_DIR_EVENTS ), monitor->Id(), (int)config.Item( ZM_EVENT_IMAGE_DIGITS ) ); snprintf( anal_path, sizeof(anal_path), "%s/%d/%%d/%%0%dd-analyse.jpg", config.dir_events, monitor->Id(), config.event_image_digits );
sigset_t block_set; sigset_t block_set;
sigemptyset( &block_set ); sigemptyset( &block_set );

View File

@ -137,13 +137,11 @@ int main( int argc, char *argv[] )
// Yadda yadda // Yadda yadda
mysql_free_result( result ); mysql_free_result( result );
if ( (bool)config.Item( ZM_OPT_X10 ) ) if ( config.opt_x10 )
{ {
const char *x10_port = (const char *)config.Item( ZM_X10_DEVICE ); if ( config.x10_device )
if ( x10_port )
{ {
fixDevice( x10_port ); fixDevice( config.x10_device );
} }
} }
} }

View File

@ -114,7 +114,7 @@ int main( int argc, const char *argv[] )
bitrate = atoi( value ); bitrate = atoi( value );
else if ( !strcmp( name, "ttl" ) ) else if ( !strcmp( name, "ttl" ) )
ttl = atoi(value); ttl = atoi(value);
else if ( (bool)config.Item( ZM_OPT_USE_AUTH ) ) else if ( config.opt_use_auth )
{ {
if ( !strcmp( name, "user" ) ) if ( !strcmp( name, "user" ) )
{ {
@ -132,7 +132,7 @@ int main( int argc, const char *argv[] )
} }
} }
if ( (bool)config.Item( ZM_OPT_USE_AUTH ) ) if ( config.opt_use_auth )
{ {
User *user = 0; User *user = 0;
if ( *username && *password ) if ( *username && *password )

View File

@ -319,7 +319,7 @@ int main( int argc, char *argv[] )
zmLoadConfig(); zmLoadConfig();
if ( (bool)config.Item( ZM_OPT_USE_AUTH ) ) if ( config.opt_use_auth )
{ {
if ( !(username && password) && !auth ) if ( !(username && password) && !auth )
{ {
@ -466,7 +466,7 @@ int main( int argc, char *argv[] )
{ {
if ( verbose ) if ( verbose )
printf( "Forcing alarm on\n" ); printf( "Forcing alarm on\n" );
monitor->ForceAlarmOn( (int)config.Item( ZM_FORCED_ALARM_SCORE ), "Forced Web" ); monitor->ForceAlarmOn( config.forced_alarm_score, "Forced Web" );
} }
if ( function & NOALARM ) if ( function & NOALARM )
{ {

View File

@ -1706,13 +1706,67 @@ if ( $reprocess )
print( CFG_HDR_FILE "// The file is autogenerated by zmconfig.pl\n" ); print( CFG_HDR_FILE "// The file is autogenerated by zmconfig.pl\n" );
print( CFG_HDR_FILE "// Do not edit this file as any changes will be overwritten\n\n" ); print( CFG_HDR_FILE "// Do not edit this file as any changes will be overwritten\n\n" );
my $last_id = 0; my $last_id = 0;
my $define_list = "";
my $declare_list = "";
my $assign_list = "";
foreach my $option ( @options ) foreach my $option ( @options )
{ {
next if ( !defined($option->{id}) ); next if ( !defined($option->{id}) );
printf( CFG_HDR_FILE "#define $option->{name} $option->{id}\n" );
my $opt_id = $option->{id};
my $opt_name = $option->{name};
my $opt_type = $option->{type};
my $var_name = substr( lc($opt_name), 3 );
$define_list .= sprintf( "#define $opt_name $opt_id\n" );
$declare_list .= sprintf( "\t" );
if ( $opt_type == $types{boolean} )
{
$declare_list .= sprintf( "bool " );
}
elsif ( $opt_type == $types{integer} || $opt_type == $types{hexadecimal} )
{
$declare_list .= sprintf( "int " );
}
elsif ( $opt_type == $types{decimal} )
{
$declare_list .= sprintf( "double " );
}
else
{
$declare_list .= sprintf( "const char *" );
}
$declare_list .= sprintf( $var_name.";\\\n" );
$assign_list .= sprintf( "\t" );
$assign_list .= sprintf( $var_name." = " );
if ( $opt_type == $types{boolean} )
{
$assign_list .= sprintf( "(bool)" );
}
elsif ( $opt_type == $types{integer} || $opt_type == $types{hexadecimal} )
{
$assign_list .= sprintf( "(int)" );
}
elsif ( $opt_type == $types{decimal} )
{
$assign_list .= sprintf( "(double) " );
}
else
{
$assign_list .= sprintf( "(const char *)" );
}
$assign_list .= sprintf( "config.Item( ".$opt_name." );\\\n" );
$last_id = $option->{id}; $last_id = $option->{id};
} }
printf( CFG_HDR_FILE "#define ZM_MAX_CFG_ID $last_id\n" ); printf( CFG_HDR_FILE $define_list."\n\n" );
printf( CFG_HDR_FILE "#define ZM_MAX_CFG_ID $last_id\n\n" );
printf( CFG_HDR_FILE "#define ZM_CFG_DECLARE_LIST \\\n" );
printf( CFG_HDR_FILE $declare_list."\n\n" );
printf( CFG_HDR_FILE "#define ZM_CFG_ASSIGN_LIST \\\n" );
printf( CFG_HDR_FILE $assign_list."\n\n" );
close( CFG_HDR_FILE ); close( CFG_HDR_FILE );
my @config_files = qw( zm.conf src/zm_config.h web/zm_config.php scripts/zmdc.pl scripts/zmwatch.pl scripts/zmaudit.pl scripts/zmfilter.pl scripts/zmtrigger.pl scripts/zmx10.pl scripts/zmpkg.pl scripts/zmupdate.pl scripts/zmvideo.pl scripts/zmcontrol-pelco-d.pl scripts/zmcontrol-visca.pl scripts/zmcontrol-kx-hcm10.pl scripts/zmtrack.pl scripts/zm db/zmschema.sql ); my @config_files = qw( zm.conf src/zm_config.h web/zm_config.php scripts/zmdc.pl scripts/zmwatch.pl scripts/zmaudit.pl scripts/zmfilter.pl scripts/zmtrigger.pl scripts/zmx10.pl scripts/zmpkg.pl scripts/zmupdate.pl scripts/zmvideo.pl scripts/zmcontrol-pelco-d.pl scripts/zmcontrol-visca.pl scripts/zmcontrol-kx-hcm10.pl scripts/zmtrack.pl scripts/zm db/zmschema.sql );