al_database.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. /**
  2. * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
  3. *
  4. * @file al_database.h
  5. *
  6. * The common interface to manipulate database record.
  7. *
  8. * @brief Gives the functionalities for quering as well as manipulating
  9. * the database record.
  10. *
  11. * @note .
  12. */
  13. #ifndef __AL_DATABASE_DBMERGE_H__
  14. #define __AL_DATABASE_DBMERGE_H__
  15. #include "al_basictypes.h"
  16. #include "cdbi.h"
  17. #include "db_lcn.h"
  18. #ifdef __cplusplus
  19. extern "C"{
  20. #endif
  21. /****************************************************
  22. * Macros definition
  23. ****************************************************//**
  24. * @addtogroup MacrosDef Macros definition
  25. * @{
  26. ********************************************************/
  27. /**
  28. * @brief Macros of invalid record handle
  29. *
  30. */
  31. #define AL_DB_INVALIDHDL CDBI_INVALID_HDL
  32. /**
  33. * @brief Get offset of detail field
  34. */
  35. #define FIELD_OFFSET(type, field) ((al_long)&(((type *)0)->field))
  36. #define FIELD_SIZEOF(type, field) (sizeof(((type *)0)->field))
  37. /****************************************************
  38. * Enumeration definition
  39. ****************************************************//**
  40. * @}
  41. * @addtogroup EnumDef Enumeration definition
  42. * @{
  43. ********************************************************/
  44. /**
  45. * @brief Enumeration of all the supported database type
  46. *
  47. */
  48. typedef enum
  49. {
  50. AL_DBTYPE_DVB_ATV = CDBI_DBTYPE_DVB_ATV, /**< Analog channel database */
  51. AL_DBTYPE_DVB_T = CDBI_DBTYPE_DVB_T, /**< DVB Terrestrial channel database */
  52. AL_DBTYPE_DVB_C = CDBI_DBTYPE_DVB_C, /**< DVB Cable channel database */
  53. AL_DBTYPE_DVB_S = CDBI_DBTYPE_DVB_S, /**< DVB Satellite channel database */
  54. #ifdef CONFIG_ISDB_SYSTEM
  55. AL_DBTYPE_DVB_SBTVD = CDBI_DBTYPE_DVB_SBTVD,
  56. #endif
  57. AL_DBTYPE_ATSC = CDBI_DBTYPE_ATSC_NTSC, /**< DVB Satellite channel database */
  58. AL_DBTYPE_DVB_DTVALL = (AL_DBTYPE_DVB_T
  59. | AL_DBTYPE_DVB_C
  60. | AL_DBTYPE_DVB_S
  61. #ifdef CONFIG_ISDB_SYSTEM
  62. | AL_DBTYPE_DVB_SBTVD
  63. #endif
  64. ),
  65. AL_DBTYPE_MAX,
  66. } AL_DB_EDBType_t;
  67. /**
  68. * @brief Enumeration of all the supported record type
  69. *
  70. */
  71. typedef enum
  72. {
  73. AL_RECTYPE_DVBTV = CDBI_RECTYPE_DVBTV, /**< DVB TV record*/
  74. AL_RECTYPE_DVBRADIO = CDBI_RECTYPE_DVBRADIO, /**< DVB Radio record*/
  75. AL_RECTYPE_DVBDATA = CDBI_RECTYPE_DVBDATA, /**< DVB Data service record*/
  76. AL_RECTYPE_DVBSERVICE = CDBI_RECTYPE_DVBSERVICE, /**< DVB TV or Radio or data record*/
  77. AL_RECTYPE_DVBNETWORK = CDBI_RECTYPE_DVBNETWORK , /**< DVB Network record*/
  78. AL_RECTYPE_DVBMULTIPLEX = CDBI_RECTYPE_DVBMULTIPLEX, /**< DVB Mulitplex record*/
  79. AL_RECTYPE_ATVSERVICE = CDBI_RECTYPE_ATVSERVICE, /**< ATV channel record*/
  80. AL_RECTYPE_MAX,
  81. } AL_DB_ERecordType_t;
  82. /**
  83. * @brief Enumeration of record operation request type.<br>
  84. * <b>Used in: </b>#AL_DB_GetRecord().
  85. */
  86. typedef enum
  87. {
  88. AL_DB_REQ_GETFIRST, /**< Getting first record handle, no need referenced handle.*/
  89. AL_DB_REQ_GETLAST, /**< Getting last record handle, no need referenced handle.*/
  90. AL_DB_REQ_GETNEXT, /**< Getting the next record handle of referenced handle.*/
  91. AL_DB_REQ_GETPREV, /**< Getting the previous record handle of referenced handle.*/
  92. AL_DB_REQ_GETPARENT, /**< Getting the parent record handle of referenced handle.*/
  93. } AL_DB_ERecordRequest_t;
  94. /**
  95. * @brief Enumeration of record move operation type.<br>
  96. * <b>Used in: </b>#AL_DB_MoveRecord().
  97. */
  98. typedef enum
  99. {
  100. /**
  101. * Move current record to the first place in its database, others go backward one by one.<br>
  102. * <b>No need referenced record.</b>
  103. */
  104. AL_DB_MV_FIRST,
  105. /**
  106. * Move current record to the last place in its database, others go forward one by one.<br>
  107. * <b>No need referenced record.</b>
  108. */
  109. AL_DB_MV_LAST,
  110. /**
  111. * Move current record to the front of the referenced service:
  112. * @li if current record locates front of the referenced service, others between them go forward one by one;
  113. * @li if current record locates behind of the referenced service, others between them go backward one by one.
  114. */
  115. AL_DB_MV_FRONT,
  116. /**
  117. * Move current record to the behind of the referenced service:
  118. * @li if current record locates front of the referenced service, others between them go forward one by one;
  119. * @li if current record locates behind of the referenced service, others between them go backward one by one.
  120. */
  121. AL_DB_MV_BEHIND,
  122. /**Swap current record and refereced record.*/
  123. AL_DB_MV_SWAP,
  124. } AL_DB_EMoveType_t;
  125. /**
  126. * @brief Enumeration of record sort operation type.<br>
  127. * <b>Used Funcs: </b>#AL_DB_SortRecords().
  128. */
  129. typedef enum
  130. {
  131. AL_DB_SORTBY_NONE, /**< No sort.*/
  132. AL_DB_SORTBY_NO, /**< Sort by program number.*/
  133. AL_DB_SORTBY_TYPE_INNER_NO, /**< Sort by program number within a service type. */
  134. AL_DB_SORTBY_NAME, /**< Sort by program name.*/
  135. AL_DB_SORTBY_ID, /**< Sort by service ID.*/
  136. AL_DB_SORTBY_FREQ_INNER_NAME, /**< Sort by frequency.*/
  137. AL_DB_SORTBY_FREQ, /**< Sort by frequency(if rec is service, all services within one freq will be list with its position in SDT).*/
  138. AL_DB_SORTBY_FREQ_OCA, /**< same with AL_DB_SORTBY_FREQ, and put the duplicate service to the list tail also.*/
  139. AL_DB_SORTBY_SERVTYPE, /**< Sort by service type.*/
  140. AL_DB_SORTBY_USER, /**< Sort by user defined method.*/
  141. AL_DB_SORT_ALL,
  142. } AL_DB_ESortType_t;
  143. /** Tune type define */
  144. typedef enum
  145. {
  146. AL_DB_MANUAL_SEARCH,
  147. AL_DB_AUTO_SEARCH,
  148. } AL_DBTuneType_t;
  149. /**< DVB private spec type define */
  150. typedef enum
  151. {
  152. AL_DB_DVB_PRISPEC_DBOOK = 0, /**< for UK, except ireland */
  153. AL_DB_DVB_PRISPEC_ZBOOK, /**< Italy */
  154. AL_DB_DVB_PRISPEC_AUS, /**< Australia */
  155. AL_DB_DVB_PRISPEC_NORDIG, /**< Nordig */
  156. AL_DB_DVB_PRISPEC_EBOOK, /**< pan Europe */
  157. AL_DB_DVB_PRISPEC_SBTVD, /**< Brazil */
  158. AL_DB_DVB_PRISPEC_OCA, /**< (Spain)Engel OCA need to save all Dupli service */
  159. } AL_DBPrivateSpec_t;
  160. /****************************************************
  161. * Structure definition
  162. ****************************************************//**
  163. * @}
  164. * @addtogroup StructDef Structure definition
  165. * @{
  166. ********************************************************/
  167. /**
  168. * @brief Structure of record handle
  169. */
  170. typedef CDBIHandle_t AL_RecHandle_t;
  171. /**
  172. * @brief Structure of record handle
  173. */
  174. typedef CDBICapability_t AL_DBCapability_t;
  175. /**
  176. * @brief Union of service detail.
  177. */
  178. typedef union
  179. {
  180. SADBServInfo_t stAnalogServ;
  181. STDBServInfo_t stDVBTServ;
  182. SCDBServInfo_t stDVBCServ;
  183. SDBServInfo_t stDVBSServ;
  184. #ifdef CONFIG_ISDB_SYSTEM
  185. SSBTVDDBServInfo_t stSBTVDServ;
  186. #endif
  187. } AL_ServiceDetail_t;
  188. /**
  189. * @brief Union of multiplex detail.
  190. */
  191. typedef union
  192. {
  193. STDBMultiplexInfo_t stDVBTMultiplex;
  194. SCDBMultiplexInfo_t stDVBCMultiplex;
  195. SDBMultiplexInfo_t stDVBSMultiplex;
  196. #ifdef CONFIG_ISDB_SYSTEM
  197. SSBTVDDBMultiplexInfo_t stSBTVDMultiplex;
  198. #endif
  199. } AL_MultiplexDetail_t;
  200. /**
  201. * @brief Union of network detail.
  202. */
  203. typedef union
  204. {
  205. STDBNetworkInfo_t stDVBTNetwork;
  206. SCDBNetworkInfo_t stDVBCNetwork;
  207. SDBNetworkInfo_t stDVBSNetwork;
  208. #ifdef CONFIG_ISDB_SYSTEM
  209. SSBTVDDBNetworkInfo_t stSBTVDNetwork;
  210. #endif
  211. } AL_NetworkDetail_t;
  212. /**
  213. * @brief Union record detail.
  214. */
  215. typedef union
  216. {
  217. AL_ServiceDetail_t stServInfo;
  218. AL_MultiplexDetail_t stTPInfo;
  219. AL_NetworkDetail_t stNetInfo;
  220. } AL_RecordDetail_t;
  221. /**
  222. * @brief User defined reset function to set default value after reset, refers to the usage of its prototype.
  223. */
  224. typedef CDBISetRec2DefVal_t AL_DB_ResetDefValFunc;
  225. /**
  226. * @brief User defined match function, refers to the usage of its prototype.
  227. */
  228. typedef fpCDBIRecMatch AL_DB_RecordMatchFunc;
  229. /**
  230. * @brief User defined record compare function, refers to the usage of its prototype.
  231. */
  232. typedef fpCDBIRecUserCmp AL_DB_RecordUserCmp;
  233. /**
  234. * @brief User defined group of match function for upper layer
  235. */
  236. typedef struct
  237. {
  238. AL_DB_RecordMatchFunc pNetMatch; /**< Network Match function callback */
  239. AL_DB_RecordMatchFunc pMulitplexMatch; /**< Multiplex Match function callback */
  240. AL_DB_RecordMatchFunc pServMatch; /**< Service Match function callback */
  241. } AL_DB_RecDupliChkFunc_t;
  242. /**
  243. * @brief start address for database in nonvolatile device.
  244. */
  245. typedef struct
  246. {
  247. pfNVMRead fNVMRead;
  248. pfNVMWrite fNVMWrite;
  249. } AL_DB_Init_t;
  250. /**
  251. * @brief Prototype define for create channel list with special attribute quickly
  252. */
  253. typedef struct
  254. {
  255. AL_DB_EDBType_t enDBType;
  256. AL_DB_ERecordType_t enRecType;
  257. BOOL bUsrSort; /* sort method */
  258. union
  259. {
  260. AL_DB_ESortType_t enSortType;
  261. AL_DB_RecordUserCmp pUserCmpCB;
  262. };
  263. AL_DB_RecordMatchFunc fpMatchFunc; /* record match function */
  264. void *pMatchParam;
  265. } AL_DB_SearchParam_t;
  266. /****************************************************
  267. * API definition - Component Operation
  268. ****************************************************//**
  269. * @}
  270. * @addtogroup COMAPI Component APIs
  271. * @{
  272. ********************************************************/
  273. /**
  274. * @brief Initialise database module
  275. *
  276. * @note This API must be called before any other APIs of this module
  277. *
  278. * @param pstInitParam [in] specify the start address of the database in
  279. * nonvolatile device, such as flash, EEPROM
  280. *
  281. * @return
  282. * #AL_SUCCESS indicates success,
  283. * On failure, #AL_FAILURE is returned.
  284. */
  285. AL_Return_t AL_DB_Init(const AL_DB_Init_t *pstInitParam);
  286. /**
  287. * @brief Synchronize data to physical storage .
  288. *
  289. * @note This API must be called after initialize function is called,
  290. * and must be called before terminate function is called.
  291. *
  292. * @param eDBType [in]Database type.
  293. * @param bIsBlocking [in]If set al_true, this API will not return until saving
  294. * data to flash is finished;if set al_false, no need to wait.
  295. *
  296. * @return
  297. * #AL_SUCCESS indicates success,
  298. * On failure, #AL_FAILURE is returned.
  299. */
  300. AL_Return_t AL_DB_Sync(AL_DB_EDBType_t eDBType, al_bool bIsBlocking);
  301. /**
  302. * @brief Synchronize data to physical storage .
  303. *
  304. * @note This API must be called after initialize function is called,
  305. * and must be called before terminate function is called.
  306. *
  307. * @param eDBType [in]Database type.
  308. * @param pstMatchFuc [in]pionter to Match function for each record type
  309. *
  310. * @return
  311. * #AL_SUCCESS indicates success,
  312. * On failure, #AL_FAILURE is returned.
  313. */
  314. AL_Return_t AL_DB_RegisterDupliChkFunc(AL_DB_EDBType_t eDBType, const AL_DB_RecDupliChkFunc_t *pstMatchFuc);
  315. /****************************************************//**
  316. * @brief Register callback to process duplicate service
  317. *
  318. * @param pFunc[in] Function Pointer to get the process strategy when duplicate services exist.
  319. * @param peTuneType[in] Current tune type.
  320. * @param pePriSpec[in] Private spec.
  321. *
  322. * @return
  323. * #AL_SUCCESS indicates success,
  324. * On failure, #AL_FAILURE is returned.
  325. ********************************************************/
  326. AL_Return_t AL_DB_RegisterDupliRecStrategy(fpCDBIGetDupliRecStrategy pFunc, AL_DBTuneType_t *peTuneType, AL_DBPrivateSpec_t *pePriSpec);
  327. /**
  328. * @brief Register Reset default value function
  329. *
  330. * @note Only used for ATV service at now.
  331. *
  332. * @param eDBType [in]Database type.
  333. * @param pfResetFuc [in]pionter to Reset function
  334. *
  335. * @return
  336. * #AL_SUCCESS indicates success,
  337. * On failure, #AL_FAILURE is returned.
  338. */
  339. AL_Return_t AL_DB_RegisterResetDefValFunc(AL_DB_ResetDefValFunc *pfResetFuc);
  340. /**
  341. * @brief Load deafault data setting to database.
  342. *
  343. * @note This API must be called after initialize function is called,
  344. * and must be called before terminate function is called.
  345. *
  346. * @param eDBType [in]Database type.
  347. * @param bIsBlocking [in]If set al_true, this API will not return until saving
  348. * data to flash is finished;if set al_false, no need to wait.
  349. *
  350. * @return
  351. * #AL_SUCCESS indicates success,
  352. * On failure, #AL_FAILURE is returned.
  353. */
  354. AL_Return_t AL_DB_SetDefault(AL_DB_EDBType_t eDBType, al_bool bIsBlocking);
  355. /**
  356. * @brief Reset database to empty.
  357. *
  358. * @note This API must be called after initialize function is called,
  359. * and must be called before terminate function is called.
  360. *
  361. * @param eDBType [in]Database type.
  362. * @param bIsBlocking [in]If set al_true, this API will not return until saving
  363. * data to flash is finished;if set al_false, no need to wait.
  364. *
  365. * @return
  366. * #AL_SUCCESS indicates success,
  367. * On failure, #AL_FAILURE is returned.
  368. */
  369. AL_Return_t AL_DB_Reset(AL_DB_EDBType_t eDBType, al_bool bIsBlocking);
  370. /**
  371. * @brief Get every component capabitlity of databse
  372. *
  373. * @param eDBType [in]Record handle.
  374. * @param pstCapability [in]Offset of field item in record detail.
  375. * @return
  376. * #AL_SUCCESS indicates success,
  377. * On failure, #AL_FAILURE is returned.
  378. */
  379. AL_Return_t AL_DB_GetCapability(
  380. AL_DB_EDBType_t eDBType,
  381. AL_DBCapability_t *pstCapability);
  382. /**
  383. * @brief Add new record to database.
  384. *
  385. * @param eDBType [in]Database type.
  386. * @param eRecType [in]Record type.
  387. * @param pstRecDetail [in]Added record detail, depend on practical detail type.
  388. * @param hParentHdl [in]If adding service record, the param must be multiplex handle;
  389. * if adding multiplex record, the param must be network handle
  390. * others, it will be ignored and assigned default #AL_DB_INVALIDHDL.
  391. * @param phRecHdl [out]Record handle, return #AL_DB_INVALIDHDL when adding failed.
  392. *
  393. * @return
  394. * #AL_SUCCESS indicates success,
  395. * On failure, #AL_FAILURE is returned.
  396. */
  397. AL_Return_t AL_DB_AddRecord(
  398. AL_DB_EDBType_t eDBType,
  399. AL_DB_ERecordType_t eRecType,
  400. const al_void * pstRecDetail,
  401. AL_RecHandle_t hParentHdl,
  402. AL_RecHandle_t *phRecHdl);
  403. /**
  404. * @brief Sort record logical sequence by specified command.
  405. *
  406. * @note This operation can not influence record physical sequence.
  407. *
  408. * @param eDBType [in]Databse type.
  409. * @param eDBType [in]Record type.
  410. * @param eSortCmd [in]Specify sort command type.
  411. * @param bAscending [in]al_true indecates sort by ascending,
  412. * and sort by descending will be set al_false.
  413. *
  414. * @return
  415. * #AL_SUCCESS indicates success,
  416. * On failure, #AL_FAILURE is returned.
  417. */
  418. AL_Return_t AL_DB_SortRecords(
  419. AL_DB_EDBType_t eDBType,
  420. AL_DB_ERecordType_t eRecType,
  421. AL_DB_ESortType_t eSortCmd,
  422. al_bool bAscending);
  423. /**
  424. * @brief Sort record logical sequence by specified sorting method provide by user.
  425. *
  426. * @note This operation can not influence record physical sequence.
  427. *
  428. * @param eDBType [in]Databse type.
  429. * @param eDBType [in]Record type.
  430. * @param fRecUserCmpCB [in]Specify sort method provided by user.
  431. *
  432. * @return
  433. * #AL_SUCCESS indicates success,
  434. * On failure, #AL_FAILURE is returned.
  435. */
  436. AL_Return_t AL_DB_SortRecordsByUser(
  437. AL_DB_EDBType_t eDBType,
  438. AL_DB_ERecordType_t eRecType,
  439. AL_DB_RecordUserCmp fRecUserCmpCB);
  440. /**
  441. * @brief Get children record number by its parent handle.
  442. *
  443. * @param hParentHdl [in]Parent record handle.
  444. * @param puiRecCnt [out]Record number.
  445. *
  446. * @return
  447. * #AL_SUCCESS indicates success,
  448. * On failure, #AL_FAILURE is returned.
  449. */
  450. AL_Return_t AL_DB_GetChildRecordNum(
  451. AL_RecHandle_t hParentHdl,
  452. al_uint32 *puiRecCnt);
  453. /**
  454. * @brief Get record handle without deleted record.
  455. *
  456. * @param eRequetCmd [in]Getting request command.
  457. * @param eDBType [in]Database type.
  458. * @param eRecType [in]Record type.
  459. * @param phRecHdl [in/out]Record handle.
  460. *
  461. * @return
  462. * #AL_SUCCESS indicates success,
  463. * On failure, #AL_FAILURE is returned.
  464. */
  465. AL_Return_t AL_DB_GetRecord(
  466. AL_DB_ERecordRequest_t eRequetCmd,
  467. AL_DB_EDBType_t eDBType,
  468. AL_DB_ERecordType_t eRecType,
  469. AL_RecHandle_t *phRecHdl);
  470. /****************************************************//**
  471. * @brief Get record handle by Index.
  472. *
  473. * @param eDBType [in]Database type.
  474. * @param eRecType [in]Record type.
  475. * @param bIndex [in]Record Index.
  476. * @param phRecHdl [out]Record handle.
  477. *
  478. * @return
  479. * #AL_SUCCESS indicates success,
  480. * On failure, #AL_FAILURE is returned.
  481. ********************************************************/
  482. AL_Return_t AL_DB_GetRecordByIndex(AL_DB_EDBType_t eDBType, AL_DB_ERecordType_t eRecType,
  483. al_uint8 bIndex, AL_RecHandle_t *phRecHdl);
  484. /****************************************************//**
  485. * @brief Get sorted record list.
  486. *
  487. * @note If wanna get service list, it will get all type services.
  488. *
  489. * @param eDBType [in]Databse type.
  490. * @param eRecType [in]Record type.
  491. * @param pRecList [in]Record list.
  492. * @param pRecNum [in]Number of records in list.
  493. *
  494. * @return
  495. * #AL_SUCCESS indicates success,
  496. * On failure, #AL_FAILURE is returned.
  497. ********************************************************/
  498. AL_Return_t AL_DB_GetRecordList (
  499. AL_DB_EDBType_t eDBType,
  500. AL_DB_ERecordType_t eRecType,
  501. AL_RecHandle_t *pRecList,
  502. al_uint16 *pRecNum);
  503. /**
  504. * @brief Get record handle by its parent handle.
  505. *
  506. * @note
  507. * If the input record is invalid record, will return the first child handle;@n
  508. * and if the input record is one valid child record, will return the next child handle.
  509. * @param hParentHdl [in]Parent record handle.
  510. * @param phRecHdl [in/out]Record handle.
  511. *
  512. * @return
  513. * #AL_SUCCESS indicates success,
  514. * On failure, #AL_FAILURE is returned.
  515. */
  516. AL_Return_t AL_DB_GetChildRecord(
  517. AL_RecHandle_t hParentHdl,
  518. AL_RecHandle_t *phRecHdl);
  519. /**
  520. * @brief check whether has child record.
  521. *
  522. * @return
  523. * #AL_SUCCESS indicates success,
  524. * On failure, #AL_FAILURE is returned.
  525. */
  526. AL_Return_t AL_DB_HasChildRecord(AL_RecHandle_t hRecHdl, al_bool *bHasChild, al_bool *bHasGrandChild);
  527. /**
  528. * @brief Get record handle by user-defined matching function.
  529. *
  530. * @param fRecMatch [in]Record matching function, implemented by user.
  531. * @param pMatchParam [in]Needed parameters of match function.
  532. * @param eDBType [in]Database tuye.
  533. * @param eRecType [in]Record type.
  534. * @param phRecHdl [out]The first matched record which behind of the referenced record;<br>
  535. * if hRefHdl = AL_DB_INVALIDHDL, indicates getting first matched record in database.
  536. *
  537. * @return
  538. * #AL_SUCCESS indicates success,
  539. * On failure, #AL_FAILURE is returned.
  540. */
  541. AL_Return_t AL_DB_GetMatchedRecord(
  542. AL_DB_RecordMatchFunc fRecMatch,
  543. al_void *pMatchParam,
  544. AL_DB_EDBType_t eDBType,
  545. AL_DB_ERecordType_t eRecType,
  546. AL_DB_ERecordRequest_t eReqCmd,
  547. AL_RecHandle_t *phRecHdl);
  548. /**
  549. * @brief Get database type and record type of record.
  550. *
  551. * @param hRecHdl [in]Record handle.
  552. * @param peDBType [out]Database type.
  553. * @param peRecType [out]Record type.
  554. *
  555. * @return
  556. * #AL_SUCCESS indicates success,
  557. * On failure, #AL_FAILURE is returned.
  558. */
  559. AL_Return_t AL_DB_GetRecordType(
  560. AL_RecHandle_t hRecHdl,
  561. AL_DB_EDBType_t *peDBType,
  562. AL_DB_ERecordType_t *peRecType);
  563. /**
  564. * @brief Move record to another place on logical sequence (in sorted list).
  565. *
  566. * @note
  567. * 1.Move record, the rest of records will be moved;
  568. * 2.Swap record, the rest of records won't be moved.
  569. *
  570. * @param eMoveCmd [in]Specify move command, contain move and swap commands.
  571. * @param hCurrRecHdl [in]Current rec handle.
  572. * @param hRefRecHdl [in]Referenced service handle,
  573. * its using depends on move command.
  574. *
  575. * @return
  576. * #AL_SUCCESS indicates success,
  577. * On failure, #AL_FAILURE is returned.
  578. */
  579. AL_Return_t AL_DB_MoveRecord(
  580. AL_DB_EMoveType_t eMoveCmd,
  581. AL_RecHandle_t hCurrRecHdl,
  582. AL_RecHandle_t hRefRecHdl);
  583. /**
  584. * @brief Remove record from physical storage.
  585. *
  586. * @note
  587. * 1.When remove one multiplex, all services belonged it will be removed;
  588. * 2.when remove one network, all muliplexes and services belonged it will be removed.
  589. *
  590. * @param hRecHdl [in]Record handle.
  591. *
  592. * @return
  593. * #AL_SUCCESS indicates success,
  594. * On failure, #AL_FAILURE is returned.
  595. */
  596. AL_Return_t AL_DB_RemoveRecord(AL_RecHandle_t hRecHdl);
  597. /**
  598. * @brief Get total number of records, without deleted records.
  599. *
  600. * @note
  601. * 1.For Analog service, get number of all inused services;
  602. * 2.For DVB service, get number of all undeleted services.
  603. *
  604. * @param eDBType [in]Databse type.
  605. * @param eRecType [in]Record type.
  606. * @param pu32Num [out]Total number of records.
  607. *
  608. * @return
  609. * #AL_SUCCESS indicates success,
  610. * On failure, #AL_FAILURE is returned.
  611. */
  612. AL_Return_t AL_DB_GetRecordsTotalNum(
  613. AL_DB_EDBType_t eDBType,
  614. AL_DB_ERecordType_t eRecType,
  615. al_uint32 *pu32Num);
  616. /****************************************************//**
  617. * @brief Get searched service list which match the searching condition.
  618. *
  619. * @param fRecMatch [in]Match function, refers to prototype #AL_DB_RecordMatchFunc.
  620. * @param pMatchParam [in]Parameter provided for match function, the type indicated by user.
  621. * @param eDBType [in]Database type.
  622. * @param eRecType [in]Record type.
  623. * @param hRecHdl [in]Record handle.
  624. * @param u32NeedNum [in]Specify upper limitation of searched records number.
  625. * @param u32SearchOffset [in]Specify passed records number,
  626. * and the rest of matched records will be add to the list.
  627. * @param pu32TotalNum [out]Total number of matched records.
  628. * @param pu32GotNum [out]The number of gotten records.
  629. * @param pstRecList [out]Searched records list.
  630. *
  631. * @return
  632. * #AL_SUCCESS indicates success,
  633. * On failure, #AL_FAILURE is returned.
  634. *
  635. ********************************************************/
  636. AL_Return_t AL_DB_SearchChildRecords(
  637. AL_DB_RecordMatchFunc fRecMatch,
  638. al_void *pMatchParam,
  639. AL_DB_EDBType_t eDBType,
  640. AL_DB_ERecordType_t eRecType,
  641. AL_RecHandle_t hRecHdl,
  642. al_uint32 u32NeedNum,
  643. al_uint32 u32SearchOffset,
  644. al_uint32 *pu32TotalNum,
  645. al_uint32 *pu32GotNum,
  646. AL_RecHandle_t *pstRecList);
  647. /**
  648. * @brief Get searched service list which match the searching condition.
  649. *
  650. * @param fRecMatch [in]Match function, refers to prototype #AL_DB_RecordMatchFunc.
  651. * @param pMatchParam [in]Parameter provided for match function, the type indicated by user.
  652. * @param eDBType [in]Database type.
  653. * @param eRecType [in]Record type.
  654. * @param u32NeedNum [in]Specify upper limitation of searched records number.
  655. * @param u32SearchOffset [in]Specify passed records number,
  656. * and the rest of matched records will be add to the list.
  657. * @param pu32TotalNum [out]Total number of matched records.
  658. * @param pu32GotNum [out]The number of gotten records.
  659. * @param pstRecList [out]Searched records list.
  660. *
  661. * @return
  662. * #AL_SUCCESS indicates success,
  663. * On failure, #AL_FAILURE is returned.
  664. */
  665. AL_Return_t AL_DB_SearchRecords(
  666. AL_DB_RecordMatchFunc fRecMatch,
  667. al_void *pMatchParam,
  668. AL_DB_EDBType_t eDBType,
  669. AL_DB_ERecordType_t eRecType,
  670. al_uint32 u32NeedNum,
  671. al_uint32 u32SearchOffset,
  672. al_uint32 *pu32TotalNum,
  673. al_uint32 *pu32GotNum,
  674. AL_RecHandle_t *pstRecList);
  675. AL_Return_t AL_DB_SearchRecordsExt(AL_DB_RecordMatchFunc fRecMatch, al_void *pMatchParam,
  676. AL_DB_EDBType_t eDBType, AL_DB_ERecordType_t eRecType, al_uint32 uiSkipNum, AL_RecHandle_t *pstRecList, al_uint32 *puiRecNum);
  677. /**
  678. * @brief Querys record detail.
  679. *
  680. * @param hRecHdl [in]Record handle.
  681. * @param pItemData [out]Record detail data.
  682. *
  683. * @return
  684. * #AL_SUCCESS indicates success,
  685. * On failure, #AL_FAILURE is returned.
  686. */
  687. AL_Return_t AL_DB_QueryDetail(AL_RecHandle_t hRecHdl, al_void *pDetailData);
  688. /**
  689. * @brief Update record detail.
  690. *
  691. * @param hRecHdl [in]Record handle.
  692. * @param pItemData [in]Record detail data.
  693. *
  694. * @return
  695. * #AL_SUCCESS indicates success,
  696. * On failure, #AL_FAILURE is returned.
  697. */
  698. AL_Return_t AL_DB_UpdateDetail(AL_RecHandle_t hRecHdl, const al_void *pDetailData);
  699. /**
  700. * @brief Query any one field of detail.
  701. *
  702. * @param hRecHdl [in]Record handle.
  703. * @param u32ItemOffset [in]Offset of field item in record detail.
  704. * @param u16ItemBytes [in]Byte length of field data.
  705. * @param pItemData [out]Specified detail field data.
  706. *
  707. * @return
  708. * #AL_SUCCESS indicates success,
  709. * On failure, #AL_FAILURE is returned.
  710. */
  711. AL_Return_t AL_DB_QueryDetailField(
  712. AL_RecHandle_t hRecHdl,
  713. al_uint16 u16ItemOffset,
  714. al_uint16 u16ItemBytes,
  715. al_void *pItemData);
  716. /**
  717. * @brief Query any one field of detail by field name.
  718. *
  719. * @param hRecHdl [in]Record handle.
  720. * @param pItemName [in]Field name, defined in detail structure.
  721. * @param pItemData [in]Specified detail field data.
  722. *
  723. * @return
  724. * #AL_SUCCESS indicates success,
  725. * On failure, #AL_FAILURE is returned.
  726. */
  727. AL_Return_t AL_DB_QueryDetailFieldByName(
  728. AL_RecHandle_t hRecHdl,
  729. al_uint8 *pItemName,
  730. al_void *pItemData);
  731. /**
  732. * @brief Update any one field of detail.
  733. *
  734. * @param hRecHdl [in]Record handle.
  735. * @param u32ItemOffset [in]Offset of field item in record detail.
  736. * @param u16ItemBytes [in]Byte length of field data.
  737. * @param pItemData [in]Specified detail field data.
  738. *
  739. * @return
  740. * #AL_SUCCESS indicates success,
  741. * On failure, #AL_FAILURE is returned.
  742. */
  743. AL_Return_t AL_DB_UpdateDetailField(
  744. AL_RecHandle_t hRecHdl,
  745. al_uint16 u16ItemOffset,
  746. al_uint16 u16ItemBytes,
  747. al_void *pItemData);
  748. /**
  749. * @brief Update any one field of detail by field name.
  750. *
  751. * @param hRecHdl [in]Record handle.
  752. * @param pItemName [in]Field name, defined in detail structure.
  753. * @param pItemData [in]Specified detail field data.
  754. *
  755. * @return
  756. * #AL_SUCCESS indicates success,
  757. * On failure, #AL_FAILURE is returned.
  758. */
  759. AL_Return_t AL_DB_UpdateDetailFieldByName(
  760. AL_RecHandle_t hRecHdl,
  761. al_uint8 *pItemName,
  762. al_void *pItemData);
  763. /****************************************************//**
  764. * @brief check whether has valid services.
  765. *
  766. * @param eDBType [in]Database type.
  767. *
  768. * @return
  769. * #AL_SUCCESS indicates success,
  770. * On failure, #AL_FAILURE is returned.
  771. ********************************************************/
  772. al_bool AL_DB_HasVisibleService(AL_DB_EDBType_t eDBType);
  773. /****************************************************//**
  774. * @brief Get channel list with special attributs(like scramble channel list, free channel list etc.)
  775. *
  776. * @param pSortParam sort parameters
  777. *
  778. * @param phRec input buffer
  779. *
  780. * @param uiRecNum buffer size
  781. *
  782. * @retval DB_SUCCESS means succss. DB_FAILURE means failed.
  783. ********************************************************/
  784. AL_Return_t AL_DB_GetRecSortListWithGivenParams(
  785. AL_DB_SearchParam_t *pSortParam, AL_RecHandle_t **phRec, UINT32 *puiRecNum);
  786. /****************************************************//**
  787. * @brief check record handle is valid
  788. *
  789. * @param hRecHdl [in]record handle
  790. *
  791. * @return
  792. * #AL_SUCCESS indicates success,
  793. * On failure, #AL_FAILURE is returned.
  794. ********************************************************/
  795. al_bool AL_DB_CheckRecValid(AL_RecHandle_t hRecHdl);
  796. /****************************************************//**
  797. * @}
  798. ********************************************************/
  799. #ifdef __cplusplus
  800. }
  801. #endif /* __cplusplus */
  802. #endif /* __AL_DATABASE_COMMON_H__*/