📄 conf.c
字号:
/* ** ** conf.c ** ** I originally wrote conf.c as part of the drpoxy package ** thanks to Matthew Pratt and others for their additions. ** ** Copyright 1999 Jeroen Vreeken (pe1rxq@chello.nl) ** ** This software is licensed under the terms of the GNU General ** Public License (GPL). Please see the file COPYING for details. ** ***//** * How to add a config option : * * 1. think twice, there are settings enough * * 2. add a field to 'struct config' (conf.h) and 'struct config conf' * * 4. add a entry to the config_params array below, if your * option should be configurable by the config file. */#include "motion.h"#if (defined(BSD))#include "video_freebsd.h"#else#include "video.h"#endif /* BSD */#define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0; }struct config conf_template = { width: DEF_WIDTH, height: DEF_HEIGHT, quality: DEF_QUALITY, rotate_deg: 0, max_changes: DEF_CHANGES, threshold_tune: 0, output_normal: "on", motion_img: 0, output_all: 0, gap: DEF_GAP, maxmpegtime: DEF_MAXMPEGTIME, snapshot_interval: 0, locate: "off", input: IN_DEFAULT, norm: 0, frame_limit: DEF_MAXFRAMERATE, quiet: 1, ppm: 0, noise: DEF_NOISELEVEL, noise_tune: 1, minimum_frame_time: 0, lightswitch: 0, nightcomp: 0, low_cpu: 0, nochild: 0, autobright: 0, brightness: 0, contrast: 0, saturation: 0, hue: 0, roundrobin_frames: 1, roundrobin_skip: 1, pre_capture: 0, post_capture: 0, switchfilter: 0, ffmpeg_cap_new: 0, ffmpeg_cap_motion: 0, ffmpeg_bps: DEF_FFMPEG_BPS, ffmpeg_vbr: DEF_FFMPEG_VBR, ffmpeg_video_codec: DEF_FFMPEG_CODEC, webcam_port: 0, webcam_quality: 50, webcam_motion: 0, webcam_maxrate: 1, webcam_localhost: 1, webcam_limit: 0, control_port: 0, control_localhost: 1, control_html_output: 1, control_authentication:NULL, frequency: 0, tuner_number: 0, timelapse: 0, timelapse_mode: DEF_TIMELAPSE_MODE,#if (defined(BSD)) tuner_device: NULL,#endif video_device: VIDEO_DEVICE, vidpipe: NULL, filepath: NULL, jpegpath: DEF_JPEGPATH, mpegpath: DEF_MPEGPATH, snappath: DEF_SNAPPATH, timepath: DEF_TIMEPATH, on_event_start: NULL, on_event_end: NULL, mask_file: NULL, smart_mask_speed: 0, sql_log_image: 1, sql_log_snapshot: 1, sql_log_mpeg: 0, sql_log_timelapse: 0, sql_query: DEF_SQL_QUERY, mysql_db: NULL, mysql_host: NULL, mysql_user: NULL, mysql_password: NULL, on_picture_save: NULL, on_motion_detected: NULL, on_movie_start: NULL, on_movie_end: NULL, motionvidpipe: NULL, netcam_url: NULL, netcam_userpass: NULL, netcam_proxy: NULL, pgsql_db: NULL, pgsql_host: NULL, pgsql_user: NULL, pgsql_password: NULL, pgsql_port: 5432, text_changes: 0, text_left: NULL, text_right: DEF_TIMESTAMP, text_event: DEF_EVENTSTAMP, text_double: 0, despeckle: NULL, minimum_motion_frames: 1, pid_file: NULL, // debug_parameter: 0};static struct context **copy_bool(struct context **, const char *, int);static struct context **copy_int(struct context **, const char *, int);static struct context **config_thread(struct context **cnt, const char *str, int val);static const char *print_bool(struct context **, char **, int, int);static const char *print_int(struct context **, char **, int, int);static const char *print_string(struct context **, char **, int, int);static const char *print_thread(struct context **, char **, int, int);static void usage(void);/* Pointer magic to determine relative addresses of variables to a struct context pointer */#define CNT_OFFSET(varname) ( (int)&((struct context *)NULL)->varname )#define CONF_OFFSET(varname) ( (int)&((struct context *)NULL)->conf.varname ) #define TRACK_OFFSET(varname) ( (int)&((struct context *)NULL)->track.varname ) config_param config_params[] = { { "daemon", "############################################################\n" "# Daemon\n" "############################################################\n\n" "# Start in daemon (background) mode and release terminal (default: off)", CNT_OFFSET(daemon), copy_bool, print_bool }, { "process_id_file", "#File to store the process ID, also called pid file. (default: not defined)", CONF_OFFSET(pid_file), copy_string, print_string }, { "setup_mode", "############################################################\n" "# Basic Setup Mode\n" "############################################################\n\n" "# Start in Setup-Mode, daemon disabled. (default: off)", CONF_OFFSET(setup_mode), copy_bool, print_bool }, { "videodevice", "\n###########################################################\n" "# Capture device options\n" "############################################################\n\n" "# Videodevice to be used for capturing (default /dev/video0)\n" "# for FreeBSD default is /dev/bktr0", CONF_OFFSET(video_device), copy_string, print_string },#if (defined(BSD)) { "tunerdevice", "# Tuner device to be used for capturing using tuner as source (default /dev/tuner0)\n" "# This is ONLY used for FreeBSD. Leave it commented out for Linux", CONF_OFFSET(tuner_device), copy_string, print_string },#endif { "input", "# The video input to be used (default: 8)\n" "# Should normally be set to 1 for video/TV cards, and 8 for USB cameras", CONF_OFFSET(input), copy_int, print_int }, { "norm", "# The video norm to use (only for video capture and TV tuner cards)\n" "# Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)", CONF_OFFSET(norm), copy_int, print_int }, { "frequency", "# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0)", CONF_OFFSET(frequency), copy_int, print_int }, { "rotate", "# Rotate image this number of degrees. The rotation affects all saved images as\n" "# well as mpeg movies. Valid values: 0 (default = no rotation), 90, 180 and 270.", CONF_OFFSET(rotate_deg), copy_int, print_int }, { "width", "# Image width (pixels). Valid range: Camera dependent, default: 352", CONF_OFFSET(width), copy_int, print_int }, { "height", "# Image height (pixels). Valid range: Camera dependent, default: 288", CONF_OFFSET(height), copy_int, print_int }, { "framerate", "# Maximum number of frames to be captured per second.\n" "# Valid range: 2-100. Default: 100 (almost no limit).", CONF_OFFSET(frame_limit), copy_int, print_int }, { "minimum_frame_time", "# Minimum time in seconds between capturing picture frames from the camera.\n" "# Default: 0 = disabled - the capture rate is given by the camera framerate.\n" "# This option is used when you want to capture images at a rate lower than 2 per second.", CONF_OFFSET(minimum_frame_time), copy_int, print_int }, { "netcam_url", "# URL to use if you are using a network camera, size will be autodetected (incl http://)\n" "# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined", CONF_OFFSET(netcam_url), copy_string, print_string }, { "netcam_userpass", "# Username and password for network camera (only if required). Default: not defined\n" "# Syntax is user:password", CONF_OFFSET(netcam_userpass), copy_string, print_string }, { "netcam_proxy", "# URL to use for a netcam proxy server, if required, e.g. \"http://myproxy\".\n" "# If a port number other than 80 is needed, use \"http://myproxy:1234\".\n" "# Default: not defined", CONF_OFFSET(netcam_proxy), copy_string, print_string }, { "auto_brightness", "# Let motion regulate the brightness of a video device (default: off).\n" "# The auto_brightness feature uses the brightness option as its target value.\n" "# If brightness is zero auto_brightness will adjust to average brightness value 128.\n" "# Only recommended for cameras without auto brightness", CONF_OFFSET(autobright), copy_bool, print_bool }, { "brightness", "# Set the initial brightness of a video device.\n" "# If auto_brightness is enabled, this value defines the average brightness level\n" "# which Motion will try and adjust to.\n" "# Valid range 0-255, default 0 = disabled", CONF_OFFSET(brightness), copy_int, print_int }, { "contrast", "# Set the contrast of a video device.\n" "# Valid range 0-255, default 0 = disabled", CONF_OFFSET(contrast), copy_int, print_int }, { "saturation", "# Set the saturation of a video device.\n" "# Valid range 0-255, default 0 = disabled", CONF_OFFSET(saturation), copy_int, print_int }, { "hue", "# Set the hue of a video device (NTSC feature).\n" "# Valid range 0-255, default 0 = disabled", CONF_OFFSET(hue), copy_int, print_int }, { "roundrobin_frames", "\n############################################################\n" "# Round Robin (multiple inputs on same video device name)\n" "############################################################\n\n" "# Number of frames to capture in each roundrobin step (default: 1)", CONF_OFFSET(roundrobin_frames), copy_int, print_int }, { "roundrobin_skip", "# Number of frames to skip before each roundrobin step (default: 1)", CONF_OFFSET(roundrobin_skip), copy_int, print_int }, { "switchfilter", "# Try to filter out noise generated by roundrobin (default: off)", CONF_OFFSET(switchfilter), copy_bool, print_bool }, { "threshold", "\n############################################################\n" "# Motion Detection Settings:\n" "############################################################\n\n" "# Threshold for number of changed pixels in an image that\n" "# triggers motion detection (default: 1500)", CONF_OFFSET(max_changes), copy_int, print_int }, { "threshold_tune", "# Automatically tune the threshold down if possible (default: off)", CONF_OFFSET(threshold_tune), copy_bool, print_bool }, { "noise_level", "# Noise threshold for the motion detection (default: 32)", CONF_OFFSET(noise), copy_int, print_int }, { "noise_tune", "# Automatically tune the noise threshold (default: on)", CONF_OFFSET(noise_tune), copy_bool, print_bool }, { "night_compensate", "# Enables motion to adjust its detection/noise level for very dark frames\n" "# Don't use this with noise_tune on. (default: off)", CONF_OFFSET(nightcomp), copy_bool, print_bool }, { "despeckle", "# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined)\n" "# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid.\n" "# (l)abeling must only be used once and the 'l' must be the last letter.\n" "# Comment out to disable", CONF_OFFSET(despeckle), copy_string, print_string }, { "mask_file", "# PGM file to use as a sensitivity mask.\n" "# Full path name to. (Default: not defined)", CONF_OFFSET(mask_file), copy_string, print_string }, { "smart_mask_speed", "# Dynamically create a mask file during operation (default: 0)\n" "# Adjust speed of mask changes from 0 (off) to 10 (fast)", CONF_OFFSET(smart_mask_speed), copy_int, print_int }, { "lightswitch", "# Ignore sudden massive light intensity changes given as a percentage of the picture\n" "# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled", CONF_OFFSET(lightswitch), copy_int, print_int }, { "minimum_motion_frames", "# Picture frames must contain motion at least the specified number of frames\n" "# in a row before they are detected as true motion. At the default of 1, all\n" "# motion is detected. Valid range: 1 to thousands, recommended 1-5", CONF_OFFSET(minimum_motion_frames), copy_int, print_int }, { "pre_capture", "# Specifies the number of pre-captured (buffered) pictures from before motion\n" "# was detected that will be output at motion detection.\n" "# Recommended range: 0 to 5 (default: 0)\n" "# Do not use large values! Large values will cause Motion to skip video frames and\n" "# cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.", CONF_OFFSET(pre_capture), copy_int, print_int }, { "post_capture", "# Number of frames to capture after motion is no longer detected (default: 0)", CONF_OFFSET(post_capture), copy_int, print_int },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -