2005-12-16 18:16:29 +08:00
|
|
|
//
|
|
|
|
// ZoneMinder Configuration, $Date$, $Revision$
|
2008-07-25 17:33:23 +08:00
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
2020-08-26 03:52:49 +08:00
|
|
|
//
|
2005-12-16 18:16:29 +08:00
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
2020-08-26 03:52:49 +08:00
|
|
|
//
|
2005-12-16 18:16:29 +08:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2020-08-26 03:52:49 +08:00
|
|
|
//
|
2005-12-16 18:16:29 +08:00
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2016-12-26 23:23:16 +08:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2020-08-26 03:52:49 +08:00
|
|
|
//
|
2005-12-16 18:16:29 +08:00
|
|
|
|
2011-06-21 17:19:10 +08:00
|
|
|
#ifndef ZM_CONFIG_H
|
|
|
|
#define ZM_CONFIG_H
|
|
|
|
|
2018-11-24 01:44:34 +08:00
|
|
|
#if !defined(PATH_MAX)
|
|
|
|
#define PATH_MAX 1024
|
|
|
|
#endif
|
2020-08-26 03:52:49 +08:00
|
|
|
|
2005-12-16 18:16:29 +08:00
|
|
|
#include "config.h"
|
|
|
|
#include "zm_config_defines.h"
|
2020-08-26 03:52:49 +08:00
|
|
|
#include "zm_config_data.h"
|
2005-12-16 18:16:29 +08:00
|
|
|
|
2008-07-25 01:08:50 +08:00
|
|
|
#include <string>
|
|
|
|
|
2011-02-16 05:59:06 +08:00
|
|
|
#ifdef HAVE_LIBAVFORMAT
|
2016-04-04 22:11:48 +08:00
|
|
|
#define ZM_HAS_FFMPEG 1
|
2011-02-16 05:59:06 +08:00
|
|
|
#endif // HAVE_LIBAVFORMAT
|
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
#define ZM_MAX_IMAGE_WIDTH 2048 // The largest image we imagine ever handling
|
|
|
|
#define ZM_MAX_IMAGE_HEIGHT 1536 // The largest image we imagine ever handling
|
|
|
|
#define ZM_MAX_IMAGE_COLOURS 4 // The largest image we imagine ever handling
|
|
|
|
#define ZM_MAX_IMAGE_DIM (ZM_MAX_IMAGE_WIDTH*ZM_MAX_IMAGE_HEIGHT)
|
|
|
|
#define ZM_MAX_IMAGE_SIZE (ZM_MAX_IMAGE_DIM*ZM_MAX_IMAGE_COLOURS)
|
2005-12-16 18:16:29 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
#define ZM_SCALE_BASE 100 // The factor by which we bump up 'scale' to simulate FP
|
|
|
|
#define ZM_RATE_BASE 100 // The factor by which we bump up 'rate' to simulate FP
|
2005-12-16 18:16:29 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
#define ZM_SQL_BATCH_SIZE 50 // Limit the size of multi-row SQL statements
|
|
|
|
#define ZM_SQL_SML_BUFSIZ 256 // Size of SQL buffer
|
|
|
|
#define ZM_SQL_MED_BUFSIZ 1024 // Size of SQL buffer
|
|
|
|
#define ZM_SQL_LGE_BUFSIZ 8192 // Size of SQL buffer
|
2010-11-11 20:22:35 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
#define ZM_NETWORK_BUFSIZ 32768 // Size of network buffer
|
2010-11-11 20:22:35 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
#define ZM_MAX_FPS 30 // The maximum frame rate we expect to handle
|
|
|
|
#define ZM_SAMPLE_RATE int(1000000/ZM_MAX_FPS) // A general nyquist sample frequency for delays etc
|
|
|
|
#define ZM_SUSPENDED_RATE int(1000000/4) // A slower rate for when disabled etc
|
2005-12-16 18:16:29 +08:00
|
|
|
|
|
|
|
extern void zmLoadConfig();
|
|
|
|
|
2020-08-26 02:51:42 +08:00
|
|
|
extern void process_configfile(char const *configFile);
|
2017-06-06 04:39:19 +08:00
|
|
|
|
2017-10-19 08:46:26 +08:00
|
|
|
struct StaticConfig {
|
2016-04-04 22:11:48 +08:00
|
|
|
std::string DB_HOST;
|
|
|
|
std::string DB_NAME;
|
|
|
|
std::string DB_USER;
|
|
|
|
std::string DB_PASS;
|
2017-08-14 22:30:42 +08:00
|
|
|
std::string DB_SSL_CA_CERT;
|
|
|
|
std::string DB_SSL_CLIENT_KEY;
|
|
|
|
std::string DB_SSL_CLIENT_CERT;
|
2016-04-04 22:11:48 +08:00
|
|
|
std::string PATH_WEB;
|
|
|
|
std::string SERVER_NAME;
|
|
|
|
unsigned int SERVER_ID;
|
2017-06-13 09:39:37 +08:00
|
|
|
std::string DIR_EVENTS;
|
|
|
|
std::string DIR_SOUNDS;
|
|
|
|
std::string DIR_EXPORTS;
|
|
|
|
std::string PATH_ZMS;
|
|
|
|
std::string PATH_MAP;
|
|
|
|
std::string PATH_SOCKS;
|
|
|
|
std::string PATH_LOGS;
|
|
|
|
std::string PATH_SWAP;
|
|
|
|
std::string PATH_ARP;
|
2017-10-19 08:46:26 +08:00
|
|
|
char capture_file_format[PATH_MAX];
|
|
|
|
char analyse_file_format[PATH_MAX];
|
|
|
|
char general_file_format[PATH_MAX];
|
|
|
|
char video_file_format[PATH_MAX];
|
2008-07-25 01:08:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern StaticConfig staticConfig;
|
|
|
|
|
2017-10-19 08:46:26 +08:00
|
|
|
class ConfigItem {
|
2005-12-16 18:16:29 +08:00
|
|
|
private:
|
2016-04-04 22:11:48 +08:00
|
|
|
char *name;
|
|
|
|
char *value;
|
|
|
|
char *type;
|
|
|
|
|
2017-12-13 01:35:28 +08:00
|
|
|
mutable enum { CFG_UNKNOWN, CFG_BOOLEAN, CFG_INTEGER, CFG_DECIMAL, CFG_STRING } cfg_type;
|
2017-10-19 08:46:26 +08:00
|
|
|
mutable union {
|
2016-04-04 22:11:48 +08:00
|
|
|
bool boolean_value;
|
|
|
|
int integer_value;
|
|
|
|
double decimal_value;
|
|
|
|
char *string_value;
|
|
|
|
} cfg_value;
|
|
|
|
mutable bool accessed;
|
2005-12-16 18:16:29 +08:00
|
|
|
|
|
|
|
public:
|
2017-11-13 02:16:18 +08:00
|
|
|
ConfigItem(const char *p_name, const char *p_value, const char *const p_type);
|
|
|
|
ConfigItem(const ConfigItem &);
|
2016-04-04 22:11:48 +08:00
|
|
|
~ConfigItem();
|
2017-11-18 22:45:54 +08:00
|
|
|
void Copy(const ConfigItem&);
|
2016-04-04 22:11:48 +08:00
|
|
|
void ConvertValue() const;
|
|
|
|
bool BooleanValue() const;
|
|
|
|
int IntegerValue() const;
|
|
|
|
double DecimalValue() const;
|
|
|
|
const char *StringValue() const;
|
|
|
|
|
2020-11-02 05:11:19 +08:00
|
|
|
ConfigItem &operator=(const ConfigItem &item) {
|
|
|
|
Copy(item);
|
|
|
|
return *this;
|
2017-11-19 05:00:10 +08:00
|
|
|
}
|
2017-10-19 08:46:26 +08:00
|
|
|
inline operator bool() const {
|
2017-11-13 02:16:18 +08:00
|
|
|
return BooleanValue();
|
2016-04-04 22:11:48 +08:00
|
|
|
}
|
2017-10-19 08:46:26 +08:00
|
|
|
inline operator int() const {
|
2017-11-13 02:16:18 +08:00
|
|
|
return IntegerValue();
|
2016-04-04 22:11:48 +08:00
|
|
|
}
|
2017-10-19 08:46:26 +08:00
|
|
|
inline operator double() const {
|
2017-11-13 02:16:18 +08:00
|
|
|
return DecimalValue();
|
2016-04-04 22:11:48 +08:00
|
|
|
}
|
2017-10-19 08:46:26 +08:00
|
|
|
inline operator const char *() const {
|
2017-11-13 02:16:18 +08:00
|
|
|
return StringValue();
|
2016-04-04 22:11:48 +08:00
|
|
|
}
|
2005-12-16 18:16:29 +08:00
|
|
|
};
|
|
|
|
|
2017-10-19 08:46:26 +08:00
|
|
|
class Config {
|
2005-12-16 18:16:29 +08:00
|
|
|
public:
|
2016-04-04 22:11:48 +08:00
|
|
|
ZM_CFG_DECLARE_LIST
|
2005-12-16 18:16:29 +08:00
|
|
|
|
|
|
|
private:
|
2016-04-04 22:11:48 +08:00
|
|
|
int n_items;
|
|
|
|
ConfigItem **items;
|
2005-12-16 18:16:29 +08:00
|
|
|
|
|
|
|
public:
|
2016-04-04 22:11:48 +08:00
|
|
|
Config();
|
|
|
|
~Config();
|
2005-12-16 18:16:29 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
void Load();
|
|
|
|
void Assign();
|
|
|
|
const ConfigItem &Item( int id );
|
2005-12-16 18:16:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Config config;
|
2011-06-21 17:19:10 +08:00
|
|
|
|
|
|
|
#endif // ZM_CONFIG_H
|