mirror of
https://github.com/Motion-Project/motion.git
synced 2026-04-20 05:56:58 -04:00
Add option for stream webcontrol_interface
This commit is contained in:
@@ -2375,11 +2375,14 @@
|
||||
|
||||
<h3><a name="webcontrol_interface"></a> webcontrol_interface </h3>
|
||||
<ul>
|
||||
<li> Values: `default` or `user` | Default: `default`</li>
|
||||
<li> Values: `default`, `user` or `stream` |
|
||||
Default: `default` for motion.conf file
|
||||
, `stream` for camera configuration files</li>
|
||||
The type of webcontrol interface to provide.
|
||||
<ul>
|
||||
<li>The value of `default` provides a traditional web page interface using html/css.</li>
|
||||
<li>The value of `user` means the html will be provided by file specified in webcontrol_html</li>
|
||||
<li>The value of `stream` means the camera stream will be provided</li>
|
||||
</ul>
|
||||
</ul>
|
||||
<p></p>
|
||||
|
||||
17
src/conf.cpp
17
src/conf.cpp
@@ -141,7 +141,7 @@ ctx_parm config_parms[] = {
|
||||
{"webcontrol_base_path", PARM_TYP_STRING, PARM_CAT_13, PARM_LVL_02, PARM_CHG_RESTART },
|
||||
{"webcontrol_ipv6", PARM_TYP_BOOL, PARM_CAT_13, PARM_LVL_02, PARM_CHG_RESTART },
|
||||
{"webcontrol_localhost", PARM_TYP_BOOL, PARM_CAT_13, PARM_LVL_02, PARM_CHG_RESTART },
|
||||
{"webcontrol_access", PARM_TYP_LIST, PARM_CAT_13, PARM_LVL_99, PARM_CHG_RESTART},
|
||||
{"webcontrol_access", PARM_TYP_LIST, PARM_CAT_13, PARM_LVL_99, PARM_CHG_RESTART},
|
||||
{"webcontrol_interface", PARM_TYP_LIST, PARM_CAT_13, PARM_LVL_02, PARM_CHG_RESTART },
|
||||
{"webcontrol_auth_method", PARM_TYP_LIST, PARM_CAT_13, PARM_LVL_04, PARM_CHG_RESTART },
|
||||
{"webcontrol_auth_admin", PARM_TYP_STRING, PARM_CAT_13, PARM_LVL_04, PARM_CHG_RESTART },
|
||||
@@ -2078,9 +2078,13 @@ void cls_config::edit_webcontrol_access(std::string &parm, enum PARM_ACT pact)
|
||||
void cls_config::edit_webcontrol_interface(std::string &parm, enum PARM_ACT pact)
|
||||
{
|
||||
if (pact == PARM_ACT_DFLT) {
|
||||
webcontrol_interface = "default";
|
||||
if ((this == app->cfg) || (this == app->conf_src)) {
|
||||
webcontrol_interface = "default";
|
||||
} else {
|
||||
webcontrol_interface = "stream";
|
||||
}
|
||||
} else if (pact == PARM_ACT_SET) {
|
||||
if ((parm == "default") || (parm == "user")) {
|
||||
if ((parm == "default") || (parm == "user") || (parm == "stream")) {
|
||||
webcontrol_interface = parm;
|
||||
} else if (parm == "") {
|
||||
webcontrol_interface = "default";
|
||||
@@ -2091,7 +2095,7 @@ void cls_config::edit_webcontrol_interface(std::string &parm, enum PARM_ACT pact
|
||||
parm = webcontrol_interface;
|
||||
} else if (pact == PARM_ACT_LIST) {
|
||||
parm = "[";
|
||||
parm = parm + "\"default\",\"user\"";
|
||||
parm = parm + "\"default\",\"user\",\"stream\"";
|
||||
parm = parm + "]";
|
||||
}
|
||||
return;
|
||||
@@ -3069,7 +3073,7 @@ void cls_config::edit_cat13(std::string parm_nm, std::string &parm_val, enum PAR
|
||||
} else if (parm_nm == "webcontrol_base_path") { edit_webcontrol_base_path(parm_val, pact);
|
||||
} else if (parm_nm == "webcontrol_ipv6") { edit_webcontrol_ipv6(parm_val, pact);
|
||||
} else if (parm_nm == "webcontrol_localhost") { edit_webcontrol_localhost(parm_val, pact);
|
||||
} else if (parm_nm == "webcontrol_access") { edit_webcontrol_access(parm_val, pact);
|
||||
} else if (parm_nm == "webcontrol_access") { edit_webcontrol_access(parm_val, pact);
|
||||
} else if (parm_nm == "webcontrol_interface") { edit_webcontrol_interface(parm_val, pact);
|
||||
} else if (parm_nm == "webcontrol_auth_method") { edit_webcontrol_auth_method(parm_val, pact);
|
||||
} else if (parm_nm == "webcontrol_auth_admin") { edit_webcontrol_auth_admin(parm_val, pact);
|
||||
@@ -3524,7 +3528,8 @@ void cls_config::camera_add(std::string fname, bool srcdir)
|
||||
indx = 0;
|
||||
while (config_parms[indx].parm_name != "") {
|
||||
parm_nm =config_parms[indx].parm_name;
|
||||
if (parm_nm != "device_id") {
|
||||
if ((parm_nm != "device_id") &&
|
||||
(parm_nm != "webcontrol_interface")) {
|
||||
app->conf_src->edit_get(parm_nm, parm_val, config_parms[indx].parm_cat);
|
||||
cam_cls->conf_src->edit_set(parm_nm, parm_val);
|
||||
}
|
||||
|
||||
@@ -843,10 +843,18 @@ void cls_webu_ans::answer_get()
|
||||
webu_text->main();
|
||||
|
||||
} else {
|
||||
if (webu_html == nullptr) {
|
||||
webu_html = new cls_webu_html(this);
|
||||
if (webu->cfg->webcontrol_interface == "stream") {
|
||||
if (webu_stream == nullptr) {
|
||||
webu_stream = new cls_webu_stream(this);
|
||||
}
|
||||
gzip_encode = false;
|
||||
webu_stream->main();
|
||||
} else {
|
||||
if (webu_html == nullptr) {
|
||||
webu_html = new cls_webu_html(this);
|
||||
}
|
||||
webu_html->main();
|
||||
}
|
||||
webu_html->main();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -930,14 +938,22 @@ mhdrslt cls_webu_ans::answer_main(struct MHD_Connection *p_connection
|
||||
}
|
||||
|
||||
if (mhd_first) {
|
||||
mhd_first = false;
|
||||
|
||||
if (mystreq(method,"POST")) {
|
||||
if (webu->cfg->webcontrol_interface == "stream") {
|
||||
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO
|
||||
,_("Actions not permitted on webcontrol_interface stream"));
|
||||
bad_request();
|
||||
return MHD_YES;
|
||||
}
|
||||
if (webu_post == nullptr) {
|
||||
webu_post = new cls_webu_post(this);
|
||||
}
|
||||
mhd_first = false;
|
||||
cnct_method = WEBUI_METHOD_POST;
|
||||
retcd = webu_post->processor_init();
|
||||
} else {
|
||||
mhd_first = false;
|
||||
cnct_method = WEBUI_METHOD_GET;
|
||||
retcd = MHD_YES;
|
||||
}
|
||||
|
||||
@@ -656,15 +656,6 @@ void cls_webu_stream::main()
|
||||
static_all_img();
|
||||
}
|
||||
retcd = stream_static();
|
||||
} else if (webua->uri_cmd1 == "mjpg") {
|
||||
if (webua->device_id > 0) {
|
||||
jpg_cnct();
|
||||
one_buffer();
|
||||
} else {
|
||||
all_cnct();
|
||||
all_buffer();
|
||||
}
|
||||
retcd = stream_mjpeg();
|
||||
} else if (webua->uri_cmd1 == "mpegts") {
|
||||
if (webua->device_id > 0) {
|
||||
ts_cnct();
|
||||
@@ -678,6 +669,15 @@ void cls_webu_stream::main()
|
||||
if (retcd == MHD_NO) {
|
||||
mydelete(webu_mpegts);
|
||||
}
|
||||
} else {
|
||||
if (webua->device_id > 0) {
|
||||
jpg_cnct();
|
||||
one_buffer();
|
||||
} else {
|
||||
all_cnct();
|
||||
all_buffer();
|
||||
}
|
||||
retcd = stream_mjpeg();
|
||||
}
|
||||
|
||||
if (retcd == MHD_NO) {
|
||||
|
||||
Reference in New Issue
Block a user