IVS_INT32 CDomainRouteMgr::GetSameSuperDomainCode(const std::string& strDomainCode1,
	const std::string& strDomainCode2, std::string& strSuperDomainCode)
{
	DOMAIN_CODE_LIST_MAP_ITER iter = m_domainCodeMap.begin();
	DOMAIN_CODE_LIST_MAP_ITER iterEnd = m_domainCodeMap.end();
	if (iter == iterEnd)
	{
		BP_RUN_LOG_INF("Get Same Super Domain Info", "No Domain Info");
		return IVS_FAIL;
	}
	IVS_INT32 iRet = IVS_FAIL;
	SUPER_DOMAIN_CODE_LIST superDomainCodeList1;	//域1的所有上级域List
	SUPER_DOMAIN_CODE_LIST superDomainCodeList2;	//域2的所有上级域List
	iRet = GetSuperDomainCodeList(superDomainCodeList1,strDomainCode1);
	iRet += GetSuperDomainCodeList(superDomainCodeList2,strDomainCode2);
	if(IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_INF("Get Same Super Domain Info", "Find Super Domain Info Error");
		return IVS_FAIL;
	}
	//如果其中一个没有
	if (superDomainCodeList1.size() >= superDomainCodeList2.size())
	{
		iRet = FindSameSuperDomainCode(superDomainCodeList1,superDomainCodeList2,strSuperDomainCode);
	}
	else
	{
		iRet = FindSameSuperDomainCode(superDomainCodeList2,superDomainCodeList1,strSuperDomainCode);
	}
	return iRet;
}
int CSDKMainctrl::Init()
{
	// 使用PID去初始化参数,第二个参数只有4位,用UUID生成被截断 不通进程同时开启有概率一样,mod by z0019317
    CMKTransID::Instance().SetTransParam("SDK#", CToolsHelp::Int2Str((int)ACE_OS::getpid()));  
	if (IVS_SUCCEED != CMainCtrl::Init())
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "Init failed","NA");
		return IVS_FAIL;
	}
	BP_RUN_LOG_INF("Init success","NA");
	if (IVS_SUCCEED != CMainCtrl::LoadNetService())
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "LoadNetService failed","NA");
		return IVS_FAIL;
	}
	BP_RUN_LOG_INF("CMainCtrl::LoadNetService success","NA");
    if (IVS_SUCCEED != CMainCtrl::LoadBusinessService(false))
    {
		BP_RUN_LOG_ERR(IVS_FAIL, "LoadBusinessService failed","NA");
        return IVS_FAIL;
    }
	BP_RUN_LOG_INF("LoadBusinessService success","NA");

	return IVS_SUCCEED;
}
//extern VOS_Sem* s_pGetSdpSem;
void CSDKMainctrl::OnLinkOpened(const std::string& strDevName, int iNetElementType, const std::string& strLinkID, const std::string& strIP, int iPort)
{

    // note by wanglei 00165153:2014.1.26 该逻辑未被调用,需要与BP确认原因 


    // 记录网元链接变更信息
    BP_RUN_LOG_INF("net element status change notify.", "linkage opened, ip:[%s], port:[%d], element type:[%d], link id:[%s].", 
        strIP.c_str(), iPort, iNetElementType, strLinkID.c_str());

    //根据linkId查找sessionID,查找CUserMgr对象
    int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(strLinkID);
    if (SDK_SESSIONID_INIT == iSessionID)
    {
        BP_RUN_LOG_INF("can't find sessionID by strLinkID, strLinkID is:","%s",strLinkID.c_str());
        return;
    }
    if (NULL == g_pNvs)
    {
        BP_RUN_LOG_INF("link opened","g_pNvs is null");
        return;
    }
    CUserMgr *pUserMgr = g_pNvs->GetUserMgr(iSessionID);
    if (NULL == pUserMgr)
    {
        BP_RUN_LOG_INF("link opened","pUserMgr is null");
        return;
    }

    CLinkRouteMgr::instance().SetLinkIDStatus(strLinkID, LINKID_STATUS_OPENED);
}
//根据map填充结构体
IVS_INT32 CDomainRouteMgr::GetDomainRouteStruct( IVS_DOMAIN_ROUTE_LIST* pDomainRouteList, IVS_UINT32 uiReqNum )
{
    BP_RUN_LOG_INF("Get Domain Route Info ", "Enter");

    IVS_UINT32 uiLen = m_domainCodeMap.size();

    //若map里面没有值,或者请求的大于最大值,则返回,告诉上层,要重新获取
    if ((0 == uiLen) || (uiLen > IVS_MAX_DOMAIN_ROUTE_NUM))
    {
        BP_RUN_LOG_ERR(IVS_FAIL, "Get Domain Route Info", "Can not find Domain Route Info");
        ClearDomainRouteMap();
        return IVS_FAIL;
    }

    DOMAIN_CODE_LIST_MAP_ITER domainInter = m_domainCodeMap.begin();
    DOMAIN_CODE_LIST_MAP_ITER domainInterEnd = m_domainCodeMap.end();
    IVS_UINT32 uiStLen = sizeof(IVS_DOMAIN_ROUTE);

    //这里要跟请求的数量进行比较
    for (IVS_UINT32 uiIndex = 0; uiIndex < uiReqNum && domainInter != domainInterEnd; uiIndex++, domainInter++)
    {
        IVS_DOMAIN_ROUTE &stRoute = pDomainRouteList->stDomainRoute[uiIndex];
        if (NULL != domainInter->second)
        {
            memcpy(&stRoute, domainInter->second, uiStLen);
        }
    }

    pDomainRouteList->uiTotal = uiLen;
    //pDomainRouteList->stIndexRange.uiFromIndex = 1;
    //pDomainRouteList->stIndexRange.uiToIndex = uiLen;
    BP_RUN_LOG_INF("Get Domain Route Info", "Leave");
    return IVS_SUCCEED;
}
void CSDKMainctrl::OnLinkClosed(const std::string& strDevName, int iNetElementType, const std::string& strLinkID, const std::string& strIP, int iPort)
{

    // 记录网元链接变更信息
    BP_RUN_LOG_INF("net element status change notify.", "linkage closed, ip:[%s], port:[%d], element type:[%d], link id:[%s].", 
        strIP.c_str(), iPort, iNetElementType, strLinkID.c_str());


	// TODO 重连等操作
    //根据linkId查找sessionID,设置连接状态为断   
    CLinkRouteMgr::instance().SetLinkIDStatus(strLinkID, LINKID_STATUS_CLOSED);
    
	int iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(strLinkID);
	if (SDK_SESSIONID_INIT == iSessionID)
	{
		BP_RUN_LOG_INF("can't find sessionID by strLinkID, strLinkID is:","%s",strLinkID.c_str());
		return;
	}
	if (NULL == g_pNvs)
	{
		BP_RUN_LOG_INF("link opened","g_pNvs is nul");
		return;
	}
	CUserMgr *pUserMgr = g_pNvs->GetUserMgr(iSessionID);
	if (NULL == pUserMgr)
	{
		BP_RUN_LOG_INF("link opened","pUserMgr is null");
		return;
	}

	pUserMgr->AddLinkIdToBusinessResumeList(strLinkID,iNetElementType,strIP,iPort,TYPE_ADD_RELINK/*TYPE_ADD_CLOSECOUNT*/);
}
 // 实现外域发送消息公共方法(支持重定向)
 IVS_INT32 CXmlProcess::GetCommSendMgrForRedirect(CXml &xml, CUserMgr* pUserMgr, NSS_MSG_TYPE_E msgType, IVS_INT32 iType, const IVS_CHAR* pCameraCode,const IVS_CHAR* pDomainCode)
 {
	 CHECK_POINTER(pDomainCode, IVS_OPERATE_MEMORY_ERROR);
	 CHECK_POINTER(pUserMgr, IVS_OPERATE_MEMORY_ERROR);

	 IVS_UINT32 xmlLen = 0;
	 const IVS_CHAR* pReq = xml.GetXMLStream(xmlLen);
	 CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR);

	 BP_RUN_LOG_INF("Get CommSendMgr For Redirect", "send XML = %s", pReq);

	 // 构造带域的请求消息,并发送
	 CSendNssMsgInfo sendNssMsgInfo;
	 sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML);
	 sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS);
	 sendNssMsgInfo.SetReqID(msgType);
	 sendNssMsgInfo.SetReqData(pReq);
	 sendNssMsgInfo.SetCameraCode(pCameraCode);
	 sendNssMsgInfo.SetDomainCode(pDomainCode);
	 std::string strpRsp;
	 IVS_INT32 iNeedRedirect = IVS_FAIL;
	 IVS_INT32 iRet = pUserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect);

     if (IVS_SUCCEED != iRet)
     {
          BP_RUN_LOG_ERR(iRet,"Get CommSendMgr For Redirect", "seng cmd fail");
          return iRet;
     }

	 if(NSS_GET_VOICE_INFO_REQ == msgType || NSS_GET_CAMERA_CFG_REQ == msgType)
	 {
		 if (IVS_SUCCEED == iNeedRedirect)
		 {
			 iRet = pUserMgr->SendRedirectServe(sendNssMsgInfo,strpRsp);
		 }
	 }

	 // 返回相应消息
	 if (BUILSTRING == iType)
	 {
		 if (strpRsp.empty())
		 {
			 BP_RUN_LOG_ERR(iRet,"NULL == strpRsp", "iRet = %d", iRet);
			 return iRet;
		 }
		 if(iRet == IVS_SUCCEED)
		 { 
			 iRet = IVS_XML_INVALID;
			 xml.RemoveElem();
			 if(xml.Parse(strpRsp.c_str()))
			 {
				 iRet = IVS_SUCCEED;
			 }
		 }
		 BP_RUN_LOG_INF("Get CommSendMgr For Redirect", "revice XML = %s", strpRsp.c_str());
	 }

	 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;
}
 //获取平台录像计划;
 IVS_INT32 CRecordPlanMgr::GetRecordPlan(const char* pCameraCode,IVS_UINT32 uiRecordMethod,
	 IVS_RECORD_PLAN* pRecordPlan)
 {
	 CHECK_POINTER(pCameraCode, IVS_PARA_INVALID);
	 CHECK_POINTER(pRecordPlan, IVS_PARA_INVALID);
	 CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR);
	 IVS_DEBUG_TRACE("");
	 //数据结构拼装XML并转换为const IVS_CHAR *
	 CXml xmlReq;
	 IVS_INT32 iRet = CRecordXMLProcess::GetRecordPlanGetXML(pCameraCode, uiRecordMethod, xmlReq);

	 unsigned int xmlLen = 0;
	 const IVS_CHAR * pReqPlan = xmlReq.GetXMLStream(xmlLen);
	 CHECK_POINTER(pReqPlan, IVS_OPERATE_MEMORY_ERROR);

	 IVS_CHAR chDevCode[IVS_DEV_CODE_LEN+1];
	 memset(chDevCode, 0, sizeof(chDevCode));

	 IVS_CHAR chDomaCode[IVS_DOMAIN_CODE_LEN+1];
	 memset(chDomaCode, 0, sizeof(chDomaCode));

	 (IVS_VOID)CXmlProcess::ParseDevCode(pCameraCode, chDevCode, chDomaCode);
	 //发送nss协议
	 CSendNssMsgInfo sendNssMsgInfo;	
	 sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML);
	 sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS);
	 sendNssMsgInfo.SetReqID(NSS_GET_RECORD_PLAN_REQ);
	 sendNssMsgInfo.SetReqData(pReqPlan); 
	 sendNssMsgInfo.SetCameraCode(chDevCode);
	 sendNssMsgInfo.SetDomainCode(chDomaCode);

	 std::string strpRsp;
	 IVS_INT32 iNeedRedirect = IVS_FAIL;
	 iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect);
	 if(IVS_SUCCEED != iRet)
	 {
		 BP_RUN_LOG_INF("Get Platform Record Plan", "ok", "Get Platform RecordPlan Success.pResultList size is 0.");
		 return iRet;
	 }

	 // 将xml转化成结构体返回
	 CXml xmlRsp;
	 (void)xmlRsp.Parse(strpRsp.c_str());
	 IVS_INT32 iParseRSPRet = CRecordXMLProcess::GetRecordPlanParseRSP(pRecordPlan,xmlRsp);

	 BP_RUN_LOG_INF("Get Record Plan", "ok", "msg have Parsed");
	 return iRet;
 }//lint !e1762 !e818 !e529
// 对xml添加一个loginID,并发送到SMU
IVS_INT32 CNSSOperator::AddLoginIdAndSendCmd(unsigned short iReqID, const IVS_CHAR* pReqXml) const
{
	CHECK_POINTER(pReqXml, IVS_OPERATE_MEMORY_ERROR);
	BP_RUN_LOG_INF("Add login id and send cmd", "send xml = %s", pReqXml);
	CCmd* pCmd = CNSSOperator::instance().BuildSMUCmd(iReqID, pReqXml);
	CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR);

	// 同步发送消息
	CCmd *pCmdRsp = CNSSOperator::instance().SendSyncCmd(pCmd);
	CHECK_POINTER(pCmdRsp, IVS_NET_RECV_TIMEOUT);
	IVS_INT32 iRet = CNSSOperator::instance().ParseCmd2NSS(pCmdRsp);
	BP_RUN_LOG_INF("send cmd", "iRet= %d", iRet);
	HW_DELETE(pCmdRsp);

	return iRet;
}
// 设置平台录像码流回放速度
int CTPPlayChannel::SetPlayBackSpeedByIP(IVS_FLOAT fSpeed)
{
	IVS_DEBUG_TRACE("Speed: %f", fSpeed);

	RTSP_SESSION_STATUS state = RTSP_CLIENT_GetStatus(m_iRtspHandle);
	if (RTSP_SESSION_STATUS_PLAYING == state ||
		RTSP_SESSION_STATUS_READY   == state)
	{
		float fSendScale = fSpeed;
		(void)CToolsHelp::GetSendScale(SERVICE_TYPE_PLAYBACK, fSpeed, fSendScale);
		MEDIA_RANGE_S stMdieaRange;
		memset(&stMdieaRange, 0x0, sizeof(MEDIA_RANGE_S));
		stMdieaRange.enRangeType = RANGE_TYPE_NPT;
		stMdieaRange.MediaBeginOffset = OFFSET_CUR;

		IVS_INT32 iRet = RTSP_CLIENT_SendPlayMsg(m_iRtspHandle, m_strURL.c_str(), (double)fSendScale, &stMdieaRange, RTSP_CLIENT_TIMEOUT);
		if (IVS_SUCCEED != iRet)
		{  
			(void)RTSP_CLIENT_SendTeardownMsg(m_iRtspHandle, m_strURL.c_str(), 1);
			(void)RTSP_CLIENT_FreeHandle(m_iRtspHandle);
			BP_RUN_LOG_ERR(iRet, "Set PlayBack Speed", "Send Play Message failed.");
			return IVS_PLAYER_RET_RTSP_SEND_PLAY_FAIL;
		}
		m_fRTSPSpeed = fSendScale;
		
        BP_RUN_LOG_INF("Set PlayBack Speed", "m_fRTSPSpeed:[%f], fSpeed:[%f].", m_fRTSPSpeed, fSpeed);
		return IVS_SUCCEED;
	}

	BP_RUN_LOG_ERR(IVS_FAIL, "Set PlayBack Speed", "fSpeed:[%f], RTSP Session Status: %d", fSpeed, state);
	return IVS_FAIL;
}
IVS_INT32 CDomainRouteMgr::GetDomainRoute()
{
    BP_RUN_LOG_INF("Get DomainRoute", "Enter");
    IVS_INT32 iRet = IVS_FAIL;
    CXml xmlRsp;
    iRet = SendCmdAndGetInfo(xmlRsp);
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet, "Get DomainRoute", "Get DomainRoute Info Error");
        return iRet;
    }

    DOMAIN_CODE_LIST stCodeInfoList;
	iRet = GetDomainRouteToListParseXML(stCodeInfoList, xmlRsp);
    if (IVS_SUCCEED == iRet)
    {
		ClearDomainRouteMap();
        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();
        char szDomainCode[IVS_DOMAIN_CODE_LEN + 1];
        unsigned int uiCopyLen = IVS_DOMAIN_CODE_LEN;
        IVS_DOMAIN_ROUTE* pstDomainRout = NULL;
        for (; iterBegin != iterEnd; iterBegin++)
        {
            pstDomainRout = *iterBegin;
            if (NULL == pstDomainRout)
            {
                continue;
            }
            //确保数组最后一位为“/0”
            memset(szDomainCode, 0, IVS_DOMAIN_CODE_LEN + 1);
            (void)CToolsHelp::Memcpy(szDomainCode, uiCopyLen, pstDomainRout->cDomainCode, uiCopyLen);
            //插入Map表
            (IVS_VOID)m_domainCodeMap.insert(std::make_pair(szDomainCode, pstDomainRout));
        }
        stCodeInfoList.clear();
    }
    m_proxyDomainCodeMap.clear(); // 清除代理域map
    BP_RUN_LOG_INF("Get DomainRoute", "Leave");
    return iRet;
}
// 推送发现到的前端设备
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_INT32 CTPPlayChannel::SetPlayBackTimeByIP(IVS_UINT32 uiTime)
{
	IVS_INT32 iRet = GetPlayBackTimeSpan(m_strURL, m_stTimeSpanInter);
	if (IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "Set PlayBack Time ByIP", "Get PlayBack TimeSpan failed");
		return iRet;
	}

	IVS_UINT32 uiTime2Set = (unsigned int)m_stTimeSpanInter.iStartTime + uiTime;
	if (uiTime2Set >= (unsigned int)m_stTimeSpanInter.iEndTime)
	{
		BP_RUN_LOG_ERR(IVS_PARA_INVALID, 
			"Set PlayBack Time ByIP", 
			"Param invalid, uiTime is over end time, startTime = %d, end time = %d, set Time = %d", 
			m_stTimeSpanInter.iStartTime, 
			m_stTimeSpanInter.iEndTime, 
			uiTime);
		return IVS_PARA_INVALID;
	}

	BP_RUN_LOG_INF("Set PlayBack Time ByIP", "RTSP_CLIENT_SendPlayMsg begin, rtsphandle=%d, speed=%f, settime=%u.", m_iRtspHandle, m_fRTSPSpeed, uiTime);

	MEDIA_RANGE_S stRange;
	memset(&stRange, 0x0, sizeof(MEDIA_RANGE_S));
	stRange.enRangeType      = RANGE_TYPE_NPT;
	stRange.MediaBeginOffset = uiTime;
	
	iRet = RTSP_CLIENT_SendPlayMsg(m_iRtspHandle, m_strURL.c_str(), (double)m_fRTSPSpeed, &stRange, RTSP_CLIENT_TIMEOUT);

	BP_RUN_LOG_INF("Set PlayBack Time ByIP", "RTSP_CLIENT_SendPlayMsg end, iRet=%d.", iRet);

	if (IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_ERR(IVS_PLAYER_RET_RTSP_SEND_PLAY_FAIL,"Set PlayBack Time ByIP", "RTSP_CLIENT_SendPlayMsg failed.");
		return IVS_PLAYER_RET_RTSP_SEND_PLAY_FAIL;
	}

	return IVS_SUCCEED;
}
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;
}
Beispiel #15
0
// 获取数据格式类型从字符串到整形
IVS_INT32 CDevEnum::GetDataFormatINT(const IVS_CHAR* pDataFormat)
{
	CHECK_POINTER(pDataFormat, IVS_OPERATE_MEMORY_ERROR);
	IVS_INT32 iRet = -1;
	IVS_INT32 iLen = sizeof(chDataFormat)/sizeof(chDataFormat[0]);
	for (int i = 1; i < iLen; i++)
	{
		if (0 == strcmp(chDataFormat[i], pDataFormat))
		{
			iRet = i;
			break;
		}
	}
	BP_RUN_LOG_INF("Get DataFormat", "resolution=%d",iRet);
	return iRet;
}
IVS_INT32 CDomainRouteMgr::GetSuperDomainCodeList(SUPER_DOMAIN_CODE_LIST& superDomainCodeList, const std::string& strDomainCode)
{
	DOMAIN_CODE_LIST_MAP_ITER iter = m_domainCodeMap.find(strDomainCode);
	DOMAIN_CODE_LIST_MAP_ITER iterEnd = m_domainCodeMap.end();
	if (iter == iterEnd)
	{
		BP_RUN_LOG_INF("Get Super Domain Info", "No Find Domain Info");
		return IVS_FAIL;
	}
	std::string strFatherDomainCode;
	char szDomainCode[IVS_DOMAIN_CODE_LEN + 1];
	unsigned int uiCopyLen = IVS_DOMAIN_CODE_LEN;
	unsigned int uiMapSize = m_domainCodeMap.size();
	unsigned int loopNum = 0; //定义循环次数限制,防止死循环发生
	IVS_DOMAIN_ROUTE* pDomainRoute = NULL;
	//先将自己所在的域信息加入到List(解决如果当前域就是最上级域的问题)
	superDomainCodeList.push_back(strDomainCode);
	//递归查找某个域的所有上级域信息
	do 
	{
		//取出查找的域信息
		pDomainRoute = dynamic_cast <IVS_DOMAIN_ROUTE*>(iter->second);//lint !e611
		if (NULL == pDomainRoute)
		{
			return IVS_FAIL;
		}
		//拷贝出父域信息
		memset(szDomainCode, 0, IVS_DOMAIN_CODE_LEN + 1);
		if (!CToolsHelp::Memcpy(szDomainCode, uiCopyLen, pDomainRoute->cSuperDomain, uiCopyLen))
		{
			BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR, "Get Super Domain Route Info", "DomainCode Memcpy error.");
			return false;
		}
		//获取该域的父域Code
		strFatherDomainCode = szDomainCode;
		//查找父域在Map表中的信息
		iter = m_domainCodeMap.find(strFatherDomainCode);
		if (iter == iterEnd)
		{
			break;
		}
		//如果父域信息在Map表中可以找到,将父域信息加入List
		superDomainCodeList.push_back(strFatherDomainCode);
	} while (loopNum < uiMapSize);

	return IVS_SUCCEED;
}
Beispiel #17
0
// 获取编码格式
IVS_INT32 CDevEnum::GetEnCodeModeEnum(const IVS_CHAR* pCodeMode)
{
    CHECK_POINTER(pCodeMode, IVS_OPERATE_MEMORY_ERROR);

    IVS_INT32 iRet = 0;

    IVS_INT32 iLen = sizeof(chEnCodeModeCHType)/sizeof(chEnCodeModeCHType[0]);
    for (IVS_INT32 i = 0; i < iLen; i++ )
    {
        if (0 == strcmp(chEnCodeModeCHType[i], pCodeMode))
        {
            iRet = i ;
        }
    }
    BP_RUN_LOG_INF("Get H264ProfileEnum fail", "VideoType=%d",iRet);

    return iRet;
}
Beispiel #18
0
// 获取可靠传输类型从字符串到整形
IVS_INT32 CDevEnum::GetReliableTransTypeINT(const IVS_CHAR* pTransType)
{
	CHECK_POINTER(pTransType, IVS_OPERATE_MEMORY_ERROR);

	IVS_INT32 iRet = -1;
	IVS_INT32 iLen = sizeof(chTransType) / sizeof(chTransType[0]);
	for (int i = 0;i < iLen;i++)
	{
		if (0 == strcmp(chTransType[i], pTransType))
		{
			iRet = i;
			break;
		}
	}

	BP_RUN_LOG_INF("Get ReliableTransType", "resolution=%d",iRet);	

	return iRet;
}
IVS_INT32 CDomainRouteMgr::FindSameSuperDomainCode(SUPER_DOMAIN_CODE_LIST& superDomainCodeList1,
	SUPER_DOMAIN_CODE_LIST& superDomainCodeList2, std::string& strSuperDomainCode)
{
	unsigned int  iSizeTolist1 = superDomainCodeList1.size();
	unsigned int  iSizeTolist2 = superDomainCodeList2.size();
	if (iSizeTolist1 < iSizeTolist2)
	{
		BP_RUN_LOG_INF("Find Same Super Domain Code", "Use Function Error");
		return IVS_FAIL;
	}
	//所有list的迭代器初始化
	SUPER_DOMAIN_CODE_LIST_ITER list1Iter = superDomainCodeList1.begin();
	SUPER_DOMAIN_CODE_LIST_ITER list1IterEnd = superDomainCodeList1.end();
	SUPER_DOMAIN_CODE_LIST_ITER list2Iter = superDomainCodeList2.begin();
	SUPER_DOMAIN_CODE_LIST_ITER list2IterEnd = superDomainCodeList2.end();
	//list的大小差异
	unsigned int  iDifSize = iSizeTolist1 - iSizeTolist2;
	//首先查找list1比list2多出的部分
	for (unsigned int i = 0; i < iDifSize ; i++)
	{
		//如果父域相同
		if (0 == strcmp((*list1Iter).c_str(),(*list2Iter).c_str()))
		{
			strSuperDomainCode = *list1Iter;
			return IVS_SUCCEED;
		}
		list1Iter++;
	}
	//剩余相等部分
	for (;list1Iter != list1IterEnd && list2Iter != list2IterEnd ;)
	{
		//如果父域相同
		if (0 == strcmp((*list1Iter).c_str(),(*list2Iter).c_str()))
		{
			strSuperDomainCode = *list1Iter;
			return IVS_SUCCEED;
		}
		list1Iter++;
		list2Iter++;
	}
	return IVS_FAIL;
}//lint !e1762
Beispiel #20
0
// 获取镜头码流分辨率
IVS_INT32 CDevEnum::GetResolutionEnum(const IVS_CHAR*pResolution)
{

    IVS_INT32 iRet = 0;
    CHECK_POINTER(pResolution, IVS_OPERATE_MEMORY_ERROR);

    IVS_INT32 iLen = sizeof(chResolutionType)/sizeof(chResolutionType[0]);
    for (IVS_INT32 i = 0; i < iLen ; i ++)
    {
        if (0 == strcmp(chResolutionType[i], pResolution))
        {
            iRet = i;
			break;
        }
    }  
   
    BP_RUN_LOG_INF("Get ResolutionEnum fail", "resolution=%d",iRet);

    return iRet;
}
bool CI18N::SetLanguage(const std::string& strLanguageXMLPath)
{
    BP_RUN_LOG_INF("load language xml failed","strLanguageXMLPath %s", strLanguageXMLPath.c_str());
	CXml xml;
	if (!xml.Load(strLanguageXMLPath.c_str(), TIXML_ENCODING_UTF8))
	{
		//表示加载资源XML不成功
		BP_RUN_LOG_ERR(IVS_FAIL,"load language xml failed","NA");
		return false;
	}

	//如果加载成功了,就遍历xml将所有的资源和语言绑定并加入map表
	if (!xml.FindElemEx("Content"))
	{
		//没找到第一个结点
		return false;
	}

	//先进行清除
	Clear();

	do 
	{
		// 获取当前结点
		const char* ResourceNode = xml.GetElem();
		// 获取当前结点的值
		const char* ResourceNodeValue = xml.GetElemValue();
		// 转换编码,防止乱码
		char* xml2ANSI = CToolsHelp::UTF8ToANSI(ResourceNodeValue);
		//把结点和值绑定进行插入
		(void)VOS_MutexLock(m_pMutexLock);
		(void)m_mapResource2Language.insert(std::make_pair(ResourceNode, xml2ANSI));
		(void)VOS_MutexUnlock(m_pMutexLock);
		free(xml2ANSI);
	} while (xml.NextElem());

	return true;
}
IVS_INT32 CTPPlayChannel::GetPlayBackTimeSpan(const std::string& strURL, 
	TIME_SPAN_INTERNAL& stTimeSpan)
{
	//从URL中获取时间戳
	std::string strTimeSpan;
	IVS_UINT32 uiPos = m_strURL.find("TimeSpan=");
	if (std::string::npos == uiPos || uiPos >= m_strURL.size())
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "Get PlayBack TimeSpan", "Can't find TimeSpan from URL");
		return IVS_FAIL;
	}
	strTimeSpan = m_strURL.substr(uiPos, m_strURL.size() - uiPos);

	uiPos = strTimeSpan.find("&");
	if (std::string::npos == uiPos)
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "Get PlayBack TimeSpan", "Cant't find &, URL format error");
		return IVS_FAIL;
	}
	strTimeSpan = strTimeSpan.substr(strlen("TimeSpan="), uiPos - strlen("TimeSpan="));

	uiPos = strTimeSpan.find("-");
	if (std::string::npos == uiPos)
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "Get PlayBack TimeSpan", "Can't find -, URL format error");
		return IVS_FAIL;
	}

	std::string strStartTime = strTimeSpan.substr(0, uiPos);
	std::string strEndTime = strTimeSpan.substr(uiPos + 1, strlen(IVS_DATE_TIME_NET_FORMAT));

	m_stTimeSpanInter.iStartTime = (IVS_INT32)CMediaBase::UTCStr2Time(strStartTime.c_str(), IVS_DATE_TIME_NET_FORMAT);
	m_stTimeSpanInter.iEndTime = (IVS_INT32)CMediaBase::UTCStr2Time(strEndTime.c_str(), IVS_DATE_TIME_NET_FORMAT);
	BP_RUN_LOG_INF("Get PlayBack TimeSpan", "strStartTime=%s strEndTime=%s iStartTime=%d iEndTime=%d.", 
		strStartTime.c_str(), strEndTime.c_str(), m_stTimeSpanInter.iStartTime, m_stTimeSpanInter.iEndTime);

	return IVS_SUCCEED;
}
//获取回放Url
int CPlayback::DoGetUrlPlayBack(const IVS_CHAR* pDomainCode,const IVS_CHAR* pNVRCode,
                                IVS_SERVICE_TYPE ServiceType,
                                const TIME_SPAN_INTERNAL& stTimeSpanInter,
                                const char *pFileName)
{
    IVS_DEBUG_TRACE("");

    int iRet = IVS_FAIL;

    //请求消息;
    memset(&m_stUrlMediaInfo, 0, sizeof(ST_URL_MEDIA_INFO));

    if(NULL != pNVRCode)
    {
        (void)CToolsHelp::Strncpy(m_stUrlMediaInfo.szNVRCode, sizeof(m_stUrlMediaInfo.szNVRCode),pNVRCode, strlen(pNVRCode));//lint !e534
    }
    else
    {
        memset(&m_stUrlMediaInfo.szNVRCode,0,IVS_NVR_CODE_LEN);//lint !e545
        m_pUserMgr->GetRecordList().GetRecordNVRInfo(m_stUrlMediaInfo.szSrcCode,stTimeSpanInter.iStartTime,stTimeSpanInter.iEndTime,m_stUrlMediaInfo.szNVRCode);
    }

    //校验参数
    if (NULL != pFileName)
    {
        (void)CToolsHelp::Strncpy(m_stUrlMediaInfo.szFileName, FILE_NAME_LEN,
                                  pFileName, strlen(pFileName)+1);
    }

    //TODO : szDstPort无实际作用,传一个固定值;打包协议类型szDstPP入参结构体未定义
    m_stUrlMediaInfo.ServiceType = ServiceType;

    std::string strCameraDomainCode = m_szCameraID;
    std::string strCameraCode;
    std::string strDomainCode;
    iRet = CToolsHelp::SplitCameraDomainCode(m_szCameraID, strCameraCode, strDomainCode);
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "CToolsHelp::SplitCameraCode failed, RetCode=%d.", iRet);
        return iRet;
    }
    (void)CToolsHelp::Strncpy(m_stUrlMediaInfo.szSrcCode, sizeof(m_stUrlMediaInfo.szSrcCode), strCameraCode.c_str(), strCameraCode.size());//lint !e534
    (void)CToolsHelp::Strncpy(m_stUrlMediaInfo.szDstCode,sizeof(m_stUrlMediaInfo.szDstCode), "01",strlen("01"));//lint !e534

    if(NULL == pDomainCode)
    {

        (void)CToolsHelp::Strncpy(m_stUrlMediaInfo.cDomainCode,IVS_DOMAIN_CODE_LEN+1,  strDomainCode.c_str(), strDomainCode.size());//lint !e534
    }
    else
    {
        (void)CToolsHelp::Strncpy(m_stUrlMediaInfo.cDomainCode,IVS_DOMAIN_CODE_LEN+1,  pDomainCode, strlen(pDomainCode));//lint !e534
    }
    m_stUrlMediaInfo.MediaPara.StreamType = m_stuMediaParam.StreamType;
    m_stUrlMediaInfo.MediaPara.ProtocolType = m_stuMediaParam.ProtocolType;
    m_stUrlMediaInfo.PackProtocolType = PACK_PROTOCOL_ES;
    m_stUrlMediaInfo.MediaPara.BroadCastType = m_stuMediaParam.BroadCastType;
    m_stUrlMediaInfo.MediaPara.VideoDecType = m_stuMediaParam.VideoDecType;
    m_stUrlMediaInfo.MediaPara.AudioDecType = m_stuMediaParam.AudioDecType;
    m_stUrlMediaInfo.MediaPara.TransMode = m_stuMediaParam.TransMode;



    (void)CToolsHelp::Strncpy(m_stUrlMediaInfo.szDstIP, sizeof(m_stUrlMediaInfo.szDstIP), "",strlen(""));//lint !e534
    (void)CToolsHelp::Strncpy(m_stUrlMediaInfo.szDstPort, sizeof(m_stUrlMediaInfo.szDstPort), "35016",strlen("35016"));//lint !e534

    std::string strTime;
    UTCTime2Str((time_t)stTimeSpanInter.iStartTime, strTime, IVS_DATE_TIME_NET_FORMAT);
    strTime.append("-");
    std::string strEndTime;
    UTCTime2Str((time_t)stTimeSpanInter.iEndTime, strEndTime, IVS_DATE_TIME_NET_FORMAT);
    strTime.append(strEndTime);
    if (TIME_SPAN_LEN <= strTime.size())
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "Parse time span from rsp url failed. time string over max length. strTime=%s.", strTime.c_str());
        return iRet;
    }
    (void)CToolsHelp::Memcpy(m_stUrlMediaInfo.szTimeSpan,TIME_SPAN_LEN, strTime.c_str(), strTime.length());
    //获取媒体URL
    iRet = GetURL(CToolsHelp::GetSCCHead().c_str(), m_pUserMgr, m_stUrlMediaInfo, m_stMediaRsp, m_bAssociatedAudio);//lint !e838
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "platform play back get URL failed!");
        return iRet;
    }

    iRet = ParseIPAddr(m_stMediaRsp.szURL,m_strMuIpAddr);
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url RealPlay", "parse IP Addr failed from url: %s",
                       m_stMediaRsp.szURL);
        return iRet;
    }

    //解析URL,得到ServiceType,如果是组播实况(直连),那么协议类型转为udp
    std::string strServiceType;
    iRet = ParseURL(m_stMediaRsp.szURL, URL_SERVICE_TYPE_FLAG, strServiceType);
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "parse service type from url failed, URL=%s",
                       m_stMediaRsp.szURL);
        return iRet;
    }
    int iServiceType = CToolsHelp::StrToInt(strServiceType);

    std::string strMediaTransMode;
    iRet = ParseURL(m_stMediaRsp.szURL, URL_MEDIA_TRANS_MODE, strMediaTransMode);
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "parse media trans mode failed from url");
        return iRet;
    }
    int iMediaTransMode = CToolsHelp::StrToInt(strMediaTransMode);

    std::string strBroadcastType;
    iRet = ParseURL(m_stMediaRsp.szURL, URL_BROADCAST_TYPE, strBroadcastType);
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "parse broadcast type failed from url");
        return iRet;
    }
    int iBroadcastType = CToolsHelp::StrToInt(strBroadcastType);

    std::string strTimeSpan;
    iRet = ParseURL(m_stMediaRsp.szURL, URL_TIME_SPAN, strTimeSpan);
    if (IVS_SUCCEED != iRet || strTimeSpan.empty())
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "parse timespan failed from url");
        return iRet;
    }

    unsigned int uiPos = strTimeSpan.find("-");
    if (std::string::npos == uiPos || uiPos >= strTimeSpan.length())
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "parse timespan failed from url,find spliter failed.");
        return iRet;
    }
    std::string strStartTime = strTimeSpan.substr(0, uiPos);
    if (std::string::npos == (uiPos+1) || (uiPos+1) >= strTimeSpan.length())
    {
        BP_RUN_LOG_ERR(iRet,"Do Get Url Play Back", "parse timespan failed from url,find spliter failed.");
        return iRet;
    }
    strEndTime = strTimeSpan.substr(uiPos+1, strlen(IVS_DATE_TIME_NET_FORMAT));

    m_stTimeSpanInter.iStartTime = (IVS_INT32)UTCStr2Time(strStartTime.c_str(), IVS_DATE_TIME_NET_FORMAT);
    m_stTimeSpanInter.iEndTime = (IVS_INT32)UTCStr2Time(strEndTime.c_str(), IVS_DATE_TIME_NET_FORMAT);

    BP_RUN_LOG_INF("Do Get Url Play Back", "strStartTime=%s strEndTime=%s iStartTime=%d iEndTime=%d.", strStartTime.c_str(), strEndTime.c_str(), m_stTimeSpanInter.iStartTime, m_stTimeSpanInter.iEndTime);

    m_enServiceType = (IVS_SERVICE_TYPE)iServiceType;
    m_stuMediaParam.TransMode = (IVS_MEDIA_TRANS_MODE)iMediaTransMode;
    m_stuMediaParam.BroadCastType = (IVS_BROADCAST_TYPE)iBroadcastType;


    // 直连组播实况,需要将协议类型转换为UDP;
    if (SERVICE_TYPE_REALVIDEO == m_enServiceType
            && MEDIA_DIRECT == m_stuMediaParam.TransMode
            && BROADCAST_MULTICAST == m_stuMediaParam.BroadCastType)
    {
        m_stuMediaParam.ProtocolType = PROTOCOL_RTP_OVER_UDP;
    }

    //// add for 流复用 [12/17/2012 z90003203] // TODO 疑问:这个流复用,服务器会给内容?
    //int iStreamType = 0;
    //iRet = ParseURL(m_stMediaRsp.szURL, URL_STREAM_TYPE, &iStreamType);
    //if (IVS_SUCCEED != iRet)
    //{
    //    BP_RUN_LOG_ERR(iRet,"GetUrlRealPlay", "parse stream type failed from url");
    //    return iRet;
    //}

    //m_stuMediaParam.StreamType = (IVS_STREAM_TYPE)iStreamType;

    //if (STREAM_TYPE_UNSPECIFIED == m_stuMediaParam.StreamType)
    //{
    //    m_stuMediaParam.StreamType = STREAM_TYPE_MAIN;
    //}
    //// end add

    return iRet;
}//lint !e529
//设置录像回放时间
int CPlayback::SetPlayBackTime(unsigned int uiTime)
{
    CLockGuard lock(m_pMediaMutex);

    // 支持拖动到开始时间,即0 == uiTime的情况合法;
    /*if (0 == uiTime)
    {
        BP_RUN_LOG_ERR(IVS_PARA_INVALID,
                        "SetPlayBackTime",
                        "Param invalid, setTime = 0");
        return IVS_PARA_INVALID;
    }*/

    IVS_PLAY_ResetData(m_ulPlayerChannel);

    if (!m_bLocalFile)
    {
        unsigned int uiTime2Set = (unsigned int)m_stTimeSpanInter.iStartTime + uiTime;
        if (uiTime2Set >= (unsigned int)m_stTimeSpanInter.iEndTime)
        {
            BP_RUN_LOG_ERR(IVS_PARA_INVALID,
                           "Set Play Back Time",
                           "Param invalid, uiTime is over end time, startTime = %d, end time = %d, set Time = %d",
                           m_stTimeSpanInter.iStartTime,
                           m_stTimeSpanInter.iEndTime,
                           uiTime);
            return IVS_PARA_INVALID;
        }

        BP_RUN_LOG_INF("Set Play Back Time", "RTSP_CLIENT_SendPlayMsg begin, rtsphandle=%d, speed=%f, settime=%u.", m_iRtspHandle, m_fSpeed, uiTime);

        MEDIA_RANGE_S stRange;
        memset(&stRange, 0x0, sizeof(MEDIA_RANGE_S));
        stRange.enRangeType      = RANGE_TYPE_NPT;
        stRange.MediaBeginOffset = uiTime;
        float fSendScale = 0.0;
        (void)CToolsHelp::GetSendScale(m_enServiceType, m_fSpeed, fSendScale);
        int iRet = RTSP_CLIENT_SendPlayMsg(m_iRtspHandle, m_stMediaRsp.szURL,
                                           (double)fSendScale, &stRange, RTSP_CLIENT_TIMEOUT);

        BP_RUN_LOG_INF("Set Play Back Time", "RTSP_CLIENT_SendPlayMsg end, iRet=%d.", iRet);

        if (0 != iRet)
        {
            BP_RUN_LOG_ERR(IVS_PLAYER_RET_RTSP_SEND_PLAY_FAIL,"Set Play Back Time", "RTSP_CLIENT_SendPlayMsg failed.");
            return IVS_PLAYER_RET_RTSP_SEND_PLAY_FAIL;
        }
    }


    IVS_PLAY_SetPlayTime(m_ulPlayerChannel, m_tmStart + uiTime);

    /*
     * DTS2013091303280
     * 暂停或单帧状态下设置播放时间,
     * 等待画面跳转到最新的时间点
     */
    if (m_bPaused || m_bStepPlay)
    {
        (void)IVS_PLAY_ResumePlay(m_ulPlayerChannel);

        unsigned long long t1 = (unsigned long long)((m_tmStart + uiTime) * 1000);
        unsigned long long t2 = t1;
        (void)IVS_PLAY_GetCurrentFrameTick(m_ulPlayerChannel, &t2);

        int loop = 100;
        while (t2 == t1 && --loop >= 0)
        {
            VOS_Sleep(20);
            (void)IVS_PLAY_GetCurrentFrameTick(m_ulPlayerChannel, &t2);
        }

        if (m_bPaused)
        {
            (void)RTSP_CLIENT_SendPauseMsg(m_iRtspHandle, m_stMediaRsp.szURL, RTSP_CLIENT_TIMEOUT);
        }
        (void)IVS_PLAY_PausePlay(m_ulPlayerChannel);
    }

    m_uiDragPlayTime = uiTime;
    return IVS_SUCCEED;
}
// 查询设备组列表
IVS_INT32 CDeviceGroupMgr::GetDeviceGroup(const IVS_CHAR* pDomainCode,
                                          const IVS_CHAR* pDevGroupCode,
                                          IVS_DEVICE_GROUP_LIST* pDeviceGroupList,
                                          IVS_UINT32 uiBufferSize)
{
    CHECK_POINTER(m_pUserMgr, IVS_OPERATE_MEMORY_ERROR);
    CHECK_POINTER(pDeviceGroupList, IVS_OPERATE_MEMORY_ERROR);
	IVS_DEBUG_TRACE("");

    // 校验内存
	IVS_INT32 iRet = IVS_FAIL;
	IVS_UINT32 uiSize = 0;
	for (IVS_INT32 i = 0; i != 2; i++)//0是本域,1是外部域
	{
		CXml xmlReq;
		(IVS_VOID)CDeviceMgrXMLProcess::GetDeviceGroupXML(i, pDomainCode, pDevGroupCode, xmlReq);

            IVS_UINT32 xmlLen = 0;
	    const IVS_CHAR* pReq = xmlReq.GetXMLStream(xmlLen);
	    CHECK_POINTER(pReq, IVS_OPERATE_MEMORY_ERROR);
           BP_RUN_LOG_INF("Get CommSendMgr", "send XML = %s", pReq);

	     // 构造带域的请求消息,并发送
	    CSendNssMsgInfo sendNssMsgInfo;
	    sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML);
	    sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS);
	    sendNssMsgInfo.SetReqID(NSS_GET_DEV_GROUP_LIST_REQ);
	    sendNssMsgInfo.SetReqData(pReq);	
	    sendNssMsgInfo.SetDomainCode(pDomainCode);
	    std::string strpRsp;
	    IVS_INT32 iNeedRedirect = IVS_FAIL;
	    iRet = m_pUserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect);
           if (IVS_SUCCEED != iRet && 0 == i)
           {
                BP_RUN_LOG_ERR(iRet, "Get DeviceGroup fail", "SendCmd fail");
                return iRet;
           }           

           CXml xmlRsp;
           if (iRet == IVS_SUCCEED)
           {
                iRet = IVS_XML_INVALID;
                if (xmlRsp.Parse(strpRsp.c_str()))
                {
                    iRet = IVS_SUCCEED;
                }
           }

           if (IVS_SUCCEED != iRet && 0 == i)
           {
                return iRet;
           }
           
           IVS_INT32 iReTurn = iRet;
	    iRet = IVS_SUCCEED;
	    if (IVS_SUCCEED == iReTurn)
           {                   
                iRet = CDeviceMgrXMLProcess::GetDeviceGroupParseXML(uiSize, pDeviceGroupList, uiBufferSize, xmlRsp); 
           }
	}
	pDeviceGroupList->uiTotal = uiSize;

    return iRet;
}
// 查询摄像机计划设置信息
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;
}
//添加平台录像计划;
IVS_INT32 CRecordPlanMgr::AddRecordPlan(IVS_UINT32 uiDeviceNum,const IVS_DEVICE_CODE* pDeviceList,
	const IVS_RECORD_PLAN* pRecordPlan,IVS_RESULT_LIST* pResultList,IVS_UINT32 uiResultBufferSize)const
{
	CHECK_POINTER(pDeviceList, IVS_PARA_INVALID);
	CHECK_POINTER(pRecordPlan, IVS_PARA_INVALID);
	CHECK_POINTER(pResultList, IVS_PARA_INVALID);
	CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR);
	IVS_DEBUG_TRACE("");

	IVS_UINT32 uiReqBufSize = sizeof(IVS_RESULT_LIST) + (uiDeviceNum-1)*sizeof(IVS_RESULT_INFO);
	if (uiReqBufSize > uiResultBufferSize)
	{
		BP_RUN_LOG_ERR(IVS_PARA_INVALID, "Add Record Plan", "Invalid DeviceNum or BufferSize");
		return IVS_PARA_INVALID;
	}

	if ((RECORD_PLAN_ALLDAY < pRecordPlan->uiRecordPlanType) ||
		(PLAN_WEEK == pRecordPlan->uiRecordPlanType && 7 < pRecordPlan->uiPlanInfoNum) ||
		(PLAN_DAY == pRecordPlan->uiRecordPlanType && 1 != pRecordPlan->uiPlanInfoNum) ||
		(PLAN_ALLDAY == pRecordPlan->uiRecordPlanType && 0 != pRecordPlan->uiPlanInfoNum))
	{
		pResultList->uiNum = uiDeviceNum;
		for (IVS_UINT32 i=0; i<pResultList->uiNum; i++)
		{
			pResultList->stInfo[i].uiSequence = i;
			pResultList->stInfo[i].iResult = IVS_PARA_INVALID;
			strncpy(pResultList->stInfo[i].cCode, pDeviceList[i].cDevCode, IVS_DEV_CODE_LEN);
		}
		BP_RUN_LOG_ERR(IVS_PARA_INVALID, "Add Record Plan", "Invalid PlanType or PlanInfoNum");
		return IVS_PARA_INVALID;
	}

	DeviceCodeMap deviceCodeMap;
	std::string strSendDomainCode;
	CmdMap cmdMap;
	CCmd *pCmd = NULL;
	IVS_INT32 iRet = m_UserMgr->RecollectCameraDomainCodes2Map(uiDeviceNum,pDeviceList,deviceCodeMap);

	DeviceCodeMapIterator deviceCodeMapIter = deviceCodeMap.begin();
	DeviceCodeMapIterator deviceCodeMapIterEnd = deviceCodeMap.end();
	for (; deviceCodeMapIter != deviceCodeMapIterEnd; deviceCodeMapIter++)
	{
		DeviceCodeList devList = static_cast<DeviceCodeList>(deviceCodeMapIter->second); //lint !e612 !e69
		strSendDomainCode = deviceCodeMapIter->first;//lint !e612

		//数据结构拼装XML并转换为const IVS_CHAR *
		CXml addRecordPlanXmlReq;
		iRet = CRecordXMLProcess::AddOrModRecordPlanGetXML(strSendDomainCode,devList, pRecordPlan, addRecordPlanXmlReq);
		if (IVS_SUCCEED != iRet)
		{
			pResultList->uiNum = uiDeviceNum;
			for (IVS_UINT32 i=0; i<pResultList->uiNum; i++)
			{
				pResultList->stInfo[i].uiSequence = i;
				pResultList->stInfo[i].iResult = iRet;
				strncpy(pResultList->stInfo[i].cCode, pDeviceList[i].cDevCode, IVS_DEV_CODE_LEN);
			}
			BP_RUN_LOG_ERR(iRet, "Add Record Plan", "Add Or Mod Record Plan Get XML failed");
			return iRet;
		}
		unsigned int xmlLen = 0;
		const IVS_CHAR* pReqPlan = addRecordPlanXmlReq.GetXMLStream(xmlLen);
		CHECK_POINTER(pReqPlan, IVS_OPERATE_MEMORY_ERROR);
		BP_DBG_LOG("ReqPlan:%s\n", pReqPlan);

		//构建发送nss协议
		CSendNssMsgInfo sendNssMsgInfo;	
		sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML);
		sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS);
		sendNssMsgInfo.SetReqID(NSS_MOD_RECORD_PLAN_REQ);
		sendNssMsgInfo.SetReqData(pReqPlan); 
		sendNssMsgInfo.SetDomainCode(strSendDomainCode.c_str());
		pCmd = m_UserMgr->BuildCmd(sendNssMsgInfo);
		if (NULL == pCmd)
		{
			BP_RUN_LOG_INF("build cmd error","cmd req id=%d, domain code=%s",NSS_MOD_RECORD_PLAN_REQ,strSendDomainCode.c_str());
			continue;
		}
		(void)cmdMap.insert(std::make_pair(pCmd->GetTransID(), pCmd));
	}
	if (cmdMap.empty())
	{
		return IVS_SUCCEED;
	}

	IVS_UINT32 uiTimeOut =  CSDKConfig::instance().GetTimeOutValue();
	std::string strpRsp;
	iRet = CDispatcher::instance().dispatcherSyncMsgOutBatch(cmdMap, uiTimeOut);

	//IVS_UINT32 iSize = deviceCodeMap.size();	
	IVS_INT32 iEachRet = 0;
	IVS_UINT32 iFailCount = 0;
	IVS_UINT32 uiRecordNum = 0;
	CmdMapIterator cmdMapIter = cmdMap.begin();
	for (; cmdMapIter != cmdMap.end(); cmdMapIter++)
	{
		CCmd *pCmdRsp = cmdMapIter->second; //lint !e612
		if(NULL != pCmdRsp)
		{
			IVS_CHAR* pRsp = CNSSOperator::instance().ParseCmd2XML(pCmdRsp,iEachRet);
			if (IVS_SUCCEED != iEachRet)
			{
				iFailCount++;
				iRet = iEachRet;
				BP_RUN_LOG_ERR(iEachRet, "Add Record Plan", "Parse Cmd 2XML failed,rspCode = %d", iEachRet);

				// 解析响应的xml
				CXml xmlRsp;
				if (NULL != pRsp && xmlRsp.Parse(pRsp))
				{
					iEachRet = CRecordXMLProcess::RecordPlanParseRSP(uiDeviceNum,pDeviceList,pResultList,uiResultBufferSize,xmlRsp,uiRecordNum);
				}
			}
		}
	}


	if(iFailCount >0)
	{
		//iRet = IVS_FAIL;
		BP_RUN_LOG_ERR(iRet, "Add Platform Record Plan", "Add Platform Record Plan in some Domains failed.");
		return iRet;
	}

	BP_RUN_LOG_INF("Add Platform Record Plan", "ok", "msg have Parsed");
	return IVS_SUCCEED;
}//lint !e529 
 //删除平台录像计划;
IVS_INT32 CRecordPlanMgr::DeleteRecordPlan(IVS_UINT32 uiDeviceNum,const IVS_DEVICE_CODE* pDeviceList,
	IVS_UINT32 uiRecordMethod,IVS_RESULT_LIST* pResultList,IVS_UINT32 uiResultBufferSize)const
 {
	 CHECK_POINTER(pDeviceList, IVS_PARA_INVALID);
	 CHECK_POINTER(pResultList, IVS_PARA_INVALID);
	 CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR);
	 IVS_DEBUG_TRACE("");
 	
	DeviceCodeMap deviceCodeMap;
	std::string strSendDomainCode;
	CCmd *pCmd = NULL;
	CmdMap cmdMap;
	IVS_INT32 iRet = m_UserMgr->RecollectCameraDomainCodes2Map(uiDeviceNum,pDeviceList,deviceCodeMap);

	DeviceCodeMapIterator deviceCodeMapIter = deviceCodeMap.begin();
	DeviceCodeMapIterator deviceCodeMapIterEnd = deviceCodeMap.end();
	for (; deviceCodeMapIter != deviceCodeMapIterEnd; deviceCodeMapIter++)
	{
		DeviceCodeList devList = static_cast<DeviceCodeList>(deviceCodeMapIter->second); //lint !e612 !e69
		strSendDomainCode = deviceCodeMapIter->first;//lint !e612

		//数据结构拼装XML并转换为const IVS_CHAR *
		CXml delRecordPlanXmlReq;
		iRet = CRecordXMLProcess::DelRecordPlanGetXML(strSendDomainCode,devList, uiRecordMethod, delRecordPlanXmlReq);
		unsigned int xmlLen = 0;
		const IVS_CHAR* pReqPlan = delRecordPlanXmlReq.GetXMLStream(xmlLen);
		CHECK_POINTER(pReqPlan, IVS_OPERATE_MEMORY_ERROR);

		//构建发送nss协议
		CSendNssMsgInfo sendNssMsgInfo;	
		sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML);
		sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS);
		sendNssMsgInfo.SetReqID(NSS_DEL_RECORD_PLAN_REQ);
		sendNssMsgInfo.SetReqData(pReqPlan); 
		sendNssMsgInfo.SetDomainCode(strSendDomainCode.c_str());
		pCmd = m_UserMgr->BuildCmd(sendNssMsgInfo);
		if (NULL == pCmd)
		{
			BP_RUN_LOG_INF("build cmd error","cmd req id=%d, domain code=%s",NSS_DEL_RECORD_PLAN_REQ,strSendDomainCode.c_str());
			continue;
		}
		(void)cmdMap.insert(std::make_pair(pCmd->GetTransID(), pCmd));
	}
	if (cmdMap.empty())
	{
		return IVS_SUCCEED;
	}

	std::string strpRsp;
	IVS_UINT32 uiTimeOut =  CSDKConfig::instance().GetTimeOutValue();
	iRet = CDispatcher::instance().dispatcherSyncMsgOutBatch(cmdMap, uiTimeOut);

	//IVS_UINT32 iSize = deviceCodeMap.size();	
	IVS_INT32 iEachRet = 0;
	IVS_UINT32 iFailCount = 0;
	IVS_UINT32 uiRecordNum = 0;
	CmdMapIterator cmdMapIter;
	for (cmdMapIter = cmdMap.begin(); cmdMapIter != cmdMap.end(); cmdMapIter++)
	{
		CCmd *pCmdRsp = cmdMapIter->second; //lint !e612
		if(NULL != pCmdRsp)
		{
			IVS_CHAR* pRsp = CNSSOperator::instance().ParseCmd2XML(pCmdRsp,iEachRet);
			if (IVS_SUCCEED != iEachRet)
			{
				iFailCount++;
				iRet = iEachRet;
				BP_RUN_LOG_ERR(iEachRet, "Delete Record Plan", "Parse Cmd 2XML failed,rspCode = %d", iEachRet);

				// 解析响应的xml
				CXml xmlRsp;
				if (NULL != pRsp && xmlRsp.Parse(pRsp))
				{
					iEachRet = CRecordXMLProcess::RecordPlanParseRSP(uiDeviceNum,pDeviceList,pResultList,uiResultBufferSize,xmlRsp,uiRecordNum);
				}
			}
		}
	}

	if(iFailCount >0)
	{
		//iRet = IVS_FAIL;
		BP_RUN_LOG_ERR(iRet, "Delete Platform Record Plan", "Delete Platform Record Plan in some Domains failed.");
		return iRet;
	}

	BP_RUN_LOG_INF("Delete Record Plan", "ok", "msg have Parsed");
 	return IVS_SUCCEED;
 }//lint !e529
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 CPlayback::GetPlayBackTime(IVS_PLAYBACK_TIME& stPlayBackTime)
{
    CLockGuard lock(m_pMediaMutex);

    memset(&stPlayBackTime, 0, sizeof(stPlayBackTime));
    //unsigned int uiPlayTime = 0;

    unsigned long long uiPlayTime = 0;

    int iRet = IVS_PLAY_GetCurrentFrameTick(m_ulPlayerChannel, &uiPlayTime);
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet,"Get Play Back Time", "Get play time failed");
        return iRet;
    }

    uiPlayTime = uiPlayTime/1000; // 转换为秒;
    if (m_bLocalFile)
    {
        memset(&stPlayBackTime, 0, sizeof(stPlayBackTime));
        snprintf(stPlayBackTime.cPlayBackTime, sizeof(stPlayBackTime.cPlayBackTime) - 1, "%u", uiPlayTime);
        return IVS_SUCCEED;
    }

    if (0 == uiPlayTime)
    {
        if (m_fSpeed > 0)
        {
            uiPlayTime = m_stTimeSpanInter.iStartTime;//lint !e732
        }
        else
        {
            uiPlayTime = m_stTimeSpanInter.iEndTime;//lint !e732
        }
    }

    std::string strCurPlayTime;
    UTCTime2Str((time_t)uiPlayTime, strCurPlayTime, IVS_DATE_TIME_FORMAT);
    std::string strStartTimeTmp;
    UTCTime2Str((time_t)m_stTimeSpanInter.iStartTime, strStartTimeTmp, IVS_DATE_TIME_FORMAT);
    BP_RUN_LOG_INF("Get Play Back Time ", "Start time = %s %d Current time = %s.", strStartTimeTmp.c_str(), m_stTimeSpanInter.iStartTime, strCurPlayTime.c_str());
    bool bRet = CToolsHelp::Strncpy(stPlayBackTime.cPlayBackTime,IVS_TIME_LEN, strCurPlayTime.c_str(), strCurPlayTime.length());
    if(false == bRet)
    {
        BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get Play Back Time", "Strncpy error.");
        return IVS_ALLOC_MEMORY_ERROR;
    }

    std::string strStartTime;
    UTCTime2Str((time_t)m_stTimeSpanInter.iStartTime, strStartTime, IVS_DATE_TIME_FORMAT);
    bRet = CToolsHelp::Strncpy(stPlayBackTime.cPlayBackStartTime,IVS_TIME_LEN+1, strStartTime.c_str(),strStartTime.length());
    if(false == bRet)
    {
        BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get Play Back Time", "Strncpy error.");
        return IVS_ALLOC_MEMORY_ERROR;
    }

    std::string strEndTime;
    UTCTime2Str((time_t)m_stTimeSpanInter.iEndTime, strEndTime, IVS_DATE_TIME_FORMAT);
    bRet = CToolsHelp::Strncpy(stPlayBackTime.cPlayBackEndTime,IVS_TIME_LEN, strEndTime.c_str(), strEndTime.length());
    if(false == bRet)
    {
        BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get Play Back Time", "Strncpy error.");
        return IVS_ALLOC_MEMORY_ERROR;
    }
    return iRet;
}