/** * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved. * * @file * Common macros, declarations and definitions of Database. * * @author jun.luo * */ #ifndef __DB_COMMON_H__ #define __DB_COMMON_H__ #include "types.h" #include "gl_task.h" #include "umf_debug.h" #ifdef __cplusplus extern "C"{ #endif #define DB_DEBUG #ifndef DEBUG_LEVEL #define DEBUG_LEVEL DEBUG_LEVEL_ERRORS #endif #ifdef DB_DEBUG #undef DEBUG_PRINT #undef DEBUG_PRINTV #define DEBUG_PRINTV(fmt, arg...) UMFDBG(0,fmt, ##arg) #define DEBUG_PRINT(fmt, arg...) UMFDBG(0,fmt, ##arg) #define DB_ASSERT(condition, str) \ if (!(condition)) { \ do { \ DEBUG_PRINTV( "%s %d >> DB_ASSERT (%s) : \"%s\"\n", \ __FUNCTION__,__LINE__, #condition, str); \ }while(1); \ } #else #define DEBUG_PRINT(fmt, arg...) #define DEBUG_PRINTV(fmt, arg...) #define DB_ASSERT(condition, str) #endif #define DEBUG_LEVEL_NONE 0 #define DEBUG_LEVEL_ERRORS 1 #define DEBUG_LEVEL_WARNINGS 2 #define DEBUG_LEVEL_MESSAGES 3 #define DEBUG_LEVEL_ALL 4 #if (DEBUG_LEVEL >= DEBUG_LEVEL_MESSAGES) #define DEBUG_MESSAGE(fmt, arg...) DEBUG_PRINT(fmt, ##arg) #else #define DEBUG_MESSAGE(fmt, arg...) #endif #if (DEBUG_LEVEL >= DEBUG_LEVEL_WARNINGS) #define DEBUG_WARNING(fmt, arg...) DEBUG_PRINT(fmt, ##arg) #else #define DEBUG_WARNING(fmt, arg...) #endif #if (DEBUG_LEVEL >= DEBUG_LEVEL_ERRORS) #define DEBUG_ERROR(fmt, arg...) DEBUG_PRINT(fmt, ##arg) #else #define DEBUG_ERROR(fmt, arg...) #endif /** Macro define to get offset of item in a data structure */ #define DBITEM_OFFSET(type, field) ((UINT32)&(((type *)0)->field)) /** Macro define to get the size of item in a given data structure */ #define DBITEM_SIZE(type, field) (sizeof ((type *)0)->field) /** Macro define to get the maximum */ #define DBMAX(a, b) ((a) > (b) ? (a) : (b)) /** Exported constants */ enum { DB_DVB_MAX_NETNAME_LEN = 80, DB_DVB_MAX_MULTIPNAME_LEN = 14, DB_DVB_MAX_MULTIP_FREQ_NUM = 20, /**< Refer to Riks requirement , Actually we are not sure what is the maximum ? */ DB_DVB_MAX_CHNAME_LEN = 100, /**< Max DVB channel name length in bytes */ DB_DVB_MAX_AUDIO_NUM = 3, DB_DVB_MAX_PRV_COMP_NUM = 8, DB_ATV_MAX_CHNAME_LEN = 8, /**< Max Analog channel name length in bytes */ DB_DVB_INVALID_PID = 0x1fff, DB_DVB_INVALID_ID = 0x1fff, DB_DVB_MAX_SRV_TRD = 4, /**< Actually we are not sure what is the maximum ? */ DB_DVB_MAX_SRV_MAX_CICAM_BRANDS = 2, /**< One service support MAX CI CAM BRANDS */ TDB_MAX_TSNUM_WITHIN_NETWORK = 100, /**< Actually we are not sure what is the maximum ? */ }; /** Database Error type define */ typedef enum { DB_FAILURE = -1, DB_SUCCESS =0, DB_INVALID_PARAM, DB_CRC_ERROR, DB_ALLOC_FAILURE, } EDBError_t; /** Service type define */ typedef enum { SERVICE_DVB_TV = 1 << 0, SERVICE_DVB_RADIO = 1 << 1, SERVICE_DVB_DATA = 1 << 2, SERVICE_DVB_ALL = SERVICE_DVB_TV | SERVICE_DVB_RADIO | SERVICE_DVB_DATA, /**< Flexibilty for DB */ SERVICE_ATV = 1 << 3, SERVICE_TYPE_INVALID /**< Invalid Service */ } EServiceType_t; /** Tune type define */ typedef enum { DB_MANUAL_SEARCH, DB_AUTO_SEARCH, } EDBTuneType_t; /**< DVB private spec type define */ typedef enum { DB_DVB_PRISPEC_DBOOK = 0, /**< for UK, except ireland */ DB_DVB_PRISPEC_ZBOOK, /**< Italy */ DB_DVB_PRISPEC_AUS, /**< Australia */ DB_DVB_PRISPEC_NORDIG, /**< Nordig */ DB_DVB_PRISPEC_EBOOK, /**< pan Europe */ DB_DVB_PRISPEC_SBTVD, /**< Brazil */ DB_DVB_PRISPEC_OCA, /**< Reserved all service */ } EDBPrivateSpec_t; /** DVB delivery type define */ typedef enum { EDVB_DELIVER_TYPE_T, EDVB_DELIVER_TYPE_T2, EDVB_DELIVER_TYPE_C, EDVB_DELIVER_TYPE_C2, EDVB_DELIVER_TYPE_S, EDVB_DELIVER_TYPE_S2, EDVB_DELIVER_TYPE_ISDB_T, EDVB_DELIVER_TYPE_ATSC, } EDVBDeliveryType_t; /** Enumeration of sort types */ typedef enum { DB_SORTBY_NONE, /**< No Sort */ DB_SORTBY_NO, /**< Sort by Service Number */ DB_SORTBY_TYPE_INNER_NO, /**< Sort by Service Number within a service type */ DB_SORTBY_NAME, /**< Sort by Service Name */ DB_SORTBY_ID, DB_SORTBY_FREQ_INNER_NAME, /**< Sort by Service Frequency */ DB_SORTBY_FREQ, /**< Sort by Service Frequency(if rec is service, all services with equal freq will be list with its position in SDT) */ DB_SORTBY_FREQ_OCA, /*< same with DB_SORTBY_FREQ, and process the duplicate service to the list tail */ DB_SORTBY_SERVTYPE, /**< Sort by Service Type */ DB_SORTBY_USER, /**< Sort by User */ DB_TOTAL_SORTS } EDBSortType_t; /** The database events that are passed to the application through callback */ typedef enum { DB_SERVICE_INFO = 1 << 0, /**< Change in channel info(contain DVB service and ATV service) */ DB_MULTIPLEX_INFO = 1 << 1, /**< Change in Transponder info */ DB_NETWORK_INFO = 1 << 2, /**< Change in Network info */ DB_FULLDB_INFO = 1 << 3, /**< Change in full database */ DB_ENTRY_ADDED = 1 << 4, /**< Entry added */ DB_ENTRY_MODIFIED = 1 << 5, /**< Entry modified */ DB_ENTRY_DELETED = 1 << 6, /**< Entry deleted, means this entry can be restore, distinguish entry remove */ DB_ENTRY_REMOVED = 1 << 7, /**< Entry removed */ DB_ENTRY_HASNOCHILD = 1 << 8, /**< This entry is a superfluous record, because it has no child now */ DB_ENTRY_CHANGEPARENT = 1 << 9, /**< This entry has changed his parent */ DB_FULLDB_RESTORED = 1 << 10, /**< Restore whole Database module, case CRC error when load Database Module or case system is boot at first time */ DB_FULLDB_STORED = 1 << 11, /**< Sync whole Database module to none valitile memory */ DB_FULLDB_ISFULL = 1 << 12, /**< DB full */ } EDBEvent_t; /** the Record priority define if duplicate record exist */ typedef enum { DB_DUPLIREC_RESERVE_FORMER, /**< The former has high priority, discard the later or delete the latter if it has added */ DB_DUPLIREC_RESERVE_LATTER, /**< The latter has high priority, discard the former or delete the former if it has added */ DB_DUPLIREC_RESERVE_ALL, /**< Reserved two services, this behavior is required by some spec(such as Z-Book) */ } EDBDupliRecStrategy_t; /** Stream_type defined by MPEG2 Organization */ typedef enum { DB_STREAM_TYPE_VIDEO_MPEG1 = 0x01, DB_STREAM_TYPE_VIDEO_MPEG2 = 0x02, DB_STREAM_TYPE_AUDIO_MPEG1 = 0x03, DB_STREAM_TYPE_AUDIO_MPEG2 = 0x04, DB_STREAM_TYPE_PRIVATE_SECTION = 0x05, DB_STREAM_TYPE_PRIVATE_DATA = 0x06, DB_STREAM_TYPE_13522_MPEG = 0x07, DB_STREAM_TYPE_H220_13818_6_DSMCC = 0x08, DB_STREAM_TYPE_H220_13818_1 = 0x09, DB_STREAM_TYPE_MULTIPROTOCOL_ENCAP = 0x0A, DB_STREAM_TYPE_OBJECT_DATA_CAROUSEL = 0x0B, DB_STREAM_TYPE_DSMCC_DESCRIPTOR = 0x0C, DB_STREAM_TYPE_ANY_DSMCC_DATA = 0x0D, DB_STREAM_TYPE_VIDEO_MPEG4 = 0x10, DB_STREAM_TYPE_AUDIO_AAC = 0x11, DB_STREAM_TYPE_VIDEO_AVC = 0x1B, DB_STREAM_TYPE_AUDIO_AC3 = 0x81, DB_STREAM_TYPE_AUDIO_EAC3 = 0x87, DB_STREAM_TYPE_VC_1 = 0xEA, } EStreamType_t; /** Service type define, refer to service descriptor in 300468 */ typedef enum { DB_SERV_TYPE_RESERVED_FOR_FUTURE = 0x00, /**< service type of RESERVED_FOR_FUTURE*/ DB_SERV_TYPE_DIGITAL_TELEVISION = 0x01, /**< service type of DIGITAL_TELEVISION */ DB_SERV_TYPE_DIGITAL_RADIO = 0x02, /**< service type of DIGITAL_RADIO*/ DB_SERV_TYPE_TELETEXT = 0x03, /**< service type of TELETEXT*/ DB_SERV_TYPE_NVOD_REFERENCE = 0x04, /**< service type of NVOD_REFERENCE*/ DB_SERV_TYPE_NVOD_TIMESHIFT = 0x05, /**< service type of NVOD_TIMESHIFT*/ DB_SERV_TYPE_MOSAIC = 0x06, /**< service type of MOSAIC*/ DB_SERV_TYPE_PAL_CODED_SIGNAL = 0x07, /**< service type of PAL_CODED_SIGNAL*/ DB_SERV_TYPE_SECAM_CODED_SIGNAL = 0x08, /**< service type of SECAM_CODED_SIGNAL*/ DB_SERV_TYPE_D_D2_MAC = 0x09, /**< service type of D_D2_MAC*/ DB_SERV_TYPE_ADVANCED_DIGITAL_RADIO= 0x0A, /**< service type of ADVANCED_DIGITAL_RADIO*/ DB_SERV_TYPE_NTSC_CODED_SIGNAL = 0x0B, /**< service type of NTSC_CODED_SIGNAL*/ DB_SERV_TYPE_DATABROADCAST = 0x0C, /**< service type of DATABROADCAST*/ DB_SERV_TYPE_COMMON_INTERFACE = 0x0D, /**< service type of COMMON_INTERFACE*/ DB_SERV_TYPE_RCS_MAP = 0x0E, /**< service type of RCS_MAP*/ DB_SERV_TYPE_RCS_FLS = 0x0F, /**< service type of RCS_FLS*/ DB_SERV_TYPE_DVB_MHP = 0x10, /**< service type of DVB_MHP*/ DB_SERV_TYPE_MPEG2_HD_DIGITAL_TELEVISION= 0x11, /**< service type of MPEG2_HD_DIGITAL_TELEVISION*/ DB_SERV_TYPE_ADVANCED_SD_DIGITAL_TV= 0x16, /**< service type of ADVANCED_SD_DIGITAL_TV*/ DB_SERV_TYPE_ADVANCED_HD_DIGITAL_TV= 0x19, /**< service type ofn ADVANCED_HD_DIGITAL_TV*/ DB_SERV_TYPE_ADVANCED_HD_NVOD_TIMESHIFT= 0x1A, /**< service type of ADVANCED_HD_NVOD_TIMESHIFT*/ DB_SERV_TYPE_ADVANCED_HD_NVOD_REFERENCE= 0x1B, /**< service type of ADVANCED_HD_NVOD_REFERENCE*/ } EServSDTType_t; /** Service attribute define */ typedef struct { UINT32 fav1 : 1; /**< fave 1 bit*/ UINT32 fav2 : 1; /**< fave 2 bit*/ UINT32 fav3 : 1; /**< fave 3 bit*/ UINT32 fav4 : 1; /**< fave 4 bit*/ UINT32 fav5 : 1; /**< fave 5 bit */ UINT32 fav6 : 1; /**< fave 6 bit*/ UINT32 fav7 : 1; /**< fave 7 bit*/ UINT32 fav8 : 1; /**< fave 8 bit*/ UINT32 move : 1; /**< move bit*/ UINT32 skip : 1; /**< skip bit*/ UINT32 delete : 1; /**< delete bit*/ UINT32 unStable :1; /**