From f67cd78909c78b8628642ac771e349f459d3be13 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sun, 20 Oct 2019 20:20:32 -0600 Subject: [PATCH] Revise conf to pointer --- src/alg.cpp | 37 +- src/alg_sec.cpp | 47 +- src/conf.cpp | 9 + src/conf_edit.cpp | 1048 ++++++++++++++++++++-------------------- src/dbse.cpp | 159 +++--- src/draw.cpp | 5 +- src/event.cpp | 111 ++--- src/exif.cpp | 5 +- src/logger.cpp | 1 + src/mmalcam.cpp | 15 +- src/motion.cpp | 7 +- src/motion.hpp | 11 +- src/motion_loop.cpp | 210 ++++---- src/movie.cpp | 51 +- src/netcam.cpp | 53 +- src/picture.cpp | 37 +- src/rotate.cpp | 13 +- src/track.cpp | 158 +++--- src/track.hpp | 1 + src/util.cpp | 5 +- src/video_common.cpp | 17 +- src/video_loopback.cpp | 9 +- src/video_v4l2.cpp | 105 ++-- src/webu.cpp | 197 ++++---- src/webu_html.cpp | 63 +-- src/webu_stream.cpp | 23 +- src/webu_text.cpp | 43 +- 27 files changed, 1237 insertions(+), 1203 deletions(-) diff --git a/src/alg.cpp b/src/alg.cpp index bfa7e08f..9745c706 100644 --- a/src/alg.cpp +++ b/src/alg.cpp @@ -7,6 +7,7 @@ * */ #include "motion.hpp" +#include "conf.hpp" #include "util.hpp" #include "alg.hpp" #include "draw.hpp" @@ -253,7 +254,7 @@ void alg_threshold_tune(struct ctx_cam *cam, int diffs, int motion) if (sum < top * 2) sum = top * 2; - if (sum < cam->conf.threshold) + if (sum < cam->conf->threshold) cam->threshold = (cam->threshold + sum) / 2; } @@ -650,7 +651,7 @@ void alg_despeckle(struct ctx_cam *cam) { int diffs,width,height,done,i,len; unsigned char *out, *common_buffer; - if (!cam->conf.despeckle_filter || cam->current_image->diffs <= 0){ + if (!cam->conf->despeckle_filter || cam->current_image->diffs <= 0){ if (cam->imgs.labelsize_max) cam->imgs.labelsize_max = 0; return; } @@ -660,14 +661,14 @@ void alg_despeckle(struct ctx_cam *cam) { width = cam->imgs.width; height = cam->imgs.height; done = 0; - len = strlen(cam->conf.despeckle_filter); + len = strlen(cam->conf->despeckle_filter); common_buffer = cam->imgs.common_buffer; cam->current_image->total_labels = 0; cam->imgs.largest_label = 0; cam->olddiffs = cam->current_image->diffs; for (i = 0; i < len; i++) { - switch (cam->conf.despeckle_filter[i]) { + switch (cam->conf->despeckle_filter[i]) { case 'E': if ((diffs = erode9(out, width, height, common_buffer, 0)) == 0) i = len; @@ -836,7 +837,7 @@ void alg_diff(struct ctx_cam *cam) { if (cam->detecting_motion || cam->motapp->setup_mode){ cam->current_image->diffs = alg_diff_standard(cam, cam->imgs.image_vprvcy); } else { - if (alg_diff_fast(cam, cam->conf.threshold / 2, cam->imgs.image_vprvcy)){ + if (alg_diff_fast(cam, cam->conf->threshold / 2, cam->imgs.image_vprvcy)){ cam->current_image->diffs = alg_diff_standard(cam, cam->imgs.image_vprvcy); } else { cam->current_image->diffs = 0; @@ -847,11 +848,11 @@ void alg_diff(struct ctx_cam *cam) { void alg_lightswitch(struct ctx_cam *cam) { - if (cam->conf.lightswitch_percent > 1 && !cam->lost_connection) { - if (cam->current_image->diffs > (cam->imgs.motionsize * cam->conf.lightswitch_percent / 100)) { + if (cam->conf->lightswitch_percent > 1 && !cam->lost_connection) { + if (cam->current_image->diffs > (cam->imgs.motionsize * cam->conf->lightswitch_percent / 100)) { MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, _("Lightswitch detected")); - if (cam->frame_skip < (unsigned int)cam->conf.lightswitch_frames) - cam->frame_skip = (unsigned int)cam->conf.lightswitch_frames; + if (cam->frame_skip < (unsigned int)cam->conf->lightswitch_frames) + cam->frame_skip = (unsigned int)cam->conf->lightswitch_frames; cam->current_image->diffs = 0; alg_update_reference_frame(cam, RESET_REF_FRAME); } @@ -869,7 +870,7 @@ void alg_switchfilter(struct ctx_cam *cam) { int y, x, line; int lines = 0, vertlines = 0; - if (!cam->conf.roundrobin_switchfilter || + if (!cam->conf->roundrobin_switchfilter || cam->current_image->diffs < cam->threshold) return; linediff = cam->current_image->diffs / cam->imgs.height; @@ -886,11 +887,11 @@ void alg_switchfilter(struct ctx_cam *cam) { if (vertlines > cam->imgs.height / 10 && lines < vertlines / 3 && (vertlines > cam->imgs.height / 4 || lines - vertlines > lines / 2)) { - if (cam->conf.text_changes) { + if (cam->conf->text_changes) { char tmp[80]; sprintf(tmp, "%d %d", lines, vertlines); draw_text(cam->current_image->image_norm, cam->imgs.width, cam->imgs.height - , cam->imgs.width - 10, 20, tmp, cam->conf.text_scale); + , cam->imgs.width - 10, 20, tmp, cam->conf->text_scale); } return; } @@ -1154,8 +1155,8 @@ static void alg_new_stddev(ctx_cam *cam){ * that distance then we have an excessive change. This is the /8 * The above is the default if nothing is specified by the user. */ - if (cam->conf.threshold_sdevx >0){ - if (cam->current_image->location.stddev_x < cam->conf.threshold_sdevx){ + if (cam->conf->threshold_sdevx >0){ + if (cam->current_image->location.stddev_x < cam->conf->threshold_sdevx){ cam->current_image->diffs = 0; return; } @@ -1167,8 +1168,8 @@ static void alg_new_stddev(ctx_cam *cam){ } } - if (cam->conf.threshold_sdevy >0){ - if (cam->current_image->location.stddev_y < cam->conf.threshold_sdevy){ + if (cam->conf->threshold_sdevy >0){ + if (cam->current_image->location.stddev_y < cam->conf->threshold_sdevy){ cam->current_image->diffs = 0; return; } @@ -1180,8 +1181,8 @@ static void alg_new_stddev(ctx_cam *cam){ } } - if (cam->conf.threshold_sdevxy >0){ - if (cam->current_image->location.stddev_xy < cam->conf.threshold_sdevxy){ + if (cam->conf->threshold_sdevxy >0){ + if (cam->current_image->location.stddev_xy < cam->conf->threshold_sdevxy){ cam->current_image->diffs = 0; return; } diff --git a/src/alg_sec.cpp b/src/alg_sec.cpp index fa3d8e95..e50e1354 100644 --- a/src/alg_sec.cpp +++ b/src/alg_sec.cpp @@ -13,6 +13,7 @@ #include #include "motion.hpp" +#include "conf.hpp" #include "util.hpp" #include "logger.hpp" #include "alg_sec.hpp" @@ -38,7 +39,7 @@ static void algsec_img_show(ctx_cam *cam, Mat &mat_src bool isdetected; char wstr[10]; - testdir = cam->conf.target_dir; + testdir = cam->conf->target_dir; imwrite(testdir + "/src_" + algmethod + ".jpg", mat_src); @@ -345,7 +346,7 @@ static void algsec_load_parms(ctx_cam *cam){ cam->algsec->height = cam->imgs.height; cam->algsec->width = cam->imgs.width; - cam->algsec->frame_interval = cam->conf.secondary_interval; + cam->algsec->frame_interval = cam->conf->secondary_interval; cam->algsec->frame_cnt = cam->algsec->frame_interval; cam->algsec->image_norm = (unsigned char*)mymalloc(cam->imgs.size_norm); cam->algsec->frame_missed = 0; @@ -357,37 +358,37 @@ static void algsec_load_parms(ctx_cam *cam){ */ cam->algsec->closing = true; - if (cam->conf.secondary_method != 0) { - cam->algsec->models[0].method = cam->conf.secondary_method; - if (cam->conf.secondary_model != NULL){ - cam->algsec->models[0].modelfile = cam->conf.secondary_model; + if (cam->conf->secondary_method != 0) { + cam->algsec->models[0].method = cam->conf->secondary_method; + if (cam->conf->secondary_model != NULL){ + cam->algsec->models[0].modelfile = cam->conf->secondary_model; } - if (cam->conf.secondary_config != NULL) { - cam->algsec->models[0].config = cam->conf.secondary_config; + if (cam->conf->secondary_config != NULL) { + cam->algsec->models[0].config = cam->conf->secondary_config; } } else { cam->algsec->models[0].method = 0; } - if (cam->conf.secondary_method2 != 0) { - cam->algsec->models[1].method = cam->conf.secondary_method2; - if (cam->conf.secondary_model2 != NULL){ - cam->algsec->models[1].modelfile = cam->conf.secondary_model2; + if (cam->conf->secondary_method2 != 0) { + cam->algsec->models[1].method = cam->conf->secondary_method2; + if (cam->conf->secondary_model2 != NULL){ + cam->algsec->models[1].modelfile = cam->conf->secondary_model2; } - if (cam->conf.secondary_config2 != NULL) { - cam->algsec->models[1].config = cam->conf.secondary_config2; + if (cam->conf->secondary_config2 != NULL) { + cam->algsec->models[1].config = cam->conf->secondary_config2; } } else { cam->algsec->models[1].method = 0; } - if (cam->conf.secondary_method3 != 0) { - cam->algsec->models[2].method = cam->conf.secondary_method3; - if (cam->conf.secondary_model3 != NULL) { - cam->algsec->models[2].modelfile = cam->conf.secondary_model3; + if (cam->conf->secondary_method3 != 0) { + cam->algsec->models[2].method = cam->conf->secondary_method3; + if (cam->conf->secondary_model3 != NULL) { + cam->algsec->models[2].modelfile = cam->conf->secondary_model3; } - if (cam->conf.secondary_config3 != NULL) { - cam->algsec->models[2].config = cam->conf.secondary_config3; + if (cam->conf->secondary_config3 != NULL) { + cam->algsec->models[2].config = cam->conf->secondary_config3; } } else { cam->algsec->models[2].method = 0; @@ -440,7 +441,7 @@ static void *algsec_handler(void *arg) { cam->algsec->closing = false; - interval = 1000000L / cam->conf.framerate; + interval = 1000000L / cam->conf->framerate; while (!cam->algsec->closing){ if (cam->algsec->detecting){ @@ -501,7 +502,7 @@ void algsec_init(ctx_cam *cam){ #ifdef HAVE_OPENCV int retcd; - mythreadname_set("cv",cam->threadnr,cam->conf.camera_name); + mythreadname_set("cv",cam->threadnr,cam->conf->camera_name); cam->algsec = new ctx_algsec; @@ -513,7 +514,7 @@ void algsec_init(ctx_cam *cam){ if (retcd == 0) algsec_start_handler(cam); - mythreadname_set("ml",cam->threadnr,cam->conf.camera_name); + mythreadname_set("ml",cam->threadnr,cam->conf->camera_name); #else (void)cam; #endif diff --git a/src/conf.cpp b/src/conf.cpp index 78d9de5c..73b1b423 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -14,6 +14,7 @@ #include "motion.hpp" #include "util.hpp" #include "logger.hpp" +#include "conf.hpp" #include "conf_edit.hpp" /* Forward Declares */ @@ -956,6 +957,9 @@ static void conf_parm_camera(struct ctx_motapp *motapp, char *str) { motapp->cam_list, sizeof(struct ctx_cam *) * (indx_cams + 2), "config_camera"); motapp->cam_list[indx_cams] = new ctx_cam; memset(motapp->cam_list[indx_cams],0,sizeof(struct ctx_cam)); + motapp->cam_list[indx_cams]->conf = new ctx_config; + memset(motapp->cam_list[indx_cams]->conf,0,sizeof(ctx_config)); + motapp->cam_list[indx_cams + 1] = NULL; conf_edit_dflt_cam(motapp->cam_list[indx_cams]); @@ -1299,6 +1303,10 @@ void conf_init_cams(struct ctx_motapp *motapp){ motapp->cam_list = (struct ctx_cam**)calloc(sizeof(struct ctx_cam *), 2); motapp->cam_list[0] = new ctx_cam; memset(motapp->cam_list[0],0,sizeof(struct ctx_cam)); + + motapp->cam_list[0]->conf = new ctx_config; + memset(motapp->cam_list[0]->conf,0,sizeof(ctx_config)); + motapp->cam_list[1] = NULL; motapp->cam_list[0]->motapp = motapp; @@ -1338,6 +1346,7 @@ void conf_deinit(struct ctx_motapp *motapp) { indx = 0; while (motapp->cam_list[indx] != NULL){ conf_edit_free(motapp->cam_list[indx]); + delete motapp->cam_list[indx]->conf; delete motapp->cam_list[indx]; indx++; } diff --git a/src/conf_edit.cpp b/src/conf_edit.cpp index 2beec969..527b1c0f 100644 --- a/src/conf_edit.cpp +++ b/src/conf_edit.cpp @@ -191,28 +191,28 @@ static void conf_edit_native_language(struct ctx_motapp *motapp, char *arg1, enu static void conf_edit_quiet(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT){ - cam->conf.quiet = TRUE; + cam->conf->quiet = TRUE; } else if (pact == PARM_ACT_SET){ if (mystrceq(arg1, "1") || mystrceq(arg1, "yes") || mystrceq(arg1, "on")) { - cam->conf.quiet = TRUE; + cam->conf->quiet = TRUE; } else { - cam->conf.quiet = FALSE; + cam->conf->quiet = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.quiet, arg1); + 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); + conf_edit_set_string(&cam->conf->camera_name,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.camera_name,NULL); + conf_edit_set_string(&cam->conf->camera_name,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.camera_name,arg1); + conf_edit_set_string(&cam->conf->camera_name,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.camera_name,arg1); + conf_edit_get_string(cam->conf->camera_name,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_name",_("camera_name")); @@ -220,76 +220,76 @@ static void conf_edit_camera_name(struct ctx_cam *cam, char *arg1, enum PARM_ACT 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; + 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; + cam->conf->camera_id = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.camera_id, arg1); + 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); + conf_edit_set_string(&cam->conf->camera_dir,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.camera_dir,NULL); + conf_edit_set_string(&cam->conf->camera_dir,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.camera_dir,arg1); + conf_edit_set_string(&cam->conf->camera_dir,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.camera_dir,arg1); + 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*)"."); + conf_edit_set_string(&cam->conf->target_dir,(char*)"."); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.target_dir,NULL); + conf_edit_set_string(&cam->conf->target_dir,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 == NULL){ - conf_edit_set_string(&cam->conf.target_dir,(char*)"."); + conf_edit_set_string(&cam->conf->target_dir,(char*)"."); } else { - conf_edit_set_string(&cam->conf.target_dir,arg1); + conf_edit_set_string(&cam->conf->target_dir,arg1); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.target_dir,arg1); + 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"); + conf_edit_set_string(&cam->conf->videodevice,(char*)"/dev/video0"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.videodevice,NULL); + conf_edit_set_string(&cam->conf->videodevice,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 == NULL){ - conf_edit_set_string(&cam->conf.videodevice,(char*)"/dev/video0"); + conf_edit_set_string(&cam->conf->videodevice,(char*)"/dev/video0"); } else { - conf_edit_set_string(&cam->conf.videodevice,arg1); + conf_edit_set_string(&cam->conf->videodevice,arg1); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.videodevice,arg1); + 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); + conf_edit_set_string(&cam->conf->vid_control_params,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.vid_control_params,NULL); + 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); + conf_edit_set_string(&cam->conf->vid_control_params,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.vid_control_params,arg1); + 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")); @@ -297,16 +297,16 @@ static void conf_edit_vid_control_params(struct ctx_cam *cam, char *arg1, enum P 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; + 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; + cam->conf->v4l2_palette = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.v4l2_palette, arg1); + conf_edit_get_int(cam->conf->v4l2_palette, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","v4l2_palette",_("v4l2_palette")); @@ -314,16 +314,16 @@ static void conf_edit_v4l2_palette(struct ctx_cam *cam, char *arg1, enum PARM_AC 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; + 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; + cam->conf->input = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.input, arg1); + conf_edit_get_int(cam->conf->input, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","input",_("input")); @@ -331,16 +331,16 @@ static void conf_edit_input(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) 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; + 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; + cam->conf->norm = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.norm, arg1); + conf_edit_get_int(cam->conf->norm, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","norm",_("norm")); @@ -348,33 +348,33 @@ static void conf_edit_norm(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) 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; + 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; + cam->conf->frequency = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.frequency, arg1); + conf_edit_get_int(cam->conf->frequency, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","frequency",_("frequency")); } 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"); + conf_edit_set_string(&cam->conf->tuner_device,(char*)"/dev/tuner0"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.tuner_device,NULL); + conf_edit_set_string(&cam->conf->tuner_device,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 == NULL){ - conf_edit_set_string(&cam->conf.tuner_device,(char*)"/dev/tuner0"); + conf_edit_set_string(&cam->conf->tuner_device,(char*)"/dev/tuner0"); } else { - conf_edit_set_string(&cam->conf.tuner_device,arg1); + conf_edit_set_string(&cam->conf->tuner_device,arg1); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.tuner_device,arg1); + conf_edit_get_string(cam->conf->tuner_device,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","tuner_device",_("tuner_device")); @@ -382,16 +382,16 @@ static void conf_edit_tuner_device(struct ctx_cam *cam, char *arg1, enum PARM_AC 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; + 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; + cam->conf->roundrobin_frames = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.roundrobin_frames, arg1); + conf_edit_get_int(cam->conf->roundrobin_frames, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","roundrobin_frames",_("roundrobin_frames")); @@ -399,110 +399,110 @@ static void conf_edit_roundrobin_frames(struct ctx_cam *cam, char *arg1, enum PA 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; + 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; + cam->conf->roundrobin_skip = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.roundrobin_skip, arg1); + 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; + 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; + cam->conf->roundrobin_switchfilter = TRUE; } else { - cam->conf.roundrobin_switchfilter = FALSE; + cam->conf->roundrobin_switchfilter = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.roundrobin_switchfilter, arg1); + 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); + conf_edit_set_string(&cam->conf->netcam_url,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.netcam_url,NULL); + conf_edit_set_string(&cam->conf->netcam_url,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.netcam_url,arg1); + conf_edit_set_string(&cam->conf->netcam_url,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.netcam_url,arg1); + 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); + conf_edit_set_string(&cam->conf->netcam_highres,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.netcam_highres,NULL); + conf_edit_set_string(&cam->conf->netcam_highres,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.netcam_highres,arg1); + conf_edit_set_string(&cam->conf->netcam_highres,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.netcam_highres,arg1); + 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); + conf_edit_set_string(&cam->conf->netcam_userpass,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.netcam_userpass,NULL); + conf_edit_set_string(&cam->conf->netcam_userpass,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.netcam_userpass,arg1); + conf_edit_set_string(&cam->conf->netcam_userpass,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.netcam_userpass,arg1); + 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; + 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; + cam->conf->netcam_use_tcp = TRUE; } else { - cam->conf.netcam_use_tcp = FALSE; + cam->conf->netcam_use_tcp = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.netcam_use_tcp, arg1); + 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); + conf_edit_set_string(&cam->conf->mmalcam_name,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.mmalcam_name,NULL); + conf_edit_set_string(&cam->conf->mmalcam_name,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.mmalcam_name,arg1); + conf_edit_set_string(&cam->conf->mmalcam_name,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.mmalcam_name,arg1); + 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); + conf_edit_set_string(&cam->conf->mmalcam_control_params,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.mmalcam_control_params,NULL); + 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); + conf_edit_set_string(&cam->conf->mmalcam_control_params,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.mmalcam_control_params,arg1); + 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")); @@ -510,7 +510,7 @@ static void conf_edit_mmalcam_control_params(struct ctx_cam *cam, char *arg1, en 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; + cam->conf->width = 640; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 64) || (parm_in > 9999)) { @@ -521,12 +521,12 @@ static void conf_edit_width(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) parm_in = parm_in - (parm_in % 8) + 8; MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO ,_("Adjusting width to next higher multiple of 8 (%d)."), parm_in); - cam->conf.width = parm_in; + cam->conf->width = parm_in; } else { - cam->conf.width = parm_in; + cam->conf->width = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.width, arg1); + conf_edit_get_int(cam->conf->width, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","width",_("width")); @@ -534,7 +534,7 @@ static void conf_edit_width(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) 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; + cam->conf->height = 480; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 64) || (parm_in > 9999)) { @@ -545,12 +545,12 @@ static void conf_edit_height(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact parm_in = parm_in - (parm_in % 8) + 8; MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO ,_("Adjusting height to next higher multiple of 8 (%d)."), parm_in); - cam->conf.height = parm_in; + cam->conf->height = parm_in; } else { - cam->conf.height = parm_in; + cam->conf->height = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.height, arg1); + conf_edit_get_int(cam->conf->height, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","height",_("height")); @@ -558,16 +558,16 @@ static void conf_edit_height(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact 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; + 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; + cam->conf->framerate = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.framerate, arg1); + conf_edit_get_int(cam->conf->framerate, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","framerate",_("framerate")); @@ -575,16 +575,16 @@ static void conf_edit_framerate(struct ctx_cam *cam, char *arg1, enum PARM_ACT p 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; + 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; + cam->conf->minimum_frame_time = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.minimum_frame_time, arg1); + 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")); @@ -592,122 +592,122 @@ static void conf_edit_minimum_frame_time(struct ctx_cam *cam, char *arg1, enum P 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; + 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; + cam->conf->rotate = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.rotate, arg1); + 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"); + conf_edit_set_string(&cam->conf->flip_axis,(char*)"none"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.flip_axis,NULL); + conf_edit_set_string(&cam->conf->flip_axis,NULL); } 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); + conf_edit_set_string(&cam->conf->flip_axis, arg1); } else { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid flip_axis %s"),arg1); } } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.flip_axis,arg1); + 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"); + conf_edit_set_string(&cam->conf->locate_motion_mode,(char*)"off"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.locate_motion_mode,NULL); + conf_edit_set_string(&cam->conf->locate_motion_mode,NULL); } 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); + 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 if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.locate_motion_mode,arg1); + 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"); + conf_edit_set_string(&cam->conf->locate_motion_style,(char*)"box"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.locate_motion_style,NULL); + conf_edit_set_string(&cam->conf->locate_motion_style,NULL); } 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); + 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 if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.locate_motion_style,arg1); + 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); + conf_edit_set_string(&cam->conf->text_left,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.text_left,NULL); + conf_edit_set_string(&cam->conf->text_left,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.text_left,arg1); + conf_edit_set_string(&cam->conf->text_left,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.text_left,arg1); + 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); + conf_edit_set_string(&cam->conf->text_right,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.text_right,NULL); + conf_edit_set_string(&cam->conf->text_right,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.text_right,arg1); + conf_edit_set_string(&cam->conf->text_right,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.text_right,arg1); + 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; + 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; + cam->conf->text_changes = TRUE; } else { - cam->conf.text_changes = FALSE; + cam->conf->text_changes = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.text_changes, arg1); + conf_edit_get_bool(cam->conf->text_changes, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_changes",_("text_changes")); @@ -715,29 +715,29 @@ static void conf_edit_text_changes(struct ctx_cam *cam, char *arg1, enum PARM_AC 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; + 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; + cam->conf->text_scale = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.text_scale, arg1); + 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"); + conf_edit_set_string(&cam->conf->text_event,(char*)"%Y%m%d%H%M%S"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.text_event,NULL); + conf_edit_set_string(&cam->conf->text_event,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.text_event,arg1); + conf_edit_set_string(&cam->conf->text_event,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.text_event,arg1); + conf_edit_get_string(cam->conf->text_event,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","text_event",_("text_event")); @@ -745,15 +745,15 @@ static void conf_edit_text_event(struct ctx_cam *cam, char *arg1, enum PARM_ACT 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; + 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; + cam->conf->emulate_motion = TRUE; } else { - cam->conf.emulate_motion = FALSE; + cam->conf->emulate_motion = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.emulate_motion, arg1); + conf_edit_get_bool(cam->conf->emulate_motion, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","emulate_motion",_("emulate_motion")); @@ -761,16 +761,16 @@ static void conf_edit_emulate_motion(struct ctx_cam *cam, char *arg1, enum PARM_ static void conf_edit_primary_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ - cam->conf.threshold = 0; + cam->conf->threshold = 0; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 0) || (parm_in > 1)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid primary method %d"),parm_in); } else { - cam->conf.primary_method = parm_in; + cam->conf->primary_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.primary_method, arg1); + conf_edit_get_int(cam->conf->primary_method, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","primary_method",_("primary_method")); @@ -778,16 +778,16 @@ static void conf_edit_primary_method(struct ctx_cam *cam, char *arg1, enum PARM_ 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; + 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; + cam->conf->threshold = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.threshold, arg1); + conf_edit_get_int(cam->conf->threshold, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold",_("threshold")); @@ -795,16 +795,16 @@ static void conf_edit_threshold(struct ctx_cam *cam, char *arg1, enum PARM_ACT p 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; + 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; + cam->conf->threshold_maximum = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.threshold_maximum, arg1); + conf_edit_get_int(cam->conf->threshold_maximum, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_maximum",_("threshold_maximum")); @@ -812,16 +812,16 @@ static void conf_edit_threshold_maximum(struct ctx_cam *cam, char *arg1, enum PA static void conf_edit_threshold_sdevx(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ - cam->conf.threshold_sdevx = 0; + cam->conf->threshold_sdevx = 0; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold_sdevx %d"),parm_in); } else { - cam->conf.threshold_sdevx = parm_in; + cam->conf->threshold_sdevx = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.threshold_sdevx, arg1); + conf_edit_get_int(cam->conf->threshold_sdevx, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_sdevx",_("threshold_sdevx")); @@ -829,16 +829,16 @@ static void conf_edit_threshold_sdevx(struct ctx_cam *cam, char *arg1, enum PARM static void conf_edit_threshold_sdevy(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ - cam->conf.threshold_sdevy = 0; + cam->conf->threshold_sdevy = 0; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold_sdevy %d"),parm_in); } else { - cam->conf.threshold_sdevy = parm_in; + cam->conf->threshold_sdevy = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.threshold_sdevy, arg1); + conf_edit_get_int(cam->conf->threshold_sdevy, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_sdevy",_("threshold_sdevy")); @@ -846,31 +846,31 @@ static void conf_edit_threshold_sdevy(struct ctx_cam *cam, char *arg1, enum PARM static void conf_edit_threshold_sdevxy(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ - cam->conf.threshold_sdevxy = 0; + cam->conf->threshold_sdevxy = 0; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid threshold_sdevxy %d"),parm_in); } else { - cam->conf.threshold_sdevxy = parm_in; + cam->conf->threshold_sdevxy = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.threshold_sdevxy, arg1); + conf_edit_get_int(cam->conf->threshold_sdevxy, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_sdevxy",_("threshold_sdevxy")); } 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; + 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; + cam->conf->threshold_tune = TRUE; } else { - cam->conf.threshold_tune = FALSE; + cam->conf->threshold_tune = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.threshold_tune, arg1); + conf_edit_get_bool(cam->conf->threshold_tune, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","threshold_tune",_("threshold_tune")); @@ -878,16 +878,16 @@ static void conf_edit_threshold_tune(struct ctx_cam *cam, char *arg1, enum PARM_ static void conf_edit_secondary_interval(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ - cam->conf.secondary_interval = 0; + cam->conf->secondary_interval = 0; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid secondary_interval %d"),parm_in); } else { - cam->conf.secondary_interval = parm_in; + cam->conf->secondary_interval = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.secondary_interval, arg1); + conf_edit_get_int(cam->conf->secondary_interval, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_interval",_("secondary_interval")); @@ -895,42 +895,42 @@ static void conf_edit_secondary_interval(struct ctx_cam *cam, char *arg1, enum P static void conf_edit_secondary_method(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ - cam->conf.secondary_method = 0; + cam->conf->secondary_method = 0; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid secondary_method %d"),parm_in); } else { - cam->conf.secondary_method = parm_in; + cam->conf->secondary_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.secondary_method, arg1); + conf_edit_get_int(cam->conf->secondary_method, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_method",_("secondary_method")); } static void conf_edit_secondary_model(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf.secondary_model,NULL); + conf_edit_set_string(&cam->conf->secondary_model,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.secondary_model,NULL); + conf_edit_set_string(&cam->conf->secondary_model,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.secondary_model,arg1); + conf_edit_set_string(&cam->conf->secondary_model,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.secondary_model,arg1); + conf_edit_get_string(cam->conf->secondary_model,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_model",_("secondary_model")); } static void conf_edit_secondary_config(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf.secondary_config,NULL); + conf_edit_set_string(&cam->conf->secondary_config,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.secondary_config,NULL); + conf_edit_set_string(&cam->conf->secondary_config,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.secondary_config,arg1); + conf_edit_set_string(&cam->conf->secondary_config,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.secondary_config,arg1); + conf_edit_get_string(cam->conf->secondary_config,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_config",_("secondary_config")); @@ -938,42 +938,42 @@ static void conf_edit_secondary_config(struct ctx_cam *cam, char *arg1, enum PAR static void conf_edit_secondary_method2(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ - cam->conf.secondary_method2 = 0; + cam->conf->secondary_method2 = 0; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid secondary_method2 %d"),parm_in); } else { - cam->conf.secondary_method2 = parm_in; + cam->conf->secondary_method2 = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.secondary_method2, arg1); + conf_edit_get_int(cam->conf->secondary_method2, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_method2",_("secondary_method2")); } static void conf_edit_secondary_model2(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf.secondary_model2,NULL); + conf_edit_set_string(&cam->conf->secondary_model2,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.secondary_model2,NULL); + conf_edit_set_string(&cam->conf->secondary_model2,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.secondary_model2,arg1); + conf_edit_set_string(&cam->conf->secondary_model2,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.secondary_model2,arg1); + conf_edit_get_string(cam->conf->secondary_model2,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_model2",_("secondary_model2")); } static void conf_edit_secondary_config2(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf.secondary_config2,NULL); + conf_edit_set_string(&cam->conf->secondary_config2,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.secondary_config2,NULL); + conf_edit_set_string(&cam->conf->secondary_config2,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.secondary_config2,arg1); + conf_edit_set_string(&cam->conf->secondary_config2,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.secondary_config2,arg1); + conf_edit_get_string(cam->conf->secondary_config2,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_config2",_("secondary_config2")); @@ -981,42 +981,42 @@ static void conf_edit_secondary_config2(struct ctx_cam *cam, char *arg1, enum PA static void conf_edit_secondary_method3(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { int parm_in; if (pact == PARM_ACT_DFLT){ - cam->conf.secondary_method3 = 0; + cam->conf->secondary_method3 = 0; } else if (pact == PARM_ACT_SET){ parm_in = atoi(arg1); if ((parm_in < 0) ) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid secondary_method3 %d"),parm_in); } else { - cam->conf.secondary_method3 = parm_in; + cam->conf->secondary_method3 = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.secondary_method3, arg1); + conf_edit_get_int(cam->conf->secondary_method3, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_method3",_("secondary_method3")); } static void conf_edit_secondary_model3(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf.secondary_model3,NULL); + conf_edit_set_string(&cam->conf->secondary_model3,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.secondary_model3,NULL); + conf_edit_set_string(&cam->conf->secondary_model3,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.secondary_model3,arg1); + conf_edit_set_string(&cam->conf->secondary_model3,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.secondary_model3,arg1); + conf_edit_get_string(cam->conf->secondary_model3,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_model3",_("secondary_model3")); } static void conf_edit_secondary_config3(struct ctx_cam *cam, char *arg1, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { - conf_edit_set_string(&cam->conf.secondary_config3,NULL); + conf_edit_set_string(&cam->conf->secondary_config3,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.secondary_config3,NULL); + conf_edit_set_string(&cam->conf->secondary_config3,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.secondary_config3,arg1); + conf_edit_set_string(&cam->conf->secondary_config3,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.secondary_config3,arg1); + conf_edit_get_string(cam->conf->secondary_config3,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","secondary_config3",_("secondary_config3")); @@ -1024,83 +1024,83 @@ static void conf_edit_secondary_config3(struct ctx_cam *cam, char *arg1, enum PA 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; + 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; + cam->conf->noise_level = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.noise_level, arg1); + 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; + 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; + cam->conf->noise_tune = TRUE; } else { - cam->conf.noise_tune = FALSE; + cam->conf->noise_tune = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.noise_tune, arg1); + 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); + conf_edit_set_string(&cam->conf->despeckle_filter,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.despeckle_filter,NULL); + conf_edit_set_string(&cam->conf->despeckle_filter,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.despeckle_filter,arg1); + conf_edit_set_string(&cam->conf->despeckle_filter,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.despeckle_filter,arg1); + 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); + conf_edit_set_string(&cam->conf->area_detect,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.area_detect,NULL); + conf_edit_set_string(&cam->conf->area_detect,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.area_detect,arg1); + conf_edit_set_string(&cam->conf->area_detect,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.area_detect,arg1); + 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); + conf_edit_set_string(&cam->conf->mask_file,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.mask_file,NULL); + conf_edit_set_string(&cam->conf->mask_file,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.mask_file,arg1); + conf_edit_set_string(&cam->conf->mask_file,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.mask_file,arg1); + 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); + conf_edit_set_string(&cam->conf->mask_privacy,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.mask_privacy,NULL); + conf_edit_set_string(&cam->conf->mask_privacy,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.mask_privacy,arg1); + conf_edit_set_string(&cam->conf->mask_privacy,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.mask_privacy,arg1); + conf_edit_get_string(cam->conf->mask_privacy,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","mask_privacy",_("mask_privacy")); @@ -1108,16 +1108,16 @@ static void conf_edit_mask_privacy(struct ctx_cam *cam, char *arg1, enum PARM_AC 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; + 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; + cam->conf->smart_mask_speed = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.smart_mask_speed, arg1); + 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")); @@ -1125,16 +1125,16 @@ static void conf_edit_smart_mask_speed(struct ctx_cam *cam, char *arg1, enum PAR 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; + 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; + cam->conf->lightswitch_percent = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.lightswitch_percent, arg1); + conf_edit_get_int(cam->conf->lightswitch_percent, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","lightswitch_percent",_("lightswitch_percent")); @@ -1142,16 +1142,16 @@ static void conf_edit_lightswitch_percent(struct ctx_cam *cam, char *arg1, enum 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; + 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; + cam->conf->lightswitch_frames = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.lightswitch_frames, arg1); + conf_edit_get_int(cam->conf->lightswitch_frames, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","lightswitch_frames",_("lightswitch_frames")); @@ -1159,16 +1159,16 @@ static void conf_edit_lightswitch_frames(struct ctx_cam *cam, char *arg1, enum P 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; + 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; + cam->conf->minimum_motion_frames = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.minimum_motion_frames, arg1); + 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")); @@ -1176,16 +1176,16 @@ static void conf_edit_minimum_motion_frames(struct ctx_cam *cam, char *arg1, enu 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; + 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; + cam->conf->event_gap = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.event_gap, arg1); + conf_edit_get_int(cam->conf->event_gap, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","event_gap",_("event_gap")); @@ -1193,16 +1193,16 @@ static void conf_edit_event_gap(struct ctx_cam *cam, char *arg1, enum PARM_ACT p 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; + 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; + cam->conf->pre_capture = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.pre_capture, arg1); + conf_edit_get_int(cam->conf->pre_capture, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","pre_capture",_("pre_capture")); @@ -1210,16 +1210,16 @@ static void conf_edit_pre_capture(struct ctx_cam *cam, char *arg1, enum PARM_ACT 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; + 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; + cam->conf->post_capture = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.post_capture, arg1); + conf_edit_get_int(cam->conf->post_capture, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","post_capture",_("post_capture")); @@ -1227,117 +1227,117 @@ static void conf_edit_post_capture(struct ctx_cam *cam, char *arg1, enum PARM_AC 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); + conf_edit_set_string(&cam->conf->on_event_start,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_event_start,NULL); + 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); + conf_edit_set_string(&cam->conf->on_event_start,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_event_start,arg1); + 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); + conf_edit_set_string(&cam->conf->on_event_end,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_event_end,NULL); + 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); + conf_edit_set_string(&cam->conf->on_event_end,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_event_end,arg1); + 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); + conf_edit_set_string(&cam->conf->on_picture_save,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_picture_save,NULL); + 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); + conf_edit_set_string(&cam->conf->on_picture_save,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_picture_save,arg1); + 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); + conf_edit_set_string(&cam->conf->on_area_detected,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_area_detected,NULL); + 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); + conf_edit_set_string(&cam->conf->on_area_detected,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_area_detected,arg1); + 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); + conf_edit_set_string(&cam->conf->on_motion_detected,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_motion_detected,NULL); + 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); + conf_edit_set_string(&cam->conf->on_motion_detected,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_motion_detected,arg1); + 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); + conf_edit_set_string(&cam->conf->on_movie_start,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_movie_start,NULL); + 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); + conf_edit_set_string(&cam->conf->on_movie_start,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_movie_start,arg1); + 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); + conf_edit_set_string(&cam->conf->on_movie_end,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_movie_end,NULL); + 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); + conf_edit_set_string(&cam->conf->on_movie_end,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_movie_end,arg1); + 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); + conf_edit_set_string(&cam->conf->on_camera_lost,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_camera_lost,NULL); + 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); + conf_edit_set_string(&cam->conf->on_camera_lost,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_camera_lost,arg1); + 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); + conf_edit_set_string(&cam->conf->on_camera_found,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.on_camera_found,NULL); + 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); + conf_edit_set_string(&cam->conf->on_camera_found,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.on_camera_found,arg1); + 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")); @@ -1345,59 +1345,59 @@ static void conf_edit_on_camera_found(struct ctx_cam *cam, char *arg1, enum PARM 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"); + conf_edit_set_string(&cam->conf->picture_output,(char*)"off"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.picture_output,NULL); + conf_edit_set_string(&cam->conf->picture_output,NULL); } 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); + conf_edit_set_string(&cam->conf->picture_output, arg1); } else { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_output %s"),arg1); } } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.picture_output,arg1); + 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; + 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; + cam->conf->picture_output_motion = TRUE; } else { - cam->conf.picture_output_motion = FALSE; + cam->conf->picture_output_motion = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.picture_output_motion, arg1); + 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"); + conf_edit_set_string(&cam->conf->picture_type,(char*)"jpeg"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.picture_type,NULL); + conf_edit_set_string(&cam->conf->picture_type,NULL); } 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); + conf_edit_set_string(&cam->conf->picture_type, arg1); } else { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid picture_type %s"),arg1); } } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.picture_type,arg1); + conf_edit_get_string(cam->conf->picture_type,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_type",_("picture_type")); @@ -1405,44 +1405,44 @@ static void conf_edit_picture_type(struct ctx_cam *cam, char *arg1, enum PARM_AC 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; + 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; + cam->conf->picture_quality = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.picture_quality, arg1); + 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); + conf_edit_set_string(&cam->conf->picture_exif,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.picture_exif,NULL); + conf_edit_set_string(&cam->conf->picture_exif,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.picture_exif,arg1); + conf_edit_set_string(&cam->conf->picture_exif,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.picture_exif,arg1); + 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"); + conf_edit_set_string(&cam->conf->picture_filename,(char*)"%v-%Y%m%d%H%M%S-%q"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.picture_filename,NULL); + conf_edit_set_string(&cam->conf->picture_filename,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 != NULL){ - conf_edit_set_string(&cam->conf.picture_filename,arg1); + conf_edit_set_string(&cam->conf->picture_filename,arg1); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.picture_filename,arg1); + conf_edit_get_string(cam->conf->picture_filename,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","picture_filename",_("picture_filename")); @@ -1450,31 +1450,31 @@ static void conf_edit_picture_filename(struct ctx_cam *cam, char *arg1, enum PAR 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; + 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; + cam->conf->snapshot_interval = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.snapshot_interval, arg1); + 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"); + conf_edit_set_string(&cam->conf->snapshot_filename,(char*)"%v-%Y%m%d%H%M%S-snapshot"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.snapshot_filename,NULL); + conf_edit_set_string(&cam->conf->snapshot_filename,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 != NULL){ - conf_edit_set_string(&cam->conf.snapshot_filename,arg1); + conf_edit_set_string(&cam->conf->snapshot_filename,arg1); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.snapshot_filename,arg1); + conf_edit_get_string(cam->conf->snapshot_filename,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","snapshot_filename",_("snapshot_filename")); @@ -1482,30 +1482,30 @@ static void conf_edit_snapshot_filename(struct ctx_cam *cam, char *arg1, enum PA 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; + 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; + cam->conf->movie_output = TRUE; } else { - cam->conf.movie_output = FALSE; + cam->conf->movie_output = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.movie_output, arg1); + 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; + 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; + cam->conf->movie_output_motion = TRUE; } else { - cam->conf.movie_output_motion = FALSE; + cam->conf->movie_output_motion = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.movie_output_motion, arg1); + 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")); @@ -1513,16 +1513,16 @@ static void conf_edit_movie_output_motion(struct ctx_cam *cam, char *arg1, enum 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; + 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; + cam->conf->movie_max_time = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.movie_max_time, arg1); + 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")); @@ -1530,16 +1530,16 @@ static void conf_edit_movie_max_time(struct ctx_cam *cam, char *arg1, enum PARM_ 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; + 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; + cam->conf->movie_bps = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.movie_bps, arg1); + conf_edit_get_int(cam->conf->movie_bps, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_bps",_("movie_bps")); @@ -1547,89 +1547,89 @@ static void conf_edit_movie_bps(struct ctx_cam *cam, char *arg1, enum PARM_ACT p 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; + 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; + cam->conf->movie_quality = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.movie_quality, arg1); + 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"); + conf_edit_set_string(&cam->conf->movie_codec,(char*)"mkv"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.movie_codec,NULL); + conf_edit_set_string(&cam->conf->movie_codec,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 != NULL){ - conf_edit_set_string(&cam->conf.movie_codec,arg1); + conf_edit_set_string(&cam->conf->movie_codec,arg1); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.movie_codec,arg1); + 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; + 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; + cam->conf->movie_passthrough = TRUE; } else { - cam->conf.movie_passthrough = FALSE; + cam->conf->movie_passthrough = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.movie_passthrough, arg1); + 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"); + conf_edit_set_string(&cam->conf->movie_filename,(char*)"%v-%Y%m%d%H%M%S"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.movie_filename,NULL); + conf_edit_set_string(&cam->conf->movie_filename,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 != NULL){ - conf_edit_set_string(&cam->conf.movie_filename,arg1); + conf_edit_set_string(&cam->conf->movie_filename,arg1); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.movie_filename,arg1); + 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; + 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; + cam->conf->movie_extpipe_use = TRUE; } else { - cam->conf.movie_extpipe_use = FALSE; + cam->conf->movie_extpipe_use = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.movie_extpipe_use, arg1); + 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); + conf_edit_set_string(&cam->conf->movie_extpipe,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.movie_extpipe,NULL); + conf_edit_set_string(&cam->conf->movie_extpipe,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.movie_extpipe,arg1); + conf_edit_set_string(&cam->conf->movie_extpipe,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.movie_extpipe,arg1); + conf_edit_get_string(cam->conf->movie_extpipe,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","movie_extpipe",_("movie_extpipe")); @@ -1638,25 +1638,25 @@ static void conf_edit_movie_extpipe(struct ctx_cam *cam, char *arg1, enum PARM_A 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; + 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; + cam->conf->timelapse_interval = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.timelapse_interval, arg1); + 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"); + conf_edit_set_string(&cam->conf->timelapse_mode,(char*)"daily"); } else if ((pact == PARM_ACT_FREE)){ - conf_edit_set_string(&cam->conf.timelapse_mode,NULL); + conf_edit_set_string(&cam->conf->timelapse_mode,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 == NULL){ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_mode %s"),arg1); @@ -1664,13 +1664,13 @@ static void conf_edit_timelapse_mode(struct ctx_cam *cam, char *arg1, enum PARM_ 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); + conf_edit_set_string(&cam->conf->timelapse_mode, arg1); } else { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_mode %s"),arg1); } } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.timelapse_mode,arg1); + conf_edit_get_string(cam->conf->timelapse_mode,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_mode",_("timelapse_mode")); @@ -1678,52 +1678,52 @@ static void conf_edit_timelapse_mode(struct ctx_cam *cam, char *arg1, enum PARM_ 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; + 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; + cam->conf->timelapse_fps = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.timelapse_fps, arg1); + 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"); + conf_edit_set_string(&cam->conf->timelapse_codec,(char*)"mpg"); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.timelapse_codec,NULL); + conf_edit_set_string(&cam->conf->timelapse_codec,NULL); } 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); + conf_edit_set_string(&cam->conf->timelapse_codec, arg1); } else { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid timelapse_codec %s"),arg1); } } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.timelapse_codec,arg1); + 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"); + conf_edit_set_string(&cam->conf->timelapse_filename,(char*)"%Y%m%d-timelapse"); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.timelapse_filename,NULL); + conf_edit_set_string(&cam->conf->timelapse_filename,NULL); } else if (pact == PARM_ACT_SET){ if (arg1 != NULL){ - conf_edit_set_string(&cam->conf.timelapse_filename,arg1); + conf_edit_set_string(&cam->conf->timelapse_filename,arg1); } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.timelapse_filename,arg1); + conf_edit_get_string(cam->conf->timelapse_filename,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","timelapse_filename",_("timelapse_filename")); @@ -1731,26 +1731,26 @@ static void conf_edit_timelapse_filename(struct ctx_cam *cam, char *arg1, enum P 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); + conf_edit_set_string(&cam->conf->video_pipe,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.video_pipe,NULL); + conf_edit_set_string(&cam->conf->video_pipe,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.video_pipe,arg1); + conf_edit_set_string(&cam->conf->video_pipe,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.video_pipe,arg1); + 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); + conf_edit_set_string(&cam->conf->video_pipe_motion,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.video_pipe_motion,NULL); + 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); + conf_edit_set_string(&cam->conf->video_pipe_motion,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.video_pipe_motion,arg1); + 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")); @@ -1759,46 +1759,46 @@ static void conf_edit_video_pipe_motion(struct ctx_cam *cam, char *arg1, enum PA 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; + 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; + cam->conf->webcontrol_port = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.webcontrol_port, arg1); + 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; + 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; + cam->conf->webcontrol_ipv6 = TRUE; } else { - cam->conf.webcontrol_ipv6 = FALSE; + cam->conf->webcontrol_ipv6 = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.webcontrol_ipv6, arg1); + 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; + 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; + cam->conf->webcontrol_localhost = TRUE; } else { - cam->conf.webcontrol_localhost = FALSE; + cam->conf->webcontrol_localhost = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.webcontrol_localhost, arg1); + conf_edit_get_bool(cam->conf->webcontrol_localhost, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_localhost",_("webcontrol_localhost")); @@ -1806,16 +1806,16 @@ static void conf_edit_webcontrol_localhost(struct ctx_cam *cam, char *arg1, enum 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; + 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; + cam->conf->webcontrol_parms = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.webcontrol_parms, arg1); + conf_edit_get_int(cam->conf->webcontrol_parms, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_parms",_("webcontrol_parms")); @@ -1823,16 +1823,16 @@ static void conf_edit_webcontrol_parms(struct ctx_cam *cam, char *arg1, enum PAR 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; + 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; + cam->conf->webcontrol_interface = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.webcontrol_interface, arg1); + conf_edit_get_int(cam->conf->webcontrol_interface, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","webcontrol_interface",_("webcontrol_interface")); @@ -1840,79 +1840,79 @@ static void conf_edit_webcontrol_interface(struct ctx_cam *cam, char *arg1, enum 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; + 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; + cam->conf->webcontrol_auth_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.webcontrol_auth_method, arg1); + 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); + conf_edit_set_string(&cam->conf->webcontrol_authentication,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.webcontrol_authentication,NULL); + conf_edit_set_string(&cam->conf->webcontrol_authentication,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.webcontrol_authentication,arg1); + conf_edit_set_string(&cam->conf->webcontrol_authentication,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.webcontrol_authentication,arg1); + 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; + 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; + cam->conf->webcontrol_tls = TRUE; } else { - cam->conf.webcontrol_tls = FALSE; + cam->conf->webcontrol_tls = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.webcontrol_tls, arg1); + 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); + conf_edit_set_string(&cam->conf->webcontrol_cert,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.webcontrol_cert,NULL); + conf_edit_set_string(&cam->conf->webcontrol_cert,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.webcontrol_cert,arg1); + conf_edit_set_string(&cam->conf->webcontrol_cert,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.webcontrol_cert,arg1); + 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); + conf_edit_set_string(&cam->conf->webcontrol_key,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.webcontrol_key,NULL); + conf_edit_set_string(&cam->conf->webcontrol_key,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.webcontrol_key,arg1); + conf_edit_set_string(&cam->conf->webcontrol_key,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.webcontrol_key,arg1); + 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); + conf_edit_set_string(&cam->conf->webcontrol_cors_header,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.webcontrol_cors_header,NULL); + conf_edit_set_string(&cam->conf->webcontrol_cors_header,NULL); } else if (pact == PARM_ACT_SET){ // 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 @@ -1929,9 +1929,9 @@ static void conf_edit_webcontrol_cors_header(struct ctx_cam *cam, char *arg1, en return; } regfree(®ex); - conf_edit_set_string(&cam->conf.webcontrol_cors_header,arg1); + conf_edit_set_string(&cam->conf->webcontrol_cors_header,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.webcontrol_cors_header,arg1); + 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")); @@ -1940,31 +1940,31 @@ static void conf_edit_webcontrol_cors_header(struct ctx_cam *cam, char *arg1, en 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; + 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; + cam->conf->stream_port = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.stream_port, arg1); + 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; + 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; + cam->conf->stream_localhost = TRUE; } else { - cam->conf.stream_localhost = FALSE; + cam->conf->stream_localhost = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.stream_localhost, arg1); + conf_edit_get_bool(cam->conf->stream_localhost, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_localhost",_("stream_localhost")); @@ -1972,53 +1972,53 @@ static void conf_edit_stream_localhost(struct ctx_cam *cam, char *arg1, enum PAR 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; + 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; + cam->conf->stream_auth_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.stream_auth_method, arg1); + 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); + conf_edit_set_string(&cam->conf->stream_authentication,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.stream_authentication,NULL); + conf_edit_set_string(&cam->conf->stream_authentication,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.stream_authentication,arg1); + conf_edit_set_string(&cam->conf->stream_authentication,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.stream_authentication,arg1); + 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; + 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; + cam->conf->stream_tls = TRUE; } else { - cam->conf.stream_tls = FALSE; + cam->conf->stream_tls = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.stream_tls, arg1); + 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); + conf_edit_set_string(&cam->conf->stream_cors_header,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.stream_cors_header,NULL); + conf_edit_set_string(&cam->conf->stream_cors_header,NULL); } else if (pact == PARM_ACT_SET){ // 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 @@ -2035,9 +2035,9 @@ static void conf_edit_stream_cors_header(struct ctx_cam *cam, char *arg1, enum P return; } regfree(®ex); - conf_edit_set_string(&cam->conf.stream_cors_header,arg1); + conf_edit_set_string(&cam->conf->stream_cors_header,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.stream_cors_header,arg1); + 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")); @@ -2045,31 +2045,31 @@ static void conf_edit_stream_cors_header(struct ctx_cam *cam, char *arg1, enum P 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; + 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; + cam->conf->stream_preview_scale = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.stream_preview_scale, arg1); + 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; + 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; + cam->conf->stream_preview_newline = TRUE; } else { - cam->conf.stream_preview_newline = FALSE; + cam->conf->stream_preview_newline = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.stream_preview_newline, arg1); + 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")); @@ -2077,16 +2077,16 @@ static void conf_edit_stream_preview_newline(struct ctx_cam *cam, char *arg1, en 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; + 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; + cam->conf->stream_preview_method = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.stream_preview_method, arg1); + 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")); @@ -2094,46 +2094,46 @@ static void conf_edit_stream_preview_method(struct ctx_cam *cam, char *arg1, enu 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; + 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; + cam->conf->stream_quality = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.stream_quality, arg1); + 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; + 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; + cam->conf->stream_grey = TRUE; } else { - cam->conf.stream_grey = FALSE; + cam->conf->stream_grey = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.stream_grey, arg1); + 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; + 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; + cam->conf->stream_motion = TRUE; } else { - cam->conf.stream_motion = FALSE; + cam->conf->stream_motion = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.stream_motion, arg1); + conf_edit_get_bool(cam->conf->stream_motion, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_motion",_("stream_motion")); @@ -2141,63 +2141,63 @@ static void conf_edit_stream_motion(struct ctx_cam *cam, char *arg1, enum PARM_A 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; + 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; + cam->conf->stream_maxrate = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.stream_maxrate, arg1); + 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); + conf_edit_set_string(&cam->conf->database_type,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.database_type,NULL); + 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); + 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); + conf_edit_set_string(&cam->conf->database_type, arg1); } else { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid database_type %s"),arg1); } } } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.database_type,arg1); + 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); + conf_edit_set_string(&cam->conf->database_dbname,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.database_dbname,NULL); + conf_edit_set_string(&cam->conf->database_dbname,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.database_dbname,arg1); + conf_edit_set_string(&cam->conf->database_dbname,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.database_dbname,arg1); + 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); + conf_edit_set_string(&cam->conf->database_host,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.database_host,NULL); + conf_edit_set_string(&cam->conf->database_host,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.database_host,arg1); + conf_edit_set_string(&cam->conf->database_host,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.database_host,arg1); + conf_edit_get_string(cam->conf->database_host,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_host",_("database_host")); @@ -2205,42 +2205,42 @@ static void conf_edit_database_host(struct ctx_cam *cam, char *arg1, enum PARM_A 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; + 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; + cam->conf->database_port = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.database_port, arg1); + 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); + conf_edit_set_string(&cam->conf->database_user,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.database_user,NULL); + conf_edit_set_string(&cam->conf->database_user,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.database_user,arg1); + conf_edit_set_string(&cam->conf->database_user,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.database_user,arg1); + 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); + conf_edit_set_string(&cam->conf->database_password,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.database_password,NULL); + conf_edit_set_string(&cam->conf->database_password,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.database_password,arg1); + conf_edit_set_string(&cam->conf->database_password,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.database_password,arg1); + conf_edit_get_string(cam->conf->database_password,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","database_password",_("database_password")); @@ -2248,16 +2248,16 @@ static void conf_edit_database_password(struct ctx_cam *cam, char *arg1, enum PA 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; + 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; + cam->conf->database_busy_timeout = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.database_busy_timeout, arg1); + 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")); @@ -2265,99 +2265,99 @@ static void conf_edit_database_busy_timeout(struct ctx_cam *cam, char *arg1, enu 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; + 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; + cam->conf->sql_log_picture = TRUE; } else { - cam->conf.sql_log_picture = FALSE; + cam->conf->sql_log_picture = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.sql_log_picture, arg1); + 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; + 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; + cam->conf->sql_log_snapshot = TRUE; } else { - cam->conf.sql_log_snapshot = FALSE; + cam->conf->sql_log_snapshot = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.sql_log_snapshot, arg1); + 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; + 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; + cam->conf->sql_log_movie = TRUE; } else { - cam->conf.sql_log_movie = FALSE; + cam->conf->sql_log_movie = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.sql_log_movie, arg1); + 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; + 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; + cam->conf->sql_log_timelapse = TRUE; } else { - cam->conf.sql_log_timelapse = FALSE; + cam->conf->sql_log_timelapse = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.sql_log_timelapse, arg1); + 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); + conf_edit_set_string(&cam->conf->sql_query_start,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.sql_query_start,NULL); + 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); + conf_edit_set_string(&cam->conf->sql_query_start,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.sql_query_start,arg1); + 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); + conf_edit_set_string(&cam->conf->sql_query_stop,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.sql_query_stop,NULL); + 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); + conf_edit_set_string(&cam->conf->sql_query_stop,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.sql_query_stop,arg1); + 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); + conf_edit_set_string(&cam->conf->sql_query,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.sql_query,NULL); + conf_edit_set_string(&cam->conf->sql_query,NULL); } else if (pact == PARM_ACT_SET){ - conf_edit_set_string(&cam->conf.sql_query,arg1); + conf_edit_set_string(&cam->conf->sql_query,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.sql_query,arg1); + conf_edit_get_string(cam->conf->sql_query,arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query",_("sql_query")); @@ -2366,31 +2366,31 @@ static void conf_edit_sql_query(struct ctx_cam *cam, char *arg1, enum PARM_ACT p 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; + 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; + cam->conf->track_type = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.track_type, arg1); + 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; + 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; + cam->conf->track_auto = TRUE; } else { - cam->conf.track_auto = FALSE; + cam->conf->track_auto = FALSE; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_bool(cam->conf.track_auto, arg1); + conf_edit_get_bool(cam->conf->track_auto, arg1); } return; MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_auto",_("track_auto")); @@ -2398,29 +2398,29 @@ static void conf_edit_track_auto(struct ctx_cam *cam, char *arg1, enum PARM_ACT 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; + 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; + cam->conf->track_move_wait = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.track_move_wait, arg1); + 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); + conf_edit_set_string(&cam->conf->track_generic_move,NULL); } else if (pact == PARM_ACT_FREE){ - conf_edit_set_string(&cam->conf.track_generic_move,NULL); + 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); + conf_edit_set_string(&cam->conf->track_generic_move,arg1); } else if (pact == PARM_ACT_GET){ - conf_edit_get_string(cam->conf.track_generic_move,arg1); + 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")); @@ -2428,16 +2428,16 @@ static void conf_edit_track_generic_move(struct ctx_cam *cam, char *arg1, enum P 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; + 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; + cam->conf->track_step_angle_x = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.track_step_angle_x, arg1); + 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")); @@ -2445,16 +2445,16 @@ static void conf_edit_track_step_angle_x(struct ctx_cam *cam, char *arg1, enum P 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; + 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; + cam->conf->track_step_angle_y = parm_in; } } else if (pact == PARM_ACT_GET){ - conf_edit_get_int(cam->conf.track_step_angle_y, arg1); + 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")); diff --git a/src/dbse.cpp b/src/dbse.cpp index dfd2b722..c788b336 100644 --- a/src/dbse.cpp +++ b/src/dbse.cpp @@ -21,6 +21,7 @@ #include "motion.hpp" +#include "conf.hpp" #include "util.hpp" #include "logger.hpp" #include "dbse.hpp" @@ -30,14 +31,14 @@ static int dbse_global_edits(struct ctx_cam **cam_list){ int retcd = 0; - if (cam_list[0]->conf.database_dbname == NULL){ + if (cam_list[0]->conf->database_dbname == NULL){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Invalid database name")); retcd = -1; } - if (((mystreq(cam_list[0]->conf.database_type, "mysql")) || - (mystreq(cam_list[0]->conf.database_type, "pgsql"))) && - (cam_list[0]->conf.database_port == 0)){ + if (((mystreq(cam_list[0]->conf->database_type, "mysql")) || + (mystreq(cam_list[0]->conf->database_type, "pgsql"))) && + (cam_list[0]->conf->database_port == 0)){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Must specify database port for mysql/pgsql")); retcd = -1; @@ -46,8 +47,8 @@ static int dbse_global_edits(struct ctx_cam **cam_list){ if (retcd == -1){ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Database functionality disabled.")); - free((void *)cam_list[0]->conf.database_type); - cam_list[0]->conf.database_type = NULL; + free((void *)cam_list[0]->conf->database_type); + cam_list[0]->conf->database_type = NULL; } return retcd; @@ -59,8 +60,8 @@ void dbse_global_deinit(struct ctx_cam **cam_list){ int indx; #if defined(HAVE_MYSQL) || defined(HAVE_MARIADB) - if (cam_list[0]->conf.database_type != NULL) { - if (mystreq(cam_list[0]->conf.database_type, "mysql")) { + if (cam_list[0]->conf->database_type != NULL) { + if (mystreq(cam_list[0]->conf->database_type, "mysql")) { MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, _("Closing MYSQL")); mysql_library_end(); } @@ -87,19 +88,19 @@ void dbse_global_init(struct ctx_cam **cam_list){ indx++; } - if (cam_list[0]->conf.database_type != NULL) { + if (cam_list[0]->conf->database_type != NULL) { if (dbse_global_edits(cam_list) == -1) return; MOTION_LOG(DBG, TYPE_DB, NO_ERRNO,_("Initializing database")); /* Initialize all the database items */ #if defined(HAVE_MYSQL) || defined(HAVE_MARIADB) - if (mystreq(cam_list[0]->conf.database_type, "mysql")) { + if (mystreq(cam_list[0]->conf->database_type, "mysql")) { if (mysql_library_init(0, NULL, NULL)) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Could not initialize database %s") - ,cam_list[0]->conf.database_type); - free((void *)cam_list[0]->conf.database_type); - cam_list[0]->conf.database_type = NULL; + ,cam_list[0]->conf->database_type); + free((void *)cam_list[0]->conf->database_type); + cam_list[0]->conf->database_type = NULL; return; } } @@ -109,33 +110,33 @@ void dbse_global_init(struct ctx_cam **cam_list){ /* database_sqlite3 == NULL if not changed causes each thread to create their own * sqlite3 connection this will only happens when using a non-threaded sqlite version */ cam_list[0]->dbse->database_sqlite3=NULL; - if ((mystreq(cam_list[0]->conf.database_type, "sqlite3")) && - cam_list[0]->conf.database_dbname) { + if ((mystreq(cam_list[0]->conf->database_type, "sqlite3")) && + cam_list[0]->conf->database_dbname) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO ,_("SQLite3 Database filename %s") - ,cam_list[0]->conf.database_dbname); + ,cam_list[0]->conf->database_dbname); int thread_safe = sqlite3_threadsafe(); if (thread_safe > 0) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, _("SQLite3 is threadsafe")); MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, _("SQLite3 serialized %s") ,(sqlite3_config(SQLITE_CONFIG_SERIALIZED)?_("FAILED"):_("SUCCESS"))); - if (sqlite3_open(cam_list[0]->conf.database_dbname, &cam_list[0]->dbse->database_sqlite3) != SQLITE_OK) { + if (sqlite3_open(cam_list[0]->conf->database_dbname, &cam_list[0]->dbse->database_sqlite3) != SQLITE_OK) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Can't open database %s : %s") - ,cam_list[0]->conf.database_dbname + ,cam_list[0]->conf->database_dbname ,sqlite3_errmsg(cam_list[0]->dbse->database_sqlite3)); sqlite3_close(cam_list[0]->dbse->database_sqlite3); MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Could not initialize database %s") - ,cam_list[0]->conf.database_dbname); - free((void *)cam_list[0]->conf.database_type); - cam_list[0]->conf.database_type = NULL; + ,cam_list[0]->conf->database_dbname); + free((void *)cam_list[0]->conf->database_type); + cam_list[0]->conf->database_type = NULL; return; } MOTION_LOG(NTC, TYPE_DB, NO_ERRNO,_("database_busy_timeout %d msec"), - cam_list[0]->conf.database_busy_timeout); - if (sqlite3_busy_timeout(cam_list[0]->dbse->database_sqlite3, cam_list[0]->conf.database_busy_timeout) != SQLITE_OK) + cam_list[0]->conf->database_busy_timeout); + if (sqlite3_busy_timeout(cam_list[0]->dbse->database_sqlite3, cam_list[0]->conf->database_busy_timeout) != SQLITE_OK) MOTION_LOG(ERR, TYPE_DB, NO_ERRNO,_("database_busy_timeout failed %s") ,sqlite3_errmsg(cam_list[0]->dbse->database_sqlite3)); } @@ -161,19 +162,19 @@ static void dbse_init_mysql(struct ctx_cam *cam){ cam->dbse->database = (MYSQL *) mymalloc(sizeof(MYSQL)); mysql_init(cam->dbse->database); - if (!mysql_real_connect(cam->dbse->database, cam->conf.database_host, cam->conf.database_user, - cam->conf.database_password, cam->conf.database_dbname, 0, NULL, 0)) { + if (!mysql_real_connect(cam->dbse->database, cam->conf->database_host, cam->conf->database_user, + cam->conf->database_password, cam->conf->database_dbname, 0, NULL, 0)) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Cannot connect to MySQL database %s on host %s with user %s") - ,cam->conf.database_dbname, cam->conf.database_host - ,cam->conf.database_user); + ,cam->conf->database_dbname, cam->conf->database_host + ,cam->conf->database_user); MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("MySQL error was %s"), mysql_error(cam->dbse->database)); MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Disabling database functionality")); dbse_global_deinit(cam->cam_list); - free((void *)cam->conf.database_type); - cam->conf.database_type = NULL; + free((void *)cam->conf->database_type); + cam->conf->database_type = NULL; return; } #if (defined(MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID > 50012) @@ -195,21 +196,21 @@ static void dbse_init_sqlite3(struct ctx_cam *cam){ cam->dbse->database_sqlite3 = cam->cam_list[0]->dbse->database_sqlite3; } else { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO - ,_("SQLite3 Database filename %s"), cam->conf.database_dbname); - if (sqlite3_open(cam->conf.database_dbname, &cam->dbse->database_sqlite3) != SQLITE_OK) { + ,_("SQLite3 Database filename %s"), cam->conf->database_dbname); + if (sqlite3_open(cam->conf->database_dbname, &cam->dbse->database_sqlite3) != SQLITE_OK) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Can't open database %s : %s") - ,cam->conf.database_dbname, sqlite3_errmsg(cam->dbse->database_sqlite3)); + ,cam->conf->database_dbname, sqlite3_errmsg(cam->dbse->database_sqlite3)); sqlite3_close(cam->dbse->database_sqlite3); MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Disabling database functionality")); - free((void *)cam->conf.database_type); - cam->conf.database_type = NULL; + free((void *)cam->conf->database_type); + cam->conf->database_type = NULL; return; } MOTION_LOG(NTC, TYPE_DB, NO_ERRNO - ,_("database_busy_timeout %d msec"), cam->conf.database_busy_timeout); - if (sqlite3_busy_timeout(cam->dbse->database_sqlite3, cam->conf.database_busy_timeout) != SQLITE_OK) + ,_("database_busy_timeout %d msec"), cam->conf->database_busy_timeout); + if (sqlite3_busy_timeout(cam->dbse->database_sqlite3, cam->conf->database_busy_timeout) != SQLITE_OK) MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("database_busy_timeout failed %s") ,sqlite3_errmsg(cam->dbse->database_sqlite3)); @@ -230,22 +231,22 @@ static void dbse_init_pgsql(struct ctx_cam *cam){ */ snprintf(connstring, 255, "dbname='%s' host='%s' user='%s' password='%s' port='%d'", - cam->conf.database_dbname, /* dbname */ - (cam->conf.database_host ? cam->conf.database_host : ""), /* host (may be blank) */ - (cam->conf.database_user ? cam->conf.database_user : ""), /* user (may be blank) */ - (cam->conf.database_password ? cam->conf.database_password : ""), /* password (may be blank) */ - cam->conf.database_port + cam->conf->database_dbname, /* dbname */ + (cam->conf->database_host ? cam->conf->database_host : ""), /* host (may be blank) */ + (cam->conf->database_user ? cam->conf->database_user : ""), /* user (may be blank) */ + (cam->conf->database_password ? cam->conf->database_password : ""), /* password (may be blank) */ + cam->conf->database_port ); cam->dbse->database_pg = PQconnectdb(connstring); if (PQstatus(cam->dbse->database_pg) == CONNECTION_BAD) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Connection to PostgreSQL database '%s' failed: %s") - ,cam->conf.database_dbname, PQerrorMessage(cam->dbse->database_pg)); + ,cam->conf->database_dbname, PQerrorMessage(cam->dbse->database_pg)); MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Disabling database functionality")); - free((void *)cam->conf.database_type); - cam->conf.database_type = NULL; + free((void *)cam->conf->database_type); + cam->conf->database_type = NULL; return; } #else @@ -257,19 +258,19 @@ static void dbse_init_pgsql(struct ctx_cam *cam){ void dbse_init(struct ctx_cam *cam){ - if (cam->conf.database_type) { + if (cam->conf->database_type) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO - ,_("Database backend %s"), cam->conf.database_type); - if (mystreq(cam->conf.database_type, "mysql")) { + ,_("Database backend %s"), cam->conf->database_type); + if (mystreq(cam->conf->database_type, "mysql")) { dbse_init_mysql(cam); - } else if (mystreq(cam->conf.database_type, "postgresql")) { + } else if (mystreq(cam->conf->database_type, "postgresql")) { dbse_init_pgsql(cam); - } else if (mystreq(cam->conf.database_type, "sqlite3")) { + } else if (mystreq(cam->conf->database_type, "sqlite3")) { dbse_init_sqlite3(cam); } else { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO ,_("Invalid Database backend %s") - , cam->conf.database_type); + , cam->conf->database_type); } dbse_sqlmask_update(cam); } @@ -278,25 +279,25 @@ void dbse_init(struct ctx_cam *cam){ } void dbse_deinit(struct ctx_cam *cam){ - if (cam->conf.database_type) { + if (cam->conf->database_type) { MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, _("Closing database")); #if defined(HAVE_MYSQL) || defined(HAVE_MARIADB) - if (mystreq(cam->conf.database_type, "mysql")) { + if (mystreq(cam->conf->database_type, "mysql")) { mysql_close(cam->dbse->database); cam->dbse->database_event_id = 0; } #endif /* HAVE_MYSQL */ #ifdef HAVE_PGSQL - if (mystreq(cam->conf.database_type, "postgresql")) { + if (mystreq(cam->conf->database_type, "postgresql")) { PQfinish(cam->dbse->database_pg); } #endif /* HAVE_PGSQL */ #ifdef HAVE_SQLITE3 /* Close the SQLite database */ - if (mystreq(cam->conf.database_type, "sqlite3")) { + if (mystreq(cam->conf->database_type, "sqlite3")) { sqlite3_close(cam->dbse->database_sqlite3); cam->dbse->database_sqlite3 = NULL; } @@ -311,10 +312,10 @@ void dbse_sqlmask_update(struct ctx_cam *cam){ * We update it for every frame in case the config was updated * via remote control. */ - cam->dbse->sql_mask = cam->conf.sql_log_picture * (FTYPE_IMAGE + FTYPE_IMAGE_MOTION) + - cam->conf.sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + - cam->conf.sql_log_movie * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + - cam->conf.sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; + cam->dbse->sql_mask = cam->conf->sql_log_picture * (FTYPE_IMAGE + FTYPE_IMAGE_MOTION) + + cam->conf->sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + + cam->conf->sql_log_movie * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + + cam->conf->sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; } static void dbse_mysql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) { @@ -335,19 +336,19 @@ static void dbse_mysql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) { cam->dbse->database = (MYSQL *) mymalloc(sizeof(MYSQL)); mysql_init(cam->dbse->database); - if (!mysql_real_connect(cam->dbse->database, cam->conf.database_host, - cam->conf.database_user, cam->conf.database_password, - cam->conf.database_dbname, 0, NULL, 0)) { + if (!mysql_real_connect(cam->dbse->database, cam->conf->database_host, + cam->conf->database_user, cam->conf->database_password, + cam->conf->database_dbname, 0, NULL, 0)) { MOTION_LOG(ALR, TYPE_DB, NO_ERRNO ,_("Cannot reconnect to MySQL" " database %s on host %s with user %s MySQL error was %s"), - cam->conf.database_dbname, - cam->conf.database_host, cam->conf.database_user, + cam->conf->database_dbname, + cam->conf->database_host, cam->conf->database_user, mysql_error(cam->dbse->database)); } else { MOTION_LOG(INF, TYPE_DB, NO_ERRNO ,_("Re-Connection to Mysql database '%s' Succeed") - ,cam->conf.database_dbname); + ,cam->conf->database_dbname); if (mysql_query(cam->dbse->database, sqlquery) != 0) { int error_my = mysql_errno(cam->dbse->database); MOTION_LOG(ERR, TYPE_DB, SHOW_ERRNO @@ -379,7 +380,7 @@ static void dbse_pgsql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Connection to PostgreSQL database '%s' failed: %s") - ,cam->conf.database_dbname, PQerrorMessage(cam->dbse->database_pg)); + ,cam->conf->database_dbname, PQerrorMessage(cam->dbse->database_pg)); // This function will close the connection to the server and attempt to reestablish a new connection to the same server, // using all the same parameters previously used. This may be useful for error recovery if a working connection is lost @@ -388,11 +389,11 @@ static void dbse_pgsql_exec(char *sqlquery,struct ctx_cam *cam, int save_id) { if (PQstatus(cam->dbse->database_pg) == CONNECTION_BAD) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO ,_("Re-Connection to PostgreSQL database '%s' failed: %s") - ,cam->conf.database_dbname, PQerrorMessage(cam->dbse->database_pg)); + ,cam->conf->database_dbname, PQerrorMessage(cam->dbse->database_pg)); } else { MOTION_LOG(INF, TYPE_DB, NO_ERRNO ,_("Re-Connection to PostgreSQL database '%s' Succeed") - ,cam->conf.database_dbname); + ,cam->conf->database_dbname); } } else if (!(PQresultStatus(res) == PGRES_COMMAND_OK || PQresultStatus(res) == PGRES_TUPLES_OK)) { @@ -438,7 +439,7 @@ void dbse_firstmotion(struct ctx_cam *cam){ char sqlquery[PATH_MAX]; - mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf.sql_query_start, + mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query_start, &cam->current_image->imgts, NULL, 0); if (strlen(sqlquery) <= 0) { @@ -446,11 +447,11 @@ void dbse_firstmotion(struct ctx_cam *cam){ return; } - if (mystreq(cam->conf.database_type, "mysql")) { + if (mystreq(cam->conf->database_type, "mysql")) { dbse_mysql_exec(sqlquery, cam, 1); - } else if (mystreq(cam->conf.database_type, "postgresql")) { + } else if (mystreq(cam->conf->database_type, "postgresql")) { dbse_pgsql_exec(sqlquery, cam, 1); - } else if (mystreq(cam->conf.database_type, "sqlite3")) { + } else if (mystreq(cam->conf->database_type, "sqlite3")) { dbse_sqlite3_exec(sqlquery, cam, 1); } @@ -459,7 +460,7 @@ void dbse_firstmotion(struct ctx_cam *cam){ void dbse_newfile(struct ctx_cam *cam, char *filename, int sqltype, struct timespec *ts1) { char sqlquery[PATH_MAX]; - mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf.sql_query, + mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query, ts1, filename, sqltype); if (strlen(sqlquery) <= 0) { @@ -467,11 +468,11 @@ void dbse_newfile(struct ctx_cam *cam, char *filename, int sqltype, struct times return; } - if (mystreq(cam->conf.database_type, "mysql")) { + if (mystreq(cam->conf->database_type, "mysql")) { dbse_mysql_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf.database_type, "postgresql")) { + } else if (mystreq(cam->conf->database_type, "postgresql")) { dbse_pgsql_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf.database_type, "sqlite3")) { + } else if (mystreq(cam->conf->database_type, "sqlite3")) { dbse_sqlite3_exec(sqlquery, cam, 0); } @@ -481,14 +482,14 @@ void dbse_fileclose(struct ctx_cam *cam, char *filename, int sqltype, struct tim char sqlquery[PATH_MAX]; - mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf.sql_query_stop, + mystrftime(cam, sqlquery, sizeof(sqlquery), cam->conf->sql_query_stop, ts1, filename, sqltype); - if (mystreq(cam->conf.database_type, "mysql")) { + if (mystreq(cam->conf->database_type, "mysql")) { dbse_mysql_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf.database_type, "postgresql")) { + } else if (mystreq(cam->conf->database_type, "postgresql")) { dbse_pgsql_exec(sqlquery, cam, 0); - } else if (mystreq(cam->conf.database_type, "sqlite3")) { + } else if (mystreq(cam->conf->database_type, "sqlite3")) { dbse_sqlite3_exec(sqlquery, cam, 0); } diff --git a/src/draw.cpp b/src/draw.cpp index 26272f53..e60a9a02 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -11,6 +11,7 @@ #include #include "motion.hpp" +#include "conf.hpp" #include "util.hpp" #include "logger.hpp" #include "draw.hpp" @@ -1207,7 +1208,7 @@ void draw_init_scale(struct ctx_cam *cam){ * scaling does not occupy more than 1/4 of image (10 pixels * 2 lines) */ - cam->text_scale = cam->conf.text_scale; + cam->text_scale = cam->conf->text_scale; if (cam->text_scale <= 0) cam->text_scale = 1; if ((cam->text_scale * 10 * 2) > (cam->imgs.width / 4)) { @@ -1225,7 +1226,7 @@ void draw_init_scale(struct ctx_cam *cam){ } /* If we had to modify the scale, change conf so we don't get another message */ - cam->conf.text_scale = cam->text_scale; + cam->conf->text_scale = cam->text_scale; } diff --git a/src/event.cpp b/src/event.cpp index 8bd384d4..f8b30352 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -8,6 +8,7 @@ see also the file 'COPYING'. */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "picture.hpp" @@ -134,7 +135,7 @@ static void event_beep(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (!cam->conf.quiet) + if (!cam->conf->quiet) printf("\a"); } @@ -156,11 +157,11 @@ static void on_picture_save_command(struct ctx_cam *cam, motion_event evnt (void)img_data; (void)ts1; - if ((filetype & FTYPE_IMAGE_ANY) != 0 && cam->conf.on_picture_save) - exec_command(cam, cam->conf.on_picture_save, fname, filetype); + if ((filetype & FTYPE_IMAGE_ANY) != 0 && cam->conf->on_picture_save) + exec_command(cam, cam->conf->on_picture_save, fname, filetype); - if ((filetype & FTYPE_MPEG_ANY) != 0 && cam->conf.on_movie_start) - exec_command(cam, cam->conf.on_movie_start, fname, filetype); + if ((filetype & FTYPE_MPEG_ANY) != 0 && cam->conf->on_movie_start) + exec_command(cam, cam->conf->on_movie_start, fname, filetype); } static void on_motion_detected_command(struct ctx_cam *cam, motion_event evnt @@ -173,8 +174,8 @@ static void on_motion_detected_command(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf.on_motion_detected) - exec_command(cam, cam->conf.on_motion_detected, NULL, 0); + if (cam->conf->on_motion_detected) + exec_command(cam, cam->conf->on_motion_detected, NULL, 0); } static void event_sqlfirstmotion(struct ctx_cam *cam, motion_event evnt @@ -187,7 +188,7 @@ static void event_sqlfirstmotion(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (!(cam->conf.database_type)) { + if (!(cam->conf->database_type)) { return; } else { dbse_firstmotion(cam); @@ -204,7 +205,7 @@ static void event_sqlnewfile(struct ctx_cam *cam, motion_event evnt (void)img_data; /* Only log the file types we want */ - if (!(cam->conf.database_type) || (sqltype & cam->dbse->sql_mask) == 0){ + if (!(cam->conf->database_type) || (sqltype & cam->dbse->sql_mask) == 0){ return; } else { dbse_newfile(cam, fname, sqltype, ts1); @@ -222,7 +223,7 @@ static void event_sqlfileclose(struct ctx_cam *cam, motion_event evnt (void)img_data; /* Only log the file types we want */ - if (!(cam->conf.database_type) || (sqltype & cam->dbse->sql_mask) == 0){ + if (!(cam->conf->database_type) || (sqltype & cam->dbse->sql_mask) == 0){ return; } else { dbse_fileclose(cam, fname, sqltype, ts1); @@ -241,8 +242,8 @@ static void on_area_command(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf.on_area_detected) - exec_command(cam, cam->conf.on_area_detected, NULL, 0); + if (cam->conf->on_area_detected) + exec_command(cam, cam->conf->on_area_detected, NULL, 0); } static void on_event_start_command(struct ctx_cam *cam, motion_event evnt @@ -255,8 +256,8 @@ static void on_event_start_command(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf.on_event_start) - exec_command(cam, cam->conf.on_event_start, NULL, 0); + if (cam->conf->on_event_start) + exec_command(cam, cam->conf->on_event_start, NULL, 0); } static void on_event_end_command(struct ctx_cam *cam, motion_event evnt @@ -269,8 +270,8 @@ static void on_event_end_command(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf.on_event_end) - exec_command(cam, cam->conf.on_event_end, NULL, 0); + if (cam->conf->on_event_end) + exec_command(cam, cam->conf->on_event_end, NULL, 0); } static void event_stream_put(struct ctx_cam *cam, motion_event evnt @@ -304,8 +305,8 @@ static void event_vlp_putpipe(struct ctx_cam *cam, motion_event evnt const char *imageext(struct ctx_cam *cam) { - if (mystreq(cam->conf.picture_type, "ppm")) return "ppm"; - if (mystreq(cam->conf.picture_type, "webp")) return "webp"; + if (mystreq(cam->conf->picture_type, "ppm")) return "ppm"; + if (mystreq(cam->conf->picture_type, "webp")) return "webp"; return "jpg"; } @@ -322,9 +323,9 @@ static void event_image_detect(struct ctx_cam *cam, motion_event evnt (void)ftype; if (cam->new_img & NEWIMG_ON) { - mystrftime(cam, filename, sizeof(filename), cam->conf.picture_filename, ts1, NULL, 0); + mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename, ts1, NULL, 0); retcd = snprintf(fullfilename, PATH_MAX, "%s/%s.%s" - , cam->conf.target_dir, filename, imageext(cam)); + , cam->conf->target_dir, filename, imageext(cam)); if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO ,_("Error creating image file name")); @@ -344,7 +345,7 @@ static void event_imagem_detect(struct ctx_cam *cam, motion_event evnt ,struct ctx_image_data *img_data, char *fname ,void *ftype, struct timespec *ts1) { - struct ctx_config *conf = &cam->conf; + struct ctx_config *conf = cam->conf; char fullfilenamem[PATH_MAX]; char filename[PATH_MAX]; char filenamem[PATH_MAX]; @@ -356,9 +357,9 @@ static void event_imagem_detect(struct ctx_cam *cam, motion_event evnt (void)ftype; if (conf->picture_output_motion) { - mystrftime(cam, filename, sizeof(filename), cam->conf.picture_filename, ts1, NULL, 0); + mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename, ts1, NULL, 0); retcd = snprintf(fullfilenamem, PATH_MAX, "%s/%sm.%s" - , cam->conf.target_dir, filenamem, imageext(cam)); + , cam->conf->target_dir, filenamem, imageext(cam)); if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO ,_("Error creating image motion file name")); @@ -377,7 +378,7 @@ static void event_image_snapshot(struct ctx_cam *cam, motion_event evnt char filename[PATH_MAX]; char filepath[PATH_MAX]; int offset = 0; - int len = strlen(cam->conf.snapshot_filename); + int len = strlen(cam->conf->snapshot_filename); char linkpath[PATH_MAX]; const char *snappath; @@ -388,13 +389,13 @@ static void event_image_snapshot(struct ctx_cam *cam, motion_event evnt if (len >= 9) offset = len - 8; - if (mystrne(cam->conf.snapshot_filename+offset, "lastsnap")) { + if (mystrne(cam->conf->snapshot_filename+offset, "lastsnap")) { /* * conf.snapshot_filename would normally be defined but if someone deleted it by control interface * it is better to revert to the default than fail */ - if (cam->conf.snapshot_filename) - snappath = cam->conf.snapshot_filename; + if (cam->conf->snapshot_filename) + snappath = cam->conf->snapshot_filename; else snappath = DEF_SNAPPATH; @@ -404,8 +405,8 @@ static void event_image_snapshot(struct ctx_cam *cam, motion_event evnt , filepath, imageext(cam)); snprintf(fullfilename, PATH_MAX, "%.*s/%.*s" , (int)(PATH_MAX-1-strlen(filename)) - , cam->conf.target_dir - , (int)(PATH_MAX-1-strlen(cam->conf.target_dir)) + , cam->conf->target_dir + , (int)(PATH_MAX-1-strlen(cam->conf->target_dir)) , filename); pic_save_norm(cam, fullfilename, img_data->image_norm, FTYPE_IMAGE_SNAPSHOT); event(cam, EVENT_FILECREATE, NULL, fullfilename, (void *)FTYPE_IMAGE_SNAPSHOT, ts1); @@ -416,7 +417,7 @@ static void event_image_snapshot(struct ctx_cam *cam, motion_event evnt */ snprintf(linkpath, PATH_MAX, "%.*s/lastsnap.%s" , (int)(PATH_MAX-strlen("/lastsnap.")-strlen(imageext(cam))) - , cam->conf.target_dir, imageext(cam)); + , cam->conf->target_dir, imageext(cam)); remove(linkpath); @@ -426,14 +427,14 @@ static void event_image_snapshot(struct ctx_cam *cam, motion_event evnt return; } } else { - mystrftime(cam, filepath, sizeof(filepath), cam->conf.snapshot_filename, ts1, NULL, 0); + mystrftime(cam, filepath, sizeof(filepath), cam->conf->snapshot_filename, ts1, NULL, 0); snprintf(filename, PATH_MAX, "%.*s.%s" , (int)(PATH_MAX-1-strlen(imageext(cam))) , filepath, imageext(cam)); snprintf(fullfilename, PATH_MAX, "%.*s/%.*s" , (int)(PATH_MAX-1-strlen(filename)) - , cam->conf.target_dir - , (int)(PATH_MAX-1-strlen(cam->conf.target_dir)) + , cam->conf->target_dir + , (int)(PATH_MAX-1-strlen(cam->conf->target_dir)) , filename); remove(fullfilename); pic_save_norm(cam, fullfilename, img_data->image_norm, FTYPE_IMAGE_SNAPSHOT); @@ -461,10 +462,10 @@ static void event_image_preview(struct ctx_cam *cam, motion_event evnt saved_current_image = cam->current_image; cam->current_image = &cam->imgs.image_preview; - mystrftime(cam, filename, sizeof(filename), cam->conf.picture_filename + mystrftime(cam, filename, sizeof(filename), cam->conf->picture_filename , &cam->imgs.image_preview.imgts, NULL, 0); retcd = snprintf(previewname, PATH_MAX, "%s/%s.%s" - , cam->conf.target_dir, filename, imageext(cam)); + , cam->conf->target_dir, filename, imageext(cam)); if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO ,_("Error creating preview file name")); @@ -493,8 +494,8 @@ static void event_camera_lost(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf.on_camera_lost) - exec_command(cam, cam->conf.on_camera_lost, NULL, 0); + if (cam->conf->on_camera_lost) + exec_command(cam, cam->conf->on_camera_lost, NULL, 0); } static void event_camera_found(struct ctx_cam *cam, motion_event evnt @@ -507,8 +508,8 @@ static void event_camera_found(struct ctx_cam *cam, motion_event evnt (void)ftype; (void)ts1; - if (cam->conf.on_camera_found) - exec_command(cam, cam->conf.on_camera_found, NULL, 0); + if (cam->conf->on_camera_found) + exec_command(cam, cam->conf->on_camera_found, NULL, 0); } static void on_movie_end_command(struct ctx_cam *cam, motion_event evnt @@ -521,8 +522,8 @@ static void on_movie_end_command(struct ctx_cam *cam, motion_event evnt (void)img_data; (void)ts1; - if ((filetype & FTYPE_MPEG_ANY) && cam->conf.on_movie_end) - exec_command(cam, cam->conf.on_movie_end, fname, filetype); + if ((filetype & FTYPE_MPEG_ANY) && cam->conf->on_movie_end) + exec_command(cam, cam->conf->on_movie_end, fname, filetype); } static void event_extpipe_end(struct ctx_cam *cam, motion_event evnt @@ -559,13 +560,13 @@ static void event_create_extpipe(struct ctx_cam *cam, motion_event evnt (void)fname; (void)ftype; - if ((cam->conf.movie_extpipe_use) && (cam->conf.movie_extpipe)) { + if ((cam->conf->movie_extpipe_use) && (cam->conf->movie_extpipe)) { /* * conf.mpegpath would normally be defined but if someone deleted it by control interface * it is better to revert to the default than fail */ - if (cam->conf.movie_filename) { - moviepath = cam->conf.movie_filename; + if (cam->conf->movie_filename) { + moviepath = cam->conf->movie_filename; } else { moviepath = DEF_MOVIEPATH; MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, _("moviepath: %s"), moviepath); @@ -574,26 +575,26 @@ static void event_create_extpipe(struct ctx_cam *cam, motion_event evnt mystrftime(cam, stamp, sizeof(stamp), moviepath, ts1, NULL, 0); snprintf(cam->extpipefilename, PATH_MAX - 4, "%.*s/%.*s" , (int)(PATH_MAX-5-strlen(stamp)) - , cam->conf.target_dir - , (int)(PATH_MAX-5-strlen(cam->conf.target_dir)) + , cam->conf->target_dir + , (int)(PATH_MAX-5-strlen(cam->conf->target_dir)) , stamp); - if (access(cam->conf.target_dir, W_OK)!= 0) { + if (access(cam->conf->target_dir, W_OK)!= 0) { /* Permission denied */ if (errno == EACCES) { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO - ,_("no write access to target directory %s"), cam->conf.target_dir); + ,_("no write access to target directory %s"), cam->conf->target_dir); return ; /* Path not found - create it */ } else if (errno == ENOENT) { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO - ,_("path not found, trying to create it %s ..."), cam->conf.target_dir); + ,_("path not found, trying to create it %s ..."), cam->conf->target_dir); if (mycreate_path(cam->extpipefilename) == -1) return ; } else { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO - ,_("error accesing path %s"), cam->conf.target_dir); + ,_("error accesing path %s"), cam->conf->target_dir); return ; } } @@ -602,7 +603,7 @@ static void event_create_extpipe(struct ctx_cam *cam, motion_event evnt if (mycreate_path(cam->extpipefilename) == -1) return ; - mystrftime(cam, stamp, sizeof(stamp), cam->conf.movie_extpipe, ts1, cam->extpipefilename, 0); + mystrftime(cam, stamp, sizeof(stamp), cam->conf->movie_extpipe, ts1, cam->extpipefilename, 0); retcd = snprintf(cam->extpipecmdline, PATH_MAX, "%s", stamp); if ((retcd < 0 ) || (retcd >= PATH_MAX)){ @@ -639,7 +640,7 @@ static void event_extpipe_put(struct ctx_cam *cam, motion_event evnt (void)ts1; /* Check use_extpipe enabled and ext_pipe not NULL */ - if ((cam->conf.movie_extpipe_use) && (cam->extpipe != NULL)) { + if ((cam->conf->movie_extpipe_use) && (cam->extpipe != NULL)) { MOTION_LOG(DBG, TYPE_EVENTS, NO_ERRNO, _("Using extpipe")); passthrough = mycheck_passthrough(cam); /* Check that is open */ @@ -691,9 +692,9 @@ static void event_movie_newfile(struct ctx_cam *cam, motion_event evnt (void)fname; (void)ftype; - if (!cam->conf.movie_output && !cam->conf.movie_output_motion) return; + if (!cam->conf->movie_output && !cam->conf->movie_output_motion) return; - if (cam->conf.movie_output) { + if (cam->conf->movie_output) { retcd = movie_init_norm(cam, ts1); if (retcd < 0){ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO @@ -705,7 +706,7 @@ static void event_movie_newfile(struct ctx_cam *cam, motion_event evnt event(cam, EVENT_FILECREATE, NULL, cam->movie_norm->filename, (void *)FTYPE_MPEG, ts1); } - if (cam->conf.movie_output_motion) { + if (cam->conf->movie_output_motion) { retcd = movie_init_motion(cam, ts1); if (retcd < 0){ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO diff --git a/src/exif.cpp b/src/exif.cpp index a441a29b..cf4ba627 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -21,6 +21,7 @@ #include "motion.hpp" +#include "conf.hpp" #include "util.hpp" #include "logger.hpp" #include "exif.hpp" @@ -205,9 +206,9 @@ unsigned exif_prepare(unsigned char **exif, // use as much of it as is indicated by conf->frame_limit subtime = NULL; - if (cam->conf.picture_exif) { + if (cam->conf->picture_exif) { description =(char*) malloc(PATH_MAX); - mystrftime(cam, description, PATH_MAX-1, cam->conf.picture_exif, &ts1, NULL, 0); + mystrftime(cam, description, PATH_MAX-1, cam->conf->picture_exif, &ts1, NULL, 0); } else { description = NULL; } diff --git a/src/logger.cpp b/src/logger.cpp index ee77cf32..c0b70bf8 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -10,6 +10,7 @@ * */ #include "motion.hpp" +#include "conf.hpp" #include "util.hpp" #include "logger.hpp" #include diff --git a/src/mmalcam.cpp b/src/mmalcam.cpp index 7f0c560d..73c7f804 100644 --- a/src/mmalcam.cpp +++ b/src/mmalcam.cpp @@ -12,6 +12,7 @@ */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "rotate.hpp" @@ -288,7 +289,7 @@ int mmalcam_start(struct ctx_cam *cam) { MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO ,_("MMAL Camera thread starting... for camera (%s) of %d x %d at %d fps") - ,cam->conf.mmalcam_name, cam->conf.width, cam->conf.height, cam->conf.framerate); + ,cam->conf->mmalcam_name, cam->conf->width, cam->conf->height, cam->conf->framerate); mmalcam->camera_parameters = (RASPICAM_CAMERA_PARAMETERS*)malloc(sizeof(RASPICAM_CAMERA_PARAMETERS)); if (mmalcam->camera_parameters == NULL) { @@ -297,12 +298,12 @@ int mmalcam_start(struct ctx_cam *cam) { } raspicamcontrol_set_defaults(mmalcam->camera_parameters); - mmalcam->width = cam->conf.width; - mmalcam->height = cam->conf.height; - mmalcam->framerate = cam->conf.framerate; + mmalcam->width = cam->conf->width; + mmalcam->height = cam->conf->height; + mmalcam->framerate = cam->conf->framerate; - if (cam->conf.mmalcam_control_params) { - parse_camera_control_params(cam->conf.mmalcam_control_params, mmalcam->camera_parameters); + if (cam->conf->mmalcam_control_params) { + parse_camera_control_params(cam->conf->mmalcam_control_params, mmalcam->camera_parameters); } cam->imgs.width = mmalcam->width; @@ -310,7 +311,7 @@ int mmalcam_start(struct ctx_cam *cam) { cam->imgs.size_norm = (mmalcam->width * mmalcam->height * 3) / 2; cam->imgs.motionsize = mmalcam->width * mmalcam->height; - int retval = create_camera_component(mmalcam, cam->conf.mmalcam_name); + int retval = create_camera_component(mmalcam, cam->conf->mmalcam_name); if (retval == 0) { retval = create_camera_buffer_structures(mmalcam); diff --git a/src/motion.cpp b/src/motion.cpp index afa74db6..538f3dd9 100644 --- a/src/motion.cpp +++ b/src/motion.cpp @@ -7,6 +7,7 @@ * */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "motion_loop.hpp" @@ -29,7 +30,7 @@ static void motion_signal_process(struct ctx_motapp *motapp){ if (motapp->cam_list != NULL) { indx = 0; while (motapp->cam_list[indx] != NULL) { - if (motapp->cam_list[indx]->conf.snapshot_interval){ + if (motapp->cam_list[indx]->conf->snapshot_interval){ motapp->cam_list[indx]->snapshot = TRUE; } indx++; @@ -270,8 +271,8 @@ static void motion_camera_ids(struct ctx_cam **cam_list){ /* Set defaults */ indx = 0; while (cam_list[indx] != NULL){ - if (cam_list[indx]->conf.camera_id > 0){ - cam_list[indx]->camera_id = cam_list[indx]->conf.camera_id; + if (cam_list[indx]->conf->camera_id > 0){ + cam_list[indx]->camera_id = cam_list[indx]->conf->camera_id; } else { cam_list[indx]->camera_id = indx; } diff --git a/src/motion.hpp b/src/motion.hpp index 44f9dcf4..27562a63 100644 --- a/src/motion.hpp +++ b/src/motion.hpp @@ -58,9 +58,8 @@ struct ctx_mmalcam; struct ctx_movie; struct ctx_netcam; struct ctx_algsec; - -#include "conf.hpp" -#include "track.hpp" +struct ctx_config; +struct ctx_track; #define DEF_PALETTE 17 @@ -312,15 +311,15 @@ struct ctx_cam { int log_level; unsigned int log_type; - struct ctx_config conf; - struct ctx_track track; + struct ctx_config *conf; + struct ctx_track *track; struct ctx_images imgs; struct ctx_mmalcam *mmalcam; struct ctx_netcam *netcam; /* this structure contains the context for normal RTSP connection */ struct ctx_netcam *netcam_high; /* this structure contains the context for high resolution RTSP connection */ struct ctx_vdev *vdev; /* Structure for v4l2 device information */ struct ctx_image_data *current_image; /* Pointer to a structure where the image, diffs etc is stored */ - ctx_algsec *algsec; + struct ctx_algsec *algsec; struct ctx_rotate *rotate_data; /* rotation data is thread-specific */ struct ctx_dbse *dbse; struct ctx_movie *movie_norm; diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index 44d629c4..90be0170 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -142,7 +142,7 @@ static void mlp_ring_process(struct ctx_cam *cam, unsigned int max_images) { cam->current_image = &cam->imgs.image_ring[cam->imgs.ring_out]; - if (cam->imgs.image_ring[cam->imgs.ring_out].shot < cam->conf.framerate) { + if (cam->imgs.image_ring[cam->imgs.ring_out].shot < cam->conf->framerate) { if (cam->log_level >= DBG) mlp_ring_process_debug(cam); event(cam, EVENT_IMAGE_DETECTED, @@ -192,7 +192,7 @@ static void mlp_detected_trigger(struct ctx_cam *cam, struct ctx_image_data *img cam->eventtime = img->imgts.tv_sec; mystrftime(cam, cam->text_event_string, sizeof(cam->text_event_string), - cam->conf.text_event, &img->imgts, NULL, 0); + cam->conf->text_event, &img->imgts, NULL, 0); event(cam, EVENT_FIRSTMOTION, img, NULL, NULL, &cam->imgs.image_ring[cam->imgs.ring_out].imgts); @@ -212,7 +212,7 @@ static void mlp_detected_trigger(struct ctx_cam *cam, struct ctx_image_data *img } static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *img) { - struct ctx_config *conf = &cam->conf; + struct ctx_config *conf = cam->conf; unsigned int distX, distY; draw_locate(cam, img); @@ -235,7 +235,7 @@ static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *im } } - if (cam->conf.track_type && cam->conf.track_auto){ + if (cam->conf->track_type && cam->conf->track_auto){ cam->frame_skip = track_move(cam, dev, &img->location, &cam->imgs, 0); } @@ -246,24 +246,24 @@ static int init_camera_type(struct ctx_cam *cam){ cam->camera_type = CAMERA_TYPE_UNKNOWN; - if (cam->conf.mmalcam_name) { + if (cam->conf->mmalcam_name) { cam->camera_type = CAMERA_TYPE_MMAL; return 0; } - if (cam->conf.netcam_url) { - if ((strncmp(cam->conf.netcam_url,"mjpeg",5) == 0) || - (strncmp(cam->conf.netcam_url,"http" ,4) == 0) || - (strncmp(cam->conf.netcam_url,"v4l2" ,4) == 0) || - (strncmp(cam->conf.netcam_url,"file" ,4) == 0) || - (strncmp(cam->conf.netcam_url,"rtmp" ,4) == 0) || - (strncmp(cam->conf.netcam_url,"rtsp" ,4) == 0)) { + if (cam->conf->netcam_url) { + if ((strncmp(cam->conf->netcam_url,"mjpeg",5) == 0) || + (strncmp(cam->conf->netcam_url,"http" ,4) == 0) || + (strncmp(cam->conf->netcam_url,"v4l2" ,4) == 0) || + (strncmp(cam->conf->netcam_url,"file" ,4) == 0) || + (strncmp(cam->conf->netcam_url,"rtmp" ,4) == 0) || + (strncmp(cam->conf->netcam_url,"rtsp" ,4) == 0)) { cam->camera_type = CAMERA_TYPE_NETCAM; } return 0; } - if (cam->conf.videodevice) { + if (cam->conf->videodevice) { cam->camera_type = CAMERA_TYPE_V4L2; return 0; } @@ -297,7 +297,7 @@ static void mlp_init_firstimage(struct ctx_cam *cam) { } cam->current_image = &cam->imgs.image_ring[cam->imgs.ring_in]; - if (cam->conf.primary_method == 0){ + if (cam->conf->primary_method == 0){ alg_update_reference_frame(cam, RESET_REF_FRAME); } else { alg_new_update_frame(cam); @@ -406,21 +406,21 @@ static void mlp_init_values(struct ctx_cam *cam) { cam->imgs.height_high = 0; cam->imgs.size_high = 0; - cam->noise = cam->conf.noise_level; + cam->noise = cam->conf->noise_level; - cam->threshold = cam->conf.threshold; - if (cam->conf.threshold_maximum > cam->conf.threshold ){ - cam->threshold_maximum = cam->conf.threshold_maximum; + cam->threshold = cam->conf->threshold; + if (cam->conf->threshold_maximum > cam->conf->threshold ){ + cam->threshold_maximum = cam->conf->threshold_maximum; } else { cam->threshold_maximum = (cam->imgs.height * cam->imgs.width * 3) / 2; } - cam->startup_frames = (cam->conf.framerate * 2) + cam->conf.pre_capture + cam->conf.minimum_motion_frames; + cam->startup_frames = (cam->conf->framerate * 2) + cam->conf->pre_capture + cam->conf->minimum_motion_frames; - cam->minimum_frame_time_downcounter = cam->conf.minimum_frame_time; + cam->minimum_frame_time_downcounter = cam->conf->minimum_frame_time; cam->get_image = 1; - cam->movie_passthrough = cam->conf.movie_passthrough; + cam->movie_passthrough = cam->conf->movie_passthrough; if ((cam->camera_type != CAMERA_TYPE_NETCAM) && (cam->movie_passthrough)) { MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO,_("Pass-through processing disabled.")); @@ -438,10 +438,10 @@ static int mlp_init_cam_start(struct ctx_cam *cam) { ,_("Could not fetch initial image from camera ")); MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO ,_("Motion continues using width and height from config file(s)")); - cam->imgs.width = cam->conf.width; - cam->imgs.height = cam->conf.height; - cam->imgs.size_norm = cam->conf.width * cam->conf.height * 3 / 2; - cam->imgs.motionsize = cam->conf.width * cam->conf.height; + cam->imgs.width = cam->conf->width; + cam->imgs.height = cam->conf->height; + cam->imgs.size_norm = cam->conf->width * cam->conf->height * 3 / 2; + cam->imgs.motionsize = cam->conf->width * cam->conf->height; } else if (cam->video_dev == -2) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO ,_("Could not fetch initial image from camera ")); @@ -461,7 +461,7 @@ static int mlp_init_cam_start(struct ctx_cam *cam) { /** mlp_init */ static int mlp_init(struct ctx_cam *cam) { - mythreadname_set("ml",cam->threadnr,cam->conf.camera_name); + mythreadname_set("ml",cam->threadnr,cam->conf->camera_name); pthread_setspecific(tls_key_threadnr, (void *)((unsigned long)cam->threadnr)); @@ -503,7 +503,7 @@ static int mlp_init(struct ctx_cam *cam) { ,_("Camera %d started: motion detection %s"), cam->camera_id, cam->pause ? _("Disabled"):_("Enabled")); - if (cam->conf.emulate_motion) { + if (cam->conf->emulate_motion) { MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, _("Emulating motion")); } @@ -520,6 +520,8 @@ void mlp_cleanup(struct ctx_cam *cam) { algsec_deinit(cam); + track_deinit(cam); + if (cam->video_dev >= 0) vid_close(cam); free(cam->imgs.image_motion.image_norm); @@ -678,12 +680,12 @@ static void mlp_mask_privacy(struct ctx_cam *cam){ static void mlp_areadetect(struct ctx_cam *cam){ int i, j, z = 0; - if ((cam->conf.area_detect) && + if ((cam->conf->area_detect) && (cam->event_nr != cam->areadetect_eventnbr) && (cam->current_image->flags & IMAGE_TRIGGER)) { - j = strlen(cam->conf.area_detect); + j = strlen(cam->conf->area_detect); for (i = 0; i < j; i++) { - z = cam->conf.area_detect[i] - 49; /* characters are stored as ascii 48-57 (0-9) */ + z = cam->conf->area_detect[i] - 49; /* characters are stored as ascii 48-57 (0-9) */ if ((z >= 0) && (z < 9)) { if (cam->current_image->location.x > cam->area_minx[z] && cam->current_image->location.x < cam->area_maxx[z] && @@ -711,10 +713,10 @@ 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.pre_capture < 0) - cam->conf.pre_capture = 0; + if (cam->conf->pre_capture < 0) + cam->conf->pre_capture = 0; - frame_buffer_size = cam->conf.pre_capture + cam->conf.minimum_motion_frames; + frame_buffer_size = cam->conf->pre_capture + cam->conf->minimum_motion_frames; if (cam->imgs.ring_size != frame_buffer_size) mlp_ring_resize(cam, frame_buffer_size); @@ -723,7 +725,7 @@ static void mlp_prepare(struct ctx_cam *cam){ cam->lastrate = cam->shots + 1; cam->shots = -1; - if (cam->conf.minimum_frame_time) { + if (cam->conf->minimum_frame_time) { cam->minimum_frame_time_downcounter--; if (cam->minimum_frame_time_downcounter == 0) cam->get_image = 1; @@ -742,8 +744,8 @@ static void mlp_prepare(struct ctx_cam *cam){ static void mlp_resetimages(struct ctx_cam *cam){ - if (cam->conf.minimum_frame_time) { - cam->minimum_frame_time_downcounter = cam->conf.minimum_frame_time; + if (cam->conf->minimum_frame_time) { + cam->minimum_frame_time_downcounter = cam->conf->minimum_frame_time; cam->get_image = 0; } @@ -795,14 +797,14 @@ static int mlp_retry(struct ctx_cam *cam){ * If the netcam has different dimensions than in the config file * we need to restart Motion to re-allocate all the buffers */ - if (cam->imgs.width != cam->conf.width || cam->imgs.height != cam->conf.height) { + if (cam->imgs.width != cam->conf->width || cam->imgs.height != cam->conf->height) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Camera has finally become available\n" "Camera image has different width and height" "from what is in the config file. You should fix that\n" "Restarting Motion thread to reinitialize all " "image buffers to new picture dimensions")); - cam->conf.width = cam->imgs.width; - cam->conf.height = cam->imgs.height; + cam->conf->width = cam->imgs.width; + cam->conf->height = cam->imgs.height; /* * Break out of main loop terminating thread * watchdog will start us again @@ -836,7 +838,7 @@ static int mlp_capture(struct ctx_cam *cam){ cam->lost_connection = 0; cam->connectionlosttime = 0; - if (cam->missing_frame_counter >= MISSING_FRAMES_TIMEOUT * cam->conf.framerate) { + if (cam->missing_frame_counter >= MISSING_FRAMES_TIMEOUT * cam->conf->framerate) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Video signal re-acquired")); event(cam, EVENT_CAMERA_FOUND, NULL, NULL, NULL, NULL); } @@ -867,7 +869,7 @@ static int mlp_capture(struct ctx_cam *cam){ ++cam->missing_frame_counter; if (cam->video_dev >= 0 && - cam->missing_frame_counter < (MISSING_FRAMES_TIMEOUT * cam->conf.framerate)) { + cam->missing_frame_counter < (MISSING_FRAMES_TIMEOUT * cam->conf->framerate)) { memcpy(cam->current_image->image_norm, cam->imgs.image_vprvcy, cam->imgs.size_norm); } else { cam->lost_connection = 1; @@ -885,14 +887,14 @@ static int mlp_capture(struct ctx_cam *cam){ 10, 20 * cam->text_scale, tmpout, cam->text_scale); /* Write error message only once */ - if (cam->missing_frame_counter == MISSING_FRAMES_TIMEOUT * cam->conf.framerate) { + if (cam->missing_frame_counter == MISSING_FRAMES_TIMEOUT * cam->conf->framerate) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO ,_("Video signal lost - Adding grey image")); event(cam, EVENT_CAMERA_LOST, NULL, NULL, NULL, &ts1); } if ((cam->video_dev > 0) && - (cam->missing_frame_counter == (MISSING_FRAMES_TIMEOUT * 4) * cam->conf.framerate)) { + (cam->missing_frame_counter == (MISSING_FRAMES_TIMEOUT * 4) * cam->conf->framerate)) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO ,_("Video signal still lost - Trying to close video device")); vid_close(cam); @@ -912,7 +914,7 @@ static void mlp_detection(struct ctx_cam *cam){ } if ( !cam->pause ) { - if (cam->conf.primary_method == 0){ + if (cam->conf->primary_method == 0){ alg_diff(cam); alg_lightswitch(cam); alg_switchfilter(cam); @@ -930,11 +932,11 @@ static void mlp_detection(struct ctx_cam *cam){ static void mlp_tuning(struct ctx_cam *cam){ - if ((cam->conf.noise_tune && cam->shots == 0) && + if ((cam->conf->noise_tune && cam->shots == 0) && (!cam->detecting_motion && (cam->current_image->diffs <= cam->threshold))) alg_noise_tune(cam, cam->imgs.image_vprvcy); - if (cam->conf.threshold_tune){ + if (cam->conf->threshold_tune){ alg_threshold_tune(cam, cam->current_image->diffs, cam->detecting_motion); } @@ -947,7 +949,7 @@ static void mlp_tuning(struct ctx_cam *cam){ , &cam->current_image->location); } - if (cam->conf.primary_method == 0){ + if (cam->conf->primary_method == 0){ alg_update_reference_frame(cam, UPDATE_REF_FRAME); } else { alg_new_update_frame(cam); @@ -964,19 +966,19 @@ static void mlp_overlay(struct ctx_cam *cam){ char tmp[PATH_MAX]; if (cam->smartmask_speed && - (cam->conf.picture_output_motion || cam->conf.movie_output_motion || + (cam->conf->picture_output_motion || cam->conf->movie_output_motion || cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0))) draw_smartmask(cam, cam->imgs.image_motion.image_norm); - if (cam->imgs.largest_label && (cam->conf.picture_output_motion || cam->conf.movie_output_motion || + if (cam->imgs.largest_label && (cam->conf->picture_output_motion || cam->conf->movie_output_motion || cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0))) draw_largest_label(cam, cam->imgs.image_motion.image_norm); - if (cam->imgs.mask && (cam->conf.picture_output_motion || cam->conf.movie_output_motion || + if (cam->imgs.mask && (cam->conf->picture_output_motion || cam->conf->movie_output_motion || cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0))) draw_fixed_mask(cam, cam->imgs.image_motion.image_norm); - if (cam->conf.text_changes) { + if (cam->conf->text_changes) { if (!cam->pause) sprintf(tmp, "%d", cam->current_image->diffs); else @@ -999,16 +1001,16 @@ static void mlp_overlay(struct ctx_cam *cam){ } /* Add text in lower left corner of the pictures */ - if (cam->conf.text_left) { - mystrftime(cam, tmp, sizeof(tmp), cam->conf.text_left, + if (cam->conf->text_left) { + mystrftime(cam, tmp, sizeof(tmp), cam->conf->text_left, &cam->current_image->imgts, NULL, 0); draw_text(cam->current_image->image_norm, cam->imgs.width, cam->imgs.height, 10, cam->imgs.height - (10 * cam->text_scale), tmp, cam->text_scale); } /* Add text in lower right corner of the pictures */ - if (cam->conf.text_right) { - mystrftime(cam, tmp, sizeof(tmp), cam->conf.text_right, + if (cam->conf->text_right) { + mystrftime(cam, tmp, sizeof(tmp), cam->conf->text_right, &cam->current_image->imgts, NULL, 0); draw_text(cam->current_image->image_norm, cam->imgs.width, cam->imgs.height, cam->imgs.width - 10, cam->imgs.height - (10 * cam->text_scale), @@ -1025,8 +1027,8 @@ static void mlp_actions_emulate(struct ctx_cam *cam){ movie_reset_start_time(cam->movie_norm, &cam->current_image->imgts); cam->detecting_motion = TRUE; - if (cam->conf.post_capture > 0) { - cam->postcap = cam->conf.post_capture; + if (cam->conf->post_capture > 0) { + cam->postcap = cam->conf->post_capture; } cam->current_image->flags |= (IMAGE_TRIGGER | IMAGE_SAVE); @@ -1043,7 +1045,7 @@ static void mlp_actions_motion(struct ctx_cam *cam){ int indx, frame_count = 0; int pos = cam->imgs.ring_in; - for (indx = 0; indx < cam->conf.minimum_motion_frames; indx++) { + for (indx = 0; indx < cam->conf->minimum_motion_frames; indx++) { if (cam->imgs.image_ring[pos].flags & IMAGE_MOTION) frame_count++; if (pos == 0){ pos = cam->imgs.ring_size-1; @@ -1052,7 +1054,7 @@ static void mlp_actions_motion(struct ctx_cam *cam){ } } - if (frame_count >= cam->conf.minimum_motion_frames) { + if (frame_count >= cam->conf->minimum_motion_frames) { cam->current_image->flags |= (IMAGE_TRIGGER | IMAGE_SAVE); @@ -1060,7 +1062,7 @@ static void mlp_actions_motion(struct ctx_cam *cam){ movie_reset_start_time(cam->movie_norm, &cam->current_image->imgts); } cam->detecting_motion = TRUE; - cam->postcap = cam->conf.post_capture; + cam->postcap = cam->conf->post_capture; for (indx = 0; indx < cam->imgs.ring_size; indx++){ cam->imgs.image_ring[indx].flags |= IMAGE_SAVE; @@ -1079,14 +1081,14 @@ static void mlp_actions_motion(struct ctx_cam *cam){ static void mlp_actions_event(struct ctx_cam *cam){ - if ((cam->conf.movie_max_time > 0) && + if ((cam->conf->movie_max_time > 0) && (cam->event_nr == cam->prev_event) && - ((cam->frame_curr_ts.tv_sec - cam->eventtime) >= cam->conf.movie_max_time)) { + ((cam->frame_curr_ts.tv_sec - cam->eventtime) >= cam->conf->movie_max_time)) { cam->event_stop = TRUE; } - if (((cam->frame_curr_ts.tv_sec - cam->lasttime >= cam->conf.event_gap) && - (cam->conf.event_gap > 0)) || cam->event_stop) { + 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) { mlp_ring_process(cam, IMAGE_BUFFER_FLUSH); @@ -1096,7 +1098,7 @@ static void mlp_actions_event(struct ctx_cam *cam){ } event(cam, EVENT_ENDMOTION, NULL, NULL, NULL, &cam->current_image->imgts); - if (cam->conf.track_type) { + if (cam->conf->track_type) { cam->frame_skip = track_center(cam, cam->video_dev, 0, 0, 0); } @@ -1118,7 +1120,7 @@ static void mlp_actions(struct ctx_cam *cam){ cam->current_image->flags |= IMAGE_MOTION; } - if ((cam->conf.emulate_motion || cam->event_user) && (cam->startup_frames == 0)) { + if ((cam->conf->emulate_motion || cam->event_user) && (cam->startup_frames == 0)) { mlp_actions_emulate(cam); } else if ((cam->current_image->flags & IMAGE_MOTION) && (cam->startup_frames == 0)) { mlp_actions_motion(cam); @@ -1127,7 +1129,7 @@ static void mlp_actions(struct ctx_cam *cam){ cam->postcap--; } else { cam->current_image->flags |= IMAGE_PRECAP; - if ((cam->conf.event_gap == 0) && cam->detecting_motion) cam->event_stop = TRUE; + if ((cam->conf->event_gap == 0) && cam->detecting_motion) cam->event_stop = TRUE; cam->detecting_motion = FALSE; } @@ -1154,11 +1156,11 @@ static void mlp_setupmode(struct ctx_cam *cam){ char msg[1024] = "\0"; char part[100]; - if (cam->conf.despeckle_filter) { + if (cam->conf->despeckle_filter) { snprintf(part, 99, _("Raw changes: %5d - changes after '%s': %5d"), - cam->olddiffs, cam->conf.despeckle_filter, cam->current_image->diffs); + cam->olddiffs, cam->conf->despeckle_filter, cam->current_image->diffs); strcat(msg, part); - if (strchr(cam->conf.despeckle_filter, 'l')) { + if (strchr(cam->conf->despeckle_filter, 'l')) { snprintf(part, 99,_(" - labels: %3d"), cam->current_image->total_labels); strcat(msg, part); } @@ -1167,12 +1169,12 @@ static void mlp_setupmode(struct ctx_cam *cam){ strcat(msg, part); } - if (cam->conf.noise_tune) { + if (cam->conf->noise_tune) { snprintf(part, 99,_(" - noise level: %2d"), cam->noise); strcat(msg, part); } - if (cam->conf.threshold_tune) { + if (cam->conf->threshold_tune) { snprintf(part, 99, _(" - threshold: %d"), cam->threshold); strcat(msg, part); } @@ -1184,9 +1186,9 @@ static void mlp_setupmode(struct ctx_cam *cam){ static void mlp_snapshot(struct ctx_cam *cam){ - 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) || + 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) || cam->snapshot) { event(cam, EVENT_IMAGE_SNAPSHOT, cam->current_image, NULL, NULL, &cam->current_image->imgts); cam->snapshot = 0; @@ -1198,27 +1200,27 @@ static void mlp_timelapse(struct ctx_cam *cam){ struct tm timestamp_tm; - if (cam->conf.timelapse_interval) { + if (cam->conf->timelapse_interval) { localtime_r(&cam->current_image->imgts.tv_sec, ×tamp_tm); if (timestamp_tm.tm_min == 0 && (cam->frame_curr_ts.tv_sec % 60 < cam->frame_last_ts.tv_sec % 60) && cam->shots == 0) { - if (mystrceq(cam->conf.timelapse_mode, "daily")) { + if (mystrceq(cam->conf->timelapse_mode, "daily")) { if (timestamp_tm.tm_hour == 0) event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); - } else if (mystreq(cam->conf.timelapse_mode, "hourly")) { + } else if (mystreq(cam->conf->timelapse_mode, "hourly")) { event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); - } else if (mystrceq(cam->conf.timelapse_mode, "weekly-sunday")) { + } else if (mystrceq(cam->conf->timelapse_mode, "weekly-sunday")) { if (timestamp_tm.tm_wday == 0 && timestamp_tm.tm_hour == 0) event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); - } else if (mystrceq(cam->conf.timelapse_mode, "weekly-monday") == 0) { + } else if (mystrceq(cam->conf->timelapse_mode, "weekly-monday") == 0) { if (timestamp_tm.tm_wday == 1 && timestamp_tm.tm_hour == 0) event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); - } else if (mystrceq(cam->conf.timelapse_mode, "monthly")) { + } else if (mystrceq(cam->conf->timelapse_mode, "monthly")) { if (timestamp_tm.tm_mday == 1 && timestamp_tm.tm_hour == 0) event(cam, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cam->current_image->imgts); @@ -1226,8 +1228,8 @@ static void mlp_timelapse(struct ctx_cam *cam){ } if (cam->shots == 0 && - cam->frame_curr_ts.tv_sec % cam->conf.timelapse_interval <= - cam->frame_last_ts.tv_sec % cam->conf.timelapse_interval) { + cam->frame_curr_ts.tv_sec % cam->conf->timelapse_interval <= + cam->frame_last_ts.tv_sec % cam->conf->timelapse_interval) { event(cam, EVENT_TIMELAPSE, cam->current_image, NULL , NULL, &cam->current_image->imgts); } @@ -1251,7 +1253,7 @@ static void mlp_loopback(struct ctx_cam *cam){ } else { event(cam, EVENT_IMAGE, cam->current_image, NULL, &cam->pipe, &cam->current_image->imgts); - if (!cam->conf.stream_motion || cam->shots == 1){ + if (!cam->conf->stream_motion || cam->shots == 1){ event(cam, EVENT_STREAM, cam->current_image, NULL, NULL, &cam->current_image->imgts); } } @@ -1267,57 +1269,57 @@ static void mlp_parmsupdate(struct ctx_cam *cam){ draw_init_scale(cam); /* Initialize and validate text_scale */ - if (mystrceq(cam->conf.picture_output, "on")) + if (mystrceq(cam->conf->picture_output, "on")) cam->new_img = NEWIMG_ON; - else if (mystrceq(cam->conf.picture_output, "first")) + else if (mystrceq(cam->conf->picture_output, "first")) cam->new_img = NEWIMG_FIRST; - else if (mystrceq(cam->conf.picture_output, "best")) + else if (mystrceq(cam->conf->picture_output, "best")) cam->new_img = NEWIMG_BEST; - else if (mystrceq(cam->conf.picture_output, "center")) + else if (mystrceq(cam->conf->picture_output, "center")) cam->new_img = NEWIMG_CENTER; else cam->new_img = NEWIMG_OFF; - if (mystrceq(cam->conf.locate_motion_mode, "on")) + if (mystrceq(cam->conf->locate_motion_mode, "on")) cam->locate_motion_mode = LOCATE_ON; - else if (mystrceq(cam->conf.locate_motion_mode, "preview")) + else if (mystrceq(cam->conf->locate_motion_mode, "preview")) cam->locate_motion_mode = LOCATE_PREVIEW; else cam->locate_motion_mode = LOCATE_OFF; - if (mystrceq(cam->conf.locate_motion_style, "box")) + if (mystrceq(cam->conf->locate_motion_style, "box")) cam->locate_motion_style = LOCATE_BOX; - else if (mystrceq(cam->conf.locate_motion_style, "redbox")) + else if (mystrceq(cam->conf->locate_motion_style, "redbox")) cam->locate_motion_style = LOCATE_REDBOX; - else if (mystrceq(cam->conf.locate_motion_style, "cross")) + else if (mystrceq(cam->conf->locate_motion_style, "cross")) cam->locate_motion_style = LOCATE_CROSS; - else if (mystrceq(cam->conf.locate_motion_style, "redcross")) + else if (mystrceq(cam->conf->locate_motion_style, "redcross")) cam->locate_motion_style = LOCATE_REDCROSS; else cam->locate_motion_style = LOCATE_BOX; - if (cam->conf.smart_mask_speed != cam->smartmask_speed || + if (cam->conf->smart_mask_speed != cam->smartmask_speed || cam->smartmask_lastrate != cam->lastrate) { - if (cam->conf.smart_mask_speed == 0) { + if (cam->conf->smart_mask_speed == 0) { memset(cam->imgs.smartmask, 0, cam->imgs.motionsize); memset(cam->imgs.smartmask_final, 255, cam->imgs.motionsize); } cam->smartmask_lastrate = cam->lastrate; - cam->smartmask_speed = cam->conf.smart_mask_speed; + cam->smartmask_speed = cam->conf->smart_mask_speed; cam->smartmask_ratio = 5 * cam->lastrate * (11 - cam->smartmask_speed); } dbse_sqlmask_update(cam); - cam->threshold = cam->conf.threshold; - if (cam->conf.threshold_maximum > cam->conf.threshold ){ - cam->threshold_maximum = cam->conf.threshold_maximum; + cam->threshold = cam->conf->threshold; + if (cam->conf->threshold_maximum > cam->conf->threshold ){ + cam->threshold_maximum = cam->conf->threshold_maximum; } else { cam->threshold_maximum = (cam->imgs.height * cam->imgs.width * 3) / 2; } - if (!cam->conf.noise_tune){ - cam->noise = cam->conf.noise_level; + if (!cam->conf->noise_tune){ + cam->noise = cam->conf->noise_level; } } @@ -1333,8 +1335,8 @@ static void mlp_frametiming(struct ctx_cam *cam){ cam->frame_wait[indx]=cam->frame_wait[indx+1]; } - if (cam->conf.framerate) { - cam->frame_wait[AVGCNT-1] = 1000000L / cam->conf.framerate; + if (cam->conf->framerate) { + cam->frame_wait[AVGCNT-1] = 1000000L / cam->conf->framerate; } else { cam->frame_wait[AVGCNT-1] = 0; } diff --git a/src/movie.cpp b/src/movie.cpp index 164aa463..cf8aa753 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -22,6 +22,7 @@ */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "netcam.hpp" @@ -1500,7 +1501,7 @@ static const char* movie_init_codec(struct ctx_cam *cam){ const char *codec; int codenbr; - codec = cam->conf.movie_codec; + codec = cam->conf->movie_codec; if (mystreq(codec, "ogg")) { MOTION_LOG(WRN, TYPE_ENCODER, NO_ERRNO, "The ogg container is no longer supported. Changing to mpeg4"); codec = "mpeg4"; @@ -1530,8 +1531,8 @@ int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1){ const char *codec; int retcd; - if (cam->conf.movie_filename){ - moviepath = cam->conf.movie_filename; + if (cam->conf->movie_filename){ + moviepath = cam->conf->movie_filename; } else { moviepath = "%v-%Y%m%d%H%M%S"; } @@ -1542,10 +1543,10 @@ int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_norm =(struct ctx_movie*) mymalloc(sizeof(struct ctx_movie)); if (mystreq(codec, "test")) { retcd = snprintf(cam->movie_norm->filename, PATH_MAX, "%s/%s_%s" - , cam->conf.target_dir, codec, stamp); + , cam->conf->target_dir, codec, stamp); } else { retcd = snprintf(cam->movie_norm->filename, PATH_MAX, "%s/%s" - , cam->conf.target_dir, stamp); + , cam->conf->target_dir, stamp); } if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO @@ -1565,15 +1566,15 @@ int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1){ } cam->movie_norm->tlapse = TIMELAPSE_NONE; cam->movie_norm->fps = cam->lastrate; - cam->movie_norm->bps = cam->conf.movie_bps; - cam->movie_norm->quality = cam->conf.movie_quality; + cam->movie_norm->bps = cam->conf->movie_bps; + cam->movie_norm->quality = cam->conf->movie_quality; cam->movie_norm->start_time.tv_sec = ts1->tv_sec; cam->movie_norm->start_time.tv_nsec = ts1->tv_nsec; cam->movie_norm->last_pts = -1; cam->movie_norm->base_pts = 0; cam->movie_norm->gop_cnt = 0; cam->movie_norm->codec_name = codec; - if (mystreq(cam->conf.movie_codec, "test")) { + if (mystreq(cam->conf->movie_codec, "test")) { cam->movie_norm->test_mode = TRUE; } else { cam->movie_norm->test_mode = FALSE; @@ -1593,8 +1594,8 @@ int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1){ const char *codec; int retcd; - if (cam->conf.movie_filename){ - moviepath = cam->conf.movie_filename; + if (cam->conf->movie_filename){ + moviepath = cam->conf->movie_filename; } else { moviepath = "%v-%Y%m%d%H%M%S"; } @@ -1605,10 +1606,10 @@ int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_motion =(struct ctx_movie*)mymalloc(sizeof(struct ctx_movie)); if (mystreq(codec, "test")) { retcd = snprintf(cam->movie_motion->filename, PATH_MAX, "%s/%s_%sm" - , cam->conf.target_dir, codec, stamp); + , cam->conf->target_dir, codec, stamp); } else { retcd = snprintf(cam->movie_motion->filename, PATH_MAX, "%s/%sm" - , cam->conf.target_dir, stamp); + , cam->conf->target_dir, stamp); } if ((retcd < 0) || (retcd >= PATH_MAX)){ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO @@ -1621,15 +1622,15 @@ int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_motion->netcam_data = NULL; cam->movie_motion->tlapse = TIMELAPSE_NONE; cam->movie_motion->fps = cam->lastrate; - cam->movie_motion->bps = cam->conf.movie_bps; - cam->movie_motion->quality = cam->conf.movie_quality; + cam->movie_motion->bps = cam->conf->movie_bps; + cam->movie_motion->quality = cam->conf->movie_quality; cam->movie_motion->start_time.tv_sec = ts1->tv_sec; cam->movie_motion->start_time.tv_nsec = ts1->tv_nsec; cam->movie_motion->last_pts = -1; cam->movie_motion->base_pts = 0; cam->movie_motion->gop_cnt = 0; cam->movie_motion->codec_name = codec; - if (mystreq(cam->conf.movie_codec, "test")) { + if (mystreq(cam->conf->movie_codec, "test")) { cam->movie_motion->test_mode = TRUE; } else { cam->movie_motion->test_mode = FALSE; @@ -1655,8 +1656,8 @@ int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_timelapse =(struct ctx_movie*)mymalloc(sizeof(struct ctx_movie)); - if (cam->conf.timelapse_filename){ - timepath = cam->conf.timelapse_filename; + if (cam->conf->timelapse_filename){ + timepath = cam->conf->timelapse_filename; } else { timepath = "%Y%m%d-timelapse"; } @@ -1664,8 +1665,8 @@ int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1){ snprintf(cam->movie_timelapse->filename, PATH_MAX - 4, "%.*s/%.*s" , (int)(PATH_MAX-5-strlen(tmp)) - , cam->conf.target_dir - , (int)(PATH_MAX-5-strlen(cam->conf.target_dir)) + , cam->conf->target_dir + , (int)(PATH_MAX-5-strlen(cam->conf->target_dir)) , tmp); if ((cam->imgs.size_high > 0) && (!cam->movie_passthrough)){ cam->movie_timelapse->width = cam->imgs.width_high; @@ -1676,9 +1677,9 @@ int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_timelapse->height = cam->imgs.height; cam->movie_timelapse->high_resolution = FALSE; } - cam->movie_timelapse->fps = cam->conf.timelapse_fps; - cam->movie_timelapse->bps = cam->conf.movie_bps; - cam->movie_timelapse->quality = cam->conf.movie_quality; + cam->movie_timelapse->fps = cam->conf->timelapse_fps; + cam->movie_timelapse->bps = cam->conf->movie_bps; + cam->movie_timelapse->quality = cam->conf->movie_quality; cam->movie_timelapse->start_time.tv_sec = ts1->tv_sec; cam->movie_timelapse->start_time.tv_nsec = ts1->tv_nsec; cam->movie_timelapse->last_pts = -1; @@ -1689,10 +1690,10 @@ int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1){ cam->movie_timelapse->passthrough = FALSE; cam->movie_timelapse->netcam_data = NULL; - if (mystreq(cam->conf.timelapse_codec,"mpg") || - mystreq(cam->conf.timelapse_codec,"swf") ){ + if (mystreq(cam->conf->timelapse_codec,"mpg") || + mystreq(cam->conf->timelapse_codec,"swf") ){ - if (mystreq(cam->conf.timelapse_codec,"swf")) { + if (mystreq(cam->conf->timelapse_codec,"swf")) { MOTION_LOG(WRN, TYPE_EVENTS, NO_ERRNO ,_("The swf container for timelapse no longer supported. Using mpg container.")); } diff --git a/src/netcam.cpp b/src/netcam.cpp index 821cba7e..d2db6eb4 100644 --- a/src/netcam.cpp +++ b/src/netcam.cpp @@ -18,6 +18,7 @@ #include #include #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "rotate.hpp" @@ -1101,13 +1102,13 @@ static void netcam_set_path (struct ctx_cam *cam, struct ctx_netcam *netcam ) { memset(&url, 0, sizeof(url)); if (netcam->high_resolution){ - netcam_url_parse(&url, cam->conf.netcam_highres); + netcam_url_parse(&url, cam->conf->netcam_highres); } else { - netcam_url_parse(&url, cam->conf.netcam_url); + netcam_url_parse(&url, cam->conf->netcam_url); } - if (cam->conf.netcam_userpass != NULL) { - userpass = mystrdup(cam->conf.netcam_userpass); + if (cam->conf->netcam_userpass != NULL) { + userpass = mystrdup(cam->conf->netcam_userpass); } else if (url.userpass != NULL) { userpass = mystrdup(url.userpass); } @@ -1159,8 +1160,8 @@ static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) { netcam->imgsize.height = 0; snprintf(netcam->cameratype,29, "%s",_("High resolution")); } else { - netcam->imgsize.width = cam->conf.width; - netcam->imgsize.height = cam->conf.height; + netcam->imgsize.width = cam->conf->width; + netcam->imgsize.height = cam->conf->height; snprintf(netcam->cameratype,29, "%s",_("Normal resolution")); } MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO @@ -1168,13 +1169,13 @@ static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) { mycheck_passthrough(cam); /* In case it was turned on via webcontrol */ netcam->status = NETCAM_NOTCONNECTED; - netcam->rtsp_uses_tcp =cam->conf.netcam_use_tcp; - netcam->v4l2_palette = cam->conf.v4l2_palette; - netcam->framerate = cam->conf.framerate; - netcam->src_fps = cam->conf.framerate; /* Default to conf fps */ + netcam->rtsp_uses_tcp =cam->conf->netcam_use_tcp; + netcam->v4l2_palette = cam->conf->v4l2_palette; + netcam->framerate = cam->conf->framerate; + netcam->src_fps = cam->conf->framerate; /* Default to conf fps */ netcam->motapp = cam->motapp; - netcam->conf = &cam->conf; - netcam->camera_name = cam->conf.camera_name; + netcam->conf = cam->conf; + netcam->camera_name = cam->conf->camera_name; netcam->img_recv =(netcam_buff_ptr) mymalloc(sizeof(netcam_buff)); netcam->img_recv->ptr =(char*) mymalloc(NETCAM_BUFFSIZE); netcam->img_latest =(netcam_buff_ptr) mymalloc(sizeof(netcam_buff)); @@ -1193,7 +1194,7 @@ static void netcam_set_parms (struct ctx_cam *cam, struct ctx_netcam *netcam ) { /* If this is the norm and we have a highres, then disable passthru on the norm */ if ((!netcam->high_resolution) && - (cam->conf.netcam_highres)) { + (cam->conf->netcam_highres)) { netcam->passthrough = FALSE; } else { netcam->passthrough = mycheck_passthrough(cam); @@ -1219,26 +1220,26 @@ static int netcam_set_dimensions (struct ctx_cam *cam) { cam->imgs.height_high = 0; cam->imgs.size_high = 0; - if (cam->conf.width % 8) { + if (cam->conf->width % 8) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO - ,_("Image width (%d) requested is not modulo 8."), cam->conf.width); - cam->conf.width = cam->conf.width - (cam->conf.width % 8) + 8; + ,_("Image width (%d) requested is not modulo 8."), cam->conf->width); + cam->conf->width = cam->conf->width - (cam->conf->width % 8) + 8; MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO - ,_("Adjusting width to next higher multiple of 8 (%d)."), cam->conf.width); + ,_("Adjusting width to next higher multiple of 8 (%d)."), cam->conf->width); } - if (cam->conf.height % 8) { + if (cam->conf->height % 8) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO - ,_("Image height (%d) requested is not modulo 8."), cam->conf.height); - cam->conf.height = cam->conf.height - (cam->conf.height % 8) + 8; + ,_("Image height (%d) requested is not modulo 8."), cam->conf->height); + cam->conf->height = cam->conf->height - (cam->conf->height % 8) + 8; MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO - ,_("Adjusting height to next higher multiple of 8 (%d)."), cam->conf.height); + ,_("Adjusting height to next higher multiple of 8 (%d)."), cam->conf->height); } /* Fill in camera details into context structure. */ - cam->imgs.width = cam->conf.width; - cam->imgs.height = cam->conf.height; - cam->imgs.size_norm = (cam->conf.width * cam->conf.height * 3) / 2; - cam->imgs.motionsize = cam->conf.width * cam->conf.height; + cam->imgs.width = cam->conf->width; + cam->imgs.height = cam->conf->height; + cam->imgs.size_norm = (cam->conf->width * cam->conf->height * 3) / 2; + cam->imgs.motionsize = cam->conf->width * cam->conf->height; return 0; } @@ -1695,7 +1696,7 @@ int netcam_setup(struct ctx_cam *cam){ indx_cam = 1; indx_max = 1; - if (cam->conf.netcam_highres) indx_max = 2; + if (cam->conf->netcam_highres) indx_max = 2; while (indx_cam <= indx_max){ if (indx_cam == 1){ diff --git a/src/picture.cpp b/src/picture.cpp index 78f6d659..144477ca 100644 --- a/src/picture.cpp +++ b/src/picture.cpp @@ -9,6 +9,7 @@ * */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "picture.hpp" @@ -240,7 +241,7 @@ int pic_put_memory(struct ctx_cam *cam, unsigned char* dest_image, int image_siz struct timespec ts1; clock_gettime(CLOCK_REALTIME, &ts1); - if (!cam->conf.stream_grey){ + if (!cam->conf->stream_grey){ return jpgutl_put_yuv420p(dest_image, image_size, image, width, height, quality, cam ,&ts1, NULL); } else { @@ -266,11 +267,11 @@ static void pic_write(struct ctx_cam *cam, FILE *picture, unsigned char *image, height = cam->imgs.height; } - if (mystreq(cam->conf.picture_type, "ppm")) { + if (mystreq(cam->conf->picture_type, "ppm")) { pic_save_ppm(picture, image, width, height); - } else if (mystreq(cam->conf.picture_type, "webp")) { + } else if (mystreq(cam->conf->picture_type, "webp")) { pic_save_webp(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); - } else if (mystreq(cam->conf.picture_type, "grey")) { + } else if (mystreq(cam->conf->picture_type, "grey")) { pic_save_grey(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); } else { pic_save_yuv420p(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); @@ -299,7 +300,7 @@ void pic_save_norm(struct ctx_cam *cam, char *file, unsigned char *image, int ft } } - pic_write(cam, picture, image, cam->conf.picture_quality, ftype); + pic_write(cam, picture, image, cam->conf->picture_quality, ftype); myfclose(picture); } @@ -412,11 +413,11 @@ static void pic_write_mask(struct ctx_cam *cam, const char *file) { /* Write pgm-header. */ fprintf(picture, "P5\n"); - fprintf(picture, "%d %d\n", cam->conf.width, cam->conf.height); + fprintf(picture, "%d %d\n", cam->conf->width, cam->conf->height); fprintf(picture, "%d\n", 255); /* Write pgm image data at once. */ - if ((int)fwrite(cam->imgs.image_motion.image_norm, cam->conf.width, cam->conf.height, picture) != cam->conf.height) { + if ((int)fwrite(cam->imgs.image_motion.image_norm, cam->conf->width, cam->conf->height, picture) != cam->conf->height) { MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO ,_("Failed writing default mask as pgm file")); return; @@ -426,7 +427,7 @@ static void pic_write_mask(struct ctx_cam *cam, const char *file) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO ,_("Creating empty mask %s\nPlease edit this file and " - "re-run motion to enable mask feature"), cam->conf.mask_file); + "re-run motion to enable mask feature"), cam->conf->mask_file); } void pic_scale_img(int width_src, int height_src, unsigned char *img_src, unsigned char *img_dst){ @@ -495,8 +496,8 @@ void pic_init_privacy(struct ctx_cam *cam){ cam->imgs.mask_privacy_high = NULL; cam->imgs.mask_privacy_high_uv = NULL; - if (cam->conf.mask_privacy) { - if ((picture = myfopen(cam->conf.mask_privacy, "r"))) { + if (cam->conf->mask_privacy) { + if ((picture = myfopen(cam->conf->mask_privacy, "r"))) { MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, _("Opening privacy mask file")); /* * NOTE: The mask is expected to have the output dimensions. I.e., the mask @@ -518,9 +519,9 @@ void pic_init_privacy(struct ctx_cam *cam){ myfclose(picture); } else { MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO - ,_("Error opening mask file %s"), cam->conf.mask_privacy); + ,_("Error opening mask file %s"), cam->conf->mask_privacy); /* Try to write an empty mask file to make it easier for the user to edit it */ - pic_write_mask(cam, cam->conf.mask_privacy); + pic_write_mask(cam, cam->conf->mask_privacy); } if (!cam->imgs.mask_privacy) { @@ -528,7 +529,7 @@ void pic_init_privacy(struct ctx_cam *cam){ ,_("Failed to read mask privacy image. Mask privacy feature disabled.")); } else { MOTION_LOG(INF, TYPE_ALL, NO_ERRNO - ,_("Mask privacy file \"%s\" loaded."), cam->conf.mask_privacy); + ,_("Mask privacy file \"%s\" loaded."), cam->conf->mask_privacy); indx_img = 1; indx_max = 1; @@ -588,8 +589,8 @@ void pic_init_mask(struct ctx_cam *cam){ FILE *picture; /* Load the mask file if any */ - if (cam->conf.mask_file) { - if ((picture = myfopen(cam->conf.mask_file, "r"))) { + if (cam->conf->mask_file) { + if ((picture = myfopen(cam->conf->mask_file, "r"))) { /* * NOTE: The mask is expected to have the output dimensions. I.e., the mask * applies to the already rotated image, not the capture image. Thus, use @@ -600,12 +601,12 @@ void pic_init_mask(struct ctx_cam *cam){ } else { MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO ,_("Error opening mask file %s") - ,cam->conf.mask_file); + ,cam->conf->mask_file); /* * Try to write an empty mask file to make it easier * for the user to edit it */ - pic_write_mask(cam, cam->conf.mask_file); + pic_write_mask(cam, cam->conf->mask_file); } if (!cam->imgs.mask) { @@ -614,7 +615,7 @@ void pic_init_mask(struct ctx_cam *cam){ } else { MOTION_LOG(INF, TYPE_ALL, NO_ERRNO ,_("Maskfile \"%s\" loaded.") - ,cam->conf.mask_file); + ,cam->conf->mask_file); } } else { cam->imgs.mask = NULL; diff --git a/src/rotate.cpp b/src/rotate.cpp index 0aff323d..4ab839f5 100644 --- a/src/rotate.cpp +++ b/src/rotate.cpp @@ -30,6 +30,7 @@ * v1 (28-Aug-2004) - initial version */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "rotate.hpp" @@ -203,19 +204,19 @@ void rotate_init(struct ctx_cam *cam){ * Assign the value in conf.rotate to rotate_data->degrees. This way, * we have a value that is safe from changes caused by motion-control. */ - if ((cam->conf.rotate % 90) > 0) { + if ((cam->conf->rotate % 90) > 0) { MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO ,_("Config option \"rotate\" not a multiple of 90: %d") - ,cam->conf.rotate); - cam->conf.rotate = 0; /* Disable rotation. */ + ,cam->conf->rotate); + cam->conf->rotate = 0; /* Disable rotation. */ cam->rotate_data->degrees = 0; /* Force return below. */ } else { - cam->rotate_data->degrees = cam->conf.rotate % 360; /* Range: 0..359 */ + cam->rotate_data->degrees = cam->conf->rotate % 360; /* Range: 0..359 */ } - if (cam->conf.flip_axis[0]=='h') { + if (cam->conf->flip_axis[0]=='h') { cam->rotate_data->axis = FLIP_TYPE_HORIZONTAL; - } else if (cam->conf.flip_axis[0]=='v') { + } else if (cam->conf->flip_axis[0]=='v') { cam->rotate_data->axis = FLIP_TYPE_VERTICAL; } else { cam->rotate_data->axis = FLIP_TYPE_NONE; diff --git a/src/track.cpp b/src/track.cpp index 3e0f7cb9..6310160f 100644 --- a/src/track.cpp +++ b/src/track.cpp @@ -7,6 +7,7 @@ */ #include #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "track.hpp" @@ -54,7 +55,7 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) { }; union pantilt pan; - if (cam->track.dev == -1) { + if (cam->track->dev == -1) { int reset = 3; //0-non reset, 1-reset pan, 2-reset tilt, 3-reset pan&tilt struct v4l2_control control_s; @@ -102,17 +103,17 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) { //get mininum //pan.value = queryctrl.minimum; - cam->track.minx = -4480 / INCPANTILT; - cam->track.miny = -1920 / INCPANTILT; + cam->track->minx = -4480 / INCPANTILT; + cam->track->miny = -1920 / INCPANTILT; //get maximum - cam->track.maxx = 4480 / INCPANTILT; - cam->track.maxy = 1920 / INCPANTILT; + cam->track->maxx = 4480 / INCPANTILT; + cam->track->maxy = 1920 / INCPANTILT; //pan.value = queryctrl.maximum; - cam->track.dev = dev; - cam->track.pan_angle = 0; - cam->track.tilt_angle = 0; - cam->track.minmaxfound = 1; + cam->track->dev = dev; + cam->track->pan_angle = 0; + cam->track->tilt_angle = 0; + cam->track->minmaxfound = 1; } @@ -120,17 +121,17 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) { MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO ,_("INPUT_PARAM_ABS pan_min %d,pan_max %d,tilt_min %d,tilt_max %d ") - ,cam->track.minx, cam->track.maxx, cam->track.miny, cam->track.maxy); + ,cam->track->minx, cam->track->maxx, cam->track->miny, cam->track->maxy); MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO ,_("INPUT_PARAM_ABS X_Angel %d, Y_Angel %d ") ,x_angle, y_angle); - if (x_angle <= cam->track.maxx && x_angle >= cam->track.minx){ - move_x_degrees = x_angle - (cam->track.pan_angle); + if (x_angle <= cam->track->maxx && x_angle >= cam->track->minx){ + move_x_degrees = x_angle - (cam->track->pan_angle); } - if (y_angle <= cam->track.maxy && y_angle >= cam->track.miny){ - move_y_degrees = y_angle - (cam->track.tilt_angle); + if (y_angle <= cam->track->maxy && y_angle >= cam->track->miny){ + move_y_degrees = y_angle - (cam->track->tilt_angle); } /* @@ -179,27 +180,27 @@ static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle) { } MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO - ,_("Found MINMAX = %d"),cam->track.minmaxfound); + ,_("Found MINMAX = %d"),cam->track->minmaxfound); - if (cam->track.dev != -1) { + if (cam->track->dev != -1) { MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO ,_("Before_ABS_Y_Angel : x= %d , Y= %d, ") - ,cam->track.pan_angle, cam->track.tilt_angle); + ,cam->track->pan_angle, cam->track->tilt_angle); if (move_x_degrees != -1) { - cam->track.pan_angle += move_x_degrees; + cam->track->pan_angle += move_x_degrees; } if (move_x_degrees != -1) { - cam->track.tilt_angle += move_y_degrees; + cam->track->tilt_angle += move_y_degrees; } MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO ,_("After_ABS_Y_Angel : x= %d , Y= %d") - ,cam->track.pan_angle, cam->track.tilt_angle); + ,cam->track->pan_angle, cam->track->tilt_angle); } - return cam->conf.track_move_wait; + return cam->conf->track_move_wait; #else return 0; #endif @@ -222,7 +223,7 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent * Don't worry, if the WebCam make a sound - over End at PAN - hmmm, should it be normal ...? * PAN Value 7777 in relative will init also a want reset for CAM - it will be "0" after that */ - if ((cam->track.minmaxfound != 1) || (cent->x == 7777)) { + if ((cam->track->minmaxfound != 1) || (cent->x == 7777)) { int reset = 3; //0-non reset, 1-reset pan, 2-reset tilt, 3-reset pan&tilt struct v4l2_control control_s; @@ -258,14 +259,14 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent * Y = -30 to +30 degrees */ - cam->track.minx = -4480 / INCPANTILT; - cam->track.miny = -1920 / INCPANTILT; - cam->track.maxx = 4480 / INCPANTILT; - cam->track.maxy = 1920 / INCPANTILT; - cam->track.dev = dev; - cam->track.pan_angle = 0; - cam->track.tilt_angle = 0; - cam->track.minmaxfound = 1; + cam->track->minx = -4480 / INCPANTILT; + cam->track->miny = -1920 / INCPANTILT; + cam->track->maxx = 4480 / INCPANTILT; + cam->track->maxy = 1920 / INCPANTILT; + cam->track->dev = dev; + cam->track->pan_angle = 0; + cam->track->tilt_angle = 0; + cam->track->minmaxfound = 1; } @@ -278,8 +279,8 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent return 0; } - 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); + 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; @@ -296,34 +297,34 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent struct v4l2_control control_s; union pantilt pan; - if (cam->track.minmaxfound == 1) { + if (cam->track->minmaxfound == 1) { /* * Check current position of camera and see if we need to adjust * values down to what is left to move */ - if (move_x_degrees < 0 && (cam->track.minx - cam->track.pan_angle) > move_x_degrees){ - move_x_degrees = cam->track.minx - cam->track.pan_angle; + if (move_x_degrees < 0 && (cam->track->minx - cam->track->pan_angle) > move_x_degrees){ + move_x_degrees = cam->track->minx - cam->track->pan_angle; } - if (move_x_degrees > 0 && (cam->track.maxx - cam->track.pan_angle) < move_x_degrees){ - move_x_degrees = cam->track.maxx - cam->track.pan_angle; + if (move_x_degrees > 0 && (cam->track->maxx - cam->track->pan_angle) < move_x_degrees){ + move_x_degrees = cam->track->maxx - cam->track->pan_angle; } - if (move_y_degrees < 0 && (cam->track.miny - cam->track.tilt_angle) > move_y_degrees){ - move_y_degrees = cam->track.miny - cam->track.tilt_angle; + if (move_y_degrees < 0 && (cam->track->miny - cam->track->tilt_angle) > move_y_degrees){ + move_y_degrees = cam->track->miny - cam->track->tilt_angle; } - if (move_y_degrees > 0 && (cam->track.maxy - cam->track.tilt_angle) < move_y_degrees){ - move_y_degrees = cam->track.maxy - cam->track.tilt_angle; + if (move_y_degrees > 0 && (cam->track->maxy - cam->track->tilt_angle) < move_y_degrees){ + move_y_degrees = cam->track->maxy - cam->track->tilt_angle; } } MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO ,_("For_SET_REL pan_min %d,pan_max %d,tilt_min %d,tilt_max %d") - ,cam->track.minx, cam->track.maxx, cam->track.miny, cam->track.maxy); + ,cam->track->minx, cam->track->maxx, cam->track->miny, cam->track->maxy); MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO ,_("For_SET_REL track_pan_Angel %d, track_tilt_Angel %d") - ,cam->track.pan_angle, cam->track.tilt_angle); + ,cam->track->pan_angle, cam->track->tilt_angle); MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO ,_("For_SET_REL move_X %d,move_Y %d"), move_x_degrees, move_y_degrees); @@ -380,27 +381,27 @@ static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent } MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO - ,_("Found MINMAX = %d"), cam->track.minmaxfound); + ,_("Found MINMAX = %d"), cam->track->minmaxfound); - if (cam->track.minmaxfound == 1) { + if (cam->track->minmaxfound == 1) { MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO ,_("Before_REL_Y_Angel : x= %d , Y= %d") - ,cam->track.pan_angle, cam->track.tilt_angle); + ,cam->track->pan_angle, cam->track->tilt_angle); if (move_x_degrees != 0){ - cam->track.pan_angle += -pan.s16.pan / INCPANTILT; + cam->track->pan_angle += -pan.s16.pan / INCPANTILT; } if (move_y_degrees != 0){ - cam->track.tilt_angle += -pan.s16.tilt / INCPANTILT; + cam->track->tilt_angle += -pan.s16.tilt / INCPANTILT; } MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO ,_("After_REL_Y_Angel : x= %d , Y= %d") - ,cam->track.pan_angle, cam->track.tilt_angle); + ,cam->track->pan_angle, cam->track->tilt_angle); } - return cam->conf.track_move_wait; + return cam->conf->track_move_wait; #else return 0; #endif /* HAVE_V4L2 */ @@ -411,10 +412,10 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua , int yoff, struct ctx_coord *cent, struct ctx_images *imgs) { char fmtcmd[PATH_MAX]; - cam->track.posx += cent->x; - cam->track.posy += cent->y; + cam->track->posx += cent->x; + cam->track->posy += cent->y; - mystrftime(cam, fmtcmd, sizeof(fmtcmd), cam->conf.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 +466,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->conf.track_generic_move); + ,cam->conf->track_generic_move); exit(1); } @@ -474,27 +475,26 @@ static int generic_move(struct ctx_cam *cam, enum track_action action, int manua ,_("Executing external command '%s'") , fmtcmd); - return cam->conf.track_move_wait; + return cam->conf->track_move_wait; } void track_init(struct ctx_cam *cam){ - cam->track.dev = -1; /* dev open */ - 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 = new ctx_track; + memset(cam->track,0,sizeof(ctx_track)); - cam->track.pan_angle = 0; /* degrees*/ - cam->track.tilt_angle = 0; /* degrees*/ - cam->track.posx = 0; - cam->track.posy = 0; - cam->track.minmaxfound = 0; /* flag for minmax values stored for pwc based camera */ + cam->track->dev = -1; /* dev open */ - if (cam->conf.track_type) + if (cam->conf->track_type) cam->frame_skip = track_center(cam, cam->video_dev, 0, 0, 0); } +void track_deinit(struct ctx_cam *cam){ + + delete cam->track; + +} + /* Add a call to your functions here: */ int track_center(struct ctx_cam *cam, int dev, int manual, int xoff, int yoff) @@ -502,14 +502,14 @@ int track_center(struct ctx_cam *cam, int dev, struct ctx_coord cent; (void)dev; - if (!manual && !cam->conf.track_auto) return 0; + if (!manual && !cam->conf->track_auto) return 0; - if (cam->conf.track_type == TRACK_TYPE_UVC){ + if (cam->conf->track_type == TRACK_TYPE_UVC){ return uvc_center(cam, dev, xoff, yoff); - } 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; + } 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); } else { return 10; // FIX ME. I chose to return something reasonable. @@ -517,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->conf.track_type); + ,_("internal error, %hu is not a known track-type"), cam->conf->track_type); return 0; } @@ -526,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->conf.track_auto) return 0; + if (!manual && !cam->conf->track_auto) return 0; - if (cam->conf.track_type == TRACK_TYPE_UVC){ + if (cam->conf->track_type == TRACK_TYPE_UVC){ return uvc_move(cam, dev, cent, imgs, manual); - } else if (cam->conf.track_type == TRACK_TYPE_GENERIC) { - if (cam->conf.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->conf.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->conf.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 a49588e6..3b11246b 100644 --- a/src/track.hpp +++ b/src/track.hpp @@ -29,6 +29,7 @@ struct ctx_track { enum track_action { TRACK_CENTER, TRACK_MOVE }; void track_init(struct ctx_cam *cam); +void track_deinit(struct ctx_cam *cam); int track_center(struct ctx_cam *cam, int dev, int manual, int xoff, int yoff); diff --git a/src/util.cpp b/src/util.cpp index b7d0a5bc..00a248af 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -20,6 +20,7 @@ */ #include "motion.hpp" +#include "conf.hpp" #include "util.hpp" #include "logger.hpp" #include "dbse.hpp" /*For dbse ID in format output */ @@ -446,8 +447,8 @@ size_t mystrftime(const struct ctx_cam *cam, char *s, size_t max, const char *us break; case '$': // thread name - if (cam->conf.camera_name && cam->conf.camera_name[0]) - snprintf(tempstr, PATH_MAX, "%s", cam->conf.camera_name); + if (cam->conf->camera_name && cam->conf->camera_name[0]) + snprintf(tempstr, PATH_MAX, "%s", cam->conf->camera_name); else ++pos_userformat; break; diff --git a/src/video_common.cpp b/src/video_common.cpp index b4f6700b..2401eb8e 100644 --- a/src/video_common.cpp +++ b/src/video_common.cpp @@ -10,6 +10,7 @@ */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "video_common.hpp" @@ -546,15 +547,15 @@ int vid_parms_parse(struct ctx_cam *cam){ } vdevctx->usrctrl_count = 0; - if (cam->conf.vid_control_params != NULL){ - MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO,_("Parsing controls: %s"),cam->conf.vid_control_params); + if (cam->conf->vid_control_params != NULL){ + MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO,_("Parsing controls: %s"),cam->conf->vid_control_params); indx_parm = 0; parmdesc_st = parmval_st = -1; parmdesc_len = parmval_len = 0; qte_open = FALSE; parmdesc = parmval = NULL; - tst = cam->conf.vid_control_params[indx_parm]; + tst = cam->conf->vid_control_params[indx_parm]; while (tst != '\0') { if (!qte_open) { if (tst == '\"') { /* This is the opening quotation */ @@ -569,7 +570,7 @@ int vid_parms_parse(struct ctx_cam *cam){ if ((parmval_st >= 0) && (parmval_len > 0)){ if (parmval != NULL) free(parmval); parmval =(char*) mymalloc(parmval_len); - snprintf(parmval, parmval_len,"%s",&cam->conf.vid_control_params[parmval_st]); + snprintf(parmval, parmval_len,"%s",&cam->conf->vid_control_params[parmval_st]); } parmdesc_st = indx_parm + 1; parmval_st = -1; @@ -578,7 +579,7 @@ int vid_parms_parse(struct ctx_cam *cam){ if ((parmdesc_st >= 0) && (parmdesc_len > 0)) { if (parmdesc != NULL) free(parmdesc); parmdesc =(char*) mymalloc(parmdesc_len); - snprintf(parmdesc, parmdesc_len,"%s",&cam->conf.vid_control_params[parmdesc_st]); + snprintf(parmdesc, parmdesc_len,"%s",&cam->conf->vid_control_params[parmdesc_st]); } parmdesc_st = -1; parmval_st = indx_parm + 1; @@ -598,7 +599,7 @@ int vid_parms_parse(struct ctx_cam *cam){ if (parmdesc_len > 0 ){ if (parmdesc != NULL) free(parmdesc); parmdesc =(char*) mymalloc(parmdesc_len); - snprintf(parmdesc, parmdesc_len,"%s",&cam->conf.vid_control_params[parmdesc_st]); + snprintf(parmdesc, parmdesc_len,"%s",&cam->conf->vid_control_params[parmdesc_st]); } parmdesc_st = -1; parmval_st = indx_parm + 1; @@ -615,13 +616,13 @@ int vid_parms_parse(struct ctx_cam *cam){ } indx_parm++; - tst = cam->conf.vid_control_params[indx_parm]; + tst = cam->conf->vid_control_params[indx_parm]; } /* Process the last parameter */ if ((parmval_st >= 0) && (parmval_len > 0)){ if (parmval != NULL) free(parmval); parmval =(char*) mymalloc(parmval_len+1); - snprintf(parmval, parmval_len,"%s",&cam->conf.vid_control_params[parmval_st]); + snprintf(parmval, parmval_len,"%s",&cam->conf->vid_control_params[parmval_st]); } if ((parmdesc != NULL) && (parmval != NULL)){ vid_parms_add(vdevctx, parmdesc, parmval); diff --git a/src/video_loopback.cpp b/src/video_loopback.cpp index 5f28ce16..72b05aa8 100644 --- a/src/video_loopback.cpp +++ b/src/video_loopback.cpp @@ -9,6 +9,7 @@ * */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "video_loopback.hpp" @@ -226,12 +227,12 @@ void vlp_init(struct ctx_cam *cam){ #if defined(HAVE_V4L2) && !defined(BSD) /* open video loopback devices if enabled */ - if (cam->conf.video_pipe) { + if (cam->conf->video_pipe) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO ,_("Opening video loopback device for normal pictures")); /* vid_startpipe should get the output dimensions */ - cam->pipe = vlp_startpipe(cam->conf.video_pipe, cam->imgs.width, cam->imgs.height); + cam->pipe = vlp_startpipe(cam->conf->video_pipe, cam->imgs.width, cam->imgs.height); if (cam->pipe < 0) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO @@ -242,12 +243,12 @@ void vlp_init(struct ctx_cam *cam){ cam->pipe = -1; } - if (cam->conf.video_pipe_motion) { + if (cam->conf->video_pipe_motion) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO ,_("Opening video loopback device for motion pictures")); /* vid_startpipe should get the output dimensions */ - cam->mpipe = vlp_startpipe(cam->conf.video_pipe_motion, cam->imgs.width, cam->imgs.height); + cam->mpipe = vlp_startpipe(cam->conf->video_pipe_motion, cam->imgs.width, cam->imgs.height); if (cam->mpipe < 0) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO diff --git a/src/video_v4l2.cpp b/src/video_v4l2.cpp index 458c2d59..a713eda6 100644 --- a/src/video_v4l2.cpp +++ b/src/video_v4l2.cpp @@ -18,6 +18,7 @@ * */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "rotate.hpp" @@ -337,7 +338,7 @@ static int v4l2_parms_set(struct ctx_cam *cam, struct video_dev *curdev){ struct ctx_usrctrl *usritem; int indx_dev, indx_user; - if (cam->conf.roundrobin_skip < 0) cam->conf.roundrobin_skip = 1; + if (cam->conf->roundrobin_skip < 0) cam->conf->roundrobin_skip = 1; if (curdev->devctrl_count == 0){ cam->vdev->update_parms = FALSE; @@ -392,14 +393,14 @@ static int v4l2_input_select(struct ctx_cam *cam, struct video_dev *curdev) { src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private; struct v4l2_input input; - if ((cam->conf.input == curdev->input) && + if ((cam->conf->input == curdev->input) && (!curdev->starting)) return 0; memset(&input, 0, sizeof (struct v4l2_input)); - if (cam->conf.input == DEF_INPUT) { + if (cam->conf->input == DEF_INPUT) { input.index = 0; } else { - input.index = cam->conf.input; + input.index = cam->conf->input; } if (xioctl(vid_source, VIDIOC_ENUMINPUT, &input) == -1) { @@ -432,7 +433,7 @@ static int v4l2_input_select(struct ctx_cam *cam, struct video_dev *curdev) { return -1; } - curdev->input = cam->conf.input; + curdev->input = cam->conf->input; curdev->device_type = input.type; curdev->device_tuner = input.tuner; @@ -447,10 +448,10 @@ static int v4l2_norm_select(struct ctx_cam *cam, struct video_dev *curdev) { v4l2_std_id std_id; int norm; - if ((cam->conf.norm == curdev->norm) && + if ((cam->conf->norm == curdev->norm) && (!curdev->starting)) return 0; - norm = cam->conf.norm; + norm = cam->conf->norm; if (xioctl(vid_source, VIDIOC_G_STD, &std_id) == -1) { if (curdev->starting){ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO @@ -498,7 +499,7 @@ static int v4l2_norm_select(struct ctx_cam *cam, struct video_dev *curdev) { } } - curdev->norm = cam->conf.norm; + curdev->norm = cam->conf->norm; return 0; } @@ -510,7 +511,7 @@ static int v4l2_frequency_select(struct ctx_cam *cam, struct video_dev *curdev) struct v4l2_tuner tuner; struct v4l2_frequency freq; - if ((curdev->frequency == cam->conf.frequency)&& + if ((curdev->frequency == cam->conf->frequency)&& (!curdev->starting)) return 0; /* If this input is attached to a tuner, set the frequency. */ @@ -533,7 +534,7 @@ static int v4l2_frequency_select(struct ctx_cam *cam, struct video_dev *curdev) memset(&freq, 0, sizeof(struct v4l2_frequency)); freq.tuner = curdev->device_tuner; freq.type = V4L2_TUNER_ANALOG_TV; - freq.frequency = (cam->conf.frequency / 1000) * 16; + freq.frequency = (cam->conf->frequency / 1000) * 16; if (xioctl(vid_source, VIDIOC_S_FREQUENCY, &freq) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO @@ -546,7 +547,7 @@ static int v4l2_frequency_select(struct ctx_cam *cam, struct video_dev *curdev) } } - curdev->frequency = cam->conf.frequency; + curdev->frequency = cam->conf->frequency; return 0; } @@ -559,8 +560,8 @@ static int v4l2_pixfmt_set(struct ctx_cam *cam, struct video_dev *curdev, u32 pi memset(&vid_source->dst_fmt, 0, sizeof(struct v4l2_format)); vid_source->dst_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - vid_source->dst_fmt.fmt.pix.width = cam->conf.width; - vid_source->dst_fmt.fmt.pix.height = cam->conf.height; + vid_source->dst_fmt.fmt.pix.width = cam->conf->width; + vid_source->dst_fmt.fmt.pix.height = cam->conf->height; vid_source->dst_fmt.fmt.pix.pixelformat = pixformat; vid_source->dst_fmt.fmt.pix.field = V4L2_FIELD_ANY; @@ -570,17 +571,17 @@ static int v4l2_pixfmt_set(struct ctx_cam *cam, struct video_dev *curdev, u32 pi ,_("Testing palette %c%c%c%c (%dx%d)") ,pixformat >> 0, pixformat >> 8 ,pixformat >> 16, pixformat >> 24 - ,cam->conf.width, cam->conf.height); + ,cam->conf->width, cam->conf->height); curdev->width = vid_source->dst_fmt.fmt.pix.width; curdev->height = vid_source->dst_fmt.fmt.pix.height; - if (vid_source->dst_fmt.fmt.pix.width != (unsigned int) cam->conf.width || - vid_source->dst_fmt.fmt.pix.height != (unsigned int) cam->conf.height) { + if (vid_source->dst_fmt.fmt.pix.width != (unsigned int) cam->conf->width || + vid_source->dst_fmt.fmt.pix.height != (unsigned int) cam->conf->height) { MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO ,_("Adjusting resolution from %ix%i to %ix%i.") - ,cam->conf.width, cam->conf.height + ,cam->conf->width, cam->conf->height ,vid_source->dst_fmt.fmt.pix.width ,vid_source->dst_fmt.fmt.pix.height); @@ -591,8 +592,8 @@ static int v4l2_pixfmt_set(struct ctx_cam *cam, struct video_dev *curdev, u32 pi ,_("Specify different palette or width/height in config file.")); return -1; } - cam->conf.width = curdev->width; - cam->conf.height = curdev->height; + cam->conf->width = curdev->width; + cam->conf->height = curdev->height; } if (xioctl(vid_source, VIDIOC_S_FMT, &vid_source->dst_fmt) == -1) { @@ -608,7 +609,7 @@ static int v4l2_pixfmt_set(struct ctx_cam *cam, struct video_dev *curdev, u32 pi ,_("Using palette %c%c%c%c (%dx%d)") ,pixformat >> 0 , pixformat >> 8 ,pixformat >> 16, pixformat >> 24 - ,cam->conf.width, cam->conf.height); + ,cam->conf->width, cam->conf->height); MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO ,_("Bytesperlines %d sizeimage %d colorspace %08x") ,vid_source->dst_fmt.fmt.pix.bytesperline @@ -635,30 +636,30 @@ static int v4l2_pixfmt_select(struct ctx_cam *cam, struct video_dev *curdev) { v4l2_palette_init(palette_array); - if (cam->conf.width % 8) { + if (cam->conf->width % 8) { MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO - ,_("config image width (%d) is not modulo 8"), cam->conf.width); - cam->conf.width = cam->conf.width - (cam->conf.width % 8) + 8; + ,_("config image width (%d) is not modulo 8"), cam->conf->width); + cam->conf->width = cam->conf->width - (cam->conf->width % 8) + 8; MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO - , _("Adjusting to width (%d)"), cam->conf.width); + , _("Adjusting to width (%d)"), cam->conf->width); } - if (cam->conf.height % 8) { + if (cam->conf->height % 8) { MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO - ,_("config image height (%d) is not modulo 8"), cam->conf.height); - cam->conf.height = cam->conf.height - (cam->conf.height % 8) + 8; + ,_("config image height (%d) is not modulo 8"), cam->conf->height); + cam->conf->height = cam->conf->height - (cam->conf->height % 8) + 8; MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO - ,_("Adjusting to height (%d)"), cam->conf.height); + ,_("Adjusting to height (%d)"), cam->conf->height); } - if (cam->conf.v4l2_palette == 21 ) { + if (cam->conf->v4l2_palette == 21 ) { MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO ,_("H264(21) format not supported via videodevice. Changing to default palette")); - cam->conf.v4l2_palette = 17; + cam->conf->v4l2_palette = 17; } /* First we try setting the config file value */ - indx_palette = cam->conf.v4l2_palette; + indx_palette = cam->conf->v4l2_palette; if ((indx_palette >= 0) && (indx_palette <= V4L2_PALETTE_COUNT_MAX)) { retcd = v4l2_pixfmt_set(cam, curdev,palette_array[indx_palette].v4l2id); if (retcd >= 0){ @@ -668,7 +669,7 @@ static int v4l2_pixfmt_select(struct ctx_cam *cam, struct video_dev *curdev) { MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO ,_("Configuration palette index %d (%s) for %dx%d doesn't work.") , indx_palette, palette_array[indx_palette].fourcc - ,cam->conf.width, cam->conf.height); + ,cam->conf->width, cam->conf->height); } memset(&fmtd, 0, sizeof(struct v4l2_fmtdesc)); @@ -830,8 +831,8 @@ static int v4l2_imgs_set(struct ctx_cam *cam, struct video_dev *curdev) { cam->imgs.height = curdev->height; cam->imgs.motionsize = cam->imgs.width * cam->imgs.height; cam->imgs.size_norm = (cam->imgs.motionsize * 3) / 2; - cam->conf.width = curdev->width; - cam->conf.height = curdev->height; + cam->conf->width = curdev->width; + cam->conf->height = curdev->height; return 0; @@ -846,8 +847,8 @@ static int v4l2_capture(struct ctx_cam *cam, struct video_dev *curdev, unsigned src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private; int shift, width, height, retcd; - width = cam->conf.width; - height = cam->conf.height; + width = cam->conf->width; + height = cam->conf->height; /* Block signals during IOCTL */ sigemptyset(&set); @@ -1003,11 +1004,11 @@ static int v4l2_device_init(struct ctx_cam *cam, struct video_dev *curdev) { pthread_mutex_init(&curdev->mutex, &curdev->attr); curdev->usage_count = 1; - curdev->input = cam->conf.input; - curdev->norm = cam->conf.norm; - curdev->frequency = cam->conf.frequency; - curdev->height = cam->conf.height; - curdev->width = cam->conf.width; + curdev->input = cam->conf->input; + curdev->norm = cam->conf->norm; + curdev->frequency = cam->conf->frequency; + curdev->height = cam->conf->height; + curdev->width = cam->conf->width; curdev->devctrl_array = NULL; curdev->devctrl_count = 0; @@ -1017,7 +1018,7 @@ static int v4l2_device_init(struct ctx_cam *cam, struct video_dev *curdev) { curdev->v4l2_private = vid_source; vid_source->fd_device = curdev->fd_device; - vid_source->fps = cam->conf.framerate; + vid_source->fps = cam->conf->framerate; vid_source->pframe = -1; vid_source->finish = &cam->finish_cam; vid_source->buffers = NULL; @@ -1034,9 +1035,9 @@ static void v4l2_device_select(struct ctx_cam *cam, struct video_dev *curdev, un return; } - if (cam->conf.input != curdev->input || - cam->conf.frequency != curdev->frequency || - cam->conf.norm != curdev->norm) { + if (cam->conf->input != curdev->input || + cam->conf->frequency != curdev->frequency || + cam->conf->norm != curdev->norm) { retcd = v4l2_input_select(cam, curdev); if (retcd == 0) retcd = v4l2_norm_select(cam, curdev); @@ -1055,7 +1056,7 @@ static void v4l2_device_select(struct ctx_cam *cam, struct video_dev *curdev, un } /* Skip the requested round robin frame count */ - for (indx = 1; indx < cam->conf.roundrobin_skip; indx++){ + for (indx = 1; indx < cam->conf->roundrobin_skip; indx++){ v4l2_capture(cam, curdev, map); } @@ -1080,9 +1081,9 @@ 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.videodevice, cam->conf.input); + ,cam->conf->videodevice, cam->conf->input); - curdev->videodevice = cam->conf.videodevice; + curdev->videodevice = cam->conf->videodevice; curdev->fd_device = -1; fd_device = -1; @@ -1096,7 +1097,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.videodevice); + ,cam->conf->videodevice); return -1; } @@ -1209,7 +1210,7 @@ static int v4l2_fps_set(struct ctx_cam *cam, struct video_dev *curdev) { setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; setfps.parm.capture.timeperframe.numerator = 1; - setfps.parm.capture.timeperframe.denominator = cam->conf.framerate; + setfps.parm.capture.timeperframe.denominator = cam->conf->framerate; MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO , _("Trying to set fps to %d") @@ -1257,7 +1258,7 @@ int v4l2_start(struct ctx_cam *cam) { /* If device is already open and initialized use it*/ curdev = videodevices; while (curdev) { - if (mystreq(cam->conf.videodevice, curdev->videodevice)) { + 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); @@ -1390,7 +1391,7 @@ void v4l2_cleanup(struct ctx_cam *cam) { int v4l2_next(struct ctx_cam *cam, struct ctx_image_data *img_data) { #ifdef HAVE_V4L2 int ret = -2; - struct ctx_config *conf = &cam->conf; + struct ctx_config *conf = cam->conf; struct video_dev *dev; pthread_mutex_lock(&v4l2_mutex); diff --git a/src/webu.cpp b/src/webu.cpp index 0b8c86ca..9daf997e 100644 --- a/src/webu.cpp +++ b/src/webu.cpp @@ -38,13 +38,16 @@ #include #include "motion.hpp" +#include "conf.hpp" +#include "conf_edit.hpp" #include "logger.hpp" #include "util.hpp" #include "webu.hpp" #include "webu_html.hpp" #include "webu_text.hpp" #include "webu_stream.hpp" -#include "conf_edit.hpp" +#include "track.hpp" + /* Context to pass the parms to functions to start mhd */ @@ -180,13 +183,13 @@ static void webu_badreq(struct webui_ctx *webui){ * bad request response either with or without the HTML tags. */ if (webui->cam != NULL) { - if (webui->cam->conf.webcontrol_interface == 1){ + if (webui->cam->conf->webcontrol_interface == 1){ webu_text_badreq(webui); } else { webu_html_badreq(webui); } } else if (webui->camlst != NULL) { - if (webui->camlst[0]->conf.webcontrol_interface == 1){ + if (webui->camlst[0]->conf->webcontrol_interface == 1){ webu_text_badreq(webui); } else { webu_html_badreq(webui); @@ -685,7 +688,7 @@ static int webu_process_config_set(struct webui_ctx *webui) { indx=0; while (config_parms[indx].parm_name != NULL) { if (((webui->thread_nbr != 0) && (config_parms[indx].main_thread)) || - (config_parms[indx].webui_level > webui->camlst[0]->conf.webcontrol_parms) || + (config_parms[indx].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx].webui_level == WEBUI_LEVEL_NEVER) ) { indx++; continue; @@ -816,9 +819,9 @@ static void webu_clientip(struct webui_ctx *webui) { is_ipv6 = FALSE; if (webui->cam != NULL ){ - if (webui->cam->conf.webcontrol_ipv6) is_ipv6 = TRUE; + if (webui->cam->conf->webcontrol_ipv6) is_ipv6 = TRUE; } else { - if (webui->camlst[0]->conf.webcontrol_ipv6) is_ipv6 = TRUE; + if (webui->camlst[0]->conf->webcontrol_ipv6) is_ipv6 = TRUE; } con_info = MHD_get_connection_info(webui->connection, MHD_CONNECTION_INFO_CLIENT_ADDRESS); @@ -886,13 +889,13 @@ static void webu_hostname(struct webui_ctx *webui, int ctrl) { * streams. */ if (ctrl){ - if (webui->cam->conf.webcontrol_tls){ + if (webui->cam->conf->webcontrol_tls){ snprintf(webui->hostproto,6,"%s","https"); } else { snprintf(webui->hostproto,6,"%s","http"); } } else { - if (webui->cam->conf.stream_tls){ + if (webui->cam->conf->stream_tls){ snprintf(webui->hostproto,6,"%s","https"); } else { snprintf(webui->hostproto,6,"%s","http"); @@ -1025,35 +1028,35 @@ static void webu_mhd_auth_parse(struct webui_ctx *webui, int ctrl){ webui->auth_pass = NULL; if (ctrl){ - auth_len = strlen(webui->cam->conf.webcontrol_authentication); - col_pos =(char*) strstr(webui->cam->conf.webcontrol_authentication,":"); + auth_len = strlen(webui->cam->conf->webcontrol_authentication); + col_pos =(char*) strstr(webui->cam->conf->webcontrol_authentication,":"); if (col_pos == NULL){ webui->auth_user = (char*)mymalloc(auth_len+1); webui->auth_pass = (char*)mymalloc(2); snprintf(webui->auth_user, auth_len + 1, "%s" - ,webui->cam->conf.webcontrol_authentication); + ,webui->cam->conf->webcontrol_authentication); snprintf(webui->auth_pass, 2, "%s",""); } else { webui->auth_user = (char*)mymalloc(auth_len - strlen(col_pos) + 1); webui->auth_pass =(char*)mymalloc(strlen(col_pos)); snprintf(webui->auth_user, auth_len - strlen(col_pos) + 1, "%s" - ,webui->cam->conf.webcontrol_authentication); + ,webui->cam->conf->webcontrol_authentication); snprintf(webui->auth_pass, strlen(col_pos), "%s", col_pos + 1); } } else { - auth_len = strlen(webui->cam->conf.stream_authentication); - col_pos =(char*) strstr(webui->cam->conf.stream_authentication,":"); + auth_len = strlen(webui->cam->conf->stream_authentication); + col_pos =(char*) strstr(webui->cam->conf->stream_authentication,":"); if (col_pos == NULL){ webui->auth_user = (char*)mymalloc(auth_len+1); webui->auth_pass = (char*)mymalloc(2); snprintf(webui->auth_user, auth_len + 1, "%s" - ,webui->cam->conf.stream_authentication); + ,webui->cam->conf->stream_authentication); snprintf(webui->auth_pass, 2, "%s",""); } else { webui->auth_user = (char*)mymalloc(auth_len - strlen(col_pos) + 1); webui->auth_pass = (char*)mymalloc(strlen(col_pos)); snprintf(webui->auth_user, auth_len - strlen(col_pos) + 1, "%s" - ,webui->cam->conf.stream_authentication); + ,webui->cam->conf->stream_authentication); snprintf(webui->auth_pass, strlen(col_pos), "%s", col_pos + 1); } } @@ -1078,9 +1081,9 @@ static int webu_mhd_auth(struct webui_ctx *webui, int ctrl){ if (ctrl){ /* Authentication for the webcontrol*/ - if (webui->cam->conf.webcontrol_authentication == NULL){ + if (webui->cam->conf->webcontrol_authentication == NULL){ webui->authenticated = TRUE; - if (webui->cam->conf.webcontrol_auth_method != 0){ + if (webui->cam->conf->webcontrol_auth_method != 0){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("No webcontrol user:pass provided")); } return MHD_YES; @@ -1088,17 +1091,17 @@ static int webu_mhd_auth(struct webui_ctx *webui, int ctrl){ if (webui->auth_user == NULL) webu_mhd_auth_parse(webui, ctrl); - if (webui->cam->conf.webcontrol_auth_method == 1){ + if (webui->cam->conf->webcontrol_auth_method == 1){ return webu_mhd_basic(webui); - } else if (webui->cam->conf.webcontrol_auth_method == 2){ + } else if (webui->cam->conf->webcontrol_auth_method == 2){ return webu_mhd_digest(webui); } } else { /* Authentication for the streams */ - if (webui->cam->conf.stream_authentication == NULL){ + if (webui->cam->conf->stream_authentication == NULL){ webui->authenticated = TRUE; - if (webui->cam->conf.stream_auth_method != 0){ + if (webui->cam->conf->stream_auth_method != 0){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("No stream user:pass provided")); } return MHD_YES; @@ -1106,9 +1109,9 @@ static int webu_mhd_auth(struct webui_ctx *webui, int ctrl){ if (webui->auth_user == NULL) webu_mhd_auth_parse(webui, ctrl); - if (webui->cam->conf.stream_auth_method == 1) { + if (webui->cam->conf->stream_auth_method == 1) { return webu_mhd_basic(webui); - } else if (webui->cam->conf.stream_auth_method == 2){ + } else if (webui->cam->conf->stream_auth_method == 2){ return webu_mhd_digest(webui); } } @@ -1140,19 +1143,19 @@ static int webu_mhd_send(struct webui_ctx *webui, int ctrl) { if (webui->cam != NULL){ if (ctrl){ - if (webui->cam->conf.webcontrol_cors_header != NULL){ + if (webui->cam->conf->webcontrol_cors_header != NULL){ MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN - , webui->cam->conf.webcontrol_cors_header); + , webui->cam->conf->webcontrol_cors_header); } - if (webui->cam->conf.webcontrol_interface == 1){ + if (webui->cam->conf->webcontrol_interface == 1){ MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/plain;"); } else { MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); } } else { - if (webui->cam->conf.stream_cors_header != NULL){ + if (webui->cam->conf->stream_cors_header != NULL){ MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN - , webui->cam->conf.stream_cors_header); + , webui->cam->conf->stream_cors_header); } MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); } @@ -1263,8 +1266,8 @@ static int webu_answer_ctrl(void *cls if (!webui->authenticated) return retcd; } - if ((webui->camlst[0]->conf.webcontrol_interface == 1) || - (webui->camlst[0]->conf.webcontrol_interface == 2)) { + if ((webui->camlst[0]->conf->webcontrol_interface == 1) || + (webui->camlst[0]->conf->webcontrol_interface == 2)) { webu_text_main(webui); } else { webu_html_main(webui); @@ -1497,12 +1500,12 @@ static void webu_mhd_features_basic(struct mhdstart_ctx *mhdst){ if (retcd == MHD_YES){ MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO ,_("Basic authentication: available")); } else { - if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_auth_method == 1)){ + if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_auth_method == 1)){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Basic authentication: disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_auth_method = 0; - } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.stream_auth_method == 1)){ + mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_auth_method = 0; + } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_auth_method == 1)){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Basic authentication: disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.stream_auth_method = 0; + mhdst->camlst[mhdst->indxthrd]->conf->stream_auth_method = 0; } else { MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("Basic authentication: disabled")); } @@ -1520,12 +1523,12 @@ static void webu_mhd_features_digest(struct mhdstart_ctx *mhdst){ if (retcd == MHD_YES){ MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO ,_("Digest authentication: available")); } else { - if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_auth_method == 2)){ + if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_auth_method == 2)){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Digest authentication: disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_auth_method = 0; - } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.stream_auth_method == 2)){ + mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_auth_method = 0; + } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_auth_method == 2)){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Digest authentication: disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.stream_auth_method = 0; + mhdst->camlst[mhdst->indxthrd]->conf->stream_auth_method = 0; } else { MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("Digest authentication: disabled")); } @@ -1561,12 +1564,12 @@ static void webu_mhd_features_tls(struct mhdstart_ctx *mhdst){ * support the ssl/tls request. */ #if MHD_VERSION < 0x00094400 - if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_tls)){ + if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_tls)){ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("libmicrohttpd libary too old SSL/TLS disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_tls = 0; - } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.stream_tls)) { + mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_tls = 0; + } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_tls)) { MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("libmicrohttpd libary too old SSL/TLS disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.stream_tls = 0; + mhdst->camlst[mhdst->indxthrd]->conf->stream_tls = 0; } #else int retcd; @@ -1574,12 +1577,12 @@ static void webu_mhd_features_tls(struct mhdstart_ctx *mhdst){ if (retcd == MHD_YES){ MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS: available")); } else { - if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_tls)){ + if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_tls)){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS: disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_tls = 0; - } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.stream_tls)){ + mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_tls = 0; + } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_tls)){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS: disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.stream_tls = 0; + mhdst->camlst[mhdst->indxthrd]->conf->stream_tls = 0; } else { MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS: disabled")); } @@ -1648,29 +1651,29 @@ static void webu_mhd_checktls(struct mhdstart_ctx *mhdst){ * then we revise the configuration request for ssl/tls */ if (mhdst->ctrl){ - if (mhdst->camlst[0]->conf.webcontrol_tls){ - if ((mhdst->camlst[0]->conf.webcontrol_cert == NULL) || (mhdst->tls_cert == NULL)) { + if (mhdst->camlst[0]->conf->webcontrol_tls){ + if ((mhdst->camlst[0]->conf->webcontrol_cert == NULL) || (mhdst->tls_cert == NULL)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS requested but no cert file provided. SSL/TLS disabled")); - mhdst->camlst[0]->conf.webcontrol_tls = 0; + mhdst->camlst[0]->conf->webcontrol_tls = 0; } - if ((mhdst->camlst[0]->conf.webcontrol_key == NULL) || (mhdst->tls_key == NULL)) { + if ((mhdst->camlst[0]->conf->webcontrol_key == NULL) || (mhdst->tls_key == NULL)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS requested but no key file provided. SSL/TLS disabled")); - mhdst->camlst[0]->conf.webcontrol_tls = 0; + mhdst->camlst[0]->conf->webcontrol_tls = 0; } } } else { - if (mhdst->camlst[mhdst->indxthrd]->conf.stream_tls){ - if ((mhdst->camlst[0]->conf.webcontrol_cert == NULL) || (mhdst->tls_cert == NULL)) { + if (mhdst->camlst[mhdst->indxthrd]->conf->stream_tls){ + if ((mhdst->camlst[0]->conf->webcontrol_cert == NULL) || (mhdst->tls_cert == NULL)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS requested but no cert file provided. SSL/TLS disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.stream_tls = 0; + mhdst->camlst[mhdst->indxthrd]->conf->stream_tls = 0; } - if ((mhdst->camlst[0]->conf.webcontrol_key == NULL) || (mhdst->tls_key == NULL)) { + if ((mhdst->camlst[0]->conf->webcontrol_key == NULL) || (mhdst->tls_key == NULL)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS requested but no key file provided. SSL/TLS disabled")); - mhdst->camlst[mhdst->indxthrd]->conf.stream_tls = 0; + mhdst->camlst[mhdst->indxthrd]->conf->stream_tls = 0; } } } @@ -1713,11 +1716,11 @@ static void webu_mhd_opts_localhost(struct mhdstart_ctx *mhdst){ * motion configuation option of localhost only. */ - if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_localhost)){ + if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_localhost)){ if (mhdst->ipv6){ memset(&mhdst->lpbk_ipv6, 0, sizeof(struct sockaddr_in6)); mhdst->lpbk_ipv6.sin6_family = AF_INET6; - mhdst->lpbk_ipv6.sin6_port = htons(mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_port); + mhdst->lpbk_ipv6.sin6_port = htons(mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_port); mhdst->lpbk_ipv6.sin6_addr = in6addr_loopback; mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_SOCK_ADDR; @@ -1728,7 +1731,7 @@ static void webu_mhd_opts_localhost(struct mhdstart_ctx *mhdst){ } else { memset(&mhdst->lpbk_ipv4, 0, sizeof(struct sockaddr_in)); mhdst->lpbk_ipv4.sin_family = AF_INET; - mhdst->lpbk_ipv4.sin_port = htons(mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_port); + mhdst->lpbk_ipv4.sin_port = htons(mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_port); mhdst->lpbk_ipv4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_SOCK_ADDR; @@ -1736,11 +1739,11 @@ static void webu_mhd_opts_localhost(struct mhdstart_ctx *mhdst){ mhdst->mhd_ops[mhdst->mhd_opt_nbr].ptr_value = (struct sockaddr *)(&mhdst->lpbk_ipv4); mhdst->mhd_opt_nbr++; } - } else if((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.stream_localhost)){ + } else if((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_localhost)){ if (mhdst->ipv6){ memset(&mhdst->lpbk_ipv6, 0, sizeof(struct sockaddr_in6)); mhdst->lpbk_ipv6.sin6_family = AF_INET6; - mhdst->lpbk_ipv6.sin6_port = htons(mhdst->camlst[mhdst->indxthrd]->conf.stream_port); + mhdst->lpbk_ipv6.sin6_port = htons(mhdst->camlst[mhdst->indxthrd]->conf->stream_port); mhdst->lpbk_ipv6.sin6_addr = in6addr_loopback; mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_SOCK_ADDR; @@ -1750,7 +1753,7 @@ static void webu_mhd_opts_localhost(struct mhdstart_ctx *mhdst){ } else { memset(&mhdst->lpbk_ipv4, 0, sizeof(struct sockaddr_in)); mhdst->lpbk_ipv4.sin_family = AF_INET; - mhdst->lpbk_ipv4.sin_port = htons(mhdst->camlst[mhdst->indxthrd]->conf.stream_port); + mhdst->lpbk_ipv4.sin_port = htons(mhdst->camlst[mhdst->indxthrd]->conf->stream_port); mhdst->lpbk_ipv4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_SOCK_ADDR; @@ -1767,8 +1770,8 @@ static void webu_mhd_opts_digest(struct mhdstart_ctx *mhdst){ * function is when we are wanting to use digest authentication */ - if (((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_auth_method == 2)) || - ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.stream_auth_method == 2))) { + if (((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_auth_method == 2)) || + ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_auth_method == 2))) { if (mhdst->ctrl) { mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_DIGEST_AUTH_RANDOM; @@ -1797,8 +1800,8 @@ static void webu_mhd_opts_digest(struct mhdstart_ctx *mhdst){ static void webu_mhd_opts_tls(struct mhdstart_ctx *mhdst){ /* Set the MHD options needed when we want TLS connections */ - if ((( mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_tls)) || - ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.stream_tls))) { + if ((( mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_tls)) || + ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_tls))) { mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_HTTPS_MEM_CERT; mhdst->mhd_ops[mhdst->mhd_opt_nbr].value = 0; @@ -1844,9 +1847,9 @@ static void webu_mhd_flags(struct mhdstart_ctx *mhdst){ if (mhdst->ipv6) mhdst->mhd_flags = mhdst->mhd_flags | MHD_USE_DUAL_STACK; - if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.webcontrol_tls)){ + if ((mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->webcontrol_tls)){ mhdst->mhd_flags = mhdst->mhd_flags | MHD_USE_SSL; - } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf.stream_tls)){ + } else if ((!mhdst->ctrl) && (mhdst->camlst[mhdst->indxthrd]->conf->stream_tls)){ mhdst->mhd_flags = mhdst->mhd_flags | MHD_USE_SSL; } @@ -1862,19 +1865,19 @@ static void webu_strm_ntc(struct ctx_cam **camlst, int indxthrd){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Started camera %d stream on port/camera_id %d/%d") ,camlst[indx]->camera_id - ,camlst[indxthrd]->conf.stream_port + ,camlst[indxthrd]->conf->stream_port ,camlst[indx]->camera_id); indx++; } } else { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Started camera %d stream on port %d") - ,camlst[indxthrd]->camera_id,camlst[indxthrd]->conf.stream_port); + ,camlst[indxthrd]->camera_id,camlst[indxthrd]->conf->stream_port); } } else { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Started camera %d stream on port %d") - ,camlst[indxthrd]->camera_id,camlst[indxthrd]->conf.stream_port); + ,camlst[indxthrd]->camera_id,camlst[indxthrd]->conf->stream_port); } } @@ -1890,12 +1893,12 @@ static void webu_init_ctrl(struct ctx_motapp *motapp){ struct mhdstart_ctx mhdst; unsigned int randnbr; - mhdst.tls_cert = webu_mhd_loadfile(motapp->cam_list[0]->conf.webcontrol_cert); - mhdst.tls_key = webu_mhd_loadfile(motapp->cam_list[0]->conf.webcontrol_key); + mhdst.tls_cert = webu_mhd_loadfile(motapp->cam_list[0]->conf->webcontrol_cert); + mhdst.tls_key = webu_mhd_loadfile(motapp->cam_list[0]->conf->webcontrol_key); mhdst.ctrl = TRUE; mhdst.indxthrd = 0; mhdst.camlst = motapp->cam_list; - mhdst.ipv6 = motapp->cam_list[0]->conf.webcontrol_ipv6; + mhdst.ipv6 = motapp->cam_list[0]->conf->webcontrol_ipv6; /* Set the rand number for webcontrol digest if needed */ srand(time(NULL)); @@ -1904,10 +1907,10 @@ static void webu_init_ctrl(struct ctx_motapp *motapp){ ,sizeof(motapp->webcontrol_digest_rand),"%d",randnbr); motapp->webcontrol_daemon = NULL; - if (motapp->cam_list[0]->conf.webcontrol_port != 0 ){ + if (motapp->cam_list[0]->conf->webcontrol_port != 0 ){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Starting webcontrol on port %d") - ,motapp->cam_list[0]->conf.webcontrol_port); + ,motapp->cam_list[0]->conf->webcontrol_port); mhdst.mhd_ops =(struct MHD_OptionItem*)mymalloc(sizeof(struct MHD_OptionItem)*WEBUI_MHD_OPTS); webu_mhd_features(&mhdst); @@ -1915,7 +1918,7 @@ static void webu_init_ctrl(struct ctx_motapp *motapp){ webu_mhd_flags(&mhdst); motapp->webcontrol_daemon = MHD_start_daemon (mhdst.mhd_flags - ,motapp->cam_list[0]->conf.webcontrol_port + ,motapp->cam_list[0]->conf->webcontrol_port ,NULL, NULL ,&webu_answer_ctrl, motapp->cam_list ,MHD_OPTION_ARRAY, mhdst.mhd_ops @@ -1926,7 +1929,7 @@ static void webu_init_ctrl(struct ctx_motapp *motapp){ } else { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Started webcontrol on port %d") - ,motapp->cam_list[0]->conf.webcontrol_port); + ,motapp->cam_list[0]->conf->webcontrol_port); } } @@ -1945,12 +1948,12 @@ static void webu_init_strm(struct ctx_cam **cam_list){ struct mhdstart_ctx mhdst; unsigned int randnbr; - mhdst.tls_cert = webu_mhd_loadfile(cam_list[0]->conf.webcontrol_cert); - mhdst.tls_key = webu_mhd_loadfile(cam_list[0]->conf.webcontrol_key); + mhdst.tls_cert = webu_mhd_loadfile(cam_list[0]->conf->webcontrol_cert); + mhdst.tls_key = webu_mhd_loadfile(cam_list[0]->conf->webcontrol_key); mhdst.ctrl = FALSE; mhdst.indxthrd = 0; mhdst.camlst = cam_list; - mhdst.ipv6 = cam_list[0]->conf.webcontrol_ipv6; + mhdst.ipv6 = cam_list[0]->conf->webcontrol_ipv6; /* Set the rand number for webcontrol digest if needed */ srand(time(NULL)); @@ -1960,16 +1963,16 @@ static void webu_init_strm(struct ctx_cam **cam_list){ while (cam_list[mhdst.indxthrd] != NULL){ cam_list[mhdst.indxthrd]->stream.daemon = NULL; - if (cam_list[mhdst.indxthrd]->conf.stream_port != 0 ){ + if (cam_list[mhdst.indxthrd]->conf->stream_port != 0 ){ if (mhdst.indxthrd == 0){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Starting all camera streams on port %d") - ,cam_list[mhdst.indxthrd]->conf.stream_port); + ,cam_list[mhdst.indxthrd]->conf->stream_port); } else { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Starting camera %d stream on port %d") ,cam_list[mhdst.indxthrd]->camera_id - ,cam_list[mhdst.indxthrd]->conf.stream_port); + ,cam_list[mhdst.indxthrd]->conf->stream_port); } mhdst.mhd_ops=(struct MHD_OptionItem*)mymalloc(sizeof(struct MHD_OptionItem)*WEBUI_MHD_OPTS); @@ -1978,14 +1981,14 @@ static void webu_init_strm(struct ctx_cam **cam_list){ webu_mhd_flags(&mhdst); if (mhdst.indxthrd == 0){ cam_list[mhdst.indxthrd]->stream.daemon = MHD_start_daemon (mhdst.mhd_flags - ,cam_list[mhdst.indxthrd]->conf.stream_port + ,cam_list[mhdst.indxthrd]->conf->stream_port ,NULL, NULL ,&webu_answer_strm, cam_list ,MHD_OPTION_ARRAY, mhdst.mhd_ops ,MHD_OPTION_END); } else { cam_list[mhdst.indxthrd]->stream.daemon = MHD_start_daemon (mhdst.mhd_flags - ,cam_list[mhdst.indxthrd]->conf.stream_port + ,cam_list[mhdst.indxthrd]->conf->stream_port ,NULL, NULL ,&webu_answer_strm, cam_list[mhdst.indxthrd] ,MHD_OPTION_ARRAY, mhdst.mhd_ops @@ -2015,18 +2018,18 @@ static void webu_init_ports(struct ctx_cam **cam_list){ */ int indx, indx2; - if (cam_list[0]->conf.webcontrol_port != 0){ + if (cam_list[0]->conf->webcontrol_port != 0){ indx = 0; while (cam_list[indx] != NULL){ - if ((cam_list[0]->conf.webcontrol_port == cam_list[indx]->conf.webcontrol_port) && (indx > 0)){ - cam_list[indx]->conf.webcontrol_port = 0; + if ((cam_list[0]->conf->webcontrol_port == cam_list[indx]->conf->webcontrol_port) && (indx > 0)){ + cam_list[indx]->conf->webcontrol_port = 0; } - if (cam_list[0]->conf.webcontrol_port == cam_list[indx]->conf.stream_port){ + if (cam_list[0]->conf->webcontrol_port == cam_list[indx]->conf->stream_port){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Duplicate port requested %d") - ,cam_list[indx]->conf.stream_port); - cam_list[indx]->conf.stream_port = 0; + ,cam_list[indx]->conf->stream_port); + cam_list[indx]->conf->stream_port = 0; } indx++; @@ -2036,16 +2039,16 @@ static void webu_init_ports(struct ctx_cam **cam_list){ /* Now check on the stream ports */ indx = 0; while (cam_list[indx] != NULL){ - if (cam_list[indx]->conf.stream_port != 0){ + if (cam_list[indx]->conf->stream_port != 0){ indx2 = indx + 1; while (cam_list[indx2] != NULL){ - if (cam_list[indx]->conf.stream_port == cam_list[indx2]->conf.stream_port){ + if (cam_list[indx]->conf->stream_port == cam_list[indx2]->conf->stream_port){ if (indx != 0){ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Duplicate port requested %d") - ,cam_list[indx2]->conf.stream_port); + ,cam_list[indx2]->conf->stream_port); } - cam_list[indx2]->conf.stream_port = 0; + cam_list[indx2]->conf->stream_port = 0; } indx2++; } diff --git a/src/webu_html.cpp b/src/webu_html.cpp index 6ba02e2a..e22129fc 100644 --- a/src/webu_html.cpp +++ b/src/webu_html.cpp @@ -34,6 +34,7 @@ */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "webu.hpp" @@ -253,7 +254,7 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) { if (webui->cam_threads == 1){ /* Only Motion.conf file */ - if (webui->camlst[0]->conf.camera_name == NULL){ + if (webui->camlst[0]->conf->camera_name == NULL){ snprintf(response, sizeof (response), "
\n" " \n" @@ -271,7 +272,7 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) { " %s\n" ,_("Cameras") ,webui->camlst[0]->camera_id - ,webui->camlst[0]->conf.camera_name); + ,webui->camlst[0]->conf->camera_name); webu_write(webui, response); } } else if (webui->cam_threads > 1){ @@ -286,7 +287,7 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) { webu_write(webui, response); for (indx=1;indx <= webui->cam_count;indx++){ - if (webui->camlst[indx]->conf.camera_name == NULL){ + if (webui->camlst[indx]->conf->camera_name == NULL){ snprintf(response, sizeof (response), " %s %d\n" ,webui->camlst[indx]->camera_id @@ -295,7 +296,7 @@ static void webu_html_navbar_camera(struct webui_ctx *webui) { snprintf(response, sizeof (response), " %s\n" ,webui->camlst[indx]->camera_id - ,webui->camlst[indx]->conf.camera_name + ,webui->camlst[indx]->conf->camera_name ); } webu_write(webui, response); @@ -371,15 +372,15 @@ static void webu_html_config_notice(struct webui_ctx *webui) { */ char response[WEBUI_LEN_RESP]; - if (webui->camlst[0]->conf.webcontrol_parms == 0){ + if (webui->camlst[0]->conf->webcontrol_parms == 0){ snprintf(response, sizeof (response), "

