提交 b6eadb7d authored 作者: blu's avatar blu

init

上级 01b85e1c
{ {
"time":0, "code":0,
"code":0, "time":0,
"data":{ "data":{
"ILSEVMGR1":{ "ipc":"172.31.0.51",
"sn":"ILSEVMGR1", "username":"admin",
"addr":"172.31.0.76", "password":"FWBWTU",
"addr-cloud":"172.31.0.76", "services":{
"proto": "zmq", "evmgr":{
"port-cloud":5556, "sn":"ILS-1",
"port-router":5550, "addr":"0.0.0.0",
"status":1, "port-pub":5556,
"ipcs":[ "port-rep":5557,
{ "iid":1
"addr":"172.31.0.51", },
"proto":"rtsp", "evpuller":{
"user":"admin", "sn":"ILS-2",
"password":"FWBWTU", "addr":"0.0.0.0",
"status":1, "port-pub":5556,
"modules":{ "port-rep":5557,
"evpuller":[ "iid":2
{ },
"sn":"ILSEVPULLER1", "evpusher":[
"addr":"172.31.0.76", {
"iid":1, "sn":"ILS-2",
"port-pub":"5556", "addr":"localhost",
"status":1 "iid":2,
} "enabled":1,
], "urlDest":"rtsp://40.73.41.176:554/test1"
"evpusher":[ }
{ ],
"sn":"ILSEVPUSHER1", "evslicer":[
"iid":1, {
"proto":"rtsp", "sn":"ILS-3",
"addrDest":"40.73.41.176", "addr":"192.168.0.25",
"portDest":554, "iid":3,
"user":"", "path": "/var/lib/slices/"
"password":"", }
"token":"", ],
"enabled":1, "evml":[
"status":1 {
} "feature":"motion",
], "sn":"ILS-4",
"evslicer":[ "addr":"192.168.0.26",
{ "iid":4
"sn":"ILSEVSLICER1", }
"iid":1, ]
"path":"slices", }
"enabled":1, }
"status":1 }
} \ No newline at end of file
],
"evml":[
{
"type":"motion",
"sn":"ILSEVMLMOTION1",
"iid":1,
"enabled":1,
"status":1
}
]
}
}
]
}
}
}
\ No newline at end of file
/* /*
module: database module: database
description: description:
author: Bruce.Lu <lzbgt@icloud.com> author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/23 update: 2019/08/23
*/ */
...@@ -18,236 +18,186 @@ using namespace std; ...@@ -18,236 +18,186 @@ using namespace std;
using json = nlohmann::json; using json = nlohmann::json;
namespace DB { namespace DB {
map<string, sqlite3 *> maphdb; map<string, sqlite3 *> maphdb;
map<string, mutex> mapMut; map<string, mutex> mapMut;
static bool bRand = false; static bool bRand = false;
//typedef int (*callback)(void*,int,char**,char**); //typedef int (*callback)(void*,int,char**,char**);
sqlite3* exec(void *pUserData, const char* fileName, const char* stmt, callback cb){ sqlite3* exec(void *pUserData, const char* fileName, const char* stmt, callback cb)
int ret = 0; {
if(fileName == NULL||strlen(fileName) == 0) { int ret = 0;
fileName = const_cast<char*>("default.db"); if(fileName == NULL||strlen(fileName) == 0) {
} fileName = const_cast<char*>("default.db");
}
sqlite3 *pdb = NULL; sqlite3 *pdb = NULL;
try{ try {
pdb = maphdb.at(string(fileName)); pdb = maphdb.at(string(fileName));
}catch(...){ }
pdb = NULL; catch(...) {
} pdb = NULL;
}
mutex &mut = mapMut[string(fileName)]; mutex &mut = mapMut[string(fileName)];
if(pdb == NULL) {
std::lock_guard<std::mutex> lock(mut);
if(pdb == NULL) { if(pdb == NULL) {
std::lock_guard<std::mutex> lock(mut); ret = sqlite3_open(fileName,&pdb);
if(pdb == NULL) { if(ret != SQLITE_OK) {
ret = sqlite3_open(fileName,&pdb); spdlog::error("sqlite3_open: {}",sqlite3_errmsg(pdb));
if(ret != SQLITE_OK) exit(1);
{
spdlog::error("sqlite3_open: {}",sqlite3_errmsg(pdb));
exit(1);
}
}
maphdb[string(fileName)] = pdb;
}
//
// sprintf(sql,"create table if not exists address (name text, tel text);");
if(stmt != NULL) {
std::lock_guard<std::mutex> lock(mut);
ret = sqlite3_exec(pdb, stmt, cb, pUserData, NULL);
if(ret != SQLITE_OK)
{
spdlog::error("sqlite3_exec: {}",sqlite3_errmsg(pdb));
} }
} }
//sqlite3_close(pdb);
return pdb;
}
string genStrRand(int length) { maphdb[string(fileName)] = pdb;
if(!bRand) { }
srand(time(NULL)); //
bRand = true; // sprintf(sql,"create table if not exists address (name text, tel text);");
if(stmt != NULL) {
std::lock_guard<std::mutex> lock(mut);
ret = sqlite3_exec(pdb, stmt, cb, pUserData, NULL);
if(ret != SQLITE_OK) {
spdlog::error("sqlite3_exec: {}",sqlite3_errmsg(pdb));
} }
static string charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; }
string result;
result.resize(length);
srand(time(NULL)); //sqlite3_close(pdb);
for (int i = 0; i < length; i++) return pdb;
result[i] = charset[rand() % charset.length()]; }
return result; string genStrRand(int length)
{
if(!bRand) {
srand(time(NULL));
bRand = true;
} }
static string charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
string result;
result.resize(length);
int _getSn(void *pUser, int cc, char **cv, char **cn) { srand(time(NULL));
int ret = SQLITE_OK; for (int i = 0; i < length; i++)
auto v = static_cast<string*>(pUser); result[i] = charset[rand() % charset.length()];
if(cc == 1) {
*v = string(cv[0]); return result;
}else{ }
if(ret < 1) {
ret = -1; int _getSn(void *pUser, int cc, char **cv, char **cn)
}else{ {
ret = 1; int ret = SQLITE_OK;
} auto v = static_cast<string*>(pUser);
if(cc == 1) {
*v = string(cv[0]);
}
else {
if(ret < 1) {
ret = -1;
}
else {
ret = 1;
} }
return ret;
} }
return ret;
}
int setSn(const char *sn, const char *fileName) { int setSn(const char *sn, const char *fileName)
int ret = 0; {
return ret; int ret = 0;
} return ret;
}
int setLocalConfig(json config, const char* fileName) { int setLocalConfig(json config, const char* fileName)
int ret = 0; {
string stmt; int ret = 0;
sqlite3* pdb =NULL; string stmt;
// init tables sqlite3* pdb =NULL;
stmt = "create table if not exists info(cls text, value text, version text, update datetime, primary key cls);"; // init tables
pdb = exec(NULL, fileName, stmt.c_str(), NULL); stmt = "create table if not exists info(cls text, value text, version text, update datetime, primary key cls);";
pdb = exec(NULL, fileName, stmt.c_str(), NULL);
if(sqlite3_errcode(pdb) != SQLITE_OK) {
spdlog::error("failed to create table info: {}", sqlite3_errmsg(pdb));
return -1;
}
// if sn exist
string sn;
stmt = "select value from info where cls=sn;";
pdb = exec(&sn, fileName, stmt.c_str(), _getSn);
if(sqlite3_errcode(pdb) != SQLITE_OK ||sn.empty()) {
spdlog::error("failed get sn: {}, will create new one", sqlite3_errmsg(pdb));
sn = genStrRand(8);
stmt = "insert into info(cls, value, update) values(sn," + sn + ",'now');";
if(sqlite3_errcode(pdb) != SQLITE_OK) { if(sqlite3_errcode(pdb) != SQLITE_OK) {
spdlog::error("failed to create table info: {}", sqlite3_errmsg(pdb)); spdlog::error("failed insert sn: {}, will create new one", sqlite3_errmsg(pdb));
return -1; return -1;
} }
// if sn exist
string sn;
stmt = "select value from info where cls=sn;";
pdb = exec(&sn, fileName, stmt.c_str(), _getSn);
if(sqlite3_errcode(pdb) != SQLITE_OK ||sn.empty()) {
spdlog::error("failed get sn: {}, will create new one", sqlite3_errmsg(pdb));
sn = genStrRand(8);
stmt = "insert into info(cls, value, update) values(sn," + sn + ",'now');";
if(sqlite3_errcode(pdb) != SQLITE_OK) {
spdlog::error("failed insert sn: {}, will create new one", sqlite3_errmsg(pdb));
return -1;
}
}
return ret;
} }
int getLocalConfig(json config) { return ret;
int ret = 0; }
return ret;
}
int _getSlices(void *pUser, int cc, char **cv, char **cn) { int getLocalConfig(json config)
int ret = 0; {
auto v = static_cast< vector<int>* >(pUser); int ret = 0;
if(cc != v->size()) { return ret;
return SQLITE_ERROR; }
}else{
for(int i = 0; i < v->size(); i ++) {
v->at(i) = atoi(cv[0]);
}
}
return ret; int _getSlices(void *pUser, int cc, char **cv, char **cn)
{
int ret = 0;
auto v = static_cast< vector<int>* >(pUser);
if(cc != v->size()) {
return SQLITE_ERROR;
}
else {
for(int i = 0; i < v->size(); i ++) {
v->at(i) = atoi(cv[0]);
}
} }
/* return ret;
{
"code":0,
"time":0,
"data":{
"ipc":"172.31.0.51",
"username":"admin",
"password":"FWBWTU",
"services":{
"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":"localhost",
"iid":2,
"enabled":1,
"urlDest":"rtsp://40.73.41.176:554/test1"
}
],
"evslicer":[
{
"sn":"ILS-3",
"addr":"192.168.0.25",
"iid":3,
"path": "/var/lib/slices/"
}
],
"evml":[
{
"feature":"motion",
"sn":"ILS-4",
"addr":"192.168.0.26",
"iid":4
}
]
}
}
} }
*/
// tables: info, evmgr, evpuller, evpusher, evslice, evml, ipc, log // table and schema
// schemas:
// info: id, cls text, value text, version, update datetime // modules: id integer, pid integer, iid integer, cls text, sn text, config text, online integer, enabled integer, update
// ex: 1, sn, ILS112233, NULL, NULL // eg: 2, 0, NULL, evmgr, ILSEVMGR1, "xxxx", 1, 1, ts
// 2, evmgr, NULL, 1.2, 2019-09-02 // : 3, 2, NULL, ipc, NULL, "xxx", 1, 1, ts
// 3, evpuller, NULL, 1.2, 2019-09-02 // : 5, 3, 1, evpuller, "ILSEVPULLER1", "xxx", 1, 1, ts
// 4, evml-motion, NULL, 1.2, 2019-09-02 // cls = evmgr|ipc|evpuller|evpusher|evslicer|evmlmotion
// ipc: id, user, passwd, addr, status
// ex: 1, admin, FWBWTU, 172.31.0.51, 0 int getSlices(void *pUser, int iid, const char *fileName)
// evmgr: iid integer, sn, cid <id_of_ipc>, addr text, status {
// evpuller: iid, sn, cid <id_of_ipc>, addr, pub, rep, status; int ret = 0;
// evpusher: iid, sn, pid <id_of_puller>, urldest, enabled, status; sqlite3 * pdb = NULL;
// evslicer: iid, sn, pid, urldest, days, miniutes, status; auto v = static_cast< vector<int>* >(pUser);
// evml: iid, sn, pid, cls, enabled, status string stmt = "select ts from slices where iid="+to_string(iid)+" order by id;";
// pdb = exec(pUser, fileName, stmt.c_str(), _getSlices);
// if(sqlite3_errcode(pdb) != SQLITE_OK) {
// create
int getSlices(void *pUser, int iid, const char *fileName) { stmt = "create table if not exists slices(id integer, iid integer, ts integer);";
int ret = 0; pdb = exec(NULL, fileName, stmt.c_str(), NULL);
sqlite3 * pdb = NULL;
auto v = static_cast< vector<int>* >(pUser);
string stmt = "select ts from slices where iid="+to_string(iid)+" order by id;";
pdb = exec(pUser, fileName, stmt.c_str(), _getSlices);
if(sqlite3_errcode(pdb) != SQLITE_OK) { if(sqlite3_errcode(pdb) != SQLITE_OK) {
// create spdlog::error("failed create table slices for evslicer {}", iid);
stmt = "create table if not exists slices(id integer, iid integer, ts integer);"; return -1;
pdb = exec(NULL, fileName, stmt.c_str(), NULL); }
if(sqlite3_errcode(pdb) != SQLITE_OK) { else {
spdlog::error("failed create table slices for evslicer {}", iid); for(int i = 1; i <= v->size(); i ++) {
return -1; stmt = "insert into slices(id, iid, ts) values(" + to_string(i) + to_string(iid) + ", 0";
}else{ pdb = exec(NULL, fileName, stmt.c_str(), NULL);
for(int i = 1; i <= v->size(); i ++) { if(sqlite3_errcode(pdb) != SQLITE_OK) return -2;
stmt = "insert into slices(id, iid, ts) values(" + to_string(i) + to_string(iid) + ", 0"; v->push_back(0);
pdb = exec(NULL, fileName, stmt.c_str(), NULL);
if(sqlite3_errcode(pdb) != SQLITE_OK) return -2;
v->push_back(0);
}
stmt = "update slices set ts=1 where id = 1 and iid="+to_string(iid) +";";
pdb = exec(NULL, stmt.c_str(), NULL, NULL);
if(sqlite3_errcode(pdb) != SQLITE_OK) return -3;
v->at(0) = 2;
} }
}else{
stmt = "update slices set ts=1 where id = 1 and iid="+to_string(iid) +";";
pdb = exec(NULL, stmt.c_str(), NULL, NULL);
if(sqlite3_errcode(pdb) != SQLITE_OK) return -3;
v->at(0) = 2;
} }
return ret;
} }
else {
}
return ret;
}
} }
\ No newline at end of file
...@@ -29,13 +29,6 @@ namespace fs = std::filesystem; ...@@ -29,13 +29,6 @@ namespace fs = std::filesystem;
using namespace std; using namespace std;
using namespace zmqhelper; using namespace zmqhelper;
/**
* functions:
* app update
* control msg
*
**/
class EvMgr:public TinyThread { class EvMgr:public TinyThread {
private: private:
void *pRouterCtx = NULL; void *pRouterCtx = NULL;
...@@ -129,7 +122,7 @@ private: ...@@ -129,7 +122,7 @@ private:
json jEvt; json jEvt;
jEvt["type"] = EV_MSG_TYPE_CONN_STAT; jEvt["type"] = EV_MSG_TYPE_CONN_STAT;
jEvt["gid"] = selfId; jEvt["gid"] = selfId;
jEvt['ts'] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count(); jEvt["ts"] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
if(eventConn) { if(eventConn) {
jEvt["event"] = EV_MSG_EVENT_CONN_CONN; jEvt["event"] = EV_MSG_EVENT_CONN_CONN;
} }
......
/* /*
module: evmlmotion module: evmlmotion
description: description:
author: Bruce.Lu <lzbgt@icloud.com> author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/23 update: 2019/08/23
*/ */
...@@ -136,10 +136,11 @@ private: ...@@ -136,10 +136,11 @@ private:
urlRouter = string("tcp://") + evmgr["addr"].get<string>() + ":" + to_string(evmgr["port-router"]); urlRouter = string("tcp://") + evmgr["addr"].get<string>() + ":" + to_string(evmgr["port-router"]);
spdlog::info("evmlmotion {} {} will connect to {} for sub, {} for router", devSn, iid, urlPub, urlRouter); spdlog::info("evmlmotion {} {} will connect to {} for sub, {} for router", devSn, iid, urlPub, urlRouter);
// TODO: multiple protocols support // TODO: multiple protocols support
if(evmlmotion.count("path") == 0){ if(evmlmotion.count("path") == 0) {
spdlog::warn("evslicer {} {} no params for path, using default: {}", devSn, iid, URLOUT_DEFAULT); spdlog::warn("evslicer {} {} no params for path, using default: {}", devSn, iid, URLOUT_DEFAULT);
urlOut = URLOUT_DEFAULT; urlOut = URLOUT_DEFAULT;
}else{ }
else {
urlOut = evmlmotion["path"]; urlOut = evmlmotion["path"];
} }
...@@ -443,75 +444,79 @@ private: ...@@ -443,75 +444,79 @@ private:
// business logic for event // business logic for event
auto dura = chrono::duration_cast<chrono::seconds>(evtStartTm - evtStartTmLast).count(); auto dura = chrono::duration_cast<chrono::seconds>(evtStartTm - evtStartTmLast).count();
switch(evtState) { switch(evtState) {
case NONE: { case NONE: {
if(hasEvent) { if(hasEvent) {
evtState = PRE;
spdlog::info("state: NONE->PRE");
evtStartTmLast = evtStartTm;
}
break;
}
case PRE: {
if(hasEvent) {
if(dura > detPara.pre) {
spdlog::info("state: PRE->PRE");
evtState = PRE; evtState = PRE;
spdlog::info("state: NONE->PRE");
evtStartTmLast = evtStartTm;
} }
break; else {
} evtState = IN;
case PRE: { json p;
if(hasEvent) { spdlog::info("state: PRE->IN");
if(dura > detPara.pre) { p["type"] = EV_MSG_TYPE_AI_MOTION;
spdlog::info("state: PRE->PRE"); p["gid"] = selfId;
evtState = PRE; p["event"] = EV_MSG_EVENT_MOTION_START;
}else{ p["ts"] = chrono::duration_cast<chrono::seconds>(evtStartTmLast.time_since_epoch()).count();
evtState = IN; //p["frame"] = origin.clone();
json p; evtQueue->push(p.dump());
spdlog::info("state: PRE->IN"); if(evtQueue->size() > MAX_EVENT_QUEUE_SIZE * 2) {
p["type"] = EV_MSG_TYPE_AI_MOTION; evtQueue->pop();
p["gid"] = selfId;
p["event"] = EV_MSG_EVENT_MOTION_START;
p["ts"] = chrono::duration_cast<chrono::seconds>(evtStartTmLast.time_since_epoch()).count();
//p["frame"] = origin.clone();
evtQueue->push(p.dump());
if(evtQueue->size() > MAX_EVENT_QUEUE_SIZE * 2) {
evtQueue->pop();
}
}
}else{
if(dura > detPara.pre){
evtState= NONE;
spdlog::info("state: PRE->NONE");
} }
} }
break;
} }
case IN: { else {
if(!hasEvent){ if(dura > detPara.pre) {
if(dura > (int)(detPara.post/2)){ evtState= NONE;
evtState = POST; spdlog::info("state: PRE->NONE");
spdlog::info("state: IN->POST");
}
}else{
evtStartTmLast = evtStartTm;
spdlog::info("state: IN->IN");
} }
break;
} }
case POST: { break;
if(!hasEvent) { }
if(dura > detPara.post) { case IN: {
spdlog::info("state: POST->NONE"); if(!hasEvent) {
evtState = NONE; if(dura > (int)(detPara.post/2)) {
json p; evtState = POST;
p["type"] = EV_MSG_TYPE_AI_MOTION; spdlog::info("state: IN->POST");
p["gid"] = selfId; }
p["event"] = EV_MSG_EVENT_MOTION_END; }
p["ts"] = chrono::duration_cast<chrono::seconds>(evtStartTmLast.time_since_epoch()).count() + (int)(detPara.post/2); else {
evtQueue->push(p.dump()); evtStartTmLast = evtStartTm;
if(evtQueue->size() > MAX_EVENT_QUEUE_SIZE*2) { spdlog::info("state: IN->IN");
evtQueue->pop(); }
} break;
}
case POST: {
if(!hasEvent) {
if(dura > detPara.post) {
spdlog::info("state: POST->NONE");
evtState = NONE;
json p;
p["type"] = EV_MSG_TYPE_AI_MOTION;
p["gid"] = selfId;
p["event"] = EV_MSG_EVENT_MOTION_END;
p["ts"] = chrono::duration_cast<chrono::seconds>(evtStartTmLast.time_since_epoch()).count() + (int)(detPara.post/2);
evtQueue->push(p.dump());
if(evtQueue->size() > MAX_EVENT_QUEUE_SIZE*2) {
evtQueue->pop();
} }
}else{
spdlog::info("state: POST->IN");
evtState=IN;
evtStartTmLast = evtStartTm;
} }
break;
} }
else {
spdlog::info("state: POST->IN");
evtState=IN;
evtStartTmLast = evtStartTm;
}
break;
}
} }
} }
...@@ -526,13 +531,14 @@ protected: ...@@ -526,13 +531,14 @@ protected:
AVPacket packet; AVPacket packet;
//event thread //event thread
thEvent = thread([&,this](){ thEvent = thread([&,this]() {
json meta; meta["type"] = EV_MSG_META_EVENT; json meta;
meta["type"] = EV_MSG_META_EVENT;
string metaType = meta.dump(); string metaType = meta.dump();
int ret = 0; int ret = 0;
vector<vector<uint8_t> > v = {str2body(this->pullerGid), str2body(metaType), str2body("")}; vector<vector<uint8_t> > v = {str2body(this->pullerGid), str2body(metaType), str2body("")};
while(true){ while(true) {
if(!this->evtQueue->empty()){ if(!this->evtQueue->empty()) {
string evt = this->evtQueue->front(); string evt = this->evtQueue->front();
v[2] = str2body(evt); v[2] = str2body(evt);
this->evtQueue->pop(); this->evtQueue->pop();
...@@ -541,7 +547,8 @@ protected: ...@@ -541,7 +547,8 @@ protected:
if(ret < 0) { if(ret < 0) {
spdlog::error("evmlmotion {} {} failed to send event: {}, {}", this->devSn, this->iid, evt, zmq_strerror(zmq_errno())); spdlog::error("evmlmotion {} {} failed to send event: {}, {}", this->devSn, this->iid, evt, zmq_strerror(zmq_errno()));
} }
}else{ }
else {
this_thread::sleep_for(chrono::seconds(3)); this_thread::sleep_for(chrono::seconds(3));
} }
} }
...@@ -610,7 +617,8 @@ public: ...@@ -610,7 +617,8 @@ public:
getInputFormat(); getInputFormat();
setupStream(); setupStream();
}; };
~EvMLMotion() { ~EvMLMotion()
{
if(pSub != NULL) { if(pSub != NULL) {
zmq_close(pSub); zmq_close(pSub);
pSub = NULL; pSub = NULL;
...@@ -658,7 +666,8 @@ int main(int argc, const char *argv[]) ...@@ -658,7 +666,8 @@ int main(int argc, const char *argv[])
string p = evtQueue.front(); string p = evtQueue.front();
spdlog::info("event: {}", p); spdlog::info("event: {}", p);
evtQueue.pop(); evtQueue.pop();
}else{ }
else {
this_thread::sleep_for(chrono::duration(chrono::seconds(2))); this_thread::sleep_for(chrono::duration(chrono::seconds(2)));
} }
} }
......
/* /*
module: evpuller module: evpuller
description: description:
author: Bruce.Lu <lzbgt@icloud.com> author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/23 update: 2019/08/23
*/ */
...@@ -111,7 +111,7 @@ protected: ...@@ -111,7 +111,7 @@ protected:
// }); // });
// thPing.detach(); // thPing.detach();
// init response msg // init response msg
while (true) { while (true) {
if(checkStop() == true) { if(checkStop() == true) {
......
/* /*
module: evpusher module: evpusher
description: description:
author: Bruce.Lu <lzbgt@icloud.com> author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/23 update: 2019/08/23
*/ */
......
/* /*
module: evslicer module: evslicer
description: description:
author: Bruce.Lu <lzbgt@icloud.com> author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/20 update: 2019/08/20
*/ */
...@@ -20,6 +20,7 @@ update: 2019/08/20 ...@@ -20,6 +20,7 @@ update: 2019/08/20
#include <filesystem> #include <filesystem>
namespace fs = std::filesystem; namespace fs = std::filesystem;
#endif #endif
#include <cstdlib> #include <cstdlib>
#include "zmqhelper.hpp" #include "zmqhelper.hpp"
#include "tinythread.hpp" #include "tinythread.hpp"
...@@ -128,7 +129,7 @@ private: ...@@ -128,7 +129,7 @@ private:
numSlices = 24 * days * 60 /minutes; numSlices = 24 * days * 60 /minutes;
// alloc memory // alloc memory
sliceIdxToName = new vector<int>(numSlices); sliceIdxToName = new vector<int>(numSlices);
// load db // TODO: load db
// DB::exec(NULL, "select id, ts, last from slices;", DB::get_slices, sliceIdxToName); // DB::exec(NULL, "select id, ts, last from slices;", DB::get_slices, sliceIdxToName);
spdlog::info("mkdir -p {}", urlOut); spdlog::info("mkdir -p {}", urlOut);
ret = system((string("mkdir -p ") + urlOut).c_str()); ret = system((string("mkdir -p ") + urlOut).c_str());
...@@ -443,13 +444,13 @@ protected: ...@@ -443,13 +444,13 @@ protected:
break; break;
} }
} }
end = chrono::system_clock::now(); end = chrono::system_clock::now();
}// while in slice }// while in slice
// write tail // write tail
// close output context // close output context
if (pAVFormatRemux != NULL){ if (pAVFormatRemux != NULL) {
if(pAVFormatRemux->pb != NULL){ if(pAVFormatRemux->pb != NULL) {
avio_closep(&pAVFormatRemux->pb); avio_closep(&pAVFormatRemux->pb);
} }
avformat_free_context(pAVFormatRemux); avformat_free_context(pAVFormatRemux);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论