Merge ../ZoneMinder.connortechnology
This commit is contained in:
commit
a5ee8307d0
|
@ -129,7 +129,7 @@ BEGIN {
|
|||
} # end BEGIN
|
||||
|
||||
sub loadConfigFromDB {
|
||||
print( "Loading config from DB\n" );
|
||||
print( "Loading config from DB" );
|
||||
my $dbh = ZoneMinder::Database::zmDbConnect();
|
||||
if ( !$dbh ) {
|
||||
print( "Error: unable to load options from database: $DBI::errstr\n" );
|
||||
|
@ -160,11 +160,12 @@ sub loadConfigFromDB {
|
|||
$option_count++;;
|
||||
}
|
||||
$sth->finish();
|
||||
print( " $option_count entries\n" );
|
||||
return( $option_count );
|
||||
} # end sub loadConfigFromDB
|
||||
|
||||
sub saveConfigToDB {
|
||||
print( "Saving config to DB\n" );
|
||||
print( "Saving config to DB " . @options . " entries\n" );
|
||||
my $dbh = ZoneMinder::Database::zmDbConnect();
|
||||
if ( !$dbh ) {
|
||||
print( "Error: unable to save options to database: $DBI::errstr\n" );
|
||||
|
|
|
@ -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 );
|
||||
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 ) ) {
|
||||
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 ) );
|
||||
}
|
||||
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 ) {
|
||||
snprintf( video_name, sizeof(video_name), "%d-%s", id, "video.mp4" );
|
||||
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 */
|
||||
if(monitor->GetOptVideoWriter() == 1) {
|
||||
if ( monitor->GetOptVideoWriter() == X264ENCODE ) {
|
||||
#if ZM_HAVE_VIDEOWRITER_X264MP4
|
||||
videowriter = new X264MP4Writer(video_file, monitor->Width(), monitor->Height(), monitor->Colours(), monitor->SubpixelOrder(), monitor->GetOptEncoderParams());
|
||||
#else
|
||||
|
@ -175,7 +173,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
|||
#endif
|
||||
}
|
||||
|
||||
if(videowriter != NULL) {
|
||||
if ( videowriter != NULL ) {
|
||||
/* Open the video stream */
|
||||
int nRet = videowriter->Open();
|
||||
if(nRet != 0) {
|
||||
|
@ -184,9 +182,12 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
|||
videowriter = NULL;
|
||||
}
|
||||
|
||||
/* Create timecodes file */
|
||||
timecodes_fd = fopen(timecodes_file, "wb");
|
||||
if(timecodes_fd == NULL) {
|
||||
snprintf( timecodes_name, sizeof(timecodes_name), "%d-%s", id, "video.timecodes" );
|
||||
snprintf( timecodes_file, sizeof(timecodes_file), video_file_format, path, timecodes_name );
|
||||
|
||||
/* Create timecodes file */
|
||||
timecodes_fd = fopen(timecodes_file, "wb");
|
||||
if ( timecodes_fd == NULL ) {
|
||||
Error("Failed creating timecodes file");
|
||||
}
|
||||
}
|
||||
|
@ -330,12 +331,12 @@ void Event::updateNotes( const StringSetMap &newNoteSetMap ) {
|
|||
noteSet.insert( newNote );
|
||||
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 ) {
|
||||
std::string notes;
|
||||
|
|
|
@ -181,8 +181,9 @@ void Logger::initialise( const std::string &id, const Options &options ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end foreach target
|
||||
} // end if config.log_debug
|
||||
|
||||
|
||||
logFile( tempLogFile );
|
||||
|
||||
|
@ -196,7 +197,6 @@ void Logger::initialise( const std::string &id, const Options &options ) {
|
|||
mFlush = (envPtr = getenv( "LOG_FLUSH")) ? atoi( envPtr ) : false;
|
||||
|
||||
//mRuntime = (envPtr = getenv( "LOG_RUNTIME")) ? atoi( envPtr ) : false;
|
||||
|
||||
{
|
||||
struct sigaction 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 );
|
||||
|
||||
#if 0
|
||||
if ( logRuntime )
|
||||
{
|
||||
if ( logRuntime ) {
|
||||
static struct timeval logStart;
|
||||
|
||||
subtractTime( &timeVal, &logStart );
|
||||
|
||||
snprintf( timeString, sizeof(timeString), "%ld.%03ld", timeVal.tv_sec, timeVal.tv_usec/1000 );
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#endif
|
||||
char *timePtr = timeString;
|
||||
timePtr += strftime( timePtr, sizeof(timeString), "%x %H:%M:%S", localtime(&timeVal.tv_sec) );
|
||||
|
|
1015
src/zm_mpeg.cpp
1015
src/zm_mpeg.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -64,7 +64,7 @@ RtpSource::RtpSource( int id, const std::string &localHost, int localPortBase, c
|
|||
mLastSrTimeReal = tvZero();
|
||||
mLastSrTimeNtp = tvZero();
|
||||
mLastSrTimeRtp = 0;
|
||||
|
||||
|
||||
if(mCodecId != AV_CODEC_ID_H264 && mCodecId != AV_CODEC_ID_MPEG4)
|
||||
Warning( "The device is using a codec that may not be supported. Do not be surprised if things don't work." );
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ bool RtpSource::updateSeq( uint16_t seq )
|
|||
{
|
||||
if ( uDelta == 1 )
|
||||
{
|
||||
Debug( 3, "Packet in sequence, gap %d", uDelta );
|
||||
Debug( 4, "Packet in sequence, gap %d", uDelta );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ void RtpSource::updateRtcpData( uint32_t ntpTimeSecs, uint32_t ntpTimeFrac, uint
|
|||
struct timeval ntpTime = tvMake( ntpTimeSecs, suseconds_t((USEC_PER_SEC*(ntpTimeFrac>>16))/(1<<16)) );
|
||||
|
||||
Debug( 5, "ntpTime: %ld.%06ld, rtpTime: %x", ntpTime.tv_sec, ntpTime.tv_usec, rtpTime );
|
||||
|
||||
|
||||
if ( mBaseTimeNtp.tv_sec == 0 )
|
||||
{
|
||||
mBaseTimeReal = tvNow();
|
||||
|
@ -276,54 +276,55 @@ bool RtpSource::handlePacket( const unsigned char *packet, size_t packetLen )
|
|||
if ( mFrameGood )
|
||||
{
|
||||
int extraHeader = 0;
|
||||
|
||||
|
||||
if( mCodecId == AV_CODEC_ID_H264 )
|
||||
{
|
||||
int nalType = (packet[rtpHeaderSize] & 0x1f);
|
||||
Debug( 3, "Have H264 frame: nal type is %d", nalType );
|
||||
|
||||
|
||||
switch (nalType)
|
||||
{
|
||||
case 24: // STAP-A
|
||||
{
|
||||
extraHeader = 2;
|
||||
break;
|
||||
}
|
||||
{
|
||||
extraHeader = 2;
|
||||
break;
|
||||
}
|
||||
case 25: // STAP-B
|
||||
case 26: // MTAP-16
|
||||
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
|
||||
mFrame.append( "\x0\x0\x1\x0", 4 );
|
||||
// Reconstruct NAL header from FU headers
|
||||
*(mFrame+3) = (packet[rtpHeaderSize+1] & 0x1f) |
|
||||
(packet[rtpHeaderSize] & 0xe0);
|
||||
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
|
||||
mFrame.append( "\x0\x0\x1\x0", 4 );
|
||||
// Reconstruct NAL header from FU headers
|
||||
*(mFrame+3) = (packet[rtpHeaderSize+1] & 0x1f) |
|
||||
(packet[rtpHeaderSize] & 0xe0);
|
||||
}
|
||||
|
||||
extraHeader = 2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Debug(3, "Unhandled nalType %d", nalType );
|
||||
}
|
||||
|
||||
extraHeader = 2;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
Debug(3, "Unhandled nalType %d", nalType );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Append NAL frame start code
|
||||
if ( !mFrame.size() )
|
||||
mFrame.append( "\x0\x0\x1", 3 );
|
||||
}
|
||||
mFrame.append( packet+rtpHeaderSize+extraHeader, packetLen-rtpHeaderSize-extraHeader );
|
||||
} else {
|
||||
Debug( 3, "NOT H264 frame: type is %d", mCodecId );
|
||||
} else {
|
||||
Debug( 3, "NOT H264 frame: type is %d", mCodecId );
|
||||
}
|
||||
|
||||
Hexdump( 4, mFrame.head(), 16 );
|
||||
|
@ -332,12 +333,15 @@ bool RtpSource::handlePacket( const unsigned char *packet, size_t packetLen )
|
|||
{
|
||||
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 );
|
||||
mFrameReady.updateValueSignal( true );
|
||||
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++ )
|
||||
if( count > 1 )
|
||||
return( false );
|
||||
|
@ -390,7 +394,7 @@ bool RtpSource::getFrame( Buffer &buffer )
|
|||
buffer = mFrame;
|
||||
mFrameReady.setValueImmediate( false );
|
||||
mFrameProcessed.updateValueSignal( true );
|
||||
Debug( 3, "Copied %d bytes", buffer.size() );
|
||||
Debug( 4, "Copied %d bytes", buffer.size() );
|
||||
return( true );
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
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);
|
||||
#endif
|
||||
if(!codec_imgsize) {
|
||||
Error("Failed calculating codec pixel format image size");
|
||||
}
|
||||
|
|
|
@ -549,7 +549,7 @@ void VideoStore::dumpPacket( AVPacket *pkt ){
|
|||
int VideoStore::writeVideoFramePacket( AVPacket *ipkt ) {
|
||||
av_init_packet(&opkt);
|
||||
|
||||
int duration;
|
||||
int duration = 0;
|
||||
|
||||
//Scale the PTS of the outgoing packet to be the correct time base
|
||||
if (ipkt->pts != AV_NOPTS_VALUE) {
|
||||
|
|
120
src/zmc.cpp
120
src/zmc.cpp
|
@ -71,8 +71,7 @@ possible, this should run at more or less constant speed.
|
|||
#include "zm_signal.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, "Options:\n" );
|
||||
|
@ -88,8 +87,7 @@ void Usage()
|
|||
exit( 0 );
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
int main( int argc, char *argv[] ) {
|
||||
self = argv[0];
|
||||
|
||||
srand( getpid() * time( 0 ) );
|
||||
|
@ -107,21 +105,19 @@ int main( int argc, char *argv[] )
|
|||
{"protocol", 1, 0, 'r'},
|
||||
{"host", 1, 0, 'H'},
|
||||
{"port", 1, 0, 'P'},
|
||||
{"path", 1, 0, 'p'},
|
||||
{"file", 1, 0, 'f'},
|
||||
{"path", 1, 0, 'p'},
|
||||
{"file", 1, 0, 'f'},
|
||||
{"monitor", 1, 0, 'm'},
|
||||
{"help", 0, 0, 'h'},
|
||||
{"version", 0, 0, 'v'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
int option_index = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -158,8 +154,7 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
if (optind < argc) {
|
||||
fprintf( stderr, "Extraneous options, " );
|
||||
while (optind < argc)
|
||||
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) );
|
||||
if ( modes > 1 )
|
||||
{
|
||||
fprintf( stderr, "Only one of device, file or monitor id allowed\n" );
|
||||
if ( modes > 1 ) {
|
||||
fprintf( stderr, "Only one of device, host/port/path, file or monitor id allowed\n" );
|
||||
Usage();
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
if ( modes < 1 )
|
||||
{
|
||||
fprintf( stderr, "One of device, file or monitor id must be specified\n" );
|
||||
if ( modes < 1 ) {
|
||||
fprintf( stderr, "One of device, host/port/path, file or monitor id must be specified\n" );
|
||||
Usage();
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
char log_id_string[32] = "";
|
||||
if ( device[0] )
|
||||
{
|
||||
if ( device[0] ) {
|
||||
const char *slash_ptr = strrchr( 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 );
|
||||
}
|
||||
else if ( file[0] )
|
||||
{
|
||||
} else if ( file[0] ) {
|
||||
const char *slash_ptr = strrchr( 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 );
|
||||
}
|
||||
|
||||
|
@ -211,35 +197,26 @@ int main( int argc, char *argv[] )
|
|||
Monitor **monitors = 0;
|
||||
int n_monitors = 0;
|
||||
#if ZM_HAS_V4L
|
||||
if ( device[0] )
|
||||
{
|
||||
if ( device[0] ) {
|
||||
n_monitors = Monitor::LoadLocalMonitors( device, monitors, Monitor::CAPTURE );
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif // ZM_HAS_V4L
|
||||
if ( host[0] )
|
||||
{
|
||||
if ( host[0] ) {
|
||||
if ( !port )
|
||||
port = "80";
|
||||
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 );
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Monitor *monitor = Monitor::Load( monitor_id, true, Monitor::CAPTURE );
|
||||
if ( monitor )
|
||||
{
|
||||
if ( monitor ) {
|
||||
monitors = new Monitor *[1];
|
||||
monitors[0] = monitor;
|
||||
n_monitors = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !n_monitors )
|
||||
{
|
||||
if ( !n_monitors ) {
|
||||
Error( "No monitors found" );
|
||||
exit ( -1 );
|
||||
}
|
||||
|
@ -255,8 +232,7 @@ int main( int argc, char *argv[] )
|
|||
sigaddset( &block_set, SIGUSR1 );
|
||||
sigaddset( &block_set, SIGUSR2 );
|
||||
|
||||
if ( monitors[0]->PrimeCapture() < 0 )
|
||||
{
|
||||
if ( monitors[0]->PrimeCapture() < 0 ) {
|
||||
Error( "Failed to prime capture of initial monitor" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
@ -265,8 +241,7 @@ int main( int argc, char *argv[] )
|
|||
long *alarm_capture_delays = new long[n_monitors];
|
||||
long *next_delays = new long[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;
|
||||
capture_delays[i] = monitors[i]->GetCaptureDelay();
|
||||
alarm_capture_delays[i] = monitors[i]->GetAlarmCaptureDelay();
|
||||
|
@ -275,18 +250,14 @@ int main( int argc, char *argv[] )
|
|||
int result = 0;
|
||||
struct timeval now;
|
||||
struct DeltaTimeval delta_time;
|
||||
while( !zm_terminate )
|
||||
{
|
||||
while( !zm_terminate ) {
|
||||
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;
|
||||
|
||||
gettimeofday( &now, NULL );
|
||||
for ( int j = 0; j < n_monitors; j++ )
|
||||
{
|
||||
if ( last_capture_times[j].tv_sec )
|
||||
{
|
||||
for ( int j = 0; j < n_monitors; j++ ) {
|
||||
if ( last_capture_times[j].tv_sec ) {
|
||||
DELTA_TIMEVAL( delta_time, now, last_capture_times[j], DT_PREC_3 );
|
||||
if ( monitors[i]->GetState() == Monitor::ALARM )
|
||||
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;
|
||||
if ( next_delays[j] < 0 )
|
||||
next_delays[j] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
next_delays[j] = 0;
|
||||
}
|
||||
if ( next_delays[j] <= min_delay )
|
||||
{
|
||||
if ( next_delays[j] <= min_delay ) {
|
||||
min_delay = next_delays[j];
|
||||
}
|
||||
}
|
||||
|
||||
if ( next_delays[i] <= min_delay || next_delays[i] <= 0 )
|
||||
{
|
||||
if ( monitors[i]->PreCapture() < 0 )
|
||||
{
|
||||
if ( next_delays[i] <= min_delay || next_delays[i] <= 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 );
|
||||
zm_terminate = true;
|
||||
result = -1;
|
||||
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 );
|
||||
zm_terminate = true;
|
||||
result = -1;
|
||||
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 );
|
||||
zm_terminate = true;
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( next_delays[i] > 0 )
|
||||
{
|
||||
if ( next_delays[i] > 0 ) {
|
||||
gettimeofday( &now, NULL );
|
||||
DELTA_TIMEVAL( delta_time, now, last_capture_times[i], DT_PREC_3 );
|
||||
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) );
|
||||
}
|
||||
}
|
||||
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 );
|
||||
}
|
||||
for ( int i = 0; i < n_monitors; i++ )
|
||||
{
|
||||
} // end while ! zm_terminate
|
||||
for ( int i = 0; i < n_monitors; i++ ) {
|
||||
delete monitors[i];
|
||||
}
|
||||
delete [] monitors;
|
||||
|
|
Loading…
Reference in New Issue