fix mving capture_file_format to staticCOnfig
This commit is contained in:
parent
b11a514823
commit
666233af54
|
@ -94,6 +94,11 @@ void zmLoadConfig() {
|
|||
Debug( 3, "Single server configuration assumed because no Server ID or Name was specified." );
|
||||
}
|
||||
}
|
||||
|
||||
snprintf( staticConfig.capture_file_format, sizeof(staticConfig.capture_file_format), "%%s/%%0%dd-capture.jpg", config.event_image_digits );
|
||||
snprintf( staticConfig.analyse_file_format, sizeof(staticConfig.analyse_file_format), "%%s/%%0%dd-analyse.jpg", config.event_image_digits );
|
||||
snprintf( staticConfig.general_file_format, sizeof(staticConfig.general_file_format), "%%s/%%0%dd-%%s", config.event_image_digits );
|
||||
snprintf( staticConfig.video_file_format, sizeof(staticConfig.video_file_format), "%%s/%%s");
|
||||
}
|
||||
|
||||
void process_configfile( char* configFile) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "zm_config_defines.h"
|
||||
#include "zm.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -61,8 +62,7 @@ extern void zmLoadConfig();
|
|||
|
||||
extern void process_configfile( char* configFile );
|
||||
|
||||
struct StaticConfig
|
||||
{
|
||||
struct StaticConfig {
|
||||
std::string DB_HOST;
|
||||
std::string DB_NAME;
|
||||
std::string DB_USER;
|
||||
|
@ -83,20 +83,22 @@ struct StaticConfig
|
|||
std::string PATH_LOGS;
|
||||
std::string PATH_SWAP;
|
||||
std::string PATH_ARP;
|
||||
char capture_file_format[PATH_MAX];
|
||||
char analyse_file_format[PATH_MAX];
|
||||
char general_file_format[PATH_MAX];
|
||||
char video_file_format[PATH_MAX];
|
||||
};
|
||||
|
||||
extern StaticConfig staticConfig;
|
||||
|
||||
class ConfigItem
|
||||
{
|
||||
class ConfigItem {
|
||||
private:
|
||||
char *name;
|
||||
char *value;
|
||||
char *type;
|
||||
|
||||
mutable enum { CFG_BOOLEAN, CFG_INTEGER, CFG_DECIMAL, CFG_STRING } cfg_type;
|
||||
mutable union
|
||||
{
|
||||
mutable union {
|
||||
bool boolean_value;
|
||||
int integer_value;
|
||||
double decimal_value;
|
||||
|
@ -113,26 +115,21 @@ public:
|
|||
double DecimalValue() const;
|
||||
const char *StringValue() const;
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
inline operator bool() const {
|
||||
return( BooleanValue() );
|
||||
}
|
||||
inline operator int() const
|
||||
{
|
||||
inline operator int() const {
|
||||
return( IntegerValue() );
|
||||
}
|
||||
inline operator double() const
|
||||
{
|
||||
inline operator double() const {
|
||||
return( DecimalValue() );
|
||||
}
|
||||
inline operator const char *() const
|
||||
{
|
||||
inline operator const char *() const {
|
||||
return( StringValue() );
|
||||
}
|
||||
};
|
||||
|
||||
class Config
|
||||
{
|
||||
class Config {
|
||||
public:
|
||||
ZM_CFG_DECLARE_LIST
|
||||
|
||||
|
|
|
@ -37,11 +37,6 @@
|
|||
|
||||
//#define USE_PREPARED_SQL 1
|
||||
|
||||
bool Event::initialised = false;
|
||||
char Event::capture_file_format[PATH_MAX];
|
||||
char Event::analyse_file_format[PATH_MAX];
|
||||
char Event::general_file_format[PATH_MAX];
|
||||
char Event::video_file_format[PATH_MAX];
|
||||
const char * Event::frame_type_names[3] = { "Normal", "Bulk", "Alarm" };
|
||||
|
||||
int Event::pre_alarm_count = 0;
|
||||
|
@ -56,8 +51,6 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
|||
videoEvent( p_videoEvent ),
|
||||
videowriter( NULL )
|
||||
{
|
||||
if ( !initialised )
|
||||
Initialise();
|
||||
|
||||
std::string notes;
|
||||
createNotes( notes );
|
||||
|
@ -173,7 +166,7 @@ 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( video_file, sizeof(video_file), staticConfig.video_file_format, path, video_name );
|
||||
Debug(1,"Writing video file to %s", video_file );
|
||||
|
||||
/* X264 MP4 video writer */
|
||||
|
@ -195,7 +188,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
|||
}
|
||||
|
||||
snprintf( timecodes_name, sizeof(timecodes_name), "%d-%s", id, "video.timecodes" );
|
||||
snprintf( timecodes_file, sizeof(timecodes_file), video_file_format, path, timecodes_name );
|
||||
snprintf( timecodes_file, sizeof(timecodes_file), staticConfig.video_file_format, path, timecodes_name );
|
||||
|
||||
/* Create timecodes file */
|
||||
timecodes_fd = fopen(timecodes_file, "wb");
|
||||
|
@ -434,7 +427,7 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st
|
|||
frames++;
|
||||
|
||||
static char event_file[PATH_MAX];
|
||||
snprintf( event_file, sizeof(event_file), capture_file_format, path, frames );
|
||||
snprintf( event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames );
|
||||
if ( monitor->GetOptSaveJPEGs() & 4 ) {
|
||||
//If this is the first frame, we should add a thumbnail to the event directory
|
||||
// ICON: We are working through the pre-event frames so this snapshot won't
|
||||
|
@ -485,9 +478,10 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
|||
frames++;
|
||||
|
||||
static char event_file[PATH_MAX];
|
||||
snprintf( event_file, sizeof(event_file), capture_file_format, path, frames );
|
||||
snprintf( event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames );
|
||||
|
||||
if ( monitor->GetOptSaveJPEGs() & 4 ) {
|
||||
// Only snapshots
|
||||
//If this is the first frame, we should add a thumbnail to the event directory
|
||||
if ( frames == 10 ) {
|
||||
char snapshot_file[PATH_MAX];
|
||||
|
@ -510,6 +504,7 @@ Debug(3, "Writing video");
|
|||
DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 );
|
||||
|
||||
FrameType frame_type = score>0?ALARM:(score<0?BULK:NORMAL);
|
||||
// < 0 means no motion detection is being done.
|
||||
if ( score < 0 )
|
||||
score = 0;
|
||||
|
||||
|
@ -555,7 +550,7 @@ Debug(3, "Writing video");
|
|||
max_score = score;
|
||||
|
||||
if ( alarm_image ) {
|
||||
snprintf( event_file, sizeof(event_file), analyse_file_format, path, frames );
|
||||
snprintf( event_file, sizeof(event_file), staticConfig.analyse_file_format, path, frames );
|
||||
|
||||
Debug( 1, "Writing analysis frame %d", frames );
|
||||
if ( monitor->GetOptSaveJPEGs() & 2 ) {
|
||||
|
|
|
@ -51,13 +51,6 @@ class EventStream;
|
|||
class Event {
|
||||
friend class EventStream;
|
||||
|
||||
protected:
|
||||
static bool initialised;
|
||||
static char capture_file_format[PATH_MAX];
|
||||
static char analyse_file_format[PATH_MAX];
|
||||
static char general_file_format[PATH_MAX];
|
||||
static char video_file_format[PATH_MAX];
|
||||
|
||||
protected:
|
||||
static int sd;
|
||||
|
||||
|
@ -79,7 +72,6 @@ class Event {
|
|||
static int pre_alarm_count;
|
||||
static PreAlarmData pre_alarm_data[MAX_PRE_ALARM_FRAMES];
|
||||
|
||||
protected:
|
||||
unsigned int id;
|
||||
Monitor *monitor;
|
||||
struct timeval start_time;
|
||||
|
@ -98,30 +90,14 @@ class Event {
|
|||
char video_file[PATH_MAX];
|
||||
char timecodes_name[PATH_MAX];
|
||||
char timecodes_file[PATH_MAX];
|
||||
|
||||
protected:
|
||||
int last_db_frame;
|
||||
|
||||
protected:
|
||||
static void Initialise() {
|
||||
if ( initialised )
|
||||
return;
|
||||
|
||||
snprintf( capture_file_format, sizeof(capture_file_format), "%%s/%%0%dd-capture.jpg", config.event_image_digits );
|
||||
snprintf( analyse_file_format, sizeof(analyse_file_format), "%%s/%%0%dd-analyse.jpg", config.event_image_digits );
|
||||
snprintf( general_file_format, sizeof(general_file_format), "%%s/%%0%dd-%%s", config.event_image_digits );
|
||||
snprintf( video_file_format, sizeof(video_file_format), "%%s/%%s");
|
||||
|
||||
initialised = true;
|
||||
}
|
||||
|
||||
void createNotes( std::string ¬es );
|
||||
|
||||
public:
|
||||
static bool OpenFrameSocket( int );
|
||||
static bool ValidateFrameSocket( int );
|
||||
|
||||
public:
|
||||
Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap, bool p_videoEvent=false );
|
||||
~Event();
|
||||
|
||||
|
|
|
@ -577,11 +577,10 @@ void EventStream::checkEventLoaded() {
|
|||
}
|
||||
|
||||
Image * EventStream::getImage( ) {
|
||||
Event::Initialise();
|
||||
static char filepath[PATH_MAX];
|
||||
|
||||
Debug( 2, "EventStream::getImage path(%s) frame(%d)", event_data->path, curr_frame_id );
|
||||
snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id );
|
||||
snprintf( filepath, sizeof(filepath), staticConfig.capture_file_format, event_data->path, curr_frame_id );
|
||||
Debug( 2, "EventStream::getImage path(%s) ", filepath, curr_frame_id );
|
||||
Image *image = new Image( filepath );
|
||||
return image;
|
||||
|
@ -596,12 +595,12 @@ bool EventStream::sendFrame( int delta_us ) {
|
|||
|
||||
// This needs to be abstracted. If we are saving jpgs, then load the capture file. If we are only saving analysis frames, then send that.
|
||||
if ( monitor->GetOptSaveJPEGs() & 1 ) {
|
||||
snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id );
|
||||
snprintf( filepath, sizeof(filepath), staticConfig.capture_file_format, event_data->path, curr_frame_id );
|
||||
} else if ( monitor->GetOptSaveJPEGs() & 2 ) {
|
||||
snprintf( filepath, sizeof(filepath), Event::analyse_file_format, event_data->path, curr_frame_id );
|
||||
snprintf( filepath, sizeof(filepath), staticConfig.analyse_file_format, event_data->path, curr_frame_id );
|
||||
if ( stat( filepath, &filestat ) < 0 ) {
|
||||
Debug(1, "analyze file %s not found will try to stream from other", filepath);
|
||||
snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id );
|
||||
snprintf( filepath, sizeof(filepath), staticConfig.capture_file_format, event_data->path, curr_frame_id );
|
||||
filepath[0] = 0;
|
||||
}
|
||||
|
||||
|
@ -752,9 +751,6 @@ bool EventStream::sendFrame( int delta_us ) {
|
|||
}
|
||||
|
||||
void EventStream::runStream() {
|
||||
Event::Initialise();
|
||||
Debug(3, "Initialized");
|
||||
|
||||
openComms();
|
||||
Debug(3, "Comms open");
|
||||
|
||||
|
|
Loading…
Reference in New Issue