|
|
|
@ -10,6 +10,9 @@ extern VideoDevice *vdev;
|
|
|
|
std::string API_Get_Ctrls();
|
|
|
|
std::string API_Get_Ctrls();
|
|
|
|
std::string API_Set_Ctrl(std::string request);
|
|
|
|
std::string API_Set_Ctrl(std::string request);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string API_Get_Values();
|
|
|
|
|
|
|
|
std::string API_Set_Value(std::string request);
|
|
|
|
|
|
|
|
|
|
|
|
// InMemoryFile GenerateJpgFile(VideoFrame *vf);
|
|
|
|
// InMemoryFile GenerateJpgFile(VideoFrame *vf);
|
|
|
|
InMemoryTar assets;
|
|
|
|
InMemoryTar assets;
|
|
|
|
|
|
|
|
|
|
|
|
@ -44,9 +47,20 @@ int WebCamServer::HandleRequest (WebRequestBuffer *requestbuffer, WebServerClien
|
|
|
|
if (webclient->SendResponseData(requestbuffer, API_Get_Ctrls(), "") != 1) return 0;
|
|
|
|
if (webclient->SendResponseData(requestbuffer, API_Get_Ctrls(), "") != 1) return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (request.find("/set/ctrl") != std::string::npos) {
|
|
|
|
else if (request.find("/set/ctrl") != std::string::npos) {
|
|
|
|
debug ("set controls");
|
|
|
|
debug ("set control");
|
|
|
|
if (webclient->SendResponseData(requestbuffer, API_Set_Ctrl(request), "") != 1) return 0;
|
|
|
|
if (webclient->SendResponseData(requestbuffer, API_Set_Ctrl(request), "") != 1) return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if (request.compare("/get/variables") == 0) {
|
|
|
|
|
|
|
|
debug ("get values");
|
|
|
|
|
|
|
|
if (webclient->SendResponseData(requestbuffer, API_Get_Values(), "") != 1) return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (request.find("/set/var") != std::string::npos) {
|
|
|
|
|
|
|
|
debug ("set value");
|
|
|
|
|
|
|
|
if (webclient->SendResponseData(requestbuffer, API_Set_Value(request), "") != 1) return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if (isfile("www"+request)) {
|
|
|
|
else if (isfile("www"+request)) {
|
|
|
|
if (webclient->SendResponseFile(requestbuffer, request, "") != 1) return 0;
|
|
|
|
if (webclient->SendResponseFile(requestbuffer, request, "") != 1) return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -102,14 +116,57 @@ std::string API_Set_Ctrl(std::string request) {
|
|
|
|
while ((t = strchr (t, '/'))) {
|
|
|
|
while ((t = strchr (t, '/'))) {
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
t++;
|
|
|
|
t++;
|
|
|
|
if (i == 3) id = atol (t);
|
|
|
|
printf ("%d %s\n", i, t);
|
|
|
|
if (i == 4) value = atoi (t);
|
|
|
|
if (i == 3) {
|
|
|
|
|
|
|
|
char *v = strchr (t, '=');
|
|
|
|
|
|
|
|
id = atol (t);
|
|
|
|
|
|
|
|
if (v == NULL) break;
|
|
|
|
|
|
|
|
value = atoi(++v);
|
|
|
|
|
|
|
|
debug ("id:%d value:%d", id, value);
|
|
|
|
|
|
|
|
vdev->SetDevCtrl(id, value);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (i > 4) break;
|
|
|
|
if (i > 4) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vdev->SetDevCtrl(id, value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONParse jp;
|
|
|
|
JSONParse jp;
|
|
|
|
jp.Clear();
|
|
|
|
jp.Clear();
|
|
|
|
return jp.ToString();
|
|
|
|
return jp.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string API_Get_Values() {
|
|
|
|
|
|
|
|
return config.GetValues();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string API_Set_Value(std::string request) {
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
std::string value;
|
|
|
|
|
|
|
|
char *t = (char*) request.c_str();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while ((t = strchr (t, '/'))) {
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
t++;
|
|
|
|
|
|
|
|
printf ("%d %s\n", i, t);
|
|
|
|
|
|
|
|
if (i == 3) {
|
|
|
|
|
|
|
|
char *v = strchr (t, '=');
|
|
|
|
|
|
|
|
if (v == NULL) break;
|
|
|
|
|
|
|
|
name = ((std::string) t).substr(0, (v-t));
|
|
|
|
|
|
|
|
value = (++v);
|
|
|
|
|
|
|
|
debug ("name:%s value:%s", name.c_str(), value.c_str());
|
|
|
|
|
|
|
|
config.SetValue(name, value);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i > 4) break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONParse jp;
|
|
|
|
|
|
|
|
jp.Clear();
|
|
|
|
|
|
|
|
return jp.ToString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|