kb_dc_servcfgdata.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:3k
源码类别:

DVD

开发平台:

C/C++

  1. #include "kb_dc_pub.h"
  2. static KB_DC_ServCfg_Map_Array *gServCfgMap=NULL;
  3. /*
  4. *  返回gServCfgMap头地址
  5. */
  6. KB_DC_ServCfg_Map_Array *KB_GetXmlServCfgMapHead(void)
  7. {
  8. return gServCfgMap;
  9. }
  10. /*
  11. *  返回gServCfgMap头地址
  12. */
  13. void KB_SetXmlServCfgMapHead(KB_DC_ServCfg_Map_Array *pHead)
  14. {
  15.  gServCfgMap = pHead;
  16. }
  17. /*
  18. *  将解析的XML业务配置信息装载到DC数据结构里
  19. */
  20. void KB_DC_ReloadXmlServCfgMap(void)
  21. {
  22. kb_xml_serviceInfoNode_t *xml_serviceInfo=NULL;
  23. KB_DC_ServCfg_Map_Array *servCfgMap=NULL;
  24. int i=0;
  25.      
  26. DCDebug3("n ----------KB_DC_ReloadXmlServCfgMap--------------------");
  27. xml_serviceInfo = KB_Xml_GetServiceInfoHead();
  28. servCfgMap = KB_GetXmlServCfgMapHead();
  29. if(servCfgMap==NULL)
  30. {
  31. DCDebug3("n to malloc servCfgMap!");
  32. servCfgMap = (KB_DC_ServCfg_Map_Array*)KBDcMalloc(sizeof(KB_DC_ServCfg_Map_Array));
  33. if(servCfgMap==NULL)
  34. {
  35. DCDebug1("n servCfgMap malloc error!");
  36. return;
  37. }
  38. KB_SetXmlServCfgMapHead(servCfgMap);
  39. }
  40. KBDcMemset(servCfgMap, 0, sizeof(KB_DC_ServCfg_Map_Array));
  41. while(xml_serviceInfo!=NULL)
  42. {
  43. DCDebug3("n reload!----");
  44. i = servCfgMap->count;
  45. servCfgMap->ServCfg[i].m_freq = xml_serviceInfo->st_ServiceInfo.m_freq;
  46. servCfgMap->ServCfg[i].m_nPid = xml_serviceInfo->st_ServiceInfo.m_nPid;
  47. servCfgMap->ServCfg[i].m_transactionsId = xml_serviceInfo->st_ServiceInfo.m_transactionsId;
  48. servCfgMap->ServCfg[i].m_type =  xml_serviceInfo->st_ServiceInfo.m_type;
  49. strcpy((char*)servCfgMap->ServCfg[i].m_string, (const char*)xml_serviceInfo->st_ServiceInfo.m_string);
  50. servCfgMap->count++;
  51. xml_serviceInfo=xml_serviceInfo->m_pNext;
  52. }
  53. //not useful , release it
  54. ReleaseXmlServiceInfo();
  55. return;
  56. }
  57. /**
  58. *   KB_GetServMapByPara
  59.  * get main frequency cfg node by parameter
  60.  * 
  61.  * 
  62.  * @return.
  63.  */
  64. KB_DC_ServCfg_Map *KB_GetServMapByPara(unsigned long fre, unsigned char type)
  65. {
  66. KB_DC_ServCfg_Map_Array *ServMapArry=NULL;
  67. int i=0;
  68. ServMapArry = KB_GetXmlServCfgMapHead();
  69. if(ServMapArry==NULL)
  70. {
  71. DCDebug1("n [KB_GetServMapByPara]: -ServMapArry is null");
  72. return NULL;
  73. }
  74. for(i=0; i<ServMapArry->count; i++)
  75. {
  76. if((fre==ServMapArry->ServCfg[i].m_freq)&&(type==ServMapArry->ServCfg[i].m_type))
  77. {
  78. DCDebug3("n --find one--");
  79. return &ServMapArry->ServCfg[i];
  80. }
  81. }
  82. return NULL;
  83. }
  84. /**
  85. *   KB_GetServCfgByPara
  86.  * get main frequency cfg node by parameter
  87.  * 
  88.  * 
  89.  * @return.
  90.  */
  91. KB_DC_ServCfg_Map *KB_GetCurServMapItem(unsigned char type)
  92. {
  93. KBTunerPara  tspara;
  94. kb_DC_GetCurTsInfo(&tspara);
  95. DCDebug3("n KB_GetCurServMapItem:  tspara.frequency=%ld",tspara.frequency);
  96. return( KB_GetServMapByPara(tspara.frequency, type));
  97. }