mirror of
https://github.com/Motion-Project/motion.git
synced 2025-12-23 23:18:21 -05:00
Revise params to use vector
This commit is contained in:
104
src/alg_sec.cpp
104
src/alg_sec.cpp
@@ -437,72 +437,74 @@ void cls_algsec::load_dnn()
|
||||
|
||||
void cls_algsec::params_log()
|
||||
{
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
ctx_params_item *itm;
|
||||
int indx;
|
||||
|
||||
if (method != "none") {
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
itm = ¶ms->params_array[indx];
|
||||
MOTPLS_SHT(INF, TYPE_ALL, NO_ERRNO, "%-25s %s"
|
||||
,it->param_name.c_str(), it->param_value.c_str());
|
||||
,itm->param_name.c_str(),itm->param_value.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cls_algsec::params_model()
|
||||
{
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
ctx_params_item *itm;
|
||||
int indx;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "model_file") {
|
||||
model_file = it->param_value;
|
||||
} else if (it->param_name == "frame_interval") {
|
||||
frame_interval = mtoi(it->param_value);
|
||||
} else if (it->param_name == "image_type") {
|
||||
image_type = it->param_value;
|
||||
} else if (it->param_name == "threshold") {
|
||||
threshold = mtof(it->param_value);
|
||||
} else if (it->param_name == "scalefactor") {
|
||||
scalefactor = mtof(it->param_value);
|
||||
} else if (it->param_name == "rotate") {
|
||||
rotate = mtoi(it->param_value);
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
itm = ¶ms->params_array[indx];
|
||||
if (itm->param_name == "model_file") {
|
||||
model_file = itm->param_value;
|
||||
} else if (itm->param_name == "frame_interval") {
|
||||
frame_interval = mtoi(itm->param_value);
|
||||
} else if (itm->param_name == "image_type") {
|
||||
image_type = itm->param_value;
|
||||
} else if (itm->param_name == "threshold") {
|
||||
threshold = mtof(itm->param_value);
|
||||
} else if (itm->param_name == "scalefactor") {
|
||||
scalefactor = mtof(itm->param_value);
|
||||
} else if (itm->param_name == "rotate") {
|
||||
rotate = mtoi(itm->param_value);
|
||||
}
|
||||
|
||||
if (method == "hog") {
|
||||
if (it->param_name =="padding") {
|
||||
hog_padding = mtoi(it->param_value);
|
||||
} else if (it->param_name =="threshold_model") {
|
||||
hog_threshold_model = mtof(it->param_value);
|
||||
} else if (it->param_name =="winstride") {
|
||||
hog_winstride = mtoi(it->param_value);
|
||||
if (itm->param_name =="padding") {
|
||||
hog_padding = mtoi(itm->param_value);
|
||||
} else if (itm->param_name =="threshold_model") {
|
||||
hog_threshold_model = mtof(itm->param_value);
|
||||
} else if (itm->param_name =="winstride") {
|
||||
hog_winstride = mtoi(itm->param_value);
|
||||
}
|
||||
} else if (method == "haar") {
|
||||
if (it->param_name =="flags") {
|
||||
haar_flags = mtoi(it->param_value);
|
||||
} else if (it->param_name =="maxsize") {
|
||||
haar_maxsize = mtoi(it->param_value);
|
||||
} else if (it->param_name =="minsize") {
|
||||
haar_minsize = mtoi(it->param_value);
|
||||
} else if (it->param_name =="minneighbors") {
|
||||
haar_minneighbors = mtoi(it->param_value);
|
||||
if (itm->param_name =="flags") {
|
||||
haar_flags = mtoi(itm->param_value);
|
||||
} else if (itm->param_name =="maxsize") {
|
||||
haar_maxsize = mtoi(itm->param_value);
|
||||
} else if (itm->param_name =="minsize") {
|
||||
haar_minsize = mtoi(itm->param_value);
|
||||
} else if (itm->param_name =="minneighbors") {
|
||||
haar_minneighbors = mtoi(itm->param_value);
|
||||
}
|
||||
} else if (method == "dnn") {
|
||||
if (it->param_name == "config") {
|
||||
dnn_config = it->param_value;
|
||||
} else if (it->param_name == "classes_file") {
|
||||
dnn_classes_file = it->param_value;
|
||||
} else if (it->param_name =="framework") {
|
||||
dnn_framework = it->param_value;
|
||||
} else if (it->param_name =="backend") {
|
||||
dnn_backend = mtoi(it->param_value);
|
||||
} else if (it->param_name =="target") {
|
||||
dnn_target = mtoi(it->param_value);
|
||||
} else if (it->param_name =="scale") {
|
||||
dnn_scale = mtof(it->param_value);
|
||||
} else if (it->param_name =="width") {
|
||||
dnn_width = mtoi(it->param_value);
|
||||
} else if (it->param_name =="height") {
|
||||
dnn_height = mtoi(it->param_value);
|
||||
if (itm->param_name == "config") {
|
||||
dnn_config = itm->param_value;
|
||||
} else if (itm->param_name == "classes_file") {
|
||||
dnn_classes_file = itm->param_value;
|
||||
} else if (itm->param_name =="framework") {
|
||||
dnn_framework = itm->param_value;
|
||||
} else if (itm->param_name =="backend") {
|
||||
dnn_backend = mtoi(itm->param_value);
|
||||
} else if (itm->param_name =="target") {
|
||||
dnn_target = mtoi(itm->param_value);
|
||||
} else if (itm->param_name =="scale") {
|
||||
dnn_scale = mtof(itm->param_value);
|
||||
} else if (itm->param_name =="width") {
|
||||
dnn_width = mtoi(itm->param_value);
|
||||
} else if (itm->param_name =="height") {
|
||||
dnn_height = mtoi(itm->param_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -565,9 +567,7 @@ void cls_algsec::load_params()
|
||||
image_norm = (u_char*)mymalloc((size_t)cam->imgs.size_norm);
|
||||
|
||||
params = new ctx_params;
|
||||
params->update_params = true;
|
||||
util_parms_parse(params, "secondary_params"
|
||||
, cam->cfg->secondary_params);
|
||||
util_parms_parse(params, "secondary_params", cam->cfg->secondary_params);
|
||||
|
||||
params_defaults();
|
||||
|
||||
|
||||
@@ -211,18 +211,16 @@ void cls_libcam:: log_draft()
|
||||
|
||||
void cls_libcam::start_params()
|
||||
{
|
||||
p_lst *lst;
|
||||
p_it it;
|
||||
ctx_params_item *itm;
|
||||
int indx;
|
||||
|
||||
params = new ctx_params;
|
||||
params->update_params = true;
|
||||
util_parms_parse(params,"libcam_params", cam->cfg->libcam_params);
|
||||
|
||||
lst = ¶ms->params_array;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
itm = ¶ms->params_array[indx];
|
||||
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s : %s"
|
||||
,it->param_name.c_str(), it->param_value.c_str());
|
||||
,itm->param_name.c_str(), itm->param_value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,12 +445,12 @@ void cls_libcam::config_control_item(std::string pname, std::string pvalue)
|
||||
|
||||
void cls_libcam::config_controls()
|
||||
{
|
||||
int retcd;
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
int retcd, indx;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
config_control_item(it->param_name, it->param_value);
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
config_control_item(
|
||||
params->params_array[indx].param_name
|
||||
,params->params_array[indx].param_value);
|
||||
}
|
||||
|
||||
retcd = config->validate();
|
||||
@@ -472,33 +470,33 @@ void cls_libcam::config_controls()
|
||||
void cls_libcam:: config_orientation()
|
||||
{
|
||||
#if (LIBCAMVER >= 2000)
|
||||
int retcd;
|
||||
int retcd, indx;
|
||||
std::string adjdesc;
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
ctx_params_item *itm;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "orientation") {
|
||||
if (it->param_value == "Rotate0") {
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
itm = ¶ms->params_array[indx];
|
||||
if (itm->param_name == "orientation") {
|
||||
if (itm->param_value == "Rotate0") {
|
||||
config->orientation = Orientation::Rotate0;
|
||||
} else if (it->param_value == "Rotate0Mirror") {
|
||||
} else if (itm->param_value == "Rotate0Mirror") {
|
||||
config->orientation = Orientation::Rotate0Mirror;
|
||||
} else if (it->param_value == "Rotate180") {
|
||||
} else if (itm->param_value == "Rotate180") {
|
||||
config->orientation = Orientation::Rotate180;
|
||||
} else if (it->param_value == "Rotate180Mirror") {
|
||||
} else if (itm->param_value == "Rotate180Mirror") {
|
||||
config->orientation = Orientation::Rotate180Mirror;
|
||||
} else if (it->param_value == "Rotate90") {
|
||||
} else if (itm->param_value == "Rotate90") {
|
||||
config->orientation = Orientation::Rotate90;
|
||||
} else if (it->param_value == "Rotate90Mirror") {
|
||||
} else if (itm->param_value == "Rotate90Mirror") {
|
||||
config->orientation = Orientation::Rotate90Mirror;
|
||||
} else if (it->param_value == "Rotate270") {
|
||||
} else if (itm->param_value == "Rotate270") {
|
||||
config->orientation = Orientation::Rotate270;
|
||||
} else if (it->param_value == "Rotate270Mirror") {
|
||||
} else if (itm->param_value == "Rotate270Mirror") {
|
||||
config->orientation = Orientation::Rotate270Mirror;
|
||||
} else {
|
||||
MOTPLS_LOG(ERR, TYPE_VIDEO, NO_ERRNO
|
||||
, "Invalid Orientation option: %s."
|
||||
, it->param_value.c_str());
|
||||
, itm->param_value.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,8 +271,7 @@ void cls_motapp::allcams_init()
|
||||
bool cfg_valid, chk;
|
||||
std::string cfg_row, cfg_col;
|
||||
ctx_params *params_loc;
|
||||
p_lst *lst;
|
||||
p_it it;
|
||||
ctx_params_item *itm;
|
||||
|
||||
all_sizes = new ctx_all_sizes;
|
||||
all_sizes->height = 0;
|
||||
@@ -294,32 +293,31 @@ void cls_motapp::allcams_init()
|
||||
cam_list[indx]->all_loc.scale =
|
||||
cam_list[indx]->cfg->stream_preview_scale;
|
||||
|
||||
params_loc->update_params = true;
|
||||
util_parms_parse(params_loc
|
||||
, "stream_preview_location"
|
||||
, cam_list[indx]->cfg->stream_preview_location);
|
||||
lst = ¶ms_loc->params_array;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "row") {
|
||||
cam_list[indx]->all_loc.row = mtoi(it->param_value);
|
||||
for (indx1=0;indx1<params_loc->params_cnt;indx1++) {
|
||||
itm = ¶ms_loc->params_array[indx];
|
||||
if (itm->param_name == "row") {
|
||||
cam_list[indx]->all_loc.row = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "col") {
|
||||
cam_list[indx]->all_loc.col = mtoi(it->param_value);
|
||||
if (itm->param_name == "col") {
|
||||
cam_list[indx]->all_loc.col = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "offset_col") {
|
||||
if (itm->param_name == "offset_col") {
|
||||
cam_list[indx]->all_loc.offset_user_col =
|
||||
mtoi(it->param_value);
|
||||
mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "offset_row") {
|
||||
if (itm->param_name == "offset_row") {
|
||||
cam_list[indx]->all_loc.offset_user_row =
|
||||
mtoi(it->param_value);
|
||||
mtoi(itm->param_value);
|
||||
}
|
||||
}
|
||||
params_loc->params_array.clear();
|
||||
}
|
||||
|
||||
delete params_loc;
|
||||
mydelete(params_loc);
|
||||
|
||||
mx_row = 0;
|
||||
mx_col = 0;
|
||||
|
||||
@@ -814,8 +814,7 @@ void cls_netcam::hwdecoders()
|
||||
void cls_netcam::decoder_error(int retcd, const char* fnc_nm)
|
||||
{
|
||||
char errstr[128];
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
if (interrupted) {
|
||||
MOTPLS_LOG(ERR, TYPE_NETCAM, NO_ERRNO
|
||||
@@ -841,9 +840,9 @@ void cls_netcam::decoder_error(int retcd, const char* fnc_nm)
|
||||
,_("%s:Ignoring and removing the user requested decoder %s")
|
||||
,cameratype.c_str(), decoder_nm.c_str());
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "decoder") {
|
||||
it->param_value = "NULL";
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == "decoder") {
|
||||
params->params_array[indx].param_value = "NULL";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1509,8 +1508,8 @@ int cls_netcam::ntc()
|
||||
void cls_netcam::set_options()
|
||||
{
|
||||
std::string tmp;
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
ctx_params_item *itm;
|
||||
|
||||
if ((service == "rtsp") ||
|
||||
(service == "rtsps") ||
|
||||
@@ -1556,15 +1555,16 @@ void cls_netcam::set_options()
|
||||
, service.c_str());
|
||||
}
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if ((it->param_name != "decoder") &&
|
||||
(it->param_name != "capture_rate")) {
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
itm = ¶ms->params_array[indx];
|
||||
if ((itm->param_name != "decoder") &&
|
||||
(itm->param_name != "capture_rate")) {
|
||||
av_dict_set(&opts
|
||||
, it->param_name.c_str(), it->param_value.c_str(), 0);
|
||||
, itm->param_name.c_str(), itm->param_value.c_str(), 0);
|
||||
if (status == NETCAM_NOTCONNECTED) {
|
||||
MOTPLS_LOG(INF, TYPE_NETCAM, NO_ERRNO,_("%s:%s = %s")
|
||||
,cameratype.c_str()
|
||||
,it->param_name.c_str(),it->param_value.c_str());
|
||||
,itm->param_name.c_str(),itm->param_value.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1613,7 +1613,7 @@ void cls_netcam::set_path ()
|
||||
|
||||
void cls_netcam::set_parms ()
|
||||
{
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
params = new ctx_params;
|
||||
|
||||
@@ -1637,17 +1637,13 @@ void cls_netcam::set_parms ()
|
||||
imgsize.height = 0;
|
||||
cameratype = _("High");
|
||||
cfg_params = cam->cfg->netcam_high_params;
|
||||
params->update_params = true;
|
||||
util_parms_parse(params
|
||||
,"netcam_high_params", cfg_params);
|
||||
util_parms_parse(params,"netcam_high_params", cfg_params);
|
||||
} else {
|
||||
imgsize.width = cfg_width;
|
||||
imgsize.height = cfg_height;
|
||||
cameratype = _("Norm");
|
||||
cfg_params = cam->cfg->netcam_params;
|
||||
params->update_params = true;
|
||||
util_parms_parse(params
|
||||
,"netcam_params", cfg_params);
|
||||
util_parms_parse(params,"netcam_params", cfg_params);
|
||||
}
|
||||
camera_name = cam->cfg->device_name;
|
||||
|
||||
@@ -1686,20 +1682,19 @@ void cls_netcam::set_parms ()
|
||||
filedir = "";
|
||||
cfg_idur = 90;
|
||||
|
||||
for (it = params->params_array.begin();
|
||||
it != params->params_array.end(); it++) {
|
||||
if (it->param_name == "decoder") {
|
||||
decoder_nm = it->param_value;
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == "decoder") {
|
||||
decoder_nm = params->params_array[indx].param_value;
|
||||
}
|
||||
if (it->param_name == "capture_rate") {
|
||||
if (it->param_value == "pts") {
|
||||
if (params->params_array[indx].param_name == "capture_rate") {
|
||||
if (params->params_array[indx].param_value == "pts") {
|
||||
pts_adj = true;
|
||||
} else {
|
||||
capture_rate = mtoi(it->param_value);
|
||||
capture_rate = mtoi(params->params_array[indx].param_value);
|
||||
}
|
||||
}
|
||||
if (it->param_name == "interrupt") {
|
||||
cfg_idur = mtoi(it->param_value);
|
||||
if (params->params_array[indx].param_name == "interrupt") {
|
||||
cfg_idur = mtoi(params->params_array[indx].param_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,56 +122,55 @@ void cls_sound::load_alerts()
|
||||
std::list<std::string> parm_val;
|
||||
std::list<std::string>::iterator it_a;
|
||||
ctx_params *tmp_params;
|
||||
p_it it;
|
||||
ctx_params_item *itm;
|
||||
int indx;
|
||||
|
||||
cfg->edit_get("snd_alerts", parm_val, PARM_CAT_18);
|
||||
|
||||
tmp_params = new ctx_params;
|
||||
for (it_a=parm_val.begin(); it_a!=parm_val.end(); it_a++) {
|
||||
tmp_params->update_params = true;
|
||||
util_parms_parse(tmp_params,"snd_alerts", it_a->c_str());
|
||||
init_alerts(&tmp_alert);
|
||||
for (it = tmp_params->params_array.begin();
|
||||
it != tmp_params->params_array.end(); it++) {
|
||||
if (it->param_name == "alert_id") {
|
||||
tmp_alert.alert_id = mtoi(it->param_value);
|
||||
for (indx=0;indx<tmp_params->params_cnt;indx++) {
|
||||
itm = &tmp_params->params_array[indx];
|
||||
if (itm->param_name == "alert_id") {
|
||||
tmp_alert.alert_id = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "alert_nm") {
|
||||
tmp_alert.alert_nm = it->param_value;
|
||||
if (itm->param_name == "alert_nm") {
|
||||
tmp_alert.alert_nm = itm->param_value;
|
||||
}
|
||||
if (it->param_name == "freq_low") {
|
||||
tmp_alert.freq_low = mtof(it->param_value);
|
||||
if (itm->param_name == "freq_low") {
|
||||
tmp_alert.freq_low = mtof(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "freq_high") {
|
||||
tmp_alert.freq_high = mtof(it->param_value);
|
||||
if (itm->param_name == "freq_high") {
|
||||
tmp_alert.freq_high = mtof(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "volume_count") {
|
||||
tmp_alert.volume_count = mtoi(it->param_value);
|
||||
if (itm->param_name == "volume_count") {
|
||||
tmp_alert.volume_count = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "volume_level") {
|
||||
tmp_alert.volume_level = mtoi(it->param_value);
|
||||
if (itm->param_name == "volume_level") {
|
||||
tmp_alert.volume_level = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "trigger_threshold") {
|
||||
tmp_alert.trigger_threshold = mtoi(it->param_value);
|
||||
if (itm->param_name == "trigger_threshold") {
|
||||
tmp_alert.trigger_threshold = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "trigger_duration") {
|
||||
tmp_alert.trigger_duration = mtoi(it->param_value);
|
||||
if (itm->param_name == "trigger_duration") {
|
||||
tmp_alert.trigger_duration = mtoi(itm->param_value);
|
||||
}
|
||||
}
|
||||
snd_info->alerts.push_back(tmp_alert);
|
||||
}
|
||||
|
||||
delete tmp_params;
|
||||
mydelete(tmp_params);
|
||||
|
||||
edit_alerts();
|
||||
}
|
||||
|
||||
void cls_sound::load_params()
|
||||
{
|
||||
p_it it;
|
||||
p_lst *lst;
|
||||
int indx;
|
||||
ctx_params_item *itm;
|
||||
|
||||
snd_info->params->update_params = true;
|
||||
util_parms_parse(snd_info->params,"snd_params", cfg->snd_params);
|
||||
|
||||
util_parms_add_default(snd_info->params,"source","alsa");
|
||||
@@ -179,28 +178,28 @@ void cls_sound::load_params()
|
||||
util_parms_add_default(snd_info->params,"frames","2048");
|
||||
util_parms_add_default(snd_info->params,"sample_rate","44100");
|
||||
|
||||
lst = &snd_info->params->params_array;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s : %s"
|
||||
, it->param_name.c_str(), it->param_value.c_str());
|
||||
for (indx=0;indx<snd_info->params->params_cnt;indx++) {
|
||||
itm = &snd_info->params->params_array[indx];
|
||||
MOTPLS_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s : %s"
|
||||
,itm->param_name.c_str(),itm->param_value.c_str());
|
||||
}
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "source") {
|
||||
snd_info->source = it->param_value;
|
||||
for (indx=0;indx<snd_info->params->params_cnt;indx++) {
|
||||
itm = &snd_info->params->params_array[indx];
|
||||
if (itm->param_name == "source") {
|
||||
snd_info->source = itm->param_value;
|
||||
}
|
||||
if (it->param_name == "channels") {
|
||||
snd_info->channels = mtoi(it->param_value);
|
||||
if (itm->param_name == "channels") {
|
||||
snd_info->channels = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "frames") {
|
||||
snd_info->frames = mtoi(it->param_value);
|
||||
if (itm->param_name == "frames") {
|
||||
snd_info->frames = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "sample_rate") {
|
||||
snd_info->sample_rate = mtoi(it->param_value);
|
||||
if (itm->param_name == "sample_rate") {
|
||||
snd_info->sample_rate = mtoi(itm->param_value);
|
||||
}
|
||||
if (it->param_name == "pulse_server") {
|
||||
snd_info->pulse_server = it->param_value;
|
||||
if (itm->param_name == "pulse_server") {
|
||||
snd_info->pulse_server = itm->param_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
61
src/util.cpp
61
src/util.cpp
@@ -683,9 +683,8 @@ void util_exec_command(cls_sound *snd, std::string cmd)
|
||||
/*********************************************/
|
||||
static void util_parms_file(ctx_params *params, std::string params_file)
|
||||
{
|
||||
int chk;
|
||||
int chk, indx;
|
||||
size_t stpos;
|
||||
p_it it;
|
||||
std::string line, parm_nm, parm_vl;
|
||||
std::ifstream ifs;
|
||||
|
||||
@@ -693,9 +692,8 @@ static void util_parms_file(ctx_params *params, std::string params_file)
|
||||
,_("parse file:%s"), params_file.c_str());
|
||||
|
||||
chk = 0;
|
||||
for (it = params->params_array.begin();
|
||||
it != params->params_array.end(); it++) {
|
||||
if (it->param_name == "params_file" ) {
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == "params_file") {
|
||||
chk++;
|
||||
}
|
||||
}
|
||||
@@ -740,19 +738,18 @@ static void util_parms_file(ctx_params *params, std::string params_file)
|
||||
|
||||
void util_parms_add(ctx_params *params, std::string parm_nm, std::string parm_val)
|
||||
{
|
||||
p_it it;
|
||||
int indx;
|
||||
ctx_params_item parm_itm;
|
||||
|
||||
for (it = params->params_array.begin();
|
||||
it != params->params_array.end(); it++) {
|
||||
if (it->param_name == parm_nm) {
|
||||
it->param_value.assign(parm_val);
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == parm_nm) {
|
||||
params->params_array[indx].param_value.assign(parm_val);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is a new parameter*/
|
||||
params->params_count++;
|
||||
params->params_cnt++;
|
||||
parm_itm.param_name.assign(parm_nm);
|
||||
parm_itm.param_value.assign(parm_val);
|
||||
params->params_array.push_back(parm_itm);
|
||||
@@ -986,15 +983,11 @@ void util_parms_parse(ctx_params *params, std::string parm_desc, std::string con
|
||||
{
|
||||
std::string parmline;
|
||||
|
||||
if (params->update_params == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* We make a copy because the parsing destroys the value passed */
|
||||
parmline = confline;
|
||||
|
||||
params->params_array.clear();
|
||||
params->params_count = 0;
|
||||
params->params_cnt = 0;
|
||||
params->params_desc = parm_desc;
|
||||
|
||||
if (confline == "") {
|
||||
@@ -1005,22 +998,17 @@ void util_parms_parse(ctx_params *params, std::string parm_desc, std::string con
|
||||
|
||||
util_parms_parse_comma(params, parmline);
|
||||
|
||||
params->update_params = false;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* Add the requested int value as a default if the parm_nm does have anything yet */
|
||||
void util_parms_add_default(ctx_params *params, std::string parm_nm, int parm_vl)
|
||||
{
|
||||
bool dflt;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
dflt = true;
|
||||
for (it = params->params_array.begin();
|
||||
it != params->params_array.end(); it++) {
|
||||
if (it->param_name == parm_nm) {
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == parm_nm) {
|
||||
dflt = false;
|
||||
}
|
||||
}
|
||||
@@ -1033,12 +1021,11 @@ void util_parms_add_default(ctx_params *params, std::string parm_nm, int parm_vl
|
||||
void util_parms_add_default(ctx_params *params, std::string parm_nm, std::string parm_vl)
|
||||
{
|
||||
bool dflt;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
dflt = true;
|
||||
for (it = params->params_array.begin();
|
||||
it != params->params_array.end(); it++) {
|
||||
if (it->param_name == parm_nm) {
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == parm_nm) {
|
||||
dflt = false;
|
||||
}
|
||||
}
|
||||
@@ -1052,28 +1039,27 @@ void util_parms_update(ctx_params *params, std::string &confline)
|
||||
{
|
||||
std::string parmline;
|
||||
std::string comma;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
comma = "";
|
||||
parmline = "";
|
||||
for (it = params->params_array.begin();
|
||||
it != params->params_array.end(); it++) {
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
parmline += comma;
|
||||
comma = ",";
|
||||
if (it->param_name.find(" ") == std::string::npos) {
|
||||
parmline += it->param_name;
|
||||
if (params->params_array[indx].param_name.find(" ") == std::string::npos) {
|
||||
parmline += params->params_array[indx].param_name;
|
||||
} else {
|
||||
parmline += "\"";
|
||||
parmline += it->param_name;
|
||||
parmline += params->params_array[indx].param_name;
|
||||
parmline += "\"";
|
||||
}
|
||||
|
||||
parmline += "=";
|
||||
if (it->param_value.find(" ") == std::string::npos) {
|
||||
parmline += it->param_value;
|
||||
if (params->params_array[indx].param_value.find(" ") == std::string::npos) {
|
||||
parmline += params->params_array[indx].param_value;
|
||||
} else {
|
||||
parmline += "\"";
|
||||
parmline += it->param_value;
|
||||
parmline += params->params_array[indx].param_value;
|
||||
parmline += "\"";
|
||||
}
|
||||
}
|
||||
@@ -1084,7 +1070,6 @@ void util_parms_update(ctx_params *params, std::string &confline)
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO
|
||||
,_("New config:%s"), confline.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* my to integer*/
|
||||
|
||||
16
src/util.hpp
16
src/util.hpp
@@ -61,19 +61,11 @@ struct ctx_params_item {
|
||||
std::string param_name; /* The name or description of the ID as requested by user*/
|
||||
std::string param_value; /* The value that the user wants the control set to*/
|
||||
};
|
||||
/* TODO Change this to lst_p and it_p so we have a type then descr. Avoids
|
||||
conflicts with var names which I'll try not to have start with a abbrev
|
||||
for their type. Types with start with something indicating their type.
|
||||
cls, ctx, it, lst, vec, etc)
|
||||
*/
|
||||
typedef std::list<ctx_params_item> p_lst;
|
||||
typedef p_lst::iterator p_it;
|
||||
|
||||
typedef std::vector<ctx_params_item> vec_params;
|
||||
struct ctx_params {
|
||||
p_lst params_array; /*List of the controls the user specified*/
|
||||
int params_count; /*Count of the controls the user specified*/
|
||||
bool update_params; /*Bool for whether to update the parameters on the device*/
|
||||
std::string params_desc; /* Description of params*/
|
||||
vec_params params_array;
|
||||
int params_cnt;
|
||||
std::string params_desc;
|
||||
};
|
||||
|
||||
void *mymalloc(size_t nbytes);
|
||||
|
||||
@@ -97,22 +97,24 @@ void cls_v4l2cam::device_close()
|
||||
/* Print the device controls to the log */
|
||||
void cls_v4l2cam::ctrls_log()
|
||||
{
|
||||
it_v4l2ctrl it;
|
||||
int indx;
|
||||
ctx_v4l2ctrl_item *itm;
|
||||
|
||||
if (device_ctrls.size() >0) {
|
||||
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO, _("---------Controls---------"));
|
||||
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO, _(" V4L2 ID : Name : Range"));
|
||||
for (it = device_ctrls.begin();it!=device_ctrls.end();it++){
|
||||
if (it->ctrl_menuitem) {
|
||||
for (indx=0;indx<device_ctrls.size();indx++){
|
||||
itm = &device_ctrls[indx];
|
||||
if (itm->ctrl_menuitem) {
|
||||
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO, " %s : %s"
|
||||
,it->ctrl_iddesc.c_str()
|
||||
,it->ctrl_name.c_str());
|
||||
,itm->ctrl_iddesc.c_str()
|
||||
,itm->ctrl_name.c_str());
|
||||
} else {
|
||||
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO, "%s : %s : %d to %d"
|
||||
,it->ctrl_iddesc.c_str()
|
||||
,it->ctrl_name.c_str()
|
||||
,it->ctrl_minimum
|
||||
,it->ctrl_maximum);
|
||||
,itm->ctrl_iddesc.c_str()
|
||||
,itm->ctrl_name.c_str()
|
||||
,itm->ctrl_minimum
|
||||
,itm->ctrl_maximum);
|
||||
}
|
||||
}
|
||||
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO, "--------------------------");
|
||||
@@ -186,31 +188,32 @@ void cls_v4l2cam::ctrls_list()
|
||||
/* Set the control array items to the device */
|
||||
void cls_v4l2cam::ctrls_set()
|
||||
{
|
||||
int retcd;
|
||||
int retcd, indx;
|
||||
struct v4l2_control vid_ctrl;
|
||||
it_v4l2ctrl it;
|
||||
ctx_v4l2ctrl_item *itm;
|
||||
|
||||
if (fd_device == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (it = device_ctrls.begin();it!=device_ctrls.end();it++) {
|
||||
if (it->ctrl_menuitem == false) {
|
||||
if (it->ctrl_currval != it->ctrl_newval) {
|
||||
for (indx=0;indx<device_ctrls.size();indx++) {
|
||||
itm = &device_ctrls[indx];
|
||||
if (itm->ctrl_menuitem == false) {
|
||||
if (itm->ctrl_currval != itm->ctrl_newval) {
|
||||
memset(&vid_ctrl, 0, sizeof (struct v4l2_control));
|
||||
vid_ctrl.id = it->ctrl_id;
|
||||
vid_ctrl.value = it->ctrl_newval;
|
||||
vid_ctrl.id = itm->ctrl_id;
|
||||
vid_ctrl.value = itm->ctrl_newval;
|
||||
retcd = xioctl(VIDIOC_S_CTRL, &vid_ctrl);
|
||||
if (retcd < 0) {
|
||||
MOTPLS_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO
|
||||
,_("setting control %s \"%s\" to %d failed with return code %d")
|
||||
,it->ctrl_iddesc.c_str(), it->ctrl_name.c_str()
|
||||
,it->ctrl_newval, retcd);
|
||||
,itm->ctrl_iddesc.c_str(), itm->ctrl_name.c_str()
|
||||
,itm->ctrl_newval, retcd);
|
||||
} else {
|
||||
MOTPLS_LOG(INF, TYPE_VIDEO, NO_ERRNO
|
||||
,_("Set control \"%s\" to value %d")
|
||||
,it->ctrl_name.c_str(), it->ctrl_newval);
|
||||
it->ctrl_currval = it->ctrl_newval;
|
||||
,itm->ctrl_name.c_str(), itm->ctrl_newval);
|
||||
itm->ctrl_currval = itm->ctrl_newval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,42 +222,43 @@ void cls_v4l2cam::ctrls_set()
|
||||
|
||||
void cls_v4l2cam::parms_set()
|
||||
{
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it_p;
|
||||
it_v4l2ctrl it_d;
|
||||
int indx_p, indx_d;
|
||||
ctx_params_item *itm_p;
|
||||
ctx_v4l2ctrl_item *itm_d;
|
||||
|
||||
if (device_ctrls.size() == 0) {
|
||||
params->update_params = false;
|
||||
return;
|
||||
}
|
||||
|
||||
for (it_d = device_ctrls.begin(); it_d != device_ctrls.end(); it_d++) {
|
||||
it_d->ctrl_newval = it_d->ctrl_default;
|
||||
for (it_p = lst->begin(); it_p != lst->end(); it_p++) {
|
||||
if ((it_d->ctrl_iddesc == it_p->param_name) ||
|
||||
(it_d->ctrl_name == it_p->param_name)) {
|
||||
switch (it_d->ctrl_type) {
|
||||
for (indx_d = 0;indx_d< device_ctrls.size(); indx_d++) {
|
||||
itm_d = &device_ctrls[indx_d];
|
||||
itm_d->ctrl_newval = itm_d->ctrl_default;
|
||||
for (indx_p=0;indx_p<params->params_cnt;indx_p++) {
|
||||
itm_p = ¶ms->params_array[indx_p];
|
||||
if ((itm_d->ctrl_iddesc == itm_p->param_name) ||
|
||||
(itm_d->ctrl_name == itm_p->param_name)) {
|
||||
switch (itm_d->ctrl_type) {
|
||||
case V4L2_CTRL_TYPE_MENU:
|
||||
/*FALLTHROUGH*/
|
||||
case V4L2_CTRL_TYPE_INTEGER:
|
||||
if (mtoi(it_p->param_value.c_str()) < it_d->ctrl_minimum) {
|
||||
if (mtoi(itm_p->param_value.c_str()) < itm_d->ctrl_minimum) {
|
||||
MOTPLS_LOG(WRN, TYPE_VIDEO, NO_ERRNO
|
||||
,_("%s control option value %s is below minimum. Skipping...")
|
||||
, it_d->ctrl_name.c_str()
|
||||
, it_p->param_value.c_str()
|
||||
, it_d->ctrl_minimum);
|
||||
} else if (mtoi(it_p->param_value.c_str()) > it_d->ctrl_maximum) {
|
||||
, itm_d->ctrl_name.c_str()
|
||||
, itm_p->param_value.c_str()
|
||||
, itm_d->ctrl_minimum);
|
||||
} else if (mtoi(itm_p->param_value.c_str()) > itm_d->ctrl_maximum) {
|
||||
MOTPLS_LOG(WRN, TYPE_VIDEO, NO_ERRNO
|
||||
,_("%s control option value %s is above maximum. Skipping...")
|
||||
, it_d->ctrl_name.c_str()
|
||||
, it_p->param_value.c_str()
|
||||
, it_d->ctrl_maximum);
|
||||
, itm_d->ctrl_name.c_str()
|
||||
, itm_p->param_value.c_str()
|
||||
, itm_d->ctrl_maximum);
|
||||
} else {
|
||||
it_d->ctrl_newval = mtoi(it_p->param_value.c_str());
|
||||
itm_d->ctrl_newval = mtoi(itm_p->param_value.c_str());
|
||||
}
|
||||
break;
|
||||
case V4L2_CTRL_TYPE_BOOLEAN:
|
||||
it_d->ctrl_newval = mtob(it_p->param_value.c_str()) ? 1 : 0;
|
||||
itm_d->ctrl_newval = mtob(itm_p->param_value.c_str()) ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
MOTPLS_LOG(WRN, TYPE_VIDEO, NO_ERRNO
|
||||
@@ -269,19 +273,17 @@ void cls_v4l2cam::parms_set()
|
||||
/* Set the device to the input number requested by user */
|
||||
void cls_v4l2cam::set_input()
|
||||
{
|
||||
int spec;
|
||||
int spec, indx;
|
||||
struct v4l2_input input;
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
|
||||
if (fd_device == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
spec = -1;
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "input") {
|
||||
spec = mtoi(it->param_value);
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == "input") {
|
||||
spec = mtoi(params->params_array[indx].param_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -331,20 +333,18 @@ void cls_v4l2cam::set_input()
|
||||
/* Set the video standard(norm) for the device to the user requested value*/
|
||||
void cls_v4l2cam::set_norm()
|
||||
{
|
||||
int spec;
|
||||
int spec, indx;
|
||||
struct v4l2_standard standard;
|
||||
v4l2_std_id std_id;
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
|
||||
if (fd_device == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
spec = 1;
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "norm") {
|
||||
spec = mtoi(it->param_value);
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == "norm") {
|
||||
spec = mtoi(params->params_array[indx].param_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -399,20 +399,18 @@ void cls_v4l2cam::set_norm()
|
||||
/* Set the frequency on the device to the user requested value */
|
||||
void cls_v4l2cam::set_frequency()
|
||||
{
|
||||
long spec;
|
||||
long spec, indx;
|
||||
struct v4l2_tuner tuner;
|
||||
struct v4l2_frequency freq;
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
|
||||
if (fd_device == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
spec = 0;
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "frequency") {
|
||||
spec = mtol(it->param_value);
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == "frequency") {
|
||||
spec = mtol(params->params_array[indx].param_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -595,10 +593,7 @@ int cls_v4l2cam::pixfmt_set(uint pixformat)
|
||||
|
||||
void cls_v4l2cam::params_check()
|
||||
{
|
||||
int spec;
|
||||
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
int spec, indx;
|
||||
|
||||
if (cam->cfg->width % 8) {
|
||||
MOTPLS_LOG(ERR, TYPE_VIDEO, NO_ERRNO
|
||||
@@ -617,9 +612,9 @@ void cls_v4l2cam::params_check()
|
||||
}
|
||||
|
||||
spec = 17;
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "palette") {
|
||||
spec = mtoi(it->param_value);
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == "palette") {
|
||||
spec = mtoi(params->params_array[indx].param_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -670,9 +665,7 @@ int cls_v4l2cam::pixfmt_list()
|
||||
/* Find and select the pixel format for camera*/
|
||||
void cls_v4l2cam::palette_set()
|
||||
{
|
||||
int indxp, retcd;
|
||||
p_lst *lst = ¶ms->params_array;
|
||||
p_it it;
|
||||
int indxp, retcd, indx;
|
||||
|
||||
if (fd_device == -1) {
|
||||
return;
|
||||
@@ -681,9 +674,9 @@ void cls_v4l2cam::palette_set()
|
||||
params_check();
|
||||
|
||||
indxp = 17;
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "palette") {
|
||||
indxp = mtoi(it->param_value);
|
||||
for (indx=0;indx<params->params_cnt;indx++) {
|
||||
if (params->params_array[indx].param_name == "palette") {
|
||||
indxp = mtoi(params->params_array[indx].param_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -898,8 +891,7 @@ void cls_v4l2cam::init_vars()
|
||||
convert = nullptr;
|
||||
|
||||
params = new ctx_params;
|
||||
params->params_count = 0;
|
||||
params->update_params = true;
|
||||
params->params_cnt = 0;
|
||||
util_parms_parse(params, "v4l2_params", cam->cfg->v4l2_params);
|
||||
util_parms_add_default(params, "input", "-1");
|
||||
util_parms_add_default(params, "palette", "17");
|
||||
|
||||
@@ -45,10 +45,7 @@ struct ctx_v4l2ctrl_item {
|
||||
};
|
||||
|
||||
typedef std::vector<ctx_v4l2ctrl_item> vec_v4l2ctrl;
|
||||
typedef vec_v4l2ctrl::iterator it_v4l2ctrl;
|
||||
typedef std::vector<ctx_palette_item> vec_palette;
|
||||
typedef vec_palette::iterator it_palette;
|
||||
|
||||
|
||||
class cls_v4l2cam {
|
||||
public:
|
||||
|
||||
@@ -362,9 +362,7 @@ void cls_webu::init_actions()
|
||||
std::string parm_vl;
|
||||
|
||||
wb_actions = new ctx_params;
|
||||
wb_actions->update_params = true;
|
||||
util_parms_parse(wb_actions
|
||||
,"webcontrol_actions", app->cfg->webcontrol_actions);
|
||||
util_parms_parse(wb_actions,"webcontrol_actions", app->cfg->webcontrol_actions);
|
||||
|
||||
if (app->cfg->webcontrol_parms == 0) {
|
||||
parm_vl = "off";
|
||||
@@ -489,9 +487,7 @@ void cls_webu::startup()
|
||||
, app->cfg->webcontrol_port);
|
||||
|
||||
wb_headers = new ctx_params;
|
||||
wb_headers->update_params = true;
|
||||
util_parms_parse(wb_headers
|
||||
, "webcontrol_headers", app->cfg->webcontrol_headers);
|
||||
util_parms_parse(wb_headers, "webcontrol_headers", app->cfg->webcontrol_headers);
|
||||
|
||||
init_actions();
|
||||
|
||||
|
||||
@@ -559,8 +559,7 @@ void cls_webu_ans::mhd_send()
|
||||
{
|
||||
mhdrslt retcd;
|
||||
struct MHD_Response *response;
|
||||
p_lst *lst = &webu->wb_headers->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
response = MHD_create_response_from_buffer(resp_page.length()
|
||||
,(void *)resp_page.c_str(), MHD_RESPMEM_PERSISTENT);
|
||||
@@ -569,10 +568,11 @@ void cls_webu_ans::mhd_send()
|
||||
return;
|
||||
}
|
||||
|
||||
if (webu->wb_headers->params_count > 0) {
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (webu->wb_headers->params_cnt > 0) {
|
||||
for (indx=0;indx<webu->wb_headers->params_cnt; indx++) {
|
||||
MHD_add_response_header (response
|
||||
, it->param_name.c_str(),it->param_value.c_str());
|
||||
,webu->wb_headers->params_array[indx].param_name.c_str()
|
||||
,webu->wb_headers->params_array[indx].param_value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,10 +41,9 @@ void cls_webu_file::main() {
|
||||
struct stat statbuf;
|
||||
struct MHD_Response *response;
|
||||
std::string full_nm;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
lst_movies movies;
|
||||
it_movies m_it;
|
||||
int indx;
|
||||
|
||||
/*If we have not fully started yet, simply return*/
|
||||
if (app->dbse == NULL) {
|
||||
@@ -52,9 +51,9 @@ void cls_webu_file::main() {
|
||||
return;
|
||||
}
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "movies") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "movies") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Movies via webcontrol disabled");
|
||||
webua->bad_request();
|
||||
return;
|
||||
|
||||
@@ -658,24 +658,25 @@ void cls_webu_html::script_assign_cams()
|
||||
/* Create the javascript function assign_actions */
|
||||
void cls_webu_html::script_assign_actions()
|
||||
{
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
ctx_params_item *itm;
|
||||
|
||||
webua->resp_page +=
|
||||
" function assign_actions() {\n"
|
||||
" var html_actions = \"\\n\";\n"
|
||||
" html_actions += \" \";\n";
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if ((it->param_name == "snapshot") &&
|
||||
(it->param_value == "on")) {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
itm = &webu->wb_actions->params_array[indx];
|
||||
if ((itm->param_name == "snapshot") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_action(\";\n"
|
||||
" html_actions += \"'snapshot');\\\">\";\n"
|
||||
" html_actions += \"Snapshot</a>\\n\";\n\n"
|
||||
;
|
||||
} else if ((it->param_name == "event") &&
|
||||
(it->param_value == "on")) {
|
||||
} else if ((itm->param_name == "event") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_action(\";\n"
|
||||
" html_actions += \"'eventstart');\\\">\";\n"
|
||||
@@ -685,8 +686,8 @@ void cls_webu_html::script_assign_actions()
|
||||
" html_actions += \"'eventend');\\\">\";\n"
|
||||
" html_actions += \"End Event</a>\\n\";\n\n"
|
||||
;
|
||||
} else if ((it->param_name == "pause") &&
|
||||
(it->param_value == "on")) {
|
||||
} else if ((itm->param_name == "pause") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_action(\";\n"
|
||||
" html_actions += \"'pause');\\\">\";\n"
|
||||
@@ -696,43 +697,43 @@ void cls_webu_html::script_assign_actions()
|
||||
" html_actions += \"'unpause');\\\">\";\n"
|
||||
" html_actions += \"Unpause</a>\\n\";\n\n"
|
||||
;
|
||||
} else if ((it->param_name == "camera_add") &&
|
||||
(it->param_value == "on")) {
|
||||
} else if ((itm->param_name == "camera_add") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_reload(\";\n"
|
||||
" html_actions += \"'camera_add');\\\">\";\n"
|
||||
" html_actions += \"Add Camera</a>\\n\";\n\n"
|
||||
;
|
||||
} else if ((it->param_name == "camera_delete") &&
|
||||
(it->param_value == "on")) {
|
||||
} else if ((itm->param_name == "camera_delete") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_reload(\";\n"
|
||||
" html_actions += \"'camera_delete');\\\">\";\n"
|
||||
" html_actions += \"Delete Camera</a>\\n\";\n\n"
|
||||
;
|
||||
} else if ((it->param_name == "config_write") &&
|
||||
(it->param_value == "on")) {
|
||||
} else if ((itm->param_name == "config_write") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_action(\";\n"
|
||||
" html_actions += \"'config_write');\\\">\";\n"
|
||||
" html_actions += \"Save Config</a>\\n\";\n\n"
|
||||
;
|
||||
} else if ((it->param_name == "stop") &&
|
||||
(it->param_value == "on")) {
|
||||
} else if ((itm->param_name == "stop") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_action(\";\n"
|
||||
" html_actions += \"'stop');\\\">\";\n"
|
||||
" html_actions += \"Stop</a>\\n\";\n\n"
|
||||
;
|
||||
} else if ((it->param_name == "restart") &&
|
||||
(it->param_value == "on")) {
|
||||
} else if ((itm->param_name == "restart") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_action(\";\n"
|
||||
" html_actions += \"'restart');\\\">\";\n"
|
||||
" html_actions += \"Start/Restart</a>\\n\";\n\n"
|
||||
;
|
||||
} else if ((it->param_name == "action_user") &&
|
||||
(it->param_value == "on")) {
|
||||
} else if ((itm->param_name == "action_user") &&
|
||||
(itm->param_value == "on")) {
|
||||
webua->resp_page +=
|
||||
" html_actions += \"<a onclick=\\\"send_action(\";\n"
|
||||
" html_actions += \"'action_user');\\\">\";\n"
|
||||
|
||||
@@ -244,12 +244,10 @@ void cls_webu_json::movies_list()
|
||||
char fmt[PATH_MAX];
|
||||
lst_movies movielist;
|
||||
it_movies m_it;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "movies") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "movies") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Movies via webcontrol disabled");
|
||||
webua->resp_page += "{\"count\" : 0} ";
|
||||
webua->resp_page += ",\"device_id\" : ";
|
||||
|
||||
@@ -370,8 +370,7 @@ mhdrslt cls_webu_mpegts::main()
|
||||
{
|
||||
mhdrslt retcd;
|
||||
struct MHD_Response *response;
|
||||
p_lst *lst = &webu->wb_headers->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
if (open_mpegts() < 0 ) {
|
||||
MOTPLS_LOG(ERR, TYPE_STREAM, NO_ERRNO, _("Unable to open mpegts"));
|
||||
@@ -387,10 +386,11 @@ mhdrslt cls_webu_mpegts::main()
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
if (webu->wb_headers->params_count > 0) {
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (webu->wb_headers->params_cnt > 0) {
|
||||
for (indx=0;indx<webu->wb_headers->params_cnt;indx++) {
|
||||
MHD_add_response_header (response
|
||||
, it->param_name.c_str(), it->param_value.c_str());
|
||||
, webu->wb_headers->params_array[indx].param_name.c_str()
|
||||
, webu->wb_headers->params_array[indx].param_value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,10 @@ mhdrslt webup_iterate_post (void *ptr, enum MHD_ValueKind kind
|
||||
void cls_webu_post::cam_add()
|
||||
{
|
||||
int indx, maxcnt;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "camera_add") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "camera_add") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Camera add action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -91,12 +89,10 @@ void cls_webu_post::cam_add()
|
||||
void cls_webu_post::cam_delete()
|
||||
{
|
||||
int indx, maxcnt;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "camera_delete") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "camera_delete") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Camera delete action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -177,12 +173,10 @@ void cls_webu_post::parse_cmd()
|
||||
void cls_webu_post::action_eventend()
|
||||
{
|
||||
int indx;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "event") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "event") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Event end action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -205,12 +199,10 @@ void cls_webu_post::action_eventend()
|
||||
void cls_webu_post::action_eventstart()
|
||||
{
|
||||
int indx;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "event") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "event") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Event start action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -219,6 +211,7 @@ void cls_webu_post::action_eventstart()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (webua->device_id == 0) {
|
||||
for (indx=0; indx<app->cam_cnt; indx++) {
|
||||
app->cam_list[indx]->event_user = true;
|
||||
@@ -233,12 +226,10 @@ void cls_webu_post::action_eventstart()
|
||||
void cls_webu_post::action_snapshot()
|
||||
{
|
||||
int indx;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "snapshot") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "snapshot") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Snapshot action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -247,6 +238,7 @@ void cls_webu_post::action_snapshot()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (webua->device_id == 0) {
|
||||
for (indx=0; indx<app->cam_cnt; indx++) {
|
||||
app->cam_list[indx]->action_snapshot = true;
|
||||
@@ -261,12 +253,10 @@ void cls_webu_post::action_snapshot()
|
||||
void cls_webu_post::action_pause()
|
||||
{
|
||||
int indx;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "pause") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "pause") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Pause action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -289,12 +279,10 @@ void cls_webu_post::action_pause()
|
||||
void cls_webu_post::action_unpause()
|
||||
{
|
||||
int indx;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "pause") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "pause") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Pause action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -317,12 +305,10 @@ void cls_webu_post::action_unpause()
|
||||
void cls_webu_post::action_restart()
|
||||
{
|
||||
int indx;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "restart") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "restart") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Restart action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -330,6 +316,7 @@ void cls_webu_post::action_restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (webua->device_id == 0) {
|
||||
MOTPLS_LOG(NTC, TYPE_STREAM, NO_ERRNO, _("Restarting all cameras"));
|
||||
for (indx=0; indx<app->cam_cnt; indx++) {
|
||||
@@ -347,12 +334,10 @@ void cls_webu_post::action_restart()
|
||||
void cls_webu_post::action_stop()
|
||||
{
|
||||
int indx;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "stop") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "stop") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Stop action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -360,6 +345,7 @@ void cls_webu_post::action_stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (webua->device_id == 0) {
|
||||
for (indx=0; indx<app->cam_cnt; indx++) {
|
||||
MOTPLS_LOG(NTC, TYPE_STREAM, NO_ERRNO
|
||||
@@ -388,12 +374,10 @@ void cls_webu_post::action_user()
|
||||
int indx, indx2;
|
||||
cls_camera *cam;
|
||||
std::string tmp;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "action_user") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "action_user") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "User action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -454,12 +438,11 @@ void cls_webu_post::action_user()
|
||||
/* Process the write config action */
|
||||
void cls_webu_post::write_config()
|
||||
{
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "config_write") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "config_write") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Config write action disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -578,13 +561,11 @@ void cls_webu_post::config()
|
||||
{
|
||||
int indx, indx2;
|
||||
std::string tmpname;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "config") {
|
||||
if (it->param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Config save actions disabled");
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "config") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "Config save action disabled");
|
||||
return;
|
||||
} else {
|
||||
break;
|
||||
@@ -664,16 +645,15 @@ void cls_webu_post::config()
|
||||
void cls_webu_post::ptz()
|
||||
{
|
||||
cls_camera *cam;
|
||||
p_lst *lst = &webu->wb_actions->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
if (webua->camindx == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (it->param_name == "ptz") {
|
||||
if (it->param_value == "off") {
|
||||
for (indx=0;indx<webu->wb_actions->params_cnt;indx++) {
|
||||
if (webu->wb_actions->params_array[indx].param_name == "ptz") {
|
||||
if (webu->wb_actions->params_array[indx].param_value == "off") {
|
||||
MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, "PTZ actions disabled");
|
||||
return;
|
||||
} else {
|
||||
@@ -681,6 +661,7 @@ void cls_webu_post::ptz()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cam = app->cam_list[webua->camindx];
|
||||
|
||||
if ((post_cmd == "pan_left") &&
|
||||
|
||||
@@ -435,8 +435,7 @@ mhdrslt cls_webu_stream::stream_mjpeg()
|
||||
{
|
||||
mhdrslt retcd;
|
||||
struct MHD_Response *response;
|
||||
p_lst *lst = &webu->wb_headers->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &webuc->time_last);
|
||||
|
||||
@@ -447,10 +446,11 @@ mhdrslt cls_webu_stream::stream_mjpeg()
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
if (webu->wb_headers->params_count > 0) {
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (webu->wb_headers->params_cnt > 0) {
|
||||
for (indx=0;indx<webu->wb_headers->params_cnt;indx++) {
|
||||
MHD_add_response_header (response
|
||||
, it->param_name.c_str(), it->param_value.c_str());
|
||||
, webu->wb_headers->params_array[indx].param_name.c_str()
|
||||
, webu->wb_headers->params_array[indx].param_value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,8 +469,7 @@ mhdrslt cls_webu_stream::stream_static()
|
||||
mhdrslt retcd;
|
||||
struct MHD_Response *response;
|
||||
char resp_used[20];
|
||||
p_lst *lst = &webu->wb_headers->params_array;
|
||||
p_it it;
|
||||
int indx;
|
||||
|
||||
if (webuc->resp_used == 0) {
|
||||
MOTPLS_LOG(ERR, TYPE_STREAM, NO_ERRNO, _("Could not get image to stream."));
|
||||
@@ -485,10 +484,11 @@ mhdrslt cls_webu_stream::stream_static()
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
if (webu->wb_headers->params_count > 0) {
|
||||
for (it = lst->begin(); it != lst->end(); it++) {
|
||||
if (webu->wb_headers->params_cnt > 0) {
|
||||
for (indx=0;indx<webu->wb_headers->params_cnt;indx++) {
|
||||
MHD_add_response_header (response
|
||||
, it->param_name.c_str(), it->param_value.c_str());
|
||||
, webu->wb_headers->params_array[indx].param_name.c_str()
|
||||
, webu->wb_headers->params_array[indx].param_value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user