提交 4fabe8c9 authored 作者: blu's avatar blu

new feature entropy filter to ignore gray frame without iframe

上级 263c2693
{ {
"code":0,
"time":0,
"data":{ "data":{
"ipc":"172.31.0.51", "T6L5N3KN":{
"username":"admin", "addr":"127.0.0.1",
"password":"FWBWTU", "api-cloud":"http://127.0.0.1:8089",
"services":{ "ipcs":[
"evmgr":{
"sn":"ILS-1",
"addr":"0.0.0.0",
"port-pub":5556,
"port-rep":5557,
"iid":1
},
"evpuller":{
"sn":"ILS-2",
"addr":"0.0.0.0",
"port-pub":5556,
"port-rep":5557,
"iid":2
},
"evpusher":[
{ {
"sn":"ILS-2", "addr":"172.31.0.51",
"addr":"localhost", "modules":{
"iid":2, "evml":[
{
"area":300,
"enabled":1, "enabled":1,
"urlDest":"rtsp://40.73.41.176:554/test1" "iid":1,
"post":30,
"pre":3,
"sn":"T6L5N3KN",
"status":0,
"thresh":80,
"type":"motion"
} }
], ],
"evslicer":[ "evpuller":[
{ {
"sn":"ILS-3", "addr":"127.0.0.1",
"addr":"192.168.0.25", "iid":1,
"iid":3, "port-pub":5556,
"path": "/var/lib/slices/" "sn":"T6L5N3KN",
"status":0
} }
], ],
"evml":[ "evpusher":[
{ {
"feature":"motion", "enabled":1,
"sn":"ILS-4", "iid":1,
"addr":"192.168.0.26", "password":"",
"iid":4 "sn":"T6L5N3KN",
"status":0,
"token":"",
"urlDest":"rtsp://40.73.41.176:554/test1",
"user":""
}
],
"evslicer":[
{
"enabled":1,
"iid":1,
"path":"slices",
"sn":"T6L5N3KN",
"status":0
} }
] ]
},
"password":"FWBWTU",
"port":554,
"proto":"rtsp",
"status":0,
"user":"admin"
} }
],
"mqtt-cloud":"<cloud_addr>",
"port-cloud":5556,
"port-router":5550,
"proto":"zmq",
"sn":"T6L5N3KN",
"status":1
} }
},
"lastupdated":1567669674
} }
\ No newline at end of file
...@@ -27,23 +27,18 @@ class HttpSrv{ ...@@ -27,23 +27,18 @@ class HttpSrv{
// sn:module -> sn_of_evmgr // sn:module -> sn_of_evmgr
json configMap; json configMap;
json config(string body){ json config(json &newConfig){
json ret; json ret;
int iret; int iret;
json oldConfigMap = this->configMap; json oldConfigMap = this->configMap;
ret["code"] = 0; ret["code"] = 0;
ret["msg"] = "ok"; ret["msg"] = "ok";
ret["time"] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count(); ret["time"] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
spdlog::info(body); spdlog::info(newConfig.dump());
if(body.empty()){
ret["code"] = 1;
ret["msg"] = "no body payload";
}else{
try{ try{
json newConfig = json::parse(body);
if(newConfig.count("data") == 0 || newConfig["data"].size() == 0) { if(newConfig.count("data") == 0 || newConfig["data"].size() == 0) {
ret["code"] = 1; ret["code"] = 1;
ret["msg"] = "evcloudsvc invalid config body received: " + body; ret["msg"] = "evcloudsvc invalid config body received: " + newConfig.dump();
spdlog::error(ret["msg"].get<string>()); spdlog::error(ret["msg"].get<string>());
}else{ }else{
json &data = newConfig["data"]; json &data = newConfig["data"];
...@@ -105,7 +100,6 @@ class HttpSrv{ ...@@ -105,7 +100,6 @@ class HttpSrv{
// update evmgr config // update evmgr config
json evmgrData; json evmgrData;
evmgrData["data"] = data; evmgrData["data"] = data;
//evmgrData["lastupdated"] = newConfig["lastupdated"];
//save //save
iret = LVDB::setLocalConfig(evmgrData, k); iret = LVDB::setLocalConfig(evmgrData, k);
...@@ -136,7 +130,7 @@ class HttpSrv{ ...@@ -136,7 +130,7 @@ class HttpSrv{
ret["code"] = -1; ret["code"] = -1;
ret["msg"] = e.what(); ret["msg"] = e.what();
} }
}
return ret; return ret;
} }
...@@ -156,6 +150,8 @@ class HttpSrv{ ...@@ -156,6 +150,8 @@ class HttpSrv{
try{ try{
string sn = req.get_param_value("sn"); string sn = req.get_param_value("sn");
string module = req.get_param_value("module"); string module = req.get_param_value("module");
bool force = (req.get_param_value("force") == "true") ? true: false;
if(sn.empty()||module.empty()){ if(sn.empty()||module.empty()){
throw StrException("no para sn/module"); throw StrException("no para sn/module");
} }
...@@ -177,7 +173,7 @@ class HttpSrv{ ...@@ -177,7 +173,7 @@ class HttpSrv{
modname = sn + ":" + modname; modname = sn + ":" + modname;
if(this->configMap.count(modname) == 0){ if(this->configMap.count(modname) == 0){
spdlog::info("evcloudsvc no such edge module registred: {}, create new entry", key); spdlog::info("evcloudsvc no such edge module registred: {}, create new entry", key);
ret = this->config(req.body); ret = this->config(cfg);
if(ret["code"] == 0) { if(ret["code"] == 0) {
}else{ }else{
spdlog::error("failed to config: {}", ret.dump()); spdlog::error("failed to config: {}", ret.dump());
...@@ -194,16 +190,15 @@ class HttpSrv{ ...@@ -194,16 +190,15 @@ class HttpSrv{
ret["msg"] = "diff"; ret["msg"] = "diff";
json data; json data;
r = LVDB::getLocalConfig(data, key); r = LVDB::getLocalConfig(data, key);
if(r < 0) { if(r < 0||force) {
ret["code"] = r; spdlog::error("failed to get localconfig or force to updaste. create new");
ret["msg"] = "failed to get config for: " + key; ret = this->config(cfg);
}else{ }else{
json diff = json::diff(data, cfg); json diff = json::diff(cfg, data);
spdlog::info("evcloudsvc diff: {}", diff.dump()); spdlog::info("evcloudsvc diff: {}", diff.dump());
ret["data"] = diff; ret["data"] = diff;
} }
} }
}catch(exception &e) { }catch(exception &e) {
ret.clear(); ret.clear();
ret["code"] = -1; ret["code"] = -1;
...@@ -260,7 +255,16 @@ class HttpSrv{ ...@@ -260,7 +255,16 @@ class HttpSrv{
}); });
svr.Post("/config", [this](const Request& req, Response& res){ svr.Post("/config", [this](const Request& req, Response& res){
auto ret = this->config(req.body); json ret;
string msg;
try{
json cfg = json::parse(req.body);
ret = this->config(cfg);
}catch (exception &e) {
msg = string("evcloudsvc exception on POST /config: ") + e.what();
ret["msg"] = msg;
ret["code"]= -1;
}
res.set_content(ret.dump(), "text/json"); res.set_content(ret.dump(), "text/json");
}); });
......
...@@ -73,6 +73,8 @@ private: ...@@ -73,6 +73,8 @@ private:
exit(1); exit(1);
} }
// set all module status to 0 // set all module status to 0
ret = LVDB::traverseConfigureModules(config, [](string modname, json &m, void* pUser)->int{ ret = LVDB::traverseConfigureModules(config, [](string modname, json &m, void* pUser)->int{
if(m.count("status") != 0) if(m.count("status") != 0)
......
...@@ -8,89 +8,15 @@ ...@@ -8,89 +8,15 @@
#include <sstream> #include <sstream>
#include "json.hpp" #include "json.hpp"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "httplib.h"
using namespace std; using namespace std;
using namespace nlohmann; using namespace nlohmann;
using namespace httplib;
// cloudutils // cloudutils
namespace cloudutils namespace cloudutils
{ {
/**
* scn:
* evpuller, evmgr, evmotion, evslicer
*
* */
/*
{
"time":0,
"lastupdated": 0,
"code":0,
"data":{
"ILSEVMGR1":{
"lastupdated": 0,
"sn":"ILSEVMGR1",
"addr":"172.31.0.76",
"addr-cloud":"172.31.0.76",RzMbCp5W6^ZS
"proto":"zmq",
"port-cloud":5556,
"port-router":5550,
"status":1,
"ipcs":[
{
"addr":"172.31.0.51",
"proto":"rtsp",
"user":"admin",
"password":"FWBWTU",
"port": 554,
"status":1,
"modules":{
"evpuller":[
{
"sn":"ILSEVPULLER1",
"addr":"172.31.0.76",
"iid":1,
"port-pub":5556,
"status":1
}
],
"evpusher":[
{
"sn":"ILSEVPUSHER1",
"iid":1,
"urlDest":"rtsp://40.73.41.176:554/test1",
"user":"",
"password":"",
"token":"",
"enabled":1,
"status":1
}
],
"evslicer":[
{
"sn":"ILSEVSLICER1",
"iid":1,
"path":"slices",
"enabled":1,
"status":1
}
],
"evml":[
{
"type":"motion",
"sn":"ILSEVMLMOTION1",
"iid":1,
"enabled":1,
"status":1
}
]
}
}
]
}
}
}
*/
// const char *config = "{\"time\":0,\"code\":0,\"data\":{\"ILSEVMGR1\":{\"sn\":\"ILSEVMGR1\",\"addr\":\"127.0.0.1\",\"addr-cloud\":\"127.0.0.1\",\"proto\":\"zmq\",\"port-cloud\":5556,\"port-router\":5550,\"status\":1,\"ipcs\":[{\"addr\":\"172.31.0.51\",\"proto\":\"rtsp\",\"user\":\"admin\",\"password\":\"iLabService\",\"status\":1,\"modules\":{\"evpuller\":[{\"sn\":\"ILSEVPULLER1\",\"addr\":\"127.0.0.1\",\"iid\":1,\"port-pub\":5556,\"status\":1}],\"evpusher\":[{\"sn\":\"ILSEVPUSHER1\",\"iid\":1,\"urlDest\":\"rtsp://40.73.41.176:554/test1\",\"user\":\"\",\"password\":\"\",\"token\":\"\",\"enabled\":1,\"status\":1}],\"evslicer\":[{\"sn\":\"ILSEVSLICER1\",\"iid\":1,\"path\":\"slices\",\"enabled\":1,\"status\":1}],\"evml\":[{\"type\":\"motion\",\"sn\":\"ILSEVMLMOTION1\",\"iid\":1,\"enabled\":1,\"status\":1}]}}]}}}";
vector<string> split(const std::string& s, char delimiter) vector<string> split(const std::string& s, char delimiter)
{ {
...@@ -104,6 +30,22 @@ vector<string> split(const std::string& s, char delimiter) ...@@ -104,6 +30,22 @@ vector<string> split(const std::string& s, char delimiter)
return tokens; return tokens;
} }
/// ref: ../config.json
json registry(json &conf, string sn, string module) {
json ret;
string api;
try{
api = conf.at(sn).at("api-cloud").get<string>() + "/register";
}catch(exception &e) {
}
// /Client cli;
return ret;
}
} // namespace cloudutils } // namespace cloudutils
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论