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 CMediaXMLProcess::GetURLResponseData(CXml &xmlRsp, ST_MEDIA_RSP& stMediaRsp, bool& bAssociatedAudio) { IVS_DEBUG_TRACE(""); memset(&stMediaRsp, 0, sizeof(ST_MEDIA_RSP)); const char*AttriValue = NULL; //临时存储单个节点值 bool bRet = false; CHECK_SUCCESS(xmlRsp.FindElem("Content")); CHECK_SUCCESS(xmlRsp.IntoElem()); CHECK_SUCCESS(xmlRsp.FindElem("URL")); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); bRet = CToolsHelp::Memcpy(stMediaRsp.szURL, URL_LEN, AttriValue, strlen(AttriValue)); if(!bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } if (xmlRsp.FindElem("AssociatedAudio")) { CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); bAssociatedAudio = (bool)atoi(AttriValue); } CHECK_SUCCESS(xmlRsp.FindElem("RtspIP")); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPIP, IVS_IP_LEN, AttriValue, strlen(AttriValue)); if(!bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } CHECK_SUCCESS(xmlRsp.FindElem("RtspPort")); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPPORT, PORT_LEN, AttriValue, strlen(AttriValue)); if(!bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } //add by zwx211831, Date:20140625, 在URL中添加UserID和DomainID,以实现查询点播业务。 //如果是旧的版本,则不变。 if (xmlRsp.FindElem("UserId") && xmlRsp.FindElem("DomainId")) { (void)xmlRsp.FindElem("DomainId"); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); std::string strDomainCode("DomainCode="); strDomainCode += AttriValue; strDomainCode += "&"; if(!CToolsHelp::Strncat(stMediaRsp.szURL, URL_LEN, strDomainCode.c_str())) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Strncat error."); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRsp.FindElem("UserId"); CHECK_SUCCESS(NULL != (AttriValue = xmlRsp.GetElemValue())); IVS_UINT32 uiUserID = 0; std::string strUserID("UserId="); GET_ELEM_VALUE_NUM_FOR_UINT("UserId", AttriValue, uiUserID, xmlRsp); strUserID += CToolsHelp::Int2Str(uiUserID); strUserID += "&"; if(!CToolsHelp::Strncat(stMediaRsp.szURL, URL_LEN, strUserID.c_str())) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Strncat error."); return IVS_ALLOC_MEMORY_ERROR; } } xmlRsp.OutOfElem(); return IVS_SUCCEED; #if 0 //XML增加AssociatedAudio字段 (void)xmlRsp.GetElem(); // Content (void)xmlRsp.IntoElem(); (void)xmlRsp.GetElem(); // URL AttriValue=xmlRsp.GetElemValue(); if(AttriValue == NULL) { BP_RUN_LOG_INF("Get URL Response Data", "URL is null"); return IVS_SDK_RET_SMU_SDK_XML_INVALD; } bool bRet = CToolsHelp::Memcpy(stMediaRsp.szURL,URL_LEN, AttriValue, strlen(AttriValue)); if(false == bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRsp.NextElem(); // RtspIP (void)xmlRsp.GetElem(); AttriValue = xmlRsp.GetElemValue(); if(AttriValue == NULL) { BP_RUN_LOG_INF("Get URL Response Data", "RtspIP is null"); return IVS_SDK_RET_SMU_SDK_XML_INVALD; } bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPIP,IVS_IP_LEN, AttriValue, strlen(AttriValue)); if(false == bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } (void)xmlRsp.NextElem(); // RtspPort (void)xmlRsp.GetElem(); AttriValue = xmlRsp.GetElemValue(); if(AttriValue == NULL) { BP_RUN_LOG_INF("Get URL Response Data", "RtspPort is null"); return IVS_SDK_RET_SMU_SDK_XML_INVALD; } bRet = CToolsHelp::Memcpy(stMediaRsp.szRTSPPORT,PORT_LEN, AttriValue, strlen(AttriValue)); if(false == bRet) { BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"Get URL Response Data", "Memcpy error."); return IVS_ALLOC_MEMORY_ERROR; } return IVS_SUCCEED; #endif }