Commit 75dd4ade authored by Jean-Paul Saman's avatar Jean-Paul Saman

Add utility function dvbpsi_SectionsCompleteDecoder()

The table decoder check for all sections received in the same manner, this
is now abstracted away in the dvbpsi_SectionsCompleteDecoder() function.
parent 551e2865
......@@ -218,6 +218,28 @@ void dvbpsi_ReInitDecoder(dvbpsi_decoder_t* p_decoder, const bool b_force)
}
}
/*****************************************************************************
* dvbpsi_SectionsCompleteDecoder
*****************************************************************************/
bool dvbpsi_SectionsCompleteDecoder(dvbpsi_decoder_t* p_decoder)
{
assert(p_decoder);
assert(p_decoder->i_last_section_number <= 255);
bool b_complete = false;
for (unsigned int i = 0; i <= p_decoder->i_last_section_number &&
i <= 255; i++)
{
if (!p_decoder->ap_sections[i])
break;
if (i == p_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
/*****************************************************************************
* dvbpsi_DeleteDecoder
*****************************************************************************/
......
......@@ -259,6 +259,17 @@ void dvbpsi_DeleteDecoder(dvbpsi_decoder_t *p_decoder);
*/
void dvbpsi_ReInitDecoder(dvbpsi_decoder_t* p_decoder, const bool b_force);
/*****************************************************************************
* dvbpsi_SectionsCompleteDecoder
*****************************************************************************/
/*!
* \fn bool dvbpsi_SectionsCompleteDecoder(dvbpsi_decoder_t* p_decoder);
* \brief Have all sections for this decoder been received.
* \param p_decoder pointer to dvbpsi_decoder_t with decoder
* \return true when all PSI sections have been received, false otherwise
*/
bool dvbpsi_SectionsCompleteDecoder(dvbpsi_decoder_t* p_decoder);
/*****************************************************************************
* dvbpsi_HasDecoder
*****************************************************************************/
......
......@@ -375,23 +375,6 @@ static bool dvbpsi_AddSectionEIT(dvbpsi_t *p_dvbpsi, dvbpsi_atsc_eit_decoder_t *
return true;
}
static bool dvbpsi_IsCompleteEIT(dvbpsi_atsc_eit_decoder_t *p_decoder)
{
assert(p_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_decoder->i_last_section_number; i++)
{
if (!p_decoder->ap_sections[i])
break;
if (i == p_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
/*****************************************************************************
* dvbpsi_atsc_GatherEITSections
*****************************************************************************
......@@ -484,7 +467,7 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteEIT(p_eit_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_eit_decoder)))
{
assert(p_eit_decoder->pf_eit_callback);
......
......@@ -313,23 +313,6 @@ static bool dvbpsi_AddSectionETT(dvbpsi_t *p_dvbpsi, dvbpsi_atsc_ett_decoder_t *
return true;
}
static bool dvbpsi_IsCompleteETT(dvbpsi_atsc_ett_decoder_t *p_decoder)
{
assert(p_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_decoder->i_last_section_number; i++)
{
if (!p_decoder->ap_sections[i])
break;
if (i == p_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
/*****************************************************************************
* dvbpsi_atsc_GatherETTSections
*****************************************************************************
......@@ -400,7 +383,7 @@ static void dvbpsi_atsc_GatherETTSections(dvbpsi_t* p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteETT(p_ett_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_ett_decoder)))
{
assert(p_ett_decoder->pf_ett_callback);
......
......@@ -405,23 +405,6 @@ static bool dvbpsi_AddSectionMGT(dvbpsi_t *p_dvbpsi, dvbpsi_atsc_mgt_decoder_t *
return true;
}
static bool dvbpsi_IsCompleteMGT(dvbpsi_atsc_mgt_decoder_t *p_decoder)
{
assert(p_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_decoder->i_last_section_number; i++)
{
if (!p_decoder->ap_sections[i])
break;
if (i == p_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
/*****************************************************************************
* dvbpsi_atsc_GatherMGTSections
*****************************************************************************
......@@ -514,7 +497,7 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteMGT(p_mgt_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_mgt_decoder)))
{
assert(p_mgt_decoder->pf_mgt_callback);
......
......@@ -304,23 +304,6 @@ static bool dvbpsi_AddSectionSTT(dvbpsi_t *p_dvbpsi, dvbpsi_atsc_stt_decoder_t *
return true;
}
static bool dvbpsi_IsCompleteSTT(dvbpsi_atsc_stt_decoder_t *p_decoder)
{
assert(p_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_decoder->i_last_section_number; i++)
{
if (!p_decoder->ap_sections[i])
break;
if (i == p_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
/*****************************************************************************
* dvbpsi_atsc_GatherSTTSections
*****************************************************************************
......@@ -413,7 +396,7 @@ static void dvbpsi_atsc_GatherSTTSections(dvbpsi_t *p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteSTT(p_stt_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_stt_decoder)))
{
assert(p_stt_decoder->pf_stt_callback);
......
......@@ -443,23 +443,6 @@ static bool dvbpsi_AddSectionVCT(dvbpsi_t *p_dvbpsi, dvbpsi_atsc_vct_decoder_t *
return true;
}
static bool dvbpsi_IsCompleteVCT(dvbpsi_atsc_vct_decoder_t *p_decoder)
{
assert(p_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_decoder->i_last_section_number; i++)
{
if (!p_decoder->ap_sections[i])
break;
if (i == p_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
/*****************************************************************************
* dvbpsi_atsc_GatherVCTSections
*****************************************************************************
......@@ -550,7 +533,7 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteVCT(p_vct_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_vct_decoder)))
{
assert(p_vct_decoder->pf_vct_callback);
......
......@@ -331,23 +331,6 @@ static bool dvbpsi_CheckBAT(dvbpsi_t *p_dvbpsi, dvbpsi_bat_decoder_t *p_bat_deco
return b_reinit;
}
static bool dvbpsi_IsCompleteBAT(dvbpsi_bat_decoder_t* p_bat_decoder)
{
assert(p_bat_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_bat_decoder->i_last_section_number; i++)
{
if (!p_bat_decoder->ap_sections[i])
break;
if (i == p_bat_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
static bool dvbpsi_AddSectionBAT(dvbpsi_t *p_dvbpsi, dvbpsi_bat_decoder_t *p_bat_decoder,
dvbpsi_psi_section_t* p_section)
{
......@@ -459,7 +442,7 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteBAT(p_bat_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_bat_decoder)))
{
assert(p_bat_decoder->pf_bat_callback);
......
......@@ -228,24 +228,6 @@ static bool dvbpsi_CheckCAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
return b_reinit;
}
static bool dvbpsi_IsCompleteCAT(dvbpsi_cat_decoder_t* p_cat_decoder)
{
assert(p_cat_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_cat_decoder->i_last_section_number; i++)
{
if (!p_cat_decoder->ap_sections[i])
break;
if (i == p_cat_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
static bool dvbpsi_AddSectionCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_decoder_t *p_decoder,
dvbpsi_psi_section_t* p_section)
{
......@@ -338,7 +320,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteCAT(p_cat_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_cat_decoder)))
{
assert(p_cat_decoder->pf_cat_callback);
......
......@@ -323,22 +323,6 @@ static bool dvbpsi_CheckNIT(dvbpsi_t *p_dvbpsi, dvbpsi_nit_decoder_t *p_nit_deco
return b_reinit;
}
static bool dvbpsi_IsCompleteNIT(dvbpsi_nit_decoder_t* p_nit_decoder)
{
assert(p_nit_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_nit_decoder->i_last_section_number; i++)
{
if (!p_nit_decoder->ap_sections[i])
break;
if (i == p_nit_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
static bool dvbpsi_AddSectionNIT(dvbpsi_t *p_dvbpsi, dvbpsi_nit_decoder_t *p_nit_decoder,
dvbpsi_psi_section_t* p_section)
{
......@@ -442,7 +426,7 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteNIT(p_nit_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_nit_decoder)))
{
assert(p_nit_decoder->pf_nit_callback);
......
......@@ -236,22 +236,6 @@ static bool dvbpsi_CheckPAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
return b_reinit;
}
static bool dvbpsi_IsCompletePAT(dvbpsi_pat_decoder_t* p_pat_decoder)
{
assert(p_pat_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_pat_decoder->i_last_section_number; i++)
{
if (!p_pat_decoder->ap_sections[i])
break;
if (i == p_pat_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
static bool dvbpsi_AddSectionPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_decoder_t *p_pat_decoder,
dvbpsi_psi_section_t* p_section)
{
......@@ -343,7 +327,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
}
/* Check if we have all the sections */
if (dvbpsi_IsCompletePAT(p_pat_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_pat_decoder)))
{
assert(p_pat_decoder->pf_pat_callback);
......
......@@ -289,22 +289,6 @@ static bool dvbpsi_CheckPMT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
return b_reinit;
}
static bool dvbpsi_IsCompletePMT(dvbpsi_pmt_decoder_t* p_pmt_decoder)
{
assert(p_pmt_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_pmt_decoder->i_last_section_number; i++)
{
if (!p_pmt_decoder->ap_sections[i])
break;
if (i == p_pmt_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
static bool dvbpsi_AddSectionPMT(dvbpsi_t *p_dvbpsi, dvbpsi_pmt_decoder_t *p_pmt_decoder,
dvbpsi_psi_section_t* p_section)
{
......@@ -406,7 +390,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio
return;
}
if (dvbpsi_IsCompletePMT(p_pmt_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_pmt_decoder)))
{
assert(p_pmt_decoder->pf_pmt_callback);
......
......@@ -311,22 +311,6 @@ static bool dvbpsi_CheckSDT(dvbpsi_t *p_dvbpsi, dvbpsi_sdt_decoder_t *p_sdt_deco
return b_reinit;
}
static bool dvbpsi_IsCompleteSDT(dvbpsi_sdt_decoder_t* p_sdt_decoder)
{
assert(p_sdt_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_sdt_decoder->i_last_section_number; i++)
{
if (!p_sdt_decoder->ap_sections[i])
break;
if (i == p_sdt_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
static bool dvbpsi_AddSectionSDT(dvbpsi_t *p_dvbpsi, dvbpsi_sdt_decoder_t *p_sdt_decoder,
dvbpsi_psi_section_t* p_section)
{
......@@ -422,7 +406,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteSDT(p_sdt_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_sdt_decoder)))
{
assert(p_sdt_decoder->pf_sdt_callback);
......
......@@ -297,22 +297,6 @@ static bool dvbpsi_CheckSIS(dvbpsi_t *p_dvbpsi, dvbpsi_sis_decoder_t* p_sis_deco
return b_reinit;
}
static bool dvbpsi_IsCompleteSIS(dvbpsi_sis_decoder_t* p_sis_decoder)
{
assert(p_sis_decoder);
bool b_complete = false;
for (unsigned int i = 0; i <= p_sis_decoder->i_last_section_number; i++)
{
if (!p_sis_decoder->ap_sections[i])
break;
if (i == p_sis_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
static bool dvbpsi_AddSectionSIS(dvbpsi_t *p_dvbpsi, dvbpsi_sis_decoder_t *p_sis_decoder,
dvbpsi_psi_section_t* p_section)
{
......@@ -414,7 +398,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteSIS(p_sis_decoder))
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_sis_decoder)))
{
assert(p_sis_decoder->pf_sis_callback);
......
......@@ -271,22 +271,6 @@ static bool dvbpsi_CheckTOT(dvbpsi_t *p_dvbpsi, dvbpsi_tot_decoder_t *p_tot_deco
return b_reinit;
}
static bool dvbpsi_IsCompleteTOT(dvbpsi_tot_decoder_t* p_tot_decoder)
{
assert(p_tot_decoder);
bool b_complete = false;
for (unsigned int i = 0; i < p_tot_decoder->i_last_section_number; i++)
{
if (!p_tot_decoder->ap_sections[i])
break;
if (i == p_tot_decoder->i_last_section_number)
b_complete = true;
}
return b_complete;
}
static bool dvbpsi_AddSectionTOT(dvbpsi_t *p_dvbpsi, dvbpsi_tot_decoder_t *p_tot_decoder,
dvbpsi_psi_section_t* p_section)
{
......@@ -392,7 +376,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
}
/* Check if we have all the sections */
if (dvbpsi_IsCompleteTOT(p_tot_decoder) || true)
if (dvbpsi_SectionsCompleteDecoder(DVBPSI_DECODER(p_tot_decoder)))
{
assert(p_tot_decoder->pf_tot_callback);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment