| | |
| | | |
| | | //nsq set callback func |
| | | DBG("NsqMsgConsumer Init"); |
| | | nsqMsgConsumer = new BasicMsg::Nsq::NsqMsgConsumer("127.0.0.1", "4150", "cut_dura_edit", to_string(appPref.getIntData("RpcVTIMPort"))); |
| | | nsqMsgConsumer = new BasicMsg::Nsq::NsqMsgConsumer("127.0.0.1", "4150", "cut_dura_edit", |
| | | to_string(appPref.getIntData("RpcVTIMPort"))); |
| | | nsqMsgConsumer->setMessageCallback(std::bind(&OnMsgFunc, std::placeholders::_1, this)); |
| | | nsqMsgConsumer->init(); |
| | | DBG("NsqMsgConsumer Init END!!"); |
| | |
| | | Json::Reader reader; |
| | | Json::Value value; |
| | | if (reader.parse(msg->body.ToString(), value)) { |
| | | int cut_max_duration = value["cut_max_duration"].asInt(); |
| | | int cut_min_duration = value["cut_min_duration"].asInt(); |
| | | DBG("cut_max_duration: " << cut_max_duration << " cut_min_duration: " << cut_min_duration); |
| | | appPref.setIntData("n_cut_max_duration", cut_max_duration); |
| | | appPref.setIntData("n_cut_min_duration", cut_min_duration); |
| | | auto itor_json_end = value.end(); |
| | | Json::Value cfg_val; |
| | | for (auto itor_json = value.begin(); itor_json != itor_json_end; ++itor_json) { |
| | | if (itor_json->isString() && reader.parse(itor_json->asString(), cfg_val)) { |
| | | if (itor_json.name() == "cut_dura_edit") { |
| | | int cut_max_duration = cfg_val["cut_max_duration"].asInt(); |
| | | int cut_min_duration = cfg_val["cut_min_duration"].asInt(); |
| | | DBG("cut_max_duration: " << cut_max_duration << " cut_min_duration: " << cut_min_duration); |
| | | appPref.setIntData("n_cut_max_duration", cut_max_duration); |
| | | appPref.setIntData("n_cut_min_duration", cut_min_duration); |
| | | |
| | | DBG("cut_max_duration: " << cut_max_duration << " cut_min_duration: " << cut_min_duration); |
| | | DBG("cut_max_duration: " << cut_max_duration << " cut_min_duration: " << cut_min_duration); |
| | | // m_GB28181_Enable = appPref.getIntData("GB28181_Enable"); |
| | | //#todo GB28181 |
| | | if (pthis->m_GB28181_Enable) { |
| | | DBG("searchCamDevTableByType before"); |
| | | auto lst = pthis->m_lDBTool->searchCamDevTableByType(1); |
| | | DBG("searchCamDevTableByType size:" << lst.size()); |
| | | //*****************************#todo extract to func ************************************ |
| | | //#todo GB28181 |
| | | if (pthis->m_GB28181_Enable) { |
| | | DBG("searchCamDevTableByType before"); |
| | | auto lst = pthis->m_lDBTool->searchCamDevTableByType(1); |
| | | DBG("searchCamDevTableByType size:" << lst.size()); |
| | | if (lst.size() > 0) { |
| | | int startCamNO = appPref.getIntData("CamStartNO"); |
| | | int CamCount = appPref.getIntData("CamEndNO") - appPref.getIntData("CamStartNO") + 1; |
| | | INFO("StartCamNO: " << startCamNO << " CamCount: " << CamCount); |
| | | auto itor = lst.begin(); |
| | | |
| | | if (lst.size() > 0) { |
| | | int startCamNO = appPref.getIntData("CamStartNO"); |
| | | int CamCount = appPref.getIntData("CamEndNO") - appPref.getIntData("CamStartNO") + 1; |
| | | INFO("StartCamNO: " << startCamNO << " CamCount: " << CamCount); |
| | | auto itor = lst.begin(); |
| | | if (startCamNO >= lst.size()) { |
| | | ERR("startCamNO > lst.size()"); |
| | | return; |
| | | } |
| | | |
| | | if (startCamNO >= lst.size()) { |
| | | ERR("startCamNO > lst.size()"); |
| | | return; |
| | | } |
| | | for (int i = 0; i < startCamNO; i++) { |
| | | itor++; |
| | | } |
| | | for (int i = 0; i < CamCount; i++) { |
| | | if (itor == lst.end()) { |
| | | ERR("itor == lst.end()"); |
| | | return; |
| | | } |
| | | std::string t_camIdex = itor->str_cam_dev_id.toStdString(); |
| | | DBG("-----camID:" << t_camIdex << "min:" << cut_min_duration << "max:" |
| | | << cut_max_duration); |
| | | pthis->m_controllers_videoCapElem[t_camIdex]->SetVideoMinMaxSeconds(cut_min_duration, |
| | | cut_max_duration); |
| | | itor++; |
| | | } |
| | | } else { |
| | | ERR("searchCamDevTableByType size is 0"); |
| | | } |
| | | } else { |
| | | auto lst = pthis->m_lDBTool->searchCamDevTableByType(0); |
| | | if (lst.size() > 0) { |
| | | int startCamNO = appPref.getIntData("CamStartNO"); |
| | | int CamCount = appPref.getIntData("CamEndNO") - appPref.getIntData("CamStartNO") + 1; |
| | | INFO("StartCamNO: " << startCamNO << " CamCount: " << CamCount); |
| | | auto itor = lst.begin(); |
| | | |
| | | for (int i = 0; i < startCamNO; i++) { |
| | | itor++; |
| | | } |
| | | if (startCamNO >= lst.size()) { |
| | | ERR("startCamNO > lst.size()"); |
| | | return; |
| | | } |
| | | |
| | | for (int i = 0; i < CamCount; i++) { |
| | | if (itor == lst.end()) { |
| | | ERR("itor == lst.end()"); |
| | | return; |
| | | for (int i = 0; i < startCamNO; i++) { |
| | | itor++; |
| | | } |
| | | |
| | | for (int i = 0; i < CamCount; i++) { |
| | | if (itor == lst.end()) { |
| | | ERR("itor == lst.end()"); |
| | | return; |
| | | } |
| | | std::string t_camIdex = itor->str_cam_dev_id.toStdString(); |
| | | DBG("-----camID:" << t_camIdex << "min:" << cut_min_duration << "max:" |
| | | << cut_max_duration); |
| | | pthis->m_controllers[t_camIdex]->SetVideoMinMaxSeconds(cut_min_duration, |
| | | cut_max_duration); |
| | | itor++; |
| | | } |
| | | |
| | | } else { |
| | | ERR("searchCamDevTableByType size is 0"); |
| | | } |
| | | } |
| | | std::string t_camIdex = itor->str_cam_dev_id.toStdString(); |
| | | DBG("-----camID:" << t_camIdex << "min:" << cut_min_duration << "max:" << cut_max_duration); |
| | | pthis->m_controllers_videoCapElem[t_camIdex]->SetVideoMinMaxSeconds(cut_min_duration, cut_max_duration); |
| | | itor++; |
| | | } |
| | | } else { |
| | | ERR("searchCamDevTableByType size is 0"); |
| | | } |
| | | |
| | | } else { |
| | | auto lst = pthis->m_lDBTool->searchCamDevTableByType(0); |
| | | |
| | | if (lst.size() > 0) { |
| | | int startCamNO = appPref.getIntData("CamStartNO"); |
| | | int CamCount = appPref.getIntData("CamEndNO") - appPref.getIntData("CamStartNO") + 1; |
| | | INFO("StartCamNO: " << startCamNO << " CamCount: " << CamCount); |
| | | auto itor = lst.begin(); |
| | | |
| | | if (startCamNO >= lst.size()) { |
| | | ERR("startCamNO > lst.size()"); |
| | | return; |
| | | } |
| | | |
| | | for (int i = 0; i < startCamNO; i++) { |
| | | itor++; |
| | | } |
| | | |
| | | for (int i = 0; i < CamCount; i++) { |
| | | if (itor == lst.end()) { |
| | | ERR("itor == lst.end()"); |
| | | return; |
| | | } |
| | | std::string t_camIdex = itor->str_cam_dev_id.toStdString(); |
| | | DBG("-----camID:" << t_camIdex << "min:" << cut_min_duration << "max:" << cut_max_duration); |
| | | pthis->m_controllers[t_camIdex]->SetVideoMinMaxSeconds(cut_min_duration, cut_max_duration); |
| | | itor++; |
| | | //*************************************************************************************** |
| | | } |
| | | |
| | | } else { |
| | | ERR("searchCamDevTableByType size is 0"); |
| | | } |
| | | |
| | | DBG("itor value is not string "); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | |
| | | } else { |
| | | ERR("Error Message!!"); |
| | | } |
| | |
| | | // 25, 0, 0, this); |
| | | |
| | | m_controllers_videoCapElem[index] = new PushStreamAppPipeController(const_cast<string &>(index), |
| | | 25, 0, appPref.getIntData("gpu.index"), this); |
| | | 25, 0, appPref.getIntData("gpu.index"), |
| | | this); |
| | | m_controllers_videoCapElem[index]->SetVideoMinMaxSeconds(lst_dev.n_cut_min_duration, |
| | | lst_dev.n_cut_max_duration); |
| | | m_controllers_videoCapElem[index]->start(); |