cdbi.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /**
  2. * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
  3. *
  4. * @file
  5. *
  6. * @brief Provides common includes, macros, external declarations and definitions
  7. * of Common DataBase Interface module.
  8. *
  9. * @author liang.wu
  10. * @author jun.luo
  11. */
  12. #ifndef _CDBI_H_
  13. #define _CDBI_H_
  14. #include "db_common.h"
  15. #include "cdb.h"
  16. #include "tdb.h"
  17. #include "sdb.h"
  18. #include "adb.h"
  19. #include "sbtvddb.h"
  20. #ifdef __cplusplus
  21. extern "C"{
  22. #endif
  23. /**
  24. * @brief defines maxism number of callback function registered by upper layer.
  25. */
  26. #define MAX_CALLBACK_FP (10)
  27. /**
  28. * @brief The invalid record handle
  29. */
  30. #define CDBI_INVALID_HDL (0)
  31. /**
  32. * @brief It is an opaque type specific to the target platform. It is a unique identifier for each record.
  33. */
  34. typedef UINT32 CDBIHandle_t;
  35. /**
  36. * @brief Macro for CDBI Error calling prompt message
  37. */
  38. #define CDBI_FUNC_CALL(funcCall) do { \
  39. if ((funcCall) != DB_SUCCESS)\
  40. {\
  41. UMFDBG(0,"[Error]%s: %d Line ", __FUNCTION__, __LINE__); \
  42. UMFDBG(0,"%s return failed~\n", #funcCall);\
  43. } \
  44. } while(0)
  45. /**
  46. * @brief Enumeration of database type for CDBI internal use
  47. */
  48. typedef enum
  49. {
  50. DBTYPE_ATV = 0x01, /**< Analog channel database*/
  51. DBTYPE_T = 0x02, /**< Terrestrial channel database*/
  52. DBTYPE_C = 0x04, /**< Cable channel database*/
  53. DBTYPE_S = 0x08, /**< Satellite channel database*/
  54. DBTYPE_SBTVD= 0x20, /**< SBTVD channel database*/
  55. #if 1
  56. DBTYPE_OOB = 0x10, /**< Out-of-band channel database*/
  57. DBTYPE_MASK = DBTYPE_ATV|DBTYPE_T|DBTYPE_C|DBTYPE_S|DBTYPE_OOB, /**< database type mask*/
  58. #endif
  59. DBTYPE_DVB = 0x80, /**< DVB system*/
  60. #if 1
  61. DBTYPE_ATSC = 0x40, /**< ATSC system*/
  62. #endif
  63. } EDBInnerType_t;
  64. /**
  65. * @brief Enumeration of all the supported databases including DVB & ATSC
  66. */
  67. typedef enum
  68. {
  69. CDBI_DBTYPE_DVB_ATV = DBTYPE_DVB | DBTYPE_ATV, /**< DVB Analog channel database*/
  70. CDBI_DBTYPE_DVB_T = DBTYPE_DVB | DBTYPE_T, /**< DVB Terrestrial channel database*/
  71. CDBI_DBTYPE_DVB_C = DBTYPE_DVB | DBTYPE_C, /**< DVB Cable channel database*/
  72. CDBI_DBTYPE_DVB_S = DBTYPE_DVB | DBTYPE_S, /**< DVB Satellite channel database*/
  73. CDBI_DBTYPE_DVB_SBTVD = DBTYPE_DVB | DBTYPE_SBTVD, /**< SBTVD channel database*/
  74. #if 1
  75. CDBI_DBTYPE_ATSC_NTSC = DBTYPE_ATSC | DBTYPE_ATV, /**<NTSC - Analog channel database */
  76. CDBI_DBTYPE_ATSC_T = DBTYPE_ATSC | DBTYPE_T, /**<ATSC Terrestrial channel database */
  77. CDBI_DBTYPE_ATSC_C = DBTYPE_ATSC | DBTYPE_C, /**<ATSC Cable channel database */
  78. CDBI_DBTYPE_ATSC_S = DBTYPE_ATSC | DBTYPE_S, /**<ATSC Satellite channel database */
  79. CDBI_DBTYPE_ATSC_OOB = DBTYPE_ATSC | DBTYPE_OOB, /**<ATSC cable channel -- through OOB Stream */
  80. #endif
  81. #if 0
  82. CDBI_DBTYPE_ATSC_NTSC = CDBI_DBTYPE_ATSC | DBTYPE_ATV, /**<NTSC - Analog channel database */
  83. CDBI_DBTYPE_ATSC_T = CDBI_DBTYPE_ATSC | DBTYPE_T, /**<ATSC Terrestrial channel database */
  84. CDBI_DBTYPE_ATSC_C = CDBI_DBTYPE_ATSC | DBTYPE_C, /**<ATSC Cable channel database */
  85. CDBI_DBTYPE_ATSC_S = CDBI_DBTYPE_ATSC | DBTYPE_S, /**<ATSC Satellite channel database */
  86. CDBI_DBTYPE_ATSC_OOB = CDBI_DBTYPE_ATSC | CDBI_DBTYPE_OOB, /**<ATSC cable channel -- through OOB Stream */
  87. #endif
  88. } ECDBIDBType_t;
  89. /**
  90. * @brief Enumeration of all the supported record type
  91. */
  92. typedef enum
  93. {
  94. CDBI_RECTYPE_DVBTV = SERVICE_DVB_TV, /**< DVB TV record*/
  95. CDBI_RECTYPE_DVBRADIO = SERVICE_DVB_RADIO, /**< DVB Radio record*/
  96. CDBI_RECTYPE_DVBDATA = SERVICE_DVB_DATA, /**< DVB Data service record*/
  97. CDBI_RECTYPE_DVBSERVICE = SERVICE_DVB_ALL, /**< DVB TV or Radio or data record*/
  98. CDBI_RECTYPE_ATVSERVICE = SERVICE_ATV, /**< ATV channel record*/
  99. CDBI_RECTYPE_DVBNETWORK = 1 << 4, /**< DVB Network record*/
  100. CDBI_RECTYPE_DVBMULTIPLEX = 1 << 5, /**< DVB Mulitplex record*/
  101. } ECDBIRecordType_t;
  102. /**
  103. * @brief Defines data structure for upper layer to get database capacity
  104. */
  105. typedef struct
  106. {
  107. UINT32 MaxNetwork; /**< Max number of Network supported*/
  108. UINT32 MaxMultiplex; /**< Max number of Multiplex supported*/
  109. UINT32 MaxService; /**< Max number of Service supported*/
  110. } CDBICapability_t;
  111. /** None volatile memory read function prototype define */
  112. typedef EDBError_t (*pfNVMRead)(ECDBIDBType_t enDBType, UINT32 uiStart, UINT32 uiBytes, void *pBuff);
  113. /** None volatile memory write function prototype define */
  114. typedef EDBError_t (*pfNVMWrite)(ECDBIDBType_t enDBType, UINT32 uiStart, UINT32 uiBytes, void const *pBuff);
  115. /** Type define of None Volatile Memory operations */
  116. typedef struct
  117. {
  118. pfNVMRead fNVMRead;
  119. pfNVMWrite fNVMWrite;
  120. } DBNVMOperate_t;
  121. /**
  122. * @brief The prototype of the callback to be registed to match record(Service, Multiplex, Network),
  123. * used by:
  124. * 1.Search function, refer to CDBIFindRecord();
  125. * 2.Add record function, used to check the duplicate Record, refer to CDBIAddRecord().
  126. *
  127. * param - parameter for match function
  128. *
  129. * pRec - The record(Service, Multiplex, Network) exist in database
  130. *
  131. * if return value
  132. * = TRUE - Match pRecord with given condition
  133. * = FALSE - Not match pRecord with given condition
  134. */
  135. typedef bool (*fpCDBIRecMatch)(void *param, void const*pRec);
  136. /**
  137. * @brief The prototype of the callback to be registed to sort record(Service, Multiplex, Network),
  138. *
  139. * param pRec1, pRec2- pointer to the content of record(Service, Multiplex, Network) exist in database
  140. *
  141. * if return value
  142. * = 0 - Both services are of same type
  143. * +ve - The first record is greater than second record
  144. * -ve - The second record is greater than first record
  145. */
  146. typedef INT32 (*fpCDBIRecUserCmp)(void const *pRec1, void const *pRec2);
  147. /**
  148. * @brief The prototype of the callback to be registed to process duplicate records(Service, Multiplex, Network),
  149. *
  150. * peTuneType - tune type, duplicate service processing rule need this information
  151. * pePriSpec - Private spec type, duplicate service processing rule need this information
  152. * ucPreSSI, ucPreSQI - The Signal Strength and Quality for previous service
  153. * ucCurSSI, ucCurSQI - The Signal Strength and Quality for current service
  154. *
  155. * SSI -- Signal Strength Indicator;SQI -- Signal Quality Indicator
  156. *
  157. * if return value
  158. * = DB_DUPLIREC_RESERVE_FORMER - The former has high priority, discard the later or delete the latter if it has added
  159. * = DB_DUPLIREC_RESERVE_LATTER - The latter has high priority, discard the former or delete the former if it has added
  160. * = DB_DUPLIREC_RESERVE_ALL - Reserved two services, this behavior is required by some spec(such as Z-Book)
  161. */
  162. typedef EDBDupliRecStrategy_t (*fpCDBIGetDupliRecStrategy)(EDBTuneType_t *peTuneType, EDBPrivateSpec_t *pePriSpec, UINT8 ucPreSSI, UINT8 ucPreSQI, UINT8 ucCurSSI, UINT8 ucCurSQI);
  163. /**
  164. * @brief Defines data ructure for upper layer to set duplicate condtion for each record type
  165. */
  166. typedef struct
  167. {
  168. fpCDBIRecMatch pNetDupliChk; /**< Duplicate Network check callback */
  169. fpCDBIRecMatch pMultipDupliChk; /**< Duplicate Multiplex check callback */
  170. fpCDBIRecMatch pServDupliChk; /**< Duplicate Service check callback */
  171. } CDBIRecDupliChk_t;
  172. /**
  173. * @brief The prototype of the callback to be registed to set record to default value
  174. *
  175. * enDBType - The database type.
  176. *
  177. * eRecType - The Record type.
  178. *
  179. * pEntry - A pointer to the db entry that it will be reset.
  180. *
  181. * uiChannelIdx - Indicate the channel index.
  182. *
  183. */
  184. typedef void CDBISetRec2DefVal_t(ECDBIDBType_t enDBType, ECDBIRecordType_t eRecType, void const *pEntry, UINT32 uiChannelIdx);
  185. /**
  186. * @brief The callback function prototype for the db watcher
  187. * This will be called whenever there is a change in database.
  188. *
  189. * @note Please don't use whichever CDBI APIs when implement this callback to avoid deadlock.
  190. */
  191. typedef void CDBIWatcher_t(ECDBIDBType_t enDBType, EDBEvent_t enEVEType, void *pEntry);
  192. /**
  193. * @brief Initialize cdbi, assigne NVM handlers and operation parameters to RMGR etc.
  194. *
  195. * @param CDBIInitParam Contain NVM parameters and NVM handlers etc.
  196. *
  197. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  198. */
  199. EDBError_t CDBIInitialize(DBNVMOperate_t *CDBIInitParam);
  200. /**
  201. * @brief UnInitialize CDBI.
  202. *
  203. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  204. */
  205. EDBError_t CDBIUnInitialize(void);
  206. /**
  207. * @brief Check whether the given database module is active
  208. *
  209. * @param enDBType[in] specify which database.
  210. *
  211. * @param pActive[out] whether Active.
  212. *
  213. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  214. */
  215. EDBError_t CDBIGetDBModuleActive(ECDBIDBType_t enDBType, bool *pActive);
  216. /**
  217. * @brief active on inactive the specify DB module.
  218. *
  219. * @param enDBType[in] specify which database.
  220. *
  221. * @param bActive[in] active the specify DB module if true, else inactive this specify DB module.
  222. *
  223. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  224. */
  225. EDBError_t CDBIActiveDBModule(ECDBIDBType_t enDBType, bool bActive);
  226. /**
  227. * @brief active or deactive LCN procedures to process LCN for specify DB Module.
  228. *
  229. * @param enDBType[in] specify which database .
  230. *
  231. * @param bActive[in] active LCN procedure for enDBType if true, else inactive.
  232. *
  233. * @return DB_SUCCESS if succeed, error code otherwise.
  234. */
  235. EDBError_t CDBIActiveLCNProc4DB(ECDBIDBType_t enDBType, bool bActive);
  236. /**
  237. * @brief Reset given database
  238. *
  239. * @param enDBType specify which database to be reset
  240. *
  241. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  242. */
  243. EDBError_t CDBIResetDBModule(ECDBIDBType_t enDBType);
  244. /**
  245. * @brief Sync given database to storage device, like FLASH or EEPROM
  246. *
  247. * @param enDBType specify which database to sync
  248. *
  249. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  250. */
  251. EDBError_t CDBISyncDBModule(ECDBIDBType_t enDBType);
  252. /**
  253. * @brief Register Record default value setter.
  254. *
  255. * @param fpSetRec2DefVal The callback function pointer.
  256. *
  257. * @note This function only support reseting the detail of ATV Service to default value at present.
  258. *
  259. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  260. */
  261. EDBError_t CDBIRegisterDBRecDefValSetter(CDBISetRec2DefVal_t *fpSetRec2DefVal);
  262. /**
  263. * @brief Register database watcher to specified database with specified event
  264. *
  265. * @param enDBType specify which database to watch
  266. *
  267. * @param enEventType A set of events to watch
  268. *
  269. * @param fpWatcher callback function pointer
  270. *
  271. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  272. */
  273. EDBError_t CDBIRegisterDBWatcher(ECDBIDBType_t enDBType, EDBEvent_t enEventType, CDBIWatcher_t *fpWatcher);
  274. /**
  275. * @brief UnRegister database watcher to specified database with specified event
  276. *
  277. * @param fpWatcher callback function pointer
  278. *
  279. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  280. */
  281. EDBError_t CDBIUnRegisterDBWatcher(ECDBIDBType_t enDBType, EDBEvent_t enEventType, CDBIWatcher_t *fpUnWatcher);
  282. /**
  283. * @brief Register database match function to set duplicate condition by upper layer
  284. *
  285. * @param enDBType specify which database to watch
  286. *
  287. * @param pStFunc Pointer to a set of duplicate condtion for each record type
  288. *
  289. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  290. */
  291. EDBError_t CDBIRegisterRecMatchFunc(ECDBIDBType_t enDBType, CDBIRecDupliChk_t *pStFunc);
  292. /**
  293. * @brief Register callback to process duplicate service
  294. *
  295. * @param pFunc Function Pointer to get the process strategy when duplicate services exist,
  296. * it will be instead by inner default duplicate service processing procedure if it is NULL.
  297. *
  298. * @param peTuneType Current tune type.
  299. *
  300. * @param pePriSpec Private spec.
  301. *
  302. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  303. */
  304. EDBError_t CDBIRegisterDupliRecStrategy(fpCDBIGetDupliRecStrategy pFunc, EDBTuneType_t *peTuneType, EDBPrivateSpec_t *pePriSpec);
  305. /**
  306. * @brief Get database capacity by given database type
  307. *
  308. * @param enDBType specify which database to get
  309. *
  310. * @param pstCapbility pointer to Capability data structure
  311. *
  312. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  313. */
  314. EDBError_t CDBIGetCapability(ECDBIDBType_t enDBType, CDBICapability_t *pstCapbility);
  315. EDBError_t CDBIGetFirstRecordEx(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, CDBIHandle_t * hRec);
  316. EDBError_t CDBIGetNextRecordEx(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, CDBIHandle_t * hRec);
  317. /**
  318. * @brief Get first record handle by given database type and record type
  319. *
  320. * @param enDBType specify which database to get
  321. *
  322. * @param enRecType record type
  323. *
  324. * @param hRec the first record handle
  325. *
  326. * @note for getting Service, all deleted services will be ignored.
  327. *
  328. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  329. */
  330. EDBError_t CDBIGetFirstRecord(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, CDBIHandle_t *hRec);
  331. /**
  332. * @brief Get Next record handle by given current database handle
  333. *
  334. * @param hCurRec current record handle
  335. *
  336. * @param enRecType record type
  337. *
  338. * @param hNextRec next record handle
  339. *
  340. * @note for getting Service, all deleted services will be ignored.
  341. *
  342. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  343. */
  344. EDBError_t CDBIGetNextRecord(CDBIHandle_t hCurRec, ECDBIRecordType_t enRecType, CDBIHandle_t *hNextRec);
  345. /**
  346. * @brief Get Previous record handle by given current database handle
  347. *
  348. * @param hCurRec current record handle
  349. *
  350. * @param enRecType record type
  351. *
  352. * @param hPrevRec the previous record handle
  353. *
  354. * @note for getting Service, all deleted services will be ignored.
  355. *
  356. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  357. */
  358. EDBError_t CDBIGetPrevRecord(CDBIHandle_t hCurRec, ECDBIRecordType_t enRecType, CDBIHandle_t *hPrevRec);
  359. /**
  360. * @brief Get Last record handle by given database type and record type
  361. *
  362. * @param enDBType specify which database to get
  363. *
  364. * @param enRecType record type
  365. *
  366. * @param hRec the last record handle
  367. *
  368. * @note for getting Service, all deleted services will be ignored.
  369. *
  370. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  371. */
  372. EDBError_t CDBIGetLastRecord(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, CDBIHandle_t *hRec);
  373. /**
  374. * @brief This function is to get the next matching(the record for which the match function returns TRUE)
  375. * record handle by given search parameter.
  376. * @note
  377. * 1.You can use:
  378. * CDBIHandle_t phRec = CDBI_INVALID_HDL;
  379. * while (DB_SUCCESS == CDBIFindRecord(..., TRUE, &phRec))
  380. * {
  381. * ...
  382. * }
  383. * or
  384. * while (DB_SUCCESS == CDBIFindRecord(..., FALSE, &phRec))
  385. * {
  386. * ...
  387. * }
  388. * to get all the Records which match the given search condition, distinguish that:
  389. * The former has an ascending order and the latter has a descending order;
  390. * 2. The value of enRecType(parameter 2) can't use combinatorial key
  391. * such as CDBI_RECTYPE_DVBTV | CDBI_RECTYPE_DVBRADIO ;
  392. * 3. For Service Searching, the result maybe contain the deleted services,
  393. * which depend on the implement of fpMatchFunc;
  394. * 4. Only support Service Searching in fact currently...
  395. *
  396. * @param enDBType[in] specify which database to get.
  397. *
  398. * @param enRecType[in] record type, refer to ECDBIRecordType_t.
  399. *
  400. * @param fpMatchFunc[in] Match function registed by upper layer.
  401. *
  402. * @param pMatchParam[in] Match parameters for fpMatchFunc.
  403. *
  404. * @param bAscending Search ascending or descending
  405. *
  406. * @param phRec[in/out] pointer to record handle.
  407. *
  408. * @return DB_SUCCESS if succeed, error code otherwise.
  409. */
  410. EDBError_t CDBIFindRecord(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, fpCDBIRecMatch fpMatchFunc,
  411. void *pMatchParam, bool bAscending, CDBIHandle_t *phRec);
  412. /**
  413. * @brief Anather function used to get the numbers of matching(the record for which the match function returns TRUE)
  414. * record handle by given search parameter.
  415. * @note
  416. * Upper layer must given the buffer given by phRec to store service handls
  417. *
  418. * @param enDBType[in] specify which database to get.
  419. *
  420. * @param enRecType[in] record type, refer to ECDBIRecordType_t.
  421. *
  422. * @param fpMatchFunc[in] Match function registed by upper layer.
  423. *
  424. * @param pMatchParam[in] Match parameters for fpMatchFunc.
  425. *
  426. * @param bAscending[in] Search ascending or descending
  427. *
  428. * @param uiSkipNum[in] skip number of record
  429. *
  430. * @param phRec[in/out] one buffer used to store service handles.
  431. *
  432. * @param puiRecNum[in/out] specified the given buffer size and output the actural number of matched records .
  433. *
  434. * @return DB_SUCCESS if succeed, error code otherwise.
  435. */
  436. EDBError_t CDBIFindRecordExt(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, fpCDBIRecMatch fpMatchFunc,
  437. void *pMatchParam, bool bAscending, UINT32 uiSkipNum, CDBIHandle_t *phRec, UINT32 *puiRecNum);
  438. /**
  439. * @brief Get Record parant by record handle
  440. *
  441. * @param hChildRec child record handle
  442. *
  443. * @param hDstRec parent record handle
  444. *
  445. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  446. */
  447. EDBError_t CDBIGetParentRec(CDBIHandle_t hChildRec, CDBIHandle_t *hParentRec);
  448. /**
  449. * @brief Get the number of children for the given parent record handle
  450. *
  451. * @param hRec Parent record handle
  452. *
  453. * @param RecNum Number of children record
  454. *
  455. * @retval DB_SUCCESS means succss. DB_FAILURE means some error occurs.
  456. */
  457. EDBError_t CDBIGetNoOfChildrenRec(CDBIHandle_t hRec, UINT32 *RecNum);
  458. /**
  459. * @brief Get the next child for the the given record handle
  460. *
  461. * @param hParentRec Parent record handle
  462. *
  463. * @param phChildRec Child record handle
  464. *
  465. * @note
  466. * You can use:
  467. * CDBIHandle_t phRec = CDBI_INVALID_HDL;
  468. * while (DB_SUCCESS == CDBIChildRecTraversal(hParentRec, &phRec))
  469. * {
  470. * ...
  471. * }
  472. * to get all the child records.
  473. *
  474. * @retval DB_SUCCESS means succss. DB_FAILURE means the traversal is completed.
  475. */
  476. EDBError_t CDBIChildRecTraversal(CDBIHandle_t hParentRec, CDBIHandle_t *phChildRec);
  477. /**
  478. * @brief check whether has child record.
  479. *
  480. * @param hParentRec record handle, it can be network or multiplex
  481. *
  482. * @param bHasChild check its whether has child
  483. *
  484. * @param bHasGrandChild check its whehter has grand child,
  485. *
  486. *
  487. * @note
  488. * if hParentRec is mulplex, this para is invalid.
  489. *
  490. *
  491. * @return DB_SUCCESS if succeed, error code otherwise.
  492. */
  493. EDBError_t CDBIHasChildRec(CDBIHandle_t hParentRec, bool *bHasChild, bool *bHasGrandChild);
  494. /**
  495. * @brief check whether has child record.
  496. *
  497. * @return DB_SUCCESS if succeed, error code otherwise.
  498. */
  499. EDBError_t CDBICheckRecValid(CDBIHandle_t hRec, bool *bIsValid);
  500. /**
  501. * @brief Add new record into database
  502. *
  503. * @param enDBType specify which database to add
  504. *
  505. * @param enRecType record type
  506. *
  507. * @param pstRecDetails record details
  508. *
  509. * @param hParent to which current record is add(If current record don't has parent, given CDBI_INVALID_HDL)
  510. *
  511. * @param hRec record handle
  512. *
  513. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  514. */
  515. EDBError_t CDBIAddRec(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, void const *pstRecDetails,
  516. CDBIHandle_t hParent, CDBIHandle_t *hRec);
  517. #ifdef DVBS_DB_SUPPORT
  518. /**
  519. * @brief copy record, the old and new has the same parent
  520. *
  521. * @param hCurRec the old record handle
  522. *
  523. * @param hNewRec the new record handle
  524. *
  525. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  526. */
  527. EDBError_t CDBICopyRec(CDBIHandle_t hCurRec, CDBIHandle_t *hNewRec);
  528. #endif
  529. /**
  530. * @brief Update record field information by given member
  531. *
  532. * @param hRec specify the record to be update
  533. *
  534. * @param FieldValue pointer to field value
  535. *
  536. * @param pSymbol the member name
  537. *
  538. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  539. */
  540. EDBError_t CDBIUpdateRecBySymbol(CDBIHandle_t hRec, const void *FieldValue, UINT8 *pSymbol);
  541. /**
  542. * @brief Get record field information by given member
  543. *
  544. * @param hRec specify the record to be update
  545. *
  546. * @param FieldValue pointer to field value
  547. *
  548. * @param pSymbol the member name
  549. *
  550. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  551. */
  552. EDBError_t CDBIGetRecBySymbol(CDBIHandle_t hRec, void *FieldValue, UINT8 *pSymbol);
  553. /**
  554. * @brief Update record field information by given handle
  555. *
  556. * @param hRec specify the record to be update
  557. *
  558. * @param FieldValue pointer to field value
  559. *
  560. * @param Offset the offset start from first byte of the record data structure
  561. *
  562. * @param Length field length
  563. *
  564. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  565. */
  566. EDBError_t CDBIUpdateRec(CDBIHandle_t hRec, const void *FieldValue, UINT16 Offset, UINT16 Length);
  567. /**
  568. * @brief Get record field information by given handle
  569. *
  570. * @param hRec specify the record to be update
  571. *
  572. * @param FieldValue pointer to field value
  573. *
  574. * @param Offset the offset start from first byte of the record data structure
  575. *
  576. * @param Length field length
  577. *
  578. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  579. */
  580. EDBError_t CDBIGetRec(CDBIHandle_t hRec, void *FieldValue, UINT16 Offset, UINT16 Length);
  581. /**
  582. * @brief Remove record from database
  583. *
  584. * @param hRec specify the record to be update
  585. *
  586. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  587. */
  588. EDBError_t CDBIRemoveRec(CDBIHandle_t hRec);
  589. /**
  590. * @brief Get total number of certain type of record in database
  591. *
  592. * @note the deleted services will be ignored
  593. *
  594. * @param enDBType specify which database to get
  595. *
  596. * @param enRecType record type
  597. *
  598. * @param RecNum pointer to total number
  599. *
  600. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  601. */
  602. EDBError_t CDBIGetNoOfRecInDB(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, UINT32 *RecNum);
  603. /**
  604. * @brief Get record sorting list.
  605. *
  606. * @param enDBType specify which database to sort
  607. *
  608. * @param enRecType record type to sort
  609. *
  610. * @param pRecList record sorting list
  611. *
  612. * @param pRecNum number of records in sorting list
  613. *
  614. * @note Only used to -S service sorting list.
  615. *
  616. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  617. */
  618. EDBError_t CDBIGetRecSortList(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, CDBIHandle_t *pRecList, UINT16 *pRecNum);
  619. /**
  620. * @brief Sort record
  621. *
  622. * @param enDBType specify which database to sort
  623. *
  624. * @param enRecType record type to sort
  625. *
  626. * @param enSortType sorting method
  627. *
  628. * @param bAscending sort ascending or descending
  629. *
  630. * @note for parameter enRecType, because all services belong to one DB Module are handled by one list,
  631. * so CDBI_RECTYPE_DVBTV, CDBI_RECTYPE_DVBRADIO, CDBI_RECTYPE_DVBDATA is invalid)
  632. *
  633. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  634. */
  635. EDBError_t CDBISortRec(ECDBIDBType_t enDBtype, ECDBIRecordType_t enRecType, EDBSortType_t enSortType, bool bAscending);
  636. /**
  637. * @brief Sort record with cmp callback function provided by user
  638. *
  639. * @param enDBType specify which database to sort
  640. *
  641. * @param enRecType record type to sort
  642. *
  643. * @param pUserCmpCB record compare callback function
  644. *
  645. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  646. */
  647. EDBError_t CDBISortRecByUser(ECDBIDBType_t enDBType, ECDBIRecordType_t enRecType, fpCDBIRecUserCmp pUserCmpCB);
  648. /**
  649. * @brief Swap record
  650. *
  651. * @param hSrcRec1 the first record handle
  652. *
  653. * @param hSrcRec2 the second record handle
  654. *
  655. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  656. */
  657. EDBError_t CDBISwapRec(CDBIHandle_t hSrcRec1, CDBIHandle_t hSrcRec2);
  658. /**
  659. * @brief Move Src record to DstRec
  660. *
  661. * @param hSrcRec src record handle
  662. *
  663. * @param hDstRec dst record handle
  664. *
  665. * @param bFront move hSrcRec to the front of hDestRec if true, else move to the hind of hDestRec
  666. *
  667. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  668. */
  669. EDBError_t CDBIMoveRec(CDBIHandle_t hSrcRec, CDBIHandle_t hDstRec, bool bFront);
  670. /**
  671. * @brief Get Record type and database type by Record handle
  672. *
  673. * @param hRec record handle
  674. *
  675. * @param DBType database type of the record
  676. *
  677. * @param RecType record type of the record
  678. *
  679. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  680. */
  681. EDBError_t CDBIGetRecTypeAndDBType(CDBIHandle_t hRec, ECDBIDBType_t *DBType, ECDBIRecordType_t *RecType);
  682. #ifdef __cplusplus
  683. }
  684. #endif /* __cplusplus */
  685. #endif