sipsiprv.h
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:16k
- #if !defined(SIPSIP_H)
- #define SIPSIP_H
- #include "gendef.h"
- typedef struct
- {
- UINT32 handle;
- KB_SIPatStruct* pstPat;
- UINT8 nType;
- INT8 nVersionNumber;
- INT8 nCurrVersionNumber;
- UINT8 nUsedFlag;
- }PATINFO;
- typedef struct
- {
- UINT32 handle;
- UINT16 nNitPid;
- KB_SINitStruct* pstNit;
- UINT8 nType;
- INT8 nVersionNumber;
- INT8 nCurrVersionNumber;
- UINT8 nUsedFlag;
- }NITINFO;
- typedef struct
- {
- UINT32 handle;
- UINT16 nProgramMapPid;
- UINT16 nSvcNO;
- KB_SIPmtStruct* pstPmt;
- UINT8 nType;
- INT8 nVersionNumber;
- INT8 nCurrVersionNumber;
- UINT8 nUsedFlag;
- }PMTINFO;
- typedef struct
- {
- UINT32 handle;
- INT32 nSvcID;
- INT16 nMaxServiceNum;
- KB_SISdtStruct* pstSdt;
- UINT8 nType;
- INT8 nVersionNumber;
- INT16 nServiceNum;
- INT8 nCurrVersionNumber;
- UINT8 nUsedFlag;
- }SDTINFO;
- typedef struct
- {
- UINT32 handle;
- INT32 nBouquetId;
- KB_SIBatStruct* pstBat;
- INT8 nBatNumber;
- UINT8 nType;
- INT8 nVersionNumber;
- INT8 nCurrVersionNumber;
- UINT8 nUsedFlag;
- }BATINFO;
- typedef struct
- {
- KB_SIEitPF* pstEitPresent;
- KB_SIEitPF* pstEitFollow;
- UINT32 handle;
- INT32 nSvcID;
- INT16 nTableId;
- UINT8 nType;
- INT8 nVersionNumber;
- INT8 nCurrVersionNumber;
- UINT8 nUsedFlag;
- }EITPFINFO;
- typedef struct
- {
- UINT32 handle;
- INT32 nSvcID;
- KB_SIEitSch* pstEinSchInfo;
- INT8 nTableDone[2];
- INT8 nCurrVersionNumber;
- INT8 nReceivedFlag[64*8];
- UINT8 nUsedFlag;
- }EITSCHINFO;
- typedef struct
- {
- UINT32 handle;
- INT16 nServiceNum;
- UINT16 nSvcID[KB_SI_MAX_EIT_SERVICE_NUM];
- KB_SIMultiEitSchedule* pstEinSchInfo;
- INT8 nTableDone[KB_SI_MAX_EIT_SERVICE_NUM][2];
- INT8 nCurrVersionNumber;
- INT8 CurrVerNo[KB_SI_MAX_EIT_SERVICE_NUM];
- INT8 nReceivedFlag[KB_SI_MAX_EIT_SERVICE_NUM][64*4];
- UINT8 nUsedFlag;
- }MULTEITSCHINFO;
- typedef struct
- {
- UINT32 handle;
- time_t* ptCurrentTime;
- UINT8 nUsedFlag;
- }TDTINFO;
- typedef struct
- {
- UINT32 handle;
- KB_SITot* pTot;
- UINT8 nUsedFlag;
- }TOTINFO;
- typedef struct
- {
- UINT32 handle;
- KB_SICatStruct* pstCat;
- UINT8 nType;
- INT8 nVersionNumber;
- INT8 nCurrVersionNumber;
- UINT8 nUsedFlag;
- }CATINFO;
- typedef struct
- {
- UINT32 handle;
- INT16 nMaxEventStatusNum;
- KB_SIRstStruct* pstRst;
- INT16 nEventStatusNum;
- UINT8 nUsedFlag;
- }RSTINFO;
- typedef struct
- {
- UINT32 whichChannel;
- BOOL checkCRC;
- UINT8* outputBuffer;
- UINT32 skipLength;
- UINT32 copyLength;
- void* tag;
- } T_DMX_Notify;
- typedef struct {
- UINT32 valid;
- UINT32 channelId;
- UINT32 subTableId;
- } T_ChannelToSubtable;
- typedef struct
- {
- UINT32 handle;
- KB_SIEitSchTimeShift* ptTimeShift;
- INT32 nSvcID;
- INT16 nTableId[1];
- INT8 nTableDone[1];
- INT8 nCurrVersionNumber;
- INT8 nReceivedFlag[64*4];
- UINT8 nUsedFlag;
- }T_EIT_SCHEDULE_TIME_SHIFT_PARA;
- enum
- {
- SI_UNKNOWN_ERROR = -11, /* -11 */
- SI_NO_FREE_SUBTABLES, /* -10 */
- SI_PROGRAM_NOT_FOUND, /* -9 */
- SI_MEMORY_FULL, /* -8 */
- SI_NO_AVAILABLE_CHANNELS, /* -7 */
- SI_NO_AVAILABLE_FILTERS, /* -6 */
- SI_INVALID_SECTION_DATA_ID, /* -5 */
- SI_OSP_ERROR, /* -4 */
-
- SI_OK = 0,
- SI_PROGRAM_EVENT_FOUND /* 1 */
- };
- #define SI_NO_EIT_PF_FILTERS (30)
- #define SI_NO_EIT_PF_TABLES_QUEUE (SI_NO_EIT_PF_FILTERS)
- #define SI_NO_EIT_SCHEDULE_TIME_SHIFT_FILTERS KB_SI_EIT_SCHEDULE_TIME_SHIFT_SOFT_FILTER_COUNT
- #define SI_EIT_SCHEDULE_SHIFT_FILTER_START_NUMBER (KB_SI_EIT_SCHEDULE_SOFT_FILTER_COUNT + SI_NO_EIT_PF_FILTERS)
- #define SI_EIT_SCHEDULE_SHIFT_FILTER_END_NUMBER (SI_EIT_SCHEDULE_SHIFT_FILTER_START_NUMBER + SI_NO_EIT_SCHEDULE_TIME_SHIFT_FILTERS)
- #define SI_NO_EIT_FILTERS (KB_SI_EIT_SCHEDULE_SOFT_FILTER_COUNT + SI_NO_EIT_PF_FILTERS)
- + (SI_NO_EIT_SCHEDULE_TIME_SHIFT_FILTERS)
- #define SI_NO_PMT_TABLES (2)
- #define SI_NO_PMT_TABLES_QUEUE (2)
- #define SI_NO_PMT_FILTERS (2)
- // SDT使用filter 0, BAT使用filter 1
- // PAT+NIT+SDT+(SI_NO_PMT_TABLES+SI_NO_PMT_FILTERS-1)+SI_NO_EIT_FILTERS+CAT+TDT+RST+BAT
- #define SI_DMX_NO_FILTERS (8 + (SI_NO_PMT_TABLES + SI_NO_PMT_FILTERS - 1) + SI_NO_EIT_FILTERS) + 1 /*dummy*/
- // PAT+NIT+SDT+EIT+CAT+TDT+RST+TOT+SI_NO_PMT_TABLES
- #define SI_DMX_NO_CHANNELS (8 + SI_NO_PMT_TABLES)
- #define SI_MAX_SUB_TABLES SI_DMX_NO_CHANNELS
- /*
- ** Specify the number of resource available
- */
- #define SI_MAX_SECTION_SMALL_DATA (80)
- #define SI_MAX_SECTION_LARGE_DATA (40)
- #define SI_MAX_SECTION_DATA (SI_MAX_SECTION_SMALL_DATA + SI_MAX_SECTION_LARGE_DATA)
- #define SI_MAX_SECTION_PER_TABLE (256)
- #define SI_DMX_BUFFER_SIZE (1024*4)
- /*
- ** Public Type definitions
- */
- typedef INT32 T_SubTableID;
- typedef struct
- {
- UINT32 length; /* The length of valid data in data[] */
- UINT8 *data;
- T_SubTableID subTableID; /* reference back to associated table */
- UINT32 filterNumber; /* Reference back to the filter which passed this section */
- }MepgData;
- typedef struct
- {
- INT32 total; /* Total number of sections. */
- INT32 received; /* Current number of recieved sections */
- UINT8 version; /* Current version of sections */
- UINT16 tableIDExt; /* Current extended table ID of sections */
- /* Pointer to the individual section data. */
- MepgData *sectionData[SI_MAX_SECTION_PER_TABLE];
- }T_SubTableData;
- typedef INT32 ((*T_TimeoutCallback)(UINT32));
- typedef struct
- {
- UINT32 enabled;
- UINT32 used; /* 使用该成员变量解决handle不匹配的问题 */
-
- INT32 tableID; /* Use -1 to indicate no filtering */
- INT32 tableIDExt; /* Use -1 to indicate no table extension */
- INT32 version; /* Use -1 to indicate no versioning */
- INT32 timeout; /* How long left for this filter (in SI Ticks) */
- UINT32 handle; /* Unique ID associated with this request. */
- UINT32 filterID; /* The ID of the demux filter */
- UINT32 filterNumber; /* The number of this filter in the channel */
- T_SubTableData data; /* Data which has passed this filter */
- T_SubTableID subTableID; /* Which sub table uses this filter */
- T_TimeoutCallback timeoutCallback;
- } T_SubTableFilter;
- typedef struct
- {
- /* Common to all filters */
- INT32 PID; /* Must be set to a valid PID; */
- UINT32 channelID; /* The ID of the demux channel */
- INT32 multipleSections; /* Standard SubTable format or not */
- /* Intial values for the filters. */
- INT32 tableID; /* Use -1 to indicate no filtering */
- INT32 tableIDExt; /* Use -1 to indicate no table extension */
- INT32 timeout; /* Timeout for the filter */
- /* The filters */
- UINT32 noFilters; /* The requested number of filters */
- UINT32 channelStarted;
- } T_SubTableDetails;
- typedef void ((*T_SubTableCallback)(T_SubTableID, UINT32, UINT32));
- typedef void ((*T_SectionCallback)(MepgData*));
- typedef void ((*T_SetupCallback)(T_SubTableID, UINT32, INT32, UINT32));
- typedef struct
- {
- T_SubTableDetails details;
- T_SubTableFilter *filter; /* Pointer to the array of filters */
-
- T_SectionCallback sectionCallback;
- T_SubTableCallback tableCallback;
- T_SetupCallback setupCallback;
- } T_SubTable;
- typedef enum
- {
- SI_MSG_COPY,
- SI_MSG_COMPLETED,
- SI_MSG_TIMER_TICK,
- MSG_SI_PAT_RECEIVE,
- MSG_SI_PAT_STOP_RECEIVE,
- MSG_SI_NIT_RECEIVE,
- MSG_SI_NIT_STOP_RECEIVE,
- MSG_SI_PMT_RECEIVE,
- MSG_SI_PMT_STOP_RECEIVE,
- MSG_SI_SDT_RECEIVE,
- MSG_SI_SDT_STOP_RECEIVE,
- MSG_SI_BAT_RECEIVE,
- MSG_SI_BAT_STOP_RECEIVE,
- MSG_SI_EIT_PF_RECEIVE,
- MSG_SI_EIT_PF_STOP_RECEIVE,
- MSG_SI_EIT_SCHEDULE_RECEIVE,
- MSG_SI_EIT_SCHEDULE_STOP_RECEIVE,
- MSG_SI_TDT_RECEIVE,
- MSG_SI_TDT_STOP_RECEIVE,
- MSG_SI_CAT_RECEIVE,
- MSG_SI_CAT_STOP_RECEIVE,
- MSG_SI_RST_RECEIVE,
- MSG_SI_RST_STOP_RECEIVE,
- MSG_SI_MULTI_EIT_SCHEDULE_RECEIVE,
- MSG_SI_MULTI_EIT_SCHEDULE_STOP_RECEIVE,
-
- MSG_SI_TOT_RECEIVE,
- MSG_SI_TOT_STOP_RECEIVE,
- MSG_SI_EIT_SCHEDULE_SHIFT_RECEIVE,
- MSG_SI_EIT_SCHEDULE_SHIFT_STOP_RECEIVE
- } T_SIMessageType;
- typedef struct
- {
- T_SIMessageType type;
- MepgData *sectionData;
- UINT32 handle;
- UINT32 filterNumber;
- }T_SIMessage;
- #define SI_SERVICE_TYPE_DTV 0x01
- #define KB_FILTER_SI_VIDEO_STREAM 0x02
- #define KB_FILTER_SI_AUDIO_STREAM 0x03
- #define KB_FILTER_SI_HIERACHY 0x04
- #define KB_FILTER_SI_REGISTRATION 0x05
- #define KB_FILTER_SI_DATA_STREAM_ALIGNMENT 0x06
- #define KB_FILTER_SI_TARGET_BACKGROUND_GRID 0x07
- #define KB_FILTER_SI_VIDEO_WINDOW 0x08
- #define KB_FILTER_SI_CA 0x09
- #define KB_FILTER_SI_LANGUAGE 0x0A /* PMT */
- #define KB_FILTER_SI_SYSTEM_CLOCK 0x0B
- #define KB_FILTER_SI_MULTIPLEX_BUFFER_USAGE 0x0C
- #define KB_FILTER_SI_COPYRIGHT 0x0D /* PMT */
- #define KB_FILTER_SI_MAXIMUM_BITRATE 0x0E
- #define KB_FILTER_SI_PRIVATE_DATA_INDICATOR 0x0F
- #define KB_FILTER_SI_SMOOTHING_BUFFER 0x10
- #define KB_FILTER_SI_STD 0x11
- #define KB_FILTER_SI_IBP 0x12
- //描述符tag
- #define KB_FILTER_SI_NETWORK_NAME 0x40
- #define KB_FILTER_SI_SERVICE_LIST 0x41
- #define KB_FILTER_SI_STUFFING 0x42 /* EIT, SDT */
- #define KB_FILTER_SI_SATELLITE_DELIVERY 0x43
- #define KB_FILTER_SI_CABLE_DELIVERY 0x44
- #define KB_FILTER_SI_BOUQUET_NAME 0x47 /* SDT */
- #define KB_FILTER_SI_SERVICE 0x48 /* SDT */
- #define KB_FILTER_SI_COUNTRY_AVAILABILITY 0x49 /* SDT */
- #define KB_FILTER_SI_LINKAGE 0x4A /* EIT, SDT */
- #define KB_FILTER_SI_NVOD_REFERENCE 0x4B /* SDT */
- #define KB_FILTER_SI_TIME_SHIFTED_SERVICE 0x4C /* SDT */
- #define KB_FILTER_SI_SHORT_EVENT 0x4D /* EIT */
- #define KB_FILTER_SI_EXTENDED_EVENT 0x4E /* EIT */
- #define KB_FILTER_SI_TIME_SHIFTED_EVENT 0x4F /* EIT */
- #define KB_FILTER_SI_COMPONENT 0x50 /* EIT */
- #define KB_FILTER_SI_MOSAIC 0x51 /* SDT, PMT */
- #define KB_FILTER_SI_STREAM_IDENTIFIER 0x52 /* PMT */
- #define KB_FILTER_SI_CA_IDENTIFIER 0x53 /* EIT, SDT */
- #define KB_FILTER_SI_CONTENT 0x54 /* EIT */
- #define KB_FILTER_SI_PARENTAL_RATING 0x55 /* EIT */
- #define KB_FILTER_SI_TELETEXT 0x56 /* PMT */
- #define KB_FILTER_SI_TELEPHONE 0x57 /* EIT, SDT */
- #define KB_FILTER_SI_LOCAL_TIME_OFFSET 0x58 /* TOT */
- #define KB_FILTER_SI_SUBTITLING 0x59 /* PMT */
- #define KB_FILTER_SI_TERRESTRIAL_DELIVERY 0x5A
- #define KB_FILTER_SI_MULTILINGUAL_NETWORK_NAME 0x5B
- #define KB_FILTER_SI_MULTILINGUAL_BOUQUET_NAME 0x5C
- #define KB_FILTER_SI_MULTILINGUAL_SERVICE_NAME 0x5D /* SDT */
- #define KB_FILTER_SI_MULTILINGUAL_COMPONENT 0x5E /* EIT */
- #define KB_FILTER_SI_PRIVATE_DATA_SPECIFIER 0x5F /* EIT, SDT, PMT */
- #define KB_FILTER_SI_SERVICE_MOVE 0x60 /* PMT */
- #define KB_FILTER_SI_SHORT_SMOOTHING_BUFFER 0x61 /* EIT */
- #define KB_FILTER_SI_FREQUENCY_LIST 0x62
- #define KB_FILTER_SI_PARTIAL_TRANSPORT_STREAM 0x63
- #define KB_FILTER_SI_DATA_BROADCAST 0x64 /* EIT, SDT */
- #define KB_FILTER_SI_CA_SYSTEM 0x65 /* PMT */
- #define KB_FILTER_SI_DATA_BROADCAST_ID 0x66 /* PMT */
- #define DMX_AVAILABLE 0
- #define DMX_ERROR -1
- #define DMX_CRC_CHECKED -2
- typedef struct
- {
- UINT32 size;
- UINT32* buffer;
- UINT32* end;
- UINT32* position;
- } SIFIFO;
- enum
- {
- LIFO_FULL = -10,
- LIFO_EMPTY,
- LIFO_OK = 0
- };
- static INT32 SIAlloc(void);
- static void SIFree(void);
- static INT32 SISubTableInitialize(void);
- static INT32 SISubTableDestroy(void);
- static T_SubTableID SISubTableCreate(T_SubTableDetails*, T_SectionCallback, T_SubTableCallback, T_TimeoutCallback, T_SetupCallback);
- static INT32 SIFreeSectionData(MepgData *section);
- static void SIFilterStopHelper(UINT32 channelID, T_SubTableFilter *filter);
- static void SIFilterStop(UINT32 channelID, T_SubTableFilter *filter);
- static void SIFilterDetach(UINT32 channelID, T_SubTableFilter *filter);
- static void SISubTableStop(T_SubTableID);
- static void SISubTableStart(T_SubTableID subTableID, UINT32 filterNumber, INT32 version, UINT32 handle);
- static BOOL SIHandleNewSection(UINT8* headerMPEGSection, T_DMX_Notify* notifyData);
- static void SISectionCopied(INT32 condition, UINT8* buffer, UINT32 length, void* tag);
- static void SITask(void);
- static void SISendTimerMessage(void);
- static void SIHandleTimerTick(void);
- static void SIStoreText(UINT8 *dst, UINT8 *src, UINT32 length);
- static INT32 LIFOInitialize(SIFIFO* lifo);
- static INT32 LIFOPush(SIFIFO* lifo, UINT32 newItem);
- static INT32 LIFOPop(SIFIFO* lifo, UINT32* item);
- static INT32 SIGetPAT(void);
- static INT32 SIGetNIT(void);
- static INT32 SIGetPmt(INT32 nPendingNo);
- static INT32 SIGetSDT(void);
- static INT32 SIGetBat(void);
- static INT32 SIGetEitPF(INT32 nPendingNo);
- static INT32 SIGetEitSCH(UINT32 nPendingNo);
- static INT32 SIGetMultEitSCH(void);
- static INT32 SIGetTDT(void);
- static INT32 SIGetCAT(void);
- static INT32 SIGetRst(void);
- static INT32 SIGetTOT(void);
- static INT32 SIStopPAT(void);
- static INT32 SIStopNIT(void);
- static INT32 SIStopPmt(INT32 nSvcID);
- static INT32 SIStopSdt(void);
- static INT32 SIStopBat(void);
- static INT32 SIStopEitSCH(INT32 nSvcID);
- static INT32 SIStopMultEitSCH(void);
- static INT32 SIStopTDT(void);
- static INT32 SIStopCAT(void);
- static INT32 SIStopRst(void);
- static INT32 SIStopTOT(void);
- static void SIParsePAT(MepgData* section);
- static void SIParseNIT(MepgData* section);
- static void SIParsePMT(MepgData* section);
- static void SIParseSDT(MepgData* section);
- static void SIParseEit(MepgData* section);
- static void SIParseCAT(MepgData* section);
- static void SIParseTDT(MepgData* section);
- static void SIParseRST(MepgData* section);
- static void SIParseTOT(MepgData* section);
- static INT32 SIParseTime(UINT8* pInData, time_t* pOutTime);
- static INT32 SIParseDuration(UINT8* pInData, UINT32* pOutDuration);
- static void SINITDescs(UINT8* pInData, INT32 dataLen, KB_SINitStruct* pstNit);
- static void SIPMTDescs(UINT8* pInData, INT32 dataLen, KB_SIPmtStruct* pstPmt, INT32 inLoop);
- static void SISDTDescs(UINT8* pInData, INT32 dataLen, KB_SISdtStruct* pstSdt);
- static void SIBATDescs(UINT8* pInData, INT32 dataLen, KB_SIBatStruct* pstBat, INT32 inLoop);
- static void SIEitPFDescs( UINT8* pInData, INT32 dataLen, KB_SIEitPF* pstEvent);
- static void SIEitSCHDescs( UINT8* pInData, INT32 dataLen, KB_SIEitSchEvent* pstEvent);
- static void SICATDescs(UINT8* pInData, INT32 dataLen, KB_SICatStruct* pstCat);
- static void SIHandlePat(T_SubTableID subTableID, UINT32 filterNumber, UINT32 handle);
- static void SIHandleNit(T_SubTableID subTableID, UINT32 filterNumber, UINT32 handle);
- static void SIHandlePmt(T_SubTableID subTableID, UINT32 filterNumber, UINT32 handle);
- static void SIHandleSdt(T_SubTableID subTableID, UINT32 filterNumber, UINT32 handle);
- static void SIHandleEit(T_SubTableID subTableID, UINT32 filterNumber, UINT32 handle);
- static void SIHandleCat(T_SubTableID subTableID, UINT32 filterNumber, UINT32 handle);
- static INT32 SIHandlePatTimeout(UINT32 filterID);
- static INT32 SIHandleNitTimeout(UINT32 filterID);
- static INT32 SIHandlePmtTimeout(UINT32 filterID);
- static INT32 SIHandleSdtTimeout(UINT32 filterID);
- static INT32 SIHandleEitTimeout(UINT32 filterID);
- static INT32 SIHandleTdtTimeout(UINT32 filterID);
- static INT32 SIHandleCatTimeout(UINT32 filterID);
- static INT32 SIHandleTotTimeout(UINT32 filterID);
- static void SIGetEitSCHShift(UINT32 nPendingNo, UINT32 nSvcID);
- static INT32 SIStopEitSCHShift(INT32 nSvcID, INT32 nTableId);
- static void SISectionEinSchInfo(MepgData *section);
- static INT32 SIStopEitSCHShiftEX(INT32 nSvcID, INT32 nTableId);
- static void SISectionEinSchInfoShift(MepgData *section);
- static void SISectionEITScheduleShiftDescriptors(UINT8* pInData,
- INT32 dataLen,
- KB_SIEitSchTimeShiftNode* pstEvent);
- #endif