Merge branch 'storageareas' into zma_to_thread

pull/3122/head
Isaac Connor 2017-12-12 15:29:19 -05:00
commit bcdadc67bf
34 changed files with 167 additions and 158 deletions

View File

@ -278,26 +278,26 @@ sub delete {
Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} $event->{StartTime}\n" );
$ZoneMinder::Database::dbh->ping();
# Do it individually to avoid locking up the table for new events
my $sql = 'delete from Events where Id = ?';
my $sql = 'DELETE FROM Events WHERE Id=?';
my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
or Error( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
my $res = $sth->execute( $event->{Id} )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
or Error( "Can't execute '$sql': ".$sth->errstr() );
$sth->finish();
if ( ! $Config{ZM_OPT_FAST_DELETE} ) {
my $sql = 'delete from Frames where EventId = ?';
my $sql = 'DELETE FROM Frames WHERE EventId=?';
my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
or Error( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
my $res = $sth->execute( $event->{Id} )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
or Error( "Can't execute '$sql': ".$sth->errstr() );
$sth->finish();
$sql = 'delete from Stats where EventId = ?';
$sql = 'DELETE FROM Stats WHERE EventId=?';
$sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
or Error( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
$res = $sth->execute( $event->{Id} )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
or Error( "Can't execute '$sql': ".$sth->errstr() );
$sth->finish();
$event->delete_files( );

View File

@ -246,7 +246,7 @@ FILTER: while( my $db_filter = $sth->fetchrow_hashref() ) {
}
return( @filters );
}
} # end sub getFilters
sub checkFilter {
my $filter = shift;

View File

@ -574,14 +574,14 @@ bool InetSocket::connect( const char *host, const char *serv )
::close(mSd);
}
freeaddrinfo(result); /* No longer needed */
if (rp == NULL) { /* No address succeeded */
Error( "connect(), Could not connect" );
mAddressFamily = AF_UNSPEC;
return( false );
}
freeaddrinfo(result); /* No longer needed */
mState = CONNECTED;
return( true );

View File

@ -55,9 +55,9 @@ void zmLoadConfig() {
for ( unsigned int i = 0; i < pglob.gl_pathc; i++ ) {
process_configfile(pglob.gl_pathv[i]);
}
closedir(configSubFolder);
}
globfree( &pglob );
closedir(configSubFolder);
}
zmDbConnect();
@ -107,6 +107,7 @@ void process_configfile( char* configFile) {
char line[512];
if ( (cfg = fopen( configFile, "r")) == NULL ) {
Fatal( "Can't open %s: %s", configFile, strerror(errno) );
return;
}
while ( fgets( line, sizeof(line), cfg ) != NULL ) {
char *line_ptr = line;
@ -214,6 +215,7 @@ ConfigItem::ConfigItem( const char *p_name, const char *p_value, const char *con
//Info( "Created new config item %s = %s (%s)\n", name, value, type );
cfg_type = CFG_UNKNOWN;
accessed = false;
}

View File

@ -97,7 +97,7 @@ private:
char *value;
char *type;
mutable enum { CFG_BOOLEAN, CFG_INTEGER, CFG_DECIMAL, CFG_STRING } cfg_type;
mutable enum { CFG_UNKNOWN, CFG_BOOLEAN, CFG_INTEGER, CFG_DECIMAL, CFG_STRING } cfg_type;
mutable union {
bool boolean_value;
int integer_value;

View File

@ -57,7 +57,7 @@ void cURLCamera::Initialise() {
databuffer.expand(CURL_BUFFER_INITIAL_SIZE);
/* cURL initialization */
cRet = curl_global_init(CURL_GLOBAL_ALL);
CURLcode cRet = curl_global_init(CURL_GLOBAL_ALL);
if(cRet != CURLE_OK) {
Fatal("libcurl initialization failed: ", curl_easy_strerror(cRet));
}
@ -65,7 +65,7 @@ void cURLCamera::Initialise() {
Debug(2,"libcurl version: %s",curl_version());
/* Create the shared data mutex */
nRet = pthread_mutex_init(&shareddata_mutex, NULL);
int nRet = pthread_mutex_init(&shareddata_mutex, NULL);
if(nRet != 0) {
Fatal("Shared data mutex creation failed: %s",strerror(nRet));
}
@ -124,6 +124,7 @@ int cURLCamera::Capture( ZMPacket &zm_packet ) {
unsigned int frame_content_length = 0;
std::string frame_content_type;
bool need_more_data = false;
int nRet;
/* Grab the mutex to ensure exclusive access to the shared data */
lock();
@ -312,9 +313,10 @@ size_t cURLCamera::data_callback(void *buffer, size_t size, size_t nmemb, void *
databuffer.append((const char*)buffer, size*nmemb);
/* Signal data available */
nRet = pthread_cond_signal(&data_available_cond);
if(nRet != 0) {
int nRet = pthread_cond_signal(&data_available_cond);
if ( nRet != 0 ) {
Error("Failed signaling data available condition variable: %s",strerror(nRet));
unlock();
return -16;
}
@ -373,6 +375,7 @@ void* cURLCamera::thread_func() {
Fatal("Failed getting easy handle from libcurl");
}
CURLcode cRet;
/* Set URL */
cRet = curl_easy_setopt(c, CURLOPT_URL, mPath.c_str());
if(cRet != CURLE_OK)

View File

@ -87,10 +87,6 @@ public:
int lock();
int unlock();
private:
int nRet;
CURLcode cRet;
};
/* Dispatchers */

View File

@ -143,9 +143,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
// Shallow Storage
snprintf( path, sizeof(path), "%s/%d/%d", storage->Path(), monitor->Id(), id );
errno = 0;
stat( path, &statbuf );
if ( errno == ENOENT || errno == ENOTDIR ) {
if ( stat( path, &statbuf ) && ( errno == ENOENT || errno == ENOTDIR ) ) {
if ( mkdir( path, 0755 ) ) {
Error( "Can't mkdir %s: %s", path, strerror(errno));
}

View File

@ -184,7 +184,7 @@ bool EventStream::loadEventData( int event_id ) {
timestamp = atoi(dbrow[1]);
double delta = atof(dbrow[2]);
int id_diff = id - last_id;
double frame_delta = (delta-last_delta)/id_diff;
double frame_delta = id_diff ? (delta-last_delta)/id_diff : 0;
if ( id_diff > 1 ) {
for ( int i = last_id+1; i < id; i++ ) {
event_data->frames[i-1].timestamp = (time_t)(last_timestamp + ((i-last_id)*frame_delta));
@ -712,7 +712,6 @@ bool EventStream::sendFrame( int delta_us ) {
break;
}
if ( send_raw ) {
#if HAVE_SENDFILE
fprintf( stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size );
@ -720,6 +719,7 @@ bool EventStream::sendFrame( int delta_us ) {
/* sendfile() failed, use standard way instead */
img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj );
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
fclose(fdj); /* Close the file handle */
Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno));
return( false );
}
@ -727,6 +727,7 @@ bool EventStream::sendFrame( int delta_us ) {
#else
fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size );
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
fclose(fdj); /* Close the file handle */
Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno));
return( false );
}
@ -754,8 +755,6 @@ void EventStream::runStream() {
checkInitialised();
Debug(3, "frame rate is: (%f)", (double)event_data->frame_count/event_data->duration );
updateFrameRate( (double)event_data->frame_count/event_data->duration );
if ( type == STREAM_JPEG )
fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
@ -765,6 +764,9 @@ void EventStream::runStream() {
exit( 0 );
}
Debug(3, "frame rate is: (%f)", (double)event_data->frame_count/event_data->duration );
updateFrameRate( (double)event_data->frame_count/event_data->duration );
while( !zm_terminate ) {
gettimeofday( &now, NULL );

View File

@ -211,7 +211,7 @@ int hacked_up_context2_for_older_ffmpeg(AVFormatContext **avctx, AVOutputFormat
}
#endif
if (filename) strncpy(s->filename, filename, sizeof(s->filename));
if (filename) strncpy(s->filename, filename, sizeof(s->filename)-1);
*avctx = s;
return 0;
}

View File

@ -229,9 +229,6 @@ int FfmpegCamera::OpenFfmpeg() {
mFormatContext = avformat_alloc_context( );
monitor->GetLastEventId() ;
Debug(2, "before avformat_open_input" );
if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, &opts ) != 0 )
#endif
{
@ -239,8 +236,6 @@ int FfmpegCamera::OpenFfmpeg() {
Error( "Unable to open input %s due to: %s", mPath.c_str(), strerror(errno) );
return -1;
}
Debug(2, "afte avformat_open_input" );
monitor->GetLastEventId() ;
AVDictionaryEntry *e = NULL;
while ( (e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)) != NULL ) {

View File

@ -60,7 +60,7 @@ FileCamera::FileCamera(
p_capture,
p_record_audio )
{
strncpy( path, p_path, sizeof(path) );
strncpy( path, p_path, sizeof(path)-1 );
if ( capture ) {
Initialise();
}
@ -90,7 +90,7 @@ int FileCamera::PreCapture() {
}
// I think this is waiting for file change...
while ( (time( 0 ) - statbuf.st_mtime) < 1 ) {
while ( (time(0) - statbuf.st_mtime) < 1 ) {
usleep( 100000 );
}
return( 0 );

View File

@ -754,57 +754,53 @@ Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p
return( high_image );
}
bool Image::ReadRaw( const char *filename )
{
bool Image::ReadRaw( const char *filename ) {
FILE *infile;
if ( (infile = fopen( filename, "rb" )) == NULL )
{
Error( "Can't open %s: %s", filename, strerror(errno) );
return( false );
if ( (infile = fopen( filename, "rb" )) == NULL ) {
Error("Can't open %s: %s", filename, strerror(errno));
return false;
}
struct stat statbuf;
if ( fstat( fileno(infile), &statbuf ) < 0 )
{
Error( "Can't fstat %s: %s", filename, strerror(errno) );
return( false );
if ( fstat( fileno(infile), &statbuf ) < 0 ) {
fclose(infile);
Error("Can't fstat %s: %s", filename, strerror(errno));
return false;
}
if ( statbuf.st_size != size )
{
Error( "Raw file size mismatch, expected %d bytes, found %ld", size, statbuf.st_size );
return( false );
if ( statbuf.st_size != size ) {
fclose(infile);
Error("Raw file size mismatch, expected %d bytes, found %ld", size, statbuf.st_size);
return false;
}
if ( fread( buffer, size, 1, infile ) < 1 )
{
Fatal( "Unable to read from '%s': %s", filename, strerror(errno) );
return( false );
if ( fread(buffer, size, 1, infile) < 1 ) {
fclose(infile);
Error("Unable to read from '%s': %s", filename, strerror(errno));
return false;
}
fclose( infile );
return( true );
return true;
}
bool Image::WriteRaw( const char *filename ) const
{
bool Image::WriteRaw( const char *filename ) const {
FILE *outfile;
if ( (outfile = fopen( filename, "wb" )) == NULL )
{
if ( (outfile = fopen( filename, "wb" )) == NULL ) {
Error( "Can't open %s: %s", filename, strerror(errno) );
return( false );
return false;
}
if ( fwrite( buffer, size, 1, outfile ) != 1 )
{
if ( fwrite( buffer, size, 1, outfile ) != 1 ) {
Error( "Unable to write to '%s': %s", filename, strerror(errno) );
return( false );
fclose( outfile );
return false;
}
fclose( outfile );
return( true );
return true;
}
bool Image::ReadJpeg( const char *filename, unsigned int p_colours, unsigned int p_subpixelorder)
@ -1347,24 +1343,20 @@ bool Image::Zip( Bytef *outbuffer, unsigned long *outbuffer_size, int compressio
}
#endif // HAVE_ZLIB_H
bool Image::Crop( unsigned int lo_x, unsigned int lo_y, unsigned int hi_x, unsigned int hi_y )
{
bool Image::Crop( unsigned int lo_x, unsigned int lo_y, unsigned int hi_x, unsigned int hi_y ) {
unsigned int new_width = (hi_x-lo_x)+1;
unsigned int new_height = (hi_y-lo_y)+1;
if ( lo_x > hi_x || lo_y > hi_y )
{
if ( lo_x > hi_x || lo_y > hi_y ) {
Error( "Invalid or reversed crop region %d,%d -> %d,%d", lo_x, lo_y, hi_x, hi_y );
return( false );
}
if ( lo_x < 0 || hi_x > (width-1) || ( lo_y < 0 || hi_y > (height-1) ) )
{
if ( hi_x > (width-1) || ( hi_y > (height-1) ) ) {
Error( "Attempting to crop outside image, %d,%d -> %d,%d not in %d,%d", lo_x, lo_y, hi_x, hi_y, width-1, height-1 );
return( false );
}
if ( new_width == width && new_height == height )
{
if ( new_width == width && new_height == height ) {
return( true );
}
@ -1372,8 +1364,7 @@ bool Image::Crop( unsigned int lo_x, unsigned int lo_y, unsigned int hi_x, unsig
uint8_t *new_buffer = AllocBuffer(new_size);
unsigned int new_stride = new_width*colours;
for ( unsigned int y = lo_y, ny = 0; y <= hi_y; y++, ny++ )
{
for ( unsigned int y = lo_y, ny = 0; y <= hi_y; y++, ny++ ) {
unsigned char *pbuf = &buffer[((y*width)+lo_x)*colours];
unsigned char *pnbuf = &new_buffer[(ny*new_width)*colours];
memcpy( pnbuf, pbuf, new_stride );
@ -1935,7 +1926,7 @@ void Image::MaskPrivacy( const unsigned char *p_bitmask, const Rgb pixel_colour
/* RGB32 compatible: complete */
void Image::Annotate( const char *p_text, const Coord &coord, const unsigned int size, const Rgb fg_colour, const Rgb bg_colour )
{
strncpy( text, p_text, sizeof(text) );
strncpy( text, p_text, sizeof(text)-1 );
unsigned int index = 0;
unsigned int line_no = 0;
@ -4666,17 +4657,17 @@ __attribute__((noinline)) void zm_convert_yuyv_rgba(const uint8_t* col1, uint8_t
g = y1 - (g_u_table[u]+g_v_table[v]);
b = y1 + b_u_table[u];
result[0] = r<0?0:(r>255?255:r);
result[1] = g<0?0:(g>255?255:g);
result[2] = b<0?0:(b>255?255:b);
result[0] = r>255?255:r;
result[1] = g>255?255:g;
result[2] = b>255?255:b;
r = y2 + r_v_table[v];
g = y2 - (g_u_table[u]+g_v_table[v]);
b = y2 + b_u_table[u];
result[4] = r<0?0:(r>255?255:r);
result[5] = g<0?0:(g>255?255:g);
result[6] = b<0?0:(b>255?255:b);
result[4] = r>255?255:r;
result[5] = g>255?255:g;
result[6] = b>255?255:b;
}
}

View File

@ -83,6 +83,7 @@ LibvlcCamera::LibvlcCamera( int p_id, const std::string &p_path, const std::stri
mTargetChroma = "GREY";
mBpp = 1;
} else {
mBpp = 0;
Panic("Unexpected colours: %d",colours);
}

View File

@ -648,6 +648,9 @@ LocalCamera::LocalCamera(
if ( !imgConversionContext ) {
Fatal( "Unable to initialise image scaling context" );
}
} else {
tmpPicture = NULL;
imgConversionContext = NULL;
} // end if capture and conversion_tye == swscale
#endif
mVideoStreamId = 0;
@ -678,19 +681,19 @@ void LocalCamera::Initialise() {
av_log_set_level( AV_LOG_QUIET );
#endif // HAVE_LIBSWSCALE
struct stat st;
if ( stat( device.c_str(), &st ) < 0 )
Fatal( "Failed to stat video device %s: %s", device.c_str(), strerror(errno) );
if ( !S_ISCHR(st.st_mode) )
Fatal( "File %s is not device file: %s", device.c_str(), strerror(errno) );
Debug( 3, "Opening video device %s", device.c_str() );
//if ( (vid_fd = open( device.c_str(), O_RDWR|O_NONBLOCK, 0 )) < 0 )
if ( (vid_fd = open( device.c_str(), O_RDWR, 0 )) < 0 )
Fatal( "Failed to open video device %s: %s", device.c_str(), strerror(errno) );
struct stat st;
if ( stat( device.c_str(), &st ) < 0 )
Fatal( "Failed to stat video device %s: %s", device.c_str(), strerror(errno) );
if ( !S_ISCHR(st.st_mode) )
Fatal( "File %s is not device file: %s", device.c_str(), strerror(errno) );
#if ZM_HAS_V4L2
Debug( 2, "V4L2 support enabled, using V4L%d api", v4l_version );
if ( v4l_version == 2 ) {
@ -1234,7 +1237,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers
int devIndex = 0;
do {
if ( device )
strcpy( queryDevice, device );
strncpy( queryDevice, device, sizeof(queryDevice)-1 );
else
sprintf( queryDevice, "/dev/video%d", devIndex );
if ( (vid_fd = open(queryDevice, O_RDWR)) <= 0 ) {
@ -1567,7 +1570,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers
}
struct video_picture vid_pic;
memset( &vid_cap, 0, sizeof(video_picture) );
memset( &vid_pic, 0, sizeof(video_picture) );
if ( ioctl( vid_fd, VIDIOCGPICT, &vid_pic ) < 0 ) {
Error( "Failed to get picture attributes: %s", strerror(errno) );
if ( verbose )

View File

@ -100,7 +100,6 @@ private:
Level mEffectiveLevel; // Level optimised to take account of maxima
bool mDbConnected;
MYSQL mDbConnection;
std::string mLogPath;
std::string mLogFile;
FILE *mLogFileFP;

View File

@ -69,7 +69,7 @@ Monitor::MonitorLink::MonitorLink( int p_id, const char *p_name ) :
trigger_data(NULL),
video_store_data(NULL)
{
strncpy( name, p_name, sizeof(name) );
strncpy( name, p_name, sizeof(name)-1 );
#if ZM_MEM_MAPPED
map_fd = -1;
@ -670,9 +670,10 @@ void Monitor::AddZones( int p_n_zones, Zone *p_zones[] ) {
}
void Monitor::AddPrivacyBitmask( Zone *p_zones[] ) {
if ( privacy_bitmask )
if ( privacy_bitmask ) {
delete[] privacy_bitmask;
privacy_bitmask = NULL;
privacy_bitmask = NULL;
}
Image *privacy_image = NULL;
for ( int i = 0; i < n_zones; i++ ) {
@ -812,6 +813,8 @@ double Monitor::GetFPS() const {
Error( "Negative FPS %f, time_diff = %lf (%d:%ld.%ld - %d:%ld.%ld), ibc: %d",
curr_fps, time_diff, index2, time2.tv_sec, time2.tv_usec, index1, time1.tv_sec, time1.tv_usec, image_buffer_count );
return 0.0;
} else {
Debug( 2, "GetFPS %f, time_diff = %lf (%d:%ld.%ld - %d:%ld.%ld), ibc: %d", curr_fps, time_diff, index2, time2.tv_sec, time2.tv_usec, index1, time1.tv_sec, time1.tv_usec, image_buffer_count );
}
return curr_fps;
}
@ -846,8 +849,8 @@ void Monitor::UpdateAdaptiveSkip() {
void Monitor::ForceAlarmOn( int force_score, const char *force_cause, const char *force_text ) {
trigger_data->trigger_state = TRIGGER_ON;
trigger_data->trigger_score = force_score;
strncpy( trigger_data->trigger_cause, force_cause, sizeof(trigger_data->trigger_cause) );
strncpy( trigger_data->trigger_text, force_text, sizeof(trigger_data->trigger_text) );
strncpy( trigger_data->trigger_cause, force_cause, sizeof(trigger_data->trigger_cause)-1 );
strncpy( trigger_data->trigger_text, force_text, sizeof(trigger_data->trigger_text)-1 );
}
void Monitor::ForceAlarmOff() {
@ -1096,8 +1099,8 @@ void Monitor::DumpImage( Image *dump_image ) const {
static char new_filename[PATH_MAX];
snprintf( filename, sizeof(filename), "Monitor%d.jpg", id );
snprintf( new_filename, sizeof(new_filename), "Monitor%d-new.jpg", id );
dump_image->WriteJpeg( new_filename );
rename( new_filename, filename );
if ( dump_image->WriteJpeg( new_filename ) )
rename( new_filename, filename );
}
}
@ -1590,8 +1593,8 @@ void Monitor::Reload() {
function = (Function)atoi(dbrow[index++]);
enabled = atoi(dbrow[index++]);
const char *p_linked_monitors = dbrow[index++];
strncpy( event_prefix, dbrow[index++], sizeof(event_prefix) );
strncpy( label_format, dbrow[index++], sizeof(label_format) );
strncpy( event_prefix, dbrow[index++], sizeof(event_prefix)-1 );
strncpy( label_format, dbrow[index++], sizeof(label_format)-1 );
label_coord = Coord( atoi(dbrow[index]), atoi(dbrow[index+1]) ); index += 2;
label_size = atoi(dbrow[index++]);
warmup_count = atoi(dbrow[index++]);
@ -3209,8 +3212,8 @@ bool Monitor::DumpSettings( char *output, bool verbose ) {
sprintf( output+strlen(output), "Stream Replay Buffer : %d\n", stream_replay_buffer );
sprintf( output+strlen(output), "Alarm Frame Count : %d\n", alarm_frame_count );
sprintf( output+strlen(output), "Section Length : %d\n", section_length );
sprintf( output+strlen(output), "Maximum FPS : %.2f\n", capture_delay?DT_PREC_3/capture_delay:0.0 );
sprintf( output+strlen(output), "Alarm Maximum FPS : %.2f\n", alarm_capture_delay?DT_PREC_3/alarm_capture_delay:0.0 );
sprintf( output+strlen(output), "Maximum FPS : %.2f\n", capture_delay?(double)DT_PREC_3/capture_delay:0.0 );
sprintf( output+strlen(output), "Alarm Maximum FPS : %.2f\n", alarm_capture_delay?(double)DT_PREC_3/alarm_capture_delay:0.0 );
sprintf( output+strlen(output), "Reference Blend %%ge : %d\n", ref_blend_perc );
sprintf( output+strlen(output), "Alarm Reference Blend %%ge : %d\n", alarm_ref_blend_perc );
sprintf( output+strlen(output), "Track Motion : %d\n", track_motion );

View File

@ -42,8 +42,6 @@ class MonitorStream : public StreamBase {
protected:
time_t ttl;
protected:
int playback_buffer;
bool delayed;
@ -60,7 +58,7 @@ class MonitorStream : public StreamBase {
void SingleImageZip( int scale=100 );
public:
MonitorStream() : playback_buffer( 0 ), delayed( false ), frame_count( 0 ) {
MonitorStream() : ttl(0), playback_buffer(0), delayed(false), frame_count(0) {
}
void setStreamBuffer( int p_playback_buffer ) {
playback_buffer = p_playback_buffer;

View File

@ -207,6 +207,7 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
if ( !ost ) {
Fatal( "Could not alloc stream" );
return;
}
ost->id = ofc->nb_streams - 1;
@ -551,6 +552,7 @@ double VideoStream::EncodeFrame( const uint8_t *buffer, int buffer_size, bool _a
buffer_copy = (uint8_t *)av_malloc( buffer_size );
if ( !buffer_copy ) {
Panic( "Could not allocate buffer_copy" );
return 0;
}
buffer_copy_size = buffer_size;
}

View File

@ -49,7 +49,10 @@ RegExpr::RegExpr( const char *pattern, int flags, int p_max_matches ) : max_matc
memset( match_lengths, 0, sizeof(*match_lengths)*max_matches );
match_valid = new bool[max_matches];
memset( match_valid, 0, sizeof(*match_valid)*max_matches );
} else {
match_vectors = NULL;
}
match_string = "";
n_matches = 0;
}

View File

@ -92,10 +92,6 @@ void RemoteCameraNVSocket::Initialise() {
int max_size = width*height*colours;
buffer.size( max_size );
mode = SINGLE_IMAGE;
format = UNDEF;
state = HEADER;
}
int RemoteCameraNVSocket::Connect() {

View File

@ -38,26 +38,22 @@ protected:
//struct sockaddr_in sa;
int sd;
Buffer buffer;
enum { SINGLE_IMAGE, MULTI_IMAGE } mode;
enum { UNDEF, JPEG, X_RGB, X_RGBZ } format;
enum { HEADER, HEADERCONT, SUBHEADER, SUBHEADERCONT, CONTENT } state;
enum { SIMPLE, REGEXP } method;
public:
RemoteCameraNVSocket(
unsigned int p_monitor_id,
const std::string &host,
const std::string &port,
const std::string &path,
int p_width,
int p_height,
int p_colours,
int p_brightness,
int p_contrast,
int p_hue,
int p_colour,
bool p_capture,
bool p_record_audio );
unsigned int p_monitor_id,
const std::string &host,
const std::string &port,
const std::string &path,
int p_width,
int p_height,
int p_colours,
int p_brightness,
int p_contrast,
int p_hue,
int p_colour,
bool p_capture,
bool p_record_audio );
~RemoteCameraNVSocket();
void Initialise();

View File

@ -34,15 +34,15 @@ Storage::Storage() {
// not using an absolute path. Make it one by appending ZM_PATH_WEB
snprintf( path, sizeof (path), "%s/%s", staticConfig.PATH_WEB.c_str( ), staticConfig.DIR_EVENTS.c_str() );
} else {
strncpy(path, staticConfig.DIR_EVENTS.c_str(), sizeof(path) );
strncpy(path, staticConfig.DIR_EVENTS.c_str(), sizeof(path)-1 );
}
}
Storage::Storage( MYSQL_ROW &dbrow ) {
unsigned int index = 0;
id = atoi( dbrow[index++] );
strncpy( name, dbrow[index++], sizeof(name) );
strncpy( path, dbrow[index++], sizeof(path) );
strncpy( name, dbrow[index++], sizeof(name)-1 );
strncpy( path, dbrow[index++], sizeof(path)-1 );
}
/* If a zero or invalid p_id is passed, then the old default path will be assumed. */
@ -69,7 +69,7 @@ Storage::Storage( unsigned int p_id ) {
// not using an absolute path. Make it one by appending ZM_PATH_WEB
snprintf( path, sizeof (path), "%s/%s", staticConfig.PATH_WEB.c_str( ), staticConfig.DIR_EVENTS.c_str() );
} else {
strncpy(path, staticConfig.DIR_EVENTS.c_str(), sizeof(path) );
strncpy(path, staticConfig.DIR_EVENTS.c_str(), sizeof(path)-1 );
}
Debug(1,"No id passed to Storage constructor. Using default path %s instead", path );
strcpy(name, "Default");

View File

@ -271,7 +271,6 @@ void StreamBase::openComms() {
unsigned int length = snprintf( sock_path_lock, sizeof(sock_path_lock), "%s/zms-%06d.lock", staticConfig.PATH_SOCKS.c_str(), connkey);
if ( length >= sizeof(sock_path_lock) ) {
Warning("Socket lock path was truncated.");
length = sizeof(sock_path_lock)-1;
}
Debug( 1, "Trying to open the lock on %s", sock_path_lock );
@ -313,7 +312,7 @@ void StreamBase::openComms() {
}
snprintf( rem_sock_path, sizeof(rem_sock_path), "%s/zms-%06dw.sock", staticConfig.PATH_SOCKS.c_str(), connkey );
strncpy( rem_addr.sun_path, rem_sock_path, sizeof(rem_addr.sun_path) );
strncpy( rem_addr.sun_path, rem_sock_path, sizeof(rem_addr.sun_path)-1 );
rem_addr.sun_family = AF_UNIX;
} // end if connKey > 0
Debug(2, "comms open" );

View File

@ -142,6 +142,7 @@ public:
vid_stream = 0;
#endif // HAVE_LIBAVCODEC
last_frame_sent = 0.0;
last_frame_timestamp = (struct timeval){0};
msg = { 0, { 0 } };
}
virtual ~StreamBase();

View File

@ -166,7 +166,7 @@ private:
mutable Condition mCondition;
public:
__attribute__((used)) ThreadData() : mCondition( mMutex ) {
__attribute__((used)) ThreadData() : mValue(0), mCondition( mMutex ) {
mChanged = false;
}
__attribute__((used)) ThreadData( T value ) : mValue( value ), mCondition( mMutex ) {

View File

@ -37,8 +37,8 @@ User::User() {
User::User( MYSQL_ROW &dbrow ) {
int index = 0;
strncpy( username, dbrow[index++], sizeof(username) );
strncpy( password, dbrow[index++], sizeof(password) );
strncpy( username, dbrow[index++], sizeof(username)-1 );
strncpy( password, dbrow[index++], sizeof(password)-1 );
enabled = (bool)atoi( dbrow[index++] );
stream = (Permission)atoi( dbrow[index++] );
events = (Permission)atoi( dbrow[index++] );

View File

@ -84,10 +84,11 @@ bool VideoStore::open() {
if ( !oc ) {
avformat_alloc_output_context2(&oc, NULL, format, filename);
if ( !oc ) {
Fatal(
Error(
"Could not create video storage stream %s as no out ctx"
" could not be assigned based on filename or format %s",
filename, format);
return;
} else {
Debug(4, "Success alocating out ctx");
}
@ -106,8 +107,12 @@ bool VideoStore::open() {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
video_in_ctx = avcodec_alloc_context3(NULL);
Debug(2, "copy to video_in_context");
avcodec_parameters_to_context(video_in_ctx, video_in_stream->codecpar);
zm_dump_codecpar( video_in_stream->codecpar );
if ( (ret=avcodec_parameters_to_context(video_in_ctx, video_in_stream->codecpar)) < 0 ) {
Error("Couldn't copy params to context");
return false;
} else {
zm_dump_codecpar( video_in_stream->codecpar );
}
#else
video_in_ctx = video_in_stream->codec;
Debug(2,"Copied video context from input stream");
@ -776,7 +781,10 @@ bool VideoStore::setup_resampler() {
AVDictionary *opts = NULL;
av_dict_set(&opts, "strict", "experimental", 0); // Needed to allow AAC
// Needed to allow AAC
if ( (ret = av_dict_set(&opts, "strict", "experimental", 0)) < 0 ) {
Error("Couldn't set experimental");
}
ret = avcodec_open2(audio_out_ctx, audio_out_codec, &opts);
av_dict_free(&opts);
if ( ret < 0 ) {

View File

@ -71,8 +71,6 @@ AVAudioResampleContext* resample_ctx;
int64_t audio_next_pts;
int64_t audio_next_dts;
int64_t filter_in_rescale_delta_last;
bool setup_resampler();
public:

View File

@ -151,7 +151,7 @@ int main( int argc, const char *argv[] ) {
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
{
if ( !strcmp( name, "auth" ) ) {
strncpy( auth, value, sizeof(auth) );
strncpy( auth, value, sizeof(auth)-1 );
}
}
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )

View File

@ -854,10 +854,12 @@ if ( canEdit( 'System' ) ) {
$changed = false;
foreach ( $configCat as $name=>$value ) {
unset( $newValue );
if ( $value['Type'] == 'boolean' && empty($_REQUEST['newConfig'][$name]) )
if ( $value['Type'] == 'boolean' && empty($_REQUEST['newConfig'][$name]) ) {
$newValue = 0;
elseif ( isset($_REQUEST['newConfig'][$name]) )
} else if ( isset($_REQUEST['newConfig'][$name]) ) {
$newValue = preg_replace( "/\r\n/", "\n", stripslashes( $_REQUEST['newConfig'][$name] ) );
}
if ( isset($newValue) && ($newValue != $value['Value']) ) {
dbQuery( 'UPDATE Config SET Value=? WHERE Name=?', array( $newValue, $name ) );
$changed = true;

View File

@ -23,18 +23,25 @@ if ( !canView('Events') ) {
return;
}
$total_size = 0;
if (isset($_SESSION['montageReviewFilter'])) { //Handles montageReview filter
$eventsSql = 'SELECT E.Id FROM Events as E WHERE 1';
$eventsSql = 'SELECT E.Id,E.DiskSpace FROM Events as E WHERE 1';
$eventsSql .= $_SESSION['montageReviewFilter']['sql'];
$results = dbQuery($eventsSql);
$eids = [];
while ( $event_row = dbFetchNext( $results ) ) {
array_push($eids, 'eids[]='.$event_row['Id']);
$total_size += $event_row['DiskSpace'];
}
$_REQUEST['eids'] = $eids;
session_start();
unset($_SESSION['montageReviewFilter']);
session_write_close();
if ( ! count($eids) ) {
Error("No events found for download using $eventsSql");
}
#session_start();
#unset($_SESSION['montageReviewFilter']);
#session_write_close();
#} else {
#Logger::Debug("NO montageReviewFilter");
}
$focusWindow = true;
@ -55,7 +62,9 @@ xhtmlHeaders(__FILE__, translate('Download') );
if ( !empty($_REQUEST['eid']) ) {
?>
<input type="hidden" name="id" value="<?php echo validInt($_REQUEST['eid']) ?>"/>
<?php
<?php
$Event = new Event( $_REQUEST['eid'] );
echo 'Downloading event ' . $_REQUEST['eid'] . ' Resulting file should be approximately ' . human_filesize( $Event->DiskSpace() );
} else if ( !empty($_REQUEST['eids']) ) {
foreach ( $_REQUEST['eids'] as $eid ) {
?>
@ -63,6 +72,9 @@ if ( !empty($_REQUEST['eid']) ) {
<?php
}
unset( $eid );
echo "Downloading " . count($_REQUEST['eids']) . ' events. Resulting file should be approximately ' . human_filesize($total_size);
} else {
echo '<div class="warning">There are no events found. Resulting download will be empty.</div>';
}
?>
<table id="contentTable" class="minor" cellspacing="0">

View File

@ -83,6 +83,7 @@ if (isset($_REQUEST['minTime']) && isset($_REQUEST['maxTime']) && count($display
}
}
parseFilter( $filter );
# This is to enable the download button
session_start();
$_SESSION['montageReviewFilter'] = $filter;
session_write_close();

View File

@ -124,7 +124,7 @@ foreach( array_map( 'basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
</div>
</div>
<div id="contentButtons">
<input type="submit" class="btn btn-primary btn-lg" value="<?php echo translate('Save') ?>"<?php echo $canEdit?'':' disabled="disabled"' ?>/>
<button value="Save" type="submit"<?php echo $canEdit?'':' disabled="disabled"' ?>><?php echo translate('Save') ?></button>
</div>
</form>
@ -189,8 +189,8 @@ foreach( array_map( 'basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
</tbody>
</table>
<div id="contentButtons">
<button value="Add New User" onclick="createPopup('?view=user&amp;uid=0', 'zmUser', 'user');"<?php if ( !canEdit( 'System' ) ) { ?> disabled="disabled"<?php } ?>><?php echo translate('AddNewUser') ?></button>
<button class="btn-danger" name="deleteBtn" value="Delete" disabled="disabled"><?php echo translate('Delete') ?></button>
<button type="button" value="Add New User" onclick="createPopup('?view=user&amp;uid=0', 'zmUser', 'user');"<?php if ( !canEdit( 'System' ) ) { ?> disabled="disabled"<?php } ?>><?php echo translate('AddNewUser') ?></button>
<button type="submit" class="btn-danger" name="deleteBtn" value="Delete" disabled="disabled"><?php echo translate('Delete') ?></button>
</div>
</form>
<?php
@ -230,8 +230,8 @@ foreach( array_map( 'basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
</tbody>
</table>
<div id="contentButtons">
<button value="Add New Server" onclick="createPopup('?view=server&amp;id=0','zmServer','server');"<?php if ( !canEdit( 'System' ) ) { ?> disabled="disabled"<?php } ?>><?php echo translate('AddNewServer') ?></button>
<button class="btn-danger" name="deleteBtn" value="Delete" disabled="disabled"><?php echo translate('Delete') ?></button>
<button type="button" value="Add New Server" onclick="createPopup('?view=server&amp;id=0','zmServer','server');"<?php if ( !canEdit( 'System' ) ) { ?> disabled="disabled"<?php } ?>><?php echo translate('AddNewServer') ?></button>
<button type="submit" class="btn-danger" name="deleteBtn" value="Delete" disabled="disabled"><?php echo translate('Delete') ?></button>
</div>
</form>
<?php
@ -264,8 +264,8 @@ foreach( array_map( 'basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
</tbody>
</table>
<div id="contentButtons">
<button value="Add New Storage" onclick="createPopup('?view=storage&amp;id=0','zmStorage','storage');"<?php if ( !canEdit( 'System' ) ) { ?> disabled="disabled"<?php } ?>><?php echo translate('AddNewStorage') ?></button>
<button class="btn-danger" name="deleteBtn" value="Delete" disabled="disabled"><?php echo translate('Delete') ?></button>
<button type="button" value="Add New Storage" onclick="createPopup('?view=storage&amp;id=0','zmStorage','storage');"<?php if ( !canEdit( 'System' ) ) { ?> disabled="disabled"<?php } ?>><?php echo translate('AddNewStorage') ?></button>
<button type="submit" class="btn-danger" name="deleteBtn" value="Delete" disabled="disabled"><?php echo translate('Delete') ?></button>
</div>
</form>
<?php
@ -367,7 +367,7 @@ foreach( array_map( 'basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
}
?>
<div id="contentButtons">
<button value="Save" <?php echo $canEdit?'':' disabled="disabled"' ?>><?php echo translate('Save') ?></button>
<button type="submit" value="Save"<?php echo $canEdit?'':' disabled="disabled"' ?>><?php echo translate('Save') ?></button>
</div>
</form>
<?php