webcontrol_parms = 0 (%s)

\n" ,_("No Configuration Options")); - } else if (webui->camlst[0]->conf.webcontrol_parms == 1){ + } else if (webui->camlst[0]->conf->webcontrol_parms == 1){ snprintf(response, sizeof (response), "

webcontrol_parms = 1 (%s)

\n" ,_("Limited Configuration Options")); - } else if (webui->camlst[0]->conf.webcontrol_parms == 2){ + } else if (webui->camlst[0]->conf->webcontrol_parms == 2){ snprintf(response, sizeof (response), "

webcontrol_parms = 2 (%s)

\n" ,_("Advanced Configuration Options")); @@ -453,7 +454,7 @@ static void webu_html_config(struct webui_ctx *webui) { indx_parm = 0; while (config_parms[indx_parm].parm_name != NULL){ - if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf.webcontrol_parms) || + if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER)){ indx_parm++; continue; @@ -575,19 +576,19 @@ static void webu_html_strminfo(struct strminfo_ctx *strm_info, int indx) { * There are WAY too many options for this. */ /* If using the main port,we need to insert a thread number into url*/ - if (strm_info->camlst[0]->conf.stream_port != 0) { + if (strm_info->camlst[0]->conf->stream_port != 0) { snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"/%d" ,strm_info->camlst[indx]->camera_id); - strm_info->port = strm_info->camlst[0]->conf.stream_port; - if (strm_info->camlst[0]->conf.stream_tls) { + strm_info->port = strm_info->camlst[0]->conf->stream_port; + if (strm_info->camlst[0]->conf->stream_tls) { snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","https"); } else { snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http"); } } else { snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"%s",""); - strm_info->port = strm_info->camlst[indx]->conf.stream_port; - if (strm_info->camlst[indx]->conf.stream_tls) { + strm_info->port = strm_info->camlst[indx]->conf->stream_port; + if (strm_info->camlst[indx]->conf->stream_tls) { snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","https"); } else { snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http"); @@ -598,15 +599,15 @@ static void webu_html_strminfo(struct strminfo_ctx *strm_info, int indx) { snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/motion"); } else { /* Assign what images and links we want */ - if (strm_info->camlst[indx]->conf.stream_preview_method == 1){ + if (strm_info->camlst[indx]->conf->stream_preview_method == 1){ /* Substream for preview */ snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream"); snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/substream"); - } else if (strm_info->camlst[indx]->conf.stream_preview_method == 2){ + } else if (strm_info->camlst[indx]->conf->stream_preview_method == 2){ /* Static image for preview */ snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream"); snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/current"); - } else if (strm_info->camlst[indx]->conf.stream_preview_method == 4){ + } else if (strm_info->camlst[indx]->conf->stream_preview_method == 4){ /* Source image for preview */ snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/source"); snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/source"); @@ -640,15 +641,15 @@ static void webu_html_preview(struct webui_ctx *webui) { if (webui->cam_threads == 1) indx_st = 0; for (indx = indx_st; indxcam_threads; indx++){ - if (webui->camlst[indx]->conf.stream_preview_newline){ + if (webui->camlst[indx]->conf->stream_preview_newline){ snprintf(response, sizeof (response),"%s","
\n"); webu_write(webui, response); } - if (webui->camlst[indx]->conf.stream_preview_method == 3){ + if (webui->camlst[indx]->conf->stream_preview_method == 3){ preview_scale = 45; } else { - preview_scale = webui->camlst[indx]->conf.stream_preview_scale; + preview_scale = webui->camlst[indx]->conf->stream_preview_scale; } strm_info.motion_images = FALSE; @@ -663,7 +664,7 @@ static void webu_html_preview(struct webui_ctx *webui) { ,preview_scale); webu_write(webui, response); - if (webui->camlst[indx]->conf.stream_preview_method == 3){ + if (webui->camlst[indx]->conf->stream_preview_method == 3){ strm_info.motion_images = TRUE; webu_html_strminfo(&strm_info,indx); snprintf(response, sizeof (response), @@ -725,7 +726,7 @@ static void webu_html_script_action(struct webui_ctx *webui) { snprintf(response, sizeof (response), " var url = \"%s://%s:%d/\"; \n" ,webui->hostproto, webui->hostname - ,webui->camlst[0]->conf.webcontrol_port); + ,webui->camlst[0]->conf->webcontrol_port); webu_write(webui, response); snprintf(response, sizeof (response), @@ -770,7 +771,7 @@ static void webu_html_script_camera_thread(struct webui_ctx *webui) { ,webui->camlst[indx]->camera_id); webu_write(webui, response); - if (webui->camlst[indx]->conf.stream_preview_method == 3){ + if (webui->camlst[indx]->conf->stream_preview_method == 3){ preview_scale = 45; } else { preview_scale = 95; @@ -787,7 +788,7 @@ static void webu_html_script_camera_thread(struct webui_ctx *webui) { ,strm_info.lnk_camid, strm_info.lnk_src, preview_scale); webu_write(webui, response); - if (webui->camlst[indx]->conf.stream_preview_method == 3){ + if (webui->camlst[indx]->conf->stream_preview_method == 3){ strm_info.motion_images = TRUE; webu_html_strminfo(&strm_info, indx); snprintf(response, sizeof (response), @@ -800,7 +801,7 @@ static void webu_html_script_camera_thread(struct webui_ctx *webui) { webu_write(webui, response); } - if (webui->camlst[indx]->conf.camera_name == NULL){ + if (webui->camlst[indx]->conf->camera_name == NULL){ snprintf(response, sizeof (response), " header=\"

%s %d (%s)

\"\n" @@ -814,7 +815,7 @@ static void webu_html_script_camera_thread(struct webui_ctx *webui) { snprintf(response, sizeof (response), " header=\"

%s (%s)

\"\n" - , webui->camlst[indx]->conf.camera_name + , webui->camlst[indx]->conf->camera_name ,(!webui->camlst[indx]->running_cam)? _("Not running") : (webui->camlst[indx]->lost_connection)? _("Lost connection"): (webui->camlst[indx]->pause)? _("Paused"):_("Active") @@ -850,15 +851,15 @@ static void webu_html_script_camera_all(struct webui_ctx *webui) { webu_write(webui, response); } - if (webui->camlst[indx]->conf.stream_preview_newline){ + if (webui->camlst[indx]->conf->stream_preview_newline){ snprintf(response, sizeof (response),"%s"," preview = preview + \"
\";\n"); webu_write(webui, response); } - if (webui->camlst[indx]->conf.stream_preview_method == 3){ + if (webui->camlst[indx]->conf->stream_preview_method == 3){ preview_scale = 45; } else { - preview_scale = webui->camlst[indx]->conf.stream_preview_scale; + preview_scale = webui->camlst[indx]->conf->stream_preview_scale; } strm_info.motion_images = FALSE; @@ -873,7 +874,7 @@ static void webu_html_script_camera_all(struct webui_ctx *webui) { ,preview_scale); webu_write(webui, response); - if (webui->camlst[indx]->conf.stream_preview_method == 3){ + if (webui->camlst[indx]->conf->stream_preview_method == 3){ strm_info.motion_images = TRUE; webu_html_strminfo(&strm_info, indx); snprintf(response, sizeof (response), @@ -997,7 +998,7 @@ static void webu_html_script_cfgclk(struct webui_ctx *webui) { snprintf(response, sizeof (response), " var url = \"%s://%s:%d/\"; \n" ,webui->hostproto, webui->hostname - ,webui->camlst[0]->conf.webcontrol_port); + ,webui->camlst[0]->conf->webcontrol_port); webu_write(webui, response); snprintf(response, sizeof (response), @@ -1098,7 +1099,7 @@ static void webu_html_script_trkclk(struct webui_ctx *webui) { snprintf(response, sizeof (response), " var url = \"%s://%s:%d/\"; \n" ,webui->hostproto, webui->hostname - ,webui->camlst[0]->conf.webcontrol_port); + ,webui->camlst[0]->conf->webcontrol_port); webu_write(webui, response); snprintf(response, sizeof (response), diff --git a/src/webu_stream.cpp b/src/webu_stream.cpp index 6af3e15a..9978b3b3 100644 --- a/src/webu_stream.cpp +++ b/src/webu_stream.cpp @@ -14,6 +14,7 @@ */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "picture.hpp" @@ -96,10 +97,10 @@ static void webu_stream_mjpeg_getimg(struct webui_ctx *webui) { /* Copy jpg from the motion loop thread */ pthread_mutex_lock(&webui->cam->stream.mutex); - if ((!webui->cam->detecting_motion) && (webui->cam->conf.stream_motion)){ + if ((!webui->cam->detecting_motion) && (webui->cam->conf->stream_motion)){ webui->stream_fps = 1; } else { - webui->stream_fps = webui->cam->conf.stream_maxrate; + webui->stream_fps = webui->cam->conf->stream_maxrate; } if (local_stream->jpeg_data == NULL) { pthread_mutex_unlock(&webui->cam->stream.mutex); @@ -294,9 +295,9 @@ int webu_stream_mjpeg(struct webui_ctx *webui) { return MHD_NO; } - if (webui->cam->conf.stream_cors_header != NULL){ + if (webui->cam->conf->stream_cors_header != NULL){ MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN - , webui->cam->conf.stream_cors_header); + , webui->cam->conf->stream_cors_header); } MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE @@ -334,9 +335,9 @@ int webu_stream_static(struct webui_ctx *webui) { return MHD_NO; } - if (webui->cam->conf.stream_cors_header != NULL){ + if (webui->cam->conf->stream_cors_header != NULL){ MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN - , webui->cam->conf.stream_cors_header); + , webui->cam->conf->stream_cors_header); } MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "image/jpeg;"); @@ -431,7 +432,7 @@ static void webu_stream_getimg_norm(struct ctx_cam *cam, struct ctx_image_data * ,cam->stream.norm.jpeg_data ,cam->imgs.size_norm ,img_data->image_norm - ,cam->conf.stream_quality + ,cam->conf->stream_quality ,cam->imgs.width ,cam->imgs.height); } @@ -463,7 +464,7 @@ static void webu_stream_getimg_sub(struct ctx_cam *cam, struct ctx_image_data *i ,cam->stream.sub.jpeg_data ,subsize ,cam->imgs.image_substream - ,cam->conf.stream_quality + ,cam->conf->stream_quality ,(cam->imgs.width / 2) ,(cam->imgs.height / 2)); } else { @@ -472,7 +473,7 @@ static void webu_stream_getimg_sub(struct ctx_cam *cam, struct ctx_image_data *i ,cam->stream.sub.jpeg_data ,cam->imgs.size_norm ,img_data->image_norm - ,cam->conf.stream_quality + ,cam->conf->stream_quality ,cam->imgs.width ,cam->imgs.height); } @@ -491,7 +492,7 @@ static void webu_stream_getimg_motion(struct ctx_cam *cam){ ,cam->stream.motion.jpeg_data ,cam->imgs.size_norm ,cam->imgs.image_motion.image_norm - ,cam->conf.stream_quality + ,cam->conf->stream_quality ,cam->imgs.width ,cam->imgs.height); } @@ -509,7 +510,7 @@ static void webu_stream_getimg_source(struct ctx_cam *cam){ ,cam->stream.source.jpeg_data ,cam->imgs.size_norm ,cam->imgs.image_virgin - ,cam->conf.stream_quality + ,cam->conf->stream_quality ,cam->imgs.width ,cam->imgs.height); } diff --git a/src/webu_text.cpp b/src/webu_text.cpp index 728e9dcb..e0cd5c45 100644 --- a/src/webu_text.cpp +++ b/src/webu_text.cpp @@ -20,6 +20,7 @@ */ #include "motion.hpp" +#include "conf.hpp" #include "logger.hpp" #include "util.hpp" #include "webu.hpp" @@ -28,7 +29,7 @@ static void webu_text_seteol(struct webui_ctx *webui) { /* Set the end of line character for text interface */ - if (webui->camlst[0]->conf.webcontrol_interface == 2) { + if (webui->camlst[0]->conf->webcontrol_interface == 2) { snprintf(webui->text_eol, WEBUI_LEN_PARM,"%s","
"); } else { snprintf(webui->text_eol, WEBUI_LEN_PARM,"%s",""); @@ -39,7 +40,7 @@ static void webu_text_seteol(struct webui_ctx *webui) { static void webu_text_camera_name(struct webui_ctx *webui) { char response[WEBUI_LEN_RESP]; - if (webui->camlst[webui->thread_nbr]->conf.camera_name == NULL){ + if (webui->camlst[webui->thread_nbr]->conf->camera_name == NULL){ snprintf(response,sizeof(response), "Camera %s %s\n" ,webui->uri_camid,webui->text_eol @@ -47,7 +48,7 @@ static void webu_text_camera_name(struct webui_ctx *webui) { } else { snprintf(response,sizeof(response), "Camera %s %s\n" - ,webui->camlst[webui->thread_nbr]->conf.camera_name + ,webui->camlst[webui->thread_nbr]->conf->camera_name ,webui->text_eol ); } @@ -58,7 +59,7 @@ static void webu_text_camera_name(struct webui_ctx *webui) { static void webu_text_back(struct webui_ctx *webui, const char *prevuri) { char response[WEBUI_LEN_RESP]; - if (webui->camlst[0]->conf.webcontrol_interface == 2) { + if (webui->camlst[0]->conf->webcontrol_interface == 2) { snprintf(response,sizeof(response), "<- back

\n" ,webui->uri_camid, prevuri @@ -71,7 +72,7 @@ static void webu_text_back(struct webui_ctx *webui, const char *prevuri) { static void webu_text_header(struct webui_ctx *webui) { char response[WEBUI_LEN_RESP]; - if (webui->camlst[0]->conf.webcontrol_interface == 2) { + if (webui->camlst[0]->conf->webcontrol_interface == 2) { snprintf(response, sizeof (response),"%s", "\n" "\n" @@ -85,7 +86,7 @@ static void webu_text_header(struct webui_ctx *webui) { static void webu_text_trailer(struct webui_ctx *webui) { char response[WEBUI_LEN_RESP]; - if (webui->camlst[0]->conf.webcontrol_interface == 2) { + if (webui->camlst[0]->conf->webcontrol_interface == 2) { snprintf(response, sizeof (response),"%s", "\n" "\n"); @@ -148,7 +149,7 @@ static void webu_text_page_basic(struct webui_ctx *webui) { if (webui->cam_threads > 1){ for (indx = 1; indx < webui->cam_threads; indx++) { - if (webui->camlst[indx]->conf.camera_name == NULL){ + if (webui->camlst[indx]->conf->camera_name == NULL){ snprintf(response, sizeof (response), "Camera %d
\n" , webui->camlst[indx]->camera_id @@ -158,7 +159,7 @@ static void webu_text_page_basic(struct webui_ctx *webui) { snprintf(response, sizeof (response), "Camera %s
\n" , webui->camlst[indx]->camera_id - ,webui->camlst[indx]->conf.camera_name); + ,webui->camlst[indx]->conf->camera_name); webu_write(webui, response); } } @@ -176,7 +177,7 @@ static void webu_text_list_raw(struct webui_ctx *webui) { indx_parm = 0; while (config_parms[indx_parm].parm_name != NULL){ - if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf.webcontrol_parms) || + if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || ((webui->thread_nbr != 0) && (config_parms[indx_parm].main_thread != 0))){ indx_parm++; @@ -223,7 +224,7 @@ static void webu_text_list_basic(struct webui_ctx *webui) { indx_parm = 0; while (config_parms[indx_parm].parm_name != NULL){ - if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf.webcontrol_parms) || + if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || ((webui->thread_nbr != 0) && (config_parms[indx_parm].main_thread != 0))){ indx_parm++; @@ -281,7 +282,7 @@ static void webu_text_set_menu(struct webui_ctx *webui) { indx_parm = 0; while (config_parms[indx_parm].parm_name != NULL){ - if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf.webcontrol_parms) || + if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || ((webui->thread_nbr != 0) && (config_parms[indx_parm].main_thread != 0))){ indx_parm++; @@ -335,7 +336,7 @@ static void webu_text_set_query(struct webui_ctx *webui) { indx_parm = 0; while (config_parms[indx_parm].parm_name != NULL){ - if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf.webcontrol_parms) || + if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || ((webui->thread_nbr != 0) && (config_parms[indx_parm].main_thread != 0)) || (mystrne(webui->uri_parm1, config_parms[indx_parm].parm_name))) { @@ -416,7 +417,7 @@ static void webu_text_get_menu(struct webui_ctx *webui) { indx_parm = 0; while (config_parms[indx_parm].parm_name != NULL){ - if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf.webcontrol_parms) || + if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || ((webui->thread_nbr != 0) && (config_parms[indx_parm].main_thread != 0))){ indx_parm++; @@ -895,7 +896,7 @@ void webu_text_get_query(struct webui_ctx *webui) { indx_parm = 0; while (config_parms[indx_parm].parm_name != NULL){ - if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf.webcontrol_parms) || + if ((config_parms[indx_parm].webui_level > webui->camlst[0]->conf->webcontrol_parms) || (config_parms[indx_parm].webui_level == WEBUI_LEVEL_NEVER) || mystrne(webui->uri_parm1,"query") || mystrne(temp_name, config_parms[indx_parm].parm_name)){ @@ -921,7 +922,7 @@ void webu_text_get_query(struct webui_ctx *webui) { webu_text_camera_name(webui); - if (webui->camlst[0]->conf.webcontrol_interface == 2) { + if (webui->camlst[0]->conf->webcontrol_interface == 2) { snprintf(response, sizeof (response), "
    \n" "
  • %s = %s
  • \n" @@ -1006,8 +1007,8 @@ void webu_text_connection(struct webui_ctx *webui) { snprintf(response,sizeof(response) , "Camera %d%s%s %s %s\n" ,webui->camlst[indx]->camera_id - ,webui->camlst[indx]->conf.camera_name ? " -- " : "" - ,webui->camlst[indx]->conf.camera_name ? webui->camlst[indx]->conf.camera_name : "" + ,webui->camlst[indx]->conf->camera_name ? " -- " : "" + ,webui->camlst[indx]->conf->camera_name ? webui->camlst[indx]->conf->camera_name : "" ,(!webui->camlst[indx]->running_cam)? "NOT RUNNING" : (webui->camlst[indx]->lost_connection)? "Lost connection": "Connection OK" ,webui->text_eol @@ -1018,8 +1019,8 @@ void webu_text_connection(struct webui_ctx *webui) { snprintf(response,sizeof(response) , "Camera %d%s%s %s %s\n" ,webui->cam->camera_id - ,webui->cam->conf.camera_name ? " -- " : "" - ,webui->cam->conf.camera_name ? webui->cam->conf.camera_name : "" + ,webui->cam->conf->camera_name ? " -- " : "" + ,webui->cam->conf->camera_name ? webui->cam->conf->camera_name : "" ,(!webui->cam->running_cam)? "NOT RUNNING" : (webui->cam->lost_connection)? "Lost connection": "Connection OK" ,webui->text_eol @@ -1031,7 +1032,7 @@ void webu_text_connection(struct webui_ctx *webui) { void webu_text_list(struct webui_ctx *webui) { - if (webui->camlst[0]->conf.webcontrol_interface == 2) { + if (webui->camlst[0]->conf->webcontrol_interface == 2) { webu_text_list_basic(webui); } else { webu_text_list_raw(webui); @@ -1046,7 +1047,7 @@ void webu_text_main(struct webui_ctx *webui) { webu_text_seteol(webui); if (strlen(webui->uri_camid) == 0){ - if (webui->camlst[0]->conf.webcontrol_interface == 2) { + if (webui->camlst[0]->conf->webcontrol_interface == 2) { webu_text_page_basic(webui); } else { webu_text_page_raw(webui);