Merge ../ZoneMinder.connortechnology

This commit is contained in:
Isaac Connor 2017-05-20 09:03:57 -04:00
commit a5ee8307d0
9 changed files with 1227 additions and 1432 deletions

View File

@ -129,7 +129,7 @@ BEGIN {
} # end BEGIN } # end BEGIN
sub loadConfigFromDB { sub loadConfigFromDB {
print( "Loading config from DB\n" ); print( "Loading config from DB" );
my $dbh = ZoneMinder::Database::zmDbConnect(); my $dbh = ZoneMinder::Database::zmDbConnect();
if ( !$dbh ) { if ( !$dbh ) {
print( "Error: unable to load options from database: $DBI::errstr\n" ); print( "Error: unable to load options from database: $DBI::errstr\n" );
@ -160,11 +160,12 @@ sub loadConfigFromDB {
$option_count++;; $option_count++;;
} }
$sth->finish(); $sth->finish();
print( " $option_count entries\n" );
return( $option_count ); return( $option_count );
} # end sub loadConfigFromDB } # end sub loadConfigFromDB
sub saveConfigToDB { sub saveConfigToDB {
print( "Saving config to DB\n" ); print( "Saving config to DB " . @options . " entries\n" );
my $dbh = ZoneMinder::Database::zmDbConnect(); my $dbh = ZoneMinder::Database::zmDbConnect();
if ( !$dbh ) { if ( !$dbh ) {
print( "Error: unable to save options to database: $DBI::errstr\n" ); print( "Error: unable to save options to database: $DBI::errstr\n" );

View File

@ -82,7 +82,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
struct tm *stime = localtime( &start_time.tv_sec ); struct tm *stime = localtime( &start_time.tv_sec );
snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes, Videoed ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s', '%d' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str(), videoEvent ); snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes, Videoed ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s', '%d' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str(), videoEvent );
if ( mysql_query( &dbconn, sql ) ) { if ( mysql_query( &dbconn, sql ) ) {
Error( "Can't insert event: %s", mysql_error( &dbconn ) ); Error( "Can't insert event: %s. sql was (%s)", mysql_error( &dbconn ), sql );
exit( mysql_errno( &dbconn ) ); exit( mysql_errno( &dbconn ) );
} }
id = mysql_insert_id( &dbconn ); id = mysql_insert_id( &dbconn );
@ -163,11 +163,9 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
if ( monitor->GetOptVideoWriter() != 0 ) { if ( monitor->GetOptVideoWriter() != 0 ) {
snprintf( video_name, sizeof(video_name), "%d-%s", id, "video.mp4" ); snprintf( video_name, sizeof(video_name), "%d-%s", id, "video.mp4" );
snprintf( video_file, sizeof(video_file), video_file_format, path, video_name ); snprintf( video_file, sizeof(video_file), video_file_format, path, video_name );
snprintf( timecodes_name, sizeof(timecodes_name), "%d-%s", id, "video.timecodes" );
snprintf( timecodes_file, sizeof(timecodes_file), video_file_format, path, timecodes_name );
/* X264 MP4 video writer */ /* X264 MP4 video writer */
if(monitor->GetOptVideoWriter() == 1) { if ( monitor->GetOptVideoWriter() == X264ENCODE ) {
#if ZM_HAVE_VIDEOWRITER_X264MP4 #if ZM_HAVE_VIDEOWRITER_X264MP4
videowriter = new X264MP4Writer(video_file, monitor->Width(), monitor->Height(), monitor->Colours(), monitor->SubpixelOrder(), monitor->GetOptEncoderParams()); videowriter = new X264MP4Writer(video_file, monitor->Width(), monitor->Height(), monitor->Colours(), monitor->SubpixelOrder(), monitor->GetOptEncoderParams());
#else #else
@ -175,7 +173,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
#endif #endif
} }
if(videowriter != NULL) { if ( videowriter != NULL ) {
/* Open the video stream */ /* Open the video stream */
int nRet = videowriter->Open(); int nRet = videowriter->Open();
if(nRet != 0) { if(nRet != 0) {
@ -184,9 +182,12 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
videowriter = NULL; videowriter = NULL;
} }
/* Create timecodes file */ snprintf( timecodes_name, sizeof(timecodes_name), "%d-%s", id, "video.timecodes" );
timecodes_fd = fopen(timecodes_file, "wb"); snprintf( timecodes_file, sizeof(timecodes_file), video_file_format, path, timecodes_name );
if(timecodes_fd == NULL) {
/* Create timecodes file */
timecodes_fd = fopen(timecodes_file, "wb");
if ( timecodes_fd == NULL ) {
Error("Failed creating timecodes file"); Error("Failed creating timecodes file");
} }
} }
@ -330,12 +331,12 @@ void Event::updateNotes( const StringSetMap &newNoteSetMap ) {
noteSet.insert( newNote ); noteSet.insert( newNote );
update = true; update = true;
} }
} } // end for
} } // end if ( noteSetMap.size() == 0
} } // end if newNoteSetupMap.size() > 0
} } // end foreach newNoteSetMap
} } // end if have old notes
} } // end if have new notes
if ( update ) { if ( update ) {
std::string notes; std::string notes;

View File

@ -181,8 +181,9 @@ void Logger::initialise( const std::string &id, const Options &options ) {
} }
} }
} }
} } // end foreach target
} } // end if config.log_debug
logFile( tempLogFile ); logFile( tempLogFile );
@ -196,7 +197,6 @@ void Logger::initialise( const std::string &id, const Options &options ) {
mFlush = (envPtr = getenv( "LOG_FLUSH")) ? atoi( envPtr ) : false; mFlush = (envPtr = getenv( "LOG_FLUSH")) ? atoi( envPtr ) : false;
//mRuntime = (envPtr = getenv( "LOG_RUNTIME")) ? atoi( envPtr ) : false; //mRuntime = (envPtr = getenv( "LOG_RUNTIME")) ? atoi( envPtr ) : false;
{ {
struct sigaction action; struct sigaction action;
memset( &action, 0, sizeof(action) ); memset( &action, 0, sizeof(action) );
@ -465,16 +465,13 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
gettimeofday( &timeVal, NULL ); gettimeofday( &timeVal, NULL );
#if 0 #if 0
if ( logRuntime ) if ( logRuntime ) {
{
static struct timeval logStart; static struct timeval logStart;
subtractTime( &timeVal, &logStart ); subtractTime( &timeVal, &logStart );
snprintf( timeString, sizeof(timeString), "%ld.%03ld", timeVal.tv_sec, timeVal.tv_usec/1000 ); snprintf( timeString, sizeof(timeString), "%ld.%03ld", timeVal.tv_sec, timeVal.tv_usec/1000 );
} } else {
else
{
#endif #endif
char *timePtr = timeString; char *timePtr = timeString;
timePtr += strftime( timePtr, sizeof(timeString), "%x %H:%M:%S", localtime(&timeVal.tv_sec) ); timePtr += strftime( timePtr, sizeof(timeString), "%x %H:%M:%S", localtime(&timeVal.tv_sec) );

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -120,7 +120,7 @@ bool RtpSource::updateSeq( uint16_t seq )
{ {
if ( uDelta == 1 ) if ( uDelta == 1 )
{ {
Debug( 3, "Packet in sequence, gap %d", uDelta ); Debug( 4, "Packet in sequence, gap %d", uDelta );
} }
else else
{ {
@ -285,36 +285,37 @@ bool RtpSource::handlePacket( const unsigned char *packet, size_t packetLen )
switch (nalType) switch (nalType)
{ {
case 24: // STAP-A case 24: // STAP-A
{ {
extraHeader = 2; extraHeader = 2;
break; break;
} }
case 25: // STAP-B case 25: // STAP-B
case 26: // MTAP-16 case 26: // MTAP-16
case 27: // MTAP-24 case 27: // MTAP-24
{
extraHeader = 3;
break;
}
// FU-A and FU-B
case 28: case 29:
{
// Is this NAL the first NAL in fragmentation sequence
if ( packet[rtpHeaderSize+1] & 0x80 )
{ {
// Now we will form new header of frame extraHeader = 3;
mFrame.append( "\x0\x0\x1\x0", 4 ); break;
// Reconstruct NAL header from FU headers
*(mFrame+3) = (packet[rtpHeaderSize+1] & 0x1f) |
(packet[rtpHeaderSize] & 0xe0);
} }
// FU-A and FU-B
case 28: case 29:
{
// Is this NAL the first NAL in fragmentation sequence
if ( packet[rtpHeaderSize+1] & 0x80 )
{
// Now we will form new header of frame
mFrame.append( "\x0\x0\x1\x0", 4 );
// Reconstruct NAL header from FU headers
*(mFrame+3) = (packet[rtpHeaderSize+1] & 0x1f) |
(packet[rtpHeaderSize] & 0xe0);
}
extraHeader = 2; extraHeader = 2;
break; break;
} }
default: { default:
Debug(3, "Unhandled nalType %d", nalType ); {
} Debug(3, "Unhandled nalType %d", nalType );
}
} }
// Append NAL frame start code // Append NAL frame start code
@ -322,8 +323,8 @@ bool RtpSource::handlePacket( const unsigned char *packet, size_t packetLen )
mFrame.append( "\x0\x0\x1", 3 ); mFrame.append( "\x0\x0\x1", 3 );
} }
mFrame.append( packet+rtpHeaderSize+extraHeader, packetLen-rtpHeaderSize-extraHeader ); mFrame.append( packet+rtpHeaderSize+extraHeader, packetLen-rtpHeaderSize-extraHeader );
} else { } else {
Debug( 3, "NOT H264 frame: type is %d", mCodecId ); Debug( 3, "NOT H264 frame: type is %d", mCodecId );
} }
Hexdump( 4, mFrame.head(), 16 ); Hexdump( 4, mFrame.head(), 16 );
@ -332,12 +333,15 @@ bool RtpSource::handlePacket( const unsigned char *packet, size_t packetLen )
{ {
if ( mFrameGood ) if ( mFrameGood )
{ {
Debug( 2, "Got new frame %d, %d bytes", mFrameCount, mFrame.size() ); Debug( 3, "Got new frame %d, %d bytes", mFrameCount, mFrame.size() );
mFrameProcessed.setValueImmediate( false ); mFrameProcessed.setValueImmediate( false );
mFrameReady.updateValueSignal( true ); mFrameReady.updateValueSignal( true );
if ( !mFrameProcessed.getValueImmediate() ) if ( !mFrameProcessed.getValueImmediate() )
{ {
// What is the point of this for loop? Is it just me, or will it call getUpdatedValue once or twice? Could it not be better written as
// if ( ! mFrameProcessed.getUpdatedValue( 1 ) && mFrameProcessed.getUpdatedValue( 1 ) ) return false;
for ( int count = 0; !mFrameProcessed.getUpdatedValue( 1 ); count++ ) for ( int count = 0; !mFrameProcessed.getUpdatedValue( 1 ); count++ )
if( count > 1 ) if( count > 1 )
return( false ); return( false );
@ -390,7 +394,7 @@ bool RtpSource::getFrame( Buffer &buffer )
buffer = mFrame; buffer = mFrame;
mFrameReady.setValueImmediate( false ); mFrameReady.setValueImmediate( false );
mFrameProcessed.updateValueSignal( true ); mFrameProcessed.updateValueSignal( true );
Debug( 3, "Copied %d bytes", buffer.size() ); Debug( 4, "Copied %d bytes", buffer.size() );
return( true ); return( true );
} }

View File

@ -70,7 +70,11 @@ X264MP4Writer::X264MP4Writer(const char* p_path, const unsigned int p_width, con
/* Calculate the image sizes. We will need this for parameter checking */ /* Calculate the image sizes. We will need this for parameter checking */
zm_imgsize = colours * width * height; zm_imgsize = colours * width * height;
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
codec_imgsize = av_image_get_buffer_size( codec_pf, width, height, 1 );
#else
codec_imgsize = avpicture_get_size( codec_pf, width, height); codec_imgsize = avpicture_get_size( codec_pf, width, height);
#endif
if(!codec_imgsize) { if(!codec_imgsize) {
Error("Failed calculating codec pixel format image size"); Error("Failed calculating codec pixel format image size");
} }

View File

@ -549,7 +549,7 @@ void VideoStore::dumpPacket( AVPacket *pkt ){
int VideoStore::writeVideoFramePacket( AVPacket *ipkt ) { int VideoStore::writeVideoFramePacket( AVPacket *ipkt ) {
av_init_packet(&opkt); av_init_packet(&opkt);
int duration; int duration = 0;
//Scale the PTS of the outgoing packet to be the correct time base //Scale the PTS of the outgoing packet to be the correct time base
if (ipkt->pts != AV_NOPTS_VALUE) { if (ipkt->pts != AV_NOPTS_VALUE) {

View File

@ -71,8 +71,7 @@ possible, this should run at more or less constant speed.
#include "zm_signal.h" #include "zm_signal.h"
#include "zm_monitor.h" #include "zm_monitor.h"
void Usage() void Usage() {
{
fprintf( stderr, "zmc -d <device_path> or -r <proto> -H <host> -P <port> -p <path> or -f <file_path> or -m <monitor_id>\n" ); fprintf( stderr, "zmc -d <device_path> or -r <proto> -H <host> -P <port> -p <path> or -f <file_path> or -m <monitor_id>\n" );
fprintf( stderr, "Options:\n" ); fprintf( stderr, "Options:\n" );
@ -88,8 +87,7 @@ void Usage()
exit( 0 ); exit( 0 );
} }
int main( int argc, char *argv[] ) int main( int argc, char *argv[] ) {
{
self = argv[0]; self = argv[0];
srand( getpid() * time( 0 ) ); srand( getpid() * time( 0 ) );
@ -107,21 +105,19 @@ int main( int argc, char *argv[] )
{"protocol", 1, 0, 'r'}, {"protocol", 1, 0, 'r'},
{"host", 1, 0, 'H'}, {"host", 1, 0, 'H'},
{"port", 1, 0, 'P'}, {"port", 1, 0, 'P'},
{"path", 1, 0, 'p'}, {"path", 1, 0, 'p'},
{"file", 1, 0, 'f'}, {"file", 1, 0, 'f'},
{"monitor", 1, 0, 'm'}, {"monitor", 1, 0, 'm'},
{"help", 0, 0, 'h'}, {"help", 0, 0, 'h'},
{"version", 0, 0, 'v'}, {"version", 0, 0, 'v'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
while (1) while (1) {
{
int option_index = 0; int option_index = 0;
int c = getopt_long (argc, argv, "d:H:P:p:f:m:h:v", long_options, &option_index); int c = getopt_long (argc, argv, "d:H:P:p:f:m:h:v", long_options, &option_index);
if (c == -1) if (c == -1) {
{
break; break;
} }
@ -158,8 +154,7 @@ int main( int argc, char *argv[] )
} }
} }
if (optind < argc) if (optind < argc) {
{
fprintf( stderr, "Extraneous options, " ); fprintf( stderr, "Extraneous options, " );
while (optind < argc) while (optind < argc)
printf ("%s ", argv[optind++]); printf ("%s ", argv[optind++]);
@ -168,37 +163,28 @@ int main( int argc, char *argv[] )
} }
int modes = ( device[0]?1:0 + host[0]?1:0 + file[0]?1:0 + (monitor_id>0?1:0) ); int modes = ( device[0]?1:0 + host[0]?1:0 + file[0]?1:0 + (monitor_id>0?1:0) );
if ( modes > 1 ) if ( modes > 1 ) {
{ fprintf( stderr, "Only one of device, host/port/path, file or monitor id allowed\n" );
fprintf( stderr, "Only one of device, file or monitor id allowed\n" );
Usage(); Usage();
exit( 0 ); exit( 0 );
} }
if ( modes < 1 ) if ( modes < 1 ) {
{ fprintf( stderr, "One of device, host/port/path, file or monitor id must be specified\n" );
fprintf( stderr, "One of device, file or monitor id must be specified\n" );
Usage(); Usage();
exit( 0 ); exit( 0 );
} }
char log_id_string[32] = ""; char log_id_string[32] = "";
if ( device[0] ) if ( device[0] ) {
{
const char *slash_ptr = strrchr( device, '/' ); const char *slash_ptr = strrchr( device, '/' );
snprintf( log_id_string, sizeof(log_id_string), "zmc_d%s", slash_ptr?slash_ptr+1:device ); snprintf( log_id_string, sizeof(log_id_string), "zmc_d%s", slash_ptr?slash_ptr+1:device );
} } else if ( host[0] ) {
else if ( host[0] )
{
snprintf( log_id_string, sizeof(log_id_string), "zmc_h%s", host ); snprintf( log_id_string, sizeof(log_id_string), "zmc_h%s", host );
} } else if ( file[0] ) {
else if ( file[0] )
{
const char *slash_ptr = strrchr( file, '/' ); const char *slash_ptr = strrchr( file, '/' );
snprintf( log_id_string, sizeof(log_id_string), "zmc_f%s", slash_ptr?slash_ptr+1:file ); snprintf( log_id_string, sizeof(log_id_string), "zmc_f%s", slash_ptr?slash_ptr+1:file );
} } else {
else
{
snprintf( log_id_string, sizeof(log_id_string), "zmc_m%d", monitor_id ); snprintf( log_id_string, sizeof(log_id_string), "zmc_m%d", monitor_id );
} }
@ -211,35 +197,26 @@ int main( int argc, char *argv[] )
Monitor **monitors = 0; Monitor **monitors = 0;
int n_monitors = 0; int n_monitors = 0;
#if ZM_HAS_V4L #if ZM_HAS_V4L
if ( device[0] ) if ( device[0] ) {
{
n_monitors = Monitor::LoadLocalMonitors( device, monitors, Monitor::CAPTURE ); n_monitors = Monitor::LoadLocalMonitors( device, monitors, Monitor::CAPTURE );
} } else
else
#endif // ZM_HAS_V4L #endif // ZM_HAS_V4L
if ( host[0] ) if ( host[0] ) {
{
if ( !port ) if ( !port )
port = "80"; port = "80";
n_monitors = Monitor::LoadRemoteMonitors( protocol, host, port, path, monitors, Monitor::CAPTURE ); n_monitors = Monitor::LoadRemoteMonitors( protocol, host, port, path, monitors, Monitor::CAPTURE );
} } else if ( file[0] ) {
else if ( file[0] )
{
n_monitors = Monitor::LoadFileMonitors( file, monitors, Monitor::CAPTURE ); n_monitors = Monitor::LoadFileMonitors( file, monitors, Monitor::CAPTURE );
} } else {
else
{
Monitor *monitor = Monitor::Load( monitor_id, true, Monitor::CAPTURE ); Monitor *monitor = Monitor::Load( monitor_id, true, Monitor::CAPTURE );
if ( monitor ) if ( monitor ) {
{
monitors = new Monitor *[1]; monitors = new Monitor *[1];
monitors[0] = monitor; monitors[0] = monitor;
n_monitors = 1; n_monitors = 1;
} }
} }
if ( !n_monitors ) if ( !n_monitors ) {
{
Error( "No monitors found" ); Error( "No monitors found" );
exit ( -1 ); exit ( -1 );
} }
@ -255,8 +232,7 @@ int main( int argc, char *argv[] )
sigaddset( &block_set, SIGUSR1 ); sigaddset( &block_set, SIGUSR1 );
sigaddset( &block_set, SIGUSR2 ); sigaddset( &block_set, SIGUSR2 );
if ( monitors[0]->PrimeCapture() < 0 ) if ( monitors[0]->PrimeCapture() < 0 ) {
{
Error( "Failed to prime capture of initial monitor" ); Error( "Failed to prime capture of initial monitor" );
exit( -1 ); exit( -1 );
} }
@ -265,8 +241,7 @@ int main( int argc, char *argv[] )
long *alarm_capture_delays = new long[n_monitors]; long *alarm_capture_delays = new long[n_monitors];
long *next_delays = new long[n_monitors]; long *next_delays = new long[n_monitors];
struct timeval * last_capture_times = new struct timeval[n_monitors]; struct timeval * last_capture_times = new struct timeval[n_monitors];
for ( int i = 0; i < n_monitors; i++ ) for ( int i = 0; i < n_monitors; i++ ) {
{
last_capture_times[i].tv_sec = last_capture_times[i].tv_usec = 0; last_capture_times[i].tv_sec = last_capture_times[i].tv_usec = 0;
capture_delays[i] = monitors[i]->GetCaptureDelay(); capture_delays[i] = monitors[i]->GetCaptureDelay();
alarm_capture_delays[i] = monitors[i]->GetAlarmCaptureDelay(); alarm_capture_delays[i] = monitors[i]->GetAlarmCaptureDelay();
@ -275,18 +250,14 @@ int main( int argc, char *argv[] )
int result = 0; int result = 0;
struct timeval now; struct timeval now;
struct DeltaTimeval delta_time; struct DeltaTimeval delta_time;
while( !zm_terminate ) while( !zm_terminate ) {
{
sigprocmask( SIG_BLOCK, &block_set, 0 ); sigprocmask( SIG_BLOCK, &block_set, 0 );
for ( int i = 0; i < n_monitors; i++ ) for ( int i = 0; i < n_monitors; i++ ) {
{
long min_delay = MAXINT; long min_delay = MAXINT;
gettimeofday( &now, NULL ); gettimeofday( &now, NULL );
for ( int j = 0; j < n_monitors; j++ ) for ( int j = 0; j < n_monitors; j++ ) {
{ if ( last_capture_times[j].tv_sec ) {
if ( last_capture_times[j].tv_sec )
{
DELTA_TIMEVAL( delta_time, now, last_capture_times[j], DT_PREC_3 ); DELTA_TIMEVAL( delta_time, now, last_capture_times[j], DT_PREC_3 );
if ( monitors[i]->GetState() == Monitor::ALARM ) if ( monitors[i]->GetState() == Monitor::ALARM )
next_delays[j] = alarm_capture_delays[j]-delta_time.delta; next_delays[j] = alarm_capture_delays[j]-delta_time.delta;
@ -294,58 +265,49 @@ int main( int argc, char *argv[] )
next_delays[j] = capture_delays[j]-delta_time.delta; next_delays[j] = capture_delays[j]-delta_time.delta;
if ( next_delays[j] < 0 ) if ( next_delays[j] < 0 )
next_delays[j] = 0; next_delays[j] = 0;
} } else {
else
{
next_delays[j] = 0; next_delays[j] = 0;
} }
if ( next_delays[j] <= min_delay ) if ( next_delays[j] <= min_delay ) {
{
min_delay = next_delays[j]; min_delay = next_delays[j];
} }
} }
if ( next_delays[i] <= min_delay || next_delays[i] <= 0 ) if ( next_delays[i] <= min_delay || next_delays[i] <= 0 ) {
{ if ( monitors[i]->PreCapture() < 0 ) {
if ( monitors[i]->PreCapture() < 0 )
{
Error( "Failed to pre-capture monitor %d %d (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors ); Error( "Failed to pre-capture monitor %d %d (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
zm_terminate = true; zm_terminate = true;
result = -1; result = -1;
break; break;
} }
if ( monitors[i]->Capture() < 0 ) if ( monitors[i]->Capture() < 0 ) {
{
Error( "Failed to capture image from monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors ); Error( "Failed to capture image from monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
zm_terminate = true; zm_terminate = true;
result = -1; result = -1;
break; break;
} }
if ( monitors[i]->PostCapture() < 0 ) if ( monitors[i]->PostCapture() < 0 ) {
{
Error( "Failed to post-capture monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors ); Error( "Failed to post-capture monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors );
zm_terminate = true; zm_terminate = true;
result = -1; result = -1;
break; break;
} }
if ( next_delays[i] > 0 ) if ( next_delays[i] > 0 ) {
{
gettimeofday( &now, NULL ); gettimeofday( &now, NULL );
DELTA_TIMEVAL( delta_time, now, last_capture_times[i], DT_PREC_3 ); DELTA_TIMEVAL( delta_time, now, last_capture_times[i], DT_PREC_3 );
long sleep_time = next_delays[i]-delta_time.delta; long sleep_time = next_delays[i]-delta_time.delta;
if ( sleep_time > 0 ) if ( sleep_time > 0 ) {
{
usleep( sleep_time*(DT_MAXGRAN/DT_PREC_3) ); usleep( sleep_time*(DT_MAXGRAN/DT_PREC_3) );
} }
} }
gettimeofday( &(last_capture_times[i]), NULL ); gettimeofday( &(last_capture_times[i]), NULL );
} } // end if next_delay <= min_delay || next_delays[i] <= 0 )
}
} // end foreach n_monitors
sigprocmask( SIG_UNBLOCK, &block_set, 0 ); sigprocmask( SIG_UNBLOCK, &block_set, 0 );
} } // end while ! zm_terminate
for ( int i = 0; i < n_monitors; i++ ) for ( int i = 0; i < n_monitors; i++ ) {
{
delete monitors[i]; delete monitors[i];
} }
delete [] monitors; delete [] monitors;