Skip to content

Commit aecab2b

Browse files
committed
Add option for stream webcontrol_interface
1 parent 2fe6674 commit aecab2b

4 files changed

Lines changed: 44 additions & 20 deletions

File tree

doc/motion_config.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2375,11 +2375,14 @@ <h3><a name="webcontrol_access"></a> webcontrol_access </h3>
23752375

23762376
<h3><a name="webcontrol_interface"></a> webcontrol_interface </h3>
23772377
<ul>
2378-
<li> Values: `default` or `user` | Default: `default`</li>
2378+
<li> Values: `default`, `user` or `stream` |
2379+
Default: `default` for motion.conf file
2380+
, `stream` for camera configuration files</li>
23792381
The type of webcontrol interface to provide.
23802382
<ul>
23812383
<li>The value of `default` provides a traditional web page interface using html/css.</li>
23822384
<li>The value of `user` means the html will be provided by file specified in webcontrol_html</li>
2385+
<li>The value of `stream` means the camera stream will be provided</li>
23832386
</ul>
23842387
</ul>
23852388
<p></p>

src/conf.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ ctx_parm config_parms[] = {
141141
{"webcontrol_base_path", PARM_TYP_STRING, PARM_CAT_13, PARM_LVL_02, PARM_CHG_RESTART },
142142
{"webcontrol_ipv6", PARM_TYP_BOOL, PARM_CAT_13, PARM_LVL_02, PARM_CHG_RESTART },
143143
{"webcontrol_localhost", PARM_TYP_BOOL, PARM_CAT_13, PARM_LVL_02, PARM_CHG_RESTART },
144-
{"webcontrol_access", PARM_TYP_LIST, PARM_CAT_13, PARM_LVL_99, PARM_CHG_RESTART},
144+
{"webcontrol_access", PARM_TYP_LIST, PARM_CAT_13, PARM_LVL_99, PARM_CHG_RESTART},
145145
{"webcontrol_interface", PARM_TYP_LIST, PARM_CAT_13, PARM_LVL_02, PARM_CHG_RESTART },
146146
{"webcontrol_auth_method", PARM_TYP_LIST, PARM_CAT_13, PARM_LVL_04, PARM_CHG_RESTART },
147147
{"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)
20782078
void cls_config::edit_webcontrol_interface(std::string &parm, enum PARM_ACT pact)
20792079
{
20802080
if (pact == PARM_ACT_DFLT) {
2081-
webcontrol_interface = "default";
2081+
if ((this == app->cfg) || (this == app->conf_src)) {
2082+
webcontrol_interface = "default";
2083+
} else {
2084+
webcontrol_interface = "stream";
2085+
}
20822086
} else if (pact == PARM_ACT_SET) {
2083-
if ((parm == "default") || (parm == "user")) {
2087+
if ((parm == "default") || (parm == "user") || (parm == "stream")) {
20842088
webcontrol_interface = parm;
20852089
} else if (parm == "") {
20862090
webcontrol_interface = "default";
@@ -2091,7 +2095,7 @@ void cls_config::edit_webcontrol_interface(std::string &parm, enum PARM_ACT pact
20912095
parm = webcontrol_interface;
20922096
} else if (pact == PARM_ACT_LIST) {
20932097
parm = "[";
2094-
parm = parm + "\"default\",\"user\"";
2098+
parm = parm + "\"default\",\"user\",\"stream\"";
20952099
parm = parm + "]";
20962100
}
20972101
return;
@@ -3069,7 +3073,7 @@ void cls_config::edit_cat13(std::string parm_nm, std::string &parm_val, enum PAR
30693073
} else if (parm_nm == "webcontrol_base_path") { edit_webcontrol_base_path(parm_val, pact);
30703074
} else if (parm_nm == "webcontrol_ipv6") { edit_webcontrol_ipv6(parm_val, pact);
30713075
} else if (parm_nm == "webcontrol_localhost") { edit_webcontrol_localhost(parm_val, pact);
3072-
} else if (parm_nm == "webcontrol_access") { edit_webcontrol_access(parm_val, pact);
3076+
} else if (parm_nm == "webcontrol_access") { edit_webcontrol_access(parm_val, pact);
30733077
} else if (parm_nm == "webcontrol_interface") { edit_webcontrol_interface(parm_val, pact);
30743078
} else if (parm_nm == "webcontrol_auth_method") { edit_webcontrol_auth_method(parm_val, pact);
30753079
} 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)
35243528
indx = 0;
35253529
while (config_parms[indx].parm_name != "") {
35263530
parm_nm =config_parms[indx].parm_name;
3527-
if (parm_nm != "device_id") {
3531+
if ((parm_nm != "device_id") &&
3532+
(parm_nm != "webcontrol_interface")) {
35283533
app->conf_src->edit_get(parm_nm, parm_val, config_parms[indx].parm_cat);
35293534
cam_cls->conf_src->edit_set(parm_nm, parm_val);
35303535
}

src/webu_ans.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,18 @@ void cls_webu_ans::answer_get()
843843
webu_text->main();
844844

845845
} else {
846-
if (webu_html == nullptr) {
847-
webu_html = new cls_webu_html(this);
846+
if (webu->cfg->webcontrol_interface == "stream") {
847+
if (webu_stream == nullptr) {
848+
webu_stream = new cls_webu_stream(this);
849+
}
850+
gzip_encode = false;
851+
webu_stream->main();
852+
} else {
853+
if (webu_html == nullptr) {
854+
webu_html = new cls_webu_html(this);
855+
}
856+
webu_html->main();
848857
}
849-
webu_html->main();
850858
}
851859
}
852860

@@ -930,14 +938,22 @@ mhdrslt cls_webu_ans::answer_main(struct MHD_Connection *p_connection
930938
}
931939

932940
if (mhd_first) {
933-
mhd_first = false;
941+
934942
if (mystreq(method,"POST")) {
943+
if (webu->cfg->webcontrol_interface == "stream") {
944+
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO
945+
,_("Actions not permitted on webcontrol_interface stream"));
946+
bad_request();
947+
return MHD_YES;
948+
}
935949
if (webu_post == nullptr) {
936950
webu_post = new cls_webu_post(this);
937951
}
952+
mhd_first = false;
938953
cnct_method = WEBUI_METHOD_POST;
939954
retcd = webu_post->processor_init();
940955
} else {
956+
mhd_first = false;
941957
cnct_method = WEBUI_METHOD_GET;
942958
retcd = MHD_YES;
943959
}

src/webu_stream.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -656,15 +656,6 @@ void cls_webu_stream::main()
656656
static_all_img();
657657
}
658658
retcd = stream_static();
659-
} else if (webua->uri_cmd1 == "mjpg") {
660-
if (webua->device_id > 0) {
661-
jpg_cnct();
662-
one_buffer();
663-
} else {
664-
all_cnct();
665-
all_buffer();
666-
}
667-
retcd = stream_mjpeg();
668659
} else if (webua->uri_cmd1 == "mpegts") {
669660
if (webua->device_id > 0) {
670661
ts_cnct();
@@ -678,6 +669,15 @@ void cls_webu_stream::main()
678669
if (retcd == MHD_NO) {
679670
mydelete(webu_mpegts);
680671
}
672+
} else {
673+
if (webua->device_id > 0) {
674+
jpg_cnct();
675+
one_buffer();
676+
} else {
677+
all_cnct();
678+
all_buffer();
679+
}
680+
retcd = stream_mjpeg();
681681
}
682682

683683
if (retcd == MHD_NO) {

0 commit comments

Comments
 (0)