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

upload video files

上级 2566dd52
...@@ -104,7 +104,8 @@ private: ...@@ -104,7 +104,8 @@ private:
this->peerData["config"][peerId] = v; this->peerData["config"][peerId] = v;
if(this->peerData["status"].count(peerId) == 0) { if(this->peerData["status"].count(peerId) == 0) {
this->peerData["status"][peerId] = -1; // unkown this->peerData["status"][peerId] = -1; // unkown
}else{ }
else {
// nop // nop
} }
this->peerData["enabled"][peerId] = 1; this->peerData["enabled"][peerId] = 1;
...@@ -119,8 +120,8 @@ private: ...@@ -119,8 +120,8 @@ private:
for(auto &m : ml) { for(auto &m : ml) {
if(m["sn"] != this->devSn) { if(m["sn"] != this->devSn) {
continue; continue;
} }
string peerName; string peerName;
ret = cfgutils::getPeerId(mn, m, peerId, peerName); ret = cfgutils::getPeerId(mn, m, peerId, peerName);
if(ret != 0) { if(ret != 0) {
...@@ -130,14 +131,16 @@ private: ...@@ -130,14 +131,16 @@ private:
if(m.count("enabled") == 0 || m["enabled"] == 0) { if(m.count("enabled") == 0 || m["enabled"] == 0) {
spdlog::warn("evdaemon {} {} was disabled", this->devSn, mn); spdlog::warn("evdaemon {} {} was disabled", this->devSn, mn);
this->peerData["enabled"][peerId] = 0; this->peerData["enabled"][peerId] = 0;
}else{ }
else {
this->peerData["enabled"][peerId] = 1; this->peerData["enabled"][peerId] = 1;
} }
this->peerData["config"][peerId] = v; this->peerData["config"][peerId] = v;
if(this->peerData["status"].count(peerId) == 0) { if(this->peerData["status"].count(peerId) == 0) {
this->peerData["status"][peerId] = -1; // unkown this->peerData["status"][peerId] = -1; // unkown
}else{ }
else {
// nop // nop
} }
...@@ -186,18 +189,20 @@ private: ...@@ -186,18 +189,20 @@ private:
int cnt = 0; int cnt = 0;
for(auto &[k,v]: this->peerData["config"].items()) { for(auto &[k,v]: this->peerData["config"].items()) {
if(this->peerData["enabled"].count(k) != 0 && this->peerData["enabled"][k] != 0) { if(this->peerData["enabled"].count(k) != 0 && this->peerData["enabled"][k] != 0) {
if((this->peerData["status"].count(k) == 0 || this->peerData["status"][k] == 0)){ if((this->peerData["status"].count(k) == 0 || this->peerData["status"][k] == 0)) {
tmp.push_back(k); tmp.push_back(k);
info += (cnt == 0? "" : string(", ")) + k; info += (cnt == 0? "" : string(", ")) + k;
}else if(this->peerData["status"][k] == -1) { }
else if(this->peerData["status"][k] == -1) {
unkown[k] = -1; unkown[k] = -1;
} }
}else{ }
terms.push_back(k); else {
terms.push_back(k);
} }
cnt++; cnt++;
} }
spdlog::info("evdaemon {} will start following subsystems: {}", devSn, info); spdlog::info("evdaemon {} will start following subsystems: {}", devSn, info);
// //
for(string &e : tmp) { for(string &e : tmp) {
...@@ -276,7 +281,7 @@ private: ...@@ -276,7 +281,7 @@ private:
string meta = j.dump(); string meta = j.dump();
vector<vector<uint8_t> > v = {str2body(selfId), str2body(this->daemonId), str2body(meta), str2body(cfg)}; vector<vector<uint8_t> > v = {str2body(selfId), str2body(this->daemonId), str2body(meta), str2body(cfg)};
z_send_multiple(pRouter, v); z_send_multiple(pRouter, v);
spdlog::info("evdaemon {} peer {} config sent: {}", devSn ,selfId, cfg); spdlog::info("evdaemon {} peer {} config sent: {}", devSn,selfId, cfg);
} }
else { else {
peerData["status"][selfId] = 0; peerData["status"][selfId] = 0;
...@@ -416,7 +421,8 @@ private: ...@@ -416,7 +421,8 @@ private:
if(meta == EV_MSG_META_CONFIG) { if(meta == EV_MSG_META_CONFIG) {
if(data.size() == 0) { if(data.size() == 0) {
spdlog::error("evdaemon {} received invalid empty config", devSn); spdlog::error("evdaemon {} received invalid empty config", devSn);
} else { }
else {
this->deltaCfg = json::diff(this->config, data); this->deltaCfg = json::diff(this->config, data);
spdlog::info("evdaemon {} received cloud config diff: {}\nnew: {}", devSn, this->deltaCfg.dump(4), data.dump()); spdlog::info("evdaemon {} received cloud config diff: {}\nnew: {}", devSn, this->deltaCfg.dump(4), data.dump());
if(this->deltaCfg.size() != 0 || this->bColdStart) { if(this->deltaCfg.size() != 0 || this->bColdStart) {
...@@ -440,9 +446,10 @@ private: ...@@ -440,9 +446,10 @@ private:
if(bBootstrap) { if(bBootstrap) {
// TODO: wait for previous started modules to connecting // TODO: wait for previous started modules to connecting
startSubSystems(); startSubSystems();
}else{ }
else {
spdlog::info("evdaemon {} skip startup subsystems since BOOTSTRAP is set to false", devSn); spdlog::info("evdaemon {} skip startup subsystems since BOOTSTRAP is set to false", devSn);
} }
} }
} }
} }
...@@ -539,7 +546,7 @@ public: ...@@ -539,7 +546,7 @@ public:
EvDaemon() EvDaemon()
{ {
/// peerId -> value /// peerId -> value
peerData["status"] = json(); peerData["status"] = json();
peerData["pids"] = json(); peerData["pids"] = json();
peerData["config"] = json(); peerData["config"] = json();
......
...@@ -83,9 +83,10 @@ private: ...@@ -83,9 +83,10 @@ private:
} }
spdlog::info("evmgr {} bind success to {}", devSn, addr); spdlog::info("evmgr {} bind success to {}", devSn, addr);
inited = true; inited = true;
error_exit: error_exit:
if(inited) { if(inited) {
}else{ }
else {
exit(1); exit(1);
} }
} }
...@@ -93,7 +94,7 @@ private: ...@@ -93,7 +94,7 @@ private:
spdlog::error("evmgr {} exception on init() for: {}. abort booting up.", devSn, e.what()); spdlog::error("evmgr {} exception on init() for: {}. abort booting up.", devSn, e.what());
exit(1); exit(1);
} }
spdlog::info("evmgr {} successfuly inited", devSn); spdlog::info("evmgr {} successfuly inited", devSn);
} }
...@@ -285,7 +286,8 @@ public: ...@@ -285,7 +286,8 @@ public:
} }
devSn = v[0]; devSn = v[0];
}else{ }
else {
spdlog::error("evmgr failed to start. no SN set"); spdlog::error("evmgr failed to start. no SN set");
exit(1); exit(1);
} }
...@@ -301,9 +303,9 @@ public: ...@@ -301,9 +303,9 @@ public:
ret = zmqhelper::recvConfigMsg(pDealer, config, addr, ident); ret = zmqhelper::recvConfigMsg(pDealer, config, addr, ident);
if(ret != 0) { if(ret != 0) {
spdlog::error("evmgr {} failed to receive configration message {}", devSn , addr); spdlog::error("evmgr {} failed to receive configration message {}", devSn, addr);
} }
init(); init();
} }
~EvMgr() ~EvMgr()
......
...@@ -70,7 +70,7 @@ private: ...@@ -70,7 +70,7 @@ private:
AVFormatContext *pAVFormatInput = nullptr; AVFormatContext *pAVFormatInput = nullptr;
AVCodecContext *pCodecCtx = nullptr; AVCodecContext *pCodecCtx = nullptr;
AVDictionary *pOptsRemux = nullptr; AVDictionary *pOptsRemux = nullptr;
DetectParam detPara = {25,500,-1,10,3,30, 2}; DetectParam detPara = {25, 500, -1, 10, 3, 30, 0.3};
EventState evtState = EventState::NONE; EventState evtState = EventState::NONE;
chrono::system_clock::time_point evtStartTm, evtStartTmLast; chrono::system_clock::time_point evtStartTm, evtStartTmLast;
queue<string> *evtQueue; queue<string> *evtQueue;
...@@ -81,7 +81,7 @@ private: ...@@ -81,7 +81,7 @@ private:
thread thEvent; thread thEvent;
string drport = "5549"; string drport = "5549";
// //
int init() int init()
{ {
int ret = 0; int ret = 0;
...@@ -577,13 +577,14 @@ protected: ...@@ -577,13 +577,14 @@ protected:
string evt = this->evtQueue->front(); string evt = this->evtQueue->front();
json jevt = json::parse(evt); json jevt = json::parse(evt);
this->evtQueue->pop(); this->evtQueue->pop();
if(jevt["event"] == EV_MSG_EVENT_MOTION_START){ if(jevt["event"] == EV_MSG_EVENT_MOTION_START) {
eventToSlicer["type"] = "event"; eventToSlicer["type"] = "event";
eventToSlicer["start"] = jevt["ts"]; eventToSlicer["start"] = jevt["ts"];
eventToSlicer["extraInfo"] = json(); //array eventToSlicer["extraInfo"] = json(); //array
eventToSlicer["extraInfo"].push_back(jevt); eventToSlicer["extraInfo"].push_back(jevt);
// TODO: save and load saved evt on crash // TODO: save and load saved evt on crash
}else if(jevt["event"] == EV_MSG_EVENT_MOTION_END){ }
else if(jevt["event"] == EV_MSG_EVENT_MOTION_END) {
eventToSlicer["end"] = jevt["ts"]; eventToSlicer["end"] = jevt["ts"];
eventToSlicer["extraInfo"].push_back(jevt); eventToSlicer["extraInfo"].push_back(jevt);
v[2] = str2body(eventToSlicer.dump()); v[2] = str2body(eventToSlicer.dump());
...@@ -595,7 +596,8 @@ protected: ...@@ -595,7 +596,8 @@ protected:
spdlog::info("evmlmotion {} sent event to {}: {}", this->selfId, this->slicerGid, eventToSlicer.dump()); spdlog::info("evmlmotion {} sent event to {}: {}", this->selfId, this->slicerGid, eventToSlicer.dump());
} }
eventToSlicer.clear(); eventToSlicer.clear();
}else{ }
else {
spdlog::error("evmlmotion {} unknown event to {}: {}", this->selfId, this->slicerGid, eventToSlicer.dump()); spdlog::error("evmlmotion {} unknown event to {}: {}", this->selfId, this->slicerGid, eventToSlicer.dump());
} }
......
...@@ -55,7 +55,8 @@ private: ...@@ -55,7 +55,8 @@ private:
ret = z_send_multiple(pDealer, rep); ret = z_send_multiple(pDealer, rep);
if(ret < 0) { if(ret < 0) {
spdlog::error("evpuller {} failed to send avformatctx data to requester {}: {}", selfId, peerId, zmq_strerror(zmq_errno())); spdlog::error("evpuller {} failed to send avformatctx data to requester {}: {}", selfId, peerId, zmq_strerror(zmq_errno()));
}else{ }
else {
spdlog::info("evpuller {} success to send avformatctx data to requester {}", selfId, peerId); spdlog::info("evpuller {} success to send avformatctx data to requester {}", selfId, peerId);
} }
} }
...@@ -103,9 +104,10 @@ public: ...@@ -103,9 +104,10 @@ public:
RepSrv(RepSrv&&) = delete; RepSrv(RepSrv&&) = delete;
RepSrv(string mgrSn, string devSn, int iid, const char* formatBytes, RepSrv(string mgrSn, string devSn, int iid, const char* formatBytes,
int len, void *pDealer):mgrSn(mgrSn),devSn(devSn), iid(iid), bytes(formatBytes), int len, void *pDealer):mgrSn(mgrSn),devSn(devSn), iid(iid), bytes(formatBytes),
len(len), pDealer(pDealer) { len(len), pDealer(pDealer)
selfId = devSn+":evpuller:" + to_string(iid); {
}; selfId = devSn+":evpuller:" + to_string(iid);
};
~RepSrv() {}; ~RepSrv() {};
}; };
...@@ -126,13 +128,14 @@ private: ...@@ -126,13 +128,14 @@ private:
string drport = "5549"; string drport = "5549";
bool isIpStr(string ip) { bool isIpStr(string ip)
{
int cnt = 3*4 + 3; int cnt = 3*4 + 3;
if(ip.size() == 0 || ip.size() > cnt) { if(ip.size() == 0 || ip.size() > cnt) {
return false; return false;
} }
auto v = strutils::split(ip, '.'); auto v = strutils::split(ip, '.');
if(v.size() == 0 || v.size () != 4){ if(v.size() == 0 || v.size () != 4) {
return false; return false;
} }
...@@ -154,7 +157,7 @@ private: ...@@ -154,7 +157,7 @@ private:
int init() int init()
{ {
bool inited = false; bool inited = false;
int ret = 0; int ret = 0;
bool found = false; bool found = false;
string user, passwd, addr; string user, passwd, addr;
try { try {
...@@ -180,7 +183,7 @@ private: ...@@ -180,7 +183,7 @@ private:
if(ipc.size()!=0 && evpuller.size()!=0) { if(ipc.size()!=0 && evpuller.size()!=0) {
found = true; found = true;
} }
if(!found) { if(!found) {
spdlog::error("evpuller {} no valid config found", devSn); spdlog::error("evpuller {} no valid config found", devSn);
...@@ -194,27 +197,29 @@ private: ...@@ -194,27 +197,29 @@ private:
// default stream port // default stream port
if(ipc.count("port") == 0) { if(ipc.count("port") == 0) {
ipcPort = "554"; ipcPort = "554";
}else{ }
else {
ipcPort = to_string(ipc["port"]); ipcPort = to_string(ipc["port"]);
} }
string ipcAddr = ipc["addr"].get<string>(); string ipcAddr = ipc["addr"].get<string>();
if(isIpStr(ipcAddr)){ if(isIpStr(ipcAddr)) {
string chan = "ch1"; string chan = "ch1";
string streamName = "main"; string streamName = "main";
if(ipc.count("channel") != 0 && !ipc["channel"].get<string>().empty()){ if(ipc.count("channel") != 0 && !ipc["channel"].get<string>().empty()) {
chan = ipc["channel"].get<string>(); chan = ipc["channel"].get<string>();
} }
if(ipc.count("streamName") != 0 && !ipc["streamName"].get<string>().empty()){ if(ipc.count("streamName") != 0 && !ipc["streamName"].get<string>().empty()) {
streamName = ipc["streamName"].get<string>(); streamName = ipc["streamName"].get<string>();
} }
if(ipc.count("proto") != 0 && !ipc["proto"].get<string>().empty()){ if(ipc.count("proto") != 0 && !ipc["proto"].get<string>().empty()) {
proto = ipc["proto"]; proto = ipc["proto"];
} }
urlIn = proto + "://" + user + ":" + passwd + "@" + ipc["addr"].get<string>() + ":" + ipcPort + "/h264/" + chan + "/" + streamName + "/av_stream"; urlIn = proto + "://" + user + ":" + passwd + "@" + ipc["addr"].get<string>() + ":" + ipcPort + "/h264/" + chan + "/" + streamName + "/av_stream";
}else{ }
else {
urlIn = ipcAddr; urlIn = ipcAddr;
} }
...@@ -249,7 +254,7 @@ private: ...@@ -249,7 +254,7 @@ private:
exit(1); exit(1);
} }
ret = zmq_connect(pDealer, urlDealer.c_str()); ret = zmq_connect(pDealer, urlDealer.c_str());
if(ret < 0) { if(ret < 0) {
spdlog::error("evpuller {} failed to connect to router {}", selfId, urlDealer); spdlog::error("evpuller {} failed to connect to router {}", selfId, urlDealer);
exit(1); exit(1);
} }
...@@ -277,10 +282,11 @@ protected: ...@@ -277,10 +282,11 @@ protected:
string proto = urlIn.substr(0,4); string proto = urlIn.substr(0,4);
if(proto == "rtsp") { if(proto == "rtsp") {
av_dict_set(&optsIn, "rtsp_transport", "tcp", 0); av_dict_set(&optsIn, "rtsp_transport", "tcp", 0);
}else{ }
else {
// //
} }
spdlog::info("evpuller {} openning stream: {}", selfId, urlIn); spdlog::info("evpuller {} openning stream: {}", selfId, urlIn);
if ((ret = avformat_open_input(&pAVFormatInput, urlIn.c_str(), NULL, &optsIn)) < 0) { if ((ret = avformat_open_input(&pAVFormatInput, urlIn.c_str(), NULL, &optsIn)) < 0) {
spdlog::error("evpuller {} Could not open input stream {}", selfId, urlIn); spdlog::error("evpuller {} Could not open input stream {}", selfId, urlIn);
...@@ -396,7 +402,8 @@ public: ...@@ -396,7 +402,8 @@ public:
} }
devSn = v[0]; devSn = v[0];
iid = stoi(v[2]); iid = stoi(v[2]);
}else{ }
else {
spdlog::error("evpuller {} failed to start. no SN set", selfId); spdlog::error("evpuller {} failed to start. no SN set", selfId);
exit(1); exit(1);
} }
...@@ -411,7 +418,7 @@ public: ...@@ -411,7 +418,7 @@ public:
ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId); ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId);
if(ret != 0) { if(ret != 0) {
spdlog::error("evpuller {} failed to receive configration message {}", selfId , addr); spdlog::error("evpuller {} failed to receive configration message {}", selfId, addr);
} }
init(); init();
} }
......
...@@ -93,13 +93,13 @@ private: ...@@ -93,13 +93,13 @@ private:
spdlog::info("evpusher {} connect to {} for sub, {} for router", selfId, urlPub, urlDealer); spdlog::info("evpusher {} connect to {} for sub, {} for router", selfId, urlPub, urlDealer);
// TODO: multiple protocols support // TODO: multiple protocols support
urlOut = evpusher["urlDest"].get<string>(); urlOut = evpusher["urlDest"].get<string>();
// setup sub // setup sub
pSubCtx = zmq_ctx_new(); pSubCtx = zmq_ctx_new();
pSub = zmq_socket(pSubCtx, ZMQ_SUB); pSub = zmq_socket(pSubCtx, ZMQ_SUB);
ret = zmq_setsockopt(pSub, ZMQ_SUBSCRIBE, "", 0); ret = zmq_setsockopt(pSub, ZMQ_SUBSCRIBE, "", 0);
if(ret != 0) { if(ret != 0) {
spdlog::error("evpusher {} {} failed set setsockopt: {}", devSn, iid, urlPub); spdlog::error("evpusher {} {} failed set setsockopt: {}", devSn, iid, urlPub);
} }
ret = zmq_connect(pSub, urlPub.c_str()); ret = zmq_connect(pSub, urlPub.c_str());
if(ret != 0) { if(ret != 0) {
...@@ -223,12 +223,14 @@ private: ...@@ -223,12 +223,14 @@ private:
ret = AVERROR_UNKNOWN; ret = AVERROR_UNKNOWN;
} }
ret = avformat_alloc_output_context2(&pAVFormatRemux, nullptr, "rtsp", urlOut.c_str()); ret = avformat_alloc_output_context2(&pAVFormatRemux, nullptr, "rtsp", urlOut.c_str());
}else if(proto == "rtmp"){ }
else if(proto == "rtmp") {
ret = avformat_alloc_output_context2(&pAVFormatRemux, nullptr, "rtmp", urlOut.c_str()); ret = avformat_alloc_output_context2(&pAVFormatRemux, nullptr, "rtmp", urlOut.c_str());
}else{ }
else {
ret = avformat_alloc_output_context2(&pAVFormatRemux, nullptr, nullptr, urlOut.c_str()); ret = avformat_alloc_output_context2(&pAVFormatRemux, nullptr, nullptr, urlOut.c_str());
} }
if (ret < 0) { if (ret < 0) {
spdlog::error("evpusher {} {} failed create avformatcontext for output: %s", devSn, iid, av_err2str(ret)); spdlog::error("evpusher {} {} failed create avformatcontext for output: %s", devSn, iid, av_err2str(ret));
exit(1); exit(1);
...@@ -406,7 +408,8 @@ public: ...@@ -406,7 +408,8 @@ public:
} }
devSn = v[0]; devSn = v[0];
iid = stoi(v[2]); iid = stoi(v[2]);
}else{ }
else {
spdlog::error("evpusher failed to start. no SN set"); spdlog::error("evpusher failed to start. no SN set");
exit(1); exit(1);
} }
...@@ -421,7 +424,7 @@ public: ...@@ -421,7 +424,7 @@ public:
ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId); ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId);
if(ret != 0) { if(ret != 0) {
spdlog::error("evpusher {} failed to receive configration message {}", devSn , addr); spdlog::error("evpusher {} failed to receive configration message {}", devSn, addr);
} }
init(); init();
......
...@@ -112,7 +112,8 @@ private: ...@@ -112,7 +112,8 @@ private:
eventQueue.pop(); eventQueue.pop();
} }
cvEvent.notify_one(); cvEvent.notify_one();
}else{ }
else {
spdlog::error("evslicer {} msg not supported from {}: {}", selfId, peerId, msg); spdlog::error("evslicer {} msg not supported from {}: {}", selfId, peerId, msg);
} }
} }
...@@ -597,7 +598,7 @@ protected: ...@@ -597,7 +598,7 @@ protected:
// remove // remove
fs::path fname(this->urlOut + "/" + videoFileTs2Name(i) + ".mp4"); fs::path fname(this->urlOut + "/" + videoFileTs2Name(i) + ".mp4");
fs::remove(fname); fs::remove(fname);
// TODO: currently we don't cache event videos. lost on reboot. // TODO: currently we don't cache event videos. lost on reboot.
// TODO: this behavior will be enhenced later. // TODO: this behavior will be enhenced later.
continue; continue;
...@@ -628,7 +629,7 @@ protected: ...@@ -628,7 +629,7 @@ protected:
for(auto &i : evts) { for(auto &i : evts) {
string fullPath = i.get_path(); string fullPath = i.get_path();
size_t pos = fullPath.find(ext, 0); size_t pos = fullPath.find(ext, 0);
if(fullPath.size() < ext.size() || pos == string::npos || pos != (fullPath.size() - ext.size())){ if(fullPath.size() < ext.size() || pos == string::npos || pos != (fullPath.size() - ext.size())) {
spdlog::debug("evslicer {} invalid file : {}", self->selfId, fullPath); spdlog::debug("evslicer {} invalid file : {}", self->selfId, fullPath);
continue; continue;
} }
...@@ -681,18 +682,21 @@ protected: ...@@ -681,18 +682,21 @@ protected:
{ {
if(seg >= numSlices) { if(seg >= numSlices) {
seg -= numSlices; seg -= numSlices;
}else if(seg <=-1) { }
else if(seg <=-1) {
seg = numSlices + seg; seg = numSlices + seg;
} }
return seg; return seg;
} }
int incSegHead(int seg) { int incSegHead(int seg)
{
return segToIdx(++seg); return segToIdx(++seg);
} }
int decSegHead(int seg) { int decSegHead(int seg)
{
return segToIdx(--seg); return segToIdx(--seg);
} }
...@@ -704,11 +708,12 @@ protected: ...@@ -704,11 +708,12 @@ protected:
int _itss = 0; int _itss = 0;
if(bSegFull) { if(bSegFull) {
_itss = segHead; _itss = segHead;
}else{ }
else {
_itss = 1; _itss = 1;
} }
if(segHead == -1){ if(segHead == -1) {
spdlog::error("evslicer {} no local records."); spdlog::error("evslicer {} no local records.");
return ret; return ret;
} }
...@@ -756,7 +761,8 @@ protected: ...@@ -756,7 +761,8 @@ protected:
return ret; return ret;
} }
void printSlices(){ void printSlices()
{
for(int i = 0; i < numSlices; i++) { for(int i = 0; i < numSlices; i++) {
spdlog::info("evslicer {} vector[{}] = {}, {}", selfId, i, vTsActive[i], videoFileTs2Name(vTsActive[i])); spdlog::info("evslicer {} vector[{}] = {}, {}", selfId, i, vTsActive[i], videoFileTs2Name(vTsActive[i]));
if(vTsActive[i] == 0) { if(vTsActive[i] == 0) {
...@@ -842,16 +848,16 @@ public: ...@@ -842,16 +848,16 @@ public:
string evt; string evt;
unique_lock<mutex> lk(this->mutEvent); unique_lock<mutex> lk(this->mutEvent);
this->cvEvent.wait(lk, [this] {return !(this->eventQueue.empty());}); this->cvEvent.wait(lk, [this] {return !(this->eventQueue.empty());});
if(!this->eventQueue.empty()) { if(!this->eventQueue.empty()) {
evt = this->eventQueue.front(); evt = this->eventQueue.front();
this->eventQueue.pop(); this->eventQueue.pop();
} }
if(evt.empty()){ if(evt.empty()) {
continue; continue;
} }
json jEvt = json::parse(evt); json jEvt = json::parse(evt);
if(jEvt["type"] == "event") { if(jEvt["type"] == "event") {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论