mirror of
https://github.com/Motion-Project/motion.git
synced 2026-05-14 09:44:17 -04:00
Put defaults and system configuration under motapp structure
This commit is contained in:
@@ -1193,7 +1193,7 @@ void alg_stddev(ctx_dev *cam)
|
||||
void alg_diff(ctx_dev *cam)
|
||||
{
|
||||
|
||||
if (cam->detecting_motion || cam->motapp->setup_mode) {
|
||||
if (cam->detecting_motion || cam->motapp->conf->setup_mode) {
|
||||
alg_diff_standard(cam);
|
||||
} else {
|
||||
if (alg_diff_fast(cam)) {
|
||||
|
||||
@@ -50,9 +50,9 @@ static void algsec_image_show(ctx_dev *cam, Mat &mat_dst)
|
||||
* need to expend the CPU to compress and load the secondary images */
|
||||
if ((cam->stream.secondary.cnct_count >0) ||
|
||||
(cam->imgs.size_secondary == 0) ||
|
||||
(cam->motapp->log_level >= DBG)) {
|
||||
(cam->motapp->conf->log_level >= DBG)) {
|
||||
|
||||
if ((cam->motapp->log_level >= DBG) &&
|
||||
if ((cam->motapp->conf->log_level >= DBG) &&
|
||||
(algmdl->isdetected == true)) {
|
||||
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "Saved detected image: %s%s%s%s"
|
||||
, cam->conf->target_dir.c_str()
|
||||
@@ -89,7 +89,7 @@ static void algsec_image_label(ctx_dev *cam, Mat &mat_dst
|
||||
try {
|
||||
algmdl->isdetected = false;
|
||||
|
||||
if (cam->motapp->log_level >= DBG) {
|
||||
if (cam->motapp->conf->log_level >= DBG) {
|
||||
imwrite(cam->conf->target_dir + "/src_" + algmdl->method + ".jpg"
|
||||
, mat_dst);
|
||||
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "Saved source image: %s%s%s%s"
|
||||
@@ -148,7 +148,7 @@ static void algsec_image_label(ctx_dev *cam, Mat &mat_dst
|
||||
try {
|
||||
algmdl->isdetected = false;
|
||||
|
||||
if (cam->motapp->log_level >= DBG) {
|
||||
if (cam->motapp->conf->log_level >= DBG) {
|
||||
imwrite(cam->conf->target_dir + "/src_" + algmdl->method + ".jpg"
|
||||
, mat_dst);
|
||||
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "Saved source image: %s%s%s%s"
|
||||
|
||||
2562
src/conf.cpp
2562
src/conf.cpp
File diff suppressed because it is too large
Load Diff
43
src/conf.hpp
43
src/conf.hpp
@@ -22,7 +22,21 @@
|
||||
#define _INCLUDE_CONF_HPP_
|
||||
|
||||
struct ctx_config {
|
||||
|
||||
/* Overall system configuration parameters */
|
||||
std::string conf_filename;
|
||||
bool from_conf_dir;
|
||||
|
||||
/* Overall application parameters */
|
||||
bool daemon;
|
||||
std::string pid_file;
|
||||
std::string log_file;
|
||||
std::string log_type_str;
|
||||
int log_level;
|
||||
int log_type;
|
||||
bool setup_mode;
|
||||
bool native_language;
|
||||
|
||||
std::string camera_name;
|
||||
int camera_id;
|
||||
std::string camera_dir;
|
||||
@@ -240,31 +254,18 @@
|
||||
extern struct ctx_parm config_parms[];
|
||||
extern struct ctx_parm_depr config_parms_depr[];
|
||||
|
||||
void conf_init_app(ctx_motapp *motapp, int argc, char* argv[]);
|
||||
void conf_init_cams(ctx_motapp *motapp);
|
||||
void conf_init(ctx_motapp *motapp);
|
||||
void conf_deinit(ctx_motapp *motapp);
|
||||
void conf_parms_log(ctx_dev **cam_list);
|
||||
void conf_parms_log(ctx_motapp *motapp);
|
||||
void conf_parms_write(ctx_motapp *motapp);
|
||||
void conf_camera_add(ctx_motapp *motapp);
|
||||
|
||||
void conf_edit_set(ctx_motapp *motapp, bool ismotapp, int threadnbr
|
||||
,std::string parm_nm, std::string parm_val);
|
||||
void conf_edit_set(ctx_motapp *motapp, bool ismotapp, int threadnbr
|
||||
,const char *parm_nm_chr, std::string parm_val);
|
||||
void conf_edit_set(ctx_motapp *motapp, bool ismotapp, int threadnbr
|
||||
,std::string parm_nm, const char *parm_val_chr);
|
||||
void conf_edit_set(ctx_motapp *motapp, bool ismotapp, int threadnbr
|
||||
,const char *parm_nm_chr, const char *parm_val_chr);
|
||||
|
||||
void conf_edit_get(ctx_dev *cam, std::string parm_nm
|
||||
, std::string &parm_val, enum PARM_CAT parm_cat);
|
||||
void conf_edit_get(ctx_dev *cam, std::string parm_nm
|
||||
, char *parm_chr, enum PARM_CAT parm_cat);
|
||||
|
||||
void conf_edit_list(ctx_dev *cam, std::string parm_nm
|
||||
, std::string &parm_val, enum PARM_CAT parm_cat);
|
||||
void conf_edit_list(ctx_dev *cam, std::string parm_nm
|
||||
, char *parm_chr, enum PARM_CAT parm_cat);
|
||||
void conf_edit_set(ctx_config *conf, std::string parm_nm
|
||||
, std::string parm_val);
|
||||
void conf_edit_get(ctx_config *conf, std::string parm_nm
|
||||
, std::string &parm_val, enum PARM_CAT parm_cat);
|
||||
void conf_edit_list(ctx_config *conf, std::string parm_nm
|
||||
, std::string &parm_val, enum PARM_CAT parm_cat);
|
||||
|
||||
std::string conf_type_desc(enum PARM_TYP ptype);
|
||||
std::string conf_cat_desc(enum PARM_CAT pcat, bool shrt);
|
||||
|
||||
14
src/dbse.cpp
14
src/dbse.cpp
@@ -1144,13 +1144,13 @@ static void dbse_pgsql_movlst(ctx_motapp *motapp, int camera_id)
|
||||
void dbse_init(ctx_motapp *motapp)
|
||||
{
|
||||
motapp->dbse = new ctx_dbse;
|
||||
motapp->dbse->database_busy_timeout = motapp->cam_list[0]->conf->database_busy_timeout;
|
||||
motapp->dbse->database_dbname = motapp->cam_list[0]->conf->database_dbname;
|
||||
motapp->dbse->database_host = motapp->cam_list[0]->conf->database_host;
|
||||
motapp->dbse->database_password = motapp->cam_list[0]->conf->database_password;
|
||||
motapp->dbse->database_port = motapp->cam_list[0]->conf->database_port;
|
||||
motapp->dbse->database_type = motapp->cam_list[0]->conf->database_type;
|
||||
motapp->dbse->database_user = motapp->cam_list[0]->conf->database_user;
|
||||
motapp->dbse->database_busy_timeout = motapp->conf->database_busy_timeout;
|
||||
motapp->dbse->database_dbname = motapp->conf->database_dbname;
|
||||
motapp->dbse->database_host = motapp->conf->database_host;
|
||||
motapp->dbse->database_password = motapp->conf->database_password;
|
||||
motapp->dbse->database_port = motapp->conf->database_port;
|
||||
motapp->dbse->database_type = motapp->conf->database_type;
|
||||
motapp->dbse->database_user = motapp->conf->database_user;
|
||||
motapp->dbse->movie_cnt = 0;
|
||||
motapp->dbse->movie_list = NULL;
|
||||
motapp->dbse->cols_cnt = 0;
|
||||
|
||||
@@ -262,29 +262,30 @@ void motion_log(int level, int type, int errno_flag,int fncname, const char *fmt
|
||||
void log_init(ctx_motapp *motapp)
|
||||
{
|
||||
|
||||
if ((motapp->log_level > ALL) ||
|
||||
(motapp->log_level == 0)) {
|
||||
motapp->log_level = LEVEL_DEFAULT;
|
||||
if ((motapp->conf->log_level > ALL) ||
|
||||
(motapp->conf->log_level == 0)) {
|
||||
motapp->conf->log_level = LEVEL_DEFAULT;
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO
|
||||
,_("Using default log level (%s) (%d)")
|
||||
,log_level_str[motapp->log_level]
|
||||
,motapp->log_level);
|
||||
,log_level_str[motapp->conf->log_level]
|
||||
,motapp->conf->log_level);
|
||||
}
|
||||
|
||||
|
||||
if (motapp->log_file != "") {
|
||||
if (motapp->log_file != "syslog") {
|
||||
if (motapp->conf->log_file != "") {
|
||||
if (motapp->conf->log_file != "syslog") {
|
||||
log_set_mode(LOGMODE_FILE);
|
||||
log_set_logfile(motapp->log_file.c_str());
|
||||
log_set_logfile(motapp->conf->log_file.c_str());
|
||||
if (logfile) {
|
||||
log_set_mode(LOGMODE_SYSLOG);
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO
|
||||
,_("Logging to file (%s)"),motapp->log_file.c_str());
|
||||
, _("Logging to file (%s)")
|
||||
, motapp->conf->log_file.c_str());
|
||||
log_set_mode(LOGMODE_FILE);
|
||||
} else {
|
||||
MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO
|
||||
,_("Exit motion, cannot create log file %s")
|
||||
,motapp->log_file.c_str());
|
||||
, _("Exit motion, cannot create log file %s")
|
||||
, motapp->conf->log_file.c_str());
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
@@ -295,13 +296,15 @@ void log_init(ctx_motapp *motapp)
|
||||
}
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "MotionPlus %s started",VERSION);
|
||||
|
||||
motapp->log_type = log_get_type(motapp->log_type_str.c_str());
|
||||
motapp->conf->log_type = log_get_type(motapp->conf->log_type_str.c_str());
|
||||
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Using log type (%s) log level (%s)"),
|
||||
log_type_str[motapp->log_type], log_level_str[motapp->log_level]);
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO
|
||||
, _("Using log type (%s) log level (%s)")
|
||||
, log_type_str[motapp->conf->log_type]
|
||||
, log_level_str[motapp->conf->log_level]);
|
||||
|
||||
log_set_level(motapp->log_level);
|
||||
log_type = motapp->log_type;
|
||||
log_set_level(motapp->conf->log_level);
|
||||
log_type = motapp->conf->log_type;
|
||||
|
||||
}
|
||||
|
||||
@@ -309,8 +312,9 @@ void log_deinit(ctx_motapp *motapp)
|
||||
{
|
||||
|
||||
if (logfile != NULL) {
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Closing logfile (%s)."),
|
||||
motapp->log_file.c_str());
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO
|
||||
, _("Closing logfile (%s).")
|
||||
, motapp->conf->log_file.c_str());
|
||||
myfclose(logfile);
|
||||
log_set_mode(LOGMODE_NONE);
|
||||
logfile = NULL;
|
||||
@@ -318,7 +322,8 @@ void log_deinit(ctx_motapp *motapp)
|
||||
|
||||
}
|
||||
|
||||
void log_set_motapp(ctx_motapp *motapp)
|
||||
/* Set the static motapp pointer in logger module */
|
||||
void log_init_app(ctx_motapp *motapp)
|
||||
{
|
||||
/* Need better design to avoid the need to do this. Extern motapp to whole app? */
|
||||
log_motapp = motapp; /* Set our static pointer used for locking parms mutex*/
|
||||
|
||||
@@ -60,6 +60,6 @@
|
||||
void log_deinit(ctx_motapp *motapp);
|
||||
void log_set_level(int new_level);
|
||||
void log_set_type(const char *new_logtype);
|
||||
void log_set_motapp(ctx_motapp *motapp);
|
||||
void log_init_app(ctx_motapp *motapp);
|
||||
|
||||
#endif /* _INCLUDE_LOGGER_HPP_ */
|
||||
|
||||
@@ -136,7 +136,7 @@ static void mlp_ring_process(ctx_dev *cam)
|
||||
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->motapp->log_level >= DBG) {
|
||||
if (cam->motapp->conf->log_level >= DBG) {
|
||||
mlp_ring_process_debug(cam);
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ static void mlp_detected(ctx_dev *cam, ctx_image_data *img)
|
||||
mlp_detected_trigger(cam, img);
|
||||
|
||||
if (img->shot < conf->framerate) {
|
||||
if (conf->stream_motion && !cam->motapp->setup_mode && img->shot != 1) {
|
||||
if (conf->stream_motion && !cam->motapp->conf->setup_mode && img->shot != 1) {
|
||||
event(cam, EVENT_STREAM, img, NULL, NULL, &img->imgts);
|
||||
}
|
||||
if (conf->picture_output_motion != "off") {
|
||||
@@ -953,7 +953,7 @@ static void mlp_overlay(ctx_dev *cam)
|
||||
if (cam->smartmask_speed &&
|
||||
((cam->conf->picture_output_motion != "off") ||
|
||||
cam->conf->movie_output_motion ||
|
||||
cam->motapp->setup_mode ||
|
||||
cam->motapp->conf->setup_mode ||
|
||||
(cam->stream.motion.cnct_count > 0))) {
|
||||
draw_smartmask(cam, cam->imgs.image_motion.image_norm);
|
||||
}
|
||||
@@ -961,7 +961,7 @@ static void mlp_overlay(ctx_dev *cam)
|
||||
if (cam->imgs.largest_label &&
|
||||
((cam->conf->picture_output_motion != "off") ||
|
||||
cam->conf->movie_output_motion ||
|
||||
cam->motapp->setup_mode ||
|
||||
cam->motapp->conf->setup_mode ||
|
||||
(cam->stream.motion.cnct_count > 0))) {
|
||||
draw_largest_label(cam, cam->imgs.image_motion.image_norm);
|
||||
}
|
||||
@@ -969,7 +969,7 @@ static void mlp_overlay(ctx_dev *cam)
|
||||
if (cam->imgs.mask &&
|
||||
((cam->conf->picture_output_motion != "off") ||
|
||||
cam->conf->movie_output_motion ||
|
||||
cam->motapp->setup_mode ||
|
||||
cam->motapp->conf->setup_mode ||
|
||||
(cam->stream.motion.cnct_count > 0))) {
|
||||
draw_fixed_mask(cam, cam->imgs.image_motion.image_norm);
|
||||
}
|
||||
@@ -984,7 +984,7 @@ static void mlp_overlay(ctx_dev *cam)
|
||||
cam->imgs.width - 10, 10, tmp, cam->text_scale);
|
||||
}
|
||||
|
||||
if (cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0)) {
|
||||
if (cam->motapp->conf->setup_mode || (cam->stream.motion.cnct_count > 0)) {
|
||||
sprintf(tmp, "D:%5d L:%3d N:%3d", cam->current_image->diffs,
|
||||
cam->current_image->total_labels, cam->noise);
|
||||
draw_text(cam->imgs.image_motion.image_norm, cam->imgs.width, cam->imgs.height,
|
||||
@@ -1191,7 +1191,7 @@ static void mlp_actions(ctx_dev *cam)
|
||||
/* Process for setup mode */
|
||||
static void mlp_setupmode(ctx_dev *cam)
|
||||
{
|
||||
if (cam->motapp->setup_mode) {
|
||||
if (cam->motapp->conf->setup_mode) {
|
||||
char msg[1024] = "\0";
|
||||
char part[100];
|
||||
|
||||
@@ -1287,7 +1287,7 @@ static void mlp_timelapse(ctx_dev *cam)
|
||||
/* send images to loopback device*/
|
||||
static void mlp_loopback(ctx_dev *cam)
|
||||
{
|
||||
if (cam->motapp->setup_mode) {
|
||||
if (cam->motapp->conf->setup_mode) {
|
||||
event(cam, EVENT_IMAGE, &cam->imgs.image_motion, NULL, &cam->pipe, &cam->current_image->imgts);
|
||||
event(cam, EVENT_STREAM, &cam->imgs.image_motion, NULL, NULL, &cam->current_image->imgts);
|
||||
} else {
|
||||
@@ -1370,8 +1370,8 @@ static void mlp_parmsupdate(ctx_dev *cam)
|
||||
}
|
||||
|
||||
if (cam->motapp->parms_changed) {
|
||||
log_set_level(cam->motapp->log_level);
|
||||
log_set_type(cam->motapp->log_type_str.c_str());
|
||||
log_set_level(cam->motapp->conf->log_level);
|
||||
log_set_type(cam->motapp->conf->log_type_str.c_str());
|
||||
cam->motapp->parms_changed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,18 +168,18 @@ static void motion_pid_write(ctx_motapp *motapp)
|
||||
{
|
||||
FILE *pidf = NULL;
|
||||
|
||||
if (motapp->pid_file != "") {
|
||||
pidf = myfopen(motapp->pid_file.c_str(), "w+e");
|
||||
if (motapp->conf->pid_file != "") {
|
||||
pidf = myfopen(motapp->conf->pid_file.c_str(), "w+e");
|
||||
if (pidf) {
|
||||
(void)fprintf(pidf, "%d\n", getpid());
|
||||
myfclose(pidf);
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO
|
||||
,_("Created process id file %s. Process ID is %d")
|
||||
,motapp->pid_file.c_str(), getpid());
|
||||
,motapp->conf->pid_file.c_str(), getpid());
|
||||
} else {
|
||||
MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO
|
||||
, _("Cannot create process id file (pid file) %s")
|
||||
, motapp->pid_file.c_str());
|
||||
, motapp->conf->pid_file.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,9 +188,9 @@ static void motion_pid_write(ctx_motapp *motapp)
|
||||
static void motion_pid_remove(ctx_motapp *motapp)
|
||||
{
|
||||
|
||||
if ((motapp->pid_file != "") &&
|
||||
if ((motapp->conf->pid_file != "") &&
|
||||
(motapp->restart_all == false)) {
|
||||
if (!unlink(motapp->pid_file.c_str())) {
|
||||
if (!unlink(motapp->conf->pid_file.c_str())) {
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Removed process id file (pid file)."));
|
||||
} else{
|
||||
MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, _("Error removing pid file"));
|
||||
@@ -309,7 +309,7 @@ static void motion_camera_ids(ctx_dev **cam_list)
|
||||
,_("Camara IDs are not unique or have values over 32,000. Falling back to thread numbers"));
|
||||
indx = 0;
|
||||
while (cam_list[indx] != NULL){
|
||||
cam_list[indx]->camera_id = indx;
|
||||
cam_list[indx]->camera_id = indx+1;
|
||||
indx++;
|
||||
}
|
||||
}
|
||||
@@ -369,33 +369,31 @@ static void motion_ntc(void)
|
||||
}
|
||||
|
||||
/** Initialize upon start up or restart */
|
||||
static void motion_startup(ctx_motapp *motapp, int daemonize, int argc, char *argv[])
|
||||
static void motion_startup(ctx_motapp *motapp, int daemonize)
|
||||
{
|
||||
|
||||
log_set_motapp(motapp); /* This is needed prior to any function possibly calling motion_log*/
|
||||
log_init_app(motapp); /* This is needed prior to any function possibly calling motion_log*/
|
||||
|
||||
conf_init_app(motapp, argc, argv);
|
||||
conf_init(motapp);
|
||||
|
||||
log_init(motapp);
|
||||
|
||||
conf_init_cams(motapp);
|
||||
|
||||
mytranslate_init();
|
||||
|
||||
mytranslate_text("",motapp->native_language);
|
||||
mytranslate_text("",motapp->conf->native_language);
|
||||
|
||||
if (daemonize) {
|
||||
if (motapp->daemon && motapp->setup_mode == 0) {
|
||||
if (motapp->conf->daemon && motapp->conf->setup_mode == 0) {
|
||||
motion_daemon();
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("MotionPlus running as daemon process"));
|
||||
}
|
||||
}
|
||||
|
||||
if (motapp->setup_mode) {
|
||||
if (motapp->conf->setup_mode) {
|
||||
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO,_("MotionPlus running in setup mode."));
|
||||
}
|
||||
|
||||
conf_parms_log(motapp->cam_list);
|
||||
conf_parms_log(motapp);
|
||||
|
||||
motion_pid_write(motapp);
|
||||
|
||||
@@ -433,7 +431,7 @@ static void motion_start_thread(ctx_motapp *motapp, int indx)
|
||||
|
||||
}
|
||||
|
||||
static void motion_restart(ctx_motapp *motapp, int argc, char **argv)
|
||||
static void motion_restart(ctx_motapp *motapp)
|
||||
{
|
||||
|
||||
MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO,_("Restarting MotionPlus."));
|
||||
@@ -442,7 +440,7 @@ static void motion_restart(ctx_motapp *motapp, int argc, char **argv)
|
||||
|
||||
SLEEP(2, 0);
|
||||
|
||||
motion_startup(motapp, false, argc, argv);
|
||||
motion_startup(motapp, false);
|
||||
MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO,_("MotionPlus restarted"));
|
||||
|
||||
motapp->restart_all = false;
|
||||
@@ -468,7 +466,7 @@ static void motion_watchdog(ctx_motapp *motapp, int camindx)
|
||||
, motapp->cam_list[camindx]->camera_id);
|
||||
|
||||
/* Shut down all the cameras */
|
||||
indx = 1;
|
||||
indx = 0;
|
||||
while (motapp->cam_list[indx] != NULL) {
|
||||
pthread_mutex_unlock(&motapp->mutex_camlst);
|
||||
pthread_mutex_unlock(&motapp->mutex_parms);
|
||||
@@ -506,7 +504,7 @@ static void motion_watchdog(ctx_motapp *motapp, int camindx)
|
||||
* we WILL have to leak memory because the freeing/deinit
|
||||
* processes could lock this thread which would stop everything.
|
||||
*/
|
||||
indx = 1;
|
||||
indx = 0;
|
||||
while (motapp->cam_list[indx] != NULL) {
|
||||
if (motapp->cam_list[indx]->netcam != NULL) {
|
||||
if (motapp->cam_list[indx]->netcam->handler_finished == false) {
|
||||
@@ -547,7 +545,7 @@ static int motion_check_threadcount(ctx_motapp *motapp)
|
||||
|
||||
thrdcnt = 0;
|
||||
|
||||
for (indx = (motapp->cam_list[1] != NULL ? 1 : 0); motapp->cam_list[indx]; indx++) {
|
||||
for (indx=0; indx<motapp->cam_cnt; indx++) {
|
||||
if (motapp->cam_list[indx]->running_cam || motapp->cam_list[indx]->restart_cam) {
|
||||
thrdcnt++;
|
||||
}
|
||||
@@ -567,44 +565,42 @@ static int motion_check_threadcount(ctx_motapp *motapp)
|
||||
|
||||
}
|
||||
|
||||
static void motion_init(ctx_motapp *motapp)
|
||||
static void motion_init(ctx_motapp *motapp, int argc, char *argv[])
|
||||
{
|
||||
motapp->argc = argc;
|
||||
motapp->argv = argv;
|
||||
|
||||
motapp->cam_list = NULL;
|
||||
pthread_mutex_init(&motapp->global_lock, NULL);
|
||||
pthread_mutex_init(&motapp->mutex_parms, NULL);
|
||||
pthread_mutex_init(&motapp->mutex_camlst, NULL);
|
||||
pthread_mutex_init(&motapp->mutex_post, NULL);
|
||||
motapp->cam_list = (ctx_dev **)mymalloc(sizeof(ctx_dev *));
|
||||
motapp->cam_list[0] = NULL;
|
||||
|
||||
motapp->threads_running = 0;
|
||||
motapp->finish_all = false;
|
||||
motapp->restart_all = false;
|
||||
|
||||
motapp->argc = 0;
|
||||
motapp->argv = NULL;
|
||||
|
||||
motapp->daemon = false;
|
||||
motapp->conf_filename="";
|
||||
motapp->pid_file="";
|
||||
motapp->log_file="";
|
||||
motapp->log_type_str="";
|
||||
motapp->log_level=0;
|
||||
motapp->log_type=0;
|
||||
motapp->setup_mode = false;
|
||||
motapp->parms_changed = false;
|
||||
motapp->pause = false;
|
||||
motapp->native_language = false;
|
||||
|
||||
motapp->cam_add = false;
|
||||
motapp->cam_delete = 0;
|
||||
motapp->cam_cnt = 0;
|
||||
|
||||
motapp->conf = new ctx_config;
|
||||
motapp->dbse = NULL;
|
||||
|
||||
motapp->webcontrol_running = false;
|
||||
motapp->webcontrol_finish = false;
|
||||
motapp->webcontrol_daemon = NULL;
|
||||
motapp->webcontrol_headers = NULL;
|
||||
motapp->webcontrol_actions = NULL;
|
||||
motapp->webcontrol_clients.clear();
|
||||
memset(motapp->webcontrol_digest_rand, 0, sizeof(motapp->webcontrol_digest_rand));
|
||||
|
||||
pthread_key_create(&tls_key_threadnr, NULL);
|
||||
pthread_setspecific(tls_key_threadnr, (void *)(0));
|
||||
|
||||
pthread_mutex_init(&motapp->global_lock, NULL);
|
||||
pthread_mutex_init(&motapp->mutex_parms, NULL);
|
||||
pthread_mutex_init(&motapp->mutex_camlst, NULL);
|
||||
pthread_mutex_init(&motapp->mutex_post, NULL);
|
||||
|
||||
}
|
||||
|
||||
/* Check for whether to add a new cam */
|
||||
@@ -621,7 +617,7 @@ static void motion_cam_add(ctx_motapp *motapp)
|
||||
pthread_mutex_unlock(&motapp->mutex_camlst);
|
||||
|
||||
indx_cam = 0;
|
||||
indx = 0;
|
||||
indx = 1;
|
||||
while (motapp->cam_list[indx_cam] != NULL) {
|
||||
if (indx < motapp->cam_list[indx_cam]->camera_id) {
|
||||
indx = motapp->cam_list[indx_cam]->camera_id;
|
||||
@@ -700,22 +696,22 @@ int main (int argc, char **argv)
|
||||
|
||||
motapp = new ctx_motapp;
|
||||
|
||||
motion_init(motapp);
|
||||
motion_init(motapp, argc, argv);
|
||||
|
||||
setup_signals();
|
||||
|
||||
motion_startup(motapp, true, argc, argv);
|
||||
motion_startup(motapp, true);
|
||||
|
||||
movie_global_init();
|
||||
|
||||
while (true) {
|
||||
|
||||
if (motapp->restart_all) {
|
||||
motion_restart(motapp, argc, argv);
|
||||
motion_restart(motapp);
|
||||
}
|
||||
|
||||
for (indx = motapp->cam_list[1] != NULL ? 1 : 0; motapp->cam_list[indx]; indx++) {
|
||||
motapp->cam_list[indx]->threadnr = indx ? indx : 1;
|
||||
for (indx=0; indx<motapp->cam_cnt; indx++) {
|
||||
motapp->cam_list[indx]->threadnr = indx;
|
||||
motion_start_thread(motapp, indx);
|
||||
}
|
||||
|
||||
@@ -729,7 +725,7 @@ int main (int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
for (indx = (motapp->cam_list[1] != NULL ? 1 : 0); motapp->cam_list[indx]; indx++) {
|
||||
for (indx=0; indx<motapp->cam_cnt; indx++) {
|
||||
/* Check if threads wants to be restarted */
|
||||
if ((motapp->cam_list[indx]->running_cam == false) &&
|
||||
(motapp->cam_list[indx]->restart_cam == true)) {
|
||||
|
||||
@@ -302,8 +302,6 @@ struct ctx_stream {
|
||||
struct ctx_dev {
|
||||
|
||||
ctx_motapp *motapp;
|
||||
char conf_filename[PATH_MAX];
|
||||
bool from_conf_dir;
|
||||
int threadnr;
|
||||
pthread_t thread_id;
|
||||
|
||||
@@ -417,17 +415,9 @@ struct ctx_motapp {
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
bool daemon;
|
||||
std::string conf_filename;
|
||||
std::string pid_file;
|
||||
std::string log_file;
|
||||
std::string log_type_str;
|
||||
int log_level;
|
||||
int log_type;
|
||||
bool setup_mode;
|
||||
bool pause;
|
||||
bool native_language;
|
||||
ctx_config *conf;
|
||||
int cam_cnt;
|
||||
|
||||
volatile int webcontrol_running;
|
||||
volatile int webcontrol_finish;
|
||||
|
||||
19
src/util.cpp
19
src/util.cpp
@@ -102,6 +102,25 @@ void mytrim(std::string &parm)
|
||||
myltrim(parm);
|
||||
}
|
||||
|
||||
/* Remove surrounding quotes */
|
||||
void myunquote(std::string &parm)
|
||||
{
|
||||
size_t plen;
|
||||
|
||||
mytrim(parm);
|
||||
|
||||
plen = parm.length();
|
||||
while ((plen >= 2) &&
|
||||
(((parm.substr(0,1)== "\"") && (parm.substr(plen,1)== "\"")) ||
|
||||
((parm.substr(0,1)== "'") && (parm.substr(plen,1)== "'")))) {
|
||||
|
||||
parm = parm.substr(1, plen-2);
|
||||
plen = parm.length();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Free memory and set the pointer to NULL*/
|
||||
void myfree(void *ptr_addr) {
|
||||
void **ptr = (void **)ptr_addr;
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
void myltrim(std::string &parm);
|
||||
void myrtrim(std::string &parm);
|
||||
void mytrim(std::string &parm);
|
||||
|
||||
void myunquote(std::string &parm);
|
||||
|
||||
AVFrame *myframe_alloc(void);
|
||||
void myframe_free(AVFrame *frame);
|
||||
|
||||
185
src/webu.cpp
185
src/webu.cpp
@@ -35,7 +35,7 @@
|
||||
|
||||
/* Context to pass the parms to functions to start mhd */
|
||||
struct ctx_mhdstart {
|
||||
ctx_motapp *motapp;
|
||||
ctx_motapp *motapp;
|
||||
std::string tls_cert;
|
||||
std::string tls_key;
|
||||
struct MHD_OptionItem *mhd_ops;
|
||||
@@ -49,7 +49,6 @@ struct ctx_mhdstart {
|
||||
/* Set defaults for the webui context */
|
||||
static void webu_context_init(ctx_motapp *motapp, ctx_webui *webui)
|
||||
{
|
||||
int indx;
|
||||
char *tmplang;
|
||||
|
||||
webui->url = "";
|
||||
@@ -79,20 +78,7 @@ static void webu_context_init(ctx_motapp *motapp, ctx_webui *webui)
|
||||
webui->cnct_type = WEBUI_CNCT_UNKNOWN;
|
||||
webui->resp_type = WEBUI_RESP_HTML; /* Default to html response */
|
||||
webui->cnct_method = WEBUI_METHOD_GET;
|
||||
|
||||
/* get the number of cameras and threads */
|
||||
indx = 0;
|
||||
if (webui->motapp->cam_list != NULL) {
|
||||
while (webui->motapp->cam_list[++indx]) {
|
||||
continue;
|
||||
};
|
||||
}
|
||||
webui->cam_threads = indx;
|
||||
|
||||
webui->cam_count = indx;
|
||||
if (indx > 1) {
|
||||
webui->cam_count--;
|
||||
}
|
||||
webui->threadnbr = -1;
|
||||
|
||||
tmplang = setlocale(LC_ALL, NULL);
|
||||
if (tmplang == NULL) {
|
||||
@@ -129,8 +115,9 @@ static void webu_context_free(ctx_webui *webui)
|
||||
/* Edit the parameters specified in the url sent */
|
||||
static void webu_parms_edit(ctx_webui *webui)
|
||||
{
|
||||
int indx, is_nbr;
|
||||
int indx, is_nbr, camera_id;
|
||||
|
||||
camera_id = -1;
|
||||
if (webui->uri_camid.length() > 0) {
|
||||
is_nbr = true;
|
||||
for (indx=0; indx < (int)webui->uri_camid.length(); indx++) {
|
||||
@@ -139,28 +126,15 @@ static void webu_parms_edit(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
if (is_nbr) {
|
||||
webui->threadnbr = atoi(webui->uri_camid.c_str());
|
||||
} else {
|
||||
webui->threadnbr = -1;
|
||||
camera_id = atoi(webui->uri_camid.c_str());
|
||||
}
|
||||
} else {
|
||||
webui->threadnbr = -1;
|
||||
}
|
||||
|
||||
if (webui->threadnbr < 0) {
|
||||
webui->cam = webui->motapp->cam_list[0];
|
||||
webui->threadnbr = 0;
|
||||
} else {
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx] != NULL) {
|
||||
if (webui->motapp->cam_list[indx]->camera_id == webui->threadnbr) {
|
||||
webui->threadnbr = indx;
|
||||
break;
|
||||
}
|
||||
indx++;
|
||||
for (indx=0; indx<webui->motapp->cam_cnt; indx++) {
|
||||
if (webui->motapp->cam_list[indx]->camera_id == camera_id) {
|
||||
webui->threadnbr = indx;
|
||||
webui->cam = webui->motapp->cam_list[indx];
|
||||
}
|
||||
/* This may be null, in which case we will not answer the request */
|
||||
webui->cam = webui->motapp->cam_list[indx];
|
||||
}
|
||||
|
||||
MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO
|
||||
@@ -169,7 +143,6 @@ static void webu_parms_edit(ctx_webui *webui)
|
||||
, webui->uri_cmd1.c_str(), webui->uri_cmd2.c_str()
|
||||
, webui->uri_cmd3.c_str());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Extract the camid and cmds from the url */
|
||||
@@ -196,7 +169,7 @@ static int webu_parseurl(ctx_webui *webui)
|
||||
|
||||
MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO, _("Decoded url: %s"),webui->url.c_str());
|
||||
|
||||
baselen = webui->motapp->cam_list[0]->conf->webcontrol_base_path.length();
|
||||
baselen = webui->motapp->conf->webcontrol_base_path.length();
|
||||
|
||||
if (webui->url.length() < baselen) {
|
||||
return -1;
|
||||
@@ -207,7 +180,7 @@ static int webu_parseurl(ctx_webui *webui)
|
||||
}
|
||||
|
||||
if (webui->url.substr(0, baselen) !=
|
||||
webui->motapp->cam_list[0]->conf->webcontrol_base_path) {
|
||||
webui->motapp->conf->webcontrol_base_path) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -284,7 +257,7 @@ static void webu_clientip(ctx_webui *webui)
|
||||
int is_ipv6;
|
||||
|
||||
is_ipv6 = false;
|
||||
if (webui->motapp->cam_list[0]->conf->webcontrol_ipv6) {
|
||||
if (webui->motapp->conf->webcontrol_ipv6) {
|
||||
is_ipv6 = true;
|
||||
}
|
||||
|
||||
@@ -320,11 +293,11 @@ static void webu_hostname(ctx_webui *webui)
|
||||
hdr = MHD_lookup_connection_value(webui->connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST);
|
||||
if (hdr == NULL) {
|
||||
webui->hostfull = "//localhost:" +
|
||||
std::to_string(webui->motapp->cam_list[0]->conf->webcontrol_port) +
|
||||
webui->motapp->cam_list[0]->conf->webcontrol_base_path;
|
||||
std::to_string(webui->motapp->conf->webcontrol_port) +
|
||||
webui->motapp->conf->webcontrol_base_path;
|
||||
} else {
|
||||
webui->hostfull = "//" + std::string(hdr) +
|
||||
webui->motapp->cam_list[0]->conf->webcontrol_base_path;
|
||||
webui->motapp->conf->webcontrol_base_path;
|
||||
}
|
||||
|
||||
MOTION_LOG(DBG,TYPE_ALL, NO_ERRNO, _("Full Host: %s"), webui->hostfull.c_str());
|
||||
@@ -378,7 +351,7 @@ static void webu_client_connect(ctx_webui *webui)
|
||||
it = webui->motapp->webcontrol_clients.begin();
|
||||
while (it != webui->motapp->webcontrol_clients.end()) {
|
||||
if ((tm_cnct.tv_sec - it->conn_time.tv_sec) >=
|
||||
(webui->cam->conf->webcontrol_lock_minutes*60)) {
|
||||
(webui->motapp->conf->webcontrol_lock_minutes*60)) {
|
||||
it = webui->motapp->webcontrol_clients.erase(it);
|
||||
}
|
||||
it++;
|
||||
@@ -430,15 +403,15 @@ static mhdrslt webu_failauth_check(ctx_webui *webui)
|
||||
while (it != webui->motapp->webcontrol_clients.end()) {
|
||||
if ((it->clientip == webui->clientip) &&
|
||||
((tm_cnct.tv_sec - it->conn_time.tv_sec) <
|
||||
(webui->cam->conf->webcontrol_lock_minutes*60)) &&
|
||||
(webui->motapp->conf->webcontrol_lock_minutes*60)) &&
|
||||
(it->authenticated == false) &&
|
||||
(it->conn_nbr > webui->cam->conf->webcontrol_lock_attempts)) {
|
||||
(it->conn_nbr > webui->motapp->conf->webcontrol_lock_attempts)) {
|
||||
MOTION_LOG(EMG, TYPE_STREAM, NO_ERRNO
|
||||
,_("Ignoring connection from: %s"), webui->clientip.c_str());
|
||||
it->conn_time = tm_cnct;
|
||||
return MHD_NO;
|
||||
} else if ((tm_cnct.tv_sec - it->conn_time.tv_sec) >=
|
||||
(webui->cam->conf->webcontrol_lock_minutes*60)) {
|
||||
(webui->motapp->conf->webcontrol_lock_minutes*60)) {
|
||||
it = webui->motapp->webcontrol_clients.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
@@ -586,19 +559,19 @@ static void webu_mhd_auth_parse(ctx_webui *webui)
|
||||
myfree(&webui->auth_user);
|
||||
myfree(&webui->auth_pass);
|
||||
|
||||
auth_len = webui->motapp->cam_list[0]->conf->webcontrol_authentication.length();
|
||||
col_pos =(char*) strstr(webui->motapp->cam_list[0]->conf->webcontrol_authentication.c_str() ,":");
|
||||
auth_len = webui->motapp->conf->webcontrol_authentication.length();
|
||||
col_pos =(char*) strstr(webui->motapp->conf->webcontrol_authentication.c_str() ,":");
|
||||
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->motapp->cam_list[0]->conf->webcontrol_authentication.c_str());
|
||||
,webui->motapp->conf->webcontrol_authentication.c_str());
|
||||
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->motapp->cam_list[0]->conf->webcontrol_authentication.c_str());
|
||||
,webui->motapp->conf->webcontrol_authentication.c_str());
|
||||
snprintf(webui->auth_pass, strlen(col_pos), "%s", col_pos + 1);
|
||||
}
|
||||
|
||||
@@ -616,9 +589,9 @@ static mhdrslt webu_mhd_auth(ctx_webui *webui)
|
||||
|
||||
snprintf(webui->auth_realm, WEBUI_LEN_PARM, "%s","Motion");
|
||||
|
||||
if (webui->motapp->cam_list[0]->conf->webcontrol_authentication == "") {
|
||||
if (webui->motapp->conf->webcontrol_authentication == "") {
|
||||
webui->authenticated = true;
|
||||
if (webui->motapp->cam_list[0]->conf->webcontrol_auth_method != "none") {
|
||||
if (webui->motapp->conf->webcontrol_auth_method != "none") {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("No webcontrol user:pass provided"));
|
||||
}
|
||||
return MHD_YES;
|
||||
@@ -628,9 +601,9 @@ static mhdrslt webu_mhd_auth(ctx_webui *webui)
|
||||
webu_mhd_auth_parse(webui);
|
||||
}
|
||||
|
||||
if (webui->motapp->cam_list[0]->conf->webcontrol_auth_method == "basic") {
|
||||
if (webui->motapp->conf->webcontrol_auth_method == "basic") {
|
||||
return webu_mhd_basic(webui);
|
||||
} else if (webui->motapp->cam_list[0]->conf->webcontrol_auth_method == "digest") {
|
||||
} else if (webui->motapp->conf->webcontrol_auth_method == "digest") {
|
||||
return webu_mhd_digest(webui);
|
||||
}
|
||||
|
||||
@@ -654,24 +627,23 @@ static mhdrslt webu_mhd_send(ctx_webui *webui)
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
if (webui->cam != NULL) {
|
||||
if (webui->motapp->webcontrol_headers->params_count > 0) {
|
||||
for (indx = 0; indx < webui->motapp->webcontrol_headers->params_count; indx++) {
|
||||
MHD_add_response_header (response
|
||||
, webui->motapp->webcontrol_headers->params_array[indx].param_name
|
||||
, webui->motapp->webcontrol_headers->params_array[indx].param_value
|
||||
);
|
||||
}
|
||||
}
|
||||
if (webui->resp_type == WEBUI_RESP_TEXT) {
|
||||
MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/plain;");
|
||||
} else if (webui->resp_type == WEBUI_RESP_JSON) {
|
||||
MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json;");
|
||||
} else {
|
||||
MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html");
|
||||
if (webui->motapp->webcontrol_headers->params_count > 0) {
|
||||
for (indx = 0; indx < webui->motapp->webcontrol_headers->params_count; indx++) {
|
||||
MHD_add_response_header (response
|
||||
, webui->motapp->webcontrol_headers->params_array[indx].param_name
|
||||
, webui->motapp->webcontrol_headers->params_array[indx].param_value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->resp_type == WEBUI_RESP_TEXT) {
|
||||
MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/plain;");
|
||||
} else if (webui->resp_type == WEBUI_RESP_JSON) {
|
||||
MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json;");
|
||||
} else {
|
||||
MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html");
|
||||
}
|
||||
|
||||
retcd = MHD_queue_response (webui->connection, MHD_HTTP_OK, response);
|
||||
MHD_destroy_response (response);
|
||||
|
||||
@@ -690,7 +662,7 @@ static mhdrslt webu_answer_post(ctx_webui *webui)
|
||||
webu_post_main(webui);
|
||||
pthread_mutex_unlock(&webui->motapp->mutex_post);
|
||||
|
||||
if (webui->motapp->cam_list[0]->conf->webcontrol_interface == "user") {
|
||||
if (webui->motapp->conf->webcontrol_interface == "user") {
|
||||
webu_html_user(webui);
|
||||
} else {
|
||||
webu_html_page(webui);
|
||||
@@ -701,7 +673,7 @@ static mhdrslt webu_answer_post(ctx_webui *webui)
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,"send post page failed");
|
||||
}
|
||||
|
||||
return MHD_YES;
|
||||
return retcd;
|
||||
|
||||
}
|
||||
|
||||
@@ -844,7 +816,7 @@ static mhdrslt webu_answer_get(ctx_webui *webui)
|
||||
|
||||
} else {
|
||||
pthread_mutex_lock(&webui->motapp->mutex_post);
|
||||
if (webui->motapp->cam_list[0]->conf->webcontrol_interface == "user") {
|
||||
if (webui->motapp->conf->webcontrol_interface == "user") {
|
||||
webu_html_user(webui);
|
||||
} else {
|
||||
webu_html_page(webui);
|
||||
@@ -880,17 +852,24 @@ static mhdrslt webu_answer(void *cls, struct MHD_Connection *connection, const c
|
||||
webui->connection = connection;
|
||||
|
||||
/* Throw bad URLS back to user*/
|
||||
if ((webui->cam == NULL) || (webui->url.length() == 0)) {
|
||||
if (webui->url.length() == 0) {
|
||||
webu_html_badreq(webui);
|
||||
retcd = webu_mhd_send(webui);
|
||||
return retcd;
|
||||
}
|
||||
|
||||
if (webui->cam->finish_cam) {
|
||||
if (webui->motapp->finish_all) {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Shutting down camera"));
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
if (webui->cam != NULL) {
|
||||
if (webui->cam->finish_cam) {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Shutting down camera"));
|
||||
return MHD_NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->clientip.length() == 0) {
|
||||
webu_clientip(webui);
|
||||
}
|
||||
@@ -1045,9 +1024,9 @@ static void webu_mhd_features_basic(ctx_mhdstart *mhdst)
|
||||
if (retcd == MHD_YES) {
|
||||
MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO ,_("Basic authentication: available"));
|
||||
} else {
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_auth_method == "basic") {
|
||||
if (mhdst->motapp->conf->webcontrol_auth_method == "basic") {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Basic authentication: disabled"));
|
||||
mhdst->motapp->cam_list[0]->conf->webcontrol_auth_method = "none";
|
||||
mhdst->motapp->conf->webcontrol_auth_method = "none";
|
||||
} else {
|
||||
MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("Basic authentication: disabled"));
|
||||
}
|
||||
@@ -1066,9 +1045,9 @@ static void webu_mhd_features_digest(ctx_mhdstart *mhdst)
|
||||
if (retcd == MHD_YES) {
|
||||
MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO ,_("Digest authentication: available"));
|
||||
} else {
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_auth_method == "digest") {
|
||||
if (mhdst->motapp->conf->webcontrol_auth_method == "digest") {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("Digest authentication: disabled"));
|
||||
mhdst->motapp->cam_list[0]->conf->webcontrol_auth_method = "none";
|
||||
mhdst->motapp->conf->webcontrol_auth_method = "none";
|
||||
} else {
|
||||
MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("Digest authentication: disabled"));
|
||||
}
|
||||
@@ -1104,9 +1083,9 @@ static void webu_mhd_features_ipv6(ctx_mhdstart *mhdst)
|
||||
static void webu_mhd_features_tls(ctx_mhdstart *mhdst)
|
||||
{
|
||||
#if MHD_VERSION < 0x00094400
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_tls) {
|
||||
if (mhdst->motapp->conf->webcontrol_tls) {
|
||||
MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("libmicrohttpd libary too old SSL/TLS disabled"));
|
||||
mhdst->motapp->cam_list[0]->conf->webcontrol_tls = 0;
|
||||
mhdst->motapp->conf->webcontrol_tls = 0;
|
||||
}
|
||||
#else
|
||||
mhdrslt retcd;
|
||||
@@ -1114,9 +1093,9 @@ static void webu_mhd_features_tls(ctx_mhdstart *mhdst)
|
||||
if (retcd == MHD_YES) {
|
||||
MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS: available"));
|
||||
} else {
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_tls) {
|
||||
if (mhdst->motapp->conf->webcontrol_tls) {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS: disabled"));
|
||||
mhdst->motapp->cam_list[0]->conf->webcontrol_tls = 0;
|
||||
mhdst->motapp->conf->webcontrol_tls = 0;
|
||||
} else {
|
||||
MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO ,_("SSL/TLS: disabled"));
|
||||
}
|
||||
@@ -1175,16 +1154,16 @@ static std::string webu_mhd_loadfile(std::string fname)
|
||||
static void webu_mhd_checktls(ctx_mhdstart *mhdst)
|
||||
{
|
||||
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_tls) {
|
||||
if ((mhdst->motapp->cam_list[0]->conf->webcontrol_cert == "") || (mhdst->tls_cert == "")) {
|
||||
if (mhdst->motapp->conf->webcontrol_tls) {
|
||||
if ((mhdst->motapp->conf->webcontrol_cert == "") || (mhdst->tls_cert == "")) {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO
|
||||
,_("SSL/TLS requested but no cert file provided. SSL/TLS disabled"));
|
||||
mhdst->motapp->cam_list[0]->conf->webcontrol_tls = 0;
|
||||
mhdst->motapp->conf->webcontrol_tls = 0;
|
||||
}
|
||||
if ((mhdst->motapp->cam_list[0]->conf->webcontrol_key == "") || (mhdst->tls_key == "")) {
|
||||
if ((mhdst->motapp->conf->webcontrol_key == "") || (mhdst->tls_key == "")) {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO
|
||||
,_("SSL/TLS requested but no key file provided. SSL/TLS disabled"));
|
||||
mhdst->motapp->cam_list[0]->conf->webcontrol_tls = 0;
|
||||
mhdst->motapp->conf->webcontrol_tls = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1212,11 +1191,11 @@ static void webu_mhd_opts_deinit(ctx_mhdstart *mhdst)
|
||||
/* Set the MHD option on acceptable connections */
|
||||
static void webu_mhd_opts_localhost(ctx_mhdstart *mhdst)
|
||||
{
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_localhost) {
|
||||
if (mhdst->motapp->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->motapp->cam_list[0]->conf->webcontrol_port);
|
||||
mhdst->lpbk_ipv6.sin6_port = htons(mhdst->motapp->conf->webcontrol_port);
|
||||
mhdst->lpbk_ipv6.sin6_addr = in6addr_loopback;
|
||||
|
||||
mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_SOCK_ADDR;
|
||||
@@ -1227,7 +1206,7 @@ static void webu_mhd_opts_localhost(ctx_mhdstart *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->motapp->cam_list[0]->conf->webcontrol_port);
|
||||
mhdst->lpbk_ipv4.sin_port = htons(mhdst->motapp->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;
|
||||
@@ -1243,7 +1222,7 @@ static void webu_mhd_opts_localhost(ctx_mhdstart *mhdst)
|
||||
static void webu_mhd_opts_digest(ctx_mhdstart *mhdst)
|
||||
{
|
||||
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_auth_method == "digest") {
|
||||
if (mhdst->motapp->conf->webcontrol_auth_method == "digest") {
|
||||
|
||||
mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_DIGEST_AUTH_RANDOM;
|
||||
mhdst->mhd_ops[mhdst->mhd_opt_nbr].value = sizeof(mhdst->motapp->webcontrol_digest_rand);
|
||||
@@ -1266,7 +1245,7 @@ static void webu_mhd_opts_digest(ctx_mhdstart *mhdst)
|
||||
/* Set the MHD options needed when we want TLS connections */
|
||||
static void webu_mhd_opts_tls(ctx_mhdstart *mhdst)
|
||||
{
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_tls) {
|
||||
if (mhdst->motapp->conf->webcontrol_tls) {
|
||||
|
||||
mhdst->mhd_ops[mhdst->mhd_opt_nbr].option = MHD_OPTION_HTTPS_MEM_CERT;
|
||||
mhdst->mhd_ops[mhdst->mhd_opt_nbr].value = 0;
|
||||
@@ -1314,7 +1293,7 @@ static void webu_mhd_flags(ctx_mhdstart *mhdst)
|
||||
mhdst->mhd_flags = mhdst->mhd_flags | MHD_USE_DUAL_STACK;
|
||||
}
|
||||
|
||||
if (mhdst->motapp->cam_list[0]->conf->webcontrol_tls) {
|
||||
if (mhdst->motapp->conf->webcontrol_tls) {
|
||||
mhdst->mhd_flags = mhdst->mhd_flags | MHD_USE_SSL;
|
||||
}
|
||||
|
||||
@@ -1327,9 +1306,9 @@ static void webu_init_actions(ctx_motapp *motapp)
|
||||
|
||||
motapp->webcontrol_actions = (ctx_params*)mymalloc(sizeof(ctx_params));
|
||||
motapp->webcontrol_actions->update_params = true;
|
||||
util_parms_parse(motapp->webcontrol_actions, motapp->cam_list[0]->conf->webcontrol_actions);
|
||||
util_parms_parse(motapp->webcontrol_actions, motapp->conf->webcontrol_actions);
|
||||
|
||||
if (motapp->cam_list[0]->conf->webcontrol_parms == 0) {
|
||||
if (motapp->conf->webcontrol_parms == 0) {
|
||||
parm_vl = "off";
|
||||
} else {
|
||||
parm_vl = "on";
|
||||
@@ -1358,18 +1337,18 @@ static void webu_init_webcontrol(ctx_motapp *motapp)
|
||||
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO
|
||||
, _("Starting webcontrol on port %d")
|
||||
, motapp->cam_list[0]->conf->webcontrol_port);
|
||||
, motapp->conf->webcontrol_port);
|
||||
|
||||
motapp->webcontrol_headers = (ctx_params*)mymalloc(sizeof(ctx_params));
|
||||
motapp->webcontrol_headers->update_params = true;
|
||||
util_parms_parse(motapp->webcontrol_headers, motapp->cam_list[0]->conf->webcontrol_headers);
|
||||
util_parms_parse(motapp->webcontrol_headers, motapp->conf->webcontrol_headers);
|
||||
|
||||
webu_init_actions(motapp);
|
||||
|
||||
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->conf->webcontrol_cert);
|
||||
mhdst.tls_key = webu_mhd_loadfile(motapp->conf->webcontrol_key);
|
||||
mhdst.motapp = motapp;
|
||||
mhdst.ipv6 = motapp->cam_list[0]->conf->webcontrol_ipv6;
|
||||
mhdst.ipv6 = motapp->conf->webcontrol_ipv6;
|
||||
|
||||
/* Set the rand number for webcontrol digest if needed */
|
||||
srand(time(NULL));
|
||||
@@ -1384,7 +1363,7 @@ static void webu_init_webcontrol(ctx_motapp *motapp)
|
||||
|
||||
motapp->webcontrol_daemon = MHD_start_daemon (
|
||||
mhdst.mhd_flags
|
||||
, motapp->cam_list[0]->conf->webcontrol_port
|
||||
, motapp->conf->webcontrol_port
|
||||
, NULL, NULL
|
||||
, &webu_answer, motapp->cam_list
|
||||
, MHD_OPTION_ARRAY, mhdst.mhd_ops
|
||||
@@ -1396,7 +1375,7 @@ static void webu_init_webcontrol(ctx_motapp *motapp)
|
||||
} else {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO
|
||||
,_("Started webcontrol on port %d")
|
||||
,motapp->cam_list[0]->conf->webcontrol_port);
|
||||
,motapp->conf->webcontrol_port);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -1436,7 +1415,7 @@ void webu_init(ctx_motapp *motapp)
|
||||
motapp->webcontrol_finish = false;
|
||||
|
||||
/* Start the webcontrol */
|
||||
if (motapp->cam_list[0]->conf->webcontrol_port != 0 ) {
|
||||
if (motapp->conf->webcontrol_port != 0 ) {
|
||||
webu_init_webcontrol(motapp);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,6 @@
|
||||
size_t resp_size; /* The allocated size of the response */
|
||||
size_t resp_used; /* The amount of the response page used */
|
||||
|
||||
int cam_count; /* Count of the number of cameras*/
|
||||
int cam_threads; /* Count of the number of camera threads running*/
|
||||
std::string lang; /* Two character abbreviation for locale language*/
|
||||
int threadnbr; /* Thread number provided from the uri */
|
||||
enum WEBUI_CNCT cnct_type; /* Type of connection we are processing */
|
||||
|
||||
@@ -438,12 +438,17 @@ static void webu_html_script_send_action(ctx_webui *webui)
|
||||
" }\n\n"
|
||||
|
||||
" var formData = new FormData();\n"
|
||||
" var camid = pData['cameras'][gIndxCam]['id'];\n"
|
||||
" var camid;\n"
|
||||
" var ans;\n\n"
|
||||
|
||||
" camid = assign_camid();\n\n"
|
||||
|
||||
" if (actval == 'action_user') {\n"
|
||||
" ans = prompt('Enter user parameter');\n"
|
||||
" }\n"
|
||||
" ans = prompt('Enter user parameter');\n"
|
||||
" } else {\n"
|
||||
" ans = '';\n"
|
||||
" }\n\n"
|
||||
|
||||
" formData.append('command', actval);\n"
|
||||
" formData.append('camid', camid);\n"
|
||||
" formData.append('user', ans);\n\n"
|
||||
@@ -462,9 +467,11 @@ static void webu_html_script_send_reload(ctx_webui *webui)
|
||||
" var formData = new FormData();\n"
|
||||
" var request = new XMLHttpRequest();\n"
|
||||
" var xmlhttp = new XMLHttpRequest();\n"
|
||||
" var camid = pData['cameras'][gIndxCam]['id'];\n"
|
||||
" var camid;\n"
|
||||
" var ans;\n\n"
|
||||
|
||||
" camid = assign_camid();\n\n"
|
||||
|
||||
" if (actval == 'camera_delete') {\n"
|
||||
" ans = confirm('Delete camera ' + camid);\n"
|
||||
" if (ans == false) {\n"
|
||||
@@ -475,7 +482,7 @@ static void webu_html_script_send_reload(ctx_webui *webui)
|
||||
" xmlhttp.onreadystatechange = function() {\n"
|
||||
" if (this.readyState == 4 && this.status == 200) {\n"
|
||||
" pData = JSON.parse(this.responseText);\n"
|
||||
" gIndxCam = 0;\n"
|
||||
" gIndxCam = -1;\n"
|
||||
" assign_config_nav();\n"
|
||||
" assign_vals(0);\n"
|
||||
" assign_cams();\n"
|
||||
@@ -512,7 +519,8 @@ static void webu_html_script_dropchange_cam(ctx_webui *webui)
|
||||
" sect.item(indx).selectedIndex =camobj.selectedIndex;\n"
|
||||
" }\n\n"
|
||||
|
||||
" for (indx = 0; indx <= pData['cameras']['count']; indx++) {\n"
|
||||
" gIndxCam = -1;\n"
|
||||
" for (indx = 0; indx < pData['cameras']['count']; indx++) {\n"
|
||||
" if (pData['cameras'][indx]['id'] == camobj.value) {\n"
|
||||
" gIndxCam = indx;\n"
|
||||
" }\n"
|
||||
@@ -548,6 +556,22 @@ static void webu_html_script_config_click(ctx_webui *webui)
|
||||
" }\n\n";
|
||||
}
|
||||
|
||||
/* Create the javascript function assign_camid */
|
||||
static void webu_html_script_assign_camid(ctx_webui *webui)
|
||||
{
|
||||
webui->resp_page +=
|
||||
" function assign_camid() {\n"
|
||||
" if (gIndxCam == -1 ) {\n"
|
||||
" camid = 0;\n"
|
||||
" } else {\n"
|
||||
" camid = pData['cameras'][gIndxCam]['id'];\n"
|
||||
" }\n\n"
|
||||
" return camid; \n"
|
||||
" }\n\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Create the javascript function assign_version */
|
||||
static void webu_html_script_assign_version(ctx_webui *webui)
|
||||
{
|
||||
@@ -565,24 +589,27 @@ static void webu_html_script_assign_cams(ctx_webui *webui)
|
||||
webui->resp_page +=
|
||||
" function assign_cams() {\n"
|
||||
" var camcnt = pData['cameras']['count'];\n"
|
||||
" var indx = 0;\n"
|
||||
" var html_drop = \"\\n\";\n"
|
||||
" var html_nav = \"\\n\";\n\n"
|
||||
" var html_nav = \"\\n\";\n"
|
||||
" var html_mov = \"\\n\";\n\n"
|
||||
" html_drop += \" <select class='cls_drop' \";\n"
|
||||
" html_drop += \" onchange='dropchange_cam(this)' \";\n"
|
||||
" html_drop += \" name='camdrop'>\\n\";\n\n"
|
||||
" for (var indx = 0; indx <= camcnt; indx++) {\n"
|
||||
" for (indx=0; indx<camcnt; indx++) {\n"
|
||||
" if (indx == 0) {\n"
|
||||
" html_nav += \"<a onclick='cams_all_click();'>\";\n"
|
||||
" html_nav += \"All Cameras</a>\\n\";\n"
|
||||
" html_nav += \"<a onclick='cams_scan_click();'>\";\n"
|
||||
" html_nav += \"Scan Cameras</a>\\n\";\n"
|
||||
" } else {\n"
|
||||
" html_nav += \"<a onclick='cams_one_click(\" + indx + \");'>\";\n"
|
||||
" html_nav += pData[\"cameras\"][indx][\"name\"] + \"</a>\\n\";\n"
|
||||
" html_mov += \"<a onclick='movies_click(\" + indx + \");'>\";\n"
|
||||
" html_mov += pData[\"cameras\"][indx][\"name\"] + \"</a>\";\n"
|
||||
" html_nav += \"Scan Cameras</a>\\n\";\n\n"
|
||||
" html_drop += \"<option \";\n"
|
||||
" html_drop += \" value='0'>default\";\n"
|
||||
" html_drop += \"</option>\\n\";\n"
|
||||
" }\n\n"
|
||||
" html_nav += \"<a onclick='cams_one_click(\" + indx + \");'>\";\n"
|
||||
" html_nav += pData[\"cameras\"][indx][\"name\"] + \"</a>\\n\";\n"
|
||||
" html_mov += \"<a onclick='movies_click(\" + indx + \");'>\";\n"
|
||||
" html_mov += pData[\"cameras\"][indx][\"name\"] + \"</a>\";\n"
|
||||
" html_drop += \"<option \";\n"
|
||||
" html_drop += \" value='\"+pData[\"cameras\"][indx][\"id\"]+\"'>\";\n"
|
||||
" html_drop += pData[\"cameras\"][indx][\"name\"];\n"
|
||||
@@ -701,7 +728,13 @@ static void webu_html_script_assign_vals(ctx_webui *webui)
|
||||
{
|
||||
webui->resp_page +=
|
||||
" function assign_vals(camid) {\n"
|
||||
" var pCfg = pData[\"configuration\"][\"cam\"+camid];\n\n"
|
||||
" var pCfg;\n\n"
|
||||
|
||||
" if (camid == 0) {\n"
|
||||
" pCfg = pData[\"configuration\"][\"default\"];\n"
|
||||
" } else {\n"
|
||||
" pCfg = pData[\"configuration\"][\"cam\"+camid];\n"
|
||||
" }\n\n"
|
||||
|
||||
" for (jkey in pCfg) {\n"
|
||||
" if (document.getElementsByName(jkey)[0] != null) {\n"
|
||||
@@ -728,7 +761,7 @@ static void webu_html_script_assign_config_nav(ctx_webui *webui)
|
||||
{
|
||||
webui->resp_page +=
|
||||
" function assign_config_nav() {\n"
|
||||
" var pCfg = pData['configuration']['cam0'];\n"
|
||||
" var pCfg = pData['configuration']['default'];\n"
|
||||
" var pCat = pData['categories'];\n"
|
||||
" var html_nav = \"\\n\";\n\n"
|
||||
|
||||
@@ -748,7 +781,7 @@ static void webu_html_script_assign_config_item(ctx_webui *webui)
|
||||
{
|
||||
webui->resp_page +=
|
||||
" function assign_config_item(jkey) {\n"
|
||||
" var pCfg = pData['configuration']['cam0'];\n"
|
||||
" var pCfg = pData['configuration']['default'];\n"
|
||||
" var html_cfg = \"\";\n"
|
||||
" var indx_lst = 0;\n\n"
|
||||
|
||||
@@ -787,7 +820,7 @@ static void webu_html_script_assign_config_cat(ctx_webui *webui)
|
||||
{
|
||||
webui->resp_page +=
|
||||
" function assign_config_cat(jcat) {\n"
|
||||
" var pCfg = pData['configuration']['cam0'];\n"
|
||||
" var pCfg = pData['configuration']['default'];\n"
|
||||
" var pCat = pData['categories'];\n"
|
||||
" var html_cfg = \"\";\n\n"
|
||||
|
||||
@@ -852,7 +885,7 @@ static void webu_html_script_initform(ctx_webui *webui)
|
||||
" xmlhttp.onreadystatechange = function() {\n"
|
||||
" if (this.readyState == 4 && this.status == 200) {\n"
|
||||
" pData = JSON.parse(this.responseText);\n"
|
||||
" gIndxCam = 0;\n"
|
||||
" gIndxCam = -1;\n"
|
||||
" gGetImgs = 1;\n"
|
||||
" gIndxScan = -1;\n\n"
|
||||
|
||||
@@ -900,10 +933,7 @@ static void webu_html_script_display_config(ctx_webui *webui)
|
||||
" } else {\n"
|
||||
" document.getElementById('divnav_config').style.display = 'block';\n"
|
||||
" }\n"
|
||||
" if (gIndxCam == -1) {\n"
|
||||
" gIndxCam = 0; \n"
|
||||
" gIndxScan = -1; \n"
|
||||
" }\n"
|
||||
" gIndxScan = -1; \n"
|
||||
" cams_timer_stop();\n"
|
||||
" }\n\n";
|
||||
}
|
||||
@@ -921,10 +951,7 @@ static void webu_html_script_display_movies(ctx_webui *webui)
|
||||
" } else {\n"
|
||||
" document.getElementById('divnav_movies').style.display = 'block';\n"
|
||||
" }\n"
|
||||
" if (gIndxCam == -1) {\n"
|
||||
" gIndxCam = 0; \n"
|
||||
" gIndxScan = -1; \n"
|
||||
" }\n"
|
||||
" gIndxScan = -1; \n"
|
||||
" cams_timer_stop();\n"
|
||||
" }\n\n";
|
||||
}
|
||||
@@ -941,10 +968,7 @@ static void webu_html_script_display_actions(ctx_webui *webui)
|
||||
" } else {\n"
|
||||
" document.getElementById('divnav_actions').style.display = 'block';\n"
|
||||
" }\n"
|
||||
" if (gIndxCam == -1) {\n"
|
||||
" gIndxCam = 0; \n"
|
||||
" gIndxScan = -1; \n"
|
||||
" }\n"
|
||||
" gIndxScan = -1; \n"
|
||||
" }\n\n";
|
||||
}
|
||||
|
||||
@@ -1002,6 +1026,9 @@ static void webu_html_script_image_pantilt(ctx_webui *webui)
|
||||
{
|
||||
webui->resp_page +=
|
||||
" function image_pantilt() {\n\n"
|
||||
" if (gIndxCam == -1 ) {\n"
|
||||
" return;\n"
|
||||
" }\n\n"
|
||||
" document.getElementById('pic'+ gIndxCam).addEventListener('click',function(event){\n"
|
||||
" bounds=this.getBoundingClientRect();\n"
|
||||
" var x = Math.floor(event.pageX - bounds.left - window.scrollX);\n"
|
||||
@@ -1039,7 +1066,7 @@ static void webu_html_script_cams_reset(ctx_webui *webui)
|
||||
" function cams_reset() {\n"
|
||||
" var indx, camcnt;\n"
|
||||
" camcnt = pData['cameras']['count'];\n"
|
||||
" for (indx = 0; indx <= camcnt; indx++) {\n"
|
||||
" for (indx=0; indx<camcnt; indx++) {\n"
|
||||
" if (document.getElementById('pic'+indx) != null) { \n"
|
||||
" document.getElementById('pic'+indx).src = ''; \n"
|
||||
" }\n"
|
||||
@@ -1061,7 +1088,12 @@ static void webu_html_script_cams_one_click(ctx_webui *webui)
|
||||
" gIndxCam = index_cam;\n\n"
|
||||
" gIndxScan = -1; \n\n"
|
||||
|
||||
" camid = pData['cameras'][index_cam].id;\n\n"
|
||||
" if (gIndxCam == -1 ) {\n"
|
||||
" return;\n"
|
||||
" }\n\n"
|
||||
|
||||
" camid = pData['cameras'][index_cam].id;\n"
|
||||
|
||||
" if ((pData['configuration']['cam'+camid].stream_preview_ptz.value == true)) {\n"
|
||||
" html_preview += camera_buttons_ptz();\n"
|
||||
" }\n\n"
|
||||
@@ -1094,14 +1126,16 @@ static void webu_html_script_cams_all_click(ctx_webui *webui)
|
||||
webui->resp_page +=
|
||||
" function cams_all_click() {\n\n"
|
||||
" var html_preview = \"\";\n"
|
||||
" var indx;\n"
|
||||
" var camid;\n\n"
|
||||
|
||||
" config_hideall();\n"
|
||||
" cams_timer_stop();\n"
|
||||
" gIndxCam = 0;\n"
|
||||
" gIndxCam = -1;\n"
|
||||
" gIndxScan = -1; \n\n"
|
||||
" var camcnt = pData['cameras']['count'];\n"
|
||||
" html_preview += \"</table>\";\n"
|
||||
" for (var indx = 1; indx <= camcnt; indx++) {\n"
|
||||
" for (indx=0; indx<camcnt; indx++) {\n"
|
||||
" camid = pData['cameras'][indx].id;\n"
|
||||
" if (pData['configuration']['cam'+camid].stream_preview_method.value == 'static') {\n"
|
||||
" html_preview += \"<a><img id='pic\" + indx + \"' src=\"\n"
|
||||
@@ -1144,7 +1178,11 @@ static void webu_html_script_movies_page(ctx_webui *webui)
|
||||
" var indx, movcnt, camid, uri;\n"
|
||||
" var fname,fsize,fdate;\n\n"
|
||||
|
||||
" camid = pData['cameras'][gIndxCam].id;\n"
|
||||
" if (gIndxCam == -1 ) {\n"
|
||||
" return;\n"
|
||||
" }\n\n"
|
||||
|
||||
" camid = assign_camid();\n"
|
||||
" uri = pHostFull+'/'+camid+'/movies/';\n\n"
|
||||
|
||||
" movcnt = pMovies['movies'][gIndxCam].count;\n"
|
||||
@@ -1214,11 +1252,16 @@ static void webu_html_script_movies_click(ctx_webui *webui)
|
||||
|
||||
webui->resp_page +=
|
||||
" function movies_click(index_cam) {\n"
|
||||
" var camid, indx, camcnt, uri;\n"
|
||||
" camid = pData['cameras'][index_cam].id;\n"
|
||||
" uri = pHostFull+'/'+camid+'/movies.json';\n"
|
||||
" var camid, indx, camcnt, uri;\n\n"
|
||||
|
||||
" if (gIndxCam == -1 ) {\n"
|
||||
" return;\n"
|
||||
" }\n\n"
|
||||
|
||||
" gIndxCam = index_cam;\n"
|
||||
" gIndxScan = -1; \n"
|
||||
" camid = assign_camid();\n"
|
||||
" uri = pHostFull+'/'+camid+'/movies.json';\n\n"
|
||||
" config_hideall();\n"
|
||||
" cams_reset();\n"
|
||||
" var xmlhttp = new XMLHttpRequest();\n"
|
||||
@@ -1251,7 +1294,10 @@ static void webu_html_script_cams_one_fnc(ctx_webui *webui)
|
||||
webui->resp_page +=
|
||||
" function cams_one_fnc () {\n"
|
||||
" var img = new Image();\n"
|
||||
" var camid;\n"
|
||||
" var camid;\n\n"
|
||||
" if (gIndxCam == -1 ) {\n"
|
||||
" return;\n"
|
||||
" }\n\n"
|
||||
" camid = pData['cameras'][gIndxCam]['id'];\n\n"
|
||||
" if (pData['configuration']['cam'+camid].stream_preview_method.value == 'static') {\n"
|
||||
" pic_url[0] = pData['cameras'][gIndxCam]['url'] + \"static/stream/t\" + new Date().getTime();\n"
|
||||
@@ -1276,7 +1322,7 @@ static void webu_html_script_cams_all_fnc(ctx_webui *webui)
|
||||
" if (gGetImgs == 1) {\n"
|
||||
" gGetImgs = 0;\n"
|
||||
" var camcnt = pData['cameras']['count'];\n"
|
||||
" var camindx = 1;\n"
|
||||
" var camindx = 0;\n"
|
||||
" var indx;\n"
|
||||
" var img = new Array(4);\n"
|
||||
" var maxchk = 1;\n"
|
||||
@@ -1284,7 +1330,7 @@ static void webu_html_script_cams_all_fnc(ctx_webui *webui)
|
||||
" pic_url[indx] = '';\n"
|
||||
" img[indx] = new Image();\n"
|
||||
" }\n"
|
||||
" while ((camindx <= camcnt) && (maxchk < 10)) {\n"
|
||||
" while ((camindx < camcnt) && (maxchk < 10)) {\n"
|
||||
" maxchk++;\n"
|
||||
" camid = pData['cameras'][camindx]['id'];\n"
|
||||
" if (pData['configuration']['cam'+camid].stream_preview_method.value == 'static') {\n"
|
||||
@@ -1321,8 +1367,8 @@ static void webu_html_script_cams_scan_fnc(ctx_webui *webui)
|
||||
" return;\n"
|
||||
" }\n\n"
|
||||
|
||||
" if(gIndxScan == camcnt) {\n"
|
||||
" gIndxScan = 1;\n"
|
||||
" if(gIndxScan == (camcnt-1)) {\n"
|
||||
" gIndxScan = 0;\n"
|
||||
" } else { \n"
|
||||
" gIndxScan++;\n"
|
||||
" }\n\n"
|
||||
@@ -1369,6 +1415,7 @@ static void webu_html_script(ctx_webui *webui)
|
||||
webu_html_script_config_hideall(webui);
|
||||
webu_html_script_config_click(webui);
|
||||
|
||||
webu_html_script_assign_camid(webui);
|
||||
webu_html_script_assign_version(webui);
|
||||
webu_html_script_assign_cams(webui);
|
||||
webu_html_script_assign_actions(webui);
|
||||
@@ -1452,12 +1499,12 @@ void webu_html_user(ctx_webui *webui)
|
||||
char response[PATH_MAX];
|
||||
FILE *fp = NULL;
|
||||
|
||||
fp = myfopen(webui->motapp->cam_list[0]->conf->webcontrol_html.c_str(), "re");
|
||||
fp = myfopen(webui->motapp->conf->webcontrol_html.c_str(), "re");
|
||||
|
||||
if (fp == NULL) {
|
||||
MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO
|
||||
, _("Invalid user html file: %s")
|
||||
, webui->motapp->cam_list[0]->conf->webcontrol_html.c_str());
|
||||
, webui->motapp->conf->webcontrol_html.c_str());
|
||||
|
||||
webu_html_badreq(webui);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "webu_json.hpp"
|
||||
#include "dbse.hpp"
|
||||
|
||||
static void webu_json_config_item(ctx_webui *webui, int indx_cam, int indx_parm)
|
||||
static void webu_json_config_item(ctx_webui *webui, ctx_config *conf, int indx_parm)
|
||||
{
|
||||
int indx;
|
||||
std::string parm_orig, parm_val, parm_list, parm_enable;
|
||||
@@ -34,16 +34,14 @@ static void webu_json_config_item(ctx_webui *webui, int indx_cam, int indx_parm)
|
||||
parm_val = "";
|
||||
parm_list = "";
|
||||
|
||||
if (webui->motapp->cam_list[0]->conf->webcontrol_parms < WEBUI_LEVEL_LIMITED) {
|
||||
if (webui->motapp->conf->webcontrol_parms < WEBUI_LEVEL_LIMITED) {
|
||||
parm_enable = "false";
|
||||
} else {
|
||||
parm_enable = "true";
|
||||
}
|
||||
|
||||
conf_edit_get(webui->motapp->cam_list[indx_cam]
|
||||
, config_parms[indx_parm].parm_name
|
||||
, parm_orig
|
||||
, config_parms[indx_parm].parm_cat);
|
||||
conf_edit_get(conf, config_parms[indx_parm].parm_name
|
||||
, parm_orig, config_parms[indx_parm].parm_cat);
|
||||
|
||||
if (parm_orig.find("\"") != std::string::npos) {
|
||||
for (indx = 0; indx < (int)parm_orig.length(); indx++){
|
||||
@@ -87,10 +85,8 @@ static void webu_json_config_item(ctx_webui *webui, int indx_cam, int indx_parm)
|
||||
"}";
|
||||
}
|
||||
} else if (config_parms[indx_parm].parm_type == PARM_TYP_LIST) {
|
||||
conf_edit_list(webui->motapp->cam_list[indx_cam]
|
||||
, config_parms[indx_parm].parm_name
|
||||
, parm_list
|
||||
, config_parms[indx_parm].parm_cat);
|
||||
conf_edit_list(conf, config_parms[indx_parm].parm_name
|
||||
, parm_list, config_parms[indx_parm].parm_cat);
|
||||
|
||||
webui->resp_page +=
|
||||
"\"" + config_parms[indx_parm].parm_name + "\"" +
|
||||
@@ -115,7 +111,7 @@ static void webu_json_config_item(ctx_webui *webui, int indx_cam, int indx_parm)
|
||||
|
||||
}
|
||||
|
||||
static void webu_json_config_parms(ctx_webui *webui, int indx_cam)
|
||||
static void webu_json_config_parms(ctx_webui *webui, ctx_config *conf)
|
||||
{
|
||||
int indx_parm;
|
||||
bool first;
|
||||
@@ -136,7 +132,7 @@ static void webu_json_config_parms(ctx_webui *webui, int indx_cam)
|
||||
}
|
||||
/* Allow limited parameters to be read only to the web page */
|
||||
if ((config_parms[indx_parm].webui_level >
|
||||
webui->motapp->cam_list[0]->conf->webcontrol_parms) &&
|
||||
webui->motapp->conf->webcontrol_parms) &&
|
||||
(config_parms[indx_parm].webui_level > WEBUI_LEVEL_LIMITED)) {
|
||||
|
||||
webui->resp_page +=
|
||||
@@ -152,7 +148,7 @@ static void webu_json_config_parms(ctx_webui *webui, int indx_cam)
|
||||
}
|
||||
webui->resp_page +="}";
|
||||
} else {
|
||||
webu_json_config_item(webui, indx_cam, indx_parm);
|
||||
webu_json_config_item(webui, conf, indx_parm);
|
||||
}
|
||||
indx_parm++;
|
||||
}
|
||||
@@ -163,22 +159,16 @@ static void webu_json_config_parms(ctx_webui *webui, int indx_cam)
|
||||
static void webu_json_config_cam_parms(ctx_webui *webui)
|
||||
{
|
||||
int indx_cam;
|
||||
bool first;
|
||||
|
||||
webui->resp_page += "{";
|
||||
webui->resp_page += "\"default\": ";
|
||||
webu_json_config_parms(webui, webui->motapp->conf);
|
||||
|
||||
indx_cam = 0;
|
||||
first = true;
|
||||
while (webui->motapp->cam_list[indx_cam] != NULL) {
|
||||
if (first) {
|
||||
first = false;
|
||||
webui->resp_page += "{";
|
||||
} else {
|
||||
webui->resp_page += ",";
|
||||
}
|
||||
webui->resp_page += "\"cam" +
|
||||
webui->resp_page += ",\"cam" +
|
||||
std::to_string(webui->motapp->cam_list[indx_cam]->camera_id) + "\": ";
|
||||
|
||||
webu_json_config_parms(webui, indx_cam);
|
||||
|
||||
webu_json_config_parms(webui, webui->motapp->cam_list[indx_cam]->conf);
|
||||
indx_cam++;
|
||||
}
|
||||
webui->resp_page += "}";
|
||||
@@ -191,40 +181,23 @@ static void webu_json_config_cam_list(ctx_webui *webui)
|
||||
{
|
||||
int indx_cam;
|
||||
std::string response;
|
||||
std::string strid;
|
||||
ctx_dev *cam;
|
||||
|
||||
/* Get the count */
|
||||
indx_cam = 0;
|
||||
while (webui->motapp->cam_list[indx_cam] != NULL) {
|
||||
indx_cam++;
|
||||
}
|
||||
webui->resp_page += "{\"count\" : " + std::to_string(indx_cam - 1);
|
||||
webui->resp_page += "{\"count\" : " + std::to_string(webui->motapp->cam_cnt);
|
||||
|
||||
indx_cam = 0;
|
||||
while (webui->motapp->cam_list[indx_cam] != NULL) {
|
||||
webui->resp_page += ",\""+ std::to_string(indx_cam) + "\":";
|
||||
|
||||
if (indx_cam == 0) {
|
||||
webui->resp_page += "{\"name\": \"default\" ";
|
||||
} else if (webui->motapp->cam_list[indx_cam]->conf->camera_name == "") {
|
||||
webui->resp_page += "{\"name\": \"camera " +
|
||||
std::to_string(webui->motapp->cam_list[indx_cam]->camera_id) + "\"";
|
||||
cam = webui->motapp->cam_list[indx_cam];
|
||||
strid =std::to_string(cam->camera_id);
|
||||
webui->resp_page += ",\"" + std::to_string(indx_cam) + "\":";
|
||||
if (cam->conf->camera_name == "") {
|
||||
webui->resp_page += "{\"name\": \"camera " + strid + "\"";
|
||||
} else {
|
||||
webui->resp_page += "{\"name\": \"" +
|
||||
webui->motapp->cam_list[indx_cam]->conf->camera_name + "\"";
|
||||
webui->resp_page += "{\"name\": \"" + cam->conf->camera_name + "\"";
|
||||
}
|
||||
|
||||
webui->resp_page += ",\"id\": " +
|
||||
std::to_string(webui->motapp->cam_list[indx_cam]->camera_id);
|
||||
|
||||
if (indx_cam == 0) {
|
||||
webui->resp_page += "}";
|
||||
} else {
|
||||
webui->resp_page +=
|
||||
",\"url\": \"" + webui->hostfull +
|
||||
"/" + std::to_string(webui->motapp->cam_list[indx_cam]->camera_id) +
|
||||
"/\"} ";
|
||||
}
|
||||
|
||||
webui->resp_page += ",\"id\": " + strid;
|
||||
webui->resp_page += ",\"url\": \"" + webui->hostfull + "/" + strid + "/\"} ";
|
||||
indx_cam++;
|
||||
}
|
||||
webui->resp_page += "}";
|
||||
@@ -302,6 +275,12 @@ static void webu_json_movies_list(ctx_webui *webui)
|
||||
webui->resp_page += "{\"count\" : 1";
|
||||
webui->resp_page += ",\""+ std::to_string(indx_req) + "\":";
|
||||
|
||||
if (webui->cam == NULL) {
|
||||
webui->resp_page += "{\"count\" : 0} ";
|
||||
webui->resp_page += "}";
|
||||
return;
|
||||
}
|
||||
|
||||
/* Validate movies permitted via params */
|
||||
wact = webui->motapp->webcontrol_actions;
|
||||
for (indx = 0; indx < wact->params_count; indx++) {
|
||||
@@ -317,14 +296,13 @@ static void webu_json_movies_list(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
|
||||
dbse_movies_getlist(webui->motapp, webui->cam->camera_id);
|
||||
|
||||
dbse_movies_getlist(webui->cam->motapp, webui->cam->camera_id);
|
||||
|
||||
movie_cnt = webui->cam->motapp->dbse->movie_cnt;
|
||||
movie_cnt = webui->motapp->dbse->movie_cnt;
|
||||
webui->resp_page += "{";
|
||||
indx = 0;
|
||||
for (indx_mov=0; indx_mov < movie_cnt; indx_mov++) {
|
||||
db = webui->cam->motapp->dbse->movie_list[indx_mov];
|
||||
db = webui->motapp->dbse->movie_list[indx_mov];
|
||||
if (db.found == true) {
|
||||
if ((db.movie_sz/1000) < 1000) {
|
||||
snprintf(fmt,PATH_MAX,"%'.1fKB"
|
||||
@@ -399,7 +377,7 @@ static void webu_json_status_vars(ctx_webui *webui, int indx_cam)
|
||||
|
||||
webui->resp_page += "{";
|
||||
|
||||
webui->resp_page += "\"name\":\"" + webui->cam->conf->camera_name+"\"";
|
||||
webui->resp_page += "\"name\":\"" + cam->conf->camera_name+"\"";
|
||||
webui->resp_page += ",\"id\":" + std::to_string(cam->camera_id);
|
||||
webui->resp_page += ",\"width\":" + std::to_string(cam->imgs.width);
|
||||
webui->resp_page += ",\"height\":" + std::to_string(cam->imgs.height);
|
||||
|
||||
@@ -80,7 +80,7 @@ static void webu_post_cam_delete(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->threadnbr == 0) {
|
||||
if (webui->threadnbr == -1) {
|
||||
MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "No camera specified for deletion." );
|
||||
return;
|
||||
} else {
|
||||
@@ -164,12 +164,6 @@ void webu_post_cmdthrd(ctx_webui *webui)
|
||||
}
|
||||
indx++;
|
||||
}
|
||||
if (webui->threadnbr == -1) {
|
||||
MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO
|
||||
, "Invalid post request. Camid: %d not found"
|
||||
, camid);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -191,8 +185,8 @@ void webu_post_action_eventend(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->threadnbr == 0) {
|
||||
indx = 1;
|
||||
if (webui->threadnbr == -1) {
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx]) {
|
||||
webui->motapp->cam_list[indx]->event_stop = true;
|
||||
indx++;
|
||||
@@ -221,8 +215,8 @@ void webu_post_action_eventstart(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->threadnbr == 0) {
|
||||
indx = 1;
|
||||
if (webui->threadnbr == -1) {
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx]) {
|
||||
webui->motapp->cam_list[indx]->event_user = true;
|
||||
indx++;
|
||||
@@ -251,8 +245,8 @@ void webu_post_action_snapshot(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->threadnbr == 0) {
|
||||
indx = 1;
|
||||
if (webui->threadnbr == -1) {
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx]) {
|
||||
webui->motapp->cam_list[indx]->snapshot = true;
|
||||
indx++;
|
||||
@@ -281,8 +275,8 @@ void webu_post_action_pause(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->threadnbr == 0) {
|
||||
indx = 1;
|
||||
if (webui->threadnbr == -1) {
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx]) {
|
||||
webui->motapp->cam_list[indx]->pause = true;
|
||||
indx++;
|
||||
@@ -311,8 +305,8 @@ void webu_post_action_unpause(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->threadnbr == 0) {
|
||||
indx = 1;
|
||||
if (webui->threadnbr == -1) {
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx]) {
|
||||
webui->motapp->cam_list[indx]->pause = false;
|
||||
indx++;
|
||||
@@ -340,9 +334,9 @@ void webu_post_action_restart(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (webui->threadnbr == 0) {
|
||||
if (webui->threadnbr == -1) {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, _("Restarting all cameras"));
|
||||
indx = 1;
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx]) {
|
||||
webui->motapp->cam_list[indx]->restart_cam = true;
|
||||
webui->motapp->cam_list[indx]->finish_cam = true;
|
||||
@@ -355,7 +349,6 @@ void webu_post_action_restart(ctx_webui *webui)
|
||||
webui->motapp->cam_list[webui->threadnbr]->restart_cam = true;
|
||||
webui->motapp->cam_list[webui->threadnbr]->finish_cam = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Process the stop action */
|
||||
@@ -375,8 +368,8 @@ void webu_post_action_stop(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (webui->threadnbr == 0) {
|
||||
indx = 1;
|
||||
if (webui->threadnbr == -1) {
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx]) {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO
|
||||
, _("Stopping cam %d")
|
||||
@@ -419,8 +412,8 @@ void webu_post_action_user(ctx_webui *webui)
|
||||
}
|
||||
}
|
||||
|
||||
if (webui->threadnbr == 0) {
|
||||
indx = 1;
|
||||
if (webui->threadnbr == -1) {
|
||||
indx = 0;
|
||||
while (webui->motapp->cam_list[indx]) {
|
||||
cam = webui->motapp->cam_list[indx];
|
||||
cam->action_user[0] = '\0';
|
||||
@@ -496,7 +489,6 @@ void webu_post_write_config(ctx_webui *webui)
|
||||
static void webu_post_config(ctx_webui *webui)
|
||||
{
|
||||
int indx, indx2;
|
||||
bool ismotapp;
|
||||
std::string tmpname;
|
||||
ctx_params *wact;
|
||||
|
||||
@@ -529,7 +521,7 @@ static void webu_post_config(ctx_webui *webui)
|
||||
/* Ignore any requests for parms above webcontrol_parms level. */
|
||||
indx2=0;
|
||||
while (config_parms[indx2].parm_name != "") {
|
||||
if ((config_parms[indx2].webui_level > webui->motapp->cam_list[0]->conf->webcontrol_parms) ||
|
||||
if ((config_parms[indx2].webui_level > webui->motapp->conf->webcontrol_parms) ||
|
||||
(config_parms[indx2].webui_level == WEBUI_LEVEL_NEVER) ) {
|
||||
indx2++;
|
||||
continue;
|
||||
@@ -541,27 +533,14 @@ static void webu_post_config(ctx_webui *webui)
|
||||
}
|
||||
|
||||
if (config_parms[indx2].parm_name != "") {
|
||||
|
||||
if (config_parms[indx2].parm_cat == PARM_CAT_00) {
|
||||
ismotapp = true;
|
||||
conf_edit_set(webui->motapp->conf
|
||||
, config_parms[indx2].parm_name
|
||||
, webui->post_info[indx].key_val);
|
||||
} else {
|
||||
ismotapp = false;
|
||||
}
|
||||
|
||||
conf_edit_set(webui->motapp, ismotapp
|
||||
, webui->threadnbr
|
||||
, config_parms[indx2].parm_name
|
||||
, webui->post_info[indx].key_val);
|
||||
|
||||
/* If changing language, do it now */
|
||||
if (config_parms[indx2].parm_name == "native_language") {
|
||||
if (webui->motapp->native_language) {
|
||||
mytranslate_text("", 1);
|
||||
MOTION_LOG(INF, TYPE_ALL, NO_ERRNO,_("Native Language : on"));
|
||||
} else {
|
||||
mytranslate_text("", 0);
|
||||
MOTION_LOG(INF, TYPE_ALL, NO_ERRNO,_("Native Language : off"));
|
||||
}
|
||||
conf_edit_set(webui->motapp->cam_list[webui->threadnbr]->conf
|
||||
, config_parms[indx2].parm_name
|
||||
, webui->post_info[indx].key_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -576,6 +555,10 @@ void webu_post_ptz(ctx_webui *webui)
|
||||
ctx_dev *cam;
|
||||
ctx_params *wact;
|
||||
|
||||
if (webui->threadnbr == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
wact = webui->motapp->webcontrol_actions;
|
||||
for (indx = 0; indx < wact->params_count; indx++) {
|
||||
if (mystreq(wact->params_array[indx].param_name,"ptz")) {
|
||||
@@ -627,7 +610,7 @@ void webu_post_main(ctx_webui *webui)
|
||||
|
||||
webu_post_cmdthrd(webui);
|
||||
|
||||
if ((webui->post_cmd == "") || (webui->threadnbr == -1)) {
|
||||
if (webui->post_cmd == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -239,14 +239,14 @@ static void webu_stream_static_getimg(ctx_webui *webui)
|
||||
static int webu_stream_checks(ctx_webui *webui)
|
||||
{
|
||||
pthread_mutex_lock(&webui->motapp->mutex_camlst);
|
||||
if (webui->threadnbr >= webui->cam_threads) {
|
||||
if (webui->threadnbr == -1) {
|
||||
MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO
|
||||
, _("Invalid thread specified: %s"),webui->url.c_str());
|
||||
pthread_mutex_unlock(&webui->motapp->mutex_camlst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (webui->threadnbr <= 0) {
|
||||
if (webui->threadnbr < 0) {
|
||||
MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO
|
||||
, _("Invalid thread specified: %s"),webui->url.c_str());
|
||||
pthread_mutex_unlock(&webui->motapp->mutex_camlst);
|
||||
@@ -433,6 +433,10 @@ mhdrslt webu_stream_main(ctx_webui *webui)
|
||||
{
|
||||
mhdrslt retcd;
|
||||
|
||||
if (webui->cam == NULL) {
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
if (webui->cam->passflag == 0) {
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user