| 15 | |
| 16 | |
| 17 | int XmlConfig::LoadConfig(const char *filename, XML_CONFIG_T *pConfig) |
| 18 | { |
| 19 | if (NULL == filename) return -1; |
| 20 | |
| 21 | memset(&xmlConfig, 0x00, sizeof(XML_CONFIG_T)); |
| 22 | |
| 23 | int ret = -1; |
| 24 | TiXmlDocument m_DocR; |
| 25 | if (!m_DocR.LoadFile(filename)) |
| 26 | { |
| 27 | //libLogger_Print(NULL, LOG_TYPE_DEBUG, "XmlConfig:: Failed to read configuration file.\nuse default parameters. file:%s\n", filename); |
| 28 | |
| 29 | char szTime[64] = { 0 }; |
| 30 | time_t tt = time(NULL); |
| 31 | unsigned int randValue = tt & 0xFFFFF; |
| 32 | /*struct tm* _timetmp = NULL; |
| 33 | _timetmp = localtime(&tt); |
| 34 | if (NULL != _timetmp) strftime(szTime, 32, "%Y%m%d%H%M%S", _timetmp);*/ |
| 35 | |
| 36 | xmlConfig.SipType = 0; |
| 37 | strcpy(xmlConfig.serverSipID, "34020000002000000001"); |
| 38 | strcpy(xmlConfig.serverDomain, "3402000000"); |
| 39 | strcpy(xmlConfig.serverIP, "demo.easygbs.com"); |
| 40 | xmlConfig.serverSipPort = 30310; |
| 41 | xmlConfig.registerExpire = 3600; |
| 42 | xmlConfig.heartbeatCount = 3; |
| 43 | xmlConfig.heartbeatInterval = 60; |
| 44 | strcpy(xmlConfig.protocol, "UDP"); |
| 45 | strcpy(xmlConfig.password, "12345678"); |
| 46 | strcpy(xmlConfig.localSipID, "34020000001110000009"); |
| 47 | xmlConfig.localPort = 15090; |
| 48 | sprintf(xmlConfig.deviceName, "EasyGBD-win-%d", randValue); |
| 49 | strcpy(xmlConfig.sourcePath, "rtsp://"); |
| 50 | |
| 51 | strcpy(xmlConfig.channels.cid, "34020000001310000001"); |
| 52 | |
| 53 | SaveConfig(filename, &xmlConfig); //�����������ļ�, ����һ���µ������ļ� |
| 54 | if (NULL != pConfig) memcpy(pConfig, &xmlConfig, sizeof(XML_CONFIG_T)); |
| 55 | return ret; |
| 56 | } |
| 57 | |
| 58 | //libLogger_Print(NULL, LOG_TYPE_DEBUG, "XmlConfig::Open the configuration file successfully: %s\n", filename); |
| 59 | |
| 60 | TiXmlHandle hDoc(&m_DocR); |
| 61 | TiXmlHandle hRoot(0); |
| 62 | |
| 63 | TiXmlElement *pServerConfigXML = hDoc.FirstChild("XmlConfig").ToElement(); |
| 64 | if (NULL != pServerConfigXML) |
| 65 | { |
| 66 | TiXmlElement *pE; |
| 67 | |
| 68 | pE = pServerConfigXML->FirstChildElement("SipType"); |
| 69 | if (pE && pE->GetText()) xmlConfig.SipType = atoi(pE->GetText()); |
| 70 | |
| 71 | pE = pServerConfigXML->FirstChildElement("serverSipID"); |
| 72 | if (pE && pE->GetText()) strcpy(xmlConfig.serverSipID, pE->GetText()); |
| 73 | |
| 74 | pE = pServerConfigXML->FirstChildElement("serverDomain"); |
no test coverage detected