派生自 development/c++

chenshijun
2019-03-07 c24b03d43977b75db84e03bfcdbe3a7b1ae2c1ea
QiaoJiaSystem/VideoAnalysFromHC/RtspAnalysElement.cpp
@@ -26,8 +26,8 @@
}
RtspAnalysElement::RtspAnalysElement(LDBTool *_dbTool) : m_lDBTool(_dbTool), maxCount(50), currentCount(0) {
    init();
    resetFdfs();
    init();
    {
//        std::thread httpServer([&]() {
//            //#todo port
@@ -68,8 +68,55 @@
}
void RtspAnalysElement::init() {
    m_GB28181_Enable = appPref.getIntData("GB28181_Enable");
    Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo();
#ifndef GB28181
    //#todo GB28181
    if (m_GB28181_Enable) {
        auto lst = m_lDBTool->searchCamDevTableByType(1);
        appPref.setIntData("n_cut_max_duration", lst_dev.n_cut_max_duration);
        appPref.setIntData("n_cut_min_duration", lst_dev.n_cut_min_duration);
        if (lst.size() > 0) {
//        Json::Value json;
            for (auto &item : lst) {
                std::string t_camIdex = item.str_cam_dev_id.toStdString();
                std::string rtsp_url = "GB28181";
//            rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(),
//                                                 item.str_password.toStdString(), item.str_brand.toStdString());
                SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(item.str_cam_dev_id);
                for (auto &rule:ruleMap) {
                    rule.second.strAddr = item.str_addr;
                    rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first);
                    if (rule.second.nSdkType == PerStaticSdk) {
                        float temp = 1 - (float) (rule.second.nThreshold) / 100;
                        rule.second.fSensitivity = (75 + 25 * temp) / 100;
                    } else if (rule.second.nSdkType != FaceSdk) {
                        float temp = 1 - (float) (rule.second.nThreshold) / 100;
                        rule.second.fSensitivity = (5 + 90 * temp) / 100;
                    }
                    DBG("fSensitivity" << rule.second.fSensitivity);
                }
                appPref.setStringData(t_camIdex + "rtsp", rtsp_url);
                // appPref.setStringData(t_camIdex+"addr", item.str_addr.toStdString());
//            json["rtsp"] = rtsp_url;
                // json["addr"] = item.str_addr.toStdString();
                INFO("cam add is " << item.str_addr.toStdString());
                addCamera(t_camIdex, ruleMap);
            }
        } else {
            ERR("searchCamDevTableAll size is 0");
        }
    } else {
    auto lst = m_lDBTool->searchCamDevTableAll();
    appPref.setIntData("n_cut_max_duration", lst_dev.n_cut_max_duration);
@@ -185,50 +232,9 @@
        ERR("searchCamDevTableAll size is 0");
    }
#else
    auto lst = m_lDBTool->searchCamDevTableByType(1);
    appPref.setIntData("n_cut_max_duration", lst_dev.n_cut_max_duration);
    appPref.setIntData("n_cut_min_duration", lst_dev.n_cut_min_duration);
    if (lst.size() > 0) {
//        Json::Value json;
        for (auto &item : lst) {
            std::string t_camIdex = item.str_cam_dev_id.toStdString();
            std::string rtsp_url = "GB28181";
//            rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(),
//                                                 item.str_password.toStdString(), item.str_brand.toStdString());
            SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(item.str_cam_dev_id);
            for (auto &rule:ruleMap) {
                rule.second.strAddr = item.str_addr;
                rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first);
                if (rule.second.nSdkType == PerStaticSdk) {
                    float temp = 1 - (float) (rule.second.nThreshold) / 100;
                    rule.second.fSensitivity = (75 + 25 * temp) / 100;
                } else if (rule.second.nSdkType != FaceSdk) {
                    float temp = 1 - (float) (rule.second.nThreshold) / 100;
                    rule.second.fSensitivity = (5 + 90 * temp) / 100;
                }
                DBG("fSensitivity" << rule.second.fSensitivity);
            }
            appPref.setStringData(t_camIdex + "rtsp", rtsp_url);
            // appPref.setStringData(t_camIdex+"addr", item.str_addr.toStdString());
//            json["rtsp"] = rtsp_url;
            // json["addr"] = item.str_addr.toStdString();
            INFO("cam add is " << item.str_addr.toStdString());
            addCamera(t_camIdex, ruleMap);
        }
    } else {
        ERR("searchCamDevTableAll size is 0");
    }
#endif
}
RtspAnalysElement::~RtspAnalysElement() {
    for (auto controller: controllers) {