al_psi_monitor.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /**
  2. * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
  3. *
  4. * @file al_psi_monitor.h
  5. *
  6. * @brief this file defines psi monitor interface for app layer.
  7. *
  8. * The file supports the psi monitor functions by used for app layer.
  9. * The psi monitor check all psi and si table changed,
  10. * if table change parse and update information to database and notify application dispose.
  11. *
  12. */
  13. #ifndef __AL_PSI_MONITOR_H__
  14. #define __AL_PSI_MONITOR_H__
  15. #include "al_basictypes.h"
  16. #include "dvb_dr.h"
  17. #include "al_database.h"
  18. #ifdef __cplusplus
  19. extern "C"{
  20. #endif
  21. /**
  22. * @brief Psi monitor dispose max other tp service namber.
  23. */
  24. #define PSIMON_MAX_OTHERTP_SRV 100
  25. #define PSIMON_MAX_EWSDETAIL_LEN 256
  26. /**
  27. * @brief Psi monitor special spec define.
  28. */
  29. typedef enum
  30. {
  31. AL_PSIMON_SPECIAL_SPEC_NONE = DVB_SPECIAL_SPEC_NONE, /**< None spec */
  32. AL_PSIMON_SPECIAL_SPEC_DTG = DVB_SPECIAL_SPEC_DTG, /**< DBOOK spec for UK */
  33. AL_PSIMON_SPECIAL_SPEC_ZBOOK = DVB_SPECIAL_SPEC_ZBOOK, /**< ZBOOK spec for ITALY */
  34. AL_PSIMON_SPECIAL_SPEC_NORDIG = DVB_SPECIAL_SPEC_NORDIG, /**< NORDIG spec for FINLAND, SWEDEN, DENMARK, NORWAY, GERMANY */
  35. AL_PSIMON_SPECIAL_SPEC_EBOOK = DVB_SPECIAL_SPEC_EBOOK, /**< EBOOK spec */
  36. AL_PSIMON_SPECIAL_SPEC_BASEON_PDSD = DVB_SPECIAL_SPEC_BASEON_PDSD,
  37. AL_PSIMON_SPECIAL_SPEC_THAI = DVB_SPECIAL_SPEC_THAI,
  38. #ifdef DVB_S
  39. AL_PSIMON_SPECIAL_SPEC_DVBS_TEST = DVB_SPECAIL_SPEC_DVBS_TEST,
  40. #endif
  41. #ifdef CONFIG_SUPPORT_FAST_SCANNING
  42. AL_PSIMON_SPECIAL_SPEC_M7_FASTSCAN = DVB_SPECIAL_SPEC_M7_FASTSCAN,
  43. #endif
  44. AL_PSIMON_SPECIAL_SPEC_DEMO_DEFAULT = DVB_SPECIAL_SPEC_DEMO_DEFAULT,
  45. } AL_PSIMon_SpecialSpec_t;
  46. /**
  47. * @brief Define psi dynamic update options.
  48. */
  49. typedef enum
  50. {
  51. AL_PSIMONITOR_CURTP_SRVADD = 1<<0, /**< Check SDT and NIT in addition */
  52. AL_PSIMONITOR_CURTP_SRVADD2 = 1<<1, /**< Check PAT in addition */
  53. AL_PSIMONITOR_CURTP_SRV_ATR = 1<<2, /**< Service name & attribute update check */
  54. AL_PSIMONITOR_CURTP_SRV_REMOVE = 1<<3, /**< When service info was gone , the service will be removed */
  55. AL_PSIMONITOR_CURTP_SRV_MOVE = 1<<4, /**< Service move descriptor, move a service from one TS to another */
  56. AL_PSIMONITOR_CURTP_SRV_REPLACE = 1<<5, /**< Service replacement check */
  57. AL_PSIMONITOR_LCN_DYNAMIC_UPDATE = 1<<6, /**< To support dynamic lcn update */
  58. AL_PSIMONITOR_OTHTP_SR_ADD = 1<<7, /**< Check other tp's service if any new tp found, its services add to database automatically */
  59. AL_PSIMONITOR_REPLACED_TO_ORIGNAL = 1<<8, /**< Service from replaced state to orignal state */
  60. AL_PSIMONITOR_OTHTP_FOND = 1<<9, /**< Check other tp frequency is change in nit, start to scan automatically */
  61. AL_PSIMONITOR_USER_TOTOFFSET = 1<<10, /**< if has TOT and country matched, forced use tot time offset */
  62. AL_PSIMONITOR_OTHTP_SR_UPDATE = 1<< 11, /**< Other tp sdt to update service info */
  63. #ifdef SUPPORT_NETWORK_UPDATE_RESCAN
  64. AL_PSIMONITOR_CURNWK_TP_RESCAN = 1<< 12, /**< Rescan to add/remove other tp */
  65. #endif
  66. AL_PSIMONITOR_KDG_LCN_DYNAMIC_UPDATE = 1<<13, /**< To support dynamic lcn update for Operator KDG */
  67. AL_PSIMONITOR_CURTP_SRVADDCHECKPMT = 1<<14, /**< Check PMT in addition */
  68. AL_PSIMONITOR_FREQ_UPDATE = 1<< 15,
  69. } AL_PsiMon_DynamicUpdate_Type_t;
  70. /**
  71. * @brief Define sipsi state.
  72. */
  73. typedef enum
  74. {
  75. AL_PSIMONITOR_STATE_NOT_RUNNING_FLAG = (1<<1), /**< Current program is not running, sdt running status is 0x01 */
  76. AL_PSIMONITOR_STATE_NOT_RUNNING_REPLACEMENT_EXIST = (1<<2), /**< Not running replacement exist, lingkage type is 0x05 */
  77. AL_PSIMONITOR_STATE_SCRAMBLED_REPLACEMENT_EXIST = (1<<3), /**< Scramble replacement exist, lingkage type is 0x03 */
  78. AL_PSIMONITOR_STATE_SIMULCAST_REPLACEMENT_EXIST = (1<<4), /**< Simulcast replacement exist, lingkage type is 0x82 , for NORDIG spec */
  79. AL_PSIMONITOR_STATE_NOT_RUNNING_REPLACED = (1<<5), /**< Not running replaced, has disposed not running replacement */
  80. AL_PSIMONITOR_STATE_SCRAMBLED_REPLACED = (1<<6), /**< Scramble replaced, has disposed scramble replacement */
  81. AL_PSIMONITOR_STATE_SIMULCAST_REPLACED = (1<<7), /**< Simulcast replaced, has dispose simulcase scramble replacement */
  82. #ifdef EPG_REPLACE
  83. AL_PSIMONITOR_STATE_EPG_REPLACEMENT_EXIST = (1<<8), /**< EPG replacement exist, lingkage type is 0x04 , for boxer spec */
  84. AL_PSIMONITOR_STATE_EPG_REPLACED = (1<<9), /**< EPG replaced, has disposed EPG replacement */
  85. #endif
  86. AL_PSIMONITOR_STATE_MAX,
  87. } AL_PsiMon_State_Type_t;
  88. /**
  89. * @brief Psi monitor simple service, used to service dynmc add and remove.
  90. */
  91. typedef struct _PSIMon_SimpleSrv
  92. {
  93. al_uint16 usOrgNetId; /**< orignal net work id */
  94. al_uint16 usNetWorkId; /** network id form NIT <*/ /*zhongbaoxing added fo NorDig test*/
  95. al_uint16 usTsId; /**< transport stream id */
  96. al_uint16 usPat_TsId;
  97. al_uint16 usServiceId; /**< service id */
  98. al_uint16 usProgNum; /**< program number */
  99. al_uint16 usPMTPid; /**< pmt pid */
  100. AL_DB_ERecordType_t ucServiceType; /**< service type */
  101. al_uint8 u8SDTSrvType;
  102. al_int32 uiFreq; /**< frequecy */
  103. al_uint8 *pucname; /**< program name */
  104. DBServAttrib_t stProgAttrib;
  105. struct _PSIMon_SimpleSrv *pstNext;
  106. } AL_PSIMon_SimpleSrv_t;
  107. /**
  108. * @brief Psi monitor audio comp data, used to multi audio dispose.
  109. */
  110. typedef struct _PsiMon_AudioComp
  111. {
  112. al_uint8 u8StreamType; /**< stream_type */
  113. al_uint16 u16ElementaryPid; /**< elementary_pid */
  114. al_uint16 u16DescLen; /**< total descriptor length */
  115. al_uint8 *pu8Desc; /**< pointer to descriptor */
  116. struct _PsiMon_AudioComp *pstNext;
  117. } AL_PsiMon_AudioComp_t;
  118. /**
  119. * @brief Psi monitor new service position for move descriptor.
  120. */
  121. typedef struct _PsiMon_NewSrvPosition
  122. {
  123. al_uint16 usOldServiceId; /**< Old service id */
  124. al_uint16 usOrgNetId; /**< Orignal network id */
  125. al_uint16 usTsId; /**< Transport id */
  126. al_uint16 usServiceId; /**< New service id */
  127. } AL_PsiMon_NewSrvPosition_t;
  128. #ifdef CONFIG_SUPPORT_INDONESIA_EWS
  129. #include "mid_siutil_dvb.h"
  130. typedef struct _PsiMon_EwsTrdwInfo
  131. {
  132. al_uint16 usDisaster;
  133. al_uint16 usLocationType;
  134. al_uint8 u8PackageId;
  135. al_uint8 u8NumLocations;
  136. SI_EWS_TRDW_LOCATION* locations;
  137. } AL_PsiMon_EwsTrdwInfo_t;
  138. typedef struct _PsiMon_EwsTcdwInfo
  139. {
  140. al_uint8 u8PackageId;
  141. al_uint8 u8Authority;
  142. al_uint16 usDisaster;
  143. SI_STRING_DESC* disaster_name;
  144. SI_STRING_DESC* disaster_position;
  145. SI_STRING_DESC* disaster_date;
  146. SI_STRING_DESC* disaster_characteristic;
  147. } AL_PsiMon_EwsTcdwInfo_t;
  148. typedef struct _PsiMon_EwsTmdwInfo
  149. {
  150. al_uint16 usLocationType;
  151. al_uint8 u8PackageId;
  152. al_uint8 u8NumMessages;
  153. SI_STRING_DESC** messages;
  154. } AL_PsiMon_EwsTmdwInfo_t;
  155. typedef struct _PsiMon_EwsList
  156. {
  157. al_uint8 u8NumTrdwEntries;
  158. al_uint32 u32TrdwCrc32;
  159. AL_PsiMon_EwsTrdwInfo_t *trdwEntries;
  160. al_uint8 u8NumTcdwEntries;
  161. al_uint32 u32TcdwCrc32;
  162. AL_PsiMon_EwsTcdwInfo_t *tcdwEntries;
  163. al_uint8 u8NumTmdwEntries;
  164. al_uint32 u32TmdwCrc32;
  165. AL_PsiMon_EwsTmdwInfo_t *tmdwEntries;
  166. } AL_PsiMon_EwsList_t;
  167. typedef struct _PsiMon_EwsDetail
  168. {
  169. // from TRDW
  170. al_uint16 usDisaster;
  171. al_uint16 usLocationType;
  172. al_uint8 u8PackageId;
  173. al_uint8 location_name[PSIMON_MAX_EWSDETAIL_LEN];
  174. // from TCDW
  175. al_uint8 u8Authority;
  176. al_uint8 disaster_name[PSIMON_MAX_EWSDETAIL_LEN];
  177. al_uint8 disaster_position[PSIMON_MAX_EWSDETAIL_LEN];
  178. al_uint8 disaster_date[PSIMON_MAX_EWSDETAIL_LEN];
  179. al_uint8 disaster_characteristic[PSIMON_MAX_EWSDETAIL_LEN];
  180. // from TMDW
  181. al_uint8 *message; // need to be freed explicitly by caller
  182. } AL_PsiMon_EwsDetail_t;
  183. AL_Return_t AL_PSI_Monitor_GetEwsDetail(al_uint32 u16AreaCode, AL_PsiMon_EwsDetail_t *ewsDetail);
  184. #endif
  185. /**
  186. * @brief Call back function prototype for application to register.
  187. */
  188. typedef al_void (* AL_pfPsiMonCheckSrvType)(al_uint8 SdtSrvType, al_uint8 SrvType, al_uint8 VideoCount, al_uint8 AudioCount, AL_DB_ERecordType_t *RetSrvType);
  189. typedef al_void (* AL_pfPsiMonCheckNotVisible)(al_uint8 SdtSrvType, al_uint8 bTempSrv, al_uint8 *bNotVisible, al_uint8 *bNotNeedSave);
  190. /**
  191. * @brief psi monitor start function.
  192. *
  193. * Active psi monitor task, start to monitor psi table and si table change
  194. *
  195. * @param hCurrProg playback play program handle.
  196. *
  197. * @param ClearReplaceData the flag of clearing replace data.
  198. *
  199. * @return AL_SUCCESS start is successful, AL_FAILURE otherwise.
  200. */
  201. AL_Return_t AL_PSI_Monitor_Start(AL_RecHandle_t hCurrProg, al_bool ClearReplaceData);
  202. /**
  203. * @brief psi monitor stop function.
  204. *
  205. * Stop psi monitor task, stop to monitor psi table and si table
  206. *
  207. * @param bExit[input] used to mark hang up psi monitor task or exit psi monitor.
  208. *
  209. * @return AL_SUCCESS stop is successful, AL_FAILURE otherwise.
  210. */
  211. AL_Return_t AL_PSI_Monitor_Stop(al_bool bExit, al_bool ClearReplaceData);
  212. /**
  213. * @brief get psi monitor running state function.
  214. *
  215. * Get dvb monitor current state.
  216. *
  217. * @param pbPsiMonState[output] psi monitor running state value.
  218. *
  219. * @return AL_SUCCESS get state is successful, AL_FAILURE otherwise.
  220. */
  221. AL_Return_t AL_PSI_Monitor_GetState(al_bool *pbPsiMonState);
  222. /**
  223. * @brief set psi monitor special spec
  224. *
  225. * Because different contry have different spec, example UK(DBook), this api to set special spec.
  226. *
  227. * @param eSpecConf[input] spec config
  228. *
  229. * @param eDynamicUpdate[input] psi monitor support dynamic update type
  230. *
  231. * @param pfPsiMonCheckSrvType[input] usded to check service type(TV/RADIO/DATA)
  232. *
  233. * @param pfPsiMonCheckNotVisible[input] usded to check service not visible
  234. *
  235. * @return AL_SUCCESS setup spec config is successful, AL_FAILURE otherwise.
  236. */
  237. AL_Return_t AL_PSI_Monitor_SetupConf(AL_PSIMon_SpecialSpec_t eSpecConf,
  238. AL_PsiMon_DynamicUpdate_Type_t eDynamicUpdate, AL_pfPsiMonCheckSrvType pfPsiMonCheckSrvType, AL_pfPsiMonCheckNotVisible pfPsiMonCheckNotVisible);
  239. void AL_PSI_Monitor_NotAddService(void);
  240. /**
  241. * @brief Get other tp service list from nit service list.
  242. *
  243. * Nit include other tp information, this function used to get other tp service list.
  244. *
  245. * @param psrv[output] other tp service list.
  246. *
  247. * @param pName service name
  248. *
  249. * @param pu16SrvNum[output] service total count.
  250. *
  251. * @return AL_SUCCESS get other tp services is successful, AL_FAILURE otherwise.
  252. */
  253. AL_Return_t AL_PSI_Monitor_GetOtherTpServList(AL_PSIMon_SimpleSrv_t *pSrv, al_uint8 *pName, al_uint16 *pu16SrvNum);
  254. #ifdef SUPPORT_NETWORK_UPDATE_RESCAN
  255. AL_Return_t AI_PSI_Monitor_UpdateCurrTpTSIDList(al_void);
  256. AL_Return_t AI_PSI_Monitor_GetVariedTpListFreq(al_uint32 *pu32TpListFreq);
  257. #endif
  258. /**
  259. * @brief Get current program audio component data.
  260. *
  261. * psi monitor received audio stream not do parse, store to cash buffer, provide to app get.
  262. *
  263. * @param pAudio[output] audio component data.
  264. *
  265. * @param pu16AudioNum[output] audio total count.
  266. *
  267. * @param pu16MinAudioPid[output] min audio pid.
  268. *
  269. * @param pu8VideoPidCount[output] video pid count.
  270. *
  271. * @return AL_SUCCESS get current program audio is successful, AL_FAILURE otherwise.
  272. */
  273. AL_Return_t AL_PSI_Monitor_GetCurrProgAudio(AL_PsiMon_AudioComp_t *pAudio,al_uint16 *pu16AudioNum,
  274. al_uint16 *pu16MinAudioPid, al_uint8 *pu8VideoPidCount);
  275. /**
  276. * @brief Get new srv position.
  277. *
  278. * For dispose service move descriptor, it is include new service information.
  279. *
  280. * @param pSrvPosition[output] new service information, service id/ts id/org net id.
  281. *
  282. * @return AL_SUCCESS get new service position is successful, AL_FAILURE otherwise.
  283. */
  284. AL_Return_t AL_PSI_Monitor_GetNewSrvPosition(AL_PsiMon_NewSrvPosition_t *pSrvPosition);
  285. /**
  286. * @brief psi monitor get FTA data.
  287. *
  288. * @ param pu8Data[output] the FTA data.
  289. *
  290. * @return AL_SUCCESS get dtg cmg data is successful, AL_FAILURE otherwise.
  291. */
  292. AL_Return_t AL_PSI_Monitor_GetFTAData(al_uint8 *pu8Data);
  293. /**
  294. * @brief psi monitor get CA data.
  295. *
  296. * @ param pu16Data[output] the CA data.
  297. *
  298. * @return AL_SUCCESS get CA data is successful, AL_FAILURE otherwise.
  299. */
  300. AL_Return_t AL_PSI_Monitor_GetCAData(al_uint16 *pu16Data);
  301. /**
  302. * @brief Check psi monitor sipsi state.
  303. *
  304. * This function used to check psi monitor sipsi info state,( NOT_RUNNING_REPLACEMENT_EXIST,
  305. * NOT_RUNNING_FLAG, SCRAMBLED_REPLACEMENT_EXIST, NOT_RUNNING_REPLACED, SCRAMBLED_REPLACED).
  306. *
  307. * @param u32State[input] sipsi state.
  308. *
  309. * @param pParam[output] sipsi state's parameter, program handle for replacement.
  310. *
  311. * @return al_ture if state exist, al_false if state not exist.
  312. */
  313. al_bool AL_PSI_Monitor_CheckState(al_uint32 u32State, AL_RecHandle_t *pParam);
  314. #ifdef __cplusplus
  315. }
  316. #endif
  317. #endif