|
|
@ -75,8 +75,7 @@ std::vector<std::string> split(const std::string &s, char delim) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Monitor::MonitorLink::MonitorLink( int p_id, const char *p_name ) : id( p_id )
|
|
|
|
Monitor::MonitorLink::MonitorLink( int p_id, const char *p_name ) : id( p_id ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
strncpy( name, p_name, sizeof(name) );
|
|
|
|
strncpy( name, p_name, sizeof(name) );
|
|
|
|
|
|
|
|
|
|
|
|
#if ZM_MEM_MAPPED
|
|
|
|
#if ZM_MEM_MAPPED
|
|
|
@ -95,15 +94,12 @@ Monitor::MonitorLink::MonitorLink( int p_id, const char *p_name ) : id( p_id )
|
|
|
|
connected = false;
|
|
|
|
connected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Monitor::MonitorLink::~MonitorLink()
|
|
|
|
Monitor::MonitorLink::~MonitorLink() {
|
|
|
|
{
|
|
|
|
|
|
|
|
disconnect();
|
|
|
|
disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Monitor::MonitorLink::connect()
|
|
|
|
bool Monitor::MonitorLink::connect() {
|
|
|
|
{
|
|
|
|
if ( !last_connect_time || (time( 0 ) - last_connect_time) > 60 ) {
|
|
|
|
if ( !last_connect_time || (time( 0 ) - last_connect_time) > 60 )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
last_connect_time = time( 0 );
|
|
|
|
last_connect_time = time( 0 );
|
|
|
|
|
|
|
|
|
|
|
|
mem_size = sizeof(SharedData) + sizeof(TriggerData);
|
|
|
|
mem_size = sizeof(SharedData) + sizeof(TriggerData);
|
|
|
@ -111,8 +107,7 @@ bool Monitor::MonitorLink::connect()
|
|
|
|
Debug( 1, "link.mem.size=%d", mem_size );
|
|
|
|
Debug( 1, "link.mem.size=%d", mem_size );
|
|
|
|
#if ZM_MEM_MAPPED
|
|
|
|
#if ZM_MEM_MAPPED
|
|
|
|
map_fd = open( mem_file, O_RDWR, (mode_t)0600 );
|
|
|
|
map_fd = open( mem_file, O_RDWR, (mode_t)0600 );
|
|
|
|
if ( map_fd < 0 )
|
|
|
|
if ( map_fd < 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug( 3, "Can't open linked memory map file %s: %s", mem_file, strerror(errno) );
|
|
|
|
Debug( 3, "Can't open linked memory map file %s: %s", mem_file, strerror(errno) );
|
|
|
|
disconnect();
|
|
|
|
disconnect();
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
@ -125,44 +120,37 @@ bool Monitor::MonitorLink::connect()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct stat map_stat;
|
|
|
|
struct stat map_stat;
|
|
|
|
if ( fstat( map_fd, &map_stat ) < 0 )
|
|
|
|
if ( fstat( map_fd, &map_stat ) < 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Error( "Can't stat linked memory map file %s: %s", mem_file, strerror(errno) );
|
|
|
|
Error( "Can't stat linked memory map file %s: %s", mem_file, strerror(errno) );
|
|
|
|
disconnect();
|
|
|
|
disconnect();
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( map_stat.st_size == 0 )
|
|
|
|
if ( map_stat.st_size == 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Error( "Linked memory map file %s is empty: %s", mem_file, strerror(errno) );
|
|
|
|
Error( "Linked memory map file %s is empty: %s", mem_file, strerror(errno) );
|
|
|
|
disconnect();
|
|
|
|
disconnect();
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
} else if ( map_stat.st_size < mem_size ) {
|
|
|
|
else if ( map_stat.st_size < mem_size )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Error( "Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size );
|
|
|
|
Error( "Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size );
|
|
|
|
disconnect();
|
|
|
|
disconnect();
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0 );
|
|
|
|
mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0 );
|
|
|
|
if ( mem_ptr == MAP_FAILED )
|
|
|
|
if ( mem_ptr == MAP_FAILED ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Error( "Can't map file %s (%d bytes) to memory: %s", mem_file, mem_size, strerror(errno) );
|
|
|
|
Error( "Can't map file %s (%d bytes) to memory: %s", mem_file, mem_size, strerror(errno) );
|
|
|
|
disconnect();
|
|
|
|
disconnect();
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else // ZM_MEM_MAPPED
|
|
|
|
#else // ZM_MEM_MAPPED
|
|
|
|
shm_id = shmget( (config.shm_key&0xffff0000)|id, mem_size, 0700 );
|
|
|
|
shm_id = shmget( (config.shm_key&0xffff0000)|id, mem_size, 0700 );
|
|
|
|
if ( shm_id < 0 )
|
|
|
|
if ( shm_id < 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug( 3, "Can't shmget link memory: %s", strerror(errno) );
|
|
|
|
Debug( 3, "Can't shmget link memory: %s", strerror(errno) );
|
|
|
|
connected = false;
|
|
|
|
connected = false;
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mem_ptr = (unsigned char *)shmat( shm_id, 0, 0 );
|
|
|
|
mem_ptr = (unsigned char *)shmat( shm_id, 0, 0 );
|
|
|
|
if ( mem_ptr < 0 )
|
|
|
|
if ( mem_ptr < 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug( 3, "Can't shmat link memory: %s", strerror(errno) );
|
|
|
|
Debug( 3, "Can't shmat link memory: %s", strerror(errno) );
|
|
|
|
connected = false;
|
|
|
|
connected = false;
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
@ -172,8 +160,7 @@ bool Monitor::MonitorLink::connect()
|
|
|
|
shared_data = (SharedData *)mem_ptr;
|
|
|
|
shared_data = (SharedData *)mem_ptr;
|
|
|
|
trigger_data = (TriggerData *)((char *)shared_data + sizeof(SharedData));
|
|
|
|
trigger_data = (TriggerData *)((char *)shared_data + sizeof(SharedData));
|
|
|
|
|
|
|
|
|
|
|
|
if ( !shared_data->valid )
|
|
|
|
if ( !shared_data->valid ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug( 3, "Linked memory not initialised by capture daemon" );
|
|
|
|
Debug( 3, "Linked memory not initialised by capture daemon" );
|
|
|
|
disconnect();
|
|
|
|
disconnect();
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
@ -188,15 +175,12 @@ bool Monitor::MonitorLink::connect()
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Monitor::MonitorLink::disconnect()
|
|
|
|
bool Monitor::MonitorLink::disconnect() {
|
|
|
|
{
|
|
|
|
if ( connected ) {
|
|
|
|
if ( connected )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
connected = false;
|
|
|
|
connected = false;
|
|
|
|
|
|
|
|
|
|
|
|
#if ZM_MEM_MAPPED
|
|
|
|
#if ZM_MEM_MAPPED
|
|
|
|
if ( mem_ptr > 0 )
|
|
|
|
if ( mem_ptr > 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
msync( mem_ptr, mem_size, MS_ASYNC );
|
|
|
|
msync( mem_ptr, mem_size, MS_ASYNC );
|
|
|
|
munmap( mem_ptr, mem_size );
|
|
|
|
munmap( mem_ptr, mem_size );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -206,25 +190,21 @@ bool Monitor::MonitorLink::disconnect()
|
|
|
|
map_fd = -1;
|
|
|
|
map_fd = -1;
|
|
|
|
#else // ZM_MEM_MAPPED
|
|
|
|
#else // ZM_MEM_MAPPED
|
|
|
|
struct shmid_ds shm_data;
|
|
|
|
struct shmid_ds shm_data;
|
|
|
|
if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 )
|
|
|
|
if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug( 3, "Can't shmctl: %s", strerror(errno) );
|
|
|
|
Debug( 3, "Can't shmctl: %s", strerror(errno) );
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
shm_id = 0;
|
|
|
|
shm_id = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ( shm_data.shm_nattch <= 1 )
|
|
|
|
if ( shm_data.shm_nattch <= 1 ) {
|
|
|
|
{
|
|
|
|
if ( shmctl( shm_id, IPC_RMID, 0 ) < 0 ) {
|
|
|
|
if ( shmctl( shm_id, IPC_RMID, 0 ) < 0 )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug( 3, "Can't shmctl: %s", strerror(errno) );
|
|
|
|
Debug( 3, "Can't shmctl: %s", strerror(errno) );
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( shmdt( mem_ptr ) < 0 )
|
|
|
|
if ( shmdt( mem_ptr ) < 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug( 3, "Can't shmdt: %s", strerror(errno) );
|
|
|
|
Debug( 3, "Can't shmdt: %s", strerror(errno) );
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -236,19 +216,15 @@ bool Monitor::MonitorLink::disconnect()
|
|
|
|
return( true );
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Monitor::MonitorLink::isAlarmed()
|
|
|
|
bool Monitor::MonitorLink::isAlarmed() {
|
|
|
|
{
|
|
|
|
if ( !connected ) {
|
|
|
|
if ( !connected )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( shared_data->state == ALARM );
|
|
|
|
return( shared_data->state == ALARM );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Monitor::MonitorLink::inAlarm()
|
|
|
|
bool Monitor::MonitorLink::inAlarm() {
|
|
|
|
{
|
|
|
|
if ( !connected ) {
|
|
|
|
if ( !connected )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( shared_data->state == ALARM || shared_data->state == ALERT );
|
|
|
|
return( shared_data->state == ALARM || shared_data->state == ALERT );
|
|
|
@ -256,12 +232,9 @@ bool Monitor::MonitorLink::inAlarm()
|
|
|
|
|
|
|
|
|
|
|
|
bool Monitor::MonitorLink::hasAlarmed()
|
|
|
|
bool Monitor::MonitorLink::hasAlarmed()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( shared_data->state == ALARM )
|
|
|
|
if ( shared_data->state == ALARM ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
} else if ( shared_data->last_event != (unsigned int)last_event ) {
|
|
|
|
else if( shared_data->last_event != (unsigned int)last_event )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
last_event = shared_data->last_event;
|
|
|
|
last_event = shared_data->last_event;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( false );
|
|
|
|
return( false );
|
|
|
@ -280,6 +253,7 @@ Monitor::Monitor(
|
|
|
|
int p_savejpegs,
|
|
|
|
int p_savejpegs,
|
|
|
|
int p_videowriter,
|
|
|
|
int p_videowriter,
|
|
|
|
std::string p_encoderparams,
|
|
|
|
std::string p_encoderparams,
|
|
|
|
|
|
|
|
bool p_record_audio,
|
|
|
|
const char *p_event_prefix,
|
|
|
|
const char *p_event_prefix,
|
|
|
|
const char *p_label_format,
|
|
|
|
const char *p_label_format,
|
|
|
|
const Coord &p_label_coord,
|
|
|
|
const Coord &p_label_coord,
|
|
|
@ -317,6 +291,7 @@ Monitor::Monitor(
|
|
|
|
savejpegspref( p_savejpegs ),
|
|
|
|
savejpegspref( p_savejpegs ),
|
|
|
|
videowriterpref( p_videowriter ),
|
|
|
|
videowriterpref( p_videowriter ),
|
|
|
|
encoderparams( p_encoderparams ),
|
|
|
|
encoderparams( p_encoderparams ),
|
|
|
|
|
|
|
|
record_audio( p_record_audio ),
|
|
|
|
label_coord( p_label_coord ),
|
|
|
|
label_coord( p_label_coord ),
|
|
|
|
label_size( p_label_size ),
|
|
|
|
label_size( p_label_size ),
|
|
|
|
image_buffer_count( p_image_buffer_count ),
|
|
|
|
image_buffer_count( p_image_buffer_count ),
|
|
|
@ -450,16 +425,15 @@ Monitor::Monitor(
|
|
|
|
shared_data->alarm_y = -1;
|
|
|
|
shared_data->alarm_y = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( ( ! mem_ptr ) || ! shared_data->valid )
|
|
|
|
if ( ( ! mem_ptr ) || ! shared_data->valid ) {
|
|
|
|
{
|
|
|
|
if ( purpose != QUERY ) {
|
|
|
|
if ( purpose != QUERY )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Error( "Shared data not initialised by capture daemon for monitor %s", name );
|
|
|
|
Error( "Shared data not initialised by capture daemon for monitor %s", name );
|
|
|
|
exit( -1 );
|
|
|
|
exit( -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Will this not happen every time a monitor is instantiated? Seems like all the calls to the Monitor constructor pass a zero for n_zones, then load zones after..
|
|
|
|
// Will this not happen every time a monitor is instantiated? Seems like all the calls to the Monitor constructor pass a zero for n_zones, then load zones after..
|
|
|
|
|
|
|
|
// In my storage areas branch, I took this out.. and didn't notice any problems.
|
|
|
|
if ( !n_zones ) {
|
|
|
|
if ( !n_zones ) {
|
|
|
|
Debug( 1, "Monitor %s has no zones, adding one.", name );
|
|
|
|
Debug( 1, "Monitor %s has no zones, adding one.", name );
|
|
|
|
n_zones = 1;
|
|
|
|
n_zones = 1;
|
|
|
@ -475,8 +449,7 @@ Monitor::Monitor(
|
|
|
|
Debug( 1, "Monitor %s LBF = '%s', LBX = %d, LBY = %d, LBS = %d", name, label_format, label_coord.X(), label_coord.Y(), label_size );
|
|
|
|
Debug( 1, "Monitor %s LBF = '%s', LBX = %d, LBY = %d, LBS = %d", name, label_format, label_coord.X(), label_coord.Y(), label_size );
|
|
|
|
Debug( 1, "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, EAF = %d, FRI = %d, RBP = %d, ARBP = %d, FM = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, alarm_frame_count, fps_report_interval, ref_blend_perc, alarm_ref_blend_perc, track_motion );
|
|
|
|
Debug( 1, "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, EAF = %d, FRI = %d, RBP = %d, ARBP = %d, FM = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, alarm_frame_count, fps_report_interval, ref_blend_perc, alarm_ref_blend_perc, track_motion );
|
|
|
|
|
|
|
|
|
|
|
|
if ( purpose == ANALYSIS )
|
|
|
|
if ( purpose == ANALYSIS ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
static char path[PATH_MAX];
|
|
|
|
static char path[PATH_MAX];
|
|
|
|
|
|
|
|
|
|
|
|
strncpy( path, config.dir_events, sizeof(path) );
|
|
|
|
strncpy( path, config.dir_events, sizeof(path) );
|
|
|
@ -484,8 +457,7 @@ Monitor::Monitor(
|
|
|
|
struct stat statbuf;
|
|
|
|
struct stat statbuf;
|
|
|
|
errno = 0;
|
|
|
|
errno = 0;
|
|
|
|
stat( path, &statbuf );
|
|
|
|
stat( path, &statbuf );
|
|
|
|
if ( errno == ENOENT || errno == ENOTDIR )
|
|
|
|
if ( errno == ENOENT || errno == ENOTDIR ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( mkdir( path, 0755 ) )
|
|
|
|
if ( mkdir( path, 0755 ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Error( "Can't make %s: %s", path, strerror(errno));
|
|
|
|
Error( "Can't make %s: %s", path, strerror(errno));
|
|
|
@ -496,10 +468,8 @@ Monitor::Monitor(
|
|
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
errno = 0;
|
|
|
|
stat( path, &statbuf );
|
|
|
|
stat( path, &statbuf );
|
|
|
|
if ( errno == ENOENT || errno == ENOTDIR )
|
|
|
|
if ( errno == ENOENT || errno == ENOTDIR ) {
|
|
|
|
{
|
|
|
|
if ( mkdir( path, 0755 ) ) {
|
|
|
|
if ( mkdir( path, 0755 ) )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Error( "Can't make %s: %s", path, strerror(errno));
|
|
|
|
Error( "Can't make %s: %s", path, strerror(errno));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
char temp_path[PATH_MAX];
|
|
|
|
char temp_path[PATH_MAX];
|
|
|
@ -513,8 +483,7 @@ Monitor::Monitor(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while( shared_data->last_write_index == (unsigned int)image_buffer_count
|
|
|
|
while( shared_data->last_write_index == (unsigned int)image_buffer_count
|
|
|
|
&& shared_data->last_write_time == 0)
|
|
|
|
&& shared_data->last_write_time == 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Warning( "Waiting for capture daemon" );
|
|
|
|
Warning( "Waiting for capture daemon" );
|
|
|
|
sleep( 1 );
|
|
|
|
sleep( 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -573,8 +542,7 @@ bool Monitor::connect() {
|
|
|
|
exit( -1 );
|
|
|
|
exit( -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mem_ptr = (unsigned char *)shmat( shm_id, 0, 0 );
|
|
|
|
mem_ptr = (unsigned char *)shmat( shm_id, 0, 0 );
|
|
|
|
if ( mem_ptr < 0 )
|
|
|
|
if ( mem_ptr < 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Error( "Can't shmat: %s", strerror(errno));
|
|
|
|
Error( "Can't shmat: %s", strerror(errno));
|
|
|
|
exit( -1 );
|
|
|
|
exit( -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -591,29 +559,25 @@ bool Monitor::connect() {
|
|
|
|
shared_images = (uint8_t*)((unsigned long)shared_images + (16 - ((unsigned long)shared_images % 16)));
|
|
|
|
shared_images = (uint8_t*)((unsigned long)shared_images + (16 - ((unsigned long)shared_images % 16)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
image_buffer = new Snapshot[image_buffer_count];
|
|
|
|
image_buffer = new Snapshot[image_buffer_count];
|
|
|
|
for ( int i = 0; i < image_buffer_count; i++ )
|
|
|
|
for ( int i = 0; i < image_buffer_count; i++ ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
image_buffer[i].timestamp = &(shared_timestamps[i]);
|
|
|
|
image_buffer[i].timestamp = &(shared_timestamps[i]);
|
|
|
|
image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) );
|
|
|
|
image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) );
|
|
|
|
image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */
|
|
|
|
image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( (deinterlacing & 0xff) == 4)
|
|
|
|
if ( (deinterlacing & 0xff) == 4) {
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Four field motion adaptive deinterlacing in use */
|
|
|
|
/* Four field motion adaptive deinterlacing in use */
|
|
|
|
/* Allocate a buffer for the next image */
|
|
|
|
/* Allocate a buffer for the next image */
|
|
|
|
next_buffer.image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
|
|
|
next_buffer.image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
|
|
|
next_buffer.timestamp = new struct timeval;
|
|
|
|
next_buffer.timestamp = new struct timeval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( ( purpose == ANALYSIS ) && analysis_fps )
|
|
|
|
if ( ( purpose == ANALYSIS ) && analysis_fps ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// Size of pre event buffer must be greater than pre_event_count
|
|
|
|
// Size of pre event buffer must be greater than pre_event_count
|
|
|
|
// if alarm_frame_count > 1, because in this case the buffer contains
|
|
|
|
// if alarm_frame_count > 1, because in this case the buffer contains
|
|
|
|
// alarmed images that must be discarded when event is created
|
|
|
|
// alarmed images that must be discarded when event is created
|
|
|
|
pre_event_buffer_count = pre_event_count + alarm_frame_count - 1;
|
|
|
|
pre_event_buffer_count = pre_event_count + alarm_frame_count - 1;
|
|
|
|
pre_event_buffer = new Snapshot[pre_event_buffer_count];
|
|
|
|
pre_event_buffer = new Snapshot[pre_event_buffer_count];
|
|
|
|
for ( int i = 0; i < pre_event_buffer_count; i++ )
|
|
|
|
for ( int i = 0; i < pre_event_buffer_count; i++ ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
pre_event_buffer[i].timestamp = new struct timeval;
|
|
|
|
pre_event_buffer[i].timestamp = new struct timeval;
|
|
|
|
pre_event_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
|
|
|
pre_event_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1892,6 +1856,7 @@ void Monitor::Reload()
|
|
|
|
closeEvent();
|
|
|
|
closeEvent();
|
|
|
|
|
|
|
|
|
|
|
|
static char sql[ZM_SQL_MED_BUFSIZ];
|
|
|
|
static char sql[ZM_SQL_MED_BUFSIZ];
|
|
|
|
|
|
|
|
// This seems to have fallen out of date.
|
|
|
|
snprintf( sql, sizeof(sql), "select Function+0, Enabled, LinkedMonitors, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = '%d'", id );
|
|
|
|
snprintf( sql, sizeof(sql), "select Function+0, Enabled, LinkedMonitors, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = '%d'", id );
|
|
|
|
|
|
|
|
|
|
|
|
if ( mysql_query( &dbconn, sql ) )
|
|
|
|
if ( mysql_query( &dbconn, sql ) )
|
|
|
@ -2084,7 +2049,7 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors )
|
|
|
|
#if ZM_HAS_V4L
|
|
|
|
#if ZM_HAS_V4L
|
|
|
|
int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose )
|
|
|
|
int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'";
|
|
|
|
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'";
|
|
|
|
if ( device[0] ) {
|
|
|
|
if ( device[0] ) {
|
|
|
|
sql += " AND Device='";
|
|
|
|
sql += " AND Device='";
|
|
|
|
sql += device;
|
|
|
|
sql += device;
|
|
|
@ -2148,6 +2113,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
|
|
|
|
bool record_audio = (*dbrow[col] != '0'); col++;
|
|
|
|
|
|
|
|
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
@ -2209,6 +2175,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE,
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio,
|
|
|
|
extras
|
|
|
|
extras
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -2225,6 +2192,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
savejpegs,
|
|
|
|
savejpegs,
|
|
|
|
videowriter,
|
|
|
|
videowriter,
|
|
|
|
encoderparams,
|
|
|
|
encoderparams,
|
|
|
|
|
|
|
|
record_audio,
|
|
|
|
event_prefix,
|
|
|
|
event_prefix,
|
|
|
|
label_format,
|
|
|
|
label_format,
|
|
|
|
Coord( label_x, label_y ),
|
|
|
|
Coord( label_x, label_y ),
|
|
|
@ -2272,7 +2240,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
|
|
|
|
|
|
|
|
int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const char *port, const char *path, Monitor **&monitors, Purpose purpose )
|
|
|
|
int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const char *port, const char *path, Monitor **&monitors, Purpose purpose )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote'";
|
|
|
|
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote'";
|
|
|
|
if ( staticConfig.SERVER_ID ) {
|
|
|
|
if ( staticConfig.SERVER_ID ) {
|
|
|
|
sql += stringtf( " AND ServerId=%d", staticConfig.SERVER_ID );
|
|
|
|
sql += stringtf( " AND ServerId=%d", staticConfig.SERVER_ID );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2318,6 +2286,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
|
|
|
|
bool record_audio = (*dbrow[col] != '0'); col++;
|
|
|
|
|
|
|
|
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
@ -2354,8 +2323,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|
|
|
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
|
|
|
|
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
|
|
|
|
|
|
|
|
|
|
|
|
Camera *camera = 0;
|
|
|
|
Camera *camera = 0;
|
|
|
|
if ( protocol == "http" )
|
|
|
|
if ( protocol == "http" ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
camera = new RemoteCameraHttp(
|
|
|
|
camera = new RemoteCameraHttp(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
|
method,
|
|
|
|
method,
|
|
|
@ -2369,12 +2337,12 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if HAVE_LIBAVFORMAT
|
|
|
|
#if HAVE_LIBAVFORMAT
|
|
|
|
else if ( protocol == "rtsp" )
|
|
|
|
else if ( protocol == "rtsp" ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
camera = new RemoteCameraRtsp(
|
|
|
|
camera = new RemoteCameraRtsp(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
|
method,
|
|
|
|
method,
|
|
|
@ -2389,12 +2357,12 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
else
|
|
|
|
else {
|
|
|
|
{
|
|
|
|
|
|
|
|
Fatal( "Unexpected remote camera protocol '%s'", protocol.c_str() );
|
|
|
|
Fatal( "Unexpected remote camera protocol '%s'", protocol.c_str() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2411,6 +2379,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|
|
|
savejpegs,
|
|
|
|
savejpegs,
|
|
|
|
videowriter,
|
|
|
|
videowriter,
|
|
|
|
encoderparams,
|
|
|
|
encoderparams,
|
|
|
|
|
|
|
|
record_audio,
|
|
|
|
event_prefix.c_str(),
|
|
|
|
event_prefix.c_str(),
|
|
|
|
label_format.c_str(),
|
|
|
|
label_format.c_str(),
|
|
|
|
Coord( label_x, label_y ),
|
|
|
|
Coord( label_x, label_y ),
|
|
|
@ -2437,7 +2406,6 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|
|
|
purpose,
|
|
|
|
purpose,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
Zone **zones = 0;
|
|
|
|
Zone **zones = 0;
|
|
|
|
int n_zones = Zone::Load( monitors[i], zones );
|
|
|
|
int n_zones = Zone::Load( monitors[i], zones );
|
|
|
@ -2456,9 +2424,8 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|
|
|
return( n_monitors );
|
|
|
|
return( n_monitors );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose purpose )
|
|
|
|
int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose purpose ) {
|
|
|
|
{
|
|
|
|
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'";
|
|
|
|
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'";
|
|
|
|
|
|
|
|
if ( file[0] ) {
|
|
|
|
if ( file[0] ) {
|
|
|
|
sql += " AND Path='";
|
|
|
|
sql += " AND Path='";
|
|
|
|
sql += file;
|
|
|
|
sql += file;
|
|
|
@ -2501,6 +2468,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
|
|
|
|
bool record_audio = (*dbrow[col] != '0'); col++;
|
|
|
|
|
|
|
|
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
@ -2546,7 +2514,8 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
monitors[i] = new Monitor(
|
|
|
|
monitors[i] = new Monitor(
|
|
|
@ -2562,6 +2531,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
|
|
|
|
savejpegs,
|
|
|
|
savejpegs,
|
|
|
|
videowriter,
|
|
|
|
videowriter,
|
|
|
|
encoderparams,
|
|
|
|
encoderparams,
|
|
|
|
|
|
|
|
record_audio,
|
|
|
|
event_prefix,
|
|
|
|
event_prefix,
|
|
|
|
label_format,
|
|
|
|
label_format,
|
|
|
|
Coord( label_x, label_y ),
|
|
|
|
Coord( label_x, label_y ),
|
|
|
@ -2609,7 +2579,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
|
|
|
|
#if HAVE_LIBAVFORMAT
|
|
|
|
#if HAVE_LIBAVFORMAT
|
|
|
|
int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose purpose )
|
|
|
|
int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose purpose )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'";
|
|
|
|
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'";
|
|
|
|
if ( file[0] ) {
|
|
|
|
if ( file[0] ) {
|
|
|
|
sql += " AND Path = '";
|
|
|
|
sql += " AND Path = '";
|
|
|
|
sql += file;
|
|
|
|
sql += file;
|
|
|
@ -2629,8 +2599,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|
|
|
Debug( 1, "Got %d monitors", n_monitors );
|
|
|
|
Debug( 1, "Got %d monitors", n_monitors );
|
|
|
|
delete[] monitors;
|
|
|
|
delete[] monitors;
|
|
|
|
monitors = new Monitor *[n_monitors];
|
|
|
|
monitors = new Monitor *[n_monitors];
|
|
|
|
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
|
|
|
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
int col = 0;
|
|
|
|
int col = 0;
|
|
|
|
|
|
|
|
|
|
|
|
int id = atoi(dbrow[col]); col++;
|
|
|
|
int id = atoi(dbrow[col]); col++;
|
|
|
@ -2654,6 +2623,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
|
|
|
|
bool record_audio = (*dbrow[col] != '0'); col++;
|
|
|
|
|
|
|
|
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
@ -2701,7 +2671,8 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
monitors[i] = new Monitor(
|
|
|
|
monitors[i] = new Monitor(
|
|
|
@ -2717,6 +2688,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|
|
|
savejpegs,
|
|
|
|
savejpegs,
|
|
|
|
videowriter,
|
|
|
|
videowriter,
|
|
|
|
encoderparams,
|
|
|
|
encoderparams,
|
|
|
|
|
|
|
|
record_audio,
|
|
|
|
event_prefix,
|
|
|
|
event_prefix,
|
|
|
|
label_format,
|
|
|
|
label_format,
|
|
|
|
Coord( label_x, label_y ),
|
|
|
|
Coord( label_x, label_y ),
|
|
|
@ -2762,9 +2734,8 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
|
|
|
|
|
|
|
|
Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose )
|
|
|
|
Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
|
|
|
|
{
|
|
|
|
std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", p_id );
|
|
|
|
std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", p_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() );
|
|
|
|
MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() );
|
|
|
|
if ( ! dbrow ) {
|
|
|
|
if ( ! dbrow ) {
|
|
|
@ -2824,6 +2795,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int savejpegs = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
int videowriter = atoi(dbrow[col]); col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
std::string encoderparams = dbrow[col]; col++;
|
|
|
|
|
|
|
|
bool record_audio = (*dbrow[col] != '0'); col++;
|
|
|
|
|
|
|
|
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int brightness = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
|
int contrast = atoi(dbrow[col]); col++;
|
|
|
@ -2869,8 +2841,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
int extras = (deinterlacing>>24)&0xff;
|
|
|
|
int extras = (deinterlacing>>24)&0xff;
|
|
|
|
|
|
|
|
|
|
|
|
Camera *camera = 0;
|
|
|
|
Camera *camera = 0;
|
|
|
|
if ( type == "Local" )
|
|
|
|
if ( type == "Local" ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
#if ZM_HAS_V4L
|
|
|
|
#if ZM_HAS_V4L
|
|
|
|
camera = new LocalCamera(
|
|
|
|
camera = new LocalCamera(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
@ -2889,16 +2860,14 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE,
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio,
|
|
|
|
extras
|
|
|
|
extras
|
|
|
|
);
|
|
|
|
);
|
|
|
|
#else // ZM_HAS_V4L
|
|
|
|
#else // ZM_HAS_V4L
|
|
|
|
Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id );
|
|
|
|
Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id );
|
|
|
|
#endif // ZM_HAS_V4L
|
|
|
|
#endif // ZM_HAS_V4L
|
|
|
|
}
|
|
|
|
} else if ( type == "Remote" ) {
|
|
|
|
else if ( type == "Remote" )
|
|
|
|
if ( protocol == "http" ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( protocol == "http" )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
camera = new RemoteCameraHttp(
|
|
|
|
camera = new RemoteCameraHttp(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
|
method.c_str(),
|
|
|
|
method.c_str(),
|
|
|
@ -2912,11 +2881,10 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else if ( protocol == "rtsp" ) {
|
|
|
|
else if ( protocol == "rtsp" )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#if HAVE_LIBAVFORMAT
|
|
|
|
#if HAVE_LIBAVFORMAT
|
|
|
|
camera = new RemoteCameraRtsp(
|
|
|
|
camera = new RemoteCameraRtsp(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
@ -2932,19 +2900,16 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
#else // HAVE_LIBAVFORMAT
|
|
|
|
#else // HAVE_LIBAVFORMAT
|
|
|
|
Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
|
|
|
|
Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
|
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
|
|
|
|
Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ( type == "File" ) {
|
|
|
|
else if ( type == "File" )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
camera = new FileCamera(
|
|
|
|
camera = new FileCamera(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
|
path.c_str(),
|
|
|
|
path.c_str(),
|
|
|
@ -2955,11 +2920,10 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else if ( type == "Ffmpeg" ) {
|
|
|
|
else if ( type == "Ffmpeg" )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#if HAVE_LIBAVFORMAT
|
|
|
|
#if HAVE_LIBAVFORMAT
|
|
|
|
camera = new FfmpegCamera(
|
|
|
|
camera = new FfmpegCamera(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
@ -2973,14 +2937,13 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
#else // HAVE_LIBAVFORMAT
|
|
|
|
#else // HAVE_LIBAVFORMAT
|
|
|
|
Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id );
|
|
|
|
Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id );
|
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
}
|
|
|
|
} else if (type == "Libvlc") {
|
|
|
|
else if (type == "Libvlc")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#if HAVE_LIBVLC
|
|
|
|
#if HAVE_LIBVLC
|
|
|
|
camera = new LibvlcCamera(
|
|
|
|
camera = new LibvlcCamera(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
@ -2994,14 +2957,13 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
#else // HAVE_LIBVLC
|
|
|
|
#else // HAVE_LIBVLC
|
|
|
|
Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id );
|
|
|
|
Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id );
|
|
|
|
#endif // HAVE_LIBVLC
|
|
|
|
#endif // HAVE_LIBVLC
|
|
|
|
}
|
|
|
|
} else if ( type == "cURL" ) {
|
|
|
|
else if ( type == "cURL" )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#if HAVE_LIBCURL
|
|
|
|
#if HAVE_LIBCURL
|
|
|
|
camera = new cURLCamera(
|
|
|
|
camera = new cURLCamera(
|
|
|
|
id,
|
|
|
|
id,
|
|
|
@ -3015,14 +2977,13 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
contrast,
|
|
|
|
contrast,
|
|
|
|
hue,
|
|
|
|
hue,
|
|
|
|
colour,
|
|
|
|
colour,
|
|
|
|
purpose==CAPTURE
|
|
|
|
purpose==CAPTURE,
|
|
|
|
|
|
|
|
record_audio
|
|
|
|
);
|
|
|
|
);
|
|
|
|
#else // HAVE_LIBCURL
|
|
|
|
#else // HAVE_LIBCURL
|
|
|
|
Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id );
|
|
|
|
Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id );
|
|
|
|
#endif // HAVE_LIBCURL
|
|
|
|
#endif // HAVE_LIBCURL
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id );
|
|
|
|
Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
monitor = new Monitor(
|
|
|
|
monitor = new Monitor(
|
|
|
@ -3038,6 +2999,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
savejpegs,
|
|
|
|
savejpegs,
|
|
|
|
videowriter,
|
|
|
|
videowriter,
|
|
|
|
encoderparams,
|
|
|
|
encoderparams,
|
|
|
|
|
|
|
|
record_audio,
|
|
|
|
event_prefix.c_str(),
|
|
|
|
event_prefix.c_str(),
|
|
|
|
label_format.c_str(),
|
|
|
|
label_format.c_str(),
|
|
|
|
Coord( label_x, label_y ),
|
|
|
|
Coord( label_x, label_y ),
|
|
|
@ -3068,8 +3030,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
int n_zones = 0;
|
|
|
|
int n_zones = 0;
|
|
|
|
if ( load_zones )
|
|
|
|
if ( load_zones ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Zone **zones = 0;
|
|
|
|
Zone **zones = 0;
|
|
|
|
n_zones = Zone::Load( monitor, zones );
|
|
|
|
n_zones = Zone::Load( monitor, zones );
|
|
|
|
monitor->AddZones( n_zones, zones );
|
|
|
|
monitor->AddZones( n_zones, zones );
|
|
|
@ -3123,8 +3084,7 @@ int Monitor::Capture()
|
|
|
|
captureResult = 0;
|
|
|
|
captureResult = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( captureResult != 0 )
|
|
|
|
if ( captureResult != 0 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// Unable to capture image for temporary reason
|
|
|
|
// Unable to capture image for temporary reason
|
|
|
|
// Fake a signal loss image
|
|
|
|
// Fake a signal loss image
|
|
|
|
Rgb signalcolor;
|
|
|
|
Rgb signalcolor;
|
|
|
@ -3135,8 +3095,7 @@ int Monitor::Capture()
|
|
|
|
captureResult = 1;
|
|
|
|
captureResult = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( captureResult == 1 )
|
|
|
|
if ( captureResult == 1 ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Deinterlacing */
|
|
|
|
/* Deinterlacing */
|
|
|
|
if ( (deinterlacing & 0xff) == 1 ) {
|
|
|
|
if ( (deinterlacing & 0xff) == 1 ) {
|
|
|
@ -3152,48 +3111,41 @@ int Monitor::Capture()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( orientation != ROTATE_0 )
|
|
|
|
if ( orientation != ROTATE_0 ) {
|
|
|
|
{
|
|
|
|
switch ( orientation ) {
|
|
|
|
switch ( orientation )
|
|
|
|
case ROTATE_0 : {
|
|
|
|
{
|
|
|
|
|
|
|
|
case ROTATE_0 :
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// No action required
|
|
|
|
// No action required
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case ROTATE_90 :
|
|
|
|
case ROTATE_90 :
|
|
|
|
case ROTATE_180 :
|
|
|
|
case ROTATE_180 :
|
|
|
|
case ROTATE_270 :
|
|
|
|
case ROTATE_270 : {
|
|
|
|
{
|
|
|
|
|
|
|
|
capture_image->Rotate( (orientation-1)*90 );
|
|
|
|
capture_image->Rotate( (orientation-1)*90 );
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case FLIP_HORI :
|
|
|
|
case FLIP_HORI :
|
|
|
|
case FLIP_VERT :
|
|
|
|
case FLIP_VERT : {
|
|
|
|
{
|
|
|
|
|
|
|
|
capture_image->Flip( orientation==FLIP_HORI );
|
|
|
|
capture_image->Flip( orientation==FLIP_HORI );
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end if captureResults == 1
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
// if true? let's get rid of this.
|
|
|
|
if ( true ) {
|
|
|
|
if ( true ) {
|
|
|
|
|
|
|
|
|
|
|
|
if ( capture_image->Size() > camera->ImageSize() )
|
|
|
|
if ( capture_image->Size() > camera->ImageSize() ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Error( "Captured image %d does not match expected size %d check width, height and colour depth",capture_image->Size(),camera->ImageSize() );
|
|
|
|
Error( "Captured image %d does not match expected size %d check width, height and colour depth",capture_image->Size(),camera->ImageSize() );
|
|
|
|
return( -1 );
|
|
|
|
return( -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( ((unsigned int)index == shared_data->last_read_index) && (function > MONITOR) )
|
|
|
|
if ( ((unsigned int)index == shared_data->last_read_index) && (function > MONITOR) ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Warning( "Buffer overrun at index %d, image %d, slow down capture, speed up analysis or increase ring buffer size", index, image_count );
|
|
|
|
Warning( "Buffer overrun at index %d, image %d, slow down capture, speed up analysis or increase ring buffer size", index, image_count );
|
|
|
|
time_t now = time(0);
|
|
|
|
time_t now = time(0);
|
|
|
|
double approxFps = double(image_buffer_count)/double(now-image_buffer[index].timestamp->tv_sec);
|
|
|
|
double approxFps = double(image_buffer_count)/double(now-image_buffer[index].timestamp->tv_sec);
|
|
|
|
time_t last_read_delta = now - shared_data->last_read_time;
|
|
|
|
time_t last_read_delta = now - shared_data->last_read_time;
|
|
|
|
if ( last_read_delta > (image_buffer_count/approxFps) )
|
|
|
|
if ( last_read_delta > (image_buffer_count/approxFps) ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Warning( "Last image read from shared memory %ld seconds ago, zma may have gone away", last_read_delta )
|
|
|
|
Warning( "Last image read from shared memory %ld seconds ago, zma may have gone away", last_read_delta )
|
|
|
|
shared_data->last_read_index = image_buffer_count;
|
|
|
|
shared_data->last_read_index = image_buffer_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3203,8 +3155,7 @@ int Monitor::Capture()
|
|
|
|
capture_image->MaskPrivacy( privacy_bitmask );
|
|
|
|
capture_image->MaskPrivacy( privacy_bitmask );
|
|
|
|
|
|
|
|
|
|
|
|
gettimeofday( image_buffer[index].timestamp, NULL );
|
|
|
|
gettimeofday( image_buffer[index].timestamp, NULL );
|
|
|
|
if ( config.timestamp_on_capture )
|
|
|
|
if ( config.timestamp_on_capture ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
TimestampImage( capture_image, image_buffer[index].timestamp );
|
|
|
|
TimestampImage( capture_image, image_buffer[index].timestamp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shared_data->signal = CheckSignal(capture_image);
|
|
|
|
shared_data->signal = CheckSignal(capture_image);
|
|
|
@ -3213,8 +3164,7 @@ int Monitor::Capture()
|
|
|
|
|
|
|
|
|
|
|
|
image_count++;
|
|
|
|
image_count++;
|
|
|
|
|
|
|
|
|
|
|
|
if ( image_count && fps_report_interval && !(image_count%fps_report_interval) )
|
|
|
|
if ( image_count && fps_report_interval && !(image_count%fps_report_interval) ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
time_t now = image_buffer[index].timestamp->tv_sec;
|
|
|
|
time_t now = image_buffer[index].timestamp->tv_sec;
|
|
|
|
fps = double(fps_report_interval)/(now-last_fps_time);
|
|
|
|
fps = double(fps_report_interval)/(now-last_fps_time);
|
|
|
|
//Info( "%d -> %d -> %d", fps_report_interval, now, last_fps_time );
|
|
|
|
//Info( "%d -> %d -> %d", fps_report_interval, now, last_fps_time );
|
|
|
@ -3223,16 +3173,14 @@ int Monitor::Capture()
|
|
|
|
last_fps_time = now;
|
|
|
|
last_fps_time = now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( shared_data->action & GET_SETTINGS )
|
|
|
|
if ( shared_data->action & GET_SETTINGS ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
shared_data->brightness = camera->Brightness();
|
|
|
|
shared_data->brightness = camera->Brightness();
|
|
|
|
shared_data->hue = camera->Hue();
|
|
|
|
shared_data->hue = camera->Hue();
|
|
|
|
shared_data->colour = camera->Colour();
|
|
|
|
shared_data->colour = camera->Colour();
|
|
|
|
shared_data->contrast = camera->Contrast();
|
|
|
|
shared_data->contrast = camera->Contrast();
|
|
|
|
shared_data->action &= ~GET_SETTINGS;
|
|
|
|
shared_data->action &= ~GET_SETTINGS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( shared_data->action & SET_SETTINGS )
|
|
|
|
if ( shared_data->action & SET_SETTINGS ) {
|
|
|
|
{
|
|
|
|
|
|
|
|
camera->Brightness( shared_data->brightness );
|
|
|
|
camera->Brightness( shared_data->brightness );
|
|
|
|
camera->Hue( shared_data->hue );
|
|
|
|
camera->Hue( shared_data->hue );
|
|
|
|
camera->Colour( shared_data->colour );
|
|
|
|
camera->Colour( shared_data->colour );
|
|
|
@ -3292,10 +3240,8 @@ void Monitor::TimestampImage( Image *ts_image, const struct timeval *ts_time ) c
|
|
|
|
bool Monitor::closeEvent()
|
|
|
|
bool Monitor::closeEvent()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
video_store_data->recording = false;
|
|
|
|
video_store_data->recording = false;
|
|
|
|
if ( event )
|
|
|
|
if ( event ) {
|
|
|
|
{
|
|
|
|
if ( function == RECORD || function == MOCORD ) {
|
|
|
|
if ( function == RECORD || function == MOCORD )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
gettimeofday( &(event->EndTime()), NULL );
|
|
|
|
gettimeofday( &(event->EndTime()), NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete event;
|
|
|
|
delete event;
|
|
|
@ -3747,7 +3693,7 @@ bool Monitor::DumpSettings( char *output, bool verbose )
|
|
|
|
zones[i]->DumpSettings( output+strlen(output), verbose );
|
|
|
|
zones[i]->DumpSettings( output+strlen(output), verbose );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( true );
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
} // bool Monitor::DumpSettings( char *output, bool verbose )
|
|
|
|
|
|
|
|
|
|
|
|
bool MonitorStream::checkSwapPath( const char *path, bool create_path )
|
|
|
|
bool MonitorStream::checkSwapPath( const char *path, bool create_path )
|
|
|
|
{
|
|
|
|
{
|
|
|
|