db_common.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /**
  2. * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
  3. *
  4. * @file
  5. * Common macros, declarations and definitions of Database.
  6. *
  7. * @author jun.luo
  8. *
  9. */
  10. #ifndef __DB_COMMON_H__
  11. #define __DB_COMMON_H__
  12. #include "types.h"
  13. #include "gl_task.h"
  14. #include "umf_debug.h"
  15. #ifdef __cplusplus
  16. extern "C"{
  17. #endif
  18. #define DB_DEBUG
  19. #ifndef DEBUG_LEVEL
  20. #define DEBUG_LEVEL DEBUG_LEVEL_ERRORS
  21. #endif
  22. #ifdef DB_DEBUG
  23. #undef DEBUG_PRINT
  24. #undef DEBUG_PRINTV
  25. #define DEBUG_PRINTV(fmt, arg...) UMFDBG(0,fmt, ##arg)
  26. #define DEBUG_PRINT(fmt, arg...) UMFDBG(0,fmt, ##arg)
  27. #define DB_ASSERT(condition, str) \
  28. if (!(condition)) { \
  29. do { \
  30. DEBUG_PRINTV( "%s %d >> DB_ASSERT (%s) : \"%s\"\n", \
  31. __FUNCTION__,__LINE__, #condition, str); \
  32. }while(1); \
  33. }
  34. #else
  35. #define DEBUG_PRINT(fmt, arg...)
  36. #define DEBUG_PRINTV(fmt, arg...)
  37. #define DB_ASSERT(condition, str)
  38. #endif
  39. #define DEBUG_LEVEL_NONE 0
  40. #define DEBUG_LEVEL_ERRORS 1
  41. #define DEBUG_LEVEL_WARNINGS 2
  42. #define DEBUG_LEVEL_MESSAGES 3
  43. #define DEBUG_LEVEL_ALL 4
  44. #if (DEBUG_LEVEL >= DEBUG_LEVEL_MESSAGES)
  45. #define DEBUG_MESSAGE(fmt, arg...) DEBUG_PRINT(fmt, ##arg)
  46. #else
  47. #define DEBUG_MESSAGE(fmt, arg...)
  48. #endif
  49. #if (DEBUG_LEVEL >= DEBUG_LEVEL_WARNINGS)
  50. #define DEBUG_WARNING(fmt, arg...) DEBUG_PRINT(fmt, ##arg)
  51. #else
  52. #define DEBUG_WARNING(fmt, arg...)
  53. #endif
  54. #if (DEBUG_LEVEL >= DEBUG_LEVEL_ERRORS)
  55. #define DEBUG_ERROR(fmt, arg...) DEBUG_PRINT(fmt, ##arg)
  56. #else
  57. #define DEBUG_ERROR(fmt, arg...)
  58. #endif
  59. /** Macro define to get offset of item in a data structure */
  60. #define DBITEM_OFFSET(type, field) ((UINT32)&(((type *)0)->field))
  61. /** Macro define to get the size of item in a given data structure */
  62. #define DBITEM_SIZE(type, field) (sizeof ((type *)0)->field)
  63. /** Macro define to get the maximum */
  64. #define DBMAX(a, b) ((a) > (b) ? (a) : (b))
  65. /** Exported constants */
  66. enum
  67. {
  68. DB_DVB_MAX_NETNAME_LEN = 80,
  69. DB_DVB_MAX_MULTIPNAME_LEN = 14,
  70. DB_DVB_MAX_MULTIP_FREQ_NUM = 20, /**< Refer to Riks requirement <frequency list descriptor>, Actually we are not sure what is the maximum ? */
  71. DB_DVB_MAX_CHNAME_LEN = 100, /**< Max DVB channel name length in bytes */
  72. DB_DVB_MAX_AUDIO_NUM = 3,
  73. DB_DVB_MAX_PRV_COMP_NUM = 8,
  74. DB_ATV_MAX_CHNAME_LEN = 8, /**< Max Analog channel name length in bytes */
  75. DB_DVB_INVALID_PID = 0x1fff,
  76. DB_DVB_INVALID_ID = 0x1fff,
  77. DB_DVB_MAX_SRV_TRD = 4, /**< Actually we are not sure what is the maximum ? */
  78. DB_DVB_MAX_SRV_MAX_CICAM_BRANDS = 2, /**< One service support MAX CI CAM BRANDS */
  79. TDB_MAX_TSNUM_WITHIN_NETWORK = 100, /**< Actually we are not sure what is the maximum ? */
  80. };
  81. /** Database Error type define */
  82. typedef enum
  83. {
  84. DB_FAILURE = -1,
  85. DB_SUCCESS =0,
  86. DB_INVALID_PARAM,
  87. DB_CRC_ERROR,
  88. DB_ALLOC_FAILURE,
  89. } EDBError_t;
  90. /** Service type define */
  91. typedef enum
  92. {
  93. SERVICE_DVB_TV = 1 << 0,
  94. SERVICE_DVB_RADIO = 1 << 1,
  95. SERVICE_DVB_DATA = 1 << 2,
  96. SERVICE_DVB_ALL = SERVICE_DVB_TV | SERVICE_DVB_RADIO | SERVICE_DVB_DATA, /**< Flexibilty for DB */
  97. SERVICE_ATV = 1 << 3,
  98. SERVICE_TYPE_INVALID /**< Invalid Service */
  99. } EServiceType_t;
  100. /** Tune type define */
  101. typedef enum
  102. {
  103. DB_MANUAL_SEARCH,
  104. DB_AUTO_SEARCH,
  105. } EDBTuneType_t;
  106. /**< DVB private spec type define */
  107. typedef enum
  108. {
  109. DB_DVB_PRISPEC_DBOOK = 0, /**< for UK, except ireland */
  110. DB_DVB_PRISPEC_ZBOOK, /**< Italy */
  111. DB_DVB_PRISPEC_AUS, /**< Australia */
  112. DB_DVB_PRISPEC_NORDIG, /**< Nordig */
  113. DB_DVB_PRISPEC_EBOOK, /**< pan Europe */
  114. DB_DVB_PRISPEC_SBTVD, /**< Brazil */
  115. DB_DVB_PRISPEC_OCA, /**< Reserved all service */
  116. } EDBPrivateSpec_t;
  117. /** DVB delivery type define */
  118. typedef enum
  119. {
  120. EDVB_DELIVER_TYPE_T,
  121. EDVB_DELIVER_TYPE_T2,
  122. EDVB_DELIVER_TYPE_C,
  123. EDVB_DELIVER_TYPE_C2,
  124. EDVB_DELIVER_TYPE_S,
  125. EDVB_DELIVER_TYPE_S2,
  126. EDVB_DELIVER_TYPE_ISDB_T,
  127. EDVB_DELIVER_TYPE_ATSC,
  128. } EDVBDeliveryType_t;
  129. /** Enumeration of sort types */
  130. typedef enum
  131. {
  132. DB_SORTBY_NONE, /**< No Sort */
  133. DB_SORTBY_NO, /**< Sort by Service Number */
  134. DB_SORTBY_TYPE_INNER_NO, /**< Sort by Service Number within a service type */
  135. DB_SORTBY_NAME, /**< Sort by Service Name */
  136. DB_SORTBY_ID,
  137. DB_SORTBY_FREQ_INNER_NAME, /**< Sort by Service Frequency */
  138. DB_SORTBY_FREQ, /**< Sort by Service Frequency(if rec is service, all services with equal freq will be list with its position in SDT) */
  139. DB_SORTBY_FREQ_OCA, /*< same with DB_SORTBY_FREQ, and process the duplicate service to the list tail */
  140. DB_SORTBY_SERVTYPE, /**< Sort by Service Type */
  141. DB_SORTBY_USER, /**< Sort by User */
  142. DB_TOTAL_SORTS
  143. } EDBSortType_t;
  144. /** The database events that are passed to the application through callback */
  145. typedef enum
  146. {
  147. DB_SERVICE_INFO = 1 << 0, /**< Change in channel info(contain DVB service and ATV service) */
  148. DB_MULTIPLEX_INFO = 1 << 1, /**< Change in Transponder info */
  149. DB_NETWORK_INFO = 1 << 2, /**< Change in Network info */
  150. DB_FULLDB_INFO = 1 << 3, /**< Change in full database */
  151. DB_ENTRY_ADDED = 1 << 4, /**< Entry added */
  152. DB_ENTRY_MODIFIED = 1 << 5, /**< Entry modified */
  153. DB_ENTRY_DELETED = 1 << 6, /**< Entry deleted, means this entry can be restore, distinguish entry remove */
  154. DB_ENTRY_REMOVED = 1 << 7, /**< Entry removed */
  155. DB_ENTRY_HASNOCHILD = 1 << 8, /**< This entry is a superfluous record, because it has no child now */
  156. DB_ENTRY_CHANGEPARENT = 1 << 9, /**< This entry has changed his parent */
  157. DB_FULLDB_RESTORED = 1 << 10, /**< Restore whole Database module, case CRC error when load Database Module or case system is boot at first time */
  158. DB_FULLDB_STORED = 1 << 11, /**< Sync whole Database module to none valitile memory */
  159. DB_FULLDB_ISFULL = 1 << 12, /**< DB full */
  160. } EDBEvent_t;
  161. /** the Record priority define if duplicate record exist */
  162. typedef enum
  163. {
  164. DB_DUPLIREC_RESERVE_FORMER, /**< The former has high priority, discard the later or delete the latter if it has added */
  165. DB_DUPLIREC_RESERVE_LATTER, /**< The latter has high priority, discard the former or delete the former if it has added */
  166. DB_DUPLIREC_RESERVE_ALL, /**< Reserved two services, this behavior is required by some spec(such as Z-Book) */
  167. } EDBDupliRecStrategy_t;
  168. /** Stream_type defined by MPEG2 Organization */
  169. typedef enum
  170. {
  171. DB_STREAM_TYPE_VIDEO_MPEG1 = 0x01,
  172. DB_STREAM_TYPE_VIDEO_MPEG2 = 0x02,
  173. DB_STREAM_TYPE_AUDIO_MPEG1 = 0x03,
  174. DB_STREAM_TYPE_AUDIO_MPEG2 = 0x04,
  175. DB_STREAM_TYPE_PRIVATE_SECTION = 0x05,
  176. DB_STREAM_TYPE_PRIVATE_DATA = 0x06,
  177. DB_STREAM_TYPE_13522_MPEG = 0x07,
  178. DB_STREAM_TYPE_H220_13818_6_DSMCC = 0x08,
  179. DB_STREAM_TYPE_H220_13818_1 = 0x09,
  180. DB_STREAM_TYPE_MULTIPROTOCOL_ENCAP = 0x0A,
  181. DB_STREAM_TYPE_OBJECT_DATA_CAROUSEL = 0x0B,
  182. DB_STREAM_TYPE_DSMCC_DESCRIPTOR = 0x0C,
  183. DB_STREAM_TYPE_ANY_DSMCC_DATA = 0x0D,
  184. DB_STREAM_TYPE_VIDEO_MPEG4 = 0x10,
  185. DB_STREAM_TYPE_AUDIO_AAC = 0x11,
  186. DB_STREAM_TYPE_VIDEO_AVC = 0x1B,
  187. DB_STREAM_TYPE_AUDIO_AC3 = 0x81,
  188. DB_STREAM_TYPE_AUDIO_EAC3 = 0x87,
  189. DB_STREAM_TYPE_VC_1 = 0xEA,
  190. } EStreamType_t;
  191. /** Service type define, refer to service descriptor in 300468 */
  192. typedef enum
  193. {
  194. DB_SERV_TYPE_RESERVED_FOR_FUTURE = 0x00, /**< service type of RESERVED_FOR_FUTURE*/
  195. DB_SERV_TYPE_DIGITAL_TELEVISION = 0x01, /**< service type of DIGITAL_TELEVISION */
  196. DB_SERV_TYPE_DIGITAL_RADIO = 0x02, /**< service type of DIGITAL_RADIO*/
  197. DB_SERV_TYPE_TELETEXT = 0x03, /**< service type of TELETEXT*/
  198. DB_SERV_TYPE_NVOD_REFERENCE = 0x04, /**< service type of NVOD_REFERENCE*/
  199. DB_SERV_TYPE_NVOD_TIMESHIFT = 0x05, /**< service type of NVOD_TIMESHIFT*/
  200. DB_SERV_TYPE_MOSAIC = 0x06, /**< service type of MOSAIC*/
  201. DB_SERV_TYPE_PAL_CODED_SIGNAL = 0x07, /**< service type of PAL_CODED_SIGNAL*/
  202. DB_SERV_TYPE_SECAM_CODED_SIGNAL = 0x08, /**< service type of SECAM_CODED_SIGNAL*/
  203. DB_SERV_TYPE_D_D2_MAC = 0x09, /**< service type of D_D2_MAC*/
  204. DB_SERV_TYPE_ADVANCED_DIGITAL_RADIO= 0x0A, /**< service type of ADVANCED_DIGITAL_RADIO*/
  205. DB_SERV_TYPE_NTSC_CODED_SIGNAL = 0x0B, /**< service type of NTSC_CODED_SIGNAL*/
  206. DB_SERV_TYPE_DATABROADCAST = 0x0C, /**< service type of DATABROADCAST*/
  207. DB_SERV_TYPE_COMMON_INTERFACE = 0x0D, /**< service type of COMMON_INTERFACE*/
  208. DB_SERV_TYPE_RCS_MAP = 0x0E, /**< service type of RCS_MAP*/
  209. DB_SERV_TYPE_RCS_FLS = 0x0F, /**< service type of RCS_FLS*/
  210. DB_SERV_TYPE_DVB_MHP = 0x10, /**< service type of DVB_MHP*/
  211. DB_SERV_TYPE_MPEG2_HD_DIGITAL_TELEVISION= 0x11, /**< service type of MPEG2_HD_DIGITAL_TELEVISION*/
  212. DB_SERV_TYPE_ADVANCED_SD_DIGITAL_TV= 0x16, /**< service type of ADVANCED_SD_DIGITAL_TV*/
  213. DB_SERV_TYPE_ADVANCED_HD_DIGITAL_TV= 0x19, /**< service type ofn ADVANCED_HD_DIGITAL_TV*/
  214. DB_SERV_TYPE_ADVANCED_HD_NVOD_TIMESHIFT= 0x1A, /**< service type of ADVANCED_HD_NVOD_TIMESHIFT*/
  215. DB_SERV_TYPE_ADVANCED_HD_NVOD_REFERENCE= 0x1B, /**< service type of ADVANCED_HD_NVOD_REFERENCE*/
  216. } EServSDTType_t;
  217. /** Service attribute define */
  218. typedef struct
  219. {
  220. UINT32 fav1 : 1; /**< fave 1 bit*/
  221. UINT32 fav2 : 1; /**< fave 2 bit*/
  222. UINT32 fav3 : 1; /**< fave 3 bit*/
  223. UINT32 fav4 : 1; /**< fave 4 bit*/
  224. UINT32 fav5 : 1; /**< fave 5 bit */
  225. UINT32 fav6 : 1; /**< fave 6 bit*/
  226. UINT32 fav7 : 1; /**< fave 7 bit*/
  227. UINT32 fav8 : 1; /**< fave 8 bit*/
  228. UINT32 move : 1; /**< move bit*/
  229. UINT32 skip : 1; /**< skip bit*/
  230. UINT32 delete : 1; /**< delete bit*/
  231. UINT32 unStable :1; /**<set program as unstable temporaryly when scan or servcie update */
  232. UINT32 parental_lock : 1; /**< parental lock bit*/
  233. UINT32 scramble : 1; /**< scramble bit*/
  234. UINT32 svrnotrun : 1; /**< */
  235. UINT32 svrtmp : 1; /**< temp service type */
  236. UINT32 mpeg4type : 1; /**< mpeg4 type */
  237. UINT32 videoavc : 1; /**< avc type */
  238. UINT32 notvisible : 1; /**< not visible */
  239. UINT32 notselectable : 1; /**< not selectable type */
  240. UINT32 freeca : 1; /**< free CA type */
  241. UINT32 nameModified :1; /**< program name modified by user */
  242. UINT32 NIDMatched :1; /**< network id matched */
  243. UINT32 ONIDMatched :1; /**< origine network matched */
  244. UINT32 ciplusused :1; /**< only ci plus direct tune and play used */
  245. UINT32 bInvalidService :1; /**< does this service exist in SDT,if yes it's valid (0).otherwise it's invalid (1). */
  246. UINT32 movestay : 1; /* need reserved move */
  247. UINT32 OCADupServLostFlag :1;/**< For Spain Channel Order */
  248. UINT32 SDServLostFlag :1; /**< For Germary Channel Order */
  249. UINT32 astraused :1; /**< only dvb-s astra used */
  250. UINT32 isProfileServ :1; /**< whether is profile service */
  251. UINT32 isVirtualChannel :1; /**< whether is virtual channel */
  252. } DBServAttrib_t;
  253. /** PES compnet define */
  254. typedef struct
  255. {
  256. UINT16 usDataPID; /**< pid value */
  257. UINT16 usStrmID; /**<stream id */
  258. UINT16/*EStreamType_t*/ usCodec; /**<stream codec */
  259. UINT16 usECMPID; /**< ecm pid*/
  260. UINT16 usCompTag; /**<mheg5 compnent tag */
  261. } DBPIDInfo_t;
  262. /** Prototype defined for store TRD Code */
  263. typedef struct
  264. {
  265. UINT8 u8DepthStatus; /**<0 means not found the TRD */
  266. UINT8 u8PrimaryCode;
  267. UINT8 u8SecondayCode;
  268. UINT16 u16TertiaryCode;
  269. } DBTRDCodeInfo_t;
  270. /**Define CAS system*/
  271. typedef enum{
  272. CAS_VIACCESS = 1,
  273. CAS_MEDIAGUA,
  274. CAS_IRDETO,
  275. CAS_NAGRA,
  276. CAS_NDS,
  277. CAS_CONAX,
  278. CAS_CRYPTOWO,
  279. CAS_ETC,//BISS
  280. CAS_MAX,
  281. }CASSystem_t;
  282. /** ci protection data struct */
  283. typedef struct
  284. {
  285. UINT8 u8hasShunningData;
  286. UINT8 u8freeCiModeFlag;
  287. UINT8 u8matchBrandFlag;
  288. UINT8 u8numberOfEntries;
  289. UINT16 u16entries[DB_DVB_MAX_SRV_MAX_CICAM_BRANDS];
  290. } DBCIProtection_t;
  291. #ifdef __cplusplus
  292. }
  293. #endif
  294. #endif