From 85bc2932ffecea89da6283b6a78e7f1b9372b796 Mon Sep 17 00:00:00 2001 From: MrDave Date: Wed, 25 Nov 2020 19:38:33 -0700 Subject: [PATCH] Revise the parse parameters --- src/motion_loop.hpp | 2 - src/motionplus.hpp | 17 ++- src/util.cpp | 311 ++++++++++++++++++++++++++++++++++++++++++- src/util.hpp | 2 + src/video_common.cpp | 156 ---------------------- src/video_common.hpp | 2 - src/video_v4l2.cpp | 58 ++++---- src/webu.cpp | 2 +- 8 files changed, 350 insertions(+), 200 deletions(-) diff --git a/src/motion_loop.hpp b/src/motion_loop.hpp index fb0dd176..24b234a5 100644 --- a/src/motion_loop.hpp +++ b/src/motion_loop.hpp @@ -22,8 +22,6 @@ #ifndef _INCLUDE_MOTION_LOOP_H_ #define _INCLUDE_MOTION_LOOP_H_ -struct ctx_cam; - void *motion_loop(void *arg); void mlp_cleanup(struct ctx_cam *cam); diff --git a/src/motionplus.hpp b/src/motionplus.hpp index 87263a3e..24c4ca40 100644 --- a/src/motionplus.hpp +++ b/src/motionplus.hpp @@ -161,16 +161,15 @@ enum MOTION_SIGNAL { MOTION_SIGNAL_SIGTERM }; -struct ctx_usrctrl { - char *ctrl_src; /* The full parameter provided from user*/ - char *ctrl_name; /* The name or description of the ID as requested by user*/ - char *ctrl_value; /* The value that the user wants the control set to*/ +struct ctx_params_item { + char *param_name; /* The name or description of the ID as requested by user*/ + char *param_value; /* The value that the user wants the control set to*/ }; -struct ctx_vdev { - struct ctx_usrctrl *usrctrl_array; /*Array of the controls the user specified*/ - int usrctrl_count; /*Count of the controls the user specified*/ - int update_parms; /*Bool for whether to update the parameters on the device*/ +struct ctx_params { + struct ctx_params_item *params_array; /*Array of the controls the user specified*/ + int params_count; /*Count of the controls the user specified*/ + int update_params; /*Bool for whether to update the parameters on the device*/ }; struct ctx_coord { @@ -288,7 +287,7 @@ struct ctx_cam { 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_params *vdev; struct ctx_image_data *current_image; /* Pointer to a structure where the image, diffs etc is stored */ struct ctx_algsec *algsec; struct ctx_rotate *rotate_data; /* rotation data is thread-specific */ diff --git a/src/util.cpp b/src/util.cpp index 0375151f..cf10e603 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -51,10 +51,15 @@ int mystrne(const char* var1, const char* var2){ void myltrim(std::string &parm) { - while (parm.substr(0,1) == " ") + if (parm.length() == 0 ) { + return; + } + + while (parm.substr(0, 1) == " ") { if (parm.length() == 1) { parm=""; + return; } else { parm = parm.substr(1); } @@ -63,10 +68,15 @@ void myltrim(std::string &parm) void myrtrim(std::string &parm) { + if (parm.length() == 0 ) { + return; + } + while (parm.substr(parm.length()-1,1) == " ") { if (parm.length() == 1) { parm=""; + return; } else { parm = parm.substr(0,parm.length()-1); } @@ -809,3 +819,302 @@ int mycopy_packet(AVPacket *dest_pkt, AVPacket *src_pkt){ #endif } /*********************************************/ + +static void util_parms_free(struct ctx_params *params) +{ + int indx_parm; + + for (indx_parm=0; indx_parmparams_count; indx_parm++) + { + if (params->params_array[indx_parm].param_name != NULL) { + free(params->params_array[indx_parm].param_name); + params->params_array[indx_parm].param_name = NULL; + } + if (params->params_array[indx_parm].param_value != NULL) { + free(params->params_array[indx_parm].param_value); + params->params_array[indx_parm].param_value = NULL; + } + } + + if (params->params_array != NULL) { + free(params->params_array); + params->params_array = NULL; + } + + params->params_count = 0; + +} + +static void util_parms_add(struct ctx_params *params, const char *parm_nm, const char *parm_val) +{ + params->params_count++; + + if (params->params_count == 1) { + params->params_array =(struct ctx_params_item *) mymalloc(sizeof(struct ctx_params_item)); + } else { + params->params_array =(struct ctx_params_item *)realloc(params->params_array + , sizeof(struct ctx_params_item)*params->params_count); + } + + if (parm_nm != NULL) { + params->params_array[params->params_count-1].param_name =(char*)mymalloc(strlen(parm_nm)+1); + sprintf(params->params_array[params->params_count-1].param_name,"%s",parm_nm); + } else { + params->params_array[params->params_count-1].param_name = NULL; + } + + if (parm_val != NULL) { + params->params_array[params->params_count-1].param_value =(char*)mymalloc(strlen(parm_val)+1); + sprintf(params->params_array[params->params_count-1].param_value,"%s",parm_val); + } else { + params->params_array[params->params_count-1].param_value = NULL; + } + + MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO,_("Parsed: >%s< >%s<") + ,params->params_array[params->params_count-1].param_name + ,params->params_array[params->params_count-1].param_value); + +} + +static void util_parms_strip_qte(std::string &parm) +{ + + if (parm.length() == 0) { + return; + } + + if (parm.substr(0, 1)=="\"") { + if (parm.length() == 1) { + parm = ""; + return; + } else { + parm = parm.substr(1); + } + } + + if (parm.substr(parm.length() -1, 1)== "\"") { + if (parm.length() == 1) { + parm = ""; + return; + } else { + parm = parm.substr(0, parm.length() - 1); + } + } + +} + +static void util_parms_extract(struct ctx_params *params, std::string &parmline + ,size_t indxnm_st,size_t indxnm_en,size_t indxvl_st,size_t indxvl_en) +{ + std::string parm_nm, parm_vl; + + if ((indxnm_st != std::string::npos) && + (indxnm_en != std::string::npos) && + (indxvl_st != std::string::npos) && + (indxvl_en != std::string::npos)) { + + parm_nm = parmline.substr(indxnm_st, indxnm_en - indxnm_st + 1); + parm_vl = parmline.substr(indxvl_st, indxvl_en - indxvl_st + 1); + + mytrim(parm_nm); + mytrim(parm_vl); + + util_parms_strip_qte(parm_nm); + util_parms_strip_qte(parm_vl); + + util_parms_add(params, parm_nm.c_str(), parm_vl.c_str()); + + } + +} + +static void util_parms_next(std::string &parmline, size_t indxnm_st, size_t indxvl_en) +{ + /* Cut out the parameter that was just extracted from the parmline string */ + /* indxvl_en is right before the comma so to move past it, we need to +2*/ + if (indxnm_st == 0) { + if ((indxvl_en + 2) > parmline.length() ) { + parmline = ""; + } else { + parmline = parmline.substr(indxvl_en + 2); + } + } else { + if ((indxvl_en + 2) > parmline.length() ) { + parmline = parmline.substr(0, indxnm_st - 1); + } else { + parmline = parmline.substr(0, indxnm_st - 1) + parmline.substr(indxvl_en + 2); + } + } + mytrim(parmline); + +} + +void util_parms_parse_qte(struct ctx_params *params, std::string &parmline) +{ + size_t indxnm_st, indxnm_en; + size_t indxvl_st, indxvl_en; + size_t indxcm, indxeq; + + /* Parse out all the items within quotes first */ + while (parmline.find("\"", 0) != std::string::npos) { + + indxnm_st = parmline.find("\"", 0); + + indxnm_en = parmline.find("\"", indxnm_st + 1); + if (indxnm_en == std::string::npos) { + indxnm_en = parmline.length() - 1; + } + + indxcm = parmline.find(",", indxnm_en + 1); + if (indxcm == std::string::npos) { + indxcm = parmline.length() - 1; + } + + indxeq = parmline.find("=", indxnm_en + 1); + if (indxeq == std::string::npos) { + indxeq = parmline.length() - 1; + } + + if (indxcm <= indxeq) { + /* The quoted part of the parm was the value not the name */ + indxvl_st = indxnm_st; + indxvl_en = indxnm_en; + + indxnm_st = parmline.find_last_of(",", indxvl_st); + if (indxnm_st == std::string::npos) { + indxnm_st = 0; + } + indxnm_st++; /* Move past the comma */ + + indxnm_en = parmline.find("=", indxnm_st); + if ((indxnm_en == std::string::npos) || + (indxnm_en > indxvl_st)) { + indxnm_en = indxvl_st + 1; + } + indxnm_en--; /* do not include the = */ + + } else { + /* The quoted part of the parm was the name */ + indxvl_st = parmline.find("\"",indxeq + 1); + indxcm = parmline.find(",", indxeq + 1); + if (indxcm == std::string::npos) { + if (indxnm_st == std::string::npos) { + indxvl_st = indxeq + 1; + if (indxvl_st >= parmline.length()){ + indxvl_st = parmline.length() - 1; + } + indxvl_en = parmline.length() - 1; + } else { + /* The value is also enclosed in quotes */ + indxvl_en=parmline.find("\"", indxvl_st + 1); + if (indxvl_en == std::string::npos) { + indxvl_en = parmline.length() - 1; + } + } + } else if (indxvl_st == std::string::npos) { + indxvl_st = indxeq + 1; + indxvl_en = parmline.find(",",indxvl_st) - 1; + } else { + /* The value is also enclosed in quotes */ + indxvl_en=parmline.find("\"", indxvl_st + 1); + if (indxvl_en == std::string::npos) { + indxvl_en = parmline.length() - 1; + } + } + } + + MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO,_("Parsing: >%s< >%ld %ld %ld %ld<") + ,parmline.c_str(), indxnm_st, indxnm_en, indxvl_st, indxvl_en); + + util_parms_extract(params, parmline, indxnm_st, indxnm_en, indxvl_st, indxvl_en); + util_parms_next(parmline, indxnm_st, indxvl_en); + + } +} + +void util_parms_parse_comma(struct ctx_params *params, std::string &parmline) +{ + size_t indxnm_st, indxnm_en; + size_t indxvl_st, indxvl_en; + + while (parmline.find(",", 0) != std::string::npos) { + indxnm_st = 0; + indxnm_en = parmline.find("=", 1); + if (indxnm_en == std::string::npos) { + indxnm_en = 0; + indxvl_st = 0; + } else { + indxvl_st = indxnm_en + 1; /* Position past = */ + indxnm_en--; /* Position before = */ + } + + if (parmline.find(",", indxvl_st) == std::string::npos) { + indxvl_en = parmline.length() - 1; + } else { + indxvl_en = parmline.find(",",indxvl_st) - 1; + } + + MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO,_("Parsing: >%s< >%ld %ld %ld %ld<") + ,parmline.c_str(), indxnm_st, indxnm_en, indxvl_st, indxvl_en); + + util_parms_extract(params, parmline, indxnm_st, indxnm_en, indxvl_st, indxvl_en); + util_parms_next(parmline, indxnm_st, indxvl_en); + } + + /* Take care of last parameter */ + if (parmline != "") { + indxnm_st = 0; + indxnm_en = parmline.find("=", 1); + if (indxnm_en == std::string::npos) { + /* If no value then we are done */ + return; + } else { + indxvl_st = indxnm_en + 1; /* Position past = */ + indxnm_en--; /* Position before = */ + } + indxvl_en = parmline.length() - 1; + + MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO,_("Parsing: >%s< >%ld %ld %ld %ld<") + ,parmline.c_str(), indxnm_st, indxnm_en, indxvl_st, indxvl_en); + + util_parms_extract(params, parmline, indxnm_st, indxnm_en, indxvl_st, indxvl_en); + util_parms_next(parmline, indxnm_st, indxvl_en); + } + +} + +int util_parms_parse(struct ctx_params *params, std::string confline) +{ + /* Parse through the configuration option to get values + * The values are separated by commas but may also have + * double quotes around the names which include a comma. + * Examples: + * v4l2_params ID01234= 1, ID23456=2 + * vid_control_parms "Brightness, auto" = 1, ID23456=2 + * vid_control_parms ID23456=2, "Brightness, auto" = 1,ID2222=5 + */ + + std::string parmline; + + if ((params->update_params == FALSE) || + (confline == "")) { + return 0; + } + /* We make a copy because the parsing destroys the value passed */ + parmline = confline; + + MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO,_("Starting parsing parameters: %s"), parmline.c_str()); + + util_parms_free(params); + + util_parms_parse_qte(params, parmline); + + util_parms_parse_comma(params, parmline); + + MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO,_("Finished parsing parameters: %s"), confline.c_str()); + + params->update_params = FALSE; + + return 0; + +} diff --git a/src/util.hpp b/src/util.hpp index 7a9b37ba..8c2cf6a9 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -115,4 +115,6 @@ int myimage_fill_arrays(AVFrame *frame,uint8_t *buffer_ptr,enum MyPixelFormat pix_fmt,int width,int height); int mycopy_packet(AVPacket *dest_pkt, AVPacket *src_pkt); + int util_parms_parse(struct ctx_params *params, std::string confline); + #endif diff --git a/src/video_common.cpp b/src/video_common.cpp index c94e6d27..e0c4c9d6 100644 --- a/src/video_common.cpp +++ b/src/video_common.cpp @@ -495,162 +495,6 @@ void vid_greytoyuv420p(unsigned char *map, unsigned char *cap_map, int width, in } -static void vid_parms_free(struct ctx_cam *cam) -{ - int indx_parm; - - for (indx_parm=0; indx_parmvdev->usrctrl_count; indx_parm++) - { - free(cam->vdev->usrctrl_array[indx_parm].ctrl_name); - cam->vdev->usrctrl_array[indx_parm].ctrl_name = NULL; - } - - if (cam->vdev->usrctrl_array != NULL) { - free(cam->vdev->usrctrl_array); - cam->vdev->usrctrl_array = NULL; - } - - cam->vdev->usrctrl_count = 0; - -} - -static void vid_parms_add(struct ctx_cam *cam, const char *parm_nm, const char *parm_val) -{ - cam->vdev->usrctrl_count++; - - if (cam->vdev->usrctrl_count == 1) { - cam->vdev->usrctrl_array =(struct ctx_usrctrl *) mymalloc(sizeof(struct ctx_usrctrl)); - } else { - cam->vdev->usrctrl_array =(struct ctx_usrctrl *)realloc(cam->vdev->usrctrl_array - , sizeof(struct ctx_usrctrl)*cam->vdev->usrctrl_count); - } - - if (parm_nm != NULL) { - cam->vdev->usrctrl_array[cam->vdev->usrctrl_count-1].ctrl_name =(char*)mymalloc(strlen(parm_nm)+1); - sprintf(cam->vdev->usrctrl_array[cam->vdev->usrctrl_count-1].ctrl_name,"%s",parm_nm); - } else { - cam->vdev->usrctrl_array[cam->vdev->usrctrl_count-1].ctrl_name = NULL; - } - - if (parm_val != NULL) { - cam->vdev->usrctrl_array[cam->vdev->usrctrl_count-1].ctrl_value =(char*)mymalloc(strlen(parm_val)+1); - sprintf(cam->vdev->usrctrl_array[cam->vdev->usrctrl_count-1].ctrl_value,"%s",parm_val); - } else { - cam->vdev->usrctrl_array[cam->vdev->usrctrl_count-1].ctrl_value = NULL; - } - - MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO,_("Parsed: >%s< >%s<") - ,cam->vdev->usrctrl_array[cam->vdev->usrctrl_count-1].ctrl_name - ,cam->vdev->usrctrl_array[cam->vdev->usrctrl_count-1].ctrl_value); - -} - -static void vid_parms_set(struct ctx_cam *cam, std::string &parms - ,size_t indxnm_st,size_t indxnm_en,size_t indxvl_st,size_t indxvl_en) -{ - std::string parm_nm, parm_vl; - - if ((indxnm_st != std::string::npos) && - (indxnm_en != std::string::npos) && - (indxvl_st != std::string::npos) && - (indxvl_en != std::string::npos)) - { - parm_nm = parms.substr(indxnm_st, indxnm_en - indxnm_st); - parm_vl = parms.substr(indxvl_st, indxvl_en - indxvl_st); - - mytrim(parm_nm); - mytrim(parm_vl); - - vid_parms_add(cam, parm_nm.c_str(), parm_vl.c_str()); - - } - - if (indxnm_st == 0) { - if ((indxvl_en + 1) > parms.length() ) { - parms = ""; - } else { - parms = parms.substr(indxvl_en + 1); - } - } else { - if ((indxvl_en + 1) > parms.length() ) { - parms = parms.substr(0, indxnm_st - 1); - } else { - parms = parms.substr(0, indxnm_st - 1) + parms.substr(indxvl_en + 1); - } - } -} - -int vid_parms_parse(struct ctx_cam *cam) -{ - /* Parse through the configuration option to get values - * The values are separated by commas but may also have - * double quotes around the names which include a comma. - * Examples: - * vid_control_parms ID01234= 1, ID23456=2 - * vid_control_parms "Brightness, auto" = 1, ID23456=2 - * vid_control_parms ID23456=2, "Brightness, auto" = 1,ID2222=5 - */ - - size_t indxnm_st, indxnm_en; - size_t indxvl_st, indxvl_en; - std::string parms; - - if (!cam->vdev->update_parms) return 0; - - vid_parms_free(cam); - - if (cam->conf->v4l2_parms != ""){ - MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO,_("Parsing controls: %s"),cam->conf->v4l2_parms.c_str()); - - parms = cam->conf->v4l2_parms; - - /* Parse out all the items within quotes first */ - while (parms.find("\"",0) != std::string::npos) - { - indxnm_st = parms.find("\"",0) + 1; - indxnm_en = parms.find("\"", indxnm_st); - indxvl_st = parms.find("=",indxnm_en + 1) + 1; - if (parms.find(",",indxvl_st) == std::string::npos) { - indxvl_en = parms.length(); - } else { - indxvl_en = parms.find(",",indxvl_st); - } - - vid_parms_set(cam,parms,indxnm_st,indxnm_en,indxvl_st,indxvl_en); - } - - /* Now parse out anything remaining based upon commas */ - while (parms.find(",",0) != std::string::npos) - { - indxnm_st = 0; - indxnm_en = parms.find("=",1); - indxvl_st = indxnm_en + 1; - if (parms.find(",",indxvl_st) == std::string::npos) { - indxvl_en = parms.length(); - } else { - indxvl_en = parms.find(",",indxvl_st); - } - - vid_parms_set(cam,parms,indxnm_st,indxnm_en,indxvl_st,indxvl_en); - } - - if (parms != "") { - - indxnm_st = 0; - indxnm_en = parms.find("=",1); - indxvl_st = indxnm_en + 1; - indxvl_en = parms.length(); - - vid_parms_set(cam,parms,indxnm_st,indxnm_en,indxvl_st,indxvl_en); - } - } - - cam->vdev->update_parms = FALSE; - - return 0; - -} - void vid_mutex_init(void) { v4l2_mutex_init(); diff --git a/src/video_common.hpp b/src/video_common.hpp index 7a9db360..8f413769 100644 --- a/src/video_common.hpp +++ b/src/video_common.hpp @@ -74,8 +74,6 @@ void vid_close(struct ctx_cam *cam); void vid_mutex_destroy(void); void vid_mutex_init(void); -int vid_parms_parse(struct ctx_cam *cam); - void vid_yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height); void vid_yuv422pto420p(unsigned char *map, unsigned char *cap_map, int width, int height); void vid_uyvyto420p(unsigned char *map, unsigned char *cap_map, int width, int height); diff --git a/src/video_v4l2.cpp b/src/video_v4l2.cpp index 231ed63e..9e7a70b9 100644 --- a/src/video_v4l2.cpp +++ b/src/video_v4l2.cpp @@ -140,16 +140,16 @@ static void v4l2_vdev_free(struct ctx_cam *cam) /* free the information we collected regarding the controls */ if (cam->vdev != NULL){ - if (cam->vdev->usrctrl_count > 0){ - for (indx=0;indxvdev->usrctrl_count;indx++){ - free(cam->vdev->usrctrl_array[indx].ctrl_name); - cam->vdev->usrctrl_array[indx].ctrl_name=NULL; + if (cam->vdev->params_count > 0){ + for (indx=0;indxvdev->params_count;indx++){ + free(cam->vdev->params_array[indx].param_name); + cam->vdev->params_array[indx].param_name=NULL; } } - cam->vdev->usrctrl_count = 0; - if (cam->vdev->usrctrl_array != NULL){ - free(cam->vdev->usrctrl_array); - cam->vdev->usrctrl_array = NULL; + cam->vdev->params_count = 0; + if (cam->vdev->params_array != NULL){ + free(cam->vdev->params_array); + cam->vdev->params_array = NULL; } free(cam->vdev); @@ -161,11 +161,11 @@ static int v4l2_vdev_init(struct ctx_cam *cam) { /* Create the v4l2 ctx_cam within the main thread ctx_cam */ - cam->vdev =(struct ctx_vdev*) mymalloc(sizeof(struct ctx_vdev)); - memset(cam->vdev, 0, sizeof(struct ctx_vdev)); - cam->vdev->usrctrl_array = NULL; - cam->vdev->usrctrl_count = 0; - cam->vdev->update_parms = TRUE; /*Set trigger that we have updated user parameters */ + cam->vdev =(struct ctx_params*) mymalloc(sizeof(struct ctx_params)); + memset(cam->vdev, 0, sizeof(struct ctx_params)); + cam->vdev->params_array = NULL; + cam->vdev->params_count = 0; + cam->vdev->update_params = TRUE; /*Set trigger that we have updated user parameters */ return 0; @@ -342,41 +342,41 @@ static int v4l2_parms_set(struct ctx_cam *cam, struct video_dev *curdev) { struct vid_devctrl_ctx *devitem; - struct ctx_usrctrl *usritem; + struct ctx_params_item *usritem; int indx_dev, indx_user; if (cam->conf->roundrobin_skip < 0) cam->conf->roundrobin_skip = 1; if (curdev->devctrl_count == 0){ - cam->vdev->update_parms = FALSE; + cam->vdev->update_params = FALSE; return 0; } for (indx_dev=0; indx_devdevctrl_count; indx_dev++ ) { devitem=&curdev->devctrl_array[indx_dev]; devitem->ctrl_newval = devitem->ctrl_default; - for (indx_user=0; indx_uservdev->usrctrl_count; indx_user++){ - usritem=&cam->vdev->usrctrl_array[indx_user]; - if ((mystrceq(devitem->ctrl_iddesc,usritem->ctrl_name)) || - (mystrceq(devitem->ctrl_name ,usritem->ctrl_name))) { + for (indx_user=0; indx_uservdev->params_count; indx_user++){ + usritem=&cam->vdev->params_array[indx_user]; + if ((mystrceq(devitem->ctrl_iddesc,usritem->param_name)) || + (mystrceq(devitem->ctrl_name ,usritem->param_name))) { switch (devitem->ctrl_type) { case V4L2_CTRL_TYPE_MENU: /*FALLTHROUGH*/ case V4L2_CTRL_TYPE_INTEGER: - if (atoi(usritem->ctrl_value) < devitem->ctrl_minimum){ + if (atoi(usritem->param_value) < devitem->ctrl_minimum){ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO ,_("%s control option value %s is below minimum. Skipping...") - ,devitem->ctrl_name, usritem->ctrl_value, devitem->ctrl_minimum); - } else if (atoi(usritem->ctrl_value) > devitem->ctrl_maximum){ + ,devitem->ctrl_name, usritem->param_value, devitem->ctrl_minimum); + } else if (atoi(usritem->param_value) > devitem->ctrl_maximum){ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO ,_("%s control option value %s is above maximum. Skipping...") - ,devitem->ctrl_name, usritem->ctrl_value, devitem->ctrl_maximum); + ,devitem->ctrl_name, usritem->param_value, devitem->ctrl_maximum); } else { - devitem->ctrl_newval = atoi(usritem->ctrl_value); + devitem->ctrl_newval = atoi(usritem->param_value); } break; case V4L2_CTRL_TYPE_BOOLEAN: - devitem->ctrl_newval = usritem->ctrl_value ? 1 : 0; + devitem->ctrl_newval = usritem->param_value ? 1 : 0; break; default: MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO @@ -1055,7 +1055,7 @@ static void v4l2_device_select(struct ctx_cam *cam, struct video_dev *curdev, un retcd = v4l2_input_select(cam, curdev); if (retcd == 0) retcd = v4l2_norm_select(cam, curdev); if (retcd == 0) retcd = v4l2_frequency_select(cam, curdev); - if (retcd == 0) retcd = vid_parms_parse(cam); + if (retcd == 0) retcd = util_parms_parse(cam->vdev, cam->conf->v4l2_parms); if (retcd == 0) retcd = v4l2_parms_set(cam, curdev); if (retcd == 0) retcd = v4l2_ctrls_set(curdev); if (retcd < 0 ){ @@ -1075,7 +1075,7 @@ static void v4l2_device_select(struct ctx_cam *cam, struct video_dev *curdev, un } else { /* No round robin - we only adjust picture controls */ - retcd = vid_parms_parse(cam); + retcd = util_parms_parse(cam->vdev, cam->conf->v4l2_parms); if (retcd == 0) retcd = v4l2_parms_set(cam, curdev); if (retcd == 0) retcd = v4l2_ctrls_set(curdev); if (retcd < 0 ) { @@ -1283,7 +1283,7 @@ int v4l2_start(struct ctx_cam *cam) while (curdev) { if (mystreq(cam->conf->v4l2_device.c_str(), curdev->v4l2_device)) { retcd = v4l2_vdev_init(cam); - if (retcd == 0) retcd = vid_parms_parse(cam); + if (retcd == 0) retcd = util_parms_parse(cam->vdev, cam->conf->v4l2_parms); if (retcd == 0) retcd = v4l2_imgs_set(cam, curdev); if (retcd == 0) { curdev->usage_count++; @@ -1310,7 +1310,7 @@ int v4l2_start(struct ctx_cam *cam) if (retcd == 0) retcd = v4l2_fps_set(cam, curdev); if (retcd == 0) retcd = v4l2_ctrls_count(curdev); if (retcd == 0) retcd = v4l2_ctrls_list(curdev); - if (retcd == 0) retcd = vid_parms_parse(cam); + if (retcd == 0) retcd = util_parms_parse(cam->vdev, cam->conf->v4l2_parms); if (retcd == 0) retcd = v4l2_parms_set(cam, curdev); if (retcd == 0) retcd = v4l2_ctrls_set(curdev); if (retcd == 0) retcd = v4l2_mmap_set(curdev); diff --git a/src/webu.cpp b/src/webu.cpp index 09e04036..09869278 100644 --- a/src/webu.cpp +++ b/src/webu.cpp @@ -668,7 +668,7 @@ static int webu_process_config_set(struct webui_ctx *webui) /*If we are updating vid parms, set the flag to update the device.*/ if ((config_parms[indx].parm_name == "v4l2_parms") && (webui->camlst[webui->thread_nbr]->vdev != NULL)){ - webui->camlst[webui->thread_nbr]->vdev->update_parms = TRUE; + webui->camlst[webui->thread_nbr]->vdev->update_params = TRUE; } /* If changing language, do it now */