提交 3c7c2d91 authored 作者: tobyfan1980's avatar tobyfan1980

evcamera: refine log message

上级 2ca2ac3c
...@@ -26,3 +26,9 @@ ...@@ -26,3 +26,9 @@
*.out *.out
*.app *.app
CMakeFiles/ CMakeFiles/
# workspace
*.code-workspace
.DS_Store
# vendor
vendor/**
...@@ -47,5 +47,14 @@ source /root/setenv.sh ...@@ -47,5 +47,14 @@ source /root/setenv.sh
- server用到的库的安装路径是 <source_path>/vendor/x64 - server用到的库的安装路径是 <source_path>/vendor/x64
### 编译 ### 编译
- evcamera
在 hi3518 下运行 make 就可以编译出一个独立的可执行文件 evcamera.
- vgw
在 server 下运行 make 就可以编译出一个独立的可执行文件 vgw.
vgw 运行只需要依赖两个环境变量
* DARWIN_URL easy darwin 的 url, 如果没有, 使用默认的 rtsp://evcloudsvc.ilabservice.cloud:554
* LOG_LEVEL 日志输出等级. 如果没有, 日志 level 为 debug
\ No newline at end of file
...@@ -32,7 +32,7 @@ unsigned short crc16(const unsigned char* data_p, unsigned char length) ...@@ -32,7 +32,7 @@ unsigned short crc16(const unsigned char* data_p, unsigned char length)
} }
namespace evutils { namespace evutils {
const char consts::version[] = "EVC20200429"; const char consts::version[] = "v20200722";
const string consts::kMsgCmd = "cmd"; const string consts::kMsgCmd = "cmd";
const string consts::kMsgCmdConfig = "config"; const string consts::kMsgCmdConfig = "config";
const string consts::kMsgConfigVgw = "vgw"; const string consts::kMsgConfigVgw = "vgw";
......
...@@ -310,7 +310,7 @@ void frame_send_entry(void *args) ...@@ -310,7 +310,7 @@ void frame_send_entry(void *args)
while(1) { while(1) {
rlogger->info("perpare for pusher"); rlogger->info("perpare for pusher");
if(!gConfigSystem.module.sys.push) { if(!gConfigSystem.module.sys.push) {
gPusherFailsFlag |= 1 >> 2; gPusherFailsFlag |= 1 << 2;
this_thread::sleep_for(4s); this_thread::sleep_for(4s);
continue; continue;
} }
...@@ -1097,12 +1097,12 @@ int main(int argc, char *argv[]) ...@@ -1097,12 +1097,12 @@ int main(int argc, char *argv[])
MaQueStartParam_s startParam = {MAQUE_VIDEO_STANDARD_PAL, {MAQUE_VIDEO_COMPRESS_H264, MAQUE_VIDEO_COMPRESS_H265}}; MaQueStartParam_s startParam = {MAQUE_VIDEO_STANDARD_PAL, {MAQUE_VIDEO_COMPRESS_H264, MAQUE_VIDEO_COMPRESS_H265}};
::memcpy(startParam.aWritableDir, strMaQuePath.c_str(), sizeof(startParam.aWritableDir)); ::memcpy(startParam.aWritableDir, strMaQuePath.c_str(), sizeof(startParam.aWritableDir));
ret = LibXmMaQue_System_startUp(&startParam); ret = LibXmMaQue_System_startUp(&startParam);
rlogger->info("ret: {}", ret); rlogger->info("LibXmMaQue_System_startUp ret: {}", ret);
// //
MaQueMemoryApi_s memApi = {MaQue_Demo_Mem_alloc, MaQue_Demo_Mem_release, MaQue_Demo_Mem_addRef, MaQue_Demo_Mem_setLength}; MaQueMemoryApi_s memApi = {MaQue_Demo_Mem_alloc, MaQue_Demo_Mem_release, MaQue_Demo_Mem_addRef, MaQue_Demo_Mem_setLength};
ret = LibXmMaQue_Mem_init(&memApi); ret = LibXmMaQue_Mem_init(&memApi);
rlogger->info("mem ret: {}", ret); rlogger->info("LibXmMaQue_Mem_init ret: {}", ret);
MaQueSystemTime_s tm; MaQueSystemTime_s tm;
LibXmMaQue_Time_getCurrentTime(&tm); LibXmMaQue_Time_getCurrentTime(&tm);
...@@ -1110,9 +1110,9 @@ int main(int argc, char *argv[]) ...@@ -1110,9 +1110,9 @@ int main(int argc, char *argv[])
// //
MaQueCodeAbilities_s capb; MaQueCodeAbilities_s capb;
ret = LibXmMaQue_VideoEnc_getAbilities(0, &capb); ret = LibXmMaQue_VideoEnc_getAbilities(0, &capb);
rlogger->info("abt ret: {}", ret); rlogger->info("LibXmMaQue_VideoEnc_getAbilities ret: {}", ret);
if (XM_SUCCESS == ret) { if (XM_SUCCESS == ret) {
rlogger->info(fmt::format("capbilities: supported codecs {0:#b}," rlogger->info(fmt::format("VideoEncode capbilities: supported codecs {0:#b},"
"max fhd/s {0:d}, max res: {0:d}, per ch mres: {0:d}, {0:d}, {0:d}, {0:d}", "max fhd/s {0:d}, max res: {0:d}, per ch mres: {0:d}, {0:d}, {0:d}, {0:d}",
int(capb.videoEncTypeMask), int(capb.videoEncTypeMask),
int(capb.maxEncPowerX1080P), int(capb.eDecImageSizeMax), int(capb.astVidEncChnAbility[0].eCapSizeMax), int(capb.maxEncPowerX1080P), int(capb.eDecImageSizeMax), int(capb.astVidEncChnAbility[0].eCapSizeMax),
...@@ -1157,11 +1157,11 @@ int main(int argc, char *argv[]) ...@@ -1157,11 +1157,11 @@ int main(int argc, char *argv[])
int64_t delta = 0; int64_t delta = 0;
while(delta < dura||always) { while(delta < dura||always) {
string result; string result;
rlogger->info("got qr job"); rlogger->info("scanning qr code");
string res = qr_analysis(result); string res = qr_analysis(result);
if(res.empty()) { if(res.empty()) {
/// TODO: handle result /// TODO: handle result
rlogger->info("processing qr event"); rlogger->info("processing qr code: {}", result);
process_qr_event(result); process_qr_event(result);
if(!always) { if(!always) {
// set to stop // set to stop
...@@ -1205,7 +1205,7 @@ int main(int argc, char *argv[]) ...@@ -1205,7 +1205,7 @@ int main(int argc, char *argv[])
bGotTime = true; bGotTime = true;
} }
else { else {
rlogger->warn("failed to get ntp time"); rlogger->warn("failed to get ntp time, start scanning QR for 10 seconds, and retry ntp 3 seconds later");
// enable QR // enable QR
gQRCodeDuration.store(10, memory_order_relaxed); gQRCodeDuration.store(10, memory_order_relaxed);
} }
...@@ -1219,6 +1219,7 @@ int main(int argc, char *argv[]) ...@@ -1219,6 +1219,7 @@ int main(int argc, char *argv[])
/// subscribe to mqtt /// subscribe to mqtt
while(gMqttClient == nullptr) { while(gMqttClient == nullptr) {
rlogger->info("enter qr mode, to scan MQ host url and retry connection");
gQRCodeDuration.store(-1, memory_order_relaxed); gQRCodeDuration.store(-1, memory_order_relaxed);
/// TODO: handle result /// TODO: handle result
gMqttClient = start_mqtt(nullptr); gMqttClient = start_mqtt(nullptr);
...@@ -1249,11 +1250,11 @@ int main(int argc, char *argv[]) ...@@ -1249,11 +1250,11 @@ int main(int argc, char *argv[])
} }
/// TODO: configuration issues handling /// TODO: configuration issues handling
if(msg_field(gJsonConfig, consts::kMsgConfigVgw).empty()) { if(msg_field(gJsonConfig, consts::kMsgConfigVgw).empty()) {
rlogger->error("missing vgw config"); rlogger->error("missing vgw config, won't be able to live streaming");
} }
thread thPush = thread(frame_send_entry, &args); thread thPush = thread(frame_send_entry, &args);
rlogger->info("sizeof pkt header {}, sizeof tv {}", sizeof(evpacket_t), sizeof(timeval)); rlogger->info("sizeof pkt header {}, sizeof timeval {}", sizeof(evpacket_t), sizeof(timeval));
if(thPush.joinable()) { if(thPush.joinable()) {
thPush.detach(); thPush.detach();
} }
...@@ -1277,10 +1278,12 @@ int main(int argc, char *argv[]) ...@@ -1277,10 +1278,12 @@ int main(int argc, char *argv[])
rlogger->info("started video upload service"); rlogger->info("started video upload service");
} }
// start motion detection
start_md_bd(&gConfigSystem); start_md_bd(&gConfigSystem);
gQRCodeDuration.store(0); gQRCodeDuration.store(0);
// start human detection
thread thSmart = thread(maq_smart_task_entry, &gConfigSystem); thread thSmart = thread(maq_smart_task_entry, &gConfigSystem);
if(thSmart.joinable()) { if(thSmart.joinable()) {
thSmart.detach(); thSmart.detach();
......
...@@ -43,14 +43,14 @@ namespace md{ ...@@ -43,14 +43,14 @@ namespace md{
/// helpers /// helpers
auto event_inspection(auto e, std::map<const std::string, int> &m){ auto event_inspection(auto e, std::map<const std::string, int> &m){
if(std::is_same<decltype(e), people>::value){ if(std::is_same<decltype(e), people>::value){
rlogger->info("type is people: {}", ++m[kKeyP]); rlogger->info("event type is people: count {}", ++m[kKeyP]);
}else if(std::is_same<decltype(e), motion>::value){ }else if(std::is_same<decltype(e), motion>::value){
rlogger->info("type is motion: {}", ++m[kKeyM]); rlogger->info("event type is motion: count {}", ++m[kKeyM]);
}else if(std::is_same<decltype(e), mpboth>::value){ }else if(std::is_same<decltype(e), mpboth>::value){
rlogger->info("type is mpboth"); rlogger->info("event type is mpboth");
return true; return true;
}else if(std::is_same<decltype(e), none>::value){ }else if(std::is_same<decltype(e), none>::value){
rlogger->info("type is none: {}", ++m[kKeyN]); rlogger->info("event type is none: count {}", ++m[kKeyN]);
} }
return false; return false;
} }
...@@ -89,9 +89,9 @@ namespace md{ ...@@ -89,9 +89,9 @@ namespace md{
hasMotion = 0; hasMotion = 0;
timeStart = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count(); timeStart = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
if(std::is_same<decltype(e), people>::value){ if(std::is_same<decltype(e), people>::value){
rlogger->info("none -p-> in, {}", timeStart/1000); rlogger->info("event state transition: none (people) --> in, {}", timeStart/1000);
}else if(std::is_same<decltype(e), mpboth>::value){ }else if(std::is_same<decltype(e), mpboth>::value){
rlogger->info("none -b-> in, {}", timeStart/1000); rlogger->info("event state transition: none (both) --> in, {}", timeStart/1000);
hasMotion++; hasMotion++;
} }
...@@ -102,9 +102,9 @@ namespace md{ ...@@ -102,9 +102,9 @@ namespace md{
if(timeStart==0) if(timeStart==0)
timeStart = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count(); timeStart = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
if(std::is_same<decltype(e), people>::value){ if(std::is_same<decltype(e), people>::value){
rlogger->info("pre -p-> in: time {}", timeStart/1000); rlogger->info("event state transition: pre (people) --> in, time {}", timeStart/1000);
}else if(std::is_same<decltype(e), mpboth>::value){ }else if(std::is_same<decltype(e), mpboth>::value){
rlogger->info("pre -b-> in: time {}", timeStart/1000); rlogger->info("event state transition: pre (both) --> in, time {}", timeStart/1000);
hasMotion++; hasMotion++;
} }
}; };
...@@ -122,12 +122,12 @@ namespace md{ ...@@ -122,12 +122,12 @@ namespace md{
const auto action_post2none = [this](auto e){ const auto action_post2none = [this](auto e){
auto timeEnd = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count(); auto timeEnd = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
if(std::is_same<decltype(e), people>::value){ if(std::is_same<decltype(e), people>::value){
rlogger->info("post -p-> none, {}", timeEnd/1000); rlogger->info("event state transition: post (people) --> none, {}", timeEnd/1000);
}else if(std::is_same<decltype(e), motion>::value){ }else if(std::is_same<decltype(e), motion>::value){
hasMotion++; hasMotion++;
rlogger->info("post -m-> none, {}", timeEnd/1000); rlogger->info("event state transition: post (motion) --> none, {}", timeEnd/1000);
}else if(std::is_same<decltype(e), none>::value){ }else if(std::is_same<decltype(e), none>::value){
rlogger->info("post -n-> none, {}", timeEnd/1000); rlogger->info("event state transition: post (none) --> none, {}", timeEnd/1000);
} }
if(hasMotion >= 1) { if(hasMotion >= 1) {
...@@ -183,21 +183,21 @@ namespace md{ ...@@ -183,21 +183,21 @@ namespace md{
using namespace sml; using namespace sml;
return make_transition_table( return make_transition_table(
*"init"_s = "none"_s, *"init"_s = "none"_s,
"none"_s + event<none>/[]{rlogger->info("none -> none");} = "none"_s, "none"_s + event<none>/[]{/* don't print this transition */} = "none"_s,
"none"_s + event<motion>/[]{rlogger->info("none -m-> pre");} = "pre"_s, "none"_s + event<motion>/[]{rlogger->info("event state transition: none (motion) --> pre");} = "pre"_s,
"none"_s + event<people>/action_none2in = "in"_s, "none"_s + event<people>/action_none2in = "in"_s,
"none"_s + event<mpboth>/action_none2in = "in"_s, "none"_s + event<mpboth>/action_none2in = "in"_s,
// pre // pre
"pre"_s + event<none>/[]{rlogger->info("pre -n-> none");} = "none"_s, "pre"_s + event<none>/[]{rlogger->info("event state transition: pre (none) --> none");} = "none"_s,
"pre"_s + event<motion>/action_pre2pre = "pre"_s, "pre"_s + event<motion>/action_pre2pre = "pre"_s,
"pre"_s + event<people>/action_pre2in = "in"_s, "pre"_s + event<people>/action_pre2in = "in"_s,
"pre"_s + event<mpboth>/action_pre2in = "in"_s, "pre"_s + event<mpboth>/action_pre2in = "in"_s,
// in // in
"in"_s + event<none> [guard_in2post]/[]{rlogger->info("in -n-> post");} = "post"_s, "in"_s + event<none> [guard_in2post]/[]{rlogger->info("event state transition: in (none) --> post");} = "post"_s,
"in"_s + event<motion> [guard_in2post]/[]{rlogger->info("in -m-> post");} = "post"_s, "in"_s + event<motion> [guard_in2post]/[]{rlogger->info("event state transition: in (motion) --> post");} = "post"_s,
"in"_s + event<people> [guard_in2post]/[]{rlogger->info("in -p-> post");} = "post"_s, "in"_s + event<people> [guard_in2post]/[]{rlogger->info("event state transition: in (people) --> post");} = "post"_s,
"in"_s + event<mpboth>/guard_in2post, "in"_s + event<mpboth>/guard_in2post,
"in"_s + sml::on_entry<_> / may_generate_event, "in"_s + sml::on_entry<_> / may_generate_event,
......
...@@ -31,7 +31,7 @@ extern "C" { ...@@ -31,7 +31,7 @@ extern "C" {
#define MAGIC_TAIL2 ((uint8_t)0xDE) #define MAGIC_TAIL2 ((uint8_t)0xDE)
#define MAGIC_TAIL3 ((uint8_t)0xAD) #define MAGIC_TAIL3 ((uint8_t)0xAD)
#define EV_UPLOAD_MAX_BUF_SIZE 1200 #define EV_UPLOAD_MAX_BUF_SIZE 1024
static const int kMaxHeapSize = 1 * 1024 * 1024; static const int kMaxHeapSize = 1 * 1024 * 1024;
using namespace std; using namespace std;
...@@ -53,6 +53,7 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set< ...@@ -53,6 +53,7 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set<
{ {
string rc; string rc;
uint8_t * buf = (uint8_t *)malloc(EV_UPLOAD_MAX_BUF_SIZE); uint8_t * buf = (uint8_t *)malloc(EV_UPLOAD_MAX_BUF_SIZE);
rlogger->info("start uploading video of camera {} from {} to {}, total {} slices, type {}", dev_sn, tss, tse, slices.size(), type);
int s = 0; int s = 0;
try { try {
...@@ -66,10 +67,29 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set< ...@@ -66,10 +67,29 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set<
rc = fmt::format("failed to connect to {}", hostUrl); rc = fmt::format("failed to connect to {}", hostUrl);
} }
else { else {
/**
* META := SN_LEN, SN, START_TS, END_TS, TYPE, NUM, {FILE_META*NUM} # 元数据
SN_LEN := UINT16 # 摄像头SN长度 一般8字节
SN := {UINT8*SN_LEN} # 摄像头SN, 长度为SN_LEN
START_TS := TS # 事件开始时间
END_TS := TS # 事件结束时间
TYPE := UINT8 # 0 - 未定义, 1 - AI人形, 2 - AI人脸, 3 - 移动侦测,
# 4 - 覆盖, 5 - 覆盖解除, 6 - 视频获取
# 其他 - 由发起请求的微服务自定义
FILE_META := FILE_TS,SIZE
FILE_TS := TS # 文件开始时间
SIZE := UINT32 # 文件字节数
NUM := UINT32 # 4-byte unsigned int. 视频文件数目
TS := INT64 # 8-byte long. 时间戳
注意: 目前, 代码中写死了, SN 为 12 个字节.
**/
auto metaLen = 2 + 12 + 8 + 8 + 1 + 4 + (8 + 4)*slices.size(); auto metaLen = 2 + 12 + 8 + 8 + 1 + 4 + (8 + 4)*slices.size();
// head : MAGIC_HEADD + META + CRC
auto headLen = 2 + metaLen + 2; auto headLen = 2 + metaLen + 2;
if(headLen > EV_UPLOAD_MAX_BUF_SIZE) { if(headLen > EV_UPLOAD_MAX_BUF_SIZE) {
rc = fmt::format("too many files to upload, ignored: {}", slices.size()); rc = fmt::format("too many files ({}) to upload such that header ({}) is too large, ignore uploading.", slices.size(), headLen);
} }
else { else {
vector<uint32_t> fsize; vector<uint32_t> fsize;
...@@ -122,9 +142,14 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set< ...@@ -122,9 +142,14 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set<
totalLen +=2; totalLen +=2;
assert(totalLen = headLen); assert(totalLen = headLen);
rlogger->info("header len: {}, crc: {}", totalLen, crc_); rlogger->info("header len: {}, crc: {}", totalLen, crc_);
bool file_transfer_failed = false;
// send header // send header
rc = raw_send(s, buf, totalLen); rc = raw_send(s, buf, totalLen);
if(!rc.empty()) { if(!rc.empty()) {
file_transfer_failed = true;
rlogger->error("failed to send file header. err: " + rc);
rc = fmt::format("{}, {}:{}", rc, uri.Host, uri.Port); rc = fmt::format("{}, {}:{}", rc, uri.Host, uri.Port);
} }
else { else {
...@@ -135,13 +160,14 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set< ...@@ -135,13 +160,14 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set<
uint32_t total_sent = 0; uint32_t total_sent = 0;
auto fpath = string(consts::recFilePath) + to_string(k) + ".h264"; auto fpath = string(consts::recFilePath) + to_string(k) + ".h264";
memcpy(buf, &fsize[idx], 4); memcpy(buf, &fsize[idx], 4);
file_transfer_failed = false;
FILE *fp = fopen(fpath.c_str(), "rb"); FILE *fp = fopen(fpath.c_str(), "rb");
if(!fp) { if(!fp) {
rc = fmt::format("failed open file : {}", fpath); rc = fmt::format("failed open file : {}", fpath);
break; break;
} }
else { else {
rlogger->info("sending file {}: {}", fpath, fsize[idx]); rlogger->info("sending file {}: size {}", fpath, fsize[idx]);
for(int i = 0; readsize > 0; i++) { for(int i = 0; readsize > 0; i++) {
if(i == 0) { if(i == 0) {
readsize = ::fread(buf+4, 1, EV_UPLOAD_MAX_BUF_SIZE - 4, fp) + 4; readsize = ::fread(buf+4, 1, EV_UPLOAD_MAX_BUF_SIZE - 4, fp) + 4;
...@@ -153,6 +179,8 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set< ...@@ -153,6 +179,8 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set<
if((i == 0 && readsize > 4) ||(i !=0 && readsize > 0)) { if((i == 0 && readsize > 4) ||(i !=0 && readsize > 0)) {
rc = raw_send(s, buf, readsize); rc = raw_send(s, buf, readsize);
if(!rc.empty()) { if(!rc.empty()) {
file_transfer_failed = true;
rlogger->error("failed to send file data via socket. err: {}", rc);
break; break;
} }
} }
...@@ -169,6 +197,9 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set< ...@@ -169,6 +197,9 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set<
rc = fmt::format("error read file: {}", strerror(errno)); rc = fmt::format("error read file: {}", strerror(errno));
rlogger->error(rc); rlogger->error(rc);
break; break;
} else if (file_transfer_failed){
rlogger->error("file transfer failed, skip rest file upload");
break;
} }
else { else {
rlogger->info("sent file {}: total {}, sent {}", fpath, fsize[idx], total_sent - 4); rlogger->info("sent file {}: total {}, sent {}", fpath, fsize[idx], total_sent - 4);
...@@ -177,18 +208,28 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set< ...@@ -177,18 +208,28 @@ string upload_video(string hostUrl, char* dev_sn, int64_t tss, int64_t tse, set<
idx++; idx++;
} }
} }
if (!file_transfer_failed){
rlogger->info("sending upload tail");
// construct tail // construct tail
buf[0] = MATIC_TAIL0; buf[0] = MATIC_TAIL0;
buf[1] = MAGIC_TAIL1; buf[1] = MAGIC_TAIL1;
buf[2] = MAGIC_TAIL2; buf[2] = MAGIC_TAIL2;
buf[3] = MAGIC_TAIL3; buf[3] = MAGIC_TAIL3;
rc = raw_send(s, buf, 4); rc = raw_send(s, buf, 4);
if(!rc.empty()){
rlogger->error("failed to send upload tail. err: {}", rc);
rc = fmt::format("upload tail error: {}", rc);
}
}
} }
} }
} }
} }
catch(exception &e) { catch(exception &e) {
rc = fmt::format("failed to send to {}: {}, {}:{}", hostUrl, e.what(), __FILE__, __LINE__); rc = fmt::format("exception sending file to {}: {}, {}:{}", hostUrl, e.what(), __FILE__, __LINE__);
} }
free(buf); free(buf);
...@@ -320,7 +361,7 @@ void upload_svc_entry(thread_upload_args_t *pArg) ...@@ -320,7 +361,7 @@ void upload_svc_entry(thread_upload_args_t *pArg)
bUpload = true; bUpload = true;
} }
if(bUpload) { if(bUpload) {
rlogger->info("waiting for job"); rlogger->debug("waiting for job");
} }
{ {
unique_lock<mutex> lk(*pArg->mut); unique_lock<mutex> lk(*pArg->mut);
...@@ -328,7 +369,7 @@ void upload_svc_entry(thread_upload_args_t *pArg) ...@@ -328,7 +369,7 @@ void upload_svc_entry(thread_upload_args_t *pArg)
}// lock released }// lock released
if(got && pArg->que->size()> 0) { if(got && pArg->que->size()> 0) {
rlogger->info("process one job, total left {}", pArg->que->size()); rlogger->info("process one upload job, total left {}", pArg->que->size());
auto elem = pArg->que->front(); auto elem = pArg->que->front();
pArg->que->pop(); pArg->que->pop();
...@@ -473,7 +514,13 @@ void remove_ts_file(int64_t ts) ...@@ -473,7 +514,13 @@ void remove_ts_file(int64_t ts)
fs::remove(fname); fs::remove(fname);
} }
// 0 - OK, -1: exception;
/**
* write to sd
* if immediate is false, copy to heap buffer, dump heap to file when the heap if full
* if immediate is true, directly write to file.
* return: 0 - OK, -1: exception;
*/
static int cached_sd_write(fstream *fp, char *buf, int sz, bool immediate = false) static int cached_sd_write(fstream *fp, char *buf, int sz, bool immediate = false)
{ {
int ret = 0; int ret = 0;
...@@ -483,9 +530,9 @@ static int cached_sd_write(fstream *fp, char *buf, int sz, bool immediate = fals ...@@ -483,9 +530,9 @@ static int cached_sd_write(fstream *fp, char *buf, int sz, bool immediate = fals
try { try {
if(!immediate) { if(!immediate) {
if(current_heap_size + sz > kMaxHeapSize) { if(current_heap_size + sz > kMaxHeapSize) {
rlogger->info("write full cached buffer to recording file. size {}", current_heap_size);
fp->write(heap_buff, current_heap_size); fp->write(heap_buff, current_heap_size);
current_heap_size = 0; current_heap_size = 0;
rlogger->info("cached_sd_write");
} }
memcpy(heap_buff + current_heap_size, buf, sz); memcpy(heap_buff + current_heap_size, buf, sz);
...@@ -493,9 +540,11 @@ static int cached_sd_write(fstream *fp, char *buf, int sz, bool immediate = fals ...@@ -493,9 +540,11 @@ static int cached_sd_write(fstream *fp, char *buf, int sz, bool immediate = fals
} }
else { else {
if(current_heap_size > 0) { if(current_heap_size > 0) {
rlogger->info("write cached buffer to recording file. size {}", current_heap_size);
fp->write(heap_buff, current_heap_size); fp->write(heap_buff, current_heap_size);
current_heap_size = 0; current_heap_size = 0;
} }
rlogger->info("write to recording file. size {}", sz);
fp->write(buf, sz); fp->write(buf, sz);
} }
} }
......
...@@ -175,7 +175,7 @@ void maq_smart_task_entry(ev_module_config_t *pArg) ...@@ -175,7 +175,7 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
return; return;
} }
rlogger->info("finished smart init"); rlogger->info("finished smart human detection initialization");
stCallback.eType = MAQUE_SMART_JPEG_ENCODE_LARGE;//MAQUE_SMART_JPEG_ENCODE_CUTOUT; stCallback.eType = MAQUE_SMART_JPEG_ENCODE_LARGE;//MAQUE_SMART_JPEG_ENCODE_CUTOUT;
stCallback.eClass = MAQUE_SMART_JPEG_CLASS_PD;//MAQUE_SMART_JPEG_CLASS_FD; stCallback.eClass = MAQUE_SMART_JPEG_CLASS_PD;//MAQUE_SMART_JPEG_CLASS_FD;
...@@ -250,7 +250,7 @@ void maq_smart_task_entry(ev_module_config_t *pArg) ...@@ -250,7 +250,7 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
fsm.process_event(md::people{}); fsm.process_event(md::people{});
} }
else { else {
rlogger->info("ai_task: deltaTimeMs {}, none", deltaTimeMs); rlogger->debug("ai_task: deltaTimeMs {}, none", deltaTimeMs);
fsm.process_event(md::none{}); fsm.process_event(md::none{});
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论