📄 dvb_filt.h
字号:
/******************************************************************************
(C)Copyright Cheertek Inc. 2002-2005,
K000, all right reserved.
Product : STB Firmware
******************************************************************************/
/*!
\file
Section Filter API. This module provides the Section Filter control API.
*/
#ifndef __DVB_FILT_H
#define __DVB_FILT_H
#include "ct_os.h"
#include "dvb_type.h"
#define MAX_FILTER_NUMBER 32
/**
* Define don't care value for table mask.
*/
#define DONT_CARE_TABLE_ID 0xffff
#define DONT_CARE_SUB_TABLE_ID 0xffffffff
#define DONT_CARE_SECTION_NUM 0xffff
#define DONT_CARE_ORG_NETWORK_ID 0xffff
#define DONT_CARE_TP_ID 0xffff
#ifdef ATSC_SYSTEM
#define DONT_CARE_SOURCE_ID 0x0000
#endif /* end if ATSC_SYSTEM */
/**
* Define special value for section filter.
*/
#define TIMEOUT_INFINITE 0
#define INVALID_FILTER_ID 0xff
/**
* Define section size follow DVB standard.
*/
#define SECTION_256 256
#define SECTION_512 512
#define SECTION_1K 1024
#define SECTION_4K 4096
/**
* Define ring buffer size for each filter.
*/
#define RING_BUFFER_SIZE_1K 1024
#define RING_BUFFER_SIZE_2K 2048
#define RING_BUFFER_SIZE_4K 4096
#define RING_BUFFER_SIZE_8K 8192
#define RING_BUFFER_SIZE_16K 16384
#define RING_BUFFER_SIZE_32K 32768
#define RING_BUFFER_SIZE_64K 65536
#define RING_BUFFER_SIZE_128K 0x20000
#define RING_BUFFER_SIZE_256K 0x40000
#define RING_BUFFER_SIZE_512K 0x80000
#define RING_BUFFER_SIZE_1M 0x100000
#define RING_BUFFER_SIZE_2M 0x200000
#define RING_BUFFER_SIZE_4M 0x400000
#define RING_BUFFER_SIZE_8M 0x800000
#define RING_BUFFER_SIZE_16M 0x1000000
#define RING_BUFFER_SIZE_32M 0x2000000
/**
* Define filter status.
*/
typedef enum
{
EN_FILTER_NO_ERROR, /*!< no error */
EN_FILTER_SECTION_AVAILABLE, /*!< there is a section available */
EN_FILTER_USER_ABORT, /*!< user abort process */
EN_FILTER_TIMEOUT, /*!< filter timeout */
EN_FILTER_CRC_ERROR, /*!< section CRC check error */
EN_FILTER_ERROR /*!< some thing wrong */
}EN_FILTER_STATUS;
typedef enum
{
EN_FILTER_NIM_DP_0,
EN_FILTER_NIM_DP_1,
EN_FILTER_NIM_DP_INTL,
}EN_FILTER_NIM_DP;
/**
* Define section header structure follow DVB standard.
*/
typedef struct DVB_SectionHeader
{
u8 u8TableID;
u16 bitReserved4:4;
u16 u16SectionLength:12; // bit structure is start from low bit
u16 u16SubTableID;
u8 bitReserved2:2; // hight bit
u8 u8VersionNumber:5;
u8 bitCurrenNext:1; // low bit
u8 u8SectionNumber;
u8 u8LastSectionNumber;
u8 au8ExtendIDs[4];
}_Pack_Struct_
DVB_SectionHeader;
/**
* Define EIT section header structure follow DVB standard.
*/
typedef struct ST_DVB_EIT_SECTION_HEADER_T
{
u8 u8TableID;
u16 bitReserved4:4;
u16 u16SectionLength:12; // bit structure is start from low bit
u16 u16SrvId;
u8 bitReserved2:2; // hight bit
u8 u8VersionNumber:5;
u8 bitCurrenNext:1; // low bit
u8 u8SectionNumber;
u8 u8LastSectionNumber;
u16 u16TransportStreamId;
u16 u16OriginalNetworkId;
u8 u8SegmentLastSectionNumer;
u8 u8LastTableId;
}_Pack_Struct_
ST_DVB_EIT_SECTION_HEADER_T;
typedef struct ST_Filter_Channel_T
{
bool8 b8Allocated; /* used or not */
bool8 b8Running; /* running or stop */
u8 b8OneShot; /* one shot or continue */
u8 u8AvailableSection; /* available section count */
u16 u16TimeoutMilliSec; /* waiting time */
u16 u16PID; /* PID */
u16 u16TableID; /* Table ID */
u32 u32PidFltNo; /* pid filter handle */
u32 u32SecFltNo; /* section filter handle */
u32 u32TimerEnd; /* end time in terms of TICK*/
u8 u8TaskName[CTOS_MAX_NAME + 1]; /* task name */
void (*pfCallBack)(u8 u8FID, EN_FILTER_STATUS enStatus); /* call back func */
u8* pu8RingBufferAddress; /* ring buffer address for ct_filter */
}ST_Filter_Channel_T;
typedef void (*SECTION_CALLBACK)(u8, EN_FILTER_STATUS);
#if (defined(TONGFANG) || defined(DVNCA))
#ifdef TONGFANG
#include "pub_st.h"
#endif //#ifdef TONGFANG
#ifdef DVNCA
#ifndef BYTE
typedef unsigned char BYTE;
#endif
#ifndef WORD
typedef unsigned short int WORD;
#endif
#ifndef DWORD
typedef unsigned int DWORD;//int32
#endif
#endif //#ifdef DVNCA
typedef void (*tFuncVoidU8Status)(u8 , EN_FILTER_STATUS );
EN_FILTER_STATUS DVB_New_SectionMonitor (u16 u16PID, BYTE* pbyFilter, BYTE* pbyMask, BYTE byLen, tFuncVoidU8Status sec_cb, u16 u16TimeoutMilliSec, u8* pu8FID);
#endif //#if (defined(TONGFANG) || defined(DVNCA))
EN_FILTER_STATUS DVB_SectionMonitor (u16 u16PID, u16 u16TableID, u32 u32SubTableID, u16 u16SectionNum, void (*sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus), u16 u16TimeoutMilliSec, u8* pu8FID );
/*! \fn EN_FILTER_STATUS DVB_SectionMonitor (u16 u16PID, u16 u16TableID, u32 u32SubTableID, u16 u16SectionNum, void (code *sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus), u16 u16TimeoutMilliSec, u8* pu8FID )
\brief Asynchronous function, get a specific section by callback function, user should close the filter ID in callback.
\param u16PID (Input) PID for this section.
\param u16TableID (Input) table ID for this section.
\param u32SubTableID (Input) sub-table ID for this section.
\param u16SectionNum (Input) section number for this section.
\param sec_cb (Input) a callback function to process timeout or section available.
\param u16TimeoutMilliSec (Input) timeout in milli-second, or using TIMEOUT_INFINITE.
\param pu8FID (Output) return used filter id.
\return EN_FILTER_STATUS reference define.
*/
EN_FILTER_STATUS DVB_SectionMonitorEIT (u16 u16PID, u16 u16TableID, u32 u32SubTableID, u16 u16SectionNum,
u16 u16TransportStreamId, u16 u16OriginalNetworkId,
void (*sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus), u16 u16TimeoutMilliSec, u8* pu8FID );
/*! \fn N_FILTER_STATUS DVB_SectionMonitorEIT (u16 u16PID, u16 u16TableID, u32 u32SubTableID, u16 u16SectionNum,u16 u16TransportStreamId, u16 u16OriginalNetworkId, void (*sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus), u16 u16TimeoutMilliSec, u8* pu8FID )
\brief Asynchronous function, get a specific section by callback function, user should close the filter ID in callback.
\param u16PID (Input) PID for this section.
\param u16TableID (Input) table ID for this section.
\param u32SubTableID (Input) sub-table ID for this section.
\param u16SectionNum (Input) section number for this section.
\param u16TransportStreamId (Input) transport stream id for this section.
\param u16OriginalNetworkId (Input) original network id for this section.
\param sec_cb (Input) a callback function to process timeout or section available.
\param u16TimeoutMilliSec (Input) timeout in milli-second, or using TIMEOUT_INFINITE.
\param pu8FID (Output) return used filter id.
\return EN_FILTER_STATUS reference define.
*/
EN_FILTER_STATUS DVB_SectionGet (u16 u16PID, u16 u16TableID, u32 u32SubTableID, u16 u16SectionNum, u8* pu8Section, u16 u16MaxSecSize, u16 u16TimeoutMilliSec);
/*! \fn EN_FILTER_STATUS DVB_SectionGet (u16 u16PID, u16 u16TableID, u32 u32SubTableID, u16 u16SectionNum, u8* pu8Section, u16 u16MaxSecSize, u16 u16TimeoutMilliSec)
\brief Synchronous function, get a specific section, check CRC and close filter automatic.
\param u16PID (Input) PID for this section.
\param u16TableID (Input) table ID for this section.
\param u32SubTableID (Input) sub-table ID for this section.
\param u16SectionNum (Input) section number for this section.
\param pu8Section (Output) a buffer point to get section.
\param u16MaxSecSize (Input) max length of receiver buffer.
\param u16TimeoutMilliSec (Input) timeout in milli-second, or using TIMEOUT_INFINITE.
\return EN_FILTER_STATUS reference define.
*/
bool8 DVB_FilterCheckCRC32(u8* pu8Section);
/*! \fn bool8 DVB_FilterCheckCRC32( u8* pu8Section )
\brief Check CRC32 in the section.
\param pu8Section (Input) a point to section buffer.
\return TRUE - CRC ok.
\return FALSE - CRC error.
*/
bool8 DVB_FilterGetSection(u8 u8FID, u8* pu8Section, u16 u16MaxLength);
/*! \fn bool8 DVB_FilterGetSection (u8 u8FID, u8* pu8Section, u16 u16MaxLength)
\brief Get section in section buffer of some filter.
\param u8FID (Input) get section from which circular buffer.
\param pu8Section (Input) a point to section buffer.
\param u16MaxLength (Input) max length of receiver buffer.
\return TRUE - got a section.
\return FALSE - no available section or wrong parameters.
*/
bool8 DVB_FilterForceToGetSection (u8 u8FID, u8* pu8Section, u16 u16MaxLength);
/*! \fn bool8 DVB_FilterGetSection (u8 u8FID, u8* pu8Section, u16 u16MaxLength)
\brief Force to get section in section buffer of some filter if possible.
\param u8FID (Input) get section from which circular buffer.
\param pu8Section (Input) a point to section buffer.
\param u16MaxLength (Input) max length of receiver buffer.
\return TRUE - got a section.
\return FALSE - no available section or wrong parameters.
*/
u8 DVB_FilterTotalUnusedFilter(void);
/*! \fn u8 DVB_FilterTotalUnusedFilter(void)
\brief Get number of unused filter.
\return number of available filter.
*/
EN_DRV_RESULT DVB_FilterInit(void);
/*! \fn void DVB_FilterInit (void)
\brief Initial section filter when system initial.
*/
u8 DVB_FilterOpen(u32 u32UsrBfrSize);
/*! \fn u8 DVB_FilterOpen (u32 u32UsrBfrSize)
\brief Open a filter to receive section with ring buffer size u32UsrBfrSize.
\return filter ID or INVALID_FILTER_ID when fail.
*/
void DVB_FilterClose(u8 u8FID);
/*! \fn void DVB_FilterClose (u8 u8FID)
\brief Close a filter.
\param u8FID (Input) the filter ID which want to close.
*/
void DVB_FilterTerminate(void);
/*! \fn void DVB_FilterTerminate(void)
\brief Close all filters.
*/
void DVB_FilterSet(u8 u8FID, u16 u16PID, DVB_SectionHeader* pstMask, DVB_SectionHeader* pstMatch, void (*sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus));
/*! \fn void DVB_FilterSet(u8 u8FID, u16 u16PID, DVB_SectionHeader* pstMask, DVB_SectionHeader* pstMatch, void (*sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus))
\brief Set condition to filter a specific section, this function doesn't work when filter running.
\param u8FID (Input) config which filter ID.
\param u16PID (Input) PID for this section.
\param pstMask (Input) set interesting bit as 1 in Mask.
\param pstMatch (Input) set condition for the section.
\param sec_cb (Input) a callback function to process timeout or section availiable.
*/
void DVB_FilterStart(u8 u8FID, u16 u16TimeoutMilliSec, bool8 b8OneShot);
/*! \fn void DVB_FilterStart (u8 u8FID, u16 u16TimeoutMilliSec, bool8 b8OneShot)
\brief Filter start to receive section, this function doesn't work when filter running.
\param u8FID (Input) start which filter ID.
\param u16TimeoutMilliSec (Input) timeout in milli-second, or using TIMEOUT_INFINITE.
\param b8OneShot (Input) one-shot or continue mode.
*/
void DVB_FilterReStart(u8 u8FID) ;
/*! \fn void DVB_FilterReStart (u8 u8FID)
\brief Filter re-start to receive section, this function will have no effect when filter is running.
\param u8FID (Input) start which filter ID.
*/
void DVB_FilterStop(u8 u8FID);
/*! \fn void DVB_FilterStop (u8 u8FID)
\brief Set filter to stop receiving.
\param u8FID (Input) specific filter ID.
*/
void DVB_FilterCleanBuffer(u8 u8FID);
/*! \fn void DVB_FilterCleanBuffer (u8 u8FID)
\brief Reset circular buffer, this function doesn't work when filter running.
\param u8FID (Input) specific filter ID.
*/
u8 DVB_FilterGetTotalNumber(void);
/*! \fn u8 DVB_FilterGetTotalNumber(void)
\brief Get max number of section filter.
\return number of section filter.
*/
EN_FILTER_NIM_DP DVB_Filter_GetLiveTsNimDp(void) ;
/*! \fn EN_FILTER_NIM_DP DVB_Filter_GetLiveTsNimDp(void)
\brief This function will get back what NimId <data path> is used for "live" <broadcast> TS stream
\return value <id> will be in the ranage of num { DATA_PATH_NONE, DATA_PATH_0, DATA_PATH_1, DATA_PATH_2 }
*/
bool8 DVB_FilterCheckAvailableSection (u8 u8FID);
/*! \fn bool8 DVB_FilterCheckAvailableSection (u8 u8FID)
\brief check whether the indicated section filter have available section data left in the ring buffer
\return TRUE - have one or more available sections.
\return FALSE - no available section.
*/
void DVB_Filter_SetLiveTsNimDp(EN_FILTER_NIM_DP enDataPath) ;
void DVB_Filter_SetDataPathForMpg(EN_FILTER_NIM_DP enDataPath) ;
#ifdef CONAX
EN_FILTER_STATUS DVB_MonitorEMM (u16 u16PID, u16 u16TableID, u32 u32SubTableID, u16 u16SectionNum,
void (*sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus), u16 u16TimeoutMilliSec, u8* pu8FID );
bool8 DVB_FilterGetEMM (u8 u8FID, u8* pu8Section, u16 u16MaxLength);
#endif
#ifdef ATSC_SYSTEM
EN_FILTER_STATUS DVB_SectionMonitorPSIP (u16 u16PID, u16 u16TableID, u32 u32TableIDExtension,
u16 u16SectionNum, u16 u16SourceID, u32 u32SecBufSize,
void (*sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus), u16 u16TimeoutMilliSec, u8* pu8FID );
#endif
#endif //__DVB_FILT_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -