예제 #1
0
파일: MediaMgr.cpp 프로젝트: eSDK/esdk_elte
//视频上墙
ELTE_INT32 CMediaMgr::VWallStart(const ELTE_CHAR* pResourceID, const ELTE_CHAR* pVideoParam) const
{
	LOG_TRACE();
	if(NULL == m_pUserMgr)
	{
		LOG_RUN_ERROR("UserMgr is null.");
		return eLTE_SDK_ERR_NULL_POINTER;
	}

	CXml reqXml;
	if(!reqXml.Parse(pVideoParam))
	{
		LOG_RUN_ERROR("ReqXml parse failed, param is %s.", pVideoParam);
		return eLTE_SDK_ERR_XML_PARSE;
	}

	if(!reqXml.FindElem("Content"))
	{
		LOG_RUN_ERROR("Find 'Content' failed, reqXml is %s.", pVideoParam);
		return eLTE_SDK_ERR_XML_FIND_ELEM;
	}

	(void)reqXml.IntoElem();
	(void)reqXml.AddElemBeforeCurNode("ResourceID");
	(void)reqXml.SetElemValue(pResourceID);

	ELTE_UINT32 xmlLen = 0;
	LOG_RUN_INFO("ReqXml is %s.", reqXml.GetXMLStream(xmlLen));

	//发送消息
	SSL_Socket& socket = const_cast<SSL_Socket&>(m_pUserMgr->GetSSLSocket());
	MutexLocker Locker(m_pUserMgr->GetMutexHandle());
	ELTE_INT32 iRet = socket.SendMsg(ELTE_SERVICE_VWALLSTART_REQ, reqXml, TRUE);
	if(eLTE_SDK_ERR_SUCCESS != iRet) 
	{
		return iRet;
	}

	iRet = m_pUserMgr->WaitObject(WAIT_OBJECT_TIME);
	if (eLTE_SDK_ERR_SUCCESS != iRet)
	{
		CServerMgr& serverMgr = const_cast<CServerMgr&>(m_pUserMgr->GetServerMgr());
		if(!serverMgr.ServerIsRunning() || 0 != m_pUserMgr->GetServerStatus())
		{
			m_pUserMgr->SetServerStatus(0);
			return eLTE_SDK_ERR_SERVER_NOT_RUNNING;
		}
		return iRet;
	}

	const PACKET_DATA& packetData = m_pUserMgr->GetPacketData();
	iRet = packetData.RspCode;
	::ResetEvent(m_pUserMgr->GetEventHandle());

	if (eLTE_SDK_ERR_SUCCESS != iRet)
	{
		LOG_RUN_ERROR("GetPacketData failed.");
	}
	return iRet;
}
 // 实现外域发送消息公共方法(支持重定向)
 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;
 }
예제 #3
0
HRESULT CHandler::Open2(IInStream *stream)
{
  UInt64 archiveStartPos;
  RINOK(stream->Seek(0, STREAM_SEEK_SET, &archiveStartPos));

  const UInt32 kHeaderSize = 0x1C;
  Byte buf[kHeaderSize];
  RINOK(ReadStream_FALSE(stream, buf, kHeaderSize));

  UInt32 size = Get16(buf + 4);
  // UInt32 ver = Get16(buf + 6); // == 0
  if (Get32(buf) != 0x78617221 || size != kHeaderSize)
    return S_FALSE;

  UInt64 packSize = Get64(buf + 8);
  UInt64 unpackSize = Get64(buf + 0x10);
  // UInt32 checkSumAlogo = Get32(buf + 0x18);

  if (unpackSize >= kXmlSizeMax)
    return S_FALSE;

  _dataStartPos = archiveStartPos + kHeaderSize + packSize;

  char *ss = _xml.GetBuffer((int)unpackSize + 1);

  NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
  CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;

  CLimitedSequentialInStream *inStreamLimSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStreamLim(inStreamLimSpec);
  inStreamLimSpec->SetStream(stream);
  inStreamLimSpec->Init(packSize);

  CBufPtrSeqOutStream *outStreamLimSpec = new CBufPtrSeqOutStream;
  CMyComPtr<ISequentialOutStream> outStreamLim(outStreamLimSpec);
  outStreamLimSpec->Init((Byte *)ss, (size_t)unpackSize);

  RINOK(zlibCoder->Code(inStreamLim, outStreamLim, NULL, NULL, NULL));

  if (outStreamLimSpec->GetPos() != (size_t)unpackSize)
    return S_FALSE;

  ss[(size_t)unpackSize] = 0;
  _xml.ReleaseBuffer();

  CXml xml;
  if (!xml.Parse(_xml))
    return S_FALSE;

  if (!xml.Root.IsTagged("xar") || xml.Root.SubItems.Size() != 1)
    return S_FALSE;
  const CXmlItem &toc = xml.Root.SubItems[0];
  if (!toc.IsTagged("toc"))
    return S_FALSE;
  if (!AddItem(toc, _files, -1))
    return S_FALSE;
  return S_OK;
}
예제 #4
0
파일: MediaMgr.cpp 프로젝트: eSDK/esdk_elte
ELTE_INT32 CMediaMgr::GetUserRECFileInfoList(const ELTE_CHAR* pQueryXml, ELTE_CHAR** pRspXml) const
{
	LOG_TRACE();
	if(NULL == m_pUserMgr)
	{
		LOG_RUN_ERROR("UserMgr is null.");
		return eLTE_SDK_ERR_NULL_POINTER;
	}
	CXml reqXml;
	if(!reqXml.Parse(pQueryXml))
	{
		LOG_RUN_ERROR("ReqXml parse failed, param is %s.", pQueryXml);
		return eLTE_SDK_ERR_XML_PARSE;
	}

	//发送消息
	SSL_Socket& socket = const_cast<SSL_Socket&>(m_pUserMgr->GetSSLSocket());
	MutexLocker Locker(m_pUserMgr->GetMutexHandle());
	ELTE_INT32 iRet = socket.SendMsg(ELTE_SERVICE_GETUSERRECFILEINFOLIST_REQ, reqXml, TRUE);
	if(eLTE_SDK_ERR_SUCCESS != iRet) 
	{
		return iRet;
	}
	iRet = m_pUserMgr->WaitObject(WAIT_OBJECT_TIME);
	if (eLTE_SDK_ERR_SUCCESS != iRet)
	{
		CServerMgr& serverMgr = const_cast<CServerMgr&>(m_pUserMgr->GetServerMgr());
		if(!serverMgr.ServerIsRunning() || 0 != m_pUserMgr->GetServerStatus())
		{
			m_pUserMgr->SetServerStatus(0);
			return eLTE_SDK_ERR_SERVER_NOT_RUNNING;
		}
		return iRet;
	}
	const PACKET_DATA& packetData = m_pUserMgr->GetPacketData();
	iRet = packetData.RspCode;
	ELTE_UINT32 uiDataLen = packetData.PacketLength - PACKET_HEAD_SIZE;
	if(uiDataLen > 0)
	{
		*pRspXml = new ELTE_CHAR[uiDataLen + 1];
		if(NULL == *pRspXml)
		{
			LOG_RUN_ERROR("New RspXml failed.");
			::ResetEvent(m_pUserMgr->GetEventHandle());
			return eLTE_SDK_ERR_CREATE_OBJECT;
		}
		eSDK_MEMSET(*pRspXml, 0x00, uiDataLen + 1);
		eSDK_MEMCPY(*pRspXml, uiDataLen + 1, packetData.Value, uiDataLen);
	}
	else
	{
		*pRspXml = NULL;
	}
	::ResetEvent(m_pUserMgr->GetEventHandle());
	return iRet;
}
예제 #5
0
// 增加角色
IVS_INT32 CRoleMgr::AddRole(const IVS_ROLE_INFO* pRoleInfo, IVS_UINT32* puiRoleID)
{
    //空校验
    CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR);
    CHECK_POINTER(pRoleInfo, IVS_PARA_INVALID);

    IVS_DEBUG_TRACE("");

    IVS_INT32 iRet = IVS_FAIL;
    CXml xmlReq;
    std::string strDomainCode;
    // 防止域编码达到临界值无结束符“\0” modify by xiongfeng
    char cDomainCodeTmp[IVS_DOMAIN_CODE_LEN + 1] = {0};
    (void)CToolsHelp::Memcpy(cDomainCodeTmp, IVS_DOMAIN_CODE_LEN, pRoleInfo->cDomainCode, IVS_DOMAIN_CODE_LEN);
    strDomainCode = cDomainCodeTmp;
    if (strDomainCode.empty())
    {
        m_UserMgr->GetDomainCode(strDomainCode);
    }

    CUserInfoMgrXMLProcess::GetRoleXML(strDomainCode.c_str(), pRoleInfo, 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_ADD_ROLE_REQ);
    sendNssMsgInfo.SetReqData(pReq);
    sendNssMsgInfo.SetDomainCode(strDomainCode);
    //发送请求
    std::string strRsp;
    IVS_INT32 iNeedRedirect = IVS_FAIL;
    iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strRsp,iNeedRedirect);
    if(IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet, "Add Role","SendCmd to SMU Return Failed");
        return  iRet;
    }

    //CHECK_POINTER(strRsp.c_str(), IVS_OPERATE_MEMORY_ERROR);
    CXml xmlRsp;
    if(!xmlRsp.Parse(strRsp.c_str()))
    {
        BP_RUN_LOG_ERR(IVS_XML_INVALID, "Add Role", "xml parsing error");

        return IVS_XML_INVALID;
    }
    iRet = CUserInfoMgrXMLProcess::AddRoleParseXML(xmlRsp, puiRoleID);

    return iRet;
}
예제 #6
0
// 查询角色列表
IVS_INT32 CRoleMgr::GetRoleList(const IVS_CHAR* pDomainCode, const IVS_INDEX_RANGE* pIndexRange, IVS_ROLE_INFO_LIST* pRoleInfoList, IVS_UINT32 /*uiBufferSize*/)
{
    CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR);
    CHECK_POINTER(pIndexRange, IVS_PARA_INVALID);
    CHECK_POINTER(pRoleInfoList, IVS_PARA_INVALID);
    IVS_DEBUG_TRACE("");

    std::string strDomainCode;
    if ( NULL == pDomainCode || '\0' == pDomainCode[0])
    {
        m_UserMgr->GetDomainCode(strDomainCode);
    }
    else
    {
        strDomainCode = pDomainCode;
    }

    //构造请求xml
    IVS_INT32 iRet = IVS_FAIL;
    CXml xmlReq;
    CUserInfoMgrXMLProcess::CommDomainCodeXml(strDomainCode.c_str(), xmlReq);
    unsigned int 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_ROLE_LIST_REQ);
    sendNssMsgInfo.SetReqData(pReq);
    sendNssMsgInfo.SetDomainCode(strDomainCode);
    std::string strpRsp;
    IVS_INT32 iNeedRedirect = IVS_FAIL;
    iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect);
    if(IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet, "Get Main DeviceList fail","SendCmd to SMU Return Failed");
        return  iRet;
    }

    //CHECK_POINTER(strpRsp.c_str(), IVS_XML_INVALID);
    CXml xmlRsp;
    if(!xmlRsp.Parse(strpRsp.c_str()))
    {
        BP_RUN_LOG_ERR(IVS_XML_INVALID, "Get Role List", "xml parsing error");
        return IVS_XML_INVALID;
    }
    iRet = CUserInfoMgrXMLProcess::GetRoleListParseXML(xmlRsp, pRoleInfoList);

    return iRet;
}
예제 #7
0
// 根据用户ID获取角色详细信息
IVS_INT32 CRoleMgr::GetRoleInfoByUserID(const IVS_CHAR* pDomainCode, IVS_UINT32 uiUserID, IVS_ROLE_INFO* pRoleInfo)
{
    CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR);
    CHECK_POINTER(pRoleInfo, IVS_PARA_INVALID);
    IVS_DEBUG_TRACE("");

    std::string sDomainCode;
    if(NULL == pDomainCode)
    {
        m_UserMgr->GetDomainCode(sDomainCode);
    }
    else
    {
        sDomainCode = pDomainCode;
    }

    IVS_INT32 iRet = IVS_FAIL;
    CXml xmlReq;
    CUserInfoMgrXMLProcess::GetUserInfoGetXML(sDomainCode.c_str(), uiUserID, xmlReq);
    unsigned int 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_USER_ROLE_REQ);
    sendNssMsgInfo.SetReqData(pReq);
    sendNssMsgInfo.SetDomainCode(sDomainCode);
    std::string strpRsp;
    IVS_INT32 iNeedRedirect = IVS_FAIL;
    iRet = m_UserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect);
    if(IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet, "Get Role Info By UserID","SendCmd to SMU Return Failed");
        return  iRet;
    }

    //CHECK_POINTER(strpRsp.c_str(), IVS_OPERATE_MEMORY_ERROR);

    CXml xmlRsp;
    if(!xmlRsp.Parse(strpRsp.c_str()))
    {
        BP_RUN_LOG_ERR(IVS_XML_INVALID, "Get RoleInfo By UserID", "xml parsing error");
        return IVS_XML_INVALID;
    }
    iRet = CUserInfoMgrXMLProcess::GetRoleInfoParseXML(xmlRsp, pRoleInfo); 

    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::OnUserOffLineNotify(CCmd* pCmd)const
{
    // 从cmd中获取xml
    CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR);

    IVS_INT32 iRet = IVS_FAIL;
    IVS_CHAR *pszInfo = CNSSOperator::instance().ParseCmd2XML(pCmd, iRet);
    CHECK_POINTER(pszInfo, IVS_OPERATE_MEMORY_ERROR);

    IVS_USER_OFFLINE_INFO pstUserOffline;
    memset(&pstUserOffline, 0, sizeof(IVS_USER_OFFLINE_INFO));

    IVS_CHAR cLoginID[LOGIN_ID_LEN + 1];
    memset(cLoginID, 0, LOGIN_ID_LEN+1);

    if (IVS_SUCCEED == iRet)
    {
        CXml xmlRsp;
        if (!xmlRsp.Parse(pszInfo))
        {
            BP_RUN_LOG_ERR(IVS_XML_INVALID, "UserOffLine Notify", "xml parsing error");
			HW_DELETE_A(pszInfo);
            return IVS_XML_INVALID;
        }
        iRet = CLoginXMLProcess::ParseUserOffLineXML(xmlRsp, cLoginID, &pstUserOffline);
    }
    if (IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(IVS_XML_INVALID, "UserOffLine Notify", "xml parsing error");
		HW_DELETE_A(pszInfo);
        return IVS_XML_INVALID;
    }
    //根据loginID获取sessionID
    //IVS_INT32 iSessionID = g_pNvs->GetSessionIDByLoginID(cLoginID);
    IVS_INT32 iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID()); //lint !e1013 !e64
    if (SDK_SESSIONID_INIT == iSessionID)
    {
        BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "UserOffLine Notify", "iSessionID is -1");
		HW_DELETE_A(pszInfo);
        return IVS_SDK_RET_INVALID_SESSION_ID;
    }
    pstUserOffline.iSessionID = iSessionID;
    (void)CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_USER_OFFLINE, &pstUserOffline, sizeof(pstUserOffline));
    HW_DELETE_A(pszInfo);
    
    //清理资源
    (void)g_pNvs->Logout(iSessionID, false);

    return IVS_SUCCEED;
}
예제 #10
0
// 获取用户权限信息
IVS_INT32 CRoleMgr::GetOperationRightGroup(const IVS_CHAR* pDomainCode, IVS_OPERATION_RIGHT_GROUP_LIST* pRightGroupList)
{
    CHECK_POINTER(m_UserMgr, IVS_OPERATE_MEMORY_ERROR);
    IVS_DEBUG_TRACE("");

    std::string strDomainCode;
    if(NULL == pDomainCode || '\0' == pDomainCode[0])
    {
        m_UserMgr->GetDomainCode(strDomainCode);
    }
    else
    {
        strDomainCode = pDomainCode;
    }

    IVS_INT32 iRet = IVS_FAIL;
    CXml xmlReq;
    CUserInfoMgrXMLProcess::CommDomainCodeXml(strDomainCode.c_str(), xmlReq);
    unsigned int 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_ALL_OP_REQ);
    sendNssMsgInfo.SetReqData(pReq);
    sendNssMsgInfo.SetDomainCode(strDomainCode);
    std::string sRsp;
    IVS_INT32 iNeedRedirect = IVS_FAIL;
    iRet = m_UserMgr->SendCmd(sendNssMsgInfo,sRsp,iNeedRedirect);
    if(IVS_SUCCEED != iRet)
    {
        BP_RUN_LOG_ERR(iRet, "Get Operation Right Group","SendCmd to SMU Return Failed");
        return  iRet;
    }

    //CHECK_POINTER(sRsp.c_str(), IVS_OPERATE_MEMORY_ERROR);

    CXml xmlRsp;
    if(!xmlRsp.Parse(sRsp.c_str()))
    {
        BP_RUN_LOG_ERR(IVS_XML_INVALID, "Get Operation Right Group", "xml parsing error");
        return IVS_XML_INVALID;
    }
    iRet = CUserInfoMgrXMLProcess::GetOperationRightGroupParseXML(xmlRsp, pRightGroupList); 

    return iRet;
}
예제 #11
0
 //获取平台录像计划;
 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
예제 #12
0
// 解析入参Mute_UL_parameter
eLTE_RET XMLProcess::XmlParseMuteULParameter(const std::string& xmlStr,	// 入参
		std::string& strCallType)			// 出参
{
	/************************************************************************
	--- XML 格式 ---
	<Content>
		<MuteParam>
			<CallType>"0"点呼,"1"组呼,"2"视频回传</CallType>
		</MuteParam>
	</Content>
	************************************************************************/ 
	
	LOG_TRACE();
	INFO_PARAM1(xmlStr);

	CXml xmlParse;
	if (!xmlParse.Parse(xmlStr.c_str()))
	{
		LOG_RUN_ERROR("parse xml failed.");
		return eLTE_ERR_FAILED;
	}
	if (!xmlParse.FindElem("Content"))
	{
		LOG_RUN_ERROR("FindElem Content failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();
	if (!xmlParse.FindElem("MuteParam"))
	{
		LOG_RUN_ERROR("FindElem MuteParam failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();

	const unsigned int XML_VAR_LENGTH = 20;
	char elemValue[XML_VAR_LENGTH] = {0};
	const char* srcValue;
	unsigned int uiMaxLen = XML_VAR_LENGTH;

	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);	
	GET_XML_ELEM_VALUE_CHAR(xmlParse, "CallType", srcValue, elemValue, uiMaxLen);
	strCallType = elemValue;

	return eLTE_ERR_SUCCESS;
}
예제 #13
0
//目录共享
IVS_INT32 CDomainRouteMgr::SetShareCatalog(const IVS_CHAR* pShareInfo)
{
	if (NULL == pShareInfo)
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "Share Cata log", "Cmd is NULL");
		return IVS_FAIL;
	}
	std::string strShareCatalog(pShareInfo);
	std::string strSendCmd;

	CXml xml;
	if (!xml.Parse(pShareInfo))
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID, "xml.Parse(pShareInfo) fail", "NA");
		return IVS_XML_INVALID;
	}
	//if (!xml.FindElemEx("Content/ExDomainInfo/ExDomainCode"))
	//{
	//	BP_RUN_LOG_ERR(IVS_XML_INVALID, "xml.FindElemEx(Content/ExDomainInfo) fail", "NA");
	//	return IVS_XML_INVALID;
	//}
	//const IVS_CHAR* pExDomainCode = xml.GetElemValue();

	IVS_INT32 iRet = SplitDevDomainCode(strShareCatalog,strSendCmd);
	if (IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_ERR(IVS_FAIL, "Share Cata log", "XML illegal ");
		return iRet;
	}

	// 构造带域的请求消息,并发送
	CSendNssMsgInfo sendNssMsgInfo;
	sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML);
	sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS);
	sendNssMsgInfo.SetReqID(NSS_SHARE_CATALOG_REQ);
	sendNssMsgInfo.SetReqData(strSendCmd.c_str());	
	std::string strpRsp;
	IVS_INT32 iNeedRedirect = IVS_FAIL;
	iRet = m_pUserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect);

	return iRet;
}//lint !e1762
예제 #14
0
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;
}
// add by zwx211831, Date:20140605 处理客户端关闭视频业务通知
int CSDKMainctrl::OnShutdownStreamNotify(CCmd* pCmd) const
{
	CHECK_POINTER(pCmd, IVS_OPERATE_MEMORY_ERROR);

	IVS_INT32 iRet = IVS_FAIL;
	IVS_CHAR *pInfo = CNSSOperator::instance().ParseCmd2XML(pCmd, iRet);
	CHECK_POINTER(pInfo, IVS_OPERATE_MEMORY_ERROR);

	IVS_SHUTDOWN_NOTIFY_INFO stShutdownNotifyInfo = {0};
	if (IVS_SUCCEED == iRet)
	{
		CXml xmlRsp;
		if (!xmlRsp.Parse(pInfo))
		{
			BP_RUN_LOG_ERR(IVS_XML_INVALID, "OnShutdownStreamNotify", "XML parse failed");
			HW_DELETE_A(pInfo);
			return IVS_XML_INVALID;
		}
		iRet = CRealXMLProcess::ParseShutdownNotifyXML(xmlRsp, &stShutdownNotifyInfo);
	}
	if (IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID, "OnShutdownStreamNotify", "XML parse failed");
		HW_DELETE_A(pInfo);
		return IVS_XML_INVALID;
	}

	IVS_INT32 iSessionID = CLinkRouteMgr::instance().FindSessionIDByLinkID(pCmd->GetNetLinkID());
	if (SDK_SESSIONID_INIT == iSessionID)
	{
		BP_RUN_LOG_ERR(IVS_SDK_RET_INVALID_SESSION_ID, "OnShutdownStreamNotify", "iSessionID is -1");
		HW_DELETE_A(pInfo);
		return IVS_SDK_RET_INVALID_SESSION_ID;
	}
	(void)CEventCallBackJob::instance().PostEvent(iSessionID, IVS_EVENT_SHUTDOWN_STREAM, &stShutdownNotifyInfo, sizeof(stShutdownNotifyInfo));
	HW_DELETE_A(pInfo);

	return IVS_SUCCEED;
}
// 解析本地抓拍参数客户端配置xml
IVS_INT32 OCXCapturePictureXMLProcess::LocalCaptureParseClientConfig(LPCTSTR pXmlStr, IVS_LOCAL_CAPTURE_PARAM &LocalCaptuParam)
{
	IVS_DEBUG_TRACE("Local Capture Config %s", pXmlStr);
	(void)CToolsHelp::Strncpy(LocalCaptuParam.cCapturePath, sizeof(LocalCaptuParam.cCapturePath) - 1, CAPTURE_DEFAULT_PATH, sizeof(CAPTURE_DEFAULT_PATH));  
	LocalCaptuParam.uiSnapshotMode = CAPTURE_DEFAULT_MODE;
	LocalCaptuParam.uiSnapshotCount = CAPTURE_DEFAULT_COUNT;			
	LocalCaptuParam.uiSnapshotInterval = CAPTURE_DEFAULT_INTERVAL;		
	LocalCaptuParam.uiSnapshotFormat = CAPTURE_DEFAULT_FORMAT;		
	LocalCaptuParam.uiNameRule = CAPTURE_DEFAULT_NAME_RULE;		
	if (NULL == pXmlStr || '\0' == pXmlStr[0])
	{
		return IVS_PARA_INVALID;
	}

	CXml xml;
	if (!xml.Parse(pXmlStr))
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID, "Local Capture Parse Client Config", "parse xml error, use default");
		return IVS_FAIL;
	}

	if (!xml.FindElemEx("CaptureConfig"))
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID,"Local Capture Parse Client Config fail", "no 'CaptureConfig' elemenet");
		return IVS_XML_INVALID;
	}
	xml.IntoElem();

	const char *value = NULL;
	bool  bSuccess = true;
	bool  bRet = false;

	bSuccess = (xml.FindElem("CapturePath")) && (NULL != (value = xml.GetElemValue()));
	if (bSuccess)
	{
		bRet = CToolsHelp::Strncpy(LocalCaptuParam.cCapturePath, sizeof(LocalCaptuParam.cCapturePath) - 1, value, strlen(value));  
	} else {
		bRet = CToolsHelp::Strncpy(LocalCaptuParam.cCapturePath, sizeof(LocalCaptuParam.cCapturePath) - 1, CAPTURE_DEFAULT_PATH, sizeof(CAPTURE_DEFAULT_PATH));
	}
	if(false == bRet)
	{
		BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Local Capture Parse Client Config", "Strncpy error.");
		return IVS_ALLOC_MEMORY_ERROR;
	}

	bSuccess = (xml.FindElem("SnapshotMode")) && (NULL != (value = xml.GetElemValue()));
	LocalCaptuParam.uiSnapshotMode = bSuccess ? atoi(value) : CAPTURE_DEFAULT_MODE;

	bSuccess = (xml.FindElem("SnapshotCount")) &&(NULL != (value = xml.GetElemValue()));
	LocalCaptuParam.uiSnapshotCount = bSuccess ? (IVS_UINT32)atoi(value) : CAPTURE_DEFAULT_COUNT;

	bSuccess = (xml.FindElem("SnapshotInterval")) &&(NULL != (value = xml.GetElemValue()));
	LocalCaptuParam.uiSnapshotInterval = bSuccess ? (IVS_UINT32)atoi(value) : CAPTURE_DEFAULT_INTERVAL;
	
	bSuccess = (xml.FindElem("SnapshotFormat")) &&(NULL != (value = xml.GetElemValue()));
	LocalCaptuParam.uiSnapshotFormat = bSuccess ? atoi(value) : CAPTURE_DEFAULT_FORMAT;
	
	bSuccess = (xml.FindElem("NameRule")) && (NULL != (value = xml.GetElemValue()));
	LocalCaptuParam.uiNameRule = bSuccess ? atoi(value) : CAPTURE_DEFAULT_NAME_RULE;

	return IVS_SUCCEED;
}
예제 #17
0
// 解析入参Video_UL_parameter
eLTE_RET XMLProcess::XmlParseVideoULParameter(const std::string& xmlStr,	// 入参
		std::string& strVideoFormat, std::string& strCameraType,			// 出参
		std::string& strUserConfirmType, std::string& strMuteType)			// 出参
{
	/************************************************************************
	--- XML 格式 ---
	<Content>
		<VideoParam>
			<VideoFormat>D1、CIF、QCIF、720P或1080P</VideoFormat>
			<CameraType>“0”表示前置,“1”表示后置。</CameraType>
			<UserConfirmType>“0”表示不需要用户确认,“1”表示需要用户确认。</UserConfirmType>
			<MuteType>“0”表示需要伴音;“1”表示不需要伴音</MuteType>
		</VideoParam>
	</Content>
	************************************************************************/ 
	
	LOG_TRACE();
	INFO_PARAM1(xmlStr);

	CXml xmlParse;
	if (!xmlParse.Parse(xmlStr.c_str()))
	{
		LOG_RUN_ERROR("parse xml failed.");
		return eLTE_ERR_FAILED;
	}
	if (!xmlParse.FindElem("Content"))
	{
		LOG_RUN_ERROR("FindElem Content failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();
	if (!xmlParse.FindElem("VideoParam"))
	{
		LOG_RUN_ERROR("FindElem VideoParam failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();

	const unsigned int XML_VAR_LENGTH = 20;
	char elemValue[XML_VAR_LENGTH] = {0};
	const char* srcValue;
	unsigned int uiMaxLen = XML_VAR_LENGTH;

	GET_XML_ELEM_VALUE_CHAR(xmlParse, "VideoFormat", srcValue, elemValue, uiMaxLen);
	strVideoFormat = elemValue;

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);	
	GET_XML_ELEM_VALUE_CHAR(xmlParse, "CameraType", srcValue, elemValue, uiMaxLen);
	strCameraType = elemValue;

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);	
	GET_XML_ELEM_VALUE_CHAR(xmlParse, "UserConfirmType", srcValue, elemValue, uiMaxLen);
	strUserConfirmType = elemValue;

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);
	GET_XML_ELEM_VALUE_CHAR(xmlParse, "MuteType", srcValue, elemValue, uiMaxLen);
	strMuteType = elemValue;

	return eLTE_ERR_SUCCESS;
}
예제 #18
0
eLTE_RET XMLProcess::ParseXmlStringEventNotifyP2pvideocallStatus(NotifyP2pvideocallStatusInfo& pInfo, const std::string& strXml)
{
	LOG_TRACE();
	INFO_PARAM1(strXml);

	CXml xmlParse;
	if (!xmlParse.Parse(strXml.c_str()))
	{
		LOG_RUN_ERROR("parse xml failed.");
		return eLTE_ERR_FAILED;
	}
	if (!xmlParse.FindElem("Content"))
	{
		LOG_RUN_ERROR("FindElem Content failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();
	if (!xmlParse.FindElem("CallStatus"))
	{
		LOG_RUN_ERROR("FindElem CallStatus failed.");
		return eLTE_ERR_FAILED;
	}
	pInfo.iCallStatus = eLTE_Tool::String2Int(xmlParse.GetElemValue());

	if (!xmlParse.FindElem("Callee"))
	{
		LOG_RUN_ERROR("FindElem Callee failed.");
		return eLTE_ERR_FAILED;
	}
	pInfo.iCallee = eLTE_Tool::String2Int(xmlParse.GetElemValue());

	if (!xmlParse.FindElem("Caller"))
	{
		LOG_RUN_ERROR("FindElem Caller failed.");
		return eLTE_ERR_FAILED;
	}
	pInfo.iCaller = eLTE_Tool::String2Int(xmlParse.GetElemValue());

	if (!xmlParse.FindElem("LocalAudioPort"))
	{
		LOG_RUN_ERROR("FindElem LocalAudioPort failed.");
		return eLTE_ERR_FAILED;
	}
	pInfo.iLocalAudioPort = eLTE_Tool::String2Int(xmlParse.GetElemValue());

	if (!xmlParse.FindElem("LocalVideoPort"))
	{
		LOG_RUN_ERROR("FindElem LocalVideoPort failed.");
		return eLTE_ERR_FAILED;
	}
	pInfo.iLocalVideoPort = eLTE_Tool::String2Int(xmlParse.GetElemValue());

	if (!xmlParse.FindElem("RemoteAudioPort"))
	{
		LOG_RUN_ERROR("FindElem RemoteAudioPort failed.");
		return eLTE_ERR_FAILED;
	}
	pInfo.iRemoteAudioPort = eLTE_Tool::String2Int(xmlParse.GetElemValue());

	if (!xmlParse.FindElem("RemoteVideoPort"))
	{
		LOG_RUN_ERROR("FindElem RemoteVideoPort failed.");
		return eLTE_ERR_FAILED;
	}
	pInfo.iRemoteVideoPort = eLTE_Tool::String2Int(xmlParse.GetElemValue());

	return eLTE_ERR_SUCCESS;
}
예제 #19
0
eLTE_RET XMLProcess::XmlParseGISSubscribeParameter(const std::string& xmlStr,     // 入参
	std::string& strSubType, std::string& strResourceList, std::string& strSubscriber)   // 出参
{
	/************************************************************************
	--- XML 格式 ---
	<Content>
		<GISParam>
			<SubType>7/8</SubType>
			<ResourceList>多个资源ID用分号分隔,最多200。例如1001;1002;1003</ResourceList>
			<Subscriber>目前可不填</Subscriber>
		</GISParam>
	</Content>
	************************************************************************/ 
	
	LOG_TRACE();
	INFO_PARAM1(xmlStr);

	CXml xmlParse;
	if (!xmlParse.Parse(xmlStr.c_str()))
	{
		LOG_RUN_ERROR("parse xml failed.");
		return eLTE_ERR_FAILED;
	}
	if (!xmlParse.FindElem("Content"))
	{
		LOG_RUN_ERROR("FindElem Content failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();
	if (!xmlParse.FindElem("GISParam"))
	{
		LOG_RUN_ERROR("FindElem GISParam failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();

	const unsigned int XML_VAR_LENGTH = 20;
	char elemValue[XML_VAR_LENGTH] = {0};
	const char* srcValue;
	unsigned int uiMaxLen = XML_VAR_LENGTH;

	GET_XML_ELEM_VALUE_CHAR(xmlParse, "SubType", srcValue, elemValue, uiMaxLen);
	strSubType = elemValue;

	if (!xmlParse.FindElem("ResourceList"))													
	{																			
		LOG_RUN_ERROR("FindElem ResourceList failed.");								
		return eLTE_ERR_XML_FIND_ELEM;											
	}																			
	srcValue = xmlParse.GetElemValue();												
	if (NULL == srcValue)														
	{																			
		LOG_RUN_ERROR("GetElemValue ResourceList failed.");							
		return eLTE_ERR_XML_GET_ELEM_VALUE;										
	}
	strResourceList = srcValue;

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);	
	GET_XML_ELEM_VALUE_CHAR(xmlParse, "Subscriber", srcValue, elemValue, uiMaxLen);
	strSubscriber = elemValue;

	return eLTE_ERR_SUCCESS;
}
예제 #20
0
eLTE_RET XMLProcess::SetXmlStringEventNotifySDSReport(const std::string& strSrc,
	CString& xmlStr)
{
	/************************************************************************
			--- XML 格式 ---
			<Content>
			<SdsType>消息类型</SdsType>
			<SdsContent>消息内容</SdsContent>
			<SdsFrom>发件人</SdsFrom>
			<SdsMmsFileNameList>
				<SdsMmsFileName>附件文件名列表</SdsMmsFileName>
				<SdsMmsFileName>附件文件名列表</SdsMmsFileName>
			</SdsMmsFileNameList>
			<SdsSubject>消息主题</SdsSubject>
			<SdsDate>消息发送日期</SdsDate>
			<SdsTime>消息发送时间</SdsTime>
			</Content>
	************************************************************************/
	LOG_TRACE();

	CXml xmlParse;

	if (!xmlParse.Parse(strSrc.c_str()))
	{
		LOG_RUN_ERROR("parse xml failed.");
		return eLTE_ERR_FAILED;
	}
	if (!xmlParse.FindElem("Content"))
	{
		LOG_RUN_ERROR("FindElem Content failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlParse.IntoElem();
	if (!xmlParse.FindElem("SdsType"))
	{
		LOG_RUN_ERROR("FindElem CallStatus failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsType = xmlParse.GetElemValue();

	std::string strSdsContent = "";
	if(xmlParse.FindElem("SdsContent"))
	{
		strSdsContent = xmlParse.GetElemValue();
	}

	if (!xmlParse.FindElem("SdsFrom"))
	{
		LOG_RUN_ERROR("FindElem SdsFrom failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsFrom = xmlParse.GetElemValue();

	std::list<std::string> fileNameList;
	//彩信
	if (xmlParse.FindElem("SdsMmsFileNameList") && xmlParse.IntoElem())
	{
		do 
		{																		
			std::string srcValue = xmlParse.GetElemValue();
			if(!srcValue.empty())
			{
				fileNameList.push_back(srcValue);
			}
		} while (xmlParse.NextElem());
		xmlParse.OutOfElem();
	}

	if (!xmlParse.FindElem("SdsSubject"))
	{
		LOG_RUN_ERROR("FindElem SdsSubject failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsSubject = xmlParse.GetElemValue();


	if (!xmlParse.FindElem("SdsDate"))
	{
		LOG_RUN_ERROR("FindElem SdsDate failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsDate = xmlParse.GetElemValue();

	if (!xmlParse.FindElem("SdsTime"))
	{
		LOG_RUN_ERROR("FindElem SdsTime failed.");
		return eLTE_ERR_FAILED;
	}
	std::string strSdsTime = xmlParse.GetElemValue();


	//拼接xml
	xmlStr.Append(_T("<Content>"));

	xmlStr.Append(_T("<SdsType>"));
	xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsType).c_str());
	xmlStr.Append(_T("</SdsType>"));

	if(!strSdsContent.empty())
	{
		xmlStr.Append(_T("<SdsContent>"));
		xmlStr.Append(eLTE_Tool::UTF8ToUnicode(strSdsContent).c_str());
		xmlStr.Append(_T("</SdsContent>"));
	}

	xmlStr.Append(_T("<SdsFrom>"));
	xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsFrom).c_str());
	xmlStr.Append(_T("</SdsFrom>"));

	if(0 < fileNameList.size())
	{
		xmlStr.Append(_T("<SdsMmsFileNameList>"));
		std::list<std::string>::iterator it = fileNameList.begin();

		for (; it != fileNameList.end(); ++it)
		{
			xmlStr.Append(_T("<SdsMmsFileName>"));
			xmlStr.Append(eLTE_Tool::UTF8ToUnicode(*it).c_str());
			xmlStr.Append(_T("</SdsMmsFileName>"));
		}

		xmlStr.Append(_T("</SdsMmsFileNameList>"));
	}

	xmlStr.Append(_T("<SdsSubject>"));
	xmlStr.Append(eLTE_Tool::UTF8ToUnicode(strSdsSubject).c_str());
	xmlStr.Append(_T("</SdsSubject>"));

	
	xmlStr.Append(_T("<SdsDirection>"));
	xmlStr.Append(_T("false"));
	xmlStr.Append(_T("</SdsDirection>"));

	xmlStr.Append(_T("<SdsDate>"));
	xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsDate).c_str());
	xmlStr.Append(_T("</SdsDate>"));

	xmlStr.Append(_T("<SdsTime>"));
	xmlStr.Append(eLTE_Tool::ANSIToUnicode(strSdsTime).c_str());
	xmlStr.Append(_T("</SdsTime>"));
	xmlStr.Append(_T("</Content>"));

	return eLTE_ERR_SUCCESS;
}
// 解析画图前图形属性设置XML
IVS_INT32 COCXDrawXMLProcess::DrawGraphicsPraseXML(IA_GRAPHICS &GraphicAttribute, ULONG &ulGroupDrawMaxNum, LPCTSTR pGraphicsXml)
{
	CHECK_POINTER(pGraphicsXml, IVS_OPERATE_MEMORY_ERROR);
	IVS_DEBUG_TRACE("GroupDrawMaxNum: %lu, GraphicsXml: %s", ulGroupDrawMaxNum, pGraphicsXml);

	CXml xml;
	if (!xml.Parse(pGraphicsXml))
	{
		return IVS_FAIL;
	}

	CHECK_SUCCESS(xml.FindElem("Content"));
	CHECK_SUCCESS(xml.IntoElem());
	CHECK_SUCCESS(xml.FindElem("Graphics"));
	CHECK_SUCCESS(xml.IntoElem());

	const char *value = NULL;

	CHECK_SUCCESS(xml.FindElem("GraphicNum") && (NULL != (value = xml.GetElemValue())));
	ulGroupDrawMaxNum = (ULONG)atoi(value);

	// 若设置的图形数大于图形数组长度,截断到最大画图个数
	if (ulGroupDrawMaxNum > GRAPHICS_NUM_MAX)
	{
		BP_RUN_LOG_INF("COCXDrawXMLProcess::DrawGraphicsPraseXML", "GroupDrawMaxNum Truncated to GRAPHICS_NUM_MAX");
		ulGroupDrawMaxNum = GRAPHICS_NUM_MAX;
	}

	CHECK_SUCCESS(xml.FindElem("GraphicList"));
	CHECK_SUCCESS(xml.IntoElem());

	// 给图形可选字段赋默认值
	memset(&GraphicAttribute, 0, sizeof(IA_GRAPHICS));
	GraphicAttribute.ulLineWidth = 3; // 默认基本线宽为3
	GraphicAttribute.bAllowDelete = TRUE; // 允许删除
	GraphicAttribute.bAllowModifySize = TRUE; // 允许修改矩形大小

	CHECK_SUCCESS(xml.FindElem("GraphicInfo"));
	CHECK_SUCCESS(xml.IntoElem());
	CHECK_SUCCESS(xml.FindElem("GraphicType") && (NULL != (value = xml.GetElemValue())));
	GraphicAttribute.ulGraphicType = (ULONG)atoi(value);

	GET_ELEMENT_ULONG(GraphicAttribute.ulGraphicGroup, GraphicGroup, xml);
	GET_ELEMENT_STRING(GraphicAttribute.GraphicGroupName, CHARACTER_NUM_MAX, GraphicGroupName, xml);

	if (xml.FindElem("GraphicBackgroundColor"))
	{
		CHECK_SUCCESS(xml.IntoElem());
		GET_ELEMENT_UCHAR(GraphicAttribute.BgColor.Alpha, Opacity, xml);
		GET_ELEMENT_UCHAR(GraphicAttribute.BgColor.Red, Red, xml);
		GET_ELEMENT_UCHAR(GraphicAttribute.BgColor.Green, Green, xml);
		GET_ELEMENT_UCHAR(GraphicAttribute.BgColor.Blue, Blue, xml);
		xml.OutOfElem();
	}

	if (xml.FindElem("GraphicLineColor"))
	{
		CHECK_SUCCESS(xml.IntoElem());
		GET_ELEMENT_UCHAR(GraphicAttribute.LineColor.Alpha, Opacity, xml);
		GET_ELEMENT_UCHAR(GraphicAttribute.LineColor.Red, Red, xml);
		GET_ELEMENT_UCHAR(GraphicAttribute.LineColor.Green, Green, xml);
		GET_ELEMENT_UCHAR(GraphicAttribute.LineColor.Blue, Blue, xml);
		xml.OutOfElem();
	}

	GET_ELEMENT_ULONG(GraphicAttribute.ulLineWidth, GraphicLineWidth, xml);

	GET_ELEMENT_ULONG(GraphicAttribute.NamePosition, NamePosition, xml);
	GET_ELEMENT_BOOL(GraphicAttribute.bAllowDelete, DeleteByMouse, xml);
	GET_ELEMENT_BOOL(GraphicAttribute.bAllowAddNewPoint, AddNewPoint, xml);
	GET_ELEMENT_BOOL(GraphicAttribute.bAllowModifySize, AllowModifySize, xml);
	GET_ELEMENT_ULONG(GraphicAttribute.ulArrowType, ArrowType, xml);
	GET_ELEMENT_BOOL(GraphicAttribute.bKeepHorizon, KeepHorizon, xml);

	xml.OutOfElem();
	xml.OutOfElem();
	xml.OutOfElem();

	return IVS_SUCCEED;

}
예제 #22
0
// 查询平台运动检测幅度数据
IVS_INT32 CMotionDetection::GetMotionRangeDataPlatform(const IVS_CHAR* pCameraCode,const IVS_TIME_SPAN* pTimeSpan,const IVS_INDEX_RANGE* pIndexRange,IVS_MOTION_RANGE_DATA_LIST* pMotionRangeData,IVS_UINT32 uiBufferSize)
{
	CHECK_POINTER(pCameraCode, IVS_OPERATE_MEMORY_ERROR);
	CHECK_POINTER(pTimeSpan, IVS_OPERATE_MEMORY_ERROR);
	CHECK_POINTER(pIndexRange, IVS_OPERATE_MEMORY_ERROR);
	CHECK_POINTER(pMotionRangeData, IVS_OPERATE_MEMORY_ERROR);
	CHECK_POINTER(m_pUserMgr,IVS_OPERATE_MEMORY_ERROR);
	IVS_DEBUG_TRACE("");

	IVS_CHAR szCameraCode[IVS_SDK_DEV_CODE_LEN + 1] = {0};
	IVS_CHAR szDomainCode[IVS_DOMAIN_CODE_LEN + 1] = {0};
	// 解析pCameraCode到摄像机编码和域编码中
	IVS_INT32 iRet = CXmlProcess::ParseDevCode(pCameraCode, szCameraCode, szDomainCode);
	if (IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_ERR(iRet, "Get Motion Range Data Platform", "Parse Device Code failed");
		return iRet;
	}
	// 拼装请求xml
	CXml xmlReq;
	iRet = CMotionDetecMgrXMLProcess::GetMotionRangeDataPlatformReqXML(szCameraCode,szDomainCode,pTimeSpan,pIndexRange, xmlReq);
	if (IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_ERR(iRet, "Get Motion Range Data Platform", "Get Motion Range Data Platform Req XML failed");
		return iRet;
	}

	std::string sRecordMethod = "RecordMethod";
	iRet = CXmlProcess::AddQueryFieldForUnifiedFormatQueryXML(sRecordMethod.c_str(),CToolsHelp::Int2Str(RECORD_METHOD_PLATFORM).c_str(), xmlReq);
	if (IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_ERR(iRet, "Add QueryField For Unified Format Query XML failed", "failed");
		return iRet;
	}

	IVS_UINT32 xmlLen = 0;
	const IVS_CHAR* pReqXml = xmlReq.GetXMLStream(xmlLen);
	CHECK_POINTER(pReqXml, IVS_OPERATE_MEMORY_ERROR);

	CSendNssMsgInfo sendNssMsgInfo;	
	sendNssMsgInfo.SetNeedXml(TYPE_NSS_XML);
	sendNssMsgInfo.SetNetElemType(NET_ELE_SMU_NSS);
	sendNssMsgInfo.SetReqID(NSS_GET_MD_DATA_REQ);
	sendNssMsgInfo.SetReqData(pReqXml);
	sendNssMsgInfo.SetCameraCode(szCameraCode);
	sendNssMsgInfo.SetDomainCode(szDomainCode);

	std::string strpRsp;
	IVS_INT32 iNeedRedirect = IVS_FAIL;
	// 发送操作失败,直接返回
	iRet = m_pUserMgr->SendCmd(sendNssMsgInfo,strpRsp,iNeedRedirect);
	if (IVS_SUCCEED == iNeedRedirect)
	{
		iRet = m_pUserMgr->SendRedirectServe(sendNssMsgInfo,strpRsp);
	}
	// NSS消息返回码错误,不解析数据,直接返回错误码
	if (IVS_SUCCEED != iRet)
	{
		BP_RUN_LOG_ERR(iRet, "Get Motion Range Data Platform", "SendCmd operation succeed,rspCode = %d", iRet);
		return iRet;
	}

	//解析数据
	CXml xmlRsp;
	(void)xmlRsp.Parse(strpRsp.c_str());
	
	//解析查询请求XML
	if (IVS_SUCCEED != CMotionDetecMgrXMLProcess::ParseGetMotionRangeDataPlatformRspXML(xmlRsp,pMotionRangeData,uiBufferSize))
	{
		BP_RUN_LOG_ERR(IVS_XML_INVALID,"Parse Get Motion Range Data Platform Rsp XML is failed","failed");
		return IVS_XML_INVALID;
	}	
	return iRet;
}
예제 #23
0
// 查询设备组列表
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;
}
예제 #24
0
// 查询摄像机计划设置信息
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;
}
// 解析设置图形的XML
IVS_INT32 COCXDrawXMLProcess::SetGraphicsPraseXML(IA_GRAPHICS *pGraphicsArr, ULONG &ulNum, LPCTSTR pGraphicsXml, const SIZE &szGraphic, BOOL bPersent)
{
	CHECK_POINTER(pGraphicsArr, IVS_FAIL);
	CHECK_POINTER(pGraphicsXml, IVS_OPERATE_MEMORY_ERROR);

	IVS_DEBUG_TRACE("GraphicsXml: %s, GraphicWidth: %d, GraphicHeight: %d",pGraphicsXml, szGraphic.cx, szGraphic.cy);

	CXml xml;
	if (!xml.Parse(pGraphicsXml))
	{
		return IVS_FAIL;
	}

	CHECK_SUCCESS(xml.FindElem("Content"));
	CHECK_SUCCESS(xml.IntoElem());
	CHECK_SUCCESS(xml.FindElem("Graphics"));
	CHECK_SUCCESS(xml.IntoElem());

	const char *value = NULL;

	CHECK_SUCCESS(xml.FindElem("GraphicNum") && (NULL != (value = xml.GetElemValue())));
	ulNum = (ULONG)atoi(value);

	// 若设置的图形数大于图形数组长度,截断到最大画图个数
	if (ulNum > GRAPHICS_NUM_MAX)
	{
		BP_RUN_LOG_INF("COCXDrawXMLProcess::SetGraphicsPraseXML", "GraphicNum Truncated to GRAPHICS_NUM_MAX");
		ulNum = GRAPHICS_NUM_MAX;
	}

	CHECK_SUCCESS(xml.FindElem("GraphicList"));
	CHECK_SUCCESS(xml.IntoElem());

	for (ULONG i = 0; i < ulNum; i++)
	{
		// 给图形可选字段赋默认值
		memset(&pGraphicsArr[i], 0, sizeof(IA_GRAPHICS));
		pGraphicsArr[i].ulLineWidth = 3; // 默认基本线宽为3
		pGraphicsArr[i].bAllowDelete = TRUE; // 允许删除
		pGraphicsArr[i].bAllowModifySize = TRUE; // 允许修改矩形大小

		if (0 == i)
		{
			CHECK_SUCCESS(xml.FindElem("GraphicInfo"));
		} else {
			CHECK_SUCCESS(xml.NextElem());
		}
		CHECK_SUCCESS(xml.IntoElem());
		CHECK_SUCCESS(xml.FindElem("GraphicType") && (NULL != (value = xml.GetElemValue())));
		pGraphicsArr[i].ulGraphicType = (ULONG)atoi(value);

		GET_ELEMENT_ULONG(pGraphicsArr[i].ulGraphicGroup, GraphicGroup, xml);
		GET_ELEMENT_STRING(pGraphicsArr[i].GraphicGroupName, CHARACTER_NUM_MAX, GraphicGroupName, xml);

		if (xml.FindElem("GraphicBackgroundColor"))
		{
			CHECK_SUCCESS(xml.IntoElem());
			GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Alpha, Opacity, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Red, Red, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Green, Green, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].BgColor.Blue, Blue, xml);
			xml.OutOfElem();
		}

		if (xml.FindElem("GraphicLineColor"))
		{
			CHECK_SUCCESS(xml.IntoElem());
			GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Alpha, Opacity, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Red, Red, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Green, Green, xml);
			GET_ELEMENT_UCHAR(pGraphicsArr[i].LineColor.Blue, Blue, xml);
			xml.OutOfElem();
		}

		GET_ELEMENT_ULONG(pGraphicsArr[i].ulLineWidth, GraphicLineWidth, xml);

		CHECK_SUCCESS(xml.FindElem("PointNum") && (NULL != (value = xml.GetElemValue())));
		pGraphicsArr[i].ulPointsNum = (ULONG)atoi(value);

		CHECK_SUCCESS(xml.FindElem("PointList"));
		CHECK_SUCCESS(xml.IntoElem());

		for (ULONG j = 0; j < pGraphicsArr[i].ulPointsNum; j++)
		{
			if (0 == j)
			{
				CHECK_SUCCESS(xml.FindElem("Point"));
			} else {
				CHECK_SUCCESS(xml.NextElem());
			}
			CHECK_SUCCESS(xml.IntoElem());

			if ((0 == szGraphic.cx) || (0 == szGraphic.cy))
			{
				if (bPersent)
				{
					CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue())));
					pGraphicsArr[i].IAPoints[j].x = (LONG)(atof(value) * FLOAT_TO_LONG_COEFF);
					CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue())));
					pGraphicsArr[i].IAPoints[j].y = (LONG)(atof(value) * FLOAT_TO_LONG_COEFF);
				} else {
					CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue())));
					pGraphicsArr[i].IAPoints[j].x = (LONG)atoi(value);
					CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue())));
					pGraphicsArr[i].IAPoints[j].y = (LONG)atoi(value);
				}
			}
			else
			{
				CHECK_SUCCESS(xml.FindElem("X") && (NULL != (value = xml.GetElemValue())));
				pGraphicsArr[i].IAPoints[j].x = (LONG)(atof(value) * szGraphic.cx + 0.5);
				CHECK_SUCCESS(xml.FindElem("Y") && (NULL != (value = xml.GetElemValue())));
				pGraphicsArr[i].IAPoints[j].y = (LONG)(atof(value) * szGraphic.cy + 0.5);
			}

			xml.OutOfElem();
		}
		xml.OutOfElem();

		GET_ELEMENT_ULONG(pGraphicsArr[i].NamePosition, NamePosition, xml);
		GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowDelete, DeleteByMouse, xml);
		GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowAddNewPoint, AddNewPoint, xml);
		GET_ELEMENT_BOOL(pGraphicsArr[i].bAllowModifySize, AllowModifySize, xml);
		GET_ELEMENT_ULONG(pGraphicsArr[i].ulArrowType, ArrowType, xml);
		GET_ELEMENT_BOOL(pGraphicsArr[i].bKeepHorizon, KeepHorizon, xml);

		xml.OutOfElem();
	}
	xml.OutOfElem();
	xml.OutOfElem();

	return IVS_SUCCEED;
}
예제 #26
0
 //删除平台录像计划;
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
예제 #27
0
//添加平台录像计划;
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 
//对XML中的设备编码拼装与编码
int CSDKMainctrl::ModifyDevCode(CXml& xml, IVS_CHAR* pData)const
{
	CHECK_POINTER(pData, IVS_OPERATE_MEMORY_ERROR);

	if (!xml.Parse(pData))
	{
		BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.Parse(pData)", "NA");
		//IVS_DELETE(pData, MUILI);
		return IVS_SMU_XML_INVALID;
	}
	if (!xml.FindElemEx("Content/Action"))
	{
		BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(Content/Action)", "NA");
		//IVS_DELETE(pData, MUILI);
		return IVS_SMU_XML_INVALID;		
	}
	// 若xml包含DevList,需要处理DevCode(拼接设备所在域编码DevDomainCode)
	if (xml.FindElem("DevList"))
	{
		xml.IntoElem();
		if (!xml.FindElem("DevInfo"))
		{
			BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevInfo)", "NA");
			//IVS_DELETE(pData, MUILI);
			return IVS_SMU_XML_INVALID;		
		}
		do 
		{
			(void)xml.IntoElem();
			// 找到设备所在域编码拼在DevCode后面
			if (!xml.FindElem("DevDomainCode"))
			{
				BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevCode)", "NA");
				//IVS_DELETE(pData, MUILI);
				return IVS_SMU_XML_INVALID;		
			}
			std::string strDevDomainCode;
            const IVS_CHAR* pDevDomainCode = xml.GetElemValue();
            if (NULL != pDevDomainCode)
            {
                strDevDomainCode = pDevDomainCode;
            }
			// 拼接设备所在域编码
			if (!xml.FindElem("DevCode"))
			{
				BP_RUN_LOG_ERR(IVS_SMU_XML_INVALID, "xml.FindElem(DevCode)", "NA");
				//IVS_DELETE(pData, MUILI);
				return IVS_SMU_XML_INVALID;		
			}
			std::string strDevCode;
            
            const IVS_CHAR* pDevCode = xml.GetElemValue();
            if (NULL != pDevCode)
            {
                strDevCode = pDevCode;
            }

			if (!strDevCode.empty())
			{
				strDevCode.append("#").append(strDevDomainCode);
				xml.ModifyElemValue(strDevCode.c_str());
			}
			xml.OutOfElem();
		} while (xml.NextElem());
		xml.OutOfElem();
	}
// 
// 	IVS_UINT32 uiXmlLen = 0;
// 	pDataXml = xml.GetXMLStream(uiXmlLen);
// 	CHECK_POINTER(pDataXml, IVS_OPERATE_MEMORY_ERROR);
	return IVS_SUCCEED;
}//lint !e818
예제 #29
0
// 解析入参视频播放参数
eLTE_RET XMLProcess::XmlParsePlayVideoParam(const std::string& xmlStrLocal, const std::string& xmlStrRemote,	// 入参
		std::string& strLocalIP, unsigned int& uiLocalVideoPort, unsigned int& uiLocalAudioPort,				// 出参
		std::string& strRemoteIP, unsigned int& uiRemoteVideoPort, unsigned int& uiRemoteAudioPort)				// 出参
{
	/************************************************************************
	--- XML 格式 ---
	<Content>
		<LocalMediaAddr>
			<LocalIP></LocalIP>
			<VideoPort></VideoPort>
			<AudioPort></AudioPort>
		</LocalMediaAddr>
	</Content>
	<Content>
		<RemoteMediaAddr>
			<RemoteIP></RemoteIP>
			<VideoPort></VideoPort>
			<AudioPort></AudioPort>
		</RemoteMediaAddr>
	</Content>
	************************************************************************/ 
	
	LOG_TRACE();
	INFO_PARAM2(xmlStrLocal, xmlStrRemote);

	// 解析本地视频参数
	CXml xmlLocal;
	if (!xmlLocal.Parse(xmlStrLocal.c_str()))
	{
		LOG_RUN_ERROR("parse xmlStrLocal failed.");
		return eLTE_ERR_FAILED;
	}
	if (!xmlLocal.FindElem("Content"))
	{
		LOG_RUN_ERROR("FindElem Content failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlLocal.IntoElem();
	if (!xmlLocal.FindElem("LocalMediaAddr"))
	{
		LOG_RUN_ERROR("FindElem LocalMediaAddr failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlLocal.IntoElem();

	const unsigned int XML_VAR_LENGTH = 20;
	char elemValue[XML_VAR_LENGTH] = {0};
	const char* srcValue;
	unsigned int uiMaxLen = XML_VAR_LENGTH;

	GET_XML_ELEM_VALUE_CHAR(xmlLocal, "LocalIP", srcValue, elemValue, uiMaxLen);
	strLocalIP = elemValue;

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);
	GET_XML_ELEM_VALUE_CHAR(xmlLocal, "VideoPort", srcValue, elemValue, uiMaxLen);
	uiLocalVideoPort = eLTE_Tool::String2UInt(elemValue);

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);
	GET_XML_ELEM_VALUE_CHAR(xmlLocal, "AudioPort", srcValue, elemValue, uiMaxLen);
	uiLocalAudioPort = eLTE_Tool::String2UInt(elemValue);

	// 解析远端视频参数
	CXml xmlRemote;
	if (!xmlRemote.Parse(xmlStrRemote.c_str()))
	{
		LOG_RUN_ERROR("parse xmlStrRemote failed.");
		return eLTE_ERR_FAILED;
	}
	if (!xmlRemote.FindElem("Content"))
	{
		LOG_RUN_ERROR("FindElem Content failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlRemote.IntoElem();
	if (!xmlRemote.FindElem("RemoteMediaAddr"))
	{
		LOG_RUN_ERROR("FindElem RemoteMediaAddr failed.");
		return eLTE_ERR_FAILED;
	}
	(void)xmlRemote.IntoElem();

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);
	GET_XML_ELEM_VALUE_CHAR(xmlRemote, "RemoteIP", srcValue, elemValue, uiMaxLen);
	strRemoteIP = elemValue;

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);
	GET_XML_ELEM_VALUE_CHAR(xmlRemote, "VideoPort", srcValue, elemValue, uiMaxLen);
	uiRemoteVideoPort = eLTE_Tool::String2UInt(elemValue);

	uiMaxLen = XML_VAR_LENGTH;
	memset(elemValue, 0, sizeof(char)*XML_VAR_LENGTH);
	GET_XML_ELEM_VALUE_CHAR(xmlRemote, "AudioPort", srcValue, elemValue, uiMaxLen);
	uiRemoteAudioPort = eLTE_Tool::String2UInt(elemValue);

	return eLTE_ERR_SUCCESS;
}
예제 #30
0
HRESULT CHandler::Open2(IInStream *stream)
{
  const UInt32 kHeaderSize = 0x1C;
  Byte buf[kHeaderSize];
  RINOK(ReadStream_FALSE(stream, buf, kHeaderSize));

  UInt32 size = Get16(buf + 4);
  // UInt32 ver = Get16(buf + 6); // == 1
  if (Get32(buf) != 0x78617221 || size != kHeaderSize)
    return S_FALSE;

  UInt64 packSize = Get64(buf + 8);
  UInt64 unpackSize = Get64(buf + 0x10);

  // _checkSumAlgo = Get32(buf + 0x18);

  if (packSize >= kXmlPackSizeMax ||
      unpackSize >= kXmlSizeMax)
    return S_FALSE;

  _dataStartPos = kHeaderSize + packSize;
  _phySize = _dataStartPos;

  _xml.Alloc((size_t)unpackSize + 1);
  _xmlLen = (size_t)unpackSize;
  
  NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
  CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;

  CLimitedSequentialInStream *inStreamLimSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStreamLim(inStreamLimSpec);
  inStreamLimSpec->SetStream(stream);
  inStreamLimSpec->Init(packSize);

  CBufPtrSeqOutStream *outStreamLimSpec = new CBufPtrSeqOutStream;
  CMyComPtr<ISequentialOutStream> outStreamLim(outStreamLimSpec);
  outStreamLimSpec->Init(_xml, (size_t)unpackSize);

  RINOK(zlibCoder->Code(inStreamLim, outStreamLim, NULL, NULL, NULL));

  if (outStreamLimSpec->GetPos() != (size_t)unpackSize)
    return S_FALSE;

  _xml[(size_t)unpackSize] = 0;
  if (strlen((const char *)(const Byte *)_xml) != unpackSize) return S_FALSE;

  CXml xml;
  if (!xml.Parse((const char *)(const Byte *)_xml))
    return S_FALSE;
  
  if (!xml.Root.IsTagged("xar") || xml.Root.SubItems.Size() != 1)
    return S_FALSE;
  const CXmlItem &toc = xml.Root.SubItems[0];
  if (!toc.IsTagged("toc"))
    return S_FALSE;
  if (!AddItem(toc, _files, -1))
    return S_FALSE;

  UInt64 totalPackSize = 0;
  unsigned numMainFiles = 0;
  
  FOR_VECTOR (i, _files)
  {
    const CFile &file = _files[i];
    file.UpdateTotalPackSize(totalPackSize);
    if (file.Name == "Payload" || file.Name == "Content")
    {
      _mainSubfile = i;
      numMainFiles++;
    }
    else if (file.Name == "PackageInfo")
      _is_pkg = true;
  }

  if (numMainFiles > 1)
    _mainSubfile = -1;
  
  _phySize = _dataStartPos + totalPackSize;

  return S_OK;
}