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();
}
@@ -1118,6 +1119,17 @@
    if (DEV_NO_TYPE == dev_type) {//add new camera
        db_c.updateConfigTableByDevType(DEV_CAMERA);
        {
            //#todo
//            std::string topic = "VideoToImageMulth";
//            std::string topic1 = "VideoAnalysFromHC";
//            Json::Value json_cfg;
//            json_cfg["cam_edit"] = content;
//            std::string msg = json_cfg.toStyledString();
//            DBG("msg:" << msg);
//            nsqMsgProducer->Publish(topic, (void *) (&msg));
//            nsqMsgProducer->Publish(topic1, (void *) (&msg));
        }
        runAllApp();
    }
        //edit camera's sdks
@@ -1125,9 +1137,20 @@
             (rec_sdk_old.str_det_thr != rec_sdk.str_det_thr) ||
             (rec_sdk_old.str_cmp_thr != rec_sdk.str_cmp_thr)) */
    {
        killVideoAnalysFromHCApp();
        sleep(1);
        runAllApp();
        //#todo sendMessage To haikang&VideoToImage
        {
            std::string topic = "VideoToImageMulth";
            std::string topic1 = "VideoAnalysFromHC";
            Json::Value json_cfg;
            json_cfg["cam_edit"] = content;
            std::string msg = json_cfg.toStyledString();
            DBG("msg:" << msg);
            nsqMsgProducer->Publish(topic, (void *) (&msg));
            nsqMsgProducer->Publish(topic1, (void *) (&msg));
        }
//        killVideoAnalysFromHCApp();
//        sleep(1);
//        runAllApp();
    }
    Json::Value value_out;
@@ -1171,8 +1194,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) {
@@ -1224,8 +1247,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) {
@@ -1407,12 +1430,22 @@
        QString cam_id = QString::fromStdString(value_reader["str_cam_dev_id"].asString());
        int ret = db_c.deleteCamDevandSdkByCamID(cam_id);
        if (ret) {
            killVideoAnalysFromHCApp();
//            killVideoAnalysFromHCApp();
            int dev_record = db_c.searchCamDevNumber();
            if (dev_record == 0) {
                db_c.updateConfigTableByDevType(DEV_NO_TYPE);
            } else {
                runAllApp();
//                runAllApp();
            }
            {
                std::string topic = "VideoToImageMulth";
                std::string topic1 = "VideoAnalysFromHC";
                Json::Value json_cfg;
                json_cfg["cam_del"] = content;
                std::string msg = json_cfg.toStyledString();
                DBG("msg:" << msg);
                nsqMsgProducer->Publish(topic, (void *) (&msg));
                nsqMsgProducer->Publish(topic1, (void *) (&msg));
            }
            return "{\"ret_status\": \"ok_ack\"}";
        } else {
@@ -1533,10 +1566,12 @@
    }
    if (ret) {
        //todo
        //todo VideoToImageMulth
        {
            std::string topic = "cut_dura_edit";
            std::string msg = content;
            std::string topic = "VideoToImageMulth";
            Json::Value json_cfg;
            json_cfg["cut_dura_edit"] = content;
            std::string msg = json_cfg.toStyledString();
            DBG("msg:" << msg);
            nsqMsgProducer->Publish(topic, (void *) (&msg));
        }
@@ -2679,6 +2714,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);
@@ -2688,17 +2724,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";