📄 dvb_filt.c
字号:
pu8MaskByte [10] = ((pstMask ->au8ExtendIDs[2]>>0)&0xff);
pu8MatchByte[11] = ((pstMatch->au8ExtendIDs[3]>>0)&0xff);
pu8MaskByte [11] = ((pstMask ->au8ExtendIDs[3]>>0)&0xff);
CT_FILT_SetPattern (astSectionFilter[u8FID].u32SecFltNo, pu8MatchByte, pu8MaskByte, FALSE);
}
/*! \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_FilterSet (u8 u8FID, u16 u16PID, DVB_SectionHeader* pstMask, DVB_SectionHeader* pstMatch,
void (*sec_cb)(u8 u8FID, EN_FILTER_STATUS enStatus))
{
CT_OS_WaitOnSemaphore (&DVBFilterSemaphore, CTOS_WAIT);
dvb_filterset (u8FID, u16PID, pstMask, pstMatch, sec_cb);
CT_OS_FreeSemaphore (&DVBFilterSemaphore);
}
bool8 _dvb_PidftOutputSectionFilter (u32 u32PidFltNo, u8 u8FID, u8 u8Enable)
{
/* set PID filter to output to which section filter */
if (CT_PF_SelectFilterOut (u32PidFltNo, astSectionFilter[u8FID].u32SecFltNo) != DRV_OK)
{
return (FALSE);
}
/* enable or disable PID filter output */
if (CT_PF_FilterOut(u32PidFltNo, u8Enable) != DRV_OK)
{
return (FALSE);
}
return (TRUE);
}
void DVB_FilterStart (u8 u8FID, u16 u16TimeoutMilliSec, bool8 b8OneShot)
{
CT_OS_WaitOnSemaphore (&DVBFilterSemaphore, CTOS_WAIT);
dvb_filterstart (u8FID, u16TimeoutMilliSec,b8OneShot);
CT_OS_FreeSemaphore (&DVBFilterSemaphore);
}
/*! \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.
*/
static void dvb_filterstart (u8 u8FID, u16 u16TimeoutMilliSec, bool8 b8OneShot)
{
/* check */
if ((u8FID>=MAX_FILTER_NUMBER)
|| (astSectionFilter[u8FID].b8Allocated == FALSE)
|| (astSectionFilter[u8FID].b8Running == TRUE))
{
FILT_DBG(( "{dvb_filterstart} FAIL u8FID[0x%x] b8Allocated[%d] b8Running[%d]\n",
u8FID, astSectionFilter[u8FID].b8Allocated, astSectionFilter[u8FID].b8Running));
return;
}
/* set one shot or continue */
astSectionFilter[u8FID].b8OneShot = b8OneShot;
/* set waitting time */
astSectionFilter[u8FID].u16TimeoutMilliSec = u16TimeoutMilliSec;
/* set end time */
if (astSectionFilter[u8FID].u16TimeoutMilliSec == TIMEOUT_INFINITE)
{
astSectionFilter[u8FID].u32TimerEnd = TIMEOUT_INFINITE;
}
else
{
/* in terms of tick */
astSectionFilter[u8FID].u32TimerEnd = DVB_TimerGet() + (astSectionFilter[u8FID].u16TimeoutMilliSec/DVB_SYSTIME_MILSEC_PER_TICK);
}
/* register call back function ,
note that all register the same call back function */
#if (defined(CT216S)||defined(CT216T) || defined (CT216H))
if (CT_FILT_Register (astSectionFilter[u8FID].u32SecFltNo, (SECTION_RDY_MASK_BIT|RING_BFR_OVRFLOW_MASK_BIT), DVB_Filter_CallBack, NULL) != DRV_OK)
#else
if (CT_FILT_Register (astSectionFilter[u8FID].u32SecFltNo, SECTION_RDY_MASK_BIT, DVB_Filter_CallBack, NULL) != DRV_OK)
#endif
{
CT_FILT_Close (astSectionFilter[u8FID].u32SecFltNo);
FILT_DBG(( "{dvb_filterstart} FAIL CT_FILT_Register u32SecFltNo[0x%x]\n",
astSectionFilter[u8FID].u32SecFltNo));
return;
}
/* reset FIFO ring buffer */
CT_FILT_ResetBuffer (astSectionFilter[u8FID].u32SecFltNo);
/* enable pid filter output to sec filter path */
_dvb_PidftOutputSectionFilter (astSectionFilter[u8FID].u32PidFltNo, u8FID, TRUE);
/* update status */
astSectionFilter[u8FID].u8AvailableSection = 0;
astSectionFilter[u8FID].b8Running = TRUE;
#if (defined (CT216U)||defined (CT956))
/* start filter */
CT_FILT_Start (astSectionFilter[u8FID].u32SecFltNo);
#endif
//FILT_DBG(( "{dvb_filterstart} end FID[0x%x] Time[0x%x] u32TimerEnd[0x%x] b8OneShot[0x%x]\n",
// u8FID, astSectionFilter[u8FID].u16TimeoutMilliSec,
// astSectionFilter[u8FID].u32TimerEnd, b8OneShot));
}
static void dvb_filterrestart (u8 u8FID)
{
/* check status */
if ((u8FID >= MAX_FILTER_NUMBER)
|| (astSectionFilter[u8FID].b8Allocated == FALSE)
|| (astSectionFilter[u8FID].b8Running == TRUE))
{
FILT_DBG(( "\n\r{dvb_filterrestart} FAIL u8FID[0x%x] b8Allocated[%d] .b8Running[%d]\n",
u8FID, astSectionFilter[u8FID].b8Allocated, astSectionFilter[u8FID].b8Running));
return;
}
/* reset FIFO ring buffer */
CT_FILT_ResetBuffer (astSectionFilter[u8FID].u32SecFltNo);
/* update status */
astSectionFilter[u8FID].u8AvailableSection = 0;
astSectionFilter[u8FID].b8Running = TRUE;
}
/*! \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_FilterReStart (u8 u8FID)
{
CT_OS_WaitOnSemaphore (&DVBFilterSemaphore, CTOS_WAIT);
dvb_filterrestart (u8FID);
CT_OS_FreeSemaphore (&DVBFilterSemaphore);
}
void _dvb_filter_Reset (u8 u8FID)
{
/* check parameter */
if (u8FID >= MAX_FILTER_NUMBER)
{
return;
}
/* reset user ring buffer */
CT_FILT_ResetBuffer (astSectionFilter[u8FID].u32SecFltNo);
/* unregister call back function */
CT_FILT_Unregister (astSectionFilter[u8FID].u32SecFltNo);
// CT_Secisr_Unregister(u8FID);
}
void _dvb_PidftStopOutput (u8 u8FID)
{
/* disable PID Filter output */
_dvb_PidftOutputSectionFilter (astSectionFilter[u8FID].u32PidFltNo, u8FID, FALSE);
/* ask proc2 not to receive stream any more */
CT_FILT_Stop (astSectionFilter[u8FID].u32SecFltNo);
}
void DVB_FilterStop (u8 u8FID)
{
CT_OS_WaitOnSemaphore (&DVBFilterSemaphore, CTOS_WAIT);
dvb_filterstop (u8FID);
CT_OS_FreeSemaphore (&DVBFilterSemaphore);
}
/*! \fn void DVB_FilterStop (u8 u8FID)
\brief Set filter to stop receiving.
\param u8FID (Input) specific filter ID.
*/
static void dvb_filterstop (u8 u8FID)
{
/* error conditions */
if ((u8FID >= MAX_FILTER_NUMBER)
|| (astSectionFilter[u8FID].b8Allocated == FALSE)
|| (astSectionFilter[u8FID].b8Running == FALSE))
{
FILT_DBG(( "\n\r{dvb_filterstopp} FAIL u8FID[0x%x] b8Allocated[0x%x] b8Running[0x%x]\n",
u8FID, astSectionFilter[u8FID].b8Allocated, astSectionFilter[u8FID].b8Running));
return;
}
/* disable PID Filter output and ask proc2 not to receive stream any more */
_dvb_PidftStopOutput (u8FID); //CT_Filter_Stop (u8FID);
/* reset FIFO and unregister */
_dvb_filter_Reset (u8FID);
/* update status */
astSectionFilter[u8FID].b8Running = FALSE;
}
static void dvb_filtercleanbuffer(u8 u8FID)
{
/*[01]error conditions ==================================================*/
if ((u8FID >= MAX_FILTER_NUMBER)
|| (astSectionFilter[u8FID].b8Allocated == FALSE)
|| (astSectionFilter[u8FID].b8Running == TRUE))
{
return;
}
/* reset fifo */
CT_FILT_ResetBuffer (astSectionFilter[u8FID].u32SecFltNo);
/* update status */
astSectionFilter[u8FID].u8AvailableSection = 0;
}
/*! \fn void DVB_FilterCleanBuffer (u8 u8FID)
\brief Reset circular buffer, this function doesn't work when filter running.
\param u8FID (Input) specific filter ID.
*/
void DVB_FilterCleanBuffer(u8 u8FID)
{
CT_OS_WaitOnSemaphore (&DVBFilterSemaphore, CTOS_WAIT);
dvb_filtercleanbuffer(u8FID);
CT_OS_FreeSemaphore (&DVBFilterSemaphore);
}
/*! \fn u8 DVB_FilterGetTotalNumber(void)
\brief Get max number of section filter.
\return number of section filter.
*/
u8 DVB_FilterGetTotalNumber(void)
{
// no bady call this
return MAX_FILTER_NUMBER;
}
void dvb_filter_poll(void)
{
// CT_OS_Delay (DVB_FILTER_WAIT_100_MS);
}
bool8 pid_flt_show_config (u8 u8FID)
{
if (u8FID >= MAX_FILTER_NUMBER)
{
return (FALSE);
}
FILT_MSG( ("%2d.PD[0x%4x] TD[0x%4x] R[%d] A[%d] O[%d] Al[%d] T[0x%x] E[0x%x] B[0x%x]\n",
u8FID,
astSectionFilter[u8FID].u16PID,
astSectionFilter[u8FID].u16TableID,
astSectionFilter[u8FID].b8Running,
astSectionFilter[u8FID].b8Allocated,
astSectionFilter[u8FID].b8OneShot,
astSectionFilter[u8FID].u8AvailableSection,
astSectionFilter[u8FID].u16TimeoutMilliSec,
(unsigned int)astSectionFilter[u8FID].u32TimerEnd,
(unsigned int)astSectionFilter[u8FID].pu8RingBufferAddress
));
return (TRUE);
}
bool8 DVB_FilterShowInfo (void)
{
u8 u8FID;
for (u8FID = 0; u8FID < MAX_FILTER_NUMBER; u8FID ++)
{
pid_flt_show_config (u8FID);
}
return (TRUE);
}
/*****************************************************************************/
EN_FILTER_NIM_DP DVB_Filter_GetLiveTsNimDp(void)
{
EN_FILTER_NIM_DP enDataPath = EN_FILTER_NIM_DP_0;
CT_OS_WaitOnSemaphore (&DVBDPSemaphore, CTOS_WAIT);
enDataPath = enLiveTsDataPath;
CT_OS_FreeSemaphore (&DVBDPSemaphore);
return (enDataPath) ;
}
/*****************************************************************************/
EN_CT_DEMUX_DP DVB_Filter_GetCtDemuxDpByDvbNimDp(EN_FILTER_NIM_DP enNimPath)
{
EN_CT_DEMUX_DP enDemuxPath = DEMUX_DATAPATH_NON;
switch(enNimPath)
{
default:
case EN_FILTER_NIM_DP_0:
#ifdef CT_INSTANT_DELAY
enDemuxPath = DEMUX_DATAPATH_2;
#else
enDemuxPath = DEMUX_DATAPATH_0;
#endif
//FILT_DBG(("\n>> enDemuxPath = DEMUX_DATAPATH_0 \n"));
break;
case EN_FILTER_NIM_DP_1:
enDemuxPath = DEMUX_DATAPATH_1;
//FILT_DBG(("\n>> enDemuxPath = DEMUX_DATAPATH_1 \n"));
break;
case EN_FILTER_NIM_DP_INTL:
#ifdef CT_INSTANT_DELAY
enDemuxPath = DEMUX_DATAPATH_0;
#else
enDemuxPath = DEMUX_DATAPATH_2;
#endif
//FILT_DBG(("\n>> enDemuxPath = DEMUX_DATAPATH_2 \n"));
break;
}
return (enDemuxPath) ;
}
/*****************************************************************************/
void DVB_Filter_SetLiveTsNimDp(EN_FILTER_NIM_DP enDataPath)
{
CT_OS_WaitOnSemaphore (&DVBDPSemaphore, CTOS_WAIT);
enLiveTsDataPath = enDataPath ;
CT_OS_FreeSemaphore (&DVBDPSemaphore);
}
/*****************************************************************************/
void DVB_Filter_SetDataPathForMpg(EN_FILTER_NIM_DP enDataPath)
{
DVB_AVT_SetDataPath(enDataPath);
}
/*****************************************************************************/
void DVBFilter_Timer_Task (u32 argc, void *argv)
{
u8 u8FID;
void (*pfTimeroutCallBack)(u8 u8FID, EN_FILTER_STATUS enStatus);
while(1)
{
CT_OS_MS_Delay(1000); // Delay 2 Sec
for (u8FID = 0; u8FID < MAX_FILTER_NUMBER; u8FID++)
{
CT_OS_WaitOnSemaphore (&DVBFilterSemaphore, CTOS_WAIT);
if ((astSectionFilter[u8FID].b8Running == TRUE)
&& (astSectionFilter[u8FID].pfCallBack != NULL)
&& (astSectionFilter[u8FID].u8AvailableSection==0)
&& (dvb_filterchecktimeout (u8FID))
)
{
// prevent null callback
pfTimeroutCallBack = astSectionFilter[u8FID].pfCallBack;
CT_OS_FreeSemaphore (&DVBFilterSemaphore);
pfTimeroutCallBack (u8FID, EN_FILTER_TIMEOUT);
CT_OS_WaitOnSemaphore (&DVBFilterSemaphore, CTOS_WAIT);
/* reset the new timeout time */
if(astSectionFilter[u8FID].u16TimeoutMilliSec != TIMEOUT_INFINITE )
astSectionFilter[u8FID].u32TimerEnd = DVB_TimerGet() + (astSectionFilter[u8FID].u16TimeoutMilliSec/DVB_SYSTIME_MILSEC_PER_TICK);
}
CT_OS_FreeSemaphore (&DVBFilterSemaphore);
}
}
}
#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 )
{
DVB_SectionHeader stMatch, stMask;
u32 u32SecBufSize;
/* check parameter */
if (pu8FID == NULL || sec_cb == NULL)
{
FILT_DBG( ("DVB_SectionMonitor retrn FAIL because check parameter \n"));
return(EN_FILTER_ERROR);
}
u32SecBufSize = DEF_SECTION_BUFFER_SIZE;
CT_OS_WaitOnSemaphore (&DVBFilterSemaphore, CTOS_WAIT);
gen_point = 101;
*pu8FID = dvb_filteropen (u32SecBufSize);
if(*pu8FID == INVALID_FILTER_ID)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -