diff --git a/src/Makefile.am b/src/Makefile.am index 2432bee8..5d7a2a7b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,8 +8,8 @@ LIBS = @LIBINTL@ @LIBS@ bin_PROGRAMS = motion -motion_SOURCES = motion.cpp logger.cpp conf.cpp draw.cpp jpegutils.cpp video_loopback.cpp \ - video_v4l2.cpp video_common.cpp dbse.cpp rotate.cpp movie.cpp exif.cpp util.cpp \ - netcam.cpp track.cpp alg.cpp event.cpp picture.cpp motion_loop.cpp \ +motion_SOURCES = motion.cpp motion_loop.cpp logger.cpp conf.cpp conf_edit.cpp util.cpp alg.cpp \ + video_v4l2.cpp video_common.cpp video_loopback.cpp netcam.cpp jpegutils.cpp exif.cpp \ + rotate.cpp draw.cpp event.cpp movie.cpp picture.cpp dbse.cpp track.cpp \ webu.cpp webu_html.cpp webu_stream.cpp webu_text.cpp mmalcam.cpp $(MMAL_SRC) diff --git a/src/conf.cpp b/src/conf.cpp index 1357ddef..037d0020 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -15,24 +15,11 @@ #include "motion.hpp" #include "util.hpp" #include "logger.hpp" +#include "conf_edit.hpp" #define EXTENSION ".conf" - /* Forward Declares */ -static void conf_process(struct ctx_cam *cam, FILE *fp); - -/* Set a NULL (0) as a type of ctx_cam, then get the address of the varname. - * This result will be the offset from the start of any ctx_cam to the location - * of the variable within the entire ctx_cam struct - */ -#define CONF_OFFSET(varname) ((long)&((struct ctx_cam *)NULL)->conf.varname) -#define TRACK_OFFSET(varname) ((long)&((struct ctx_cam *)NULL)->track.varname) - -/* The sequence of these within here determines how they are presented to user - * Descriptions are limited to one line and few to no references to values since - * the motion_guide.html is our single source of documentation and historically - * these descriptions were not updated with revisions. - */ +void conf_process(struct ctx_motapp *motapp, FILE *fp, int threadnbr); /*Configuration parameters */ struct ctx_parm config_parms[] = { @@ -42,1190 +29,588 @@ struct ctx_parm config_parms[] = { "# System control configuration parameters\n" "############################################################\n\n" "# Start in daemon (background) mode and release terminal.", - 1, - CONF_OFFSET(daemon), - PARM_TYPE_BOOL, - WEBUI_LEVEL_ADVANCED - }, + 1 ,PARM_TYP_BOOL,PARM_CAT_00,WEBUI_LEVEL_ADVANCED}, { "setup_mode", "# Start in Setup-Mode, daemon disabled.", - 0, - CONF_OFFSET(setup_mode), - PARM_TYPE_BOOL, - WEBUI_LEVEL_ADVANCED - }, + 0 ,PARM_TYP_BOOL ,PARM_CAT_00,WEBUI_LEVEL_ADVANCED}, { "pid_file", "# File to store the process ID.", - 1, - CONF_OFFSET(pid_file), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 1 ,PARM_TYP_STRING ,PARM_CAT_00,WEBUI_LEVEL_ADVANCED}, { "log_file", "# File to write logs messages into. If not defined stderr and syslog is used.", - 1, - CONF_OFFSET(log_file), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 1, PARM_TYP_STRING, PARM_CAT_00 , WEBUI_LEVEL_ADVANCED}, { "log_level", "# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL).", - 1, - CONF_OFFSET(log_level), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 1, PARM_TYP_INT, PARM_CAT_00, WEBUI_LEVEL_LIMITED}, { "log_type", "# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL).", - 1, - CONF_OFFSET(log_type), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 1, PARM_TYP_STRING, PARM_CAT_00, WEBUI_LEVEL_LIMITED}, { "quiet", "# Do not sound beeps when detecting motion", - 0, - CONF_OFFSET(quiet), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_01, WEBUI_LEVEL_LIMITED}, { "native_language", "# Native language support.", - 1, - CONF_OFFSET(native_language), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 1, PARM_TYP_STRING, PARM_CAT_00, WEBUI_LEVEL_LIMITED}, { "camera_name", "# User defined name for the camera.", - 0, - CONF_OFFSET(camera_name), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING,PARM_CAT_01, WEBUI_LEVEL_ADVANCED }, { "camera_id", "# Numeric identifier for the camera.", - 0, - CONF_OFFSET(camera_id), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_INT,PARM_CAT_01,WEBUI_LEVEL_ADVANCED}, /* camera and camera_dir must be last in this list */ { "target_dir", "# Target directory for pictures, snapshots and movies", - 0, - CONF_OFFSET(target_dir), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_STRING,PARM_CAT_01, WEBUI_LEVEL_LIMITED }, { "videodevice", "# Video device (e.g. /dev/video0) to be used for capturing.", - 0, - CONF_OFFSET(video_device), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED + 0,PARM_TYP_STRING,PARM_CAT_01,WEBUI_LEVEL_ADVANCED }, { "vid_control_params", "# Parameters to control video device. See motion_guide.html", - 0, - CONF_OFFSET(vid_control_params), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_STRING,PARM_CAT_01,WEBUI_LEVEL_LIMITED}, { "v4l2_palette", "# Preferred color palette to be used for the video device", - 0, - CONF_OFFSET(v4l2_palette), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_INT, PARM_CAT_01, WEBUI_LEVEL_ADVANCED}, { "input", "# The input number to be used on the video device.", - 0, - CONF_OFFSET(input), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_INT, PARM_CAT_01, WEBUI_LEVEL_ADVANCED }, { "norm", "# The video norm to use for video capture and TV tuner cards.", - 0, - CONF_OFFSET(norm), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0,PARM_TYP_INT, PARM_CAT_01, WEBUI_LEVEL_ADVANCED }, { "frequency", "# The frequency to set the tuner to (kHz) for TV tuner cards", - 0, - CONF_OFFSET(frequency), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0,PARM_TYP_INT, PARM_CAT_01,WEBUI_LEVEL_ADVANCED }, { "roundrobin_frames", "# Number of frames to capture in each roundrobin step", - 0, - CONF_OFFSET(roundrobin_frames), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_01, WEBUI_LEVEL_LIMITED }, { "roundrobin_skip", "# Number of frames to skip before each roundrobin step", - 0, - CONF_OFFSET(roundrobin_skip), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_01, WEBUI_LEVEL_LIMITED }, { "roundrobin_switchfilter", "# Try to filter out noise generated by roundrobin", - 0, - CONF_OFFSET(roundrobin_switchfilter), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_BOOL, PARM_CAT_01, WEBUI_LEVEL_LIMITED}, { "netcam_url", "# The full URL of the network camera stream.", - 0, - CONF_OFFSET(netcam_url), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_01, WEBUI_LEVEL_ADVANCED}, { "netcam_highres", "# Optional high resolution URL for rtsp/rtmp cameras only.", - 0, - CONF_OFFSET(netcam_highres), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_01, WEBUI_LEVEL_ADVANCED}, { "netcam_userpass", "# Username and password for network camera. Syntax username:password", - 0, - CONF_OFFSET(netcam_userpass), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, - { - "netcam_keepalive", - "# The method for keep-alive of network socket for mjpeg streams.", - 0, - CONF_OFFSET(netcam_keepalive), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, - { - "netcam_proxy", - "# The URL to use for a netcam proxy server.", - 0, - CONF_OFFSET(netcam_proxy), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, - { - "netcam_tolerant_check", - "# Use less strict jpeg checks for network cameras.", - 0, - CONF_OFFSET(netcam_tolerant_check), - PARM_TYPE_BOOL, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_01, WEBUI_LEVEL_ADVANCED }, { "netcam_use_tcp", "# Use TCP transport for RTSP/RTMP connections to camera.", - 1, - CONF_OFFSET(netcam_use_tcp), - PARM_TYPE_BOOL, - WEBUI_LEVEL_ADVANCED - }, + 1, PARM_TYP_STRING, PARM_CAT_01, WEBUI_LEVEL_ADVANCED }, { "mmalcam_name", "# Name of mmal camera (e.g. vc.ril.camera for pi camera).", - 0, - CONF_OFFSET(mmalcam_name), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_01, WEBUI_LEVEL_ADVANCED }, { "mmalcam_control_params", "# Camera control parameters (see raspivid/raspistill tool documentation)", - 0, - CONF_OFFSET(mmalcam_control_params), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_01, WEBUI_LEVEL_ADVANCED }, { "width", "############################################################\n" "# Image Processing configuration parameters\n" "############################################################\n\n" "# Image width in pixels.", - 0, - CONF_OFFSET(width), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_ADVANCED }, { "height", "# Image height in pixels.", - 0, - CONF_OFFSET(height), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_ADVANCED}, { "framerate", "# Maximum number of frames to be captured per second.", - 0, - CONF_OFFSET(framerate), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "rotate", "# Number of degrees to rotate image.", - 0, - CONF_OFFSET(rotate), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "flip_axis", "# Flip image over a given axis", - 0, - CONF_OFFSET(flip_axis), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "locate_motion_mode", "# Draw a locate box around the moving object.", - 0, - CONF_OFFSET(locate_motion_mode), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "locate_motion_style", "# Set the look and style of the locate box.", - 0, - CONF_OFFSET(locate_motion_style), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "text_left", "# Text to be overlayed in the lower left corner of images", - 0, - CONF_OFFSET(text_left), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "text_right", "# Text to be overlayed in the lower right corner of images.", - 0, - CONF_OFFSET(text_right), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "text_changes", "# Overlay number of changed pixels in upper right corner of images.", - 0, - CONF_OFFSET(text_changes), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_BOOL, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "text_scale", "# Scale factor for text overlayed on images.", - 0, - CONF_OFFSET(text_scale), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "text_event", "# The special event conversion specifier %C", - 0, - CONF_OFFSET(text_event), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "emulate_motion", "############################################################\n" "# Motion detection configuration parameters\n" "############################################################\n\n" "# Always save pictures and movies even if there was no motion.", - 0, - CONF_OFFSET(emulate_motion), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_BOOL, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "threshold", "# Threshold for number of changed pixels that triggers motion.", - 0, - CONF_OFFSET(threshold), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "threshold_maximum", "# The maximum threshold for number of changed pixels that triggers motion.", - 0, - CONF_OFFSET(threshold_maximum), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "threshold_tune", "# Enable tuning of the threshold down if possible.", - 0, - CONF_OFFSET(threshold_tune), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_BOOL, PARM_CAT_02, WEBUI_LEVEL_LIMITED}, { "noise_level", "# Noise threshold for the motion detection.", - 0, - CONF_OFFSET(noise_level), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "noise_tune", "# Automatically tune the noise threshold", - 0, - CONF_OFFSET(noise_tune), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_BOOL, PARM_CAT_02, WEBUI_LEVEL_LIMITED}, { "despeckle_filter", "# Despeckle the image using (E/e)rode or (D/d)ilate or (l)abel.", - 0, - CONF_OFFSET(despeckle_filter), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "area_detect", "# Area number used to trigger the on_area_detected script.", - 0, - CONF_OFFSET(area_detect), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "mask_file", "# Full path and file name for motion detection mask PGM file.", - 0, - CONF_OFFSET(mask_file), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0,PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_ADVANCED }, { "mask_privacy", "# Full path and file name for privacy mask PGM file.", - 0, - CONF_OFFSET(mask_privacy), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0,PARM_TYP_STRING, PARM_CAT_02, WEBUI_LEVEL_ADVANCED }, { "smart_mask_speed", "# The value defining how slow or fast the smart motion mask created and used.", - 0, - CONF_OFFSET(smart_mask_speed), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "lightswitch_percent", "# Percentage of image that triggers a lightswitch detected.", - 0, - CONF_OFFSET(lightswitch_percent), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED}, { "lightswitch_frames", "# When lightswitch is detected, ignore this many frames", - 0, - CONF_OFFSET(lightswitch_frames), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "minimum_motion_frames", "# Number of images that must contain motion to trigger an event.", - 0, - CONF_OFFSET(minimum_motion_frames), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "event_gap", "# Gap in seconds of no motion detected that triggers the end of an event.", - 0, - CONF_OFFSET(event_gap), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "pre_capture", "# The number of pre-captured (buffered) pictures from before motion.", - 0, - CONF_OFFSET(pre_capture), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "post_capture", "# Number of frames to capture after motion is no longer detected.", - 0, - CONF_OFFSET(post_capture), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED }, { "on_event_start", "############################################################\n" "# Script execution configuration parameters\n" "############################################################\n\n" "# Command to be executed when an event starts.", - 0, - CONF_OFFSET(on_event_start), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED }, { "on_event_end", "# Command to be executed when an event ends.", - 0, - CONF_OFFSET(on_event_end), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED}, { "on_picture_save", "# Command to be executed when a picture is saved.", - 0, - CONF_OFFSET(on_picture_save), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED }, { "on_area_detected", "# Command to be executed when motion in a predefined area is detected", - 0, - CONF_OFFSET(on_area_detected), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED }, { "on_motion_detected", "# Command to be executed when motion is detected", - 0, - CONF_OFFSET(on_motion_detected), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED }, { "on_movie_start", "# Command to be executed when a movie file is created.", - 0, - CONF_OFFSET(on_movie_start), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED}, { "on_movie_end", "# Command to be executed when a movie file is closed.", - 0, - CONF_OFFSET(on_movie_end), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED }, { "on_camera_lost", "# Command to be executed when a camera can't be opened or if it is lost", - 0, - CONF_OFFSET(on_camera_lost), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED }, { "on_camera_found", "# Command to be executed when a camera that was lost has been found.", - 0, - CONF_OFFSET(on_camera_found), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED}, { "picture_output", "############################################################\n" "# Picture output configuration parameters\n" "############################################################\n\n" "# Output pictures when motion is detected", - 0, - CONF_OFFSET(picture_output), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "picture_output_motion", "# Output pictures with only the pixels moving object (ghost images)", - 0, - CONF_OFFSET(picture_output_motion), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "picture_type", "# Format for the output pictures.", - 0, - CONF_OFFSET(picture_type), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED}, { "picture_quality", "# The quality (in percent) to be used in the picture compression", - 0, - CONF_OFFSET(picture_quality), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "picture_exif", "# Text to include in a JPEG EXIF comment", - 0, - CONF_OFFSET(picture_exif), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "picture_filename", "# File name(without extension) for pictures relative to target directory", - 0, - CONF_OFFSET(picture_filename), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "snapshot_interval", "############################################################\n" "# Snapshot output configuration parameters\n" "############################################################\n\n" "# Make automated snapshot every N seconds", - 0, - CONF_OFFSET(snapshot_interval), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "snapshot_filename", "# File name(without extension) for snapshots relative to target directory", - 0, - CONF_OFFSET(snapshot_filename), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED}, { "movie_output", "############################################################\n" "# Movie output configuration parameters\n" "############################################################\n\n" "# Create movies of motion events.", - 0, - CONF_OFFSET(movie_output), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "movie_output_motion", "# Create movies of moving pixels of motion events.", - 0, - CONF_OFFSET(movie_output_motion), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "movie_max_time", "# Maximum length of movie in seconds.", - 0, - CONF_OFFSET(movie_max_time), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "movie_bps", "# The fixed bitrate to be used by the movie encoder. Ignore quality setting", - 0, - CONF_OFFSET(movie_bps), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "movie_quality", "# The encoding quality of the movie. (0=use bitrate. 1=worst quality, 100=best)", - 0, - CONF_OFFSET(movie_quality), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "movie_codec", "# Container/Codec to used for the movie. See motion_guide.html", - 0, - CONF_OFFSET(movie_codec), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "movie_passthrough", "# Pass through from the camera to the movie without decode/encoding.", - 0, - CONF_OFFSET(movie_passthrough), - PARM_TYPE_BOOL, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_BOOL, PARM_CAT_03, WEBUI_LEVEL_ADVANCED }, { "movie_filename", "# File name(without extension) for movies relative to target directory", - 0, - CONF_OFFSET(movie_filename), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "movie_extpipe_use", "# Use pipe and external encoder for creating movies.", - 0, - CONF_OFFSET(movie_extpipe_use), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "movie_extpipe", "# Full path and options for external encoder of movies from raw images", - 0, - CONF_OFFSET(movie_extpipe), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_RESTRICTED }, { "timelapse_interval", "############################################################\n" "# Timelapse output configuration parameters\n" "############################################################\n\n" "# Interval in seconds between timelapse captures.", - 0, - CONF_OFFSET(timelapse_interval), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "timelapse_mode", "# Timelapse file rollover mode. See motion_guide.html for options and uses.", - 0, - CONF_OFFSET(timelapse_mode), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED}, { "timelapse_fps", "# Frame rate for timelapse playback", - 0, - CONF_OFFSET(timelapse_fps), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "timelapse_codec", "# Container/Codec for timelapse movie.", - 0, - CONF_OFFSET(timelapse_codec), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED}, { "timelapse_filename", "# File name(without extension) for timelapse movies relative to target directory", - 0, - CONF_OFFSET(timelapse_filename), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED}, { "video_pipe", "############################################################\n" "# Loopback pipe configuration parameters\n" "############################################################\n\n" "# v4l2 loopback device to receive normal images", - 0, - CONF_OFFSET(video_pipe), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED }, { "video_pipe_motion", "# v4l2 loopback device to receive motion images", - 0, - CONF_OFFSET(video_pipe_motion), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_03, WEBUI_LEVEL_LIMITED}, { "webcontrol_port", "############################################################\n" "# Webcontrol configuration parameters\n" "############################################################\n\n" "# Port number used for the webcontrol.", - 1, - CONF_OFFSET(webcontrol_port), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 1, PARM_TYP_STRING, PARM_CAT_04, WEBUI_LEVEL_ADVANCED}, { "webcontrol_ipv6", "# Enable IPv6 addresses.", - 0, - CONF_OFFSET(webcontrol_ipv6), - PARM_TYPE_BOOL, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_BOOL, PARM_CAT_04, WEBUI_LEVEL_ADVANCED}, { "webcontrol_localhost", "# Restrict webcontrol connections to the localhost.", - 1, - CONF_OFFSET(webcontrol_localhost), - PARM_TYPE_BOOL, - WEBUI_LEVEL_ADVANCED - }, + 1, PARM_TYP_BOOL, PARM_CAT_04, WEBUI_LEVEL_ADVANCED }, { "webcontrol_parms", "# Type of configuration options to allow via the webcontrol.", - 1, - CONF_OFFSET(webcontrol_parms), - PARM_TYPE_INT, - WEBUI_LEVEL_NEVER - }, + 1, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_NEVER}, { "webcontrol_interface", "# Method that webcontrol should use for interface with user.", - 1, - CONF_OFFSET(webcontrol_interface), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 1, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_LIMITED }, { "webcontrol_auth_method", "# The authentication method for the webcontrol", - 0, - CONF_OFFSET(webcontrol_auth_method), - PARM_TYPE_INT, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED}, { "webcontrol_authentication", "# Authentication string for the webcontrol. Syntax username:password", - 1, - CONF_OFFSET(webcontrol_authentication), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 1, PARM_TYP_STRING, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED}, { "webcontrol_tls", "# Use ssl / tls for the webcontrol", - 0, - CONF_OFFSET(webcontrol_tls), - PARM_TYPE_BOOL, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_BOOL, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED }, { "webcontrol_cert", "# Full path and file name of the certificate file for tls", - 1, - CONF_OFFSET(webcontrol_cert), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 1, PARM_TYP_STRING, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED}, { "webcontrol_key", "# Full path and file name of the key file for tls", - 1, - CONF_OFFSET(webcontrol_key), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 1, PARM_TYP_STRING, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED}, { "webcontrol_cors_header", "# The cross-origin resource sharing (CORS) header for webcontrol", - 0, - CONF_OFFSET(webcontrol_cors_header), - PARM_TYPE_URI, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED }, { "stream_port", "############################################################\n" "# Live stream configuration parameters\n" "############################################################\n\n" "# The port number for the live stream.", - 0, - CONF_OFFSET(stream_port), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_ADVANCED }, { "stream_localhost", "# Restrict stream connections to the localhost.", - 0, - CONF_OFFSET(stream_localhost), - PARM_TYPE_BOOL, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_BOOL, PARM_CAT_04, WEBUI_LEVEL_ADVANCED }, { "stream_auth_method", "# Authentication method for live stream.", - 0, - CONF_OFFSET(stream_auth_method), - PARM_TYPE_INT, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED}, { "stream_authentication", "# The authentication string for the stream. Syntax username:password", - 1, - CONF_OFFSET(stream_authentication), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 1, PARM_TYP_STRING, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED }, { "stream_tls", "# Use ssl / tls for stream.", - 0, - CONF_OFFSET(stream_tls), - PARM_TYPE_BOOL, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_BOOL, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED }, { "stream_cors_header", "# The cross-origin resource sharing (CORS) header for the stream", - 0, - CONF_OFFSET(stream_cors_header), - PARM_TYPE_URI, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_04, WEBUI_LEVEL_RESTRICTED }, { "stream_preview_scale", "# Percentage to scale the stream image on the webcontrol.", - 0, - CONF_OFFSET(stream_preview_scale), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_LIMITED }, { "stream_preview_newline", "# Have the stream image start on a new line of the webcontrol", - 0, - CONF_OFFSET(stream_preview_newline), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_04, WEBUI_LEVEL_LIMITED }, { "stream_preview_method", "# Method for showing stream on webcontrol.", - 0, - CONF_OFFSET(stream_preview_method), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_LIMITED }, { "stream_quality", "# Quality of the jpeg images produced for stream.", - 0, - CONF_OFFSET(stream_quality), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_LIMITED }, { "stream_grey", "# Provide the stream images in black and white", - 0, - CONF_OFFSET(stream_grey), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_04, WEBUI_LEVEL_LIMITED }, { "stream_motion", "# Output frames at 1 fps when no motion is detected.", - 0, - CONF_OFFSET(stream_motion), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_04, WEBUI_LEVEL_LIMITED }, { "stream_maxrate", "# Maximum framerate of images provided for stream", - 0, - CONF_OFFSET(stream_maxrate), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, - { - "stream_limit", - "# Limit the number of images per connection", - 0, - CONF_OFFSET(stream_limit), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_04, WEBUI_LEVEL_LIMITED }, { "database_type", "############################################################\n" "# Database and SQL Configuration parameters\n" "############################################################\n\n" "# The type of database being used if any.", - 0, - CONF_OFFSET(database_type), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED}, { "database_dbname", "# Database name to use. For sqlite3, the full path and name.", - 0, - CONF_OFFSET(database_dbname), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, { "database_host", "# The host on which the database is located", - 0, - CONF_OFFSET(database_host), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, { "database_port", "# Port used by the database.", - 0, - CONF_OFFSET(database_port), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, { "database_user", "# User account name for database.", - 0, - CONF_OFFSET(database_user), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_RESTRICTED }, { "database_password", "# User password for database.", - 0, - CONF_OFFSET(database_password), - PARM_TYPE_STRING, - WEBUI_LEVEL_RESTRICTED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_RESTRICTED }, { "database_busy_timeout", "# Database wait for unlock time", - 0, - CONF_OFFSET(database_busy_timeout), - PARM_TYPE_INT, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, { "sql_log_picture", "# Log to the database when creating motion triggered image file", - 0, - CONF_OFFSET(sql_log_picture), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_LIMITED }, { "sql_log_snapshot", "# Log to the database when creating a snapshot image file", - 0, - CONF_OFFSET(sql_log_snapshot), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_LIMITED}, { "sql_log_movie", "# Log to the database when creating motion triggered movie file", - 0, - CONF_OFFSET(sql_log_movie), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_LIMITED }, { "sql_log_timelapse", "# Log to the database when creating timelapse movie file", - 0, - CONF_OFFSET(sql_log_timelapse), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0,PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_LIMITED}, { "sql_query_start", "# SQL query at event start. See motion_guide.html", - 0, - CONF_OFFSET(sql_query_start), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, { "sql_query_stop", "# SQL query at event stop. See motion_guide.html", - 0, - CONF_OFFSET(sql_query_stop), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, { "sql_query", "# SQL query string that is sent to the database. See motion_guide.html", - 0, - CONF_OFFSET(sql_query), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED}, { "track_type", "############################################################\n" "# Tracking configuration parameters\n" "############################################################\n\n" "# Method used by tracking camera. See motion_guide.html", - 0, - TRACK_OFFSET(type), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_LIMITED }, { "track_auto", "# Enable auto tracking", - 0, - TRACK_OFFSET(active), - PARM_TYPE_BOOL, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_BOOL, PARM_CAT_05, WEBUI_LEVEL_LIMITED }, { "track_move_wait", "# Delay to wait for after tracking movement as number of picture frames.", - 0, - TRACK_OFFSET(move_wait), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_LIMITED }, { "track_generic_move", "# Command to execute to move a camera in generic tracking mode", - 0, - TRACK_OFFSET(generic_move), - PARM_TYPE_STRING, - WEBUI_LEVEL_LIMITED - }, - { - "track_maxx", - "# Maximum value on x-axis", - 0, - TRACK_OFFSET(maxx), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, - { - "track_minx", - "# Minimum value on x-axis", - 0, - TRACK_OFFSET(minx), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, - { - "track_maxy", - "# Maximum value on y-axis", - 0, - TRACK_OFFSET(maxy), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, - { - "track_miny", - "# Minimum value on y-axis", - 0, - TRACK_OFFSET(miny), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_LIMITED }, { "track_step_angle_x", "# Angle in degrees the camera moves per step on the X-axis with auto-track", - 0, - TRACK_OFFSET(step_angle_x), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_LIMITED }, { "track_step_angle_y", "# Angle in degrees the camera moves per step on the Y-axis with auto-track.", - 0, - TRACK_OFFSET(step_angle_y), - PARM_TYPE_INT, - WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_05, WEBUI_LEVEL_LIMITED }, { "camera", "##############################################################\n" "# Camera config files - One for each camera.\n" "##############################################################", - 1, - 0, - PARM_TYPE_CAMERA, - WEBUI_LEVEL_ADVANCED - }, + 1, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, /* using a conf.d style camera addition */ { "camera_dir", "##############################################################\n" "# Directory to read '.conf' files for cameras.\n" "##############################################################", - 1, - CONF_OFFSET(camera_dir), - PARM_TYPE_STRING, - WEBUI_LEVEL_ADVANCED - }, - { NULL, NULL, 0, 0, (enum PARM_TYPE)0, (enum WEBUI_LEVEL)0 } + 1, PARM_TYP_STRING, PARM_CAT_05, WEBUI_LEVEL_ADVANCED }, + { NULL, NULL, 0, (enum PARM_TYP)0, (enum PARM_CAT)0, (enum WEBUI_LEVEL)0 } }; /* @@ -1243,401 +628,185 @@ struct ctx_parm_depr config_parms_depr[] = { "thread", "3.4.1", "The \"thread\" option has been replaced by the \"camera\"", - 0, - "camera", - PARM_TYPE_CAMERA + "camera" }, { "ffmpeg_timelapse", "4.0.1", "\"ffmpeg_timelapse\" replaced with \"timelapse_interval\"", - CONF_OFFSET(timelapse_interval), - "timelapse_interval", - PARM_TYPE_INT + "timelapse_interval" }, { "ffmpeg_timelapse_mode", "4.0.1", "\"ffmpeg_timelapse_mode\" replaced with \"timelapse_mode\"", - CONF_OFFSET(timelapse_mode), - "timelapse_mode", - PARM_TYPE_STRING + "timelapse_mode" }, { "brightness", "4.1.1", "\"brightness\" replaced with \"vid_control_params\"", - CONF_OFFSET(vid_control_params), - "vid_control_params", - PARM_TYPE_STRING + "vid_control_params" }, { "contrast", "4.1.1", "\"contrast\" replaced with \"vid_control_params\"", - CONF_OFFSET(vid_control_params), - "vid_control_params", - PARM_TYPE_STRING + "vid_control_params" }, { "saturation", "4.1.1", "\"saturation\" replaced with \"vid_control_params\"", - CONF_OFFSET(vid_control_params), - "vid_control_params", - PARM_TYPE_STRING + "vid_control_params" }, { "hue", "4.1.1", "\"hue\" replaced with \"vid_control_params\"", - CONF_OFFSET(vid_control_params), - "vid_control_params", - PARM_TYPE_STRING + "vid_control_params" }, { "power_line_frequency", "4.1.1", "\"power_line_frequency\" replaced with \"vid_control_params\"", - CONF_OFFSET(vid_control_params), - "vid_control_params", - PARM_TYPE_STRING + "vid_control_params" }, { "text_double", "4.1.1", "\"text_double\" replaced with \"text_scale\"", - CONF_OFFSET(text_scale), - "text_scale", - PARM_TYPE_INT + "text_scale" }, { "webcontrol_html_output", "4.1.1", "\"webcontrol_html_output\" replaced with \"webcontrol_interface\"", - CONF_OFFSET(webcontrol_interface), - "webcontrol_interface", - PARM_TYPE_INT + "webcontrol_interface" }, { "lightswitch", "4.1.1", "\"lightswitch\" replaced with \"lightswitch_percent\"", - CONF_OFFSET(lightswitch_percent), - "lightswitch_percent", - PARM_TYPE_INT + "lightswitch_percent" }, { "ffmpeg_output_movies", "4.1.1", "\"ffmpeg_output_movies\" replaced with \"movie_output\"", - CONF_OFFSET(movie_output), - "movie_output", - PARM_TYPE_BOOL + "movie_output" }, { "ffmpeg_output_debug_movies", "4.1.1", "\"ffmpeg_output_debug_movies\" replaced with \"movie_output_motion\"", - CONF_OFFSET(movie_output_motion), - "movie_output_motion", - PARM_TYPE_BOOL + "movie_output_motion" }, { "max_movie_time", "4.1.1", "\"max_movie_time\" replaced with \"movie_max_time\"", - CONF_OFFSET(movie_max_time), - "movie_max_time", - PARM_TYPE_INT + "movie_max_time" }, { "ffmpeg_bps", "4.1.1", "\"ffmpeg_bps\" replaced with \"movie_bps\"", - CONF_OFFSET(movie_bps), - "movie_bps", - PARM_TYPE_INT + "movie_bps" }, { "ffmpeg_variable_bitrate", "4.1.1", "\"ffmpeg_variable_bitrate\" replaced with \"movie_quality\"", - CONF_OFFSET(movie_quality), - "movie_quality", - PARM_TYPE_INT + "movie_quality" }, { "ffmpeg_video_codec", "4.1.1", "\"ffmpeg_video_codec\" replaced with \"movie_codec\"", - CONF_OFFSET(movie_codec), - "movie_codec", - PARM_TYPE_STRING + "movie_codec" }, { "ffmpeg_passthrough", "4.1.1", "\"ffmpeg_passthrough\" replaced with \"movie_passthrough\"", - CONF_OFFSET(movie_passthrough), - "movie_passthrough", - PARM_TYPE_BOOL + "movie_passthrough" }, { "use_extpipe", "4.1.1", "\"use_extpipe\" replaced with \"movie_extpipe_use\"", - CONF_OFFSET(movie_extpipe_use), - "movie_extpipe_use", - PARM_TYPE_BOOL + "movie_extpipe_use" }, { "extpipe", "4.1.1", "\"extpipe\" replaced with \"movie_extpipe\"", - CONF_OFFSET(movie_extpipe), - "movie_extpipe", - PARM_TYPE_STRING + "movie_extpipe" }, { "output_pictures", "4.1.1", "\"output_pictures\" replaced with \"picture_output\"", - CONF_OFFSET(picture_output), - "picture_output", - PARM_TYPE_STRING + "picture_output" }, { "output_debug_pictures", "4.1.1", "\"output_debug_pictures\" replaced with \"picture_output_motion\"", - CONF_OFFSET(picture_output_motion), - "picture_output_motion", - PARM_TYPE_BOOL + "picture_output_motion" }, { "quality", "4.1.1", "\"quality\" replaced with \"picture_quality\"", - CONF_OFFSET(picture_quality), - "picture_quality", - PARM_TYPE_INT + "picture_quality" }, { "exif_text", "4.1.1", "\"exif_text\" replaced with \"picture_exif\"", - CONF_OFFSET(picture_exif), - "picture_exif", - PARM_TYPE_STRING + "picture_exif" }, { "motion_video_pipe", "4.1.1", "\"motion_video_pipe\" replaced with \"video_pipe_motion\"", - CONF_OFFSET(video_pipe_motion), - "video_pipe_motion", - PARM_TYPE_STRING + "video_pipe_motion" }, { "ipv6_enabled", "4.1.1", "\"ipv6_enabled\" replaced with \"webcontrol_ipv6\"", - CONF_OFFSET(webcontrol_ipv6), - "webcontrol_ipv6", - PARM_TYPE_BOOL + "webcontrol_ipv6" }, { "rtsp_uses_tcp", "4.1.1", "\"rtsp_uses_tcp\" replaced with \"netcam_use_tcp\"", - CONF_OFFSET(netcam_use_tcp), - "netcam_use_tcp", - PARM_TYPE_BOOL + "netcam_use_tcp" }, { "switchfilter", "4.1.1", "\"switchfilter\" replaced with \"roundrobin_switchfilter\"", - CONF_OFFSET(roundrobin_switchfilter), - "roundrobin_switchfilter", - PARM_TYPE_BOOL + "roundrobin_switchfilter" }, { "logfile", "4.1.1", "\"logfile\" replaced with \"log_file\"", - CONF_OFFSET(log_file), - "log_file", - PARM_TYPE_STRING + "log_file" }, { "process_id_file", "4.1.1", "\"process_id_file\" replaced with \"pid_file\"", - CONF_OFFSET(pid_file), - "pid_file", - PARM_TYPE_STRING + "pid_file" }, - { NULL, NULL, NULL, 0, NULL,(enum PARM_TYPE)0} + { NULL, NULL, NULL, NULL} }; -static void config_parms_intl(void){ - /* This function prints out the configuration parms side by side - * with the translations. It is currently disabled but put into - * the code so that they can be found by xgettext. If enabled, then - * it will be printed when called from the conf_load. - */ - - if (FALSE){ - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","daemon",_("daemon")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","setup_mode",_("setup_mode")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","pid_file",_("pid_file")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_file",_("log_file")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_level",_("log_level")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_type",_("log_type")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","quiet",_("quiet")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","native_language",_("native_language")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_name",_("camera_name")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_id",_("camera_id")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","target_dir",_("target_dir")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","videodevice",_("videodevice")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","vid_control_params",_("vid_control_params")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","v4l2_palette",_("v4l2_palette")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","input",_("input")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","norm",_("norm")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","frequency",_("frequency")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","tunerdevice",_("tunerdevice")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_frames",_("roundrobin_frames")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_skip",_("roundrobin_skip")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_switchfilter",_("roundrobin_switchfilter")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_url",_("netcam_url")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_highres",_("netcam_highres")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_userpass",_("netcam_userpass")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_keepalive",_("netcam_keepalive")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_proxy",_("netcam_proxy")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_tolerant_check",_("netcam_tolerant_check")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_use_tcp",_("netcam_use_tcp")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mmalcam_name",_("mmalcam_name")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mmalcam_control_params",_("mmalcam_control_params")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","width",_("width")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","height",_("height")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","framerate",_("framerate")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","rotate",_("rotate")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","flip_axis",_("flip_axis")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","locate_motion_mode",_("locate_motion_mode")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","locate_motion_style",_("locate_motion_style")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_left",_("text_left")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_right",_("text_right")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_changes",_("text_changes")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_scale",_("text_scale")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_event",_("text_event")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","emulate_motion",_("emulate_motion")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold",_("threshold")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_maximum",_("threshold_maximum")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_tune",_("threshold_tune")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","noise_level",_("noise_level")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","noise_tune",_("noise_tune")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","despeckle_filter",_("despeckle_filter")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","area_detect",_("area_detect")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mask_file",_("mask_file")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mask_privacy",_("mask_privacy")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","smart_mask_speed",_("smart_mask_speed")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","lightswitch_percent",_("lightswitch_percent")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","lightswitch_frames",_("lightswitch_frames")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","minimum_motion_frames",_("minimum_motion_frames")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","event_gap",_("event_gap")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","pre_capture",_("pre_capture")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","post_capture",_("post_capture")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_event_start",_("on_event_start")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_event_end",_("on_event_end")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_picture_save",_("on_picture_save")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_area_detected",_("on_area_detected")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_motion_detected",_("on_motion_detected")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_movie_start",_("on_movie_start")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_movie_end",_("on_movie_end")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_camera_lost",_("on_camera_lost")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_camera_found",_("on_camera_found")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_output",_("picture_output")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_output_motion",_("picture_output_motion")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_type",_("picture_type")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_quality",_("picture_quality")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_exif",_("picture_exif")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_filename",_("picture_filename")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","snapshot_interval",_("snapshot_interval")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","snapshot_filename",_("snapshot_filename")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_output",_("movie_output")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_output_motion",_("movie_output_motion")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_max_time",_("movie_max_time")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_bps",_("movie_bps")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_quality",_("movie_quality")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_codec",_("movie_codec")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_passthrough",_("movie_passthrough")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_filename",_("movie_filename")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_extpipe_use",_("movie_extpipe_use")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_extpipe",_("movie_extpipe")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_interval",_("timelapse_interval")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_mode",_("timelapse_mode")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_fps",_("timelapse_fps")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_codec",_("timelapse_codec")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_filename",_("timelapse_filename")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","video_pipe",_("video_pipe")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","video_pipe_motion",_("video_pipe_motion")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_port",_("webcontrol_port")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_ipv6",_("webcontrol_ipv6")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_localhost",_("webcontrol_localhost")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_parms",_("webcontrol_parms")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_interface",_("webcontrol_interface")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_auth_method",_("webcontrol_auth_method")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_authentication",_("webcontrol_authentication")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_tls",_("webcontrol_tls")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_cert",_("webcontrol_cert")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_key",_("webcontrol_key")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_cors_header",_("webcontrol_cors_header")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_port",_("stream_port")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_localhost",_("stream_localhost")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_auth_method",_("stream_auth_method")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_authentication",_("stream_authentication")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_tls",_("stream_tls")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_cors_header",_("stream_cors_header")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_scale",_("stream_preview_scale")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_newline",_("stream_preview_newline")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_method",_("stream_preview_method")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_quality",_("stream_quality")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_grey",_("stream_grey")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_motion",_("stream_motion")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_maxrate",_("stream_maxrate")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_limit",_("stream_limit")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_type",_("database_type")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_dbname",_("database_dbname")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_host",_("database_host")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_port",_("database_port")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_user",_("database_user")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_password",_("database_password")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_busy_timeout",_("database_busy_timeout")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_picture",_("sql_log_picture")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_snapshot",_("sql_log_snapshot")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_movie",_("sql_log_movie")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_timelapse",_("sql_log_timelapse")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query_start",_("sql_query_start")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query_stop",_("sql_query_stop")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query",_("sql_query")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_type",_("track_type")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_auto",_("track_auto")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_maxx",_("track_maxx")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_minx",_("track_minx")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_maxy",_("track_maxy")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_miny",_("track_miny")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_step_angle_x",_("track_step_angle_x")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_step_angle_y",_("track_step_angle_y")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_move_wait",_("track_move_wait")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_generic_move",_("track_generic_move")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera",_("camera")); - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_dir",_("camera_dir")); - - } -} - /** Prints usage and options allowed from Command-line. */ static void usage(void) { printf("motion Version %s, Copyright 2000-2019 Jeroen Vreeken/Folkert van Heusden/Kenneth Lavrsen/Motion-Project maintainers\n",PACKAGE_VERSION); @@ -1662,75 +831,38 @@ static void usage(void) { printf("\n"); } -static void conf_malloc_strings(struct ctx_cam *cam) { - unsigned int i = 0; - char **val; - - while (config_parms[i].parm_name != NULL) { - if ((config_parms[i].parm_type == PARM_TYPE_STRING) || - (config_parms[i].parm_type == PARM_TYPE_URI)) { - /* val is made to point to a pointer to the current string. */ - val = (char **)((char *)cam + config_parms[i].parm_offset); - - /* - * If there is a string, malloc() space for it, copy - * the string to new space, and point to the new - * string. we don't free() because we're copying a - * static string. - */ - *val = mystrdup(*val); - } - i++; - } -} - /** Process Command-line options specified */ -static void conf_cmdline(struct ctx_cam *cam, int thread) { - struct ctx_config *conf = &cam->conf; +static void conf_cmdline(struct ctx_motapp *motapp) { int c; - while ((c = getopt(conf->argc, conf->argv, "bc:d:hmns?p:k:l:")) != EOF) + while ((c = getopt(motapp->argc, motapp->argv, "bc:d:hmns?p:k:l:")) != EOF) switch (c) { case 'c': - if (thread == -1){ - strcpy(cam->conf_filename, optarg); - } + snprintf(motapp->conf_filename,sizeof(motapp->conf_filename) - 1,"%s",optarg); break; case 'b': - cam->motapp->daemon = TRUE; + motapp->daemon = TRUE; break; case 'n': - cam->motapp->daemon = FALSE; + motapp->daemon = FALSE; break; case 's': - conf->setup_mode = 1; + motapp->setup_mode = TRUE; break; case 'd': - /* No validation - just take what user gives. */ - if (thread == -1){ - cam->motapp->log_level = (unsigned int)atoi(optarg); - } + motapp->log_level = (unsigned int)atoi(optarg); break; case 'k': - if (thread == -1) { - strncpy(cam->motapp->log_type_str, optarg, sizeof(cam->motapp->log_type_str) - 1); - cam->motapp->log_type_str[sizeof(cam->motapp->log_type_str) - 1] = '\0'; - } + snprintf(motapp->log_type_str,sizeof(motapp->log_type_str) - 1,"%s",optarg); break; case 'p': - if (thread == -1) { - strncpy(cam->motapp->pid_file, optarg, sizeof(cam->motapp->pid_file) - 1); - cam->motapp->pid_file[sizeof(cam->motapp->pid_file) - 1] = '\0'; - } + snprintf(motapp->pid_file,sizeof(motapp->pid_file) - 1,"%s",optarg); break; case 'l': - if (thread == -1) { - strncpy(cam->motapp->log_file, optarg, sizeof(cam->motapp->log_file) - 1); - cam->motapp->log_file[sizeof(cam->motapp->log_file) - 1] = '\0'; - } + snprintf(motapp->log_file,sizeof(motapp->log_file) - 1,"%s",optarg); break; case 'm': - cam->pause = TRUE; + motapp->pause = TRUE; break; case 'h': case '?': @@ -1742,65 +874,117 @@ static void conf_cmdline(struct ctx_cam *cam, int thread) { optind = 1; } -static void conf_parm_set_bool(struct ctx_cam *cam, const char *str, int offset) { - void *tmp; +static void conf_parm_camera(struct ctx_motapp *motapp, char *str) { - tmp = (char *)cam + (int)offset; + int indx_cams, indx; + char parm_val[PATH_MAX]; + FILE *fp; - if (mystrceq(str, "1") || mystrceq(str, "yes") || mystrceq(str, "on")) { - *((int *)tmp) = 1; - } else { - *((int *)tmp) = 0; - } -} - -static void conf_parm_set_int(struct ctx_cam *cam, const char *str, int offset) { - void *tmp; - - tmp = (char *)cam + offset; - if ( mystrceq(str, "yes") || mystrceq(str, "on")) { - *((int *)tmp) = 1; - } else if (mystrceq(str, "no") || mystrceq(str, "off")) { - *((int *)tmp) = 0; - } else { - *((int *)tmp) = atoi(str); - } -} - -static void conf_parm_set_string(struct ctx_cam *cam, const char *str, int offset) { - char **tmp; - - tmp = (char **)((char *)cam + offset); - *tmp = mystrcpy(*tmp, str); -} - -static void conf_parm_set_uri(struct ctx_cam *cam, const char *str, int offset) { - // A complicated regex to validate a url found here: - // https://stackoverflow.com/questions/38608116/how-to-check-a-specified-string-is-a-valid-url-or-not-using-c-code - const char *regex_str = "^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$"; - - regex_t regex; - if (regcomp(®ex, regex_str, REG_EXTENDED) != 0) { - MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO - ,_("Error compiling regex in copy_uri")); + fp = fopen(str, "r"); + if (!fp) { + MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO + ,_("Camera config file %s not found"), str); return; } - // A single asterisk is also valid - if (!mystrceq(str, "*") && regexec(®ex, str, 0, NULL, 0) == REG_NOMATCH) { - MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO - ,_("Invalid origin for cors_header")); - regfree(®ex); - return; + /* Find the current number of threads defined. */ + indx_cams = 0; + while (motapp->cam_list[indx_cams] != NULL){ + indx_cams++; + }; + + /* Index starts at zero (+1) plus another for our new camera(+2)*/ + motapp->cam_list = (struct ctx_cam **)myrealloc( + motapp->cam_list, sizeof(struct ctx_cam *) * (indx_cams + 2), "config_camera"); + motapp->cam_list[indx_cams] = (struct ctx_cam *)mymalloc(sizeof(struct ctx_cam)); + motapp->cam_list[indx_cams + 1] = NULL; + + conf_edit_dflt_cam(motapp->cam_list[indx_cams]); + + indx = 0; + while (config_parms[indx].parm_name != NULL) { + conf_edit_get(motapp->cam_list[0],(char *)config_parms[indx].parm_name + ,parm_val, config_parms[indx].parm_cat); + /* Once we adjust all the code to allow for "" being same as NULL we can remove this*/ + if ((config_parms[indx].parm_type == PARM_TYP_STRING) && (mystreq(parm_val,""))) { + conf_edit_set(motapp,indx_cams, (char *)config_parms[indx].parm_name, NULL); + } else { + conf_edit_set(motapp,indx_cams, (char *)config_parms[indx].parm_name, parm_val); + } + indx++; } - regfree(®ex); - conf_parm_set_string(cam, str, offset); + /* Process the camera's config file and notify user on console. */ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO + ,_("Processing camera config file %s"), str); + snprintf(motapp->cam_list[indx_cams]->conf_filename + ,sizeof(motapp->cam_list[indx_cams]->conf_filename),"%s", str); + conf_process(motapp, fp, indx_cams); + + myfclose(fp); + + /*Cascade new pointers to all cameras. */ + indx_cams = 0; + while (motapp->cam_list[indx_cams] != NULL){ + motapp->cam_list[indx_cams]->motapp = motapp; + motapp->cam_list[indx_cams]->cam_list = motapp->cam_list; + indx_cams++; + } + + return; +} + +/** Process camera_dir */ +static void conf_parm_camera_dir(struct ctx_motapp *motapp, char *str) { + DIR *dp; + struct dirent *ep; + size_t name_len; + int i; + + char conf_file[PATH_MAX]; + + dp = opendir(str); + if (dp != NULL) { + while( (ep = readdir(dp)) ) { + name_len = strlen(ep->d_name); + if (name_len > strlen(EXTENSION) && + (strncmp(EXTENSION, + (ep->d_name + name_len - strlen(EXTENSION)), + strlen(EXTENSION)) == 0 + ) + ) + { + memset(conf_file, '\0', sizeof(conf_file)); + snprintf(conf_file, sizeof(conf_file) - 1, "%s/%s", + str, ep->d_name); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO + ,_("Processing config file %s"), conf_file ); + conf_parm_camera(motapp, conf_file); + /* The last ctx_cam thread would be ours, + * set it as created from conf directory. + */ + i = 0; + while (motapp->cam_list[++i]); + motapp->cam_list[i-1]->from_conf_dir = TRUE; + } + } + closedir(dp); + } else { + MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO + ,_("Camera directory config %s not found"), str); + } + + /* Store the given config value to allow writing it out */ + conf_edit_set(motapp,0, (char *)"camera_dir", str); + + return; } static void conf_parm_set_text_double(struct ctx_cam *cam, const char *str, int offset) { void *tmp; + return; + tmp = (char *)cam + (int)offset; if (mystrceq(str, "1") || mystrceq(str, "yes") || mystrceq(str, "on")) { *((int *)tmp) = 2; @@ -1812,6 +996,8 @@ static void conf_parm_set_text_double(struct ctx_cam *cam, const char *str, int static void conf_parm_set_html_output(struct ctx_cam *cam, const char *str, int offset) { void *tmp; + return; + tmp = (char *)cam + (int)offset; if (mystrceq(str, "1") || mystrceq(str, "yes") || mystrceq(str, "on")) { *((int *)tmp) = 0; @@ -1882,187 +1068,25 @@ static void conf_parm_set_vid_ctrl(struct ctx_cam *cam, const char *config_val, return; } -static void conf_camera(struct ctx_cam *cam, const char *str) { - - int indx_cams; - FILE *fp; - - fp = fopen(str, "r"); - if (!fp) { - MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO - ,_("Camera config file %s not found"), str); - return; - } - - /* Find the current number of threads defined. */ - indx_cams = 0; - while (cam->motapp->cam_list[indx_cams] != NULL){ - indx_cams++; - }; - - /* Index starts at zero (+1) plus another for our new camera(+2)*/ - cam->motapp->cam_list = (struct ctx_cam **)myrealloc( - cam->motapp->cam_list, sizeof(struct ctx_cam *) * (indx_cams + 2), "config_camera"); - cam->motapp->cam_list[indx_cams] = (struct ctx_cam *)mymalloc(sizeof(struct ctx_cam)); - cam->motapp->cam_list[indx_cams + 1] = NULL; - - /* Copy numeric values and set string pointers to new locations */ - memcpy(cam->motapp->cam_list[indx_cams],cam->motapp->cam_list[0], sizeof(struct ctx_cam)); - conf_malloc_strings(cam->motapp->cam_list[indx_cams]); - - /* Process the camera's config file and notify user on console. */ - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - ,_("Processing camera config file %s"), str); - snprintf(cam->motapp->cam_list[indx_cams]->conf_filename - ,sizeof(cam->motapp->cam_list[indx_cams]->conf_filename),"%s", str); - conf_process(cam->motapp->cam_list[indx_cams], fp); - - /*Cascade new pointers to all cameras. */ - cam->motapp->cam_list[indx_cams]->motapp = cam->motapp; - indx_cams = 0; - while (cam->motapp->cam_list[indx_cams] != NULL){ - cam->motapp->cam_list[indx_cams]->cam_list = cam->motapp->cam_list; - indx_cams++; - } - - /* Finally we close the camera config file. */ - myfclose(fp); - - return; -} - -/** Process camera_dir */ -static void conf_camera_dir(struct ctx_cam *cam, const char *str, int offset) { - DIR *dp; - struct dirent *ep; - size_t name_len; - int i; - - char conf_file[PATH_MAX]; - - dp = opendir(str); - if (dp != NULL) { - while( (ep = readdir(dp)) ) { - name_len = strlen(ep->d_name); - if (name_len > strlen(EXTENSION) && - (strncmp(EXTENSION, - (ep->d_name + name_len - strlen(EXTENSION)), - strlen(EXTENSION)) == 0 - ) - ) - { - memset(conf_file, '\0', sizeof(conf_file)); - snprintf(conf_file, sizeof(conf_file) - 1, "%s/%s", - str, ep->d_name); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - ,_("Processing config file %s"), conf_file ); - conf_camera(cam, conf_file); - /* The last ctx_cam thread would be ours, - * set it as created from conf directory. - */ - i = 0; - while (cam->motapp->cam_list[++i]); - cam->motapp->cam_list[i-1]->from_conf_dir = 1; - } - } - closedir(dp); - } else { - MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO - ,_("Camera directory config %s not found"), str); - } - - /* Store the given config value to allow writing it out */ - conf_parm_set_string(cam, str, offset); - - return; -} - -static void conf_edit_framerate(struct ctx_cam *cam, const char *arg1) { - int parm; - - parm = atoi(arg1); - if (parm < 2) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - , _("Invalid framerate using minimum value of 2")); - parm = 2; - } else if (parm >100) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - , _("Invalid framerate using maximum value of 100")); - parm = 100; - } - - cam->conf.framerate = parm; -} - -static void conf_edit_picture_filename(struct ctx_cam *cam, const char *arg1) { - - if (cam->conf.picture_filename != NULL) free(cam->conf.picture_filename); - - if (arg1 == NULL){ - cam->conf.picture_filename = (char*)mymalloc(strlen("%v-%Y%m%d%H%M%S-%q")+1); - snprintf(cam->conf.picture_filename,strlen("%v-%Y%m%d%H%M%S-%q")+1 - ,"%s","%v-%Y%m%d%H%M%S-%q"); - } else { - cam->conf.picture_filename = (char*)mymalloc(strlen(arg1)+1); - snprintf(cam->conf.picture_filename, strlen(arg1)+1, "%s", arg1); - } - -} - -static int conf_edit(struct ctx_cam *cam, const char *cmd, const char *arg1) { - int retcd; - - retcd = 0; - if (mystreq(cmd,"framerate") ){ - conf_edit_framerate(cam, arg1); - } else if (mystreq(cmd,"picture_filename") ){ - conf_edit_picture_filename(cam, arg1); - } else { - retcd = -1; - } - return retcd; - -} - -static int conf_parm_set_current(struct ctx_cam *cam, const char *cmd, const char *arg1) { +/* +static int conf_parm_set_current(struct ctx_cam *cam, const char *cmd, char *arg1) { int indx = 0; - if (conf_edit(cam,cmd,arg1) == 0) return 0; - while (config_parms[indx].parm_name != NULL) { if (mystreq(cmd, config_parms[indx].parm_name)) { - - if (mystreq(config_parms[indx].parm_name,"camera")) { - conf_camera(cam, arg1); - - } else if (mystreq(config_parms[indx].parm_name,"camera_dir")) { - conf_camera_dir(cam, arg1, config_parms[indx].parm_offset); - - } else if (config_parms[indx].parm_type == PARM_TYPE_BOOL) { - conf_parm_set_bool(cam, arg1, config_parms[indx].parm_offset); - - } else if (config_parms[indx].parm_type == PARM_TYPE_INT) { - conf_parm_set_int(cam, arg1, config_parms[indx].parm_offset); - - } else if (config_parms[indx].parm_type == PARM_TYPE_STRING) { - conf_parm_set_string(cam, arg1, config_parms[indx].parm_offset); - - } else if (config_parms[indx].parm_type == PARM_TYPE_URI) { - conf_parm_set_uri(cam, arg1, config_parms[indx].parm_offset); - - } else { - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO - , _("Coding error \"%s\""), config_parms[indx].parm_name); - } + conf_edit_set(cam, cmd, arg1, config_parms[indx].parm_cat, FALSE); return 0; } indx++; } + return 0; return -1; } -static int conf_parm_set_depreciated(struct ctx_cam *cam, const char *cmd, const char *arg1) { +static int conf_parm_set_depreciated(struct ctx_cam *cam, const char *cmd, char *arg1) { + + return 0; int indx = 0; @@ -2080,26 +1104,14 @@ static int conf_parm_set_depreciated(struct ctx_cam *cam, const char *cmd, const conf_parm_set_vid_ctrl(cam, arg1, indx); } else if (mystreq(config_parms_depr[indx].parm_name,"webcontrol_html_output")) { - conf_parm_set_html_output(cam, arg1, config_parms[indx].parm_offset); - + //conf_parm_set_html_output(cam, arg1, config_parms[indx].parm_offset); + conf_parm_set_html_output(cam, arg1, 0); } else if (mystreq(config_parms_depr[indx].parm_name,"text_double")) { - conf_parm_set_text_double(cam, arg1, config_parms[indx].parm_offset); - + //conf_parm_set_text_double(cam, arg1, config_parms[indx].parm_offset); + conf_parm_set_text_double(cam, arg1, 0); } else if (mystreq(config_parms_depr[indx].parm_name,"thread")) { conf_camera(cam, arg1); - } else if (config_parms_depr[indx].parm_type == PARM_TYPE_BOOL) { - conf_parm_set_bool(cam, arg1, config_parms[indx].parm_offset); - - } else if (config_parms_depr[indx].parm_type == PARM_TYPE_INT) { - conf_parm_set_int(cam, arg1, config_parms[indx].parm_offset); - - } else if (config_parms_depr[indx].parm_type == PARM_TYPE_STRING) { - conf_parm_set_string(cam, arg1, config_parms[indx].parm_offset); - - } else if (config_parms_depr[indx].parm_type == PARM_TYPE_URI) { - conf_parm_set_uri(cam, arg1, config_parms[indx].parm_offset); - } else { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO , _("Coding error \"%s\""), config_parms_depr[indx].parm_name); @@ -2112,8 +1124,7 @@ static int conf_parm_set_depreciated(struct ctx_cam *cam, const char *cmd, const return -1; } -/** Set the parameter to specified value */ -void conf_parm_set(struct ctx_cam *cam, const char *cmd, const char *arg1) { +void conf_parm_set_old(struct ctx_cam *cam, const char *cmd, char *arg1) { if (!cmd) return; @@ -2125,16 +1136,16 @@ void conf_parm_set(struct ctx_cam *cam, const char *cmd, const char *arg1) { return; } +*/ /** Process each line from the config file. */ -static void conf_process(struct ctx_cam *cam, FILE *fp) { +void conf_process(struct ctx_motapp *motapp, FILE *fp, int threadnbr) { char line[PATH_MAX], *cmd = NULL, *arg1 = NULL; char *beg = NULL, *end = NULL; while (fgets(line, PATH_MAX-1, fp)) { - if (!(line[0] == '#' || line[0] == ';' || strlen(line) < 2)) {/* skipcomment */ - + if (!(line[0] == '#' || line[0] == ';' || strlen(line) < 2)) { arg1 = NULL; /* Trim white space and any CR or LF at the end of the line. */ @@ -2142,10 +1153,8 @@ static void conf_process(struct ctx_cam *cam, FILE *fp) { while (end >= line && (*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r')){ end--; } - *(end+1) = '\0'; - /* If line is only whitespace we continue to the next line. */ if (strlen(line) == 0) continue; /* Trim leading whitespace from the line and find command. */ @@ -2153,13 +1162,11 @@ static void conf_process(struct ctx_cam *cam, FILE *fp) { while (*beg == ' ' || *beg == '\t'){ beg++; } - cmd = beg; /* Command starts here. */ while (*beg != ' ' && *beg != '\t' && *beg != '=' && *beg != '\0'){ beg++; } - *beg = '\0'; /* Command string terminates here. */ /* Trim space between command and argument. */ @@ -2170,11 +1177,7 @@ static void conf_process(struct ctx_cam *cam, FILE *fp) { beg++; } - /* - * If argument is in "" we will strip them off - * It is important that we can use "" so that we can use - * leading spaces in text_left and text_right. - */ + /* Strip quotes from around arg */ if ((beg[0] == '"' && beg[strlen(beg)-1] == '"') || (beg[0] == '\'' && beg[strlen(beg)-1] == '\'')) { beg[strlen(beg)-1] = '\0'; @@ -2183,228 +1186,32 @@ static void conf_process(struct ctx_cam *cam, FILE *fp) { arg1 = beg; /* Argument starts here */ } - /* Else arg1 stays null pointer */ - - conf_parm_set(cam, cmd, arg1); + /* Ignore camera/dir in sub files */ + if (threadnbr == -1){ + conf_edit_set(motapp, threadnbr, cmd, arg1); + } else { + if (mystreq(cmd,"camera_dir")) { + if (threadnbr == 0) conf_parm_camera_dir(motapp, arg1); + } else if (mystreq(cmd,"camera")) { + if (threadnbr == 0) conf_parm_camera(motapp, arg1); + } else { + conf_edit_set(motapp, threadnbr, cmd, arg1); + } + } } } return; } -static void conf_defaults(struct ctx_cam **cam_list) { - /* - * Copy the template config structure with all the default config values - * into cam_list[0]->conf - */ - - cam_list[0]->conf.setup_mode = FALSE; - cam_list[0]->conf.pid_file = NULL; - cam_list[0]->conf.log_file = NULL; - cam_list[0]->conf.log_level = LEVEL_DEFAULT+10; - cam_list[0]->conf.log_type = NULL; - cam_list[0]->conf.quiet = TRUE; - cam_list[0]->conf.native_language = TRUE; - cam_list[0]->conf.camera_name = NULL; - cam_list[0]->conf.camera_id = 0; - cam_list[0]->conf.camera_dir = NULL; - cam_list[0]->conf.target_dir = NULL; - - /* Capture device configuration parameters */ - cam_list[0]->conf.video_device = "/dev/video0"; - cam_list[0]->conf.vid_control_params = NULL; - cam_list[0]->conf.v4l2_palette = 17; - cam_list[0]->conf.input = -1; - cam_list[0]->conf.norm = 0; - cam_list[0]->conf.frequency = 0; - cam_list[0]->conf.roundrobin_frames = 1; - cam_list[0]->conf.roundrobin_skip = 1; - cam_list[0]->conf.roundrobin_switchfilter = FALSE; - - cam_list[0]->conf.netcam_url = NULL; - cam_list[0]->conf.netcam_highres = NULL; - cam_list[0]->conf.netcam_userpass = NULL; - cam_list[0]->conf.netcam_keepalive = "off"; - cam_list[0]->conf.netcam_proxy = NULL; - cam_list[0]->conf.netcam_tolerant_check = FALSE; - cam_list[0]->conf.netcam_use_tcp = TRUE; - - cam_list[0]->conf.mmalcam_name = NULL; - cam_list[0]->conf.mmalcam_control_params = NULL; - - /* Image processing configuration parameters */ - cam_list[0]->conf.width = 640; - cam_list[0]->conf.height = 480; - conf_edit_framerate(cam_list[0],"15"); - cam_list[0]->conf.rotate = 0; - cam_list[0]->conf.flip_axis = "none"; - cam_list[0]->conf.locate_motion_mode = "off"; - cam_list[0]->conf.locate_motion_style = "box", - cam_list[0]->conf.text_left = NULL; - cam_list[0]->conf.text_right = "%Y-%m-%d\\n%T"; - cam_list[0]->conf.text_changes = FALSE; - cam_list[0]->conf.text_scale = 1; - cam_list[0]->conf.text_event = "%Y%m%d%H%M%S"; - - /* Motion detection configuration parameters */ - cam_list[0]->conf.emulate_motion = FALSE; - cam_list[0]->conf.threshold = 1500; - cam_list[0]->conf.threshold_maximum = 0; - cam_list[0]->conf.threshold_tune = FALSE; - - cam_list[0]->conf.noise_level = 32; - cam_list[0]->conf.noise_tune = TRUE; - cam_list[0]->conf.despeckle_filter = NULL; - cam_list[0]->conf.area_detect = NULL; - cam_list[0]->conf.mask_file = NULL; - cam_list[0]->conf.mask_privacy = NULL; - cam_list[0]->conf.smart_mask_speed = 0; - cam_list[0]->conf.lightswitch_percent = 0; - cam_list[0]->conf.lightswitch_frames = 5; - cam_list[0]->conf.minimum_motion_frames = 1; - cam_list[0]->conf.event_gap = 60; - cam_list[0]->conf.pre_capture = 0; - cam_list[0]->conf.post_capture = 0; - - /* Script execution configuration parameters */ - cam_list[0]->conf.on_event_start = NULL; - cam_list[0]->conf.on_event_end = NULL; - cam_list[0]->conf.on_picture_save = NULL; - cam_list[0]->conf.on_motion_detected = NULL; - cam_list[0]->conf.on_area_detected = NULL; - cam_list[0]->conf.on_movie_start = NULL; - cam_list[0]->conf.on_movie_end = NULL; - cam_list[0]->conf.on_camera_lost = NULL; - cam_list[0]->conf.on_camera_found = NULL; - - /* Picture output configuration parameters */ - cam_list[0]->conf.picture_output = "off"; - cam_list[0]->conf.picture_output_motion = FALSE; - cam_list[0]->conf.picture_type = "jpeg"; - cam_list[0]->conf.picture_quality = 75; - cam_list[0]->conf.picture_exif = NULL; - conf_edit_picture_filename(cam_list[0], NULL); - - /* Snapshot configuration parameters */ - cam_list[0]->conf.snapshot_interval = 0; - cam_list[0]->conf.snapshot_filename = "%v-%Y%m%d%H%M%S-snapshot"; - - /* Movie output configuration parameters */ - cam_list[0]->conf.movie_output = TRUE; - cam_list[0]->conf.movie_output_motion = FALSE; - cam_list[0]->conf.movie_max_time = 120; - cam_list[0]->conf.movie_bps = 400000; - cam_list[0]->conf.movie_quality = 60; - cam_list[0]->conf.movie_codec = "mkv"; - cam_list[0]->conf.movie_passthrough = FALSE; - cam_list[0]->conf.movie_filename = "%v-%Y%m%d%H%M%S"; - cam_list[0]->conf.movie_extpipe_use = FALSE; - cam_list[0]->conf.movie_extpipe = NULL; - - /* Timelapse movie configuration parameters */ - cam_list[0]->conf.timelapse_interval = 0; - cam_list[0]->conf.timelapse_mode = "daily"; - cam_list[0]->conf.timelapse_fps = 30; - cam_list[0]->conf.timelapse_codec = "mpg"; - cam_list[0]->conf.timelapse_filename = "%Y%m%d-timelapse"; - - /* Loopback device configuration parameters */ - cam_list[0]->conf.video_pipe = NULL; - cam_list[0]->conf.video_pipe_motion = NULL; - - /* Webcontrol configuration parameters */ - cam_list[0]->conf.webcontrol_port = 0; - cam_list[0]->conf.webcontrol_ipv6 = FALSE; - cam_list[0]->conf.webcontrol_localhost = TRUE; - cam_list[0]->conf.webcontrol_parms = 0; - cam_list[0]->conf.webcontrol_interface = 0; - cam_list[0]->conf.webcontrol_auth_method = 0; - cam_list[0]->conf.webcontrol_authentication = NULL; - cam_list[0]->conf.webcontrol_tls = FALSE; - cam_list[0]->conf.webcontrol_cert = NULL; - cam_list[0]->conf.webcontrol_key = NULL; - cam_list[0]->conf.webcontrol_cors_header = NULL; - - /* Live stream configuration parameters */ - cam_list[0]->conf.stream_port = 0; - cam_list[0]->conf.stream_localhost = TRUE; - cam_list[0]->conf.stream_auth_method = 0; - cam_list[0]->conf.stream_authentication = NULL; - cam_list[0]->conf.stream_tls = FALSE; - cam_list[0]->conf.stream_cors_header = NULL; - cam_list[0]->conf.stream_preview_scale = 25; - cam_list[0]->conf.stream_preview_newline = FALSE; - cam_list[0]->conf.stream_preview_method = 0; - cam_list[0]->conf.stream_quality = 50; - cam_list[0]->conf.stream_grey = FALSE; - cam_list[0]->conf.stream_motion = FALSE; - cam_list[0]->conf.stream_maxrate = 1; - cam_list[0]->conf.stream_limit = 0; - - /* Database and SQL configuration parameters */ - cam_list[0]->conf.database_type = NULL; - cam_list[0]->conf.database_dbname = NULL; - cam_list[0]->conf.database_host = "localhost"; - cam_list[0]->conf.database_port = 0; - cam_list[0]->conf.database_user = NULL; - cam_list[0]->conf.database_password = NULL; - cam_list[0]->conf.database_busy_timeout = 0; - - cam_list[0]->conf.sql_log_picture = 0; - cam_list[0]->conf.sql_log_snapshot = 0; - cam_list[0]->conf.sql_log_movie = 0; - cam_list[0]->conf.sql_log_timelapse = 0; - cam_list[0]->conf.sql_query_start = NULL; - cam_list[0]->conf.sql_query_stop = NULL; - cam_list[0]->conf.sql_query = NULL; - - -} - -static const char *conf_parm_get_bool(struct ctx_cam **cam_list, int indx_parm, int indx_thrd) { - int val = config_parms[indx_parm].parm_offset; - - if (indx_thrd && - *(int*)((char *)cam_list[indx_thrd] + val) == *(int*)((char *)cam_list[0] + val)){ - return NULL; - } - - if (*(int*)((char *)cam_list[indx_thrd] + val)){ - return "on"; - } else { - return "off"; - } -} - -static const char *conf_parm_get_int(struct ctx_cam **cam_list, int indx_parm, int indx_thrd){ - static char retval[20]; - int val = config_parms[indx_parm].parm_offset; - - if (indx_thrd && - *(int*)((char *)cam_list[indx_thrd] + val) == *(int*)((char *)cam_list[0] + val)){ - return NULL; - } - - sprintf(retval, "%d", *(int*)((char *)cam_list[indx_thrd] + val)); - - return retval; -} - -static const char *conf_parm_get_string(struct ctx_cam **cam_list, int indx_parm, int indx_thrd) { - int val = config_parms[indx_parm].parm_offset; - const char **cptr0, **cptr1; - - cptr0 = (const char **)((char *)cam_list[0] + val); - cptr1 = (const char **)((char *)cam_list[indx_thrd] + val); - - if ((indx_thrd) && (*cptr0 != NULL) && (*cptr1 != NULL) && (mystreq(*cptr0, *cptr1))){ - return NULL; - } - - return *cptr1; -} static const char *conf_parm_get_camera(struct ctx_cam **cam_list, int indx_parm, int indx_thrd){ + + (void)cam_list; + (void)indx_thrd; + (void)indx_parm; + + /* char *retval; unsigned int i = 0; @@ -2416,7 +1223,6 @@ static const char *conf_parm_get_camera(struct ctx_cam **cam_list, int indx_parm retval[0] = 0; while (cam_list[++i]) { - /* Skip config files loaded from conf directory */ if (cam_list[i]->from_conf_dir) continue; retval = (char*)myrealloc(retval, strlen(retval) + strlen(cam_list[i]->conf_filename) + 10, @@ -2425,47 +1231,32 @@ static const char *conf_parm_get_camera(struct ctx_cam **cam_list, int indx_parm } return NULL; -} - -/** Retrieve the parameter requested */ -const char *conf_parm_get(struct ctx_cam **cam_list, int indx_parm, int indx_thrd){ - - if (config_parms[indx_parm].parm_type == PARM_TYPE_BOOL) { - return conf_parm_get_bool(cam_list, indx_parm, indx_thrd); - - } else if (config_parms[indx_parm].parm_type == PARM_TYPE_INT) { - return conf_parm_get_int(cam_list, indx_parm, indx_thrd); - - } else if ((config_parms[indx_parm].parm_type == PARM_TYPE_STRING) || - (config_parms[indx_parm].parm_type == PARM_TYPE_URI)) { - return conf_parm_get_string(cam_list, indx_parm, indx_thrd); - - } else if ((config_parms[indx_parm].parm_type == PARM_TYPE_CAMERA)) { - return conf_parm_get_camera(cam_list, indx_parm, indx_thrd); - - } else { - return NULL; - } - + */ + return NULL; } /** Write the configuration(s) to the log */ void conf_parms_log(struct ctx_cam **cam_list) { - int i, t; - const char *parm_val; - - t = 0; - while(cam_list[++t]); + int i, threadnbr, diff_val; + char parm_val[PATH_MAX], parm_main[PATH_MAX]; MOTION_LOG(INF, TYPE_ALL, NO_ERRNO - ,_("Writing configuration parameters from all files (%d):"), t); - for (t = 0; cam_list[t]; t++) { + ,_("Writing configuration parameters from all files")); + threadnbr = 0; + while (cam_list[threadnbr]!= NULL){ motion_log(INF, TYPE_ALL, NO_ERRNO,0 - ,_("Camera %d - Config file: %s"), t, cam_list[t]->conf_filename); + ,_("Camera %d - Config file: %s"), threadnbr, cam_list[threadnbr]->conf_filename); i = 0; while (config_parms[i].parm_name != NULL) { - parm_val = conf_parm_get(cam_list, i, t); - if (parm_val != NULL) { + diff_val = TRUE; + conf_edit_get(cam_list[threadnbr], config_parms[i].parm_name + , parm_val ,config_parms[i].parm_cat); + if (threadnbr > 0){ + conf_edit_get(cam_list[0], config_parms[i].parm_name + , parm_main ,config_parms[i].parm_cat); + if (mystreq(parm_val, parm_main)) diff_val = FALSE; + } + if (diff_val) { if (mystreq(config_parms[i].parm_name, "netcam_url") || mystreq(config_parms[i].parm_name, "netcam_userpass") || mystreq(config_parms[i].parm_name, "netcam_highres") || @@ -2490,20 +1281,16 @@ void conf_parms_log(struct ctx_cam **cam_list) { , config_parms[i].parm_name, parm_val); } } - } else { - if (t == 0) { - motion_log(INF, TYPE_ALL, NO_ERRNO,0, "%-25s " - , config_parms[i].parm_name); - } } i++; } + threadnbr++; } } /** Write the configuration(s) to file */ void conf_parms_write(struct ctx_cam **cam_list) { - const char *retval; + char parm_val[PATH_MAX]; int i, thread; char timestamp[32]; FILE *conffile; @@ -2526,18 +1313,19 @@ void conf_parms_write(struct ctx_cam **cam_list) { fprintf(conffile, "\n\n"); for (i = 0; config_parms[i].parm_name; i++) { - retval = conf_parm_get(cam_list, i, thread); + conf_edit_get(cam_list[i], config_parms[i].parm_name + , parm_val, config_parms[i].parm_cat); /* If config parameter has a value (not NULL) print it to the config file. */ - if (retval) { + if (parm_val) { fprintf(conffile, "%s\n", config_parms[i].parm_help); /* * If the option is a text_* and first char is a space put * quotation marks around to allow leading spaces. */ - if (strncmp(config_parms[i].parm_name, "text", 4) || strncmp(retval, " ", 1)){ - fprintf(conffile, "%s %s\n\n", config_parms[i].parm_name, retval); + if (strncmp(config_parms[i].parm_name, "text", 4) || strncmp(parm_val, " ", 1)){ + fprintf(conffile, "%s %s\n\n", config_parms[i].parm_name, parm_val); } else { - fprintf(conffile, "%s \"%s\"\n\n", config_parms[i].parm_name, retval); + fprintf(conffile, "%s \"%s\"\n\n", config_parms[i].parm_name, parm_val); } } else { if (thread == 0) { @@ -2561,136 +1349,121 @@ void conf_parms_write(struct ctx_cam **cam_list) { } } -void conf_init(struct ctx_motapp *motapp, int argc, char *argv[]){ +void conf_init_app(struct ctx_motapp *motapp, int argc, char *argv[]){ FILE *fp = NULL; char filename[PATH_MAX]; - int i; + char path[PATH_MAX]; + int i, retcd; - /* Create the starting cam_list. The last entry must be NULL */ - motapp->cam_list = (struct ctx_cam**)calloc(sizeof(struct ctx_cam *), 2); + motapp->argc = argc; + motapp->argv = argv; + conf_edit_dflt_app(motapp); - motapp->cam_list[0] = (struct ctx_cam *)mymalloc(sizeof(struct ctx_cam)); - memset(motapp->cam_list[0], 0, sizeof(struct ctx_cam)); - motapp->cam_list[1] = NULL; + conf_cmdline(motapp); - /* Minimum required initial values. Most defaults set in - * motion_init_defaults at start of motion_loop - */ - motapp->cam_list[0]->motapp = motapp; - motapp->cam_list[0]->cam_list = motapp->cam_list; - motapp->cam_list[0]->conf.argv = argv; - motapp->cam_list[0]->conf.argc = argc; - - conf_defaults(motapp->cam_list); - - /* - * For each member of cam_list[0] which is a pointer to a string - * if the member points to a string in conf_template and is not NULL. - * 1. Reserve (malloc) memory for the string. - * 2. Copy the conf_template given string to the reserved memory. - * 3. Change the cam_list[0] member (char*) pointing to the string in reserved memory. - * This ensures that we can free and malloc the string when changed - * via http remote control or config file or Command-line options. - */ - conf_malloc_strings(motapp->cam_list[0]); - - /* - * Open the motion.conf file. We try in this sequence: - * 1. Command-line - * 2. current working directory - * 3. $HOME/.motion/motion.conf - * 4. sysconfdir/motion.conf - */ - /* Get filename , pid file & log file from Command-line. */ - - conf_cmdline(motapp->cam_list[0], -1); - - if (motapp->cam_list[0]->conf_filename[0]) { /* User has supplied filename on Command-line. */ - strncpy(filename, motapp->cam_list[0]->conf_filename, PATH_MAX-1); - filename[PATH_MAX-1] = '\0'; - fp = fopen (filename, "r"); + if (strlen(motapp->conf_filename) >0) { + retcd = snprintf(filename, PATH_MAX, "%s", motapp->conf_filename); + if ((retcd < 0) || (retcd > PATH_MAX)){ + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); + exit(-1); + } + fp = fopen (filename, "r"); } - if (!fp) { /* Command-line didn't work, try current dir. */ - char path[PATH_MAX]; - - if (motapp->cam_list[0]->conf_filename[0]){ - MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO - ,_("Configfile %s not found - trying defaults.") - ,filename); - } - + if (!fp) { if (getcwd(path, sizeof(path)) == NULL) { MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error getcwd")); exit(-1); } - - snprintf(filename, PATH_MAX, "%.*s/motion.conf" - , (int)(PATH_MAX-1-strlen("/motion.conf")) - , path); + retcd = snprintf(filename, PATH_MAX, "%s/motion.conf", path); + if ((retcd < 0) || (retcd > PATH_MAX)){ + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); + exit(-1); + } fp = fopen (filename, "r"); } - if (!fp) { /* Specified file does not exist... try default file. */ - snprintf(filename, PATH_MAX, "%s/.motion/motion.conf", getenv("HOME")); - fp = fopen(filename, "r"); - - if (!fp) { - snprintf(filename, PATH_MAX, "%s/motion.conf", sysconfdir); - fp = fopen(filename, "r"); - - if (!fp){ /* There is no config file.... use defaults. */ - MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO - ,_("could not open configfile %s") - ,filename); - } + if (!fp) { + retcd = snprintf(filename, PATH_MAX, "%s/.motion/motion.conf", getenv("HOME")); + if ((retcd < 0) || (retcd > PATH_MAX)){ + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); + exit(-1); } + fp = fopen(filename, "r"); + } + + if (!fp) { + retcd = snprintf(filename, PATH_MAX, "%s/motion.conf", sysconfdir); + if ((retcd < 0) || (retcd > PATH_MAX)){ + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); + exit(-1); + } + fp = fopen(filename, "r"); + } + + if (!fp){ + MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO + ,_("could not open configfile %s") + ,filename); } /* Now we process the motion.conf config file and close it. */ if (fp) { - strncpy(motapp->cam_list[0]->conf_filename, filename - , sizeof(motapp->cam_list[0]->conf_filename) - 1); - motapp->cam_list[0]->conf_filename[sizeof(motapp->cam_list[0]->conf_filename) - 1] = '\0'; + retcd = snprintf(motapp->conf_filename, PATH_MAX, "%s", filename); + if ((retcd < 0) || (retcd > PATH_MAX)){ + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error setting filename")); + exit(-1); + } + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO,_("Processing config file %s"), filename); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - ,_("Processing thread 0 - config file %s"), filename); + conf_process(motapp, fp, -1); - conf_process(motapp->cam_list[0], fp); - - myfclose(fp); + myfclose(fp); } else { MOTION_LOG(CRT, TYPE_ALL, NO_ERRNO ,_("No config file to process, using default values")); } - /* Set the application defaults to values in cam_list[0] */ - motapp->daemon = motapp->cam_list[0]->conf.daemon; - if (motapp->cam_list[0]->conf.pid_file){ - snprintf(motapp->pid_file - , sizeof(motapp->pid_file) - , "%s", motapp->cam_list[0]->conf.pid_file); - } - if (motapp->cam_list[0]->conf.log_file){ - snprintf(motapp->log_file - , sizeof(motapp->log_file) - , "%s", motapp->cam_list[0]->conf.log_file); - } - if (motapp->cam_list[0]->conf.log_type){ - snprintf(motapp->log_type_str - , sizeof(motapp->log_type_str) - , "%s", motapp->cam_list[0]->conf.log_type); - } - motapp->log_level = motapp->cam_list[0]->conf.log_level; + return; +} - /*Now update everything with command line overrides */ - i = -1; - while (motapp->cam_list[++i]){ - conf_cmdline(motapp->cam_list[i], i); - motapp->cam_list[i]->motapp = motapp; - motapp->cam_list[i]->cam_list = motapp->cam_list; +void conf_init_cams(struct ctx_motapp *motapp){ + FILE *fp = NULL; + char filename[PATH_MAX]; + int i, retcd; + + motapp->cam_list = (struct ctx_cam**)calloc(sizeof(struct ctx_cam *), 2); + motapp->cam_list[0] = (struct ctx_cam *)mymalloc(sizeof(struct ctx_cam)); + memset(motapp->cam_list[0], 0, sizeof(struct ctx_cam)); + motapp->cam_list[1] = NULL; + + motapp->cam_list[0]->motapp = motapp; + motapp->cam_list[0]->cam_list = motapp->cam_list; + + conf_edit_dflt_cam(motapp->cam_list[0]); + + if (strlen(motapp->conf_filename) > 0) { + retcd = snprintf(motapp->cam_list[0]->conf_filename + ,PATH_MAX,"%s",motapp->conf_filename); + if ((retcd < 0)|| (retcd > PATH_MAX)){ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO + ,_("Error setting file name %s"), filename); + exit(1); + } + fp = fopen (motapp->conf_filename, "r"); } - config_parms_intl(); + + if (fp) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO + ,_("Processing thread 0 - config file %s"), filename); + conf_process(motapp, fp, 0); + myfclose(fp); + } else { + MOTION_LOG(CRT, TYPE_ALL, NO_ERRNO + ,_("No config file to process, using default values")); + } + + motapp->cam_list[0]->pause = motapp->pause; return; } @@ -2699,18 +1472,20 @@ void conf_deinit(struct ctx_motapp *motapp) { int j, indx; void **val; + (void)val; indx = 0; while (motapp->cam_list[indx] != NULL){ /* Free memory allocated for config parameters */ for (j = 0; config_parms[j].parm_name != NULL; j++) { - if ((config_parms[j].parm_type == PARM_TYPE_STRING) || - (config_parms[j].parm_type == PARM_TYPE_URI) ) { + if (FALSE){ + //if ((config_parms[j].parm_type == PARM_TYPE_STRING) || + // (config_parms[j].parm_type == PARM_TYPE_URI) ) { - val = (void **)((char *)motapp->cam_list[indx] + config_parms[j].parm_offset); - if (*val) { - free(*val); - *val = NULL; - } + // val = (void **)((char *)motapp->cam_list[indx] + config_parms[j].parm_offset); + // if (*val) { + // free(*val); + // *val = NULL; + // } } } free(motapp->cam_list[indx]); diff --git a/src/conf.hpp b/src/conf.hpp index 653ae277..4c226add 100644 --- a/src/conf.hpp +++ b/src/conf.hpp @@ -20,42 +20,32 @@ struct ctx_config { /* Overall system configuration parameters */ - int daemon; - int setup_mode; - char *pid_file; - char *log_file; - int log_level; - char *log_type; int quiet; - int native_language; - const char *camera_name; + char *camera_name; int camera_id; - const char *camera_dir; - const char *target_dir; + char *camera_dir; + char *target_dir; /* Capture device configuration parameters */ - const char *video_device; + char *videodevice; char *vid_control_params; int v4l2_palette; int input; int norm; unsigned long frequency; int auto_brightness; - const char *tuner_device; + char *tuner_device; int roundrobin_frames; int roundrobin_skip; int roundrobin_switchfilter; - const char *netcam_url; - const char *netcam_highres; - const char *netcam_userpass; - const char *netcam_keepalive; - const char *netcam_proxy; - int netcam_tolerant_check; + char *netcam_url; + char *netcam_highres; + char *netcam_userpass; int netcam_use_tcp; - const char *mmalcam_name; - const char *mmalcam_control_params; + char *mmalcam_name; + char *mmalcam_control_params; /* Image processing configuration parameters */ int width; @@ -63,14 +53,14 @@ int framerate; int minimum_frame_time; int rotate; - const char *flip_axis; - const char *locate_motion_mode; - const char *locate_motion_style; - const char *text_left; - const char *text_right; + char *flip_axis; + char *locate_motion_mode; + char *locate_motion_style; + char *text_left; + char *text_right; int text_changes; int text_scale; - const char *text_event; + char *text_event; /* Motion detection configuration parameters */ int emulate_motion; @@ -79,10 +69,10 @@ int threshold_tune; int noise_level; int noise_tune; - const char *despeckle_filter; - const char *area_detect; - const char *mask_file; - const char *mask_privacy; + char *despeckle_filter; + char *area_detect; + char *mask_file; + char *mask_privacy; int smart_mask_speed; int lightswitch_percent; int lightswitch_frames; @@ -103,16 +93,16 @@ char *on_camera_found; /* Picture output configuration parameters */ - const char *picture_output; + char *picture_output; int picture_output_motion; - const char *picture_type; + char *picture_type; int picture_quality; - const char *picture_exif; + char *picture_exif; char *picture_filename; /* Snapshot configuration parameters */ int snapshot_interval; - const char *snapshot_filename; + char *snapshot_filename; /* Movie output configuration parameters */ int movie_output; @@ -120,22 +110,22 @@ int movie_max_time; int movie_bps; int movie_quality; - const char *movie_codec; + char *movie_codec; int movie_passthrough; - const char *movie_filename; + char *movie_filename; int movie_extpipe_use; - const char *movie_extpipe; + char *movie_extpipe; /* Timelapse movie configuration parameters */ int timelapse_interval; - const char *timelapse_mode; + char *timelapse_mode; int timelapse_fps; - const char *timelapse_codec; - const char *timelapse_filename; + char *timelapse_codec; + char *timelapse_filename; /* Loopback device configuration parameters */ - const char *video_pipe; - const char *video_pipe_motion; + char *video_pipe; + char *video_pipe_motion; /* Webcontrol configuration parameters */ int webcontrol_port; @@ -144,19 +134,19 @@ int webcontrol_parms; int webcontrol_interface; int webcontrol_auth_method; - const char *webcontrol_authentication; + char *webcontrol_authentication; int webcontrol_tls; - const char *webcontrol_cert; - const char *webcontrol_key; - const char *webcontrol_cors_header; + char *webcontrol_cert; + char *webcontrol_key; + char *webcontrol_cors_header; /* Live stream configuration parameters */ int stream_port; int stream_localhost; int stream_auth_method; - const char *stream_authentication; + char *stream_authentication; int stream_tls; - const char *stream_cors_header; + char *stream_cors_header; int stream_preview_scale; int stream_preview_newline; int stream_preview_method; @@ -164,45 +154,53 @@ int stream_grey; int stream_motion; int stream_maxrate; - int stream_limit; /* Database and SQL configuration parameters */ - const char *database_type; - const char *database_dbname; - const char *database_host; + char *database_type; + char *database_dbname; + char *database_host; int database_port; - const char *database_user; - const char *database_password; + char *database_user; + char *database_password; int database_busy_timeout; - int sql_log_picture; - int sql_log_snapshot; - int sql_log_movie; - int sql_log_timelapse; - const char *sql_query_start; - const char *sql_query_stop; - const char *sql_query; + int sql_log_picture; + int sql_log_snapshot; + int sql_log_movie; + int sql_log_timelapse; + char *sql_query_start; + char *sql_query_stop; + char *sql_query; - /* Command line parameters */ - int argc; - char **argv; + int track_type; + int track_auto; + int track_step_angle_x; + int track_step_angle_y; + int track_move_wait; + char *track_generic_move; }; - enum PARM_TYPE{ - PARM_TYPE_BOOL, - PARM_TYPE_INT, - PARM_TYPE_STRING, - PARM_TYPE_URI, - PARM_TYPE_CAMERA + enum PARM_CAT{ + PARM_CAT_00 + ,PARM_CAT_01 + ,PARM_CAT_02 + ,PARM_CAT_03 + ,PARM_CAT_04 + ,PARM_CAT_05 + }; + enum PARM_TYP{ + PARM_TYP_STRING + ,PARM_TYP_INT + ,PARM_TYP_BOOL }; /** Current parameters in the config file */ struct ctx_parm { const char *parm_name; /* name for this parameter */ const char *parm_help; /* short explanation for parameter */ - unsigned int main_thread; /* belong only to main thread when value>0 */ - int parm_offset; /* Offset from ctx_cam pointer to variable */ - enum PARM_TYPE parm_type; /* char string of either bool,int,string,etc. */ + int main_thread; /* belong only to main thread when value>0 */ + enum PARM_TYP parm_type; /* char string of either bool,int,string,etc. */ + enum PARM_CAT parm_cat; int webui_level; /* Enum to display in webui: 0,1,2,3,99(always to never)*/ }; @@ -211,19 +209,16 @@ const char *parm_name; /* Name of the deprecated option */ const char *last_version; /* Last version this option was used in */ const char *info; /* Short text on why it was deprecated (removed, replaced with, etc) */ - int parm_offset; /* Offset from ctx_cam pointer to variable */ const char *newname; /* Name of the new parameter */ - enum PARM_TYPE parm_type; /* char string of either bool,int,string,etc. */ }; extern struct ctx_parm config_parms[]; extern struct ctx_parm_depr config_parms_depr[]; - void conf_init(struct ctx_motapp *motapp, int argc, char *argv[]); + void conf_init_app(struct ctx_motapp *motapp, int argc, char *argv[]); + void conf_init_cams(struct ctx_motapp *motapp); void conf_deinit(struct ctx_motapp *motapp); void conf_parms_log(struct ctx_cam **cam_list); void conf_parms_write(struct ctx_cam **cam_list); - void conf_parm_set(struct ctx_cam *cam, const char *cmd, const char *arg1); - const char *conf_parm_get(struct ctx_cam **cam_list, int indx_parm, int indx_thrd); #endif /* _INCLUDE_CONF_H */ diff --git a/src/conf_edit.cpp b/src/conf_edit.cpp new file mode 100644 index 00000000..775e6e18 --- /dev/null +++ b/src/conf_edit.cpp @@ -0,0 +1,2371 @@ +/* conf_system.cpp + * + * This file is part of the Motion application + * Copyright (C) 2019 Motion-Project Developers(motion-project.github.io) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include "motion.hpp" +#include "util.hpp" +#include "logger.hpp" +#include "conf.hpp" + +enum PARM_ACT{ + PARM_ACT_DFLT + ,PARM_ACT_SET + ,PARM_ACT_GET +}; + +static void conf_edit_get_string(char *parm, char *arg1) { + if (parm == NULL){ + snprintf(arg1, PATH_MAX,"%s",""); + } else { + snprintf(arg1,PATH_MAX,"%s",parm); + } +} +static void conf_edit_get_int(int parm, char *arg1) { + snprintf(arg1, 20, "%d", parm); +} +static void conf_edit_get_bool(int parm, char *arg1) { + if (parm == TRUE){ + snprintf(arg1, PATH_MAX, "%s", "on"); + } else { + snprintf(arg1, PATH_MAX, "%s", "off"); + } +} +static void conf_edit_set_string(char **parm_cam, char *arg1) { + if (*parm_cam != NULL) free(*parm_cam); + if (arg1 == NULL){ + *parm_cam = NULL; + } else { + *parm_cam = (char*)mymalloc(strlen(arg1)+1); + snprintf(*parm_cam, strlen(arg1)+1, "%s", arg1); + } +} + +static void conf_edit_daemon(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + motapp->daemon = FALSE; + } else if (pact == TRUE){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + motapp->daemon = TRUE; + } else { + motapp->daemon = FALSE; + } + } else { + conf_edit_get_bool(motapp->daemon, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","daemon",_("daemon")); +} +static void conf_edit_setup_mode(struct ctx_motapp *motapp, char *arg1, int pact) { + if (pact == PARM_ACT_DFLT){ + motapp->setup_mode = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + motapp->setup_mode = TRUE; + } else { + motapp->setup_mode = FALSE; + } + } else { + conf_edit_get_bool(motapp->setup_mode, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","setup_mode",_("setup_mode")); +} +static void conf_edit_pid_file(struct ctx_motapp *motapp, char *arg1, int pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&motapp->pid_file,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&motapp->pid_file,arg1); + } else { + conf_edit_get_string(motapp->pid_file,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","pid_file",_("pid_file")); +} +static void conf_edit_log_file(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&motapp->log_file,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&motapp->log_file,arg1); + } else { + conf_edit_get_string(motapp->log_file,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_file",_("log_file")); +} +static void conf_edit_log_level(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + motapp->log_level = 6; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 9)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid log_level %d"),parm_in); + } else { + motapp->log_level = parm_in; + } + } else { + conf_edit_get_int(motapp->log_level, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_level",_("log_level")); +} +static void conf_edit_log_type(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&motapp->log_type_str,(char*)"ALL"); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid log_level %s"),motapp->log_type_str); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + conf_edit_set_string(&motapp->log_type_str,(char*)"ALL"); + } else { + if (mystreq(arg1,"ALL") || mystreq(arg1,"COR") || + mystreq(arg1,"STR") || mystreq(arg1,"ENC") || + mystreq(arg1,"NET") || mystreq(arg1,"DBL") || + mystreq(arg1,"EVT") || mystreq(arg1,"TRK") || + mystreq(arg1,"VID") || mystreq(arg1,"ALL")) { + conf_edit_set_string(&motapp->log_type_str, arg1); + } else { + conf_edit_set_string(&motapp->log_type_str,(char*)"ALL"); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid log_level %s"),arg1); + } + } + conf_edit_set_string(&motapp->log_type_str,arg1); + } else { + conf_edit_get_string(motapp->log_type_str,arg1); + } + + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","log_type",_("log_type")); +} +static void conf_edit_native_language(struct ctx_motapp *motapp, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + motapp->native_language = TRUE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + motapp->native_language = TRUE; + } else { + motapp->native_language = FALSE; + } + } else { + conf_edit_get_bool(motapp->native_language, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_changes",_("text_changes")); +} + +static void conf_edit_quiet(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.quiet = TRUE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.quiet = TRUE; + } else { + cam->conf.quiet = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.quiet, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","quiet",_("quiet")); +} +static void conf_edit_camera_name(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.camera_name,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.camera_name,arg1); + } else { + conf_edit_get_string(cam->conf.camera_name,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_name",_("camera_name")); +} +static void conf_edit_camera_id(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.camera_id = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if (parm_in < 0) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid camera_id %d"),parm_in); + } else { + cam->conf.camera_id = parm_in; + } + } else { + conf_edit_get_int(cam->conf.camera_id, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_id",_("camera_id")); +} +static void conf_edit_camera_dir(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.camera_dir,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.camera_dir,arg1); + } else { + conf_edit_get_string(cam->conf.camera_dir,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_dir",_("camera_dir")); +} +static void conf_edit_target_dir(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.target_dir,(char*)"."); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + conf_edit_set_string(&cam->conf.target_dir,(char*)"."); + } else { + conf_edit_set_string(&cam->conf.target_dir,arg1); + } + } else { + conf_edit_get_string(cam->conf.target_dir,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","target_dir",_("target_dir")); +} +static void conf_edit_videodevice(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.videodevice,(char*)"/dev/video0"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + conf_edit_set_string(&cam->conf.videodevice,(char*)"/dev/video0"); + } else { + conf_edit_set_string(&cam->conf.videodevice,arg1); + } + } else { + conf_edit_get_string(cam->conf.videodevice,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","videodevice",_("videodevice")); +} +static void conf_edit_vid_control_params(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.vid_control_params,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.vid_control_params,arg1); + } else { + conf_edit_get_string(cam->conf.vid_control_params,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","vid_control_params",_("vid_control_params")); +} +static void conf_edit_v4l2_palette(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.v4l2_palette = 17; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in >21)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid v4l2_palette %d"),parm_in); + } else { + cam->conf.v4l2_palette = parm_in; + } + } else { + conf_edit_get_int(cam->conf.v4l2_palette, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","v4l2_palette",_("v4l2_palette")); +} +static void conf_edit_input(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.input = -1; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < -1) || (parm_in > 7)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid input %d"),parm_in); + } else { + cam->conf.input = parm_in; + } + } else { + conf_edit_get_int(cam->conf.input, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","input",_("input")); +} +static void conf_edit_norm(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.norm = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 3)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid norm %d"),parm_in); + } else { + cam->conf.norm = parm_in; + } + } else { + conf_edit_get_int(cam->conf.norm, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","norm",_("norm")); +} +static void conf_edit_frequency(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.frequency = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 999999)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid frequency %d"),parm_in); + } else { + cam->conf.frequency = parm_in; + } + } else { + conf_edit_get_int(cam->conf.frequency, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","frequency",_("frequency")); +} +static void conf_edit_auto_brightness(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.auto_brightness = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 3)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid auto_brightness %d"),parm_in); + } else { + cam->conf.auto_brightness = parm_in; + } + } else { + conf_edit_get_int(cam->conf.auto_brightness, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","auto_brightness",_("auto_brightness")); +} +static void conf_edit_tuner_device(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.tuner_device,(char*)"/dev/tuner0"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + conf_edit_set_string(&cam->conf.tuner_device,(char*)"/dev/tuner0"); + } else { + conf_edit_set_string(&cam->conf.tuner_device,arg1); + } + } else { + conf_edit_get_string(cam->conf.tuner_device,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","tuner_device",_("tuner_device")); +} +static void conf_edit_roundrobin_frames(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.roundrobin_frames = 1; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid roundrobin_frames %d"),parm_in); + } else { + cam->conf.roundrobin_frames = parm_in; + } + } else { + conf_edit_get_int(cam->conf.roundrobin_frames, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_frames",_("roundrobin_frames")); +} +static void conf_edit_roundrobin_skip(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.roundrobin_skip = 1; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid roundrobin_skip %d"),parm_in); + } else { + cam->conf.roundrobin_skip = parm_in; + } + } else { + conf_edit_get_int(cam->conf.roundrobin_skip, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_skip",_("roundrobin_skip")); +} +static void conf_edit_roundrobin_switchfilter(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.roundrobin_switchfilter = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.roundrobin_switchfilter = TRUE; + } else { + cam->conf.roundrobin_switchfilter = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.roundrobin_switchfilter, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_switchfilter",_("roundrobin_switchfilter")); +} +static void conf_edit_netcam_url(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.netcam_url,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.netcam_url,arg1); + } else { + conf_edit_get_string(cam->conf.netcam_url,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_url",_("netcam_url")); +} +static void conf_edit_netcam_highres(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.netcam_highres,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.netcam_highres,arg1); + } else { + conf_edit_get_string(cam->conf.netcam_highres,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_highres",_("netcam_highres")); +} +static void conf_edit_netcam_userpass(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.netcam_userpass,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.netcam_userpass,arg1); + } else { + conf_edit_get_string(cam->conf.netcam_userpass,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","netcam_userpass",_("netcam_userpass")); +} +static void conf_edit_netcam_use_tcp(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.netcam_use_tcp = TRUE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.netcam_use_tcp = TRUE; + } else { + cam->conf.netcam_use_tcp = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.netcam_use_tcp, arg1); + } + return; +} +static void conf_edit_mmalcam_name(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.mmalcam_name,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.mmalcam_name,arg1); + } else { + conf_edit_get_string(cam->conf.mmalcam_name,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mmalcam_name",_("mmalcam_name")); +} +static void conf_edit_mmalcam_control_params(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.mmalcam_control_params,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.mmalcam_control_params,arg1); + } else { + conf_edit_get_string(cam->conf.mmalcam_control_params,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mmalcam_control_params",_("mmalcam_control_params")); +} +static void conf_edit_width(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.width = 640; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 64) || (parm_in > 9999)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid width %d"),parm_in); + } else { + cam->conf.width = parm_in; + } + } else { + conf_edit_get_int(cam->conf.width, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","width",_("width")); +} +static void conf_edit_height(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.height = 480; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 64) || (parm_in > 9999)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid height %d"),parm_in); + } else { + cam->conf.height = parm_in; + } + } else { + conf_edit_get_int(cam->conf.height, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","height",_("height")); +} +static void conf_edit_framerate(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.framerate = 15; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 2) || (parm_in > 100)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid framerate %d"),parm_in); + } else { + cam->conf.framerate = parm_in; + } + } else { + conf_edit_get_int(cam->conf.framerate, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","framerate",_("framerate")); +} +static void conf_edit_minimum_frame_time(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.minimum_frame_time = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid minimum_frame_time %d"),parm_in); + } else { + cam->conf.minimum_frame_time = parm_in; + } + } else { + conf_edit_get_int(cam->conf.minimum_frame_time, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","minimum_frame_time",_("minimum_frame_time")); +} +static void conf_edit_rotate(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.rotate = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in != 0) && (parm_in != 90) && + (parm_in != 180) && (parm_in != 270) ) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid rotate %d"),parm_in); + } else { + cam->conf.rotate = parm_in; + } + } else { + conf_edit_get_int(cam->conf.rotate, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","rotate",_("rotate")); +} +static void conf_edit_flip_axis(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.flip_axis,(char*)"none"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid flip_axis %s"),arg1); + } else { + if (mystreq(arg1,"none") || mystreq(arg1,"v") || mystreq(arg1,"h")) { + conf_edit_set_string(&cam->conf.flip_axis, arg1); + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid flip_axis %s"),arg1); + } + } + } else { + conf_edit_get_string(cam->conf.flip_axis,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","flip_axis",_("flip_axis")); +} +static void conf_edit_locate_motion_mode(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.locate_motion_mode,(char*)"off"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_mode %s"),arg1); + } else { + if (mystreq(arg1,"off") || mystreq(arg1,"on") || mystreq(arg1,"preview")) { + conf_edit_set_string(&cam->conf.locate_motion_mode, arg1); + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_mode %s"),arg1); + } + } + } else { + conf_edit_get_string(cam->conf.locate_motion_mode,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","locate_motion_mode",_("locate_motion_mode")); +} +static void conf_edit_locate_motion_style(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.locate_motion_style,(char*)"box"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_style %s"),arg1); + } else { + if (mystreq(arg1,"box") || mystreq(arg1,"redbox") || + mystreq(arg1,"cross") || mystreq(arg1,"redcross")) { + conf_edit_set_string(&cam->conf.locate_motion_style, arg1); + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid locate_motion_style %s"),arg1); + } + } + } else { + conf_edit_get_string(cam->conf.locate_motion_style,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","locate_motion_style",_("locate_motion_style")); +} +static void conf_edit_text_left(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.text_left,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.text_left,arg1); + } else { + conf_edit_get_string(cam->conf.text_left,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_left",_("text_left")); +} +static void conf_edit_text_right(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.text_right,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.text_right,arg1); + } else { + conf_edit_get_string(cam->conf.text_right,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_right",_("text_right")); +} +static void conf_edit_text_changes(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.text_changes = TRUE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.text_changes = TRUE; + } else { + cam->conf.text_changes = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.text_changes, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_changes",_("text_changes")); +} +static void conf_edit_text_scale(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.text_scale = 1; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 10)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid text_scale %d"),parm_in); + } else { + cam->conf.text_scale = parm_in; + } + } else { + conf_edit_get_int(cam->conf.text_scale, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_scale",_("text_scale")); +} +static void conf_edit_text_event(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.text_event,(char*)"%Y%m%d%H%M%S"); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.text_event,arg1); + } else { + conf_edit_get_string(cam->conf.text_event,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_event",_("text_event")); +} + +static void conf_edit_emulate_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.emulate_motion = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.emulate_motion = TRUE; + } else { + cam->conf.emulate_motion = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.emulate_motion, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","emulate_motion",_("emulate_motion")); +} +static void conf_edit_threshold(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.threshold = 1500; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold %d"),parm_in); + } else { + cam->conf.threshold = parm_in; + } + } else { + conf_edit_get_int(cam->conf.threshold, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold",_("threshold")); +} +static void conf_edit_threshold_maximum(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.threshold_maximum = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) ) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold_maximum %d"),parm_in); + } else { + cam->conf.threshold_maximum = parm_in; + } + } else { + conf_edit_get_int(cam->conf.threshold_maximum, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_maximum",_("threshold_maximum")); +} +static void conf_edit_threshold_tune(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.threshold_tune = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.threshold_tune = TRUE; + } else { + cam->conf.threshold_tune = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.threshold_tune, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_tune",_("threshold_tune")); +} +static void conf_edit_noise_level(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.noise_level = 32; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 255)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid noise_level %d"),parm_in); + } else { + cam->conf.noise_level = parm_in; + } + } else { + conf_edit_get_int(cam->conf.noise_level, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","noise_level",_("noise_level")); +} +static void conf_edit_noise_tune(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.noise_tune = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.noise_tune = TRUE; + } else { + cam->conf.noise_tune = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.noise_tune, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","noise_tune",_("noise_tune")); +} +static void conf_edit_despeckle_filter(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.despeckle_filter,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.despeckle_filter,arg1); + } else { + conf_edit_get_string(cam->conf.despeckle_filter,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","despeckle_filter",_("despeckle_filter")); +} +static void conf_edit_area_detect(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.area_detect,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.area_detect,arg1); + } else { + conf_edit_get_string(cam->conf.area_detect,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","area_detect",_("area_detect")); +} +static void conf_edit_mask_file(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.mask_file,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.mask_file,arg1); + } else { + conf_edit_get_string(cam->conf.mask_file,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mask_file",_("mask_file")); +} +static void conf_edit_mask_privacy(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.mask_privacy,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.mask_privacy,arg1); + } else { + conf_edit_get_string(cam->conf.mask_privacy,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mask_privacy",_("mask_privacy")); +} +static void conf_edit_smart_mask_speed(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.smart_mask_speed = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 10)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid smart_mask_speed %d"),parm_in); + } else { + cam->conf.smart_mask_speed = parm_in; + } + } else { + conf_edit_get_int(cam->conf.smart_mask_speed, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","smart_mask_speed",_("smart_mask_speed")); +} +static void conf_edit_lightswitch_percent(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.lightswitch_percent = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 100)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid lightswitch_percent %d"),parm_in); + } else { + cam->conf.lightswitch_percent = parm_in; + } + } else { + conf_edit_get_int(cam->conf.lightswitch_percent, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","lightswitch_percent",_("lightswitch_percent")); +} +static void conf_edit_lightswitch_frames(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.lightswitch_frames = 5; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 1000)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid lightswitch_frames %d"),parm_in); + } else { + cam->conf.lightswitch_frames = parm_in; + } + } else { + conf_edit_get_int(cam->conf.lightswitch_frames, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","lightswitch_frames",_("lightswitch_frames")); +} +static void conf_edit_minimum_motion_frames(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.minimum_motion_frames = 1; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 10000)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid minimum_motion_frames %d"),parm_in); + } else { + cam->conf.minimum_motion_frames = parm_in; + } + } else { + conf_edit_get_int(cam->conf.minimum_motion_frames, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","minimum_motion_frames",_("minimum_motion_frames")); +} +static void conf_edit_event_gap(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.event_gap = 60; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid event_gap %d"),parm_in); + } else { + cam->conf.event_gap = parm_in; + } + } else { + conf_edit_get_int(cam->conf.event_gap, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","event_gap",_("event_gap")); +} +static void conf_edit_pre_capture(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.pre_capture = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 10000)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid pre_capture %d"),parm_in); + } else { + cam->conf.pre_capture = parm_in; + } + } else { + conf_edit_get_int(cam->conf.pre_capture, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","pre_capture",_("pre_capture")); +} +static void conf_edit_post_capture(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.post_capture = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid post_capture %d"),parm_in); + } else { + cam->conf.post_capture = parm_in; + } + } else { + conf_edit_get_int(cam->conf.post_capture, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","post_capture",_("post_capture")); +} + +static void conf_edit_on_event_start(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_event_start,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_event_start,arg1); + } else { + conf_edit_get_string(cam->conf.on_event_start,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_event_start",_("on_event_start")); +} +static void conf_edit_on_event_end(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_event_end,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_event_end,arg1); + } else { + conf_edit_get_string(cam->conf.on_event_end,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_event_end",_("on_event_end")); +} +static void conf_edit_on_picture_save(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_picture_save,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_picture_save,arg1); + } else { + conf_edit_get_string(cam->conf.on_picture_save,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_picture_save",_("on_picture_save")); +} +static void conf_edit_on_area_detected(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_area_detected,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_area_detected,arg1); + } else { + conf_edit_get_string(cam->conf.on_area_detected,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_area_detected",_("on_area_detected")); +} +static void conf_edit_on_motion_detected(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_motion_detected,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_motion_detected,arg1); + } else { + conf_edit_get_string(cam->conf.on_motion_detected,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_motion_detected",_("on_motion_detected")); +} +static void conf_edit_on_movie_start(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_movie_start,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_movie_start,arg1); + } else { + conf_edit_get_string(cam->conf.on_movie_start,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_movie_start",_("on_movie_start")); +} +static void conf_edit_on_movie_end(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_movie_end,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_movie_end,arg1); + } else { + conf_edit_get_string(cam->conf.on_movie_end,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_movie_end",_("on_movie_end")); +} +static void conf_edit_on_camera_lost(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_camera_lost,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_camera_lost,arg1); + } else { + conf_edit_get_string(cam->conf.on_camera_lost,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_camera_lost",_("on_camera_lost")); +} +static void conf_edit_on_camera_found(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.on_camera_found,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.on_camera_found,arg1); + } else { + conf_edit_get_string(cam->conf.on_camera_found,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","on_camera_found",_("on_camera_found")); +} + +static void conf_edit_picture_output(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.picture_output,(char*)"off"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_output %s"),arg1); + } else { + if (mystreq(arg1,"on") || mystreq(arg1,"off") || + mystreq(arg1,"first") || mystreq(arg1,"best")) { + conf_edit_set_string(&cam->conf.picture_output, arg1); + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_output %s"),arg1); + } + } + } else { + conf_edit_get_string(cam->conf.picture_output,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_output",_("picture_output")); +} +static void conf_edit_picture_output_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.picture_output_motion = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.picture_output_motion = TRUE; + } else { + cam->conf.picture_output_motion = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.picture_output_motion, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_output_motion",_("picture_output_motion")); +} +static void conf_edit_picture_type(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.picture_type,(char*)"jpeg"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_type %s"),arg1); + } else { + if (mystreq(arg1,"jpeg") || mystreq(arg1,"webp") || + mystreq(arg1,"ppm")) { + conf_edit_set_string(&cam->conf.picture_type, arg1); + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_type %s"),arg1); + } + } + } else { + conf_edit_get_string(cam->conf.picture_type,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_type",_("picture_type")); +} +static void conf_edit_picture_quality(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.picture_quality = 75; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 100)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_quality %d"),parm_in); + } else { + cam->conf.picture_quality = parm_in; + } + } else { + conf_edit_get_int(cam->conf.picture_quality, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_quality",_("picture_quality")); +} +static void conf_edit_picture_exif(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.picture_exif,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.picture_exif,arg1); + } else { + conf_edit_get_string(cam->conf.picture_exif,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_exif",_("picture_exif")); +} +static void conf_edit_picture_filename(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.picture_filename,(char*)"%v-%Y%m%d%H%M%S-%q"); + } else if (pact == PARM_ACT_SET){ + if (arg1 != NULL){ + conf_edit_set_string(&cam->conf.picture_filename,arg1); + } + } else { + conf_edit_get_string(cam->conf.picture_filename,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_filename",_("picture_filename")); +} +static void conf_edit_snapshot_interval(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.snapshot_interval = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid snapshot_interval %d"),parm_in); + } else { + cam->conf.snapshot_interval = parm_in; + } + } else { + conf_edit_get_int(cam->conf.snapshot_interval, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","snapshot_interval",_("snapshot_interval")); +} +static void conf_edit_snapshot_filename(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.snapshot_filename,(char*)"%v-%Y%m%d%H%M%S-snapshot"); + } else if (pact == PARM_ACT_SET){ + if (arg1 != NULL){ + conf_edit_set_string(&cam->conf.snapshot_filename,arg1); + } + } else { + conf_edit_get_string(cam->conf.snapshot_filename,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","snapshot_filename",_("snapshot_filename")); +} + +static void conf_edit_movie_output(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.movie_output = TRUE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.movie_output = TRUE; + } else { + cam->conf.movie_output = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.movie_output, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_output",_("movie_output")); +} +static void conf_edit_movie_output_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.movie_output_motion = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.movie_output_motion = TRUE; + } else { + cam->conf.movie_output_motion = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.movie_output_motion, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_output_motion",_("movie_output_motion")); +} +static void conf_edit_movie_max_time(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.movie_max_time = 120; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid movie_max_time %d"),parm_in); + } else { + cam->conf.movie_max_time = parm_in; + } + } else { + conf_edit_get_int(cam->conf.movie_max_time, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_max_time",_("movie_max_time")); +} +static void conf_edit_movie_bps(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.movie_bps = 400000; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 9999999)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid movie_bps %d"),parm_in); + } else { + cam->conf.movie_bps = parm_in; + } + } else { + conf_edit_get_int(cam->conf.movie_bps, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_bps",_("movie_bps")); +} +static void conf_edit_movie_quality(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.movie_quality = 60; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 100)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid movie_quality %d"),parm_in); + } else { + cam->conf.movie_quality = parm_in; + } + } else { + conf_edit_get_int(cam->conf.movie_quality, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_quality",_("movie_quality")); +} +static void conf_edit_movie_codec(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.movie_codec,(char*)"mkv"); + } else if (pact == PARM_ACT_SET){ + if (arg1 != NULL){ + conf_edit_set_string(&cam->conf.movie_codec,arg1); + } + } else { + conf_edit_get_string(cam->conf.movie_codec,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_codec",_("movie_codec")); +} +static void conf_edit_movie_passthrough(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.movie_passthrough = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.movie_passthrough = TRUE; + } else { + cam->conf.movie_passthrough = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.movie_passthrough, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_passthrough",_("movie_passthrough")); +} +static void conf_edit_movie_filename(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.movie_filename,(char*)"%v-%Y%m%d%H%M%S"); + } else if (pact == PARM_ACT_SET){ + if (arg1 != NULL){ + conf_edit_set_string(&cam->conf.movie_filename,arg1); + } + } else { + conf_edit_get_string(cam->conf.movie_filename,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_filename",_("movie_filename")); +} +static void conf_edit_movie_extpipe_use(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.movie_extpipe_use = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.movie_extpipe_use = TRUE; + } else { + cam->conf.movie_extpipe_use = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.movie_extpipe_use, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_extpipe_use",_("movie_extpipe_use")); +} +static void conf_edit_movie_extpipe(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact){ + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.movie_extpipe,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.movie_extpipe,arg1); + } else { + conf_edit_get_string(cam->conf.movie_extpipe,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_extpipe",_("movie_extpipe")); +} + +static void conf_edit_timelapse_interval(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.timelapse_interval = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_interval %d"),parm_in); + } else { + cam->conf.timelapse_interval = parm_in; + } + } else { + conf_edit_get_int(cam->conf.timelapse_interval, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_interval",_("timelapse_interval")); +} +static void conf_edit_timelapse_mode(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.timelapse_mode,(char*)"daily"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_mode %s"),arg1); + } else { + if (mystreq(arg1,"hourly") || mystreq(arg1,"daily") || + mystreq(arg1,"weekly-sunday") || mystreq(arg1,"weekly-monday") || + mystreq(arg1,"monthly") || mystreq(arg1,"manual")) { + conf_edit_set_string(&cam->conf.timelapse_mode, arg1); + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_mode %s"),arg1); + } + } + } else { + conf_edit_get_string(cam->conf.timelapse_mode,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_mode",_("timelapse_mode")); +} +static void conf_edit_timelapse_fps(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.timelapse_fps = 30; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 2) || (parm_in > 1000)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_fps %d"),parm_in); + } else { + cam->conf.timelapse_fps = parm_in; + } + } else { + conf_edit_get_int(cam->conf.timelapse_fps, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_fps",_("timelapse_fps")); +} +static void conf_edit_timelapse_codec(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.timelapse_codec,(char*)"mpg"); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_codec %s"),arg1); + } else { + if (mystreq(arg1,"mpg") || mystreq(arg1,"mpeg4")) { + conf_edit_set_string(&cam->conf.timelapse_codec, arg1); + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_codec %s"),arg1); + } + } + } else { + conf_edit_get_string(cam->conf.timelapse_codec,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_codec",_("timelapse_codec")); +} +static void conf_edit_timelapse_filename(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.timelapse_filename,(char*)"%Y%m%d-timelapse"); + } else if (pact == PARM_ACT_SET){ + if (arg1 != NULL){ + conf_edit_set_string(&cam->conf.timelapse_filename,arg1); + } + } else { + conf_edit_get_string(cam->conf.timelapse_filename,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_filename",_("timelapse_filename")); +} + +static void conf_edit_video_pipe(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.video_pipe,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.video_pipe,arg1); + } else { + conf_edit_get_string(cam->conf.video_pipe,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","video_pipe",_("video_pipe")); +} +static void conf_edit_video_pipe_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.video_pipe_motion,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.video_pipe_motion,arg1); + } else { + conf_edit_get_string(cam->conf.video_pipe_motion,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","video_pipe_motion",_("video_pipe_motion")); +} + +static void conf_edit_webcontrol_port(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.webcontrol_port = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 65535)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_port %d"),parm_in); + } else { + cam->conf.webcontrol_port = parm_in; + } + } else { + conf_edit_get_int(cam->conf.webcontrol_port, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_port",_("webcontrol_port")); +} +static void conf_edit_webcontrol_ipv6(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.webcontrol_ipv6 = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.webcontrol_ipv6 = TRUE; + } else { + cam->conf.webcontrol_ipv6 = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.webcontrol_ipv6, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_ipv6",_("webcontrol_ipv6")); +} +static void conf_edit_webcontrol_localhost(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.webcontrol_localhost = TRUE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.webcontrol_localhost = TRUE; + } else { + cam->conf.webcontrol_localhost = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.webcontrol_localhost, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_localhost",_("webcontrol_localhost")); +} +static void conf_edit_webcontrol_parms(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.webcontrol_parms = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 3)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_parms %d"),parm_in); + } else { + cam->conf.webcontrol_parms = parm_in; + } + } else { + conf_edit_get_int(cam->conf.webcontrol_parms, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_parms",_("webcontrol_parms")); +} +static void conf_edit_webcontrol_interface(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.webcontrol_interface = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_interface %d"),parm_in); + } else { + cam->conf.webcontrol_interface = parm_in; + } + } else { + conf_edit_get_int(cam->conf.webcontrol_interface, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_interface",_("webcontrol_interface")); +} +static void conf_edit_webcontrol_auth_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.webcontrol_auth_method = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_auth_method %d"),parm_in); + } else { + cam->conf.webcontrol_auth_method = parm_in; + } + } else { + conf_edit_get_int(cam->conf.webcontrol_auth_method, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_auth_method",_("webcontrol_auth_method")); +} +static void conf_edit_webcontrol_authentication(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.webcontrol_authentication,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.webcontrol_authentication,arg1); + } else { + conf_edit_get_string(cam->conf.webcontrol_authentication,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_authentication",_("webcontrol_authentication")); +} +static void conf_edit_webcontrol_tls(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.webcontrol_tls = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.webcontrol_tls = TRUE; + } else { + cam->conf.webcontrol_tls = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.webcontrol_tls, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_tls",_("webcontrol_tls")); +} +static void conf_edit_webcontrol_cert(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.webcontrol_cert,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.webcontrol_cert,arg1); + } else { + conf_edit_get_string(cam->conf.webcontrol_cert,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_cert",_("webcontrol_cert")); +} +static void conf_edit_webcontrol_key(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.webcontrol_key,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.webcontrol_key,arg1); + } else { + conf_edit_get_string(cam->conf.webcontrol_key,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_key",_("webcontrol_key")); +} +static void conf_edit_webcontrol_cors_header(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.webcontrol_cors_header,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.webcontrol_cors_header,arg1); + } else { + conf_edit_get_string(cam->conf.webcontrol_cors_header,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_cors_header",_("webcontrol_cors_header")); +} + +static void conf_edit_stream_port(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_port = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 65535)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_port %d"),parm_in); + } else { + cam->conf.stream_port = parm_in; + } + } else { + conf_edit_get_int(cam->conf.stream_port, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_port",_("stream_port")); +} +static void conf_edit_stream_localhost(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_localhost = TRUE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.stream_localhost = TRUE; + } else { + cam->conf.stream_localhost = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.stream_localhost, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_localhost",_("stream_localhost")); +} +static void conf_edit_stream_auth_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_auth_method = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_auth_method %d"),parm_in); + } else { + cam->conf.stream_auth_method = parm_in; + } + } else { + conf_edit_get_int(cam->conf.stream_auth_method, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_auth_method",_("stream_auth_method")); +} +static void conf_edit_stream_authentication(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.stream_authentication,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.stream_authentication,arg1); + } else { + conf_edit_get_string(cam->conf.stream_authentication,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_authentication",_("stream_authentication")); +} +static void conf_edit_stream_tls(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_tls = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.stream_tls = TRUE; + } else { + cam->conf.stream_tls = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.stream_tls, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_tls",_("stream_tls")); +} +static void conf_edit_stream_cors_header(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.stream_cors_header,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.stream_cors_header,arg1); + } else { + conf_edit_get_string(cam->conf.stream_cors_header,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_cors_header",_("stream_cors_header")); +} +static void conf_edit_stream_preview_scale(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_preview_scale = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 1000)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_preview_scale %d"),parm_in); + } else { + cam->conf.stream_preview_scale = parm_in; + } + } else { + conf_edit_get_int(cam->conf.stream_preview_scale, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_scale",_("stream_preview_scale")); +} +static void conf_edit_stream_preview_newline(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_preview_newline = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.stream_preview_newline = TRUE; + } else { + cam->conf.stream_preview_newline = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.stream_preview_newline, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_newline",_("stream_preview_newline")); +} +static void conf_edit_stream_preview_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_preview_method = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 4)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_preview_method %d"),parm_in); + } else { + cam->conf.stream_preview_method = parm_in; + } + } else { + conf_edit_get_int(cam->conf.stream_preview_method, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_method",_("stream_preview_method")); +} +static void conf_edit_stream_quality(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_quality = 50; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 100)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_quality %d"),parm_in); + } else { + cam->conf.stream_quality = parm_in; + } + } else { + conf_edit_get_int(cam->conf.stream_quality, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_quality",_("stream_quality")); +} +static void conf_edit_stream_grey(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_grey = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.stream_grey = TRUE; + } else { + cam->conf.stream_grey = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.stream_grey, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_grey",_("stream_grey")); +} +static void conf_edit_stream_motion(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_motion = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.stream_motion = TRUE; + } else { + cam->conf.stream_motion = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.stream_motion, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_motion",_("stream_motion")); +} +static void conf_edit_stream_maxrate(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.stream_maxrate = 1; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 1) || (parm_in > 100)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid stream_maxrate %d"),parm_in); + } else { + cam->conf.stream_maxrate = parm_in; + } + } else { + conf_edit_get_int(cam->conf.stream_maxrate, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_maxrate",_("stream_maxrate")); +} +static void conf_edit_database_type(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.database_type,NULL); + } else if (pact == PARM_ACT_SET){ + if (arg1 == NULL){ + conf_edit_set_string(&cam->conf.database_type, NULL); + } else { + if (mystreq(arg1,"mysql") || mystreq(arg1,"postgresql") || mystreq(arg1,"sqlite3")) { + conf_edit_set_string(&cam->conf.database_type, arg1); + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid database_type %s"),arg1); + } + } + } else { + conf_edit_get_string(cam->conf.database_type,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_type",_("database_type")); +} +static void conf_edit_database_dbname(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.database_dbname,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.database_dbname,arg1); + } else { + conf_edit_get_string(cam->conf.database_dbname,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_dbname",_("database_dbname")); +} +static void conf_edit_database_host(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.database_host,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.database_host,arg1); + } else { + conf_edit_get_string(cam->conf.database_host,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_host",_("database_host")); +} +static void conf_edit_database_port(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.database_port = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 65535)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid database_port %d"),parm_in); + } else { + cam->conf.database_port = parm_in; + } + } else { + conf_edit_get_int(cam->conf.database_port, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_port",_("database_port")); +} +static void conf_edit_database_user(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.database_user,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.database_user,arg1); + } else { + conf_edit_get_string(cam->conf.database_user,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_user",_("database_user")); +} +static void conf_edit_database_password(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.database_password,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.database_password,arg1); + } else { + conf_edit_get_string(cam->conf.database_password,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_password",_("database_password")); +} +static void conf_edit_database_busy_timeout(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.database_busy_timeout = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 10000)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid database_busy_timeout %d"),parm_in); + } else { + cam->conf.database_busy_timeout = parm_in; + } + } else { + conf_edit_get_int(cam->conf.database_busy_timeout, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_busy_timeout",_("database_busy_timeout")); +} + +static void conf_edit_sql_log_picture(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.sql_log_picture = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.sql_log_picture = TRUE; + } else { + cam->conf.sql_log_picture = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.sql_log_picture, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_picture",_("sql_log_picture")); +} +static void conf_edit_sql_log_snapshot(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.sql_log_snapshot = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.sql_log_snapshot = TRUE; + } else { + cam->conf.sql_log_snapshot = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.sql_log_snapshot, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_snapshot",_("sql_log_snapshot")); +} +static void conf_edit_sql_log_movie(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.sql_log_movie = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.sql_log_movie = TRUE; + } else { + cam->conf.sql_log_movie = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.sql_log_movie, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_movie",_("sql_log_movie")); +} +static void conf_edit_sql_log_timelapse(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.sql_log_timelapse = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.sql_log_timelapse = TRUE; + } else { + cam->conf.sql_log_timelapse = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.sql_log_timelapse, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_log_timelapse",_("sql_log_timelapse")); +} +static void conf_edit_sql_query_start(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.sql_query_start,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.sql_query_start,arg1); + } else { + conf_edit_get_string(cam->conf.sql_query_start,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query_start",_("sql_query_start")); +} +static void conf_edit_sql_query_stop(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.sql_query_stop,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.sql_query_stop,arg1); + } else { + conf_edit_get_string(cam->conf.sql_query_stop,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query_stop",_("sql_query_stop")); +} +static void conf_edit_sql_query(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.sql_query,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.sql_query,arg1); + } else { + conf_edit_get_string(cam->conf.sql_query,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query",_("sql_query")); +} + +static void conf_edit_track_type(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.track_type = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 5)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_type %d"),parm_in); + } else { + cam->conf.track_type = parm_in; + } + } else { + conf_edit_get_int(cam->conf.track_type, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_type",_("track_type")); +} +static void conf_edit_track_auto(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + cam->conf.track_auto = FALSE; + } else if (pact == PARM_ACT_SET){ + if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { + cam->conf.track_auto = TRUE; + } else { + cam->conf.track_auto = FALSE; + } + } else { + conf_edit_get_bool(cam->conf.track_auto, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_auto",_("track_auto")); +} +static void conf_edit_track_move_wait(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.track_move_wait = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_move_wait %d"),parm_in); + } else { + cam->conf.track_move_wait = parm_in; + } + } else { + conf_edit_get_int(cam->conf.track_move_wait, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_move_wait",_("track_move_wait")); +} +static void conf_edit_track_generic_move(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + if (pact == PARM_ACT_DFLT){ + conf_edit_set_string(&cam->conf.track_generic_move,NULL); + } else if (pact == PARM_ACT_SET){ + conf_edit_set_string(&cam->conf.track_generic_move,arg1); + } else { + conf_edit_get_string(cam->conf.track_generic_move,arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_generic_move",_("track_generic_move")); +} +static void conf_edit_track_step_angle_x(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.track_step_angle_x = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_step_angle_x %d"),parm_in); + } else { + cam->conf.track_step_angle_x = parm_in; + } + } else { + conf_edit_get_int(cam->conf.track_step_angle_x, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_step_angle_x",_("track_step_angle_x")); +} +static void conf_edit_track_step_angle_y(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf.track_step_angle_y = 0; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(arg1); + if ((parm_in < 0) || (parm_in > 2147483647)) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_step_angle_y %d"),parm_in); + } else { + cam->conf.track_step_angle_y = parm_in; + } + } else { + conf_edit_get_int(cam->conf.track_step_angle_y, arg1); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_step_angle_y",_("track_step_angle_y")); +} + + +static void conf_parm_set_uri(struct ctx_cam *cam, const char *str, int offset) { + + (void)cam; + (void)str; + (void)offset; + /* + // A complicated regex to validate a url found here: + // https://stackoverflow.com/questions/38608116/how-to-check-a-specified-string-is-a-valid-url-or-not-using-c-code + const char *regex_str = "^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$"; + + regex_t regex; + if (regcomp(®ex, regex_str, REG_EXTENDED) != 0) { + MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO + ,_("Error compiling regex in copy_uri")); + return; + } + + // A single asterisk is also valid + if (!mystrceq(str, "*") && regexec(®ex, str, 0, NULL, 0) == REG_NOMATCH) { + MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO + ,_("Invalid origin for cors_header")); + regfree(®ex); + return; + } + + regfree(®ex); + */ +} + + +static void conf_edit_cat00(struct ctx_motapp *motapp, const char *cmd, char *arg1, enum PARM_ACT pact) { + if (mystreq(cmd,"daemon") ){ conf_edit_daemon(motapp, arg1, pact); + } else if (mystreq(cmd,"setup_mode")) { conf_edit_setup_mode(motapp, arg1, pact); + } else if (mystreq(cmd,"pid_file")){ conf_edit_pid_file(motapp, arg1, pact); + } else if (mystreq(cmd,"log_file")){ conf_edit_log_file(motapp, arg1, pact); + } else if (mystreq(cmd,"log_level")){ conf_edit_log_level(motapp, arg1, pact); + } else if (mystreq(cmd,"log_type")){ conf_edit_log_type(motapp, arg1, pact); + } else if (mystreq(cmd,"native_language")){ conf_edit_native_language(motapp, arg1, pact); + } + +} +static void conf_edit_cat01(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { + + if (mystreq(cmd,"quiet")){ conf_edit_quiet(cam, arg1, pact); + } else if (mystreq(cmd,"camera_dir")){ conf_edit_camera_dir(cam, arg1, pact); + } else if (mystreq(cmd,"camera_name")){ conf_edit_camera_name(cam, arg1, pact); + } else if (mystreq(cmd,"camera_id")){ conf_edit_camera_id(cam, arg1, pact); + } else if (mystreq(cmd,"target_dir")){ conf_edit_target_dir(cam, arg1, pact); + } else if (mystreq(cmd,"videodevice") ){ conf_edit_videodevice(cam, arg1, pact); + } else if (mystreq(cmd,"vid_control_params")) { conf_edit_vid_control_params(cam, arg1, pact); + } else if (mystreq(cmd,"v4l2_palette")){ conf_edit_v4l2_palette(cam, arg1, pact); + } else if (mystreq(cmd,"input")){ conf_edit_input(cam, arg1, pact); + } else if (mystreq(cmd,"norm")){ conf_edit_norm(cam, arg1, pact); + } else if (mystreq(cmd,"frequency")){ conf_edit_frequency(cam, arg1, pact); + } else if (mystreq(cmd,"auto_brightness")){ conf_edit_auto_brightness(cam, arg1, pact); + } else if (mystreq(cmd,"tuner_device")){ conf_edit_tuner_device(cam, arg1, pact); + } else if (mystreq(cmd,"roundrobin_frames")){ conf_edit_roundrobin_frames(cam, arg1, pact); + } else if (mystreq(cmd,"roundrobin_skip")){ conf_edit_roundrobin_skip(cam, arg1, pact); + } else if (mystreq(cmd,"roundrobin_switchfilter")){ conf_edit_roundrobin_switchfilter(cam, arg1, pact); + } else if (mystreq(cmd,"netcam_url")){ conf_edit_netcam_url(cam, arg1, pact); + } else if (mystreq(cmd,"netcam_highres")){ conf_edit_netcam_highres(cam, arg1, pact); + } else if (mystreq(cmd,"netcam_userpass")){ conf_edit_netcam_userpass(cam, arg1, pact); + } else if (mystreq(cmd,"netcam_use_tcp")){ conf_edit_netcam_use_tcp(cam, arg1, pact); + } else if (mystreq(cmd,"mmalcam_name")){ conf_edit_mmalcam_name(cam, arg1, pact); + } else if (mystreq(cmd,"mmalcam_control_params")){ conf_edit_mmalcam_control_params(cam, arg1, pact); + } + +} +static void conf_edit_cat02(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { + + if (mystreq(cmd,"width")){ conf_edit_width(cam, arg1, pact); + } else if (mystreq(cmd,"height")){ conf_edit_height(cam, arg1, pact); + } else if (mystreq(cmd,"framerate")){ conf_edit_framerate(cam, arg1, pact); + } else if (mystreq(cmd,"minimum_frame_time")){ conf_edit_minimum_frame_time(cam, arg1, pact); + } else if (mystreq(cmd,"rotate")){ conf_edit_rotate(cam, arg1, pact); + } else if (mystreq(cmd,"flip_axis")){ conf_edit_flip_axis(cam, arg1, pact); + } else if (mystreq(cmd,"locate_motion_mode")){ conf_edit_locate_motion_mode(cam, arg1, pact); + } else if (mystreq(cmd,"locate_motion_style")){ conf_edit_locate_motion_style(cam, arg1, pact); + } else if (mystreq(cmd,"text_left")){ conf_edit_text_left(cam, arg1, pact); + } else if (mystreq(cmd,"text_right")){ conf_edit_text_right(cam, arg1, pact); + } else if (mystreq(cmd,"text_changes")){ conf_edit_text_changes(cam, arg1, pact); + } else if (mystreq(cmd,"text_scale")){ conf_edit_text_scale(cam, arg1, pact); + } else if (mystreq(cmd,"text_event")){ conf_edit_text_event(cam, arg1, pact); + } else if (mystreq(cmd,"emulate_motion")){ conf_edit_emulate_motion(cam, arg1, pact); + } else if (mystreq(cmd,"threshold")){ conf_edit_threshold(cam, arg1, pact); + } else if (mystreq(cmd,"threshold_maximum")){ conf_edit_threshold_maximum(cam, arg1, pact); + } else if (mystreq(cmd,"threshold_tune")){ conf_edit_threshold_tune(cam, arg1, pact); + } else if (mystreq(cmd,"noise_level")){ conf_edit_noise_level(cam, arg1, pact); + } else if (mystreq(cmd,"noise_tune")){ conf_edit_noise_tune(cam, arg1, pact); + } else if (mystreq(cmd,"despeckle_filter")){ conf_edit_despeckle_filter(cam, arg1, pact); + } else if (mystreq(cmd,"area_detect")){ conf_edit_area_detect(cam, arg1, pact); + } else if (mystreq(cmd,"mask_file")){ conf_edit_mask_file(cam, arg1, pact); + } else if (mystreq(cmd,"mask_privacy")){ conf_edit_mask_privacy(cam, arg1, pact); + } else if (mystreq(cmd,"smart_mask_speed")){ conf_edit_smart_mask_speed(cam, arg1, pact); + } else if (mystreq(cmd,"lightswitch_percent")){ conf_edit_lightswitch_percent(cam, arg1, pact); + } else if (mystreq(cmd,"lightswitch_frames")){ conf_edit_lightswitch_frames(cam, arg1, pact); + } else if (mystreq(cmd,"minimum_motion_frames")){ conf_edit_minimum_motion_frames(cam, arg1, pact); + } else if (mystreq(cmd,"event_gap")){ conf_edit_event_gap(cam, arg1, pact); + } else if (mystreq(cmd,"pre_capture")){ conf_edit_pre_capture(cam, arg1, pact); + } else if (mystreq(cmd,"post_capture")){ conf_edit_post_capture(cam, arg1, pact); + } + +} +static void conf_edit_cat03(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { + + if (mystreq(cmd,"on_event_start")){ conf_edit_on_event_start(cam, arg1, pact); + } else if (mystreq(cmd,"on_event_end")){ conf_edit_on_event_end(cam, arg1, pact); + } else if (mystreq(cmd,"on_picture_save")){ conf_edit_on_picture_save(cam, arg1, pact); + } else if (mystreq(cmd,"on_area_detected")){ conf_edit_on_area_detected(cam, arg1, pact); + } else if (mystreq(cmd,"on_motion_detected")){ conf_edit_on_motion_detected(cam, arg1, pact); + } else if (mystreq(cmd,"on_movie_start")){ conf_edit_on_movie_start(cam, arg1, pact); + } else if (mystreq(cmd,"on_movie_end")){ conf_edit_on_movie_end(cam, arg1, pact); + } else if (mystreq(cmd,"on_camera_lost")){ conf_edit_on_camera_lost(cam, arg1, pact); + } else if (mystreq(cmd,"on_camera_found")){ conf_edit_on_camera_found(cam, arg1, pact); + } else if (mystreq(cmd,"picture_output")){ conf_edit_picture_output(cam, arg1, pact); + } else if (mystreq(cmd,"picture_output_motion")){ conf_edit_picture_output_motion(cam, arg1, pact); + } else if (mystreq(cmd,"picture_type")){ conf_edit_picture_type(cam, arg1, pact); + } else if (mystreq(cmd,"picture_quality")){ conf_edit_picture_quality(cam, arg1, pact); + } else if (mystreq(cmd,"picture_exif")){ conf_edit_picture_exif(cam, arg1, pact); + } else if (mystreq(cmd,"picture_filename")){ conf_edit_picture_filename(cam, arg1, pact); + } else if (mystreq(cmd,"snapshot_interval")){ conf_edit_snapshot_interval(cam, arg1, pact); + } else if (mystreq(cmd,"snapshot_filename")){ conf_edit_snapshot_filename(cam, arg1, pact); + } else if (mystreq(cmd,"movie_output")){ conf_edit_movie_output(cam, arg1, pact); + } else if (mystreq(cmd,"movie_output_motion")){ conf_edit_movie_output_motion(cam, arg1, pact); + } else if (mystreq(cmd,"movie_max_time")){ conf_edit_movie_max_time(cam, arg1, pact); + } else if (mystreq(cmd,"movie_bps")){ conf_edit_movie_bps(cam, arg1, pact); + } else if (mystreq(cmd,"movie_quality")){ conf_edit_movie_quality(cam, arg1, pact); + } else if (mystreq(cmd,"movie_codec")){ conf_edit_movie_codec(cam, arg1, pact); + } else if (mystreq(cmd,"movie_passthrough")){ conf_edit_movie_passthrough(cam, arg1, pact); + } else if (mystreq(cmd,"movie_filename")){ conf_edit_movie_filename(cam, arg1, pact); + } else if (mystreq(cmd,"movie_extpipe_use")){ conf_edit_movie_extpipe_use(cam, arg1, pact); + } else if (mystreq(cmd,"movie_extpipe")){ conf_edit_movie_extpipe(cam, arg1, pact); + } else if (mystreq(cmd,"timelapse_interval")){ conf_edit_timelapse_interval(cam, arg1, pact); + } else if (mystreq(cmd,"timelapse_mode")){ conf_edit_timelapse_mode(cam, arg1, pact); + } else if (mystreq(cmd,"timelapse_fps")){ conf_edit_timelapse_fps(cam, arg1, pact); + } else if (mystreq(cmd,"timelapse_codec")){ conf_edit_timelapse_codec(cam, arg1, pact); + } else if (mystreq(cmd,"timelapse_filename")){ conf_edit_timelapse_filename(cam, arg1, pact); + } else if (mystreq(cmd,"video_pipe")){ conf_edit_video_pipe(cam, arg1, pact); + } else if (mystreq(cmd,"video_pipe_motion")){ conf_edit_video_pipe_motion(cam, arg1, pact); + } + +} +static void conf_edit_cat04(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { + if (mystreq(cmd,"webcontrol_port")){ conf_edit_webcontrol_port(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_ipv6")){ conf_edit_webcontrol_ipv6(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_localhost")){ conf_edit_webcontrol_localhost(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_parms")){ conf_edit_webcontrol_parms(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_interface")){ conf_edit_webcontrol_interface(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_auth_method")){ conf_edit_webcontrol_auth_method(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_authentication")){ conf_edit_webcontrol_authentication(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_tls")){ conf_edit_webcontrol_tls(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_cert")){ conf_edit_webcontrol_cert(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_key")){ conf_edit_webcontrol_key(cam, arg1, pact); + } else if (mystreq(cmd,"webcontrol_cors_header")){ conf_edit_webcontrol_cors_header(cam, arg1, pact); + } else if (mystreq(cmd,"stream_port")){ conf_edit_stream_port(cam, arg1, pact); + } else if (mystreq(cmd,"stream_localhost")){ conf_edit_stream_localhost(cam, arg1, pact); + } else if (mystreq(cmd,"stream_auth_method")){ conf_edit_stream_auth_method(cam, arg1, pact); + } else if (mystreq(cmd,"stream_authentication")){ conf_edit_stream_authentication(cam, arg1, pact); + } else if (mystreq(cmd,"stream_tls")){ conf_edit_stream_tls(cam, arg1, pact); + } else if (mystreq(cmd,"stream_cors_header")){ conf_edit_stream_cors_header(cam, arg1, pact); + } else if (mystreq(cmd,"stream_preview_scale")){ conf_edit_stream_preview_scale(cam, arg1, pact); + } else if (mystreq(cmd,"stream_preview_newline")){ conf_edit_stream_preview_newline(cam, arg1, pact); + } else if (mystreq(cmd,"stream_preview_method")){ conf_edit_stream_preview_method(cam, arg1, pact); + } else if (mystreq(cmd,"stream_quality")){ conf_edit_stream_quality(cam, arg1, pact); + } else if (mystreq(cmd,"stream_grey")){ conf_edit_stream_grey(cam, arg1, pact); + } else if (mystreq(cmd,"stream_motion")){ conf_edit_stream_motion(cam, arg1, pact); + } else if (mystreq(cmd,"stream_maxrate")){ conf_edit_stream_maxrate(cam, arg1, pact); + } + +} +static void conf_edit_cat05(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_ACT pact) { + if (mystreq(cmd,"database_type")){ conf_edit_database_type(cam, arg1, pact); + } else if (mystreq(cmd,"database_dbname")){ conf_edit_database_dbname(cam, arg1, pact); + } else if (mystreq(cmd,"database_host")){ conf_edit_database_host(cam, arg1, pact); + } else if (mystreq(cmd,"database_port")){ conf_edit_database_port(cam, arg1, pact); + } else if (mystreq(cmd,"database_user")){ conf_edit_database_user(cam, arg1, pact); + } else if (mystreq(cmd,"database_password")){ conf_edit_database_password(cam, arg1, pact); + } else if (mystreq(cmd,"database_busy_timeout")){ conf_edit_database_busy_timeout(cam, arg1, pact); + } else if (mystreq(cmd,"sql_log_picture")){ conf_edit_sql_log_picture(cam, arg1, pact); + } else if (mystreq(cmd,"sql_log_snapshot")){ conf_edit_sql_log_snapshot(cam, arg1, pact); + } else if (mystreq(cmd,"sql_log_movie")){ conf_edit_sql_log_movie(cam, arg1, pact); + } else if (mystreq(cmd,"sql_log_timelapse")){ conf_edit_sql_log_timelapse(cam, arg1, pact); + } else if (mystreq(cmd,"sql_query_start")){ conf_edit_sql_query_start(cam, arg1, pact); + } else if (mystreq(cmd,"sql_query_stop")){ conf_edit_sql_query_stop(cam, arg1, pact); + } else if (mystreq(cmd,"sql_query")){ conf_edit_sql_query(cam, arg1, pact); + } else if (mystreq(cmd,"track_type")){ conf_edit_track_type(cam, arg1, pact); + } else if (mystreq(cmd,"track_auto")){ conf_edit_track_auto(cam, arg1, pact); + } else if (mystreq(cmd,"track_move_wait")){ conf_edit_track_move_wait(cam, arg1, pact); + } else if (mystreq(cmd,"track_generic_move")){ conf_edit_track_generic_move(cam, arg1, pact); + } else if (mystreq(cmd,"track_step_angle_x")){ conf_edit_track_step_angle_x(cam, arg1, pact); + } else if (mystreq(cmd,"track_step_angle_y")){ conf_edit_track_step_angle_y(cam, arg1, pact); + } + +} + +void conf_edit_dflt_app(struct ctx_motapp *motapp) { + motapp->conf_filename = (char*)mymalloc(PATH_MAX); + motapp->log_file = NULL; + motapp->log_type_str = NULL; + motapp->pid_file = NULL; + conf_edit_daemon(motapp, NULL,PARM_ACT_DFLT); + conf_edit_setup_mode(motapp, NULL, PARM_ACT_DFLT); + conf_edit_pid_file(motapp, NULL, PARM_ACT_DFLT); + conf_edit_log_file(motapp, NULL, PARM_ACT_DFLT); + conf_edit_log_level(motapp, NULL, PARM_ACT_DFLT); + conf_edit_log_type(motapp, NULL, PARM_ACT_DFLT); + conf_edit_native_language(motapp, NULL, PARM_ACT_DFLT); + +} +void conf_edit_dflt_cam(struct ctx_cam *cam) { + int indx; + enum PARM_CAT pcat; + + indx = 0; + while (config_parms[indx].parm_name != NULL) { + pcat = config_parms[indx].parm_cat; + if ((config_parms[indx].parm_cat != PARM_CAT_00)) { + if (pcat == PARM_CAT_01) { + conf_edit_cat01(cam, config_parms[indx].parm_name, NULL,PARM_ACT_DFLT); + } else if (pcat == PARM_CAT_02) { + conf_edit_cat02(cam, config_parms[indx].parm_name, NULL, PARM_ACT_DFLT); + } else if (pcat == PARM_CAT_03) { + conf_edit_cat03(cam, config_parms[indx].parm_name, NULL, PARM_ACT_DFLT); + } else if (pcat == PARM_CAT_04) { + conf_edit_cat04(cam, config_parms[indx].parm_name, NULL, PARM_ACT_DFLT); + } else if (pcat == PARM_CAT_05) { + conf_edit_cat05(cam, config_parms[indx].parm_name, NULL, PARM_ACT_DFLT); + } + } + indx++; + } +} + +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr, char *cmd, char *arg1){ + int indx; + enum PARM_CAT pcat; + + indx = 0; + while (config_parms[indx].parm_name != NULL) { + if (mystreq(cmd, config_parms[indx].parm_name)) { + pcat = config_parms[indx].parm_cat; + if ((pcat == PARM_CAT_00) && (threadnbr == -1)) { + conf_edit_cat00(motapp, cmd, arg1, PARM_ACT_SET); + } else if ((config_parms[indx].parm_cat != PARM_CAT_00) && (threadnbr != -1)) { + if (pcat == PARM_CAT_01) { + conf_edit_cat01(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + } else if (pcat == PARM_CAT_02) { + conf_edit_cat02(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + } else if (pcat == PARM_CAT_03) { + conf_edit_cat03(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + } else if (pcat == PARM_CAT_04) { + conf_edit_cat04(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + } else if (pcat == PARM_CAT_05) { + conf_edit_cat05(motapp->cam_list[threadnbr], cmd, arg1, PARM_ACT_SET); + } + } + return; + } + indx++; + } + return; +} + +int conf_edit_get(struct ctx_cam *cam, const char *cmd, char *arg1, enum PARM_CAT pcat) { + int retcd; + + retcd = 0; + if (pcat == PARM_CAT_00) { conf_edit_cat00(cam->motapp, cmd, arg1,PARM_ACT_GET); + } else if (pcat == PARM_CAT_01) { conf_edit_cat01(cam, cmd, arg1, PARM_ACT_GET); + } else if (pcat == PARM_CAT_02) { conf_edit_cat02(cam, cmd, arg1, PARM_ACT_GET); + } else if (pcat == PARM_CAT_03) { conf_edit_cat03(cam, cmd, arg1, PARM_ACT_GET); + } else if (pcat == PARM_CAT_04) { conf_edit_cat04(cam, cmd, arg1, PARM_ACT_GET); + } else if (pcat == PARM_CAT_05) { conf_edit_cat05(cam, cmd, arg1, PARM_ACT_GET); + } else { + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO,"%s",_("Program coding error")); + retcd = -1; + } + return retcd; + if (FALSE){ + conf_parm_set_uri(cam,NULL,0); + } + +} + diff --git a/src/conf_edit.hpp b/src/conf_edit.hpp new file mode 100644 index 00000000..788e5b38 --- /dev/null +++ b/src/conf_edit.hpp @@ -0,0 +1,33 @@ +/* dbse.hpp + * + * This file is part of the Motion application + * Copyright (C) 2019 Motion-Project Developers(motion-project.github.io) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +/* + * Header files for the database functionality. + */ +#ifndef _INCLUDE_CONF_EDIT_H_ +#define _INCLUDE_CONF_EDIT_H_ + +void conf_edit_set(struct ctx_motapp *motapp, int threadnbr, char *cmd, char *arg1); +int conf_edit_get(struct ctx_cam *cam, const char *cmd, char *arg1 , enum PARM_CAT pcat); +void conf_edit_dflt_app(struct ctx_motapp *motapp); +void conf_edit_dflt_cam(struct ctx_cam *cam); + +#endif \ No newline at end of file diff --git a/src/logger.cpp b/src/logger.cpp index 2c0e6852..37be4a2e 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -263,7 +263,6 @@ void log_init(struct ctx_motapp *motapp){ if ((motapp->log_level > ALL) || (motapp->log_level == 0)) { motapp->log_level = LEVEL_DEFAULT; - motapp->cam_list[0]->conf.log_level = motapp->log_level; MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO ,_("Using default log level (%s) (%d)") ,log_get_level_str(motapp->log_level) @@ -273,36 +272,30 @@ void log_init(struct ctx_motapp *motapp){ } - if ((motapp->log_file[0]) && (strncmp(motapp->log_file, "syslog", 6))) { - - log_set_mode(LOGMODE_FILE); - - log_set_logfile(motapp->log_file); - - if (logfile) { - log_set_mode(LOGMODE_SYSLOG); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO - ,_("Logging to file (%s)"),motapp->log_file); + if (motapp->log_file != NULL) { + if (mystrne(motapp->log_file,"syslog")) { log_set_mode(LOGMODE_FILE); + log_set_logfile(motapp->log_file); + if (logfile) { + log_set_mode(LOGMODE_SYSLOG); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO + ,_("Logging to file (%s)"),motapp->log_file); + log_set_mode(LOGMODE_FILE); + } else { + MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO + ,_("Exit motion, cannot create log file %s") + ,motapp->log_file); + exit(0); + } } else { - MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO - ,_("Exit motion, cannot create log file %s") - ,motapp->log_file); - exit(0); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Logging to syslog")); } } else { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Logging to syslog")); } - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "Motion %s Started",VERSION); - if ((motapp->log_type_str[0] == 0) || - !(motapp->log_type = log_get_type(motapp->log_type_str))) { - motapp->log_type = TYPE_DEFAULT; - snprintf(motapp->log_type_str,4,"ALL"); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO,_("Using default log type (%s)"), - log_get_type_str(motapp->log_type)); - } + motapp->log_type = log_get_type(motapp->log_type_str); MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Using log type (%s) log level (%s)"), log_get_type_str(motapp->log_type), log_get_level_str(motapp->log_level)); diff --git a/src/motion.cpp b/src/motion.cpp index f0f027cc..afa74db6 100644 --- a/src/motion.cpp +++ b/src/motion.cpp @@ -149,9 +149,9 @@ static void setup_signals(void){ static void motion_remove_pid(struct ctx_motapp *motapp) { if ((motapp->daemon) && - (motapp->cam_list[0]->conf.pid_file) && + (motapp->pid_file) && (motapp->restart_all == FALSE)) { - if (!unlink(motapp->cam_list[0]->conf.pid_file)){ + if (!unlink(motapp->pid_file)){ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Removed process id file (pid file).")); } else{ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error removing pid file")); @@ -355,22 +355,24 @@ static void motion_ntc(void){ /** Initialize upon start up or restart */ static void motion_startup(struct ctx_motapp *motapp, int daemonize, int argc, char *argv[]) { - conf_init(motapp, argc, argv); + conf_init_app(motapp, argc, argv); log_init(motapp); + conf_init_cams(motapp); + mytranslate_init(); - mytranslate_text("",motapp->cam_list[0]->conf.native_language); + mytranslate_text("",motapp->native_language); if (daemonize) { - if (motapp->daemon && motapp->cam_list[0]->conf.setup_mode == 0) { + if (motapp->daemon && motapp->setup_mode == 0) { motion_daemon(motapp); MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Motion running as daemon process")); } } - if (motapp->cam_list[0]->conf.setup_mode){ + if (motapp->setup_mode){ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO,_("Motion running in setup mode.")); } diff --git a/src/motion.hpp b/src/motion.hpp index e4d48232..8b2a6ae6 100644 --- a/src/motion.hpp +++ b/src/motion.hpp @@ -359,11 +359,9 @@ struct ctx_cam { struct timespec frame_curr_ts; struct timespec frame_last_ts; - time_t currenttime; time_t lasttime; time_t eventtime; time_t connectionlosttime; /* timestamp from connection lost */ - time_t lastframetime; unsigned int lastrate; unsigned int startup_frames; unsigned int frame_skip; @@ -395,15 +393,8 @@ struct ctx_cam { int smartmask_ratio; int smartmask_count; unsigned int smartmask_lastrate; - int previous_diffs, previous_location_x, previous_location_y; - unsigned long int time_last_frame, time_current_frame; - unsigned int passflag; //only purpose is to flag first frame vs all others..... - int rolling_frame; - - struct MHD_Daemon *webcontrol_daemon; - char webcontrol_digest_rand[8]; }; @@ -417,12 +408,18 @@ struct ctx_motapp { volatile int finish_all; volatile int restart_all; + int argc; + char **argv; int daemon; - char pid_file[PATH_MAX]; - char log_file[PATH_MAX]; - char log_type_str[6]; + char *conf_filename; + char *pid_file; + char *log_file; + char *log_type_str; int log_level; - unsigned int log_type; + int log_type; + int setup_mode; + int pause; + int native_language; volatile int webcontrol_running; volatile int webcontrol_finish; diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index d67a6110..2afb4514 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -30,6 +30,7 @@ #include "video_loopback.hpp" #include "netcam.hpp" #include "conf.hpp" +#include "conf_edit.hpp" #include "alg.hpp" #include "track.hpp" #include "event.hpp" @@ -225,7 +226,7 @@ static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *im mlp_detected_trigger(cam, img); if (img->shot < conf->framerate) { - if (conf->stream_motion && !conf->setup_mode && img->shot != 1){ + if (conf->stream_motion && !cam->motapp->setup_mode && img->shot != 1){ event(cam, EVENT_STREAM, img, NULL, NULL, &img->imgts); } if (conf->picture_output_motion){ @@ -233,7 +234,7 @@ static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *im } } - if (cam->track.type && cam->track.active){ + if (cam->conf.track_type && cam->conf.track_auto){ cam->frame_skip = track_move(cam, dev, &img->location, &cam->imgs, 0); } @@ -261,7 +262,7 @@ static int init_camera_type(struct ctx_cam *cam){ return 0; } - if (cam->conf.video_device) { + if (cam->conf.videodevice) { cam->camera_type = CAMERA_TYPE_V4L2; return 0; } @@ -522,7 +523,6 @@ static int mlp_init(struct ctx_cam *cam) { mlp_init_areadetect(cam); - cam->lastframetime = 0; cam->minimum_frame_time_downcounter = cam->conf.minimum_frame_time; cam->get_image = 1; @@ -534,13 +534,9 @@ static int mlp_init(struct ctx_cam *cam) { cam->previous_location_x = 0; cam->previous_location_y = 0; - cam->time_last_frame = 1; - cam->time_current_frame = 0; - cam->smartmask_lastrate = 0; cam->passflag = 0; //only purpose to flag first frame - cam->rolling_frame = 0; if (cam->conf.emulate_motion) { MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, _("Emulating motion")); @@ -751,9 +747,6 @@ static void mlp_prepare(struct ctx_cam *cam){ cam->frame_last_ts.tv_nsec = cam->frame_curr_ts.tv_nsec; clock_gettime(CLOCK_REALTIME, &cam->frame_curr_ts); - if (cam->conf.minimum_motion_frames < 1) - cam->conf.minimum_motion_frames = 1; - if (cam->conf.pre_capture < 0) cam->conf.pre_capture = 0; @@ -762,15 +755,9 @@ static void mlp_prepare(struct ctx_cam *cam){ if (cam->imgs.ring_size != frame_buffer_size) mlp_ring_resize(cam, frame_buffer_size); - /* - * If we have started on a new second we reset the shots variable - * lastrate is updated to be the number of the last frame. last rate - * is used as the ffmpeg framerate when motion is detected. - */ if (cam->frame_last_ts.tv_sec != cam->frame_curr_ts.tv_sec) { cam->lastrate = cam->shots + 1; cam->shots = -1; - cam->lastframetime = cam->currenttime; if (cam->conf.minimum_frame_time) { cam->minimum_frame_time_downcounter--; @@ -781,8 +768,6 @@ static void mlp_prepare(struct ctx_cam *cam){ } } - - /* Increase the shots variable for each frame captured within this second */ cam->shots++; if (cam->startup_frames > 0) @@ -838,7 +823,7 @@ static int mlp_retry(struct ctx_cam *cam){ int size_high; if (cam->video_dev < 0 && - cam->currenttime % 10 == 0 && cam->shots == 0) { + cam->frame_curr_ts.tv_sec % 10 == 0 && cam->shots == 0) { MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO ,_("Retrying until successful connection with camera")); cam->video_dev = vid_start(cam); @@ -971,7 +956,7 @@ static int mlp_capture(struct ctx_cam *cam){ * Don't reset time when thread restarts */ if (cam->connectionlosttime == 0){ - cam->connectionlosttime = cam->currenttime; + cam->connectionlosttime = cam->frame_curr_ts.tv_sec; } @@ -1036,7 +1021,7 @@ static void mlp_detection(struct ctx_cam *cam){ * motion, the alg_diff will trigger alg_diff_standard * anyway */ - if (cam->detecting_motion || cam->conf.setup_mode) + if (cam->detecting_motion || cam->motapp->setup_mode) cam->current_image->diffs = alg_diff_standard(cam, cam->imgs.image_vprvcy); else cam->current_image->diffs = alg_diff(cam, cam->imgs.image_vprvcy); @@ -1103,7 +1088,7 @@ static void mlp_detection(struct ctx_cam *cam){ cam->imgs.labelsize_max = 0; /* Disable labeling if enabled */ } - } else if (!cam->conf.setup_mode) { + } else if (!cam->motapp->setup_mode) { cam->current_image->diffs = 0; } @@ -1206,17 +1191,17 @@ static void mlp_overlay(struct ctx_cam *cam){ /* Smartmask overlay */ if (cam->smartmask_speed && (cam->conf.picture_output_motion || cam->conf.movie_output_motion || - cam->conf.setup_mode || (cam->stream.motion.cnct_count > 0))) + cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0))) draw_smartmask(cam, cam->imgs.image_motion.image_norm); /* Largest labels overlay */ if (cam->imgs.largest_label && (cam->conf.picture_output_motion || cam->conf.movie_output_motion || - cam->conf.setup_mode || (cam->stream.motion.cnct_count > 0))) + cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0))) draw_largest_label(cam, cam->imgs.image_motion.image_norm); /* Fixed mask overlay */ if (cam->imgs.mask && (cam->conf.picture_output_motion || cam->conf.movie_output_motion || - cam->conf.setup_mode || (cam->stream.motion.cnct_count > 0))) + cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0))) draw_fixed_mask(cam, cam->imgs.image_motion.image_norm); /* Add changed pixels in upper right corner of the pictures */ @@ -1234,7 +1219,7 @@ static void mlp_overlay(struct ctx_cam *cam){ * Add changed pixels to motion-images (for stream) in setup_mode * and always overlay smartmask (not only when motion is detected) */ - if (cam->conf.setup_mode || (cam->stream.motion.cnct_count > 0)) { + if (cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0)) { sprintf(tmp, "D:%5d L:%3d N:%3d", cam->current_image->diffs, cam->current_image->total_labels, cam->noise); draw_text(cam->imgs.image_motion.image_norm, cam->imgs.width, cam->imgs.height, @@ -1385,14 +1370,14 @@ static void mlp_actions(struct ctx_cam *cam){ * First test for movie_max_time */ if ((cam->conf.movie_max_time && cam->event_nr == cam->prev_event) && - (cam->currenttime - cam->eventtime >= cam->conf.movie_max_time)) + (cam->frame_curr_ts.tv_sec - cam->eventtime >= cam->conf.movie_max_time)) cam->event_stop = TRUE; /* * Now test for quiet longer than 'gap' OR make movie as decided in * previous statement. */ - if (((cam->currenttime - cam->lasttime >= cam->conf.event_gap) && cam->conf.event_gap > 0) || + if (((cam->frame_curr_ts.tv_sec - cam->lasttime >= cam->conf.event_gap) && cam->conf.event_gap > 0) || cam->event_stop) { if (cam->event_nr == cam->prev_event || cam->event_stop) { @@ -1411,7 +1396,7 @@ static void mlp_actions(struct ctx_cam *cam){ * If tracking is enabled we center our camera so it does not * point to a place where it will miss the next action */ - if (cam->track.type) + if (cam->conf.track_type) cam->frame_skip = track_center(cam, cam->video_dev, 0, 0, 0); MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("End of event %d"), cam->event_nr); @@ -1444,7 +1429,7 @@ static void mlp_actions(struct ctx_cam *cam){ static void mlp_setupmode(struct ctx_cam *cam){ /* If CAMERA_VERBOSE enabled output some numbers to console */ - if (cam->conf.setup_mode) { + if (cam->motapp->setup_mode) { char msg[1024] = "\0"; char part[100]; @@ -1478,9 +1463,6 @@ static void mlp_setupmode(struct ctx_cam *cam){ static void mlp_snapshot(struct ctx_cam *cam){ - /* time_current_frame is used both for snapshot and timelapse features */ - cam->time_current_frame = cam->currenttime; - if ((cam->conf.snapshot_interval > 0 && cam->shots == 0 && cam->frame_curr_ts.tv_sec % cam->conf.snapshot_interval <= cam->frame_last_ts.tv_sec % cam->conf.snapshot_interval) || @@ -1540,7 +1522,8 @@ static void mlp_timelapse(struct ctx_cam *cam){ ,_("Invalid timelapse_mode argument '%s'"), cam->conf.timelapse_mode); MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO ,_("%:s Defaulting to manual timelapse mode")); - conf_parm_set(cam, (char *)"movie_timelapse_mode",(char *)"manual"); + //conf_edit_set(cam, (char *)"movie_timelapse_mode" + // , (char *)"manual", PARM_CAT_03,FALSE); } } @@ -1560,9 +1543,6 @@ static void mlp_timelapse(struct ctx_cam *cam){ event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); } - cam->time_last_frame = cam->time_current_frame; - - } static void mlp_loopback(struct ctx_cam *cam){ @@ -1576,7 +1556,7 @@ static void mlp_loopback(struct ctx_cam *cam){ * 1 frame per second but the minute motion is detected the mlp_detected() function * sends all detected pictures to the stream except the 1st per second which is already sent. */ - if (cam->conf.setup_mode) { + if (cam->motapp->setup_mode) { event(cam, EVENT_IMAGE, &cam->imgs.image_motion, NULL, &cam->pipe, &cam->current_image->imgts); event(cam, EVENT_STREAM, &cam->imgs.image_motion, NULL, NULL, &cam->current_image->imgts); diff --git a/src/netcam.cpp b/src/netcam.cpp index c73d7774..821cba7e 100644 --- a/src/netcam.cpp +++ b/src/netcam.cpp @@ -1106,11 +1106,6 @@ static void netcam_set_path (struct ctx_cam *cam, struct ctx_netcam *netcam ) { netcam_url_parse(&url, cam->conf.netcam_url); } - if (cam->conf.netcam_proxy) { - MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO - ,_("Proxies not supported using for %s"),url.service); - } - if (cam->conf.netcam_userpass != NULL) { userpass = mystrdup(cam->conf.netcam_userpass); } else if (url.userpass != NULL) { diff --git a/src/track.cpp b/src/track.cpp index c360b97d..3e0f7cb9 100644 --- a/src/track.cpp +++ b/src/track.cpp @@ -199,7 +199,7 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) { ,cam->track.pan_angle, cam->track.tilt_angle); } - return cam->track.move_wait; + return cam->conf.track_move_wait; #else return 0; #endif @@ -278,8 +278,8 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent return 0; } - move_x_degrees = delta_x * cam->track.step_angle_x / (imgs->width / 2); - move_y_degrees = -delta_y * cam->track.step_angle_y / (imgs->height / 2); + move_x_degrees = delta_x * cam->conf.track_step_angle_x / (imgs->width / 2); + move_y_degrees = -delta_y * cam->conf.track_step_angle_y / (imgs->height / 2); } else { move_x_degrees = cent->x; move_y_degrees = cent->y; @@ -400,7 +400,7 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent ,cam->track.pan_angle, cam->track.tilt_angle); } - return cam->track.move_wait; + return cam->conf.track_move_wait; #else return 0; #endif /* HAVE_V4L2 */ @@ -414,7 +414,7 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua cam->track.posx += cent->x; cam->track.posy += cent->y; - mystrftime(cam, fmtcmd, sizeof(fmtcmd), cam->track.generic_move, &cam->current_image->imgts, NULL, 0); + mystrftime(cam, fmtcmd, sizeof(fmtcmd), cam->conf.track_generic_move, &cam->current_image->imgts, NULL, 0); if (!fork()) { int i; @@ -465,7 +465,7 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua /* if above function succeeds the program never reach here */ MOTION_LOG(ALR, TYPE_EVENTS, SHOW_ERRNO ,_("Unable to start external command '%s'") - ,cam->track.generic_move); + ,cam->conf.track_generic_move); exit(1); } @@ -474,21 +474,16 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua ,_("Executing external command '%s'") , fmtcmd); - return cam->track.move_wait; + return cam->conf.track_move_wait; } void track_init(struct ctx_cam *cam){ cam->track.dev = -1; /* dev open */ - cam->track.active = 0; /* auto tracking active */ - cam->track.move_wait = 10; /* number of frames to disable motion detection after camera moving */ - cam->track.generic_move = NULL; /* command to execute to move a generic camera */ cam->track.maxx = 0; /* int maxx; */ cam->track.minx = 0; /* int minx; */ cam->track.maxy = 0; /* int maxy; */ cam->track.miny = 0; /* int miny; */ - cam->track.step_angle_x = 10; /* UVC step angle in degrees X-axis that camera moves during auto tracking */ - cam->track.step_angle_y = 10; /* UVC step angle in degrees Y-axis that camera moves during auto tracking */ cam->track.pan_angle = 0; /* degrees*/ cam->track.tilt_angle = 0; /* degrees*/ @@ -496,7 +491,7 @@ void track_init(struct ctx_cam *cam){ cam->track.posy = 0; cam->track.minmaxfound = 0; /* flag for minmax values stored for pwc based camera */ - if (cam->track.type) + if (cam->conf.track_type) cam->frame_skip = track_center(cam, cam->video_dev, 0, 0, 0); } @@ -507,12 +502,12 @@ int track_center(struct ctx_cam *cam, int dev, struct ctx_coord cent; (void)dev; - if (!manual && !cam->track.active) return 0; + if (!manual && !cam->conf.track_auto) return 0; - if (cam->track.type == TRACK_TYPE_UVC){ + if (cam->conf.track_type == TRACK_TYPE_UVC){ return uvc_center(cam, dev, xoff, yoff); - } else if (cam->track.type == TRACK_TYPE_GENERIC) { - if (cam->track.generic_move){ + } else if (cam->conf.track_type == TRACK_TYPE_GENERIC) { + if (cam->conf.track_generic_move){ cent.x = -cam->track.posx; cent.y = -cam->track.posy; return generic_move(cam, TRACK_CENTER, manual,0 ,0 ,¢ , NULL); @@ -522,7 +517,7 @@ int track_center(struct ctx_cam *cam, int dev, } MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO - ,_("internal error, %hu is not a known track-type"), cam->track.type); + ,_("internal error, %hu is not a known track-type"), cam->conf.track_type); return 0; } @@ -531,20 +526,20 @@ int track_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent , struct ctx_images *imgs, int manual) { - if (!manual && !cam->track.active) return 0; + if (!manual && !cam->conf.track_auto) return 0; - if (cam->track.type == TRACK_TYPE_UVC){ + if (cam->conf.track_type == TRACK_TYPE_UVC){ return uvc_move(cam, dev, cent, imgs, manual); - } else if (cam->track.type == TRACK_TYPE_GENERIC) { - if (cam->track.generic_move) { + } else if (cam->conf.track_type == TRACK_TYPE_GENERIC) { + if (cam->conf.track_generic_move) { return generic_move(cam, TRACK_MOVE, manual, 0, 0, cent, imgs); } else { - return cam->track.move_wait; + return cam->conf.track_move_wait; } } MOTION_LOG(WRN, TYPE_TRACK, SHOW_ERRNO - ,_("internal error, %hu is not a known track-type"), cam->track.type); + ,_("internal error, %hu is not a known track-type"), cam->conf.track_type); return 0; } diff --git a/src/track.hpp b/src/track.hpp index 8d0396ce..a49588e6 100644 --- a/src/track.hpp +++ b/src/track.hpp @@ -13,17 +13,10 @@ struct ctx_coord; struct ctx_track { int dev; - /* Config options: */ - int type; - int active; /* This is the track_auto but 'auto' is defined word so use active*/ - int move_wait; - char *generic_move; - int maxx; - int minx; - int maxy; - int miny; - int step_angle_x; - int step_angle_y; + int maxx; + int minx; + int maxy; + int miny; int pan_angle; // degrees int tilt_angle; // degrees diff --git a/src/video_common.hpp b/src/video_common.hpp index 5184b4c1..da77b5a3 100644 --- a/src/video_common.hpp +++ b/src/video_common.hpp @@ -19,7 +19,7 @@ struct video_dev { struct video_dev *next; int usage_count; int fd_device; - const char *video_device; + const char *videodevice; int input; int norm; int width; diff --git a/src/video_v4l2.cpp b/src/video_v4l2.cpp index 09600b13..446627db 100644 --- a/src/video_v4l2.cpp +++ b/src/video_v4l2.cpp @@ -45,7 +45,7 @@ #define MIN2(x, y) ((x) < (y) ? (x) : (y)) static pthread_mutex_t v4l2_mutex; - static struct video_dev *video_devices = NULL; + static struct video_dev *videodevices = NULL; typedef struct video_image_buff { unsigned char *ptr; @@ -1220,13 +1220,13 @@ static int v4l2_device_open(struct ctx_cam *cam, struct video_dev *curdev) { MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO ,_("Using videodevice %s and input %d") - ,cam->conf.video_device, cam->conf.input); + ,cam->conf.videodevice, cam->conf.input); - curdev->video_device = cam->conf.video_device; + curdev->videodevice = cam->conf.videodevice; curdev->fd_device = -1; fd_device = -1; - fd_device = open(curdev->video_device, O_RDWR|O_CLOEXEC); + fd_device = open(curdev->videodevice, O_RDWR|O_CLOEXEC); if (fd_device > 0) { curdev->fd_device = fd_device; src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private; @@ -1236,7 +1236,7 @@ static int v4l2_device_open(struct ctx_cam *cam, struct video_dev *curdev) { MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO ,_("Failed to open video device %s") - ,cam->conf.video_device); + ,cam->conf.videodevice); return -1; } @@ -1395,9 +1395,9 @@ int v4l2_start(struct ctx_cam *cam) { pthread_mutex_lock(&v4l2_mutex); /* If device is already open and initialized use it*/ - curdev = video_devices; + curdev = videodevices; while (curdev) { - if (mystreq(cam->conf.video_device, curdev->video_device)) { + if (mystreq(cam->conf.videodevice, curdev->videodevice)) { retcd = v4l2_vdev_init(cam); if (retcd == 0) retcd = vid_parms_parse(cam); if (retcd == 0) retcd = v4l2_imgs_set(cam, curdev); @@ -1449,8 +1449,8 @@ int v4l2_start(struct ctx_cam *cam) { curdev->starting = FALSE; /* Insert into linked list. */ - curdev->next = video_devices; - video_devices = curdev; + curdev->next = videodevices; + videodevices = curdev; pthread_mutex_unlock(&v4l2_mutex); @@ -1464,7 +1464,7 @@ int v4l2_start(struct ctx_cam *cam) { void v4l2_cleanup(struct ctx_cam *cam) { #ifdef HAVE_V4L2 - struct video_dev *dev = video_devices; + struct video_dev *dev = videodevices; struct video_dev *prev = NULL; /* Cleanup the v4l2 part */ @@ -1489,7 +1489,7 @@ void v4l2_cleanup(struct ctx_cam *cam) { if (--dev->usage_count == 0) { MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO - ,_("Closing video device %s"), dev->video_device); + ,_("Closing video device %s"), dev->videodevice); v4l2_device_close(dev); v4l2_device_cleanup(dev); @@ -1498,7 +1498,7 @@ void v4l2_cleanup(struct ctx_cam *cam) { /* Remove from list */ if (prev == NULL) - video_devices = dev->next; + videodevices = dev->next; else prev->next = dev->next; @@ -1509,7 +1509,7 @@ void v4l2_cleanup(struct ctx_cam *cam) { } else { MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO ,_("Still %d users of video device %s, so we don't close it now") - ,dev->usage_count, dev->video_device); + ,dev->usage_count, dev->videodevice); /* * There is still at least one thread using this device * If we own it, release it. @@ -1534,7 +1534,7 @@ int v4l2_next(struct ctx_cam *cam, struct ctx_image_data *img_data) { struct video_dev *dev; pthread_mutex_lock(&v4l2_mutex); - dev = video_devices; + dev = videodevices; while (dev) { if (dev->fd_device == cam->video_dev) break; @@ -1572,7 +1572,7 @@ int v4l2_next(struct ctx_cam *cam, struct ctx_image_data *img_data) { #endif // HAVE_V4L2 } -int v4l2_palette_valid(char *video_device, int v4l2_palette) { +int v4l2_palette_valid(char *videodevice, int v4l2_palette) { #ifdef HAVE_V4L2 /* This function is a boolean that returns true(1) if the palette selected in the @@ -1591,10 +1591,10 @@ int v4l2_palette_valid(char *video_device, int v4l2_palette) { v4l2_palette_init(palette_array); vid_source =(src_v4l2_t*)calloc(sizeof(src_v4l2_t), 1); - vid_source->fd_device = open(video_device, O_RDWR|O_CLOEXEC); + vid_source->fd_device = open(videodevice, O_RDWR|O_CLOEXEC); if (vid_source->fd_device < 0) { MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO - ,_("Failed to open video device %s"),video_device); + ,_("Failed to open video device %s"),videodevice); free(vid_source); free(palette_array); return 0; @@ -1621,7 +1621,7 @@ int v4l2_palette_valid(char *video_device, int v4l2_palette) { return retcd; #else /* We do not have v4l2 so we can not determine whether it is valid or not */ - (void)video_device; + (void)videodevice; (void)v4l2_palette; return 0; #endif // HAVE_V4L2 @@ -1657,7 +1657,7 @@ void v4l2_palette_fourcc(int v4l2_palette, char *fourcc) { #endif // HAVE_V4L2 } -int v4l2_parms_valid(char *video_device, int v4l2_palette, int v4l2_fps, int v4l2_width, int v4l2_height){ +int v4l2_parms_valid(char *videodevice, int v4l2_palette, int v4l2_fps, int v4l2_width, int v4l2_height){ #ifdef HAVE_V4L2 /* This function is a boolean that returns true(1) if the parms selected in the @@ -1678,10 +1678,10 @@ int v4l2_parms_valid(char *video_device, int v4l2_palette, int v4l2_fps, int v4l v4l2_palette_init(palette_array); vid_source =(src_v4l2_t*) calloc(sizeof(src_v4l2_t), 1); - vid_source->fd_device = open(video_device, O_RDWR|O_CLOEXEC); + vid_source->fd_device = open(videodevice, O_RDWR|O_CLOEXEC); if (vid_source->fd_device < 0) { MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO - ,_("Failed to open video device %s"),video_device); + ,_("Failed to open video device %s"),videodevice); free(vid_source); free(palette_array); return 0; @@ -1748,7 +1748,7 @@ int v4l2_parms_valid(char *video_device, int v4l2_palette, int v4l2_fps, int v4l return retcd; #else /* We do not have v4l2 so we can not determine whether it is valid or not */ - (void)video_device; + (void)videodevice; (void)v4l2_fps; (void)v4l2_palette; (void)v4l2_width; diff --git a/src/webu.cpp b/src/webu.cpp index 8b1f4410..03ff6b99 100644 --- a/src/webu.cpp +++ b/src/webu.cpp @@ -44,6 +44,8 @@ #include "webu_html.hpp" #include "webu_text.hpp" #include "webu_stream.hpp" +#include "conf_edit.hpp" + /* Context to pass the parms to functions to start mhd */ struct mhdstart_ctx { @@ -697,7 +699,8 @@ static int webu_process_config_set(struct webui_ctx *webui) { if (config_parms[indx].parm_name != NULL){ if (strlen(webui->uri_parm1) > 0){ - conf_parm_set(webui->cam, webui->uri_parm1, webui->uri_value1); + conf_edit_set(webui->camlst[webui->thread_nbr]->motapp,webui->thread_nbr + , (char *)config_parms[indx].parm_name, webui->uri_parm1); /*If we are updating vid parms, set the flag to update the device.*/ if (mystreq(config_parms[indx].parm_name, "vid_control_params") && @@ -707,7 +710,7 @@ static int webu_process_config_set(struct webui_ctx *webui) { /* If changing language, do it now */ if (mystreq(config_parms[indx].parm_name, "native_language")){ - if (webui->camlst[webui->thread_nbr]->conf.native_language){ + if (webui->camlst[webui->thread_nbr]->motapp->native_language){ mytranslate_text("", 1); MOTION_LOG(INF, TYPE_ALL, NO_ERRNO,_("Native Language : on")); } else { @@ -1756,8 +1759,8 @@ static void webu_mhd_opts_digest(struct mhdstart_ctx *mhdst){ if (mhdst->ctrl) { mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_DIGEST_AUTH_RANDOM; - mhdst->mhd_ops[mhdst->mhd_opt_nbr].value = sizeof(mhdst->camlst[mhdst->indxthrd]->webcontrol_digest_rand); - mhdst->mhd_ops[mhdst->mhd_opt_nbr].ptr_value = mhdst->camlst[mhdst->indxthrd]->webcontrol_digest_rand; + mhdst->mhd_ops[mhdst->mhd_opt_nbr].value = sizeof(mhdst->camlst[mhdst->indxthrd]->motapp->webcontrol_digest_rand); + mhdst->mhd_ops[mhdst->mhd_opt_nbr].ptr_value = mhdst->camlst[mhdst->indxthrd]->motapp->webcontrol_digest_rand; mhdst->mhd_opt_nbr++; } else { mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_DIGEST_AUTH_RANDOM; diff --git a/src/webu_html.cpp b/src/webu_html.cpp index 0976a73e..6ba02e2a 100644 --- a/src/webu_html.cpp +++ b/src/webu_html.cpp @@ -38,6 +38,7 @@ #include "util.hpp" #include "webu.hpp" #include "webu_html.hpp" +#include "conf_edit.hpp" /* struct to save information regarding the links to include in html page */ struct strminfo_ctx { @@ -426,7 +427,7 @@ static void webu_html_config(struct webui_ctx *webui) { char response[WEBUI_LEN_RESP]; int indx_parm, indx, diff_vals; - const char *val_main, *val_thread; + char val_main[PATH_MAX], val_thread[PATH_MAX]; char *val_temp; @@ -458,7 +459,8 @@ static void webu_html_config(struct webui_ctx *webui) { continue; } - val_main = conf_parm_get(webui->camlst, indx_parm, 0); + conf_edit_get(webui->camlst[0], config_parms[indx_parm].parm_name + , val_main, config_parms[indx_parm].parm_cat); snprintf(response, sizeof (response), " \n" @@ -317,7 +324,7 @@ static void webu_text_set_query(struct webui_ctx *webui) { /* Write out the options and values to allow user to set them*/ char response[WEBUI_LEN_RESP]; int indx_parm; - const char *val_parm; + char val_parm[PATH_MAX]; webu_text_header(webui); @@ -336,9 +343,11 @@ static void webu_text_set_query(struct webui_ctx *webui) { continue; } - val_parm = conf_parm_get(webui->camlst, indx_parm, webui->thread_nbr); + conf_edit_get(webui->camlst[webui->thread_nbr], config_parms[indx_parm].parm_name + , val_parm, config_parms[indx_parm].parm_cat); if (val_parm == NULL){ - val_parm = conf_parm_get(webui->camlst, indx_parm, 0); + conf_edit_get(webui->camlst[0], config_parms[indx_parm].parm_name + , val_parm, config_parms[indx_parm].parm_cat); } snprintf(response, sizeof (response), "
\n" @@ -866,7 +875,7 @@ void webu_text_get_query(struct webui_ctx *webui) { /* Write out the option value for one parm */ char response[WEBUI_LEN_RESP]; int indx_parm; - const char *val_parm; + char val_parm[PATH_MAX]; char temp_name[WEBUI_LEN_PARM]; @@ -894,9 +903,11 @@ void webu_text_get_query(struct webui_ctx *webui) { continue; } - val_parm = conf_parm_get(webui->camlst, indx_parm, webui->thread_nbr); + conf_edit_get(webui->camlst[webui->thread_nbr], config_parms[indx_parm].parm_name + , val_parm, config_parms[indx_parm].parm_cat); if (val_parm == NULL){ - val_parm = conf_parm_get(webui->camlst, indx_parm, 0); + conf_edit_get(webui->camlst[0], config_parms[indx_parm].parm_name + , val_parm, config_parms[indx_parm].parm_cat); } if (mystrne(webui->uri_value1, config_parms[indx_parm].parm_name)){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO