/******************************************************************** * * PSI_Process.h - PSI Section Processing. (PSI). * * Copyright 2004~ DigitalSTREAMTechnology, Inc. * All Rights Reserved * * _Id: PSI_PsiSectGather.h ,v 1.0 2004/015/28 jina Exp ********************************************************************/ #ifndef DST_PSI_SECTGATHER_H_ #define DST_PSI_SECTGATHER_H_ #ifdef __cplusplus extern "C" { #endif #if !defined (_DSTHALERROR_H_) #include "dsthalerror.h" #endif /* * Section syntax macro definitions */ #define SECTION_TID 0 /* TID index */ #define SECTION_LEN_HI 1 /* length hi index */ #define SECTION_LEN_LO 2 /* length lo index */ #define SECTION_TID_EXT_HI 3 /* Table ID extension high index*/ #define SECTION_TID_EXT_LO 4 /* Table ID extension low index */ #define SECTION_VERSION 5 /* version number index */ #define SECTION_NUM 6 /* section number index */ #define SECTION_NUM_LAST 7 /* last section number index */ #define SECTION_HEADER_LENGTH 8 /* number of bytes in section header */ #define SECTION_LEN_MASK 0x0FFF /* length bit mask */ #define SECTION_VERSION_MASK 0x3E /* version number bit mask */ #define SECTION_VERSION_SHIFT 1 /* version number bit shift */ #define SECTION_CNI_MASK 0x01 /* current next indicator mask */ #define PID_MASK 0x1FFF /* Mask for various places a PID is used */ #define PSIMODE_EAGER_FLAG 8 /*Independency¸¦ À§ÇØ Á¤ÀÇ ÇÑ´Ù.*/ //#define PSI_Printf #ifdef DMALLOC #define PSI_Malloc malloc #define PSI_Free free #else void * PSI_Malloc( int iSize ); void PSI_Free( void *memBlock ); #endif //#if 0 /* * PSImode defines the type of PSI processing to do */ typedef enum { privateMode = 0, /* Takes data not in section syntax */ sectionMode = 1, /* Take a single section */ tableMode = 2, /* Take a table made of multiple sections */ eagerTableMode = 10, /* Same as tableMode but also send psiSectionReceived events */ segmentTableMode = 11, /* Same as tableMode but also checks segment_last_section_number */ segmentOnlyMode = 12, /* Same as tableMode but receive only 1 segment */ segmentEagerMode = 13, si_privateTableMode_RD = 16, si_eagerPrivateTableMode_RD = 32 }PSIMode; /* * PSIUpdateMode defines what to do when an event is sent to the client */ typedef enum { psiOneShot = 1, /* Filter must be reset for more data to come in. */ psiVersionChange, /* Event is sent every time the version changes */ psiCRCChange, /* Event is sent every time any CRC changes */ psiContinuous, /* Event is sent every time filter matches */ }PSIUpdateMode; /* * PSI events */ typedef enum { psiNoEvent = 0, /* Null event used internally and is never sent */ /* The following events are sent to all eventProcs monitoring a given PID */ /* They are the same as the corresponding pes events */ psiDup3Packet, /* Three duplicate transport packets */ psiLostPacket, /* Lost transport packet */ psiDiscontinuity, /* Discontinuity_indicator set at transport */ psiSplicingPoint, /* Splicing point reached */ psiSyncErr, /* Section straddling transport packets incorrectly terminated */ psiScrambledErr, /* Sections are scrambled. DemuxDev disabled */ /* The following events are sent to only one eventProc */ psiSectionReceived = 10,/* Eager only - A section has been received within a table. More to come */ psiDataReceived, /* Data is available. Load is complete */ psiMemoryError, /* Out of CPU memory trying to allocate buffer space */ psiSectionTooBig, /* A section was received which was larger than maxData */ psiCRCError, /* CRC error occurred.*/ psiVersionChanged, /* Eager only - Version changed, restarting table collection */ psiCRCUnchanged, /* Eager sectionMode psiCRCChange only - The CRC is the same as for the last table */ psiMaxSectionOverflow, /* Table mode only - Actual # of sections > requested maxSections */ psiLastSectionOverflow, /* Table mode only - section # > last_section # */ psiARIBEmmReceived, /* Event for ARIB EMM messages */ psiARIBIndivEmmReceived, /* Event for ARIB EMM individual messages */ psiARIBCommonEmmReceived, /* Event for ARIB EMM common messages */ psiFifoFullEvent, /* Event for FIFO full condition in Linux */ killUserTask = 1000 /* Linux event notification to user space to terminate task */ }PSIEvent; #define DYNARRAY_SECTPTR 256 /* Debugger thinks there is this many anreies */ typedef struct PSIDataArray_t { struct PSIContext_t *context; /* request ID */ DS_U16 pid; /* pid which this section came from */ DS_S32 numSections; /* number of section */ DS_S32 maxSections; /* max number of sections structure can hold */ DS_U8 *sectPtr[DYNARRAY_SECTPTR]; /* dynamic array of 1 or more section pointers */ DS_U8 lastSegmentNumber[DYNARRAY_SECTPTR]; }PSIDataArray_t; typedef struct PSIEventProcData_t { PSIDataArray_t *desc; DS_U32 err; DS_U32 hEvent; }PSIEventProcData_t; #define PSIDescriptorSize(nelem) (sizeof(PSIDataArray_t) + \ ((nelem)-DYNARRAY_SECTPTR)*sizeof(DS_U8 *)) #define PSISectionLength(ptr) ((((ptr[1])<<8)+(ptr[2]))&0x0FFF) typedef enum PSIFieldSelect_k { TOP_FIELD = 0x00, BOTTOM_FIELD = 0x10, BOTH_FIELDS = 0x02 } PSIFieldSelect_k; typedef struct PSIMaskByte_t { DS_U8 value; DS_U8 matchMask; DS_U8 noMatchMask; }PSIMaskByte_t; #define DYNARRAY_PSIMaskEntry 16 /* Debugger thinks there is this many entries */ typedef struct PSIMask_t { int numEntries; /* size of psiFilter */ PSIMaskByte_t entries[DYNARRAY_PSIMaskEntry]; /* Variable number of filter entries */ } PSIMask_t; #define PSIMaskSize(nelem) (sizeof(PSIMask_t) + \ ((nelem)-DYNARRAY_PSIMaskEntry)*sizeof(PSIMaskByte_t)) //typedef void (*PSIEventProc)(PSIEvent event, PSIControl *psiCtl, DS_U32 userParam); typedef void (*PSIEventProc_f)(PSIEvent event , void* pPsiInfo , DS_U32 userParam ); typedef void (*PSIRegisterProc_f)( DS_U32 userParam1 , DS_U32 userParam2 ); //JFET_20050614 //FOR THE GEMSTAR EPG typedef void (*GemstarUserCallBack)(DS_U8* sectPtr); typedef struct PSIContext_t { void *pParent; DS_U16 pid; DS_S32 selfIndex; /* start section index or self */ PSIMode psiMode; /* The PSI data collection mode */ PSIUpdateMode updateMode; /* The PSI update mode */ DS_S32 maxData; /* Max bytes per section */ DS_S32 maxSections; /* Max number of sections to collect */ DS_S32 curSection; /* The last section received */ DS_S32 version; /* Version number for table being gathered */ PSIEventProc_f eventProc; /* The event upcall */ DS_U32 userParam; /* User data to pass to upcall */ DS_U32 lastCRC; /* Used for siCRCChange */ DS_U32 runningCRC; /* Used to combine all CRC's for sections in table */ DS_BOOL lastCRCValid; /* TRUE if lastCRC has valid data */ DS_BOOL oneShot; /* whether or not this is a oneShot */ PSIDataArray_t *curDataArray; /* A complete descriptor waiting to be taken */ PSIDataArray_t *nextDataArray; /* An incomplete descriptor for data still being gathered */ DS_U8 lastVersion; PSIMask_t *psiMask; PSIRegisterProc_f stopProc; DS_U32 userParamStop; DS_BOOL bRegistered; DS_U8 segment_number; }PSIContext_t; struct PSIContext_t *DD_PSI_AllocPSIContext(void); void DD_PSI_FreePSIContext( struct PSIContext_t *pPsiContext ); DHL_RESULT DD_PSI_GetEmptyPSIMask( DS_S32 numEntries, PSIMask_t **ppMask ); DHL_RESULT DD_PSI_GetTIDPSIMask(struct PSIMask_t **ppMask, DS_U8 TID, DS_BOOL current_next_indicator); DHL_RESULT DD_PSI_GetExTIDPSIMask(struct PSIMask_t **ppMask, DS_U8 TID, DS_U16 TIDExtension, DS_BOOL current_next_indicator); DHL_RESULT DD_PSI_GetExTIDFieldPSIMask( struct PSIMask_t **ppMask, DS_U8 TID, DS_U16 TIDExtension, PSIFieldSelect_k whichField, DS_BOOL current_next_indicator); DHL_RESULT DD_PSI_GetDvbEitMask( PSIMask_t **ppMask, DS_U8 TID, DS_U16 TIDExtension, DS_U8 segment_number, DS_BOOL current_next_indicator); DHL_RESULT DD_PSI_GetETTPSIMask( struct PSIMask_t **ppMask, DS_U8 TID, DS_U32 ETM_id, DS_BOOL current_next_indicator); DHL_RESULT DD_PSI_GetDsmccPSIMask( PSIMask_t **ppMask, DS_U8 TID, DS_U32 DsmccMessageId, DS_BOOL current_next_indicator); DHL_RESULT DD_PSI_GetDsmccPSIMaskEx( PSIMask_t **ppMask, DS_U8 TID, DS_U32 DsmccMessageId, DS_BOOL current_next_indicator, int segment_number); DHL_RESULT DD_PSI_ReadPSIArray( struct PSIContext_t *psi , struct PSIDataArray_t **returnArray); void DD_PSI_FreePSIArray(PSIDataArray_t *psi); DHL_RESULT DD_PSI_GetLastReceivedSection( PSIContext_t *psiCtl, DS_BOOL detach, DS_S32 *returnSectionNumber, DS_S32 *returnLastSectionNumber, DS_U8 **returnSectionData); typedef DS_U8 *P_DS_U8; DHL_RESULT DD_PSI_GetLastReceivedSegment( PSIContext_t *psiCtl, DS_BOOL detach, DS_S32 *returnSegmentNumber, DS_S32 *returnSegmentCount, P_DS_U8 returnSectionData[]); DHL_RESULT DD_PSI_RegisterPSICtx( void *pParent, DS_U16 pid, PSIMode psiMode, PSIUpdateMode updateMode, PSIMask_t *prefList, DS_U16 maxData, DS_U16 maxSections, PSIEventProc_f eventProc, DS_U32 userParam , PSIRegisterProc_f stopFuncPtr, DS_U32 usrParamStop, DS_BOOL bRegister, void **returnPSIControl ); void DD_PSI_ReleasePSICtx( void * pPSICtx ); void DD_PSI_DataReceived( struct PSIContext_t *master , DS_U8 *data, int len); DHL_RESULT DD_PSI_GetTIDPSISimpleMask(PSIMask_t **ppMask, DS_U8 TID ); DHL_RESULT DD_PSI_GetTIDPrivateSubtypePSIMask( PSIMask_t **ppMask, DS_U8 TID, DS_U8 byteToSee, DS_U8 byteValue, PSIFieldSelect_k whichField); PSIContext_t *DD_PSI_DoSWSectionFiltering( DS_U16 pid , DS_U8 *pData , int iLen); void DD_PSI_ResetRegisteredMonitorFilters(void); void DD_PSI_ClearRegisteredMonitorFilters(void); void DD_PSI_ResetRegisteredMonitorFiltersExcludingOne( DS_U8 tid , DS_U8 byteIndex , DS_U8 byteMask , DS_U8 byteValue); DHL_RESULT DHL_PSI_ReadPSIDataSw( void * hTblHandle , struct PSIDataArray_t **returnPsi ); DHL_RESULT DHL_PSI_MonitorPSIPidSw( DS_U16 pid, PSIMode psiMode, PSIUpdateMode updateMode, PSIMask_t *prefList, DS_U16 maxData, DS_U16 maxSections, PSIEventProc_f eventProc, DS_U32 userParam, void **returnPSIControl ); DHL_RESULT DHL_PSI_CancelMonitorSw( void * hPsiCtl ); void DHL_PSI_FreePSIArray( PSIDataArray_t *psi ); #ifdef __cplusplus } #endif #endif /*ifndef DST_PSI_SECTGATHER_H_*/