diff --git a/src/conf.cpp b/src/conf.cpp index fd6d34ca..e8d0a753 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -85,6 +85,10 @@ struct ctx_parm config_parms[] = { "# Numeric identifier for the camera.", 0, PARM_TYP_INT,PARM_CAT_01,WEBUI_LEVEL_ADVANCED}, { + "camera_tmo", + "# Timeout for camera lost connection.", + 0, PARM_TYP_INT,PARM_CAT_01,WEBUI_LEVEL_LIMITED}, + { "target_dir", "# Target directory for pictures, snapshots and movies", 0,PARM_TYP_STRING,PARM_CAT_01, WEBUI_LEVEL_LIMITED }, @@ -1039,6 +1043,25 @@ static void conf_edit_camera_id(struct ctx_cam *cam, std::string &parm, enum PAR MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_id",_("camera_id")); } +static void conf_edit_camera_tmo(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) +{ + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf->camera_tmo = 30; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(parm.c_str()); + if (parm_in < 1) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid camera_tmo %d"),parm_in); + } else { + cam->conf->camera_tmo = parm_in; + } + } else if (pact == PARM_ACT_GET){ + parm = std::to_string(cam->conf->camera_id); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","camera_tmo",_("camera_tmo")); +} + static void conf_edit_camera_dir(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { if (pact == PARM_ACT_DFLT) { @@ -3151,6 +3174,7 @@ static void conf_edit_cat01(struct ctx_cam *cam, std::string parm_nm, std::strin } else if (parm_nm == "camera_dir"){ conf_edit_camera_dir(cam, parm_val, pact); } else if (parm_nm == "camera_name"){ conf_edit_camera_name(cam, parm_val, pact); } else if (parm_nm == "camera_id"){ conf_edit_camera_id(cam, parm_val, pact); + } else if (parm_nm == "camera_tmo"){ conf_edit_camera_tmo(cam, parm_val, pact); } else if (parm_nm == "target_dir"){ conf_edit_target_dir(cam, parm_val, pact); } else if (parm_nm == "watchdog_tmo"){ conf_edit_watchdog_tmo(cam, parm_val, pact); } else if (parm_nm == "watchdog_kill"){ conf_edit_watchdog_kill(cam, parm_val, pact); diff --git a/src/conf.hpp b/src/conf.hpp index 68613feb..03c5eb42 100644 --- a/src/conf.hpp +++ b/src/conf.hpp @@ -33,6 +33,7 @@ std::string target_dir; int watchdog_tmo; int watchdog_kill; + int camera_tmo; /* Capture device configuration parameters */ std::string v4l2_device; diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index 3c2ca9fc..308c329e 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -943,7 +943,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 >= (cam->conf->camera_tmo * cam->conf->framerate)) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Video signal re-acquired")); event(cam, EVENT_CAMERA_FOUND, NULL, NULL, NULL, NULL); } @@ -974,7 +974,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 < (cam->conf->camera_tmo * cam->conf->framerate)) { memcpy(cam->current_image->image_norm, cam->imgs.image_vprvcy, cam->imgs.size_norm); } else { cam->lost_connection = 1; @@ -992,14 +992,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 == (cam->conf->camera_tmo * 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 == ((cam->conf->camera_tmo * 4) * cam->conf->framerate))) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO ,_("Video signal still lost - Trying to close video device")); mlp_cam_close(cam); diff --git a/src/motionplus.hpp b/src/motionplus.hpp index ff7724e5..66eb70fa 100644 --- a/src/motionplus.hpp +++ b/src/motionplus.hpp @@ -86,7 +86,6 @@ struct ctx_v4l2cam; #define MYFFVER (LIBAVFORMAT_VERSION_MAJOR * 1000)+LIBAVFORMAT_VERSION_MINOR #define THRESHOLD_TUNE_LENGTH 256 -#define MISSING_FRAMES_TIMEOUT 30 /* Frame count before grey lost image is used */ /* Filetype defines */ #define FTYPE_IMAGE 1