// 子设备(设备树)消息异步响应处理 int CSDKMainctrl::HandleGetUserChannelListRsp(CCmd* pCmd)const { CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); CHECK_POINTER(g_pNvs, IVS_OPERATE_MEMORY_ERROR); std::string strTransID = pCmd->GetTransID(); IVS_CHANNLELIST_RETRIVE_STATUS_INFO channelListRetriveStatus; memset(&channelListRetriveStatus, 0, sizeof(channelListRetriveStatus)); IVS_INT32 iRet = g_pNvs->GetChannelListRetriveStatusByTransID(strTransID, channelListRetriveStatus); if (IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet, "handle get user channel list rsp", "fail to get channel list retrieve status by key word transID:%s.", strTransID.c_str()); return iRet; } IVS_CHAR* pDataXML = CNSSOperator::instance().ParseCmd2XML(pCmd, iRet); // 允许pDataXML为空 channelListRetriveStatus.iLastRetCode = iRet; // 记录错误码 //modify by zwx211831, Date:20140616,增加对获取的UserMgr指针判空操作,防止该用户已离线。 CUserMgr *pUserMgr = g_pNvs->GetUserMgr(channelListRetriveStatus.iSessionID); if (NULL == pUserMgr) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "handle get user channel list rsp", "Invalid SessionID, SessionID is:%d.", channelListRetriveStatus.iSessionID); IVS_DELETE(pDataXML, MUILI); return IVS_SDK_RET_INVALID_SESSION_ID; } (void)pUserMgr->GetDeviceMgr().ProcessGetUserChannelListRsp(channelListRetriveStatus, pDataXML); //(void)g_pNvs->GetUserMgr(channelListRetriveStatus.iSessionID)->GetDeviceMgr().ProcessGetUserChannelListRsp(channelListRetriveStatus, pDataXML); //end g_pNvs->RemoveChannelListRetriveStatusByTransID(strTransID); IVS_DELETE(pDataXML, MUILI); return IVS_SUCCEED; }
// 联动动作停止通知 int CSDKMainctrl::StopLinkageAction(CCmd* pCmd)const { // 获取通知内容 CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_CHAR* pData = CSDKMainService::ProcessMAUCmd(pCmd); CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR); int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e1055 !e746 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "Stop linkage action", "iSessionID = %d", iSessionID); IVS_DELETE(pData, MUILI); return IVS_FAIL; } CXml xml; const IVS_CHAR* pDataXml = NULL; IVS_INT32 iRet = ModifyDevCode(xml, pData); if (IVS_SUCCEED != iRet) { IVS_DELETE(pData, MUILI); return iRet; } IVS_UINT32 uiXMLLen = 0; pDataXml = xml.GetXMLStream(uiXMLLen); IVS_DELETE(pData, MUILI); CHECK_POINTER(pDataXml, IVS_OPERATE_MEMORY_ERROR); CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_STOP_LINKAGE_ACTION, pDataXml, static_cast<IVS_INT32>(strlen(pDataXml)) + 1); return IVS_SUCCEED; }
void CChannelInfo::Clear() { if (NULL != m_pConnVideoRtp) { m_pConnVideoRtp->ShutDown(); IVS_DELETE(m_pConnVideoRtp); } if (NULL != m_pConnVideoRtcp) { m_pConnVideoRtcp->ShutDown(); IVS_DELETE(m_pConnVideoRtcp); } if (NULL != m_pConnAudioRtp) { m_pConnAudioRtp->ShutDown(); IVS_DELETE(m_pConnAudioRtp); } if (NULL != m_pConnAudioRtcp) { m_pConnAudioRtcp->ShutDown(); IVS_DELETE(m_pConnAudioRtcp); } if (NULL != m_pConnMulticast) { m_pConnMulticast->ShutDown(); IVS_DELETE(m_pConnMulticast); } m_uiLocalVideoRtpPort = 0; m_uiLocalVideoRtcpPort = 0; m_uiLocalAudioRtpPort = 0; m_uiLocalAudioRtcpPort = 0; m_uiRemoteVideoRtpPort = 0; m_uiRemoteVideoRtcpPort = 0; m_uiRemoteAudioRtpPort = 0; m_uiRemoteAudioRtcpPort = 0; m_strRemoteSendStreamIp = ""; m_strLocalRecvStreamIP = ""; m_enProtocolType = PROTOCOL_RTP_OVER_UDP; m_ulChannel = 0; m_cbDataCallBack = NULL; m_pDataUserData = NULL; m_cbExceptionCallBack = NULL; m_bIsMuilt = false; m_bIsOnlyVideo = false; }
void CXmlProcess::SetElemValueStr(const IVS_CHAR* pXmlValue,IVS_UINT32 ulLength,CXml &xml) { CHECK_POINTER_VOID(pXmlValue); IVS_CHAR* pXmlNewValue = IVS_NEW((IVS_CHAR* &)pXmlNewValue,ulLength+1); CHECK_POINTER_VOID(pXmlNewValue); memset(pXmlNewValue,0,ulLength+1); if (!CToolsHelp::Memcpy(pXmlNewValue, ulLength+1, pXmlValue, ulLength)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "CToolsHelp::Memcpy fail", "NA"); IVS_DELETE(pXmlNewValue,MUILI); return; } (void)xml.SetElemValue(pXmlNewValue); IVS_DELETE(pXmlNewValue,MUILI); }
// 释放IADraw句柄 IVS_DRAW_API LONG Draw_FreeHandle(DRAW_HANDLE handle) { CHECK_HANDLE(handle); CIADrawer *pIADrawer = (CIADrawer *)handle; IVS_DELETE(pIADrawer); return IVS_SUCCEED; }
void CRealPlayMgr::ReleaseRealPlay(CRealPlay * pRealPlay) { if (pRealPlay && 0 == pRealPlay->PutRef()) { IVS_DELETE(pRealPlay); } }//lint !e1762 暂不列为const
void CRealPlayMgr::FreeRealPlayEx(IVS_ULONG ulHandle) { BP_DBG_LOG("Free Real PlayEx", "Free Handle %u", ulHandle); CRealPlay *pRealPlay = NULL; (void)VOS_MutexLock(m_pHanleRealPlayMutex); HandleRealPlayMapIter iter = m_HanleRealPlayMap.find(ulHandle); if (iter != m_HanleRealPlayMap.end()) { pRealPlay = iter->second; m_HanleRealPlayMap.erase(iter++); } (void)VOS_MutexUnlock(m_pHanleRealPlayMutex); if (NULL == pRealPlay) { BP_RUN_LOG_ERR(IVS_FAIL, "FreeRealPlayEx", "pRealPlay = NULL"); return; } if (0 == pRealPlay->PutRef()) { BP_DBG_LOG("Free Real PlayEx", "Delete Handle %u", ulHandle); IVS_DELETE(pRealPlay); } }
// 修改域路由 IVS_INT32 CDomainRouteMgr::ModifyDomainRoute(IVS_DOMAIN_ROUTE* pDomainRoute) { if (NULL == pDomainRoute) { BP_RUN_LOG_ERR(IVS_FAIL, "Modify Domain Route", "DomainRoute is NULL"); return IVS_FAIL; } DOMAIN_CODE_LIST_MAP_ITER mapIter; char szDomainCode[IVS_DOMAIN_CODE_LEN + 1]; unsigned int uiCopyLen = IVS_DOMAIN_CODE_LEN; memset(szDomainCode, 0, IVS_DOMAIN_CODE_LEN + 1); if (!CToolsHelp::Memcpy(szDomainCode, uiCopyLen, pDomainRoute->cDomainCode, uiCopyLen)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Modify Domain Route", "DomainCode Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } mapIter = m_domainCodeMap.find(szDomainCode); //Map中存在相同Key的域路由信息 if (mapIter != m_domainCodeMap.end()) { IVS_DELETE(mapIter->second); //lint !e1025 !e1514 !e64 m_domainCodeMap.erase(mapIter); } m_domainCodeMap.insert(std::make_pair(szDomainCode, pDomainRoute)); //lint !e534 return IVS_SUCCEED; }
// 移除解码器信息 IVS_VOID CSDKDecoderMgr::RemoveDecoderInfo() { (void)VOS_MutexLock(m_pDecoderInfoMapMutex); try { for(SDK_DECODER_INFO_MAP::iterator ite=m_decoderInfoMap.begin();ite!=m_decoderInfoMap.end();ite++) { SDK_DECODER_INFO* pInfo = dynamic_cast<SDK_DECODER_INFO*>(ite->second);//lint !e611 if(NULL!=pInfo) { if(pInfo->bOnline) { ////////////////////////////////////////////////////////////////////////// //2013-1-28 高书明 先屏蔽HWPuSDK相关函数,与BP的dll冲突 //(void)IVS_PU_Logout(pInfo->ulIdentifyID); ////////////////////////////////////////////////////////////////////////// pInfo->bOnline = FALSE; pInfo->ulIdentifyID = 0; } IVS_DELETE(pInfo); } } m_decoderInfoMap.clear(); } catch(...) { m_decoderInfoMap.clear(); } (void)VOS_MutexUnlock(m_pDecoderInfoMapMutex); }
CAudioMgr::~CAudioMgr(void) { m_pUserMgr = NULL; try { HandleTalkBackMapIter iter = m_HanleTalkBackMap.begin(); while(m_HanleTalkBackMap.end() != iter) { CAudioObj* pTalkback = dynamic_cast<CAudioObj*>(iter->second);//lint !e611 if (NULL != pTalkback) { IVS_DELETE(pTalkback); } ++iter; } m_HanleTalkBackMap.clear(); if (NULL != m_pHandleTalkBackMutex) { (void)VOS_DestroyMutex(m_pHandleTalkBackMutex); m_pHandleTalkBackMutex = NULL; } } catch (...) { } if (NULL != m_pHandleTalkBackMutex) { VOS_DestroyMutex(m_pHandleTalkBackMutex); m_pHandleTalkBackMutex = NULL; } }
// 推送发现到的前端设备 int CSDKMainctrl::OnDisCoveredDevNotify(CCmd* pCmd)const { BP_RUN_LOG_INF("OnDisCoveredDevNotify", "Begin"); CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_CHAR* pData = CSDKMainService::ProcessDevNotify(pCmd); CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR); int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e1055 !e746 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "linkage action", "iSessionID is -1"); IVS_DELETE(pData, MUILI); return IVS_FAIL; } CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_FIND_DEVICE, pData, static_cast<IVS_INT32>(strlen(pData)) + 1); IVS_DELETE(pData, MUILI); BP_RUN_LOG_INF("OnDisCoveredDevNotify", "End"); return IVS_SUCCEED; }
IVS_VOID CTelepresenceMgr::RemovePlayChannel(IVS_ULONG ulHandle) { IVS_DEBUG_TRACE(""); CLockGuard autoLock(m_pChannelMapMutex); CTPPlayChannel* pPlayChannel = NULL; TP_PLAY_CHANNEL_MAP::iterator ite = m_channelMap.find(ulHandle); if(ite!=m_channelMap.end()) { pPlayChannel = dynamic_cast<CTPPlayChannel*>(ite->second);//lint !e611 IVS_DELETE(pPlayChannel); m_channelMap.erase(ite); } }
IVS_INT32 CDomainRouteMgr::SendCmdAndGetInfo(CXml& xmlRsp) const { IVS_INT32 iRet = IVS_FAIL; CHECK_POINTER(m_pUserMgr,IVS_OPERATE_MEMORY_ERROR); // 获取本域SMU连接 std::string strSMULinkID; IVS_INT32 iGetLinkRet = m_pUserMgr->GetLocalDomainLinkID(NET_ELE_SMU_NSS, strSMULinkID); if (IVS_SUCCEED != iGetLinkRet) { BP_RUN_LOG_ERR(iGetLinkRet, "Get LocalDomainLinkID failed", "NA"); return iGetLinkRet; } //创建要发送的CMD,拼装了NSS消息头 CCmd* pCmd = CNSSOperator::instance().BuildSMUCmd(NSS_GET_DOMAIN_ROUTE_REQ, NULL, strSMULinkID); CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); //发送消息 CCmd *pCmdRsp = CNSSOperator::instance().SendSyncCmd(pCmd); CHECK_POINTER(pCmdRsp, IVS_NET_RECV_TIMEOUT); const IVS_CHAR* pRsp = CNSSOperator::instance().ParseCmd2XML(pCmdRsp, iRet); HW_DELETE(pCmdRsp); CHECK_POINTER(pRsp, iRet); if (IVS_SUCCEED != iRet) { BP_RUN_LOG_INF("Send Command get return value", " Error"); IVS_DELETE(pRsp, MUILI); //lint !e605 return IVS_FAIL; } iRet = IVS_XML_INVALID; BP_RUN_LOG_INF("Get domain route ", "pRsp:%s", pRsp); if (xmlRsp.Parse(pRsp)) { iRet = IVS_SUCCEED; } IVS_DELETE(pRsp, MUILI); //lint !e605 return iRet; }
IVS_INT32 CXmlProcess::GetCommBuildRet( CXml &xml, NSS_MSG_TYPE_E msgType, IVS_INT32 iType, const std::string& strLinkID) { IVS_UINT32 xmlLen = 0; const IVS_CHAR* pReq = xml.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); BP_RUN_LOG_INF("COCXXmlProcess::GetCommBuildRet", "send XML = %s", pReq); //创建要发送的CMD,拼装了NSS消息头 CCmd* pCmd = CNSSOperator::instance().BuildSMUCmd(msgType, pReq, strLinkID); CHECK_POINTER(pCmd, IVS_SDK_RET_BP_CMD_REQ_INVALID); //发送消息 CCmd *pCmdRsp = CNSSOperator::instance().SendSyncCmd(pCmd); CHECK_POINTER(pCmdRsp, IVS_NET_RECV_TIMEOUT); //返回响应消息 IVS_INT32 iRet = IVS_SUCCEED; const IVS_CHAR* pRsp = NULL; if (BUILDRET == iType) { iRet = CNSSOperator::instance().ParseCmd2NSS(pCmdRsp); } else { pRsp = CNSSOperator::instance().ParseCmd2XML(pCmdRsp, iRet); } BP_RUN_LOG_INF("GetCommBuildRet", "revice XML = %s", pRsp); HW_DELETE(pCmdRsp); if (BUILSTRING == iType) { if (NULL == pRsp) { BP_RUN_LOG_ERR(iRet,"NULL == pRsp", "iRet = %d", iRet); return iRet; } if(iRet == IVS_SUCCEED) { iRet = IVS_XML_INVALID; xml.RemoveElem(); if(xml.Parse(pRsp)) { iRet = IVS_SUCCEED; } IVS_DELETE(pRsp, MUILI); } } BP_RUN_LOG_INF("GetCommBuildRet", "iType = %d,iRet = %d", iType, iRet); return iRet; }
int CSDKMainctrl::HandleMAUCmd(CCmd* pCmd) const { CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); //ParseCmd2XML已经从utf8转到ansi IVS_CHAR* pData = CSDKMainService::ProcessMAUCmd(pCmd); CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR); int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e1055 !e746 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_FAIL, "session id invalid","NA"); IVS_DELETE(pData, MUILI); return IVS_FAIL; } // 根据不同的REQID获取事件ID IVS_INT32 iEventType = 0; switch(pCmd->GetReqID()) //lint !e1055 !e1013 !e746 { case NSS_BA_LEARNING_SCHEDULE_REPORT_REQ: iEventType = IVS_EVENT_IA_BA_LEARNING_SCHEDULE_REPORT; break; case NSS_FR_REPORT_SCHEDULE_REQ: iEventType = IVS_EVENT_IA_FR_SCHEDULE_REPORT; break; case NSS_PUSH_ALARM_LOCUS_REQ: iEventType = IVS_EVENT_IA_PUSH_ALARM_LOCUS; break; case NSS_ADDPLAN_SCHEDULE_REPORT_REQ: iEventType = IVS_EVENT_IA_ADDPLAN_SCHEDULE_REPORT; break; default: break; } CEventCallBackJob::instance().PostEvent(iSessionID, iEventType, pData, static_cast<IVS_INT32>(strlen(pData)) + 1); IVS_DELETE(pData, MUILI); return IVS_SUCCEED; }
//删除代理域路由 IVS_VOID CDomainRouteMgr::ClearProxyDomainRouteMap() { //删除代理域路由 PROXY_DOMAIN_CODEL_MAP_ITER proxy_domain_map_iter = m_proxyDomainCodeMap.begin(); PROXY_DOMAIN_CODEL_MAP_ITER proxy_domain_map_iter_end = m_proxyDomainCodeMap.end(); while (proxy_domain_map_iter != proxy_domain_map_iter_end) { IVS_DOMAIN_ROUTE* pProxyRoute = dynamic_cast <IVS_DOMAIN_ROUTE*>(proxy_domain_map_iter->second); //lint !e611 IVS_DELETE(pProxyRoute); m_proxyDomainCodeMap.erase(proxy_domain_map_iter++); } m_proxyDomainCodeMap.clear(); }
// 删除域路由 IVS_VOID CDomainRouteMgr::ClearDomainRouteMap() { //删除域路由 DOMAIN_CODE_LIST_MAP_ITER domain_map_iter = m_domainCodeMap.begin(); DOMAIN_CODE_LIST_MAP_ITER domain_map_iter_end = m_domainCodeMap.end(); while (domain_map_iter != domain_map_iter_end) { IVS_DOMAIN_ROUTE* pRoute = dynamic_cast <IVS_DOMAIN_ROUTE*>(domain_map_iter->second); //lint !e611 IVS_DELETE(pRoute); m_domainCodeMap.erase(domain_map_iter++); } m_domainCodeMap.clear(); }
void CRealPlayMgr::FreeRealPlay(IVS_ULONG ulHandle) { (void)VOS_MutexLock(m_pHanleRealPlayMutex); HandleRealPlayMapIter iter = m_HanleRealPlayMap.find(ulHandle); HandleRealPlayMapIter iterEnd = m_HanleRealPlayMap.end(); if (iter != iterEnd) { CRealPlay* pRealPlay = dynamic_cast<CRealPlay*>(iter->second);//lint !e611 if (NULL != pRealPlay) { IVS_DELETE(pRealPlay); } m_HanleRealPlayMap.erase(iter++); } (void)VOS_MutexUnlock(m_pHanleRealPlayMutex); }
int CSDKMainctrl::OnModeCruiseRecordOver(CCmd* pCmd)const { CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_CHAR* pData = CSDKMainService::ProcessDevNotify(pCmd); CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR); int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e1055 !e746 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "mode cruise record over", "iSessionID is -1"); IVS_DELETE(pData, MUILI); return IVS_SDK_RET_INVALID_SESSION_ID; } CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_MODE_CRUISE_RECORD_OVER, pData, static_cast<IVS_INT32>(strlen(pData)) + 1); return IVS_SUCCEED; }
//关闭所有实况; void CRealPlayMgr::StopAllRealPlay() { IVS_DEBUG_TRACE(""); (void)VOS_MutexLock(m_pHanleRealPlayMutex); CRealPlay *pRealPlay = NULL; HandleRealPlayMapIter realplayIter = m_HanleRealPlayMap.begin(); HandleRealPlayMapIter realplayIterEnd = m_HanleRealPlayMap.end(); //查找空闲对象; for (;realplayIter != realplayIterEnd; realplayIter++) { pRealPlay = dynamic_cast<CRealPlay*>(realplayIter->second);//lint !e611 if (NULL != pRealPlay) { try { if (pRealPlay->GetStatus() == MEDIA_STATUS_BUSY) { (void)pRealPlay->StopRealPlay(); } } catch(...) { BP_RUN_LOG_ERR(IVS_FAIL, "StopAllRealPlay", "Delete realplay[%lu] failed.", pRealPlay); } try { IVS_DELETE(pRealPlay); } catch(...) { BP_RUN_LOG_ERR(IVS_FAIL, "StopAllRealPlay", "Delete realplay[%lu] failed.", pRealPlay); } } pRealPlay = NULL; } m_HanleRealPlayMap.clear(); (void)VOS_MutexUnlock(m_pHanleRealPlayMutex); }
CTelepresenceMgr::~CTelepresenceMgr(void) { VOS_MutexLock(m_pChannelMapMutex); try { TP_PLAY_CHANNEL_MAP::iterator iter = m_channelMap.begin(); TP_PLAY_CHANNEL_MAP::iterator iter_end = m_channelMap.end(); for(; iter!=iter_end; iter++) { CTPPlayChannel* pChannel = dynamic_cast<CTPPlayChannel*>(iter->second);//lint !e611 IVS_DELETE(pChannel); } } catch (...) { } (void)VOS_MutexUnlock(m_pChannelMapMutex); (void)VOS_DestroyMutex(m_pChannelMapMutex); m_pChannelMapMutex = NULL; m_pUserMgr = NULL; }
// 断连通知 IVS_VOID CSDKDecoderMgr::NotifyDisConnect(IVS_ULONG ulIdentifyID) { std::string strDecoderId; (void)VOS_MutexLock(m_pDecoderInfoMapMutex); for(SDK_DECODER_INFO_MAP::iterator ite=m_decoderInfoMap.begin();ite!=m_decoderInfoMap.end();ite++) { SDK_DECODER_INFO* pInfo = dynamic_cast<SDK_DECODER_INFO*>(ite->second);//lint !e611 if(NULL!=pInfo) { if(ulIdentifyID==pInfo->ulIdentifyID) { strDecoderId = pInfo->szDecoderID; pInfo->bOnline = FALSE; pInfo->ulIdentifyID = 0; break; } } } (void)VOS_MutexUnlock(m_pDecoderInfoMapMutex); if(NULL!=m_pCallBackFun && NULL!=m_pUserData && strDecoderId.length()>0) { CUMW_NOTIFY_INFO stNotifyInfo = {0}; CUMW_NOTIFY_REMOTE_DECODER_OFF_LINE_INFO* pstOffline = IVS_NEW(pstOffline); if(NULL!=pstOffline) { stNotifyInfo.ulNotifyType = CUMW_NOTIFY_TYPE_REMOTE_DECODER_DISCONNECT; stNotifyInfo.pNotifyInfo = pstOffline; stNotifyInfo.ulNotifyInfoLen = sizeof(CUMW_NOTIFY_REMOTE_DECODER_OFF_LINE_INFO); if(CToolsHelp::Strncpy(pstOffline->szDecoderID, sizeof(pstOffline->szDecoderID), strDecoderId.c_str(), strDecoderId.length())) { (void)m_pCallBackFun(&stNotifyInfo, m_pUserData); } else { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Decoder disconnect", "Copy Decoder ID Failed"); } IVS_DELETE(pstOffline); } } }
//停止所有播放 void CTelepresenceMgr::StopAllPlayByIP() { IVS_DEBUG_TRACE(""); VOS_MutexLock(m_pChannelMapMutex); TP_PLAY_CHANNEL_MAP::iterator iter = m_channelMap.begin(); TP_PLAY_CHANNEL_MAP::iterator iter_end = m_channelMap.end(); try { for(; iter!=iter_end; iter++) { CTPPlayChannel* pPlayChannel = dynamic_cast<CTPPlayChannel*>(iter->second);//lint !e611 pPlayChannel->StopPlayByIP(); IVS_DELETE(pPlayChannel); } } catch (...) { } m_channelMap.clear(); VOS_MutexUnlock(m_pChannelMapMutex); }
// 解析获取域路由响应 IVS_INT32 CDomainRouteMgr::GeDomainRouteParseXML( IVS_DOMAIN_ROUTE_LIST* pDomainRouteList, CXml &xmlRsp) { BP_RUN_LOG_INF("Get Parse Domain Route XML Info", "Enter"); CHECK_POINTER(pDomainRouteList, IVS_OPERATE_MEMORY_ERROR); DOMAIN_CODE_LIST stCodeInfoList; IVS_INT32 iRet = IVS_FAIL; iRet = GetDomainRouteToListParseXML(stCodeInfoList, xmlRsp); if (IVS_SUCCEED == iRet) { pDomainRouteList->uiTotal = stCodeInfoList.size(); DOMAIN_CODE_LIST_ITER iterBegin = stCodeInfoList.begin(); DOMAIN_CODE_LIST_ITER iterEnd = stCodeInfoList.end(); DOMAIN_CODE_LIST_MAP_ITER mapIter; DOMAIN_CODE_LIST_MAP_ITER mapIterEnd = m_domainCodeMap.end(); IVS_UINT32 uiSTLen = sizeof(IVS_DOMAIN_ROUTE); IVS_UINT32 uiIndex = 0; char szDomainCode[IVS_DOMAIN_CODE_LEN + 1]; unsigned int uiCopyLen = IVS_DOMAIN_CODE_LEN; for (; iterBegin != iterEnd; iterBegin++) { if (NULL == *iterBegin) { continue; } IVS_DOMAIN_ROUTE &stDomainRouteTmp = pDomainRouteList->stDomainRoute[uiIndex]; memset(&stDomainRouteTmp, 0, sizeof(stDomainRouteTmp)); //赋值设备信息到pDomainRouteList if (!CToolsHelp::Memcpy(&stDomainRouteTmp, uiSTLen, *iterBegin, uiSTLen)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Parse Domain Route XML Info", "DomainRoute Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } memset(szDomainCode, 0, IVS_DOMAIN_CODE_LEN + 1); strncpy(szDomainCode, (*iterBegin)->cDomainCode, IVS_DOMAIN_CODE_LEN); mapIter = m_domainCodeMap.find(szDomainCode); if (mapIter != mapIterEnd) { //说明Map里面已近存在了一个相同key值的对象,需要删除否则内存泄漏 IVS_DELETE(mapIter->second); //lint !e1025 !e1514 !e64 m_domainCodeMap.erase(mapIter); } //更新Map表 (IVS_VOID)m_domainCodeMap.insert(std::make_pair(szDomainCode, *iterBegin)); uiIndex++; } stCodeInfoList.clear(); } else { pDomainRouteList->uiTotal = 0; } // TODO for 通用请求 BP_RUN_LOG_INF("Get Parse Domain Route XML Info", "Leave"); return iRet; }
IVS_INT32 CDomainRouteMgr::ModifyProxyDomainRoute(IVS_DOMAIN_ROUTE* pDomainRoute) { if (NULL == pDomainRoute) { BP_RUN_LOG_ERR(IVS_FAIL, "Modify Proxy Domain Route", "DomainRoute is NULL"); return IVS_FAIL; } PROXY_DOMAIN_CODEL_MAP_ITER mapIter; DOMAIN_CODE_LIST_MAP_ITER damainCodeIter; DOMAIN_CODE_LIST_MAP_ITER damainCodeEndIter = m_domainCodeMap.end(); char szDomainCode[IVS_DOMAIN_CODE_LEN + 1]; unsigned int uiCopyLen = IVS_DOMAIN_CODE_LEN; IVS_DOMAIN_ROUTE* pProxyDomainRoute = NULL; std::string strFatherDomainCode; unsigned int uiMapSize = m_domainCodeMap.size(); //定义循环次数限制,防止死循环发生 unsigned int loopNum = 0; memset(szDomainCode, 0, IVS_DOMAIN_CODE_LEN + 1); if (!CToolsHelp::Memcpy(szDomainCode, uiCopyLen, pDomainRoute->cDomainCode, uiCopyLen)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Modify Proxy Domain Route", "DomainCode Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } mapIter = m_proxyDomainCodeMap.find(szDomainCode); //Map中存在相同Key的域路由信息 if (mapIter != m_proxyDomainCodeMap.end()) { IVS_DELETE(mapIter->second); //lint !e1025 !e1514 !e64 m_proxyDomainCodeMap.erase(mapIter); } do { loopNum++; //找到第一个代理域则退出 if (TRUE == pDomainRoute->bIsAgent) { pProxyDomainRoute = pDomainRoute; //lint !e611 break; } memset(szDomainCode, 0, IVS_DOMAIN_CODE_LEN + 1); if (!CToolsHelp::Memcpy(szDomainCode, uiCopyLen, pDomainRoute->cSuperDomain, uiCopyLen)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Modify Proxy Domain Route", "DomainCode Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } //获取该域的父域Code strFatherDomainCode = szDomainCode; //查找父域在Map表中的信息 damainCodeIter = m_domainCodeMap.find(strFatherDomainCode); //如果该域不存在父域信息,说明已经是本域,即根节点 if (damainCodeIter == damainCodeEndIter) { break; } pDomainRoute = dynamic_cast <IVS_DOMAIN_ROUTE*>(damainCodeIter->second); //lint !e611 } while (loopNum < uiMapSize); if (NULL != pProxyDomainRoute) { memset(szDomainCode, 0, IVS_DOMAIN_CODE_LEN + 1); if (NULL != pDomainRoute) { if (!CToolsHelp::Memcpy(szDomainCode, uiCopyLen, pDomainRoute->cDomainCode, uiCopyLen)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Modify Proxy Domain Route", "DomainCode Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } } m_proxyDomainCodeMap.insert(std::make_pair(szDomainCode, pProxyDomainRoute)); //lint !e534 } return IVS_SUCCEED; }
int CSDKMainctrl::OnDevAlarmNotify(CCmd* pCmd)const { BP_RUN_LOG_INF("OnDevAlarmNotify", "Begin"); CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_CHAR* pData = IVS_NEW(pData, sizeof(IVS_DEVICE_ALARM_NOTIFY)); CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR); memset(pData, 0x0, sizeof(IVS_DEVICE_ALARM_NOTIFY)); IVS_DEVICE_ALARM_NOTIFY* pDevAlarmNotify = reinterpret_cast<IVS_DEVICE_ALARM_NOTIFY*>(pData); //lint !e826 // if (NULL == pDevAlarmNotify) // { // BP_RUN_LOG_ERR(IVS_SDK_RET_INTRINSIC_PTR_ERROR, "pDevAlarmNotify is null", "NA"); // IVS_DELETE(pData, MUILI); // return IVS_SDK_RET_INTRINSIC_PTR_ERROR; // } IVS_INT32 iRet = CSDKMainService::ProcessDevAlarmNotify(pCmd, pDevAlarmNotify); // NSS头 TNssMsgHeader m_header; memset(&m_header, 0, sizeof(TNssMsgHeader)); m_header.usiProtocolVersion = 0x0100; m_header.usiMsgType = NSS_OMU_ALARM_CU_REPORT_RSP; m_header.uiSeqID = 0; m_header.uiTraceID = 0; if (!CToolsHelp::Strncpy(m_header.szTransactionNo, TRANSACTIONNO_LEN, pCmd->GetTransID().c_str(), strlen(pCmd->GetTransID().c_str()))) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "CToolsHelp::Strncpy(m_header.szTransactionNo, TRANSACTIONNO_LEN, pCmd->GetTransID().c_str(), 64)", "NA"); IVS_DELETE(pData, MUILI); return IVS_ALLOC_MEMORY_ERROR; } m_header.uiRspCode = static_cast<IVS_UINT32>(iRet); m_header.uiPacketLength = sizeof(TNssMsgHeader); // 转换网络字节序 m_header.usiProtocolVersion = ntohs(m_header.usiProtocolVersion); m_header.usiMsgType = ntohs(m_header.usiMsgType); m_header.uiSeqID = ntohl(m_header.uiSeqID); m_header.uiTraceID = ntohl(m_header.uiTraceID); m_header.uiRspCode = ntohl(m_header.uiRspCode); m_header.uiPacketLength = ntohl(m_header.uiPacketLength); // 定义ACE的消息缓冲,这个在cmd里面去释放,这里不释放 ACE_Message_Block* pMsgBlock = new ACE_Message_Block(sizeof(TNssMsgHeader)); pMsgBlock->copy((char*)&m_header, sizeof(TNssMsgHeader)); CDispatcher::instance().dispatcherOutWithoutTransaction(pCmd->GetNetElemType(), pCmd->GetNetLinkID().c_str(), pCmd->GetTransID().c_str(), NSS_OMU_ALARM_CU_REPORT_RSP, pMsgBlock); if (IVS_SUCCEED == iRet) { int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e1055 !e746 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_FAIL, "session id invalid","NA"); IVS_DELETE(pData, MUILI); return IVS_FAIL; } // utf8->ansi char cAlarmDest[IVS_ALARM_DESCRIPTION_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cAlarmDest, IVS_ALARM_DESCRIPTION_LEN, pDevAlarmNotify->cAlarmDest,IVS_ALARM_DESCRIPTION_LEN); char* pAlarmDest = CToolsHelp::UTF8ToANSI(cAlarmDest); if (NULL != pAlarmDest) { // 清理掉先 memset(pDevAlarmNotify->cAlarmDest, 0, IVS_ALARM_DESCRIPTION_LEN); (void)CToolsHelp::Memcpy(pDevAlarmNotify->cAlarmDest, IVS_ALARM_DESCRIPTION_LEN, pAlarmDest,strlen(pAlarmDest)); free(pAlarmDest); pAlarmDest = NULL; } char cAlarmInName[IVS_ALARM_NAME_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cAlarmInName, IVS_ALARM_NAME_LEN, pDevAlarmNotify->cAlarmInName,IVS_ALARM_NAME_LEN); char* pAlarmInName = CToolsHelp::UTF8ToANSI(cAlarmInName); if (NULL != pAlarmInName) { // 清理掉先 memset(pDevAlarmNotify->cAlarmInName, 0, IVS_ALARM_NAME_LEN); (void)CToolsHelp::Memcpy(pDevAlarmNotify->cAlarmInName, IVS_ALARM_NAME_LEN, pAlarmInName,strlen(pAlarmInName)); free(pAlarmInName); pAlarmInName = NULL; } CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_OMU_REPORT_ALARM, pDevAlarmNotify, sizeof(IVS_DEVICE_ALARM_NOTIFY)); } IVS_DELETE(pData, MUILI); BP_RUN_LOG_INF("OnDevAlarmNotify", "End"); return iRet; }
int CSDKMainctrl::OnAlarmStatusNotify(CCmd* pCmd)const { CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_ALARM_STATUS_NOTIFY* pstAlarmStatusNotify = CSDKMainService::ProcessAlarmStatusNotify(pCmd); CHECK_POINTER(pstAlarmStatusNotify, IVS_OPERATE_MEMORY_ERROR); int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "session id invalid","NA"); IVS_DELETE(pstAlarmStatusNotify); return IVS_FAIL; } // 处理DevDomainCode(若推上来为空,置为本域域编码) CUserMgr *pUserMgr = g_pNvs->GetUserMgr(iSessionID); if (NULL == pUserMgr) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "session id invalid","NA"); IVS_DELETE(pstAlarmStatusNotify); return IVS_FAIL; } char cDevDomainCodeTemp[IVS_DOMAIN_CODE_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cDevDomainCodeTemp, IVS_DOMAIN_CODE_LEN, pstAlarmStatusNotify->cDevDomainCode,IVS_DOMAIN_CODE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Memcpy fail", "NA"); IVS_DELETE(pstAlarmStatusNotify); return IVS_ALLOC_MEMORY_ERROR; } std::string strDomainCode = cDevDomainCodeTemp; if (strDomainCode.empty()) { pUserMgr->GetDomainCode(strDomainCode); if (!CToolsHelp::Memcpy(pstAlarmStatusNotify->cDevDomainCode, IVS_DOMAIN_CODE_LEN, strDomainCode.c_str(), strDomainCode.size())) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Memcpy fail", "NA"); IVS_DELETE(pstAlarmStatusNotify); return IVS_ALLOC_MEMORY_ERROR; } } // 将域编码拼接在AlarmInCode后面 char cAlarmInCodeTemp[IVS_ALARM_CODE_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cAlarmInCodeTemp, IVS_ALARM_CODE_LEN, pstAlarmStatusNotify->cAlarmInCode,IVS_ALARM_CODE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Memcpy fail", "NA"); IVS_DELETE(pstAlarmStatusNotify); return IVS_ALLOC_MEMORY_ERROR; } std::string strCode = cAlarmInCodeTemp; strCode.append("#").append(strDomainCode); memset(pstAlarmStatusNotify->cAlarmInCode, 0, IVS_ALARM_CODE_LEN); if (!CToolsHelp::Memcpy(pstAlarmStatusNotify->cAlarmInCode, IVS_ALARM_CODE_LEN,strCode.c_str(), strlen(strCode.c_str()))) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Memcpy fail", "NA"); IVS_DELETE(pstAlarmStatusNotify); return IVS_ALLOC_MEMORY_ERROR; } // 转码utf8->ansi char cOperatorName[IVS_NAME_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cOperatorName, IVS_NAME_LEN, pstAlarmStatusNotify->stOperateInfo.cOperatorName,IVS_NAME_LEN); char* pOperatorName = CToolsHelp::UTF8ToANSI(cOperatorName); if (NULL != pOperatorName) { // 清理掉先 memset(pstAlarmStatusNotify->stOperateInfo.cOperatorName, 0, IVS_NAME_LEN); (void)CToolsHelp::Memcpy(pstAlarmStatusNotify->stOperateInfo.cOperatorName, IVS_NAME_LEN, pOperatorName,strlen(pOperatorName)); free(pOperatorName); pOperatorName = NULL; } char cOperateInfo[IVS_ALARM_DESCRIPTION_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cOperateInfo, IVS_ALARM_DESCRIPTION_LEN, pstAlarmStatusNotify->stOperateInfo.cOperateInfo,IVS_ALARM_DESCRIPTION_LEN); char* pOperateInfo = CToolsHelp::UTF8ToANSI(cOperateInfo); if (NULL != pOperateInfo) { // 清理掉先 memset(pstAlarmStatusNotify->stOperateInfo.cOperateInfo, 0, IVS_ALARM_DESCRIPTION_LEN); (void)CToolsHelp::Memcpy(pstAlarmStatusNotify->stOperateInfo.cOperateInfo, IVS_ALARM_DESCRIPTION_LEN, pOperateInfo,strlen(pOperateInfo)); free(pOperateInfo); pOperateInfo = NULL; } CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_REPORT_ALARM_STATUS, pstAlarmStatusNotify, sizeof(IVS_ALARM_STATUS_NOTIFY)); IVS_DELETE(pstAlarmStatusNotify); return IVS_SUCCEED; }
int CSDKMainctrl::OnAlarmNotify(CCmd* pCmd)const { CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); IVS_ALARM_NOTIFY* pstAlarmNotify = CSDKMainService::ProcessAlarmAlarmNotifyCmd(pCmd); CHECK_POINTER(pstAlarmNotify, IVS_FAIL); int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e1055 !e746 !e64 if (SDK_SESSIONID_INIT == iSessionID) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "session id invalid","NA"); IVS_DELETE(pstAlarmNotify); return IVS_FAIL; } // 处理cDevDomainCode CUserMgr *pUserMgr = g_pNvs->GetUserMgr(iSessionID); if (NULL == pUserMgr) { BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "pUserMgr is null","NA"); IVS_DELETE(pstAlarmNotify); return IVS_FAIL; } char cDevDomainCodeTemp[IVS_DOMAIN_CODE_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cDevDomainCodeTemp, IVS_DOMAIN_CODE_LEN, pstAlarmNotify->cDevDomainCode,IVS_DOMAIN_CODE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Memcpy fail", "NA"); IVS_DELETE(pstAlarmNotify); return IVS_ALLOC_MEMORY_ERROR; } // cDevDomainCode为空填充本域编码 std::string strDomainCode = cDevDomainCodeTemp; if (strDomainCode.empty()) { pUserMgr->GetDomainCode(strDomainCode); if (!CToolsHelp::Memcpy(pstAlarmNotify->cDevDomainCode, IVS_DOMAIN_CODE_LEN, strDomainCode.c_str(), strDomainCode.size())) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Memcpy fail", "NA"); IVS_DELETE(pstAlarmNotify); return IVS_ALLOC_MEMORY_ERROR; } } // 处理cAlarmInCode,拼接上域编码 char cAlarmInCodeTemp[IVS_ALARM_CODE_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cAlarmInCodeTemp, IVS_ALARM_CODE_LEN, pstAlarmNotify->cAlarmInCode,IVS_ALARM_CODE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Memcpy fail", "NA"); IVS_DELETE(pstAlarmNotify); return IVS_ALLOC_MEMORY_ERROR; } std::string strDevCode = cAlarmInCodeTemp; std::string strCode = cAlarmInCodeTemp; strCode.append("#").append(strDomainCode); memset(pstAlarmNotify->cAlarmInCode, 0, IVS_ALARM_CODE_LEN); if (!CToolsHelp::Memcpy(pstAlarmNotify->cAlarmInCode, IVS_ALARM_CODE_LEN,strCode.c_str(), strlen(strCode.c_str()))) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "CToolsHelp::Memcpy fail", "NA"); IVS_DELETE(pstAlarmNotify); return IVS_ALLOC_MEMORY_ERROR; } // 判断告警类型,是否涉及到告警上下线 char cAlarmTypeTemp[IVS_ALARM_CODE_LEN + 1] = {0}; if (!CToolsHelp::Memcpy(cAlarmTypeTemp, IVS_ALARM_CODE_LEN, pstAlarmNotify->cAlarmType,IVS_ALARM_CODE_LEN)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Memcpy fail", "NA"); IVS_DELETE(pstAlarmNotify); return IVS_ALLOC_MEMORY_ERROR; } std::string strAlarmType = cAlarmTypeTemp; uint32_t pos = strAlarmType.find_last_of("_"); std::string suffix = strAlarmType.substr(pos+1); if ((suffix.compare("ONLINE") == 0) || (suffix.compare("OFFLINE") == 0)) { // 更新状态 strCode = strCode.substr(0, strCode.rfind("#"));//pstAlarmNotify->cAlarmInCode;*/ IVS_UINT32 uiAlarmStatus = pstAlarmNotify->uiAlarmStatus; CDeviceMgr& deviceMgr = pUserMgr->GetDeviceMgr(); std::string strNVRCode = pstAlarmNotify->cNvrCode; deviceMgr.ModifyDevStatusByDomainCode(strDomainCode, strDevCode, uiAlarmStatus, strNVRCode); } // 转码 char cAlarmDesc[IVS_ALARM_DESCRIPTION_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cAlarmDesc, IVS_ALARM_DESCRIPTION_LEN, pstAlarmNotify->cAlarmDesc,IVS_ALARM_DESCRIPTION_LEN); char* pAlarmDescAnsi = CToolsHelp::UTF8ToANSI(cAlarmDesc); if (NULL != pAlarmDescAnsi) { // 清理掉先 memset(pstAlarmNotify->cAlarmDesc, 0, IVS_ALARM_DESCRIPTION_LEN); (void)CToolsHelp::Memcpy(pstAlarmNotify->cAlarmDesc, IVS_ALARM_DESCRIPTION_LEN, pAlarmDescAnsi,strlen(pAlarmDescAnsi)); free(pAlarmDescAnsi); pAlarmDescAnsi = NULL; } char cAlarmInName[IVS_ALARM_NAME_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cAlarmInName, IVS_ALARM_NAME_LEN, pstAlarmNotify->cAlarmInName,IVS_ALARM_NAME_LEN); char* pAlarmInName = CToolsHelp::UTF8ToANSI(cAlarmInName); if (NULL != pAlarmInName) { // 清理掉先 memset(pstAlarmNotify->cAlarmInName, 0, IVS_ALARM_NAME_LEN); (void)CToolsHelp::Memcpy(pstAlarmNotify->cAlarmInName, IVS_ALARM_NAME_LEN, pAlarmInName,strlen(pAlarmInName)); free(pAlarmInName); pAlarmInName = NULL; } char cAlarmLevelName[IVS_NAME_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cAlarmLevelName, IVS_NAME_LEN, pstAlarmNotify->cAlarmLevelName,IVS_NAME_LEN); char* pAlarmLevelName = CToolsHelp::UTF8ToANSI(cAlarmLevelName); if (NULL != pAlarmLevelName) { // 清理掉先 memset(pstAlarmNotify->cAlarmLevelName, 0, IVS_NAME_LEN); (void)CToolsHelp::Memcpy(pstAlarmNotify->cAlarmLevelName, IVS_NAME_LEN, pAlarmLevelName,strlen(pAlarmLevelName)); free(pAlarmLevelName); pAlarmLevelName = NULL; } char cAlarmTypeName[IVS_ALARM_NAME_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cAlarmTypeName, IVS_ALARM_NAME_LEN, pstAlarmNotify->cAlarmTypeName,IVS_ALARM_NAME_LEN); char* pAlarmTypeName = CToolsHelp::UTF8ToANSI(cAlarmTypeName); if (NULL != pAlarmTypeName) { // 清理掉先 memset(pstAlarmNotify->cAlarmTypeName, 0, IVS_ALARM_NAME_LEN); (void)CToolsHelp::Memcpy(pstAlarmNotify->cAlarmTypeName, IVS_ALARM_NAME_LEN, pAlarmTypeName,strlen(pAlarmTypeName)); free(pAlarmTypeName); pAlarmTypeName = NULL; } char cExtParam[IVS_ALARM_EX_PARAM_LEN + 1] = {0}; (void)CToolsHelp::Memcpy(cExtParam, IVS_ALARM_EX_PARAM_LEN, pstAlarmNotify->cExtParam,IVS_ALARM_EX_PARAM_LEN); char* pExtParam = CToolsHelp::UTF8ToANSI(cExtParam); if (NULL != pExtParam) { // 清理掉先 memset(pstAlarmNotify->cExtParam, 0, IVS_ALARM_EX_PARAM_LEN); (void)CToolsHelp::Memcpy(pstAlarmNotify->cExtParam, IVS_ALARM_EX_PARAM_LEN, pExtParam,strlen(pExtParam)); free(pExtParam); pExtParam = NULL; } CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_REPORT_ALARM, pstAlarmNotify, sizeof(IVS_ALARM_NOTIFY)); IVS_DELETE(pstAlarmNotify); return IVS_SUCCEED; }
IVS_INT32 CDomainRouteMgr::GetShareCatalogList(const IVS_CHAR* pQueryInfo, IVS_CHAR** pRspXml) { CHECK_POINTER(m_pUserMgr, IVS_OPERATE_MEMORY_ERROR); if (NULL == pQueryInfo) { BP_RUN_LOG_ERR(IVS_FAIL, "Get Share Cata log List", "Query Info is NULL"); return IVS_FAIL; } // 获取本域SMU连接 std::string strSMULinkID; IVS_INT32 iGetLinkRet = m_pUserMgr->GetLocalDomainLinkID(NET_ELE_SMU_NSS, strSMULinkID); if (IVS_SUCCEED != iGetLinkRet) { BP_RUN_LOG_ERR(iGetLinkRet, "Get LocalDomainLinkID failed", "NA"); return iGetLinkRet; } CCmd* pCmd = CNSSOperator::instance().BuildSMUCmd(NSS_GET_SHARE_CATALOG_LIST_REQ, pQueryInfo, strSMULinkID); CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR); //发送消息 IVS_INT32 iRet = IVS_FAIL; CCmd *pCmdRsp = CNSSOperator::instance().SendSyncCmd(pCmd); CHECK_POINTER(pCmdRsp, IVS_NET_RECV_TIMEOUT); const char* pBefore = CNSSOperator::instance().ParseCmd2XML(pCmdRsp, iRet); if (IVS_SUCCEED != iRet || NULL == pBefore) { HW_DELETE(pCmdRsp); BP_RUN_LOG_ERR(iRet, "Share Cata log list", "XML illegal "); return iRet; } HW_DELETE(pCmdRsp); std::string strBefore = pBefore; IVS_DELETE(pBefore, MUILI); //std::string strBefore("<Content><ShareDevList><ShareDevInfo><OriginDevCode>123456</OriginDevCode><OriginDomainCode>0123456789</OriginDomainCode><LocalDevCode>0123#001</LocalDevCode></ShareDevInfo></ShareDevList></Content>"); //std::string strBefore("<OriginDevCode>00000010000000000301</OriginDevCode><OriginDomainCode>001</OriginDomainCode><Latitude>0</Latitude><OriginDevCode>00000010000000000201#001</OriginDevCode><OriginDomainCode>001</OriginDomainCode><LocalDevCode /><Latitude>0</Latitude><OriginDevCode>00000010000000000101#001</OriginDevCode><OriginDomainCode>001</OriginDomainCode><OriginDevCode>1</OriginDevCode><OriginDomainCode /><LocalDevCode />"); std::string strAfter; iRet = ComplicationDevDomainCode(strBefore,strAfter); CXml xml; std::string strDomainCode; m_pUserMgr->GetDomainCode(strDomainCode); std::string strLocalDevCode; if (!xml.Parse(strAfter.c_str())) { BP_RUN_LOG_ERR(IVS_OPERATE_MEMORY_ERROR, "xml.Parse(strAfter) fail", "NA"); return IVS_OPERATE_MEMORY_ERROR; } if (!xml.FindElemEx("Content/ShareDevList")) { BP_RUN_LOG_ERR(IVS_SMU_DEV_REQ_XML_INVALID, "xml.FindElemEx(Content/ShareDevList) fail", "NA"); return IVS_SMU_DEV_REQ_XML_INVALID; } if (!xml.FindElem("ShareDevInfo")) { IVS_UINT32 uiXmlLen = 0; const IVS_CHAR* pRsp = xml.GetXMLStream(uiXmlLen); if (NULL == pRsp) { return IVS_SMU_DEV_REQ_XML_INVALID; } IVS_CHAR *cTmp = IVS_NEW(cTmp,strlen(pRsp) + 1); if (NULL == cTmp) { return IVS_ALLOC_MEMORY_ERROR; } memset(cTmp, 0, strlen(pRsp) + 1); memcpy(cTmp, pRsp, strlen(pRsp)); *pRspXml = cTmp; return IVS_SUCCEED; } do { (void)xml.IntoElem(); if (!xml.FindElem("LocalDevCode")) { BP_RUN_LOG_ERR(IVS_SMU_DEV_REQ_XML_INVALID, "xml.FindElem(LocalDevCode) fail", "NA"); return IVS_SMU_DEV_REQ_XML_INVALID; } const IVS_CHAR* pLocalDevCode = xml.GetElemValue(); if (NULL != pLocalDevCode) { strLocalDevCode = pLocalDevCode; } if (0 != strcmp(strLocalDevCode.c_str(), "")) { strLocalDevCode.append("#"); strLocalDevCode.append(strDomainCode); xml.ModifyElemValue(strLocalDevCode.c_str()); } xml.OutOfElem(); } while (xml.NextElem()); IVS_UINT32 uiLen = 0; const IVS_CHAR* pRsq = xml.GetXMLStream(uiLen); if (NULL == pRsq) { return IVS_SMU_DEV_REQ_XML_INVALID; } IVS_CHAR *cTmp = IVS_NEW(cTmp,strlen(pRsq) + 1); if (NULL == cTmp) { return IVS_ALLOC_MEMORY_ERROR; } memset(cTmp, 0, strlen(pRsq) + 1); memcpy(cTmp, pRsq, strlen(pRsq)); *pRspXml = cTmp; return iRet; }//lint !e1762
// 查询摄像机计划设置信息 IVS_INT32 CRecordPlanMgr::GetCameraPlanInfo(IVS_UINT32 uiPlanType, IVS_CHAR** pRspXml) { CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR); IVS_DEBUG_TRACE(""); IVS_INT32 iRet = IVS_FAIL; std::vector<std::string> domainCodeList; domainCodeList.clear(); iRet = m_UserMgr->GetDeviceMgr().GetDomainListByUserID(domainCodeList); if(IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet, "Get Domain List By User ID","Failed"); return iRet; } CmdMap cmdMap; std::map<std::string, std::string> domainCodeMap; std::map<std::string, std::string>::iterator domainCodeMapIter; IVS_UINT32 iSize = domainCodeList.size(); for(IVS_UINT32 i = 0; i < iSize; i++) { std::string strDomainCode = domainCodeList.at(i); CXml xmlReq; CRecordXMLProcess::GetCameraPlanInfoGetXML(uiPlanType, strDomainCode.c_str(), xmlReq); IVS_UINT32 xmlLen = 0; const IVS_CHAR* pReq = xmlReq.GetXMLStream(xmlLen); CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR); // 构造带域的请求消息,并发送 CSendNssMsgInfo sendNssMsgInfo; sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML); sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS); sendNssMsgInfo.SetReqID(NSS_GET_CAMERA_PLAN_INFO_REQ); sendNssMsgInfo.SetReqData(pReq); sendNssMsgInfo.SetDomainCode(strDomainCode); CCmd *pCmd = m_UserMgr->BuildCmd(sendNssMsgInfo); if (NULL == pCmd) { BP_RUN_LOG_INF("build cmd error","cmd req id=%d, domain code=%s",NSS_GET_CAMERA_PLAN_INFO_REQ,strDomainCode.c_str()); continue; } (void)domainCodeMap.insert(std::make_pair(pCmd->GetTransID(), strDomainCode)); (void)cmdMap.insert(std::make_pair(pCmd->GetTransID(), pCmd)); } if (cmdMap.empty()) { return IVS_SUCCEED; } IVS_UINT32 uiTimeout = CSDKConfig::instance().GetTimeOutValue(); iRet = CDispatcher::instance().dispatcherSyncMsgOutBatch(cmdMap, uiTimeout); if(IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet, "Get Camera Plan Info fail","SendCmd to SMU Return Failed"); return iRet; } std::map<std::string, PLAN_INFO_VEC> m_PlanMap; CmdMapIterator cmdMapIter; std::string strDomainCode; CCmd *pCmdRsp = NULL; for (cmdMapIter = cmdMap.begin(); cmdMapIter != cmdMap.end(); cmdMapIter++) { domainCodeMapIter = domainCodeMap.find(cmdMapIter->first); if (domainCodeMapIter != domainCodeMap.end()) { strDomainCode = domainCodeMapIter->second; } if(strDomainCode.empty()) { continue; } pCmdRsp = static_cast<CCmd *>(cmdMapIter->second);//lint !e63 IVS_CHAR* pRsp = CNSSOperator::instance().ParseCmd2XML(pCmdRsp, iRet); if (NULL == pRsp) { continue; } CXml xmlRsp; if(!xmlRsp.Parse(pRsp)) { BP_RUN_LOG_ERR(IVS_XML_INVALID, "Get Camera Plan Info", "xml parsing error"); continue; } PLAN_INFO_VEC m_PlanList; m_PlanList.clear(); iRet = CRecordXMLProcess::GetCameraPlanInfoParseXML(xmlRsp, m_PlanList); if(IVS_SUCCEED != iRet) { BP_RUN_LOG_ERR(iRet, "Get Camera PlanInfo ParseXML", "xml parsing error"); continue; } (void)m_PlanMap.insert(std::make_pair(strDomainCode, m_PlanList)); } CXml rspXml; CRecordXMLProcess::GetCameraPlanInfoGetXml(m_PlanMap, rspXml); IVS_UINT32 iLen = 0; const IVS_CHAR* pRsq = rspXml.GetXMLStream(iLen); IVS_DELETE(*pRspXml, MUILI); CHECK_POINTER(pRsq, IVS_OPERATE_MEMORY_ERROR); IVS_CHAR* pResult = IVS_NEW(pResult, strlen(pRsq) + 1); memset(pResult, 0x0, strlen(pRsq) + 1); if (!CToolsHelp::Memcpy(pResult, strlen(pRsq) + 1, pRsq, strlen(pRsq) + 1)) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "CToolsHelp::Memcpy pRsq to pResult failed", "NA"); return IVS_ALLOC_MEMORY_ERROR; } *pRspXml = pResult; return iRet; }