From 23bd97eaa5626ad96ca3f5d3e97e93d14705ca6d Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期六, 30 三月 2019 17:50:24 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/yangwu1.3' into 1.3nsq
---
QiaoJiaSystem/DataManagerServer/http_configserver.cpp | 65 +++++++++++++++++++++-----------
1 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
index 64595d9..b53818f 100644
--- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
+++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
@@ -22,6 +22,7 @@
#include <time.h>
#include <dirent.h>
#include "basic/pipe_element/ffmpeg/basic_struct_for_video_image.h"
+#include <basic/timer_counter/Clocktimer.h>
#include "vss/controller/VssDevTblController.h"
#include "vss/controller/VssChannelTblController.h"
@@ -33,7 +34,7 @@
using namespace std;
devHttpServer_c::devHttpServer_c()
- : _HttpSrvRetRecieve("0.0.0.0", 8083, 1), erlangDbTool(nullptr), m_SqliteFaceEncap("LocalDataDB") {
+ : _HttpSrvRetRecieve("0.0.0.0", 8083, 1), erlangDbTool(nullptr), m_SqliteFaceEncap("LocalDataDB"){
init();
}
@@ -73,6 +74,10 @@
void devHttpServer_c::init(void) {
std::string strDevId = appConfig.getStringProperty("DEV_ID");
+
+ //nsq
+ nsqMsgProducer = new BasicMsg::Nsq::NsqMsgProducer("127.0.0.1", "4150");
+ nsqMsgProducer->init();
// DSVAD010120181119
m_batch = strDevId.substr(5, 2);
@@ -292,10 +297,10 @@
elem["n_duration"] = iter->n_duration;
elem["str_brand"] = iter->str_brand.toStdString();
elem["str_reserved"] = iter->str_reserved.toStdString();
- cout << elem.toStyledString() << endl;
+ DBG(elem.toStyledString());
value.append(elem);
}
- cout << value.toStyledString() << endl;
+ DBG(value.toStyledString());
// std::string out = value.toStyledString();
std::string out = value.size() > 0 ? value.toStyledString() : "[]";
@@ -696,7 +701,7 @@
}
dev_rec.str_storage_dev_id = QString::fromLatin1((const char *) serialnumber);//鑾峰彇纾佺洏闃靛垪鐨勮澶噄d
- std::cout << dev_rec.str_storage_dev_id.toStdString() << std::endl;
+ DBG(dev_rec.str_storage_dev_id.toStdString());
ret = db_c.updateDeviceTable(dev_rec);
} else {
return "{\"ret_status\": \"浼犺緭閿欒锛岃妫�鏌ワ紒\"}";
@@ -743,7 +748,7 @@
std::string str_result;
std::string str_tmp;
for (int i = 0; i < lvecUsefulChans.size(); i++) {
- std::cout << lvecUsefulChans.at(i) << std::endl;
+ DBG(lvecUsefulChans.at(i));
str_tmp = std::to_string(lvecUsefulChans.at(i));
str_result += str_tmp;
str_result += ",";
@@ -888,17 +893,17 @@
}
}
- cout << elem.toStyledString() << endl;
+ DBG(elem.toStyledString());
value.append(elem);
}
for (std::vector<int>::iterator it1 = chns.begin(); it1 != chns.end(); it1++) {
chn_unused["n_chn"] = *it1;
- cout << "*it1" << *it1 << endl;
+ DBG("*it1" << *it1);
value.append(chn_unused);
}
- cout << value.toStyledString() << endl;
+ DBG(value.toStyledString());
// std::string out = value.toStyledString();
std::string out = value.size() > 0 ? value.toStyledString() : "[]";
return out;
@@ -1026,12 +1031,12 @@
// elem["str_det_thr"] = rec_sdk.str_det_thr.toStdString();
// elem["str_cmp_thr"] = rec_sdk.str_cmp_thr.toStdString();
- cout << elem.toStyledString() << endl;
+ DBG(elem.toStyledString());
value.append(elem);
}
- cout << value.toStyledString() << endl;
+ DBG(value.toStyledString());
std::string out = value.size() > 0 ? value.toStyledString() : "[]";
return out;
}
@@ -1167,8 +1172,8 @@
std::string publish_basepath = rtmpAddr + "cam" + str_uuid;
DBG("publish_basepath:" << publish_basepath);
appPref.setStringData("publish.basepath", publish_basepath);
- appPref.setIntData("pulish.width", 640);
- appPref.setIntData("pulish.height", 360);
+// appPref.setIntData("pulish.width", 1920);
+// appPref.setIntData("pulish.height", 1080);
if (m_rtmp.find(ip) != m_rtmp.end()) {
if (m_rtmp[ip].appPC == nullptr) {
@@ -1220,8 +1225,8 @@
std::string publish_basepath = rtmpAddr + "cam" + str_uuid;
DBG("publish_basepath:" << publish_basepath);
appPref.setStringData("publish.basepath", publish_basepath);
- appPref.setIntData("pulish.width", 640);
- appPref.setIntData("pulish.height", 360);
+// appPref.setIntData("pulish.width", 1920);
+// appPref.setIntData("pulish.height", 1080);
if (m_rtmp.find(ip) != m_rtmp.end()) {
if (m_rtmp[ip].appPC == nullptr) {
@@ -1447,7 +1452,7 @@
"sed -i '/tracker_server=/d' ./WebFDSClient.conf && sed -i '/\\\"host:port\\\"/atracker_server=" + \
value["web_pic_ip"].asString() + ":" + std::to_string(value["web_pic_port"].asInt()) + \
"' ./WebFDSClient.conf";//
- std::cout << "cmd_web:" << cmd_web << std::endl;
+ DBG("cmd_web:" << cmd_web);
system(cmd_web.c_str());
//#todo fastDfsClient
@@ -1456,7 +1461,7 @@
"sed -i '/tracker_server=/d' ./fastDfsClient.conf && sed -i '/\\\"host:port\\\"/atracker_server=" + \
value["es_pic_ip"].asString() + ":" + std::to_string(value["es_pic_port"].asInt()) + \
"' ./fastDfsClient.conf";
- std::cout << "cmd_es:" << cmd_es << std::endl;
+ DBG("cmd_es:" << cmd_es);
system(cmd_es.c_str());
//#todo config
@@ -1529,9 +1534,13 @@
}
if (ret) {
- killVideoAnalysFromHCApp();
- sleep(1);
- runAllApp();
+ //todo
+ {
+ std::string topic = "cut_dura_edit";
+ std::string msg = content;
+ DBG("msg:" << msg);
+ nsqMsgProducer->Publish(topic, (void *) (&msg));
+ }
return "{\"ret_status\": \"ok_ack\"}";
} else {
return "{\"ret_status\": \"鍐呭鏈夎锛岃妫�鏌ワ紒\"}";
@@ -1611,7 +1620,7 @@
// system("sed -i 's/address .*$/address 192.168.1.111/g' test");
std::string cmd_ip =
"sed -i 's/address .*$/address " + ip_addr + "/g' /etc/network/interfaces";
- std::cout << "cmd_ip:" << cmd_ip << std::endl;
+ DBG("cmd_ip:" << cmd_ip);
system(cmd_ip.c_str());
//淇敼config.json
@@ -2273,7 +2282,7 @@
fieldValues.insert(std::make_pair("uuid", strUUID));
fieldValues.insert(std::make_pair("idCard", idcard));
- m_SqliteFaceEncap.updateFace(TableName, addFaceData, fieldValues);
+ ret_addPerson = m_SqliteFaceEncap.updateFace(TableName, addFaceData, fieldValues);
}
} else {
@@ -2671,6 +2680,7 @@
std::string strSelectTemplate = R"#( -vf "select=eq(n\,%d)")#";
sprintf(selectExpBuff, strSelectTemplate.c_str(), frameIdDiff - 1);
if (videoSt.Valid() && imgSt.Valid()) {
+ ClockTimer clockTimer1("ffmpeg getpic");
std::string cmd("ffmpeg -i '" + videoPath + "'" + std::string(selectExpBuff) + " -vframes 1" + " -y '" +
str_imgName + "'");
INFO("Video To Image Cmd: " << cmd);
@@ -2680,17 +2690,20 @@
return "{\"error\":\"鏈煡鍒拌棰戣矾寰刓"}";
}
+ ClockTimer clockTimer2("cv::imread(str_imgName)");
cv::Mat img = cv::imread(str_imgName);
if (img.empty()) {
ERR("{\"error\":\"Video File error\"}");
return "{\"error\":\"瑙嗛鏂囦欢閿欒\"}";
}
+ ClockTimer clockTimer3("CvUtil::cvMat2Buffer(img, buffer)");
std::vector<unsigned char> buffer;
CvUtil::cvMat2Buffer(img, buffer);
std::string img_url = "http://";
fdfsClient.rwLock.rdlock();
if (fdfsClient.fastFds != nullptr) {
+ ClockTimer clockTimer4("fdfsClient.fastFds->uploadFile");
std::string t_strImg = "";
if (!fdfsClient.fastFds->uploadFile(buffer, t_strImg, "jpg")) {
img_url = "upload image fail";
@@ -2834,7 +2847,7 @@
appConfig.setStringProperty("DEV_ID", dev_id);
appConfig.save();
- //std::cout<<dev_id<<std::endl;
+
return true;
}
@@ -3338,6 +3351,8 @@
}
std::string devHttpServer_c::getSnapshot(std::string ip, unsigned int port, std::string content, PResponse &response) {
+ DBG("ip:" << ip << "; port:" << port);
+ DBG("content: " << content);
Json::Reader reader;
Json::Value value;
@@ -3406,7 +3421,11 @@
fdfsClient.rwLock.unlock();
Json::Value result;
result["imgUrl"] = strImgUrl;
- db_c.updateCamDevSnapshot(QString::fromStdString(rtsp_ip), QString::fromStdString(strImgUrl));
+ if (value.isMember("id")) {
+ db_c.updateCamDevSnapshotbyID(value["id"].asString().c_str(), QString::fromStdString(strImgUrl));
+ } else {
+ db_c.updateCamDevSnapshot(QString::fromStdString(rtsp_ip), QString::fromStdString(strImgUrl));
+ }
return result.toStyledString();
--
Gitblit v1.8.0