提交 39bf8d53 authored 作者: tobyfan1980's avatar tobyfan1980

vgw: add more comments and logs

上级 e65ecfc1
......@@ -289,6 +289,8 @@ int setupRouter(void **ctx, void **s, string addr, int rcvQS=0)
if(rcvQS !=0) {
zmq_setsockopt(*s, ZMQ_RCVHWM, &rcvQS, sizeof(rcvQS));
}
spdlog::info("zmq binding {}", addr);
ret = zmq_bind(*s, addr.c_str());
if(ret < 0) {
spdlog::error("failed to bind zmq at {} for reason: {}, retrying load configuration...", addr, zmq_strerror(zmq_errno()));
......@@ -314,6 +316,7 @@ int main()
darwinUrl = string(darwinUrl_);
}
// set log level
auto logLevel_ = getenv("LOG_LEVEL");
if(logLevel_) {
spdlog::set_level(spdlog::level::from_str(logLevel_));
......@@ -323,6 +326,7 @@ int main()
spdlog::set_level(spdlog::level::debug);
}
// setup zmq, listening incoming connections
string addr = "tcp://0.0.0.0:7123";
if(setupRouter(&pRouterCtx, &pRouter, addr)<0) {
exit(1);
......@@ -372,9 +376,13 @@ int main()
if(deviceMap.count(sn) == 0) {
deviceLock.emplace(sn, new mutex());
deviceMap.emplace(sn, new packet_processor_t());
spdlog::info("add camera {} to device map", sn);
deviceMap[sn]->sn = sn;
}
}
// for the first packet, change the transmitting state and start a thread to handle
// incoming packets.
if(deviceMap[sn]->state == 0) {
deviceMap[sn]->state = 1;
thread thWorker = thread(fn_worker, deviceMap[sn]);
......@@ -383,6 +391,8 @@ int main()
}
}
// for each camera, we cache at most 10 packets in a queue, when overflow, remove the earliest one
// before pushing to queue.
{
lock_guard<mutex> lg(*deviceLock[sn]);
if(deviceMap[sn]->pktQue.size() > 10) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论