Commit 2e8db83c authored by Jean-Paul Saman's avatar Jean-Paul Saman

Add utiltiy function dvbpsi_ChainSectionsDecoder()

The function dvbpsi_ChainSectionsDecoder() turns the dvbpsi_decoder_t::ap_sections[] array
into a linked list.
parent 75dd4ade
......@@ -240,6 +240,22 @@ bool dvbpsi_SectionsCompleteDecoder(dvbpsi_decoder_t* p_decoder)
return b_complete;
}
/*****************************************************************************
* dvbpsi_ChainSectionsDecoder
*****************************************************************************/
void dvbpsi_ChainSectionsDecoder(dvbpsi_decoder_t *p_decoder)
{
assert(p_decoder);
assert(p_decoder->i_last_section_number <= 255);
if (p_decoder->i_last_section_number)
{
for (uint8_t i = 0; i <= p_decoder->i_last_section_number - 1 &&
i <= 255; i++)
p_decoder->ap_sections[i]->p_next = p_decoder->ap_sections[i + 1];
}
}
/*****************************************************************************
* dvbpsi_DeleteDecoder
*****************************************************************************/
......
......@@ -270,6 +270,17 @@ void dvbpsi_ReInitDecoder(dvbpsi_decoder_t* p_decoder, const bool b_force);
*/
bool dvbpsi_SectionsCompleteDecoder(dvbpsi_decoder_t* p_decoder);
/*****************************************************************************
* dvbpsi_ChainSectionsDecoder
*****************************************************************************/
/*!
* \fn void dvbpsi_ChainSectionsDecoder(dvbpsi_decoder_t *p_decoder);
* \brief Chain the sections if the last has been received.
* \param p_decoder pointer to dvbpsi_decoder_t with decoder
* \return nothing
*/
void dvbpsi_ChainSectionsDecoder(dvbpsi_decoder_t *p_decoder);
/*****************************************************************************
* dvbpsi_HasDecoder
*****************************************************************************/
......
......@@ -475,17 +475,13 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi,
p_eit_decoder->current_eit = *p_eit_decoder->p_building_eit;
p_eit_decoder->b_current_valid = true;
/* Chain the sections */
if (p_eit_decoder->i_last_section_number)
{
for (uint8_t i = 0; i <= p_eit_decoder->i_last_section_number - 1; i++)
p_eit_decoder->ap_sections[i]->p_next =
p_eit_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_eit_decoder));
/* Decode the sections */
dvbpsi_atsc_DecodeEITSections(p_eit_decoder->p_building_eit,
p_eit_decoder->ap_sections[0]);
/* Delete the sections */
dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[0]);
p_eit_decoder->ap_sections[0] = NULL;
/* signal the new EIT */
p_eit_decoder->pf_eit_callback(p_eit_decoder->p_cb_data,
p_eit_decoder->p_building_eit);
......
......@@ -391,17 +391,13 @@ static void dvbpsi_atsc_GatherETTSections(dvbpsi_t* p_dvbpsi,
p_ett_decoder->current_ett = *p_ett_decoder->p_building_ett;
p_ett_decoder->b_current_valid = true;
/* Chain the sections */
if (p_ett_decoder->i_last_section_number)
{
for (uint8_t i = 0; i <= p_ett_decoder->i_last_section_number - 1; i++)
p_ett_decoder->ap_sections[i]->p_next =
p_ett_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_ett_decoder));
/* Decode the sections */
dvbpsi_atsc_DecodeETTSections(p_ett_decoder->p_building_ett,
p_ett_decoder->ap_sections[0]);
/* Delete the sections */
dvbpsi_DeletePSISections(p_ett_decoder->ap_sections[0]);
p_ett_decoder->ap_sections[0] = NULL;
/* signal the new ETT */
p_ett_decoder->pf_ett_callback(p_ett_decoder->p_cb_data,
p_ett_decoder->p_building_ett);
......
......@@ -505,17 +505,13 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi,
p_mgt_decoder->current_mgt = *p_mgt_decoder->p_building_mgt;
p_mgt_decoder->b_current_valid = true;
/* Chain the sections */
if (p_mgt_decoder->i_last_section_number)
{
for (uint8_t i = 0; i <= p_mgt_decoder->i_last_section_number - 1; i++)
p_mgt_decoder->ap_sections[i]->p_next =
p_mgt_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_mgt_decoder));
/* Decode the sections */
dvbpsi_atsc_DecodeMGTSections(p_mgt_decoder->p_building_mgt,
p_mgt_decoder->ap_sections[0]);
/* Delete the sections */
dvbpsi_DeletePSISections(p_mgt_decoder->ap_sections[0]);
p_mgt_decoder->ap_sections[0] = NULL;
/* signal the new MGT */
p_mgt_decoder->pf_mgt_callback(p_mgt_decoder->p_cb_data,
p_mgt_decoder->p_building_mgt);
......
......@@ -405,18 +405,13 @@ static void dvbpsi_atsc_GatherSTTSections(dvbpsi_t *p_dvbpsi,
p_stt_decoder->b_current_valid = true;
/* Chain the sections */
assert(p_stt_decoder->i_last_section_number > 256);
if (p_stt_decoder->i_last_section_number)
{
for(uint8_t i = 0; i <= p_stt_decoder->i_last_section_number - 1; i++)
p_stt_decoder->ap_sections[i]->p_next =
p_stt_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_stt_decoder));
/* Decode the sections */
dvbpsi_atsc_DecodeSTTSections(p_stt_decoder->p_building_stt,
p_stt_decoder->ap_sections[0]);
/* Delete the sections */
dvbpsi_DeletePSISections(p_stt_decoder->ap_sections[0]);
p_stt_decoder->ap_sections[0] = NULL;
/* signal the new STT */
p_stt_decoder->pf_stt_callback(p_stt_decoder->p_cb_data,
p_stt_decoder->p_building_stt);
......
......@@ -542,18 +542,13 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi,
p_vct_decoder->b_current_valid = true;
/* Chain the sections */
assert(p_vct_decoder->i_last_section_number > 256);
if (p_vct_decoder->i_last_section_number)
{
for(uint8_t i = 0; i <= p_vct_decoder->i_last_section_number - 1; i++)
p_vct_decoder->ap_sections[i]->p_next =
p_vct_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_vct_decoder));
/* Decode the sections */
dvbpsi_atsc_DecodeVCTSections(p_vct_decoder->p_building_vct,
p_vct_decoder->ap_sections[0]);
/* Delete the sections */
dvbpsi_DeletePSISections(p_vct_decoder->ap_sections[0]);
p_vct_decoder->ap_sections[0] = NULL;
/* signal the new VCT */
p_vct_decoder->pf_vct_callback(p_vct_decoder->p_cb_data,
p_vct_decoder->p_building_vct);
......
......@@ -450,17 +450,13 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
p_bat_decoder->current_bat = *p_bat_decoder->p_building_bat;
p_bat_decoder->b_current_valid = true;
/* Chain the sections */
if (p_bat_decoder->i_last_section_number)
{
for (uint8_t j = 0; j <= p_bat_decoder->i_last_section_number - 1; j++)
p_bat_decoder->ap_sections[j]->p_next =
p_bat_decoder->ap_sections[j + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_bat_decoder));
/* Decode the sections */
dvbpsi_DecodeBATSections(p_bat_decoder->p_building_bat,
p_bat_decoder->ap_sections[0]);
/* Delete the sections */
dvbpsi_DeletePSISections(p_bat_decoder->ap_sections[0]);
p_bat_decoder->ap_sections[0] = NULL;
/* signal the new BAT */
p_bat_decoder->pf_bat_callback(p_bat_decoder->p_cb_data,
p_bat_decoder->p_building_bat);
......
......@@ -328,11 +328,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
p_cat_decoder->current_cat = *p_cat_decoder->p_building_cat;
p_cat_decoder->b_current_valid = true;
/* Chain the sections */
if (p_cat_decoder->i_last_section_number)
{
for (int i = 0; i <= p_cat_decoder->i_last_section_number - 1; i++)
p_cat_decoder->ap_sections[i]->p_next = p_cat_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_cat_decoder));
/* Decode the sections */
dvbpsi_DecodeCATSections(p_cat_decoder->p_building_cat,
p_cat_decoder->ap_sections[0]);
......
......@@ -480,19 +480,7 @@ void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_de
p_eit_decoder->b_current_valid = true;
/* Chain the sections */
if (p_eit_decoder->i_last_section_number)
{
dvbpsi_psi_section_t * p_prev_section;
p_prev_section = p_eit_decoder->ap_sections[0];
for (unsigned int i = 1; i <= p_eit_decoder->i_last_section_number; i++)
{
if (p_eit_decoder->ap_sections[i] != NULL)
{
p_prev_section->p_next = p_eit_decoder->ap_sections[i];
p_prev_section = p_eit_decoder->ap_sections[i];
}
}
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_eit_decoder));
/* Decode the sections */
dvbpsi_DecodeEITSections(p_eit_decoder->p_building_eit, p_eit_decoder->ap_sections[0]);
......
......@@ -435,12 +435,7 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
p_nit_decoder->b_current_valid = true;
/* Chain the sections */
if (p_nit_decoder->i_last_section_number)
{
for (unsigned int i = 0; (int)i <= p_nit_decoder->i_last_section_number - 1; i++)
p_nit_decoder->ap_sections[i]->p_next =
p_nit_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_nit_decoder));
/* Decode the sections */
dvbpsi_DecodeNITSections(p_nit_decoder->p_building_nit,
......@@ -448,7 +443,6 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
/* Delete the sections */
dvbpsi_DeletePSISections(p_nit_decoder->ap_sections[0]);
p_nit_decoder->ap_sections[0] = NULL;
/* signal the new NIT */
p_nit_decoder->pf_nit_callback(p_nit_decoder->p_cb_data,
p_nit_decoder->p_building_nit);
......
......@@ -336,12 +336,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
p_pat_decoder->b_current_valid = true;
/* Chain the sections */
if (p_pat_decoder->i_last_section_number)
{
for (unsigned int i = 0; (int)i <= p_pat_decoder->i_last_section_number - 1; i++)
p_pat_decoder->ap_sections[i]->p_next =
p_pat_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_pat_decoder));
/* Decode the sections */
dvbpsi_DecodePATSections(p_pat_decoder->p_building_pat,
......
......@@ -398,12 +398,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio
p_pmt_decoder->current_pmt = *p_pmt_decoder->p_building_pmt;
p_pmt_decoder->b_current_valid = true;
/* Chain the sections */
if (p_pmt_decoder->i_last_section_number)
{
for (unsigned int i = 0; (int)i <= p_pmt_decoder->i_last_section_number - 1; i++)
p_pmt_decoder->ap_sections[i]->p_next =
p_pmt_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_pmt_decoder));
/* Decode the sections */
dvbpsi_DecodePMTSections(p_pmt_decoder->p_building_pmt,
p_pmt_decoder->ap_sections[0]);
......
......@@ -414,11 +414,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
p_sdt_decoder->current_sdt = *p_sdt_decoder->p_building_sdt;
p_sdt_decoder->b_current_valid = true;
/* Chain the sections */
if (p_sdt_decoder->i_last_section_number)
{
for (unsigned int i = 0; (int)i <= p_sdt_decoder->i_last_section_number - 1; i++)
p_sdt_decoder->ap_sections[i]->p_next = p_sdt_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_sdt_decoder));
/* Decode the sections */
dvbpsi_DecodeSDTSections(p_sdt_decoder->p_building_sdt,
p_sdt_decoder->ap_sections[0]);
......
......@@ -406,11 +406,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
p_sis_decoder->current_sis = *p_sis_decoder->p_building_sis;
p_sis_decoder->b_current_valid = true;
/* Chain the sections */
if (p_sis_decoder->i_last_section_number)
{
for (unsigned int i = 0; (int)i <= p_sis_decoder->i_last_section_number - 1; i++)
p_sis_decoder->ap_sections[i]->p_next = p_sis_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_sis_decoder));
/* Decode the sections */
dvbpsi_DecodeSISSections(p_dvbpsi, p_sis_decoder->p_building_sis,
p_sis_decoder->ap_sections[0]);
......
......@@ -384,11 +384,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
p_tot_decoder->current_tot = *p_tot_decoder->p_building_tot;
p_tot_decoder->b_current_valid = true;
/* Chain the sections */
if (p_tot_decoder->i_last_section_number)
{
for (uint8_t i = 0; i <= p_tot_decoder->i_last_section_number - 1; i++)
p_tot_decoder->ap_sections[i]->p_next = p_tot_decoder->ap_sections[i + 1];
}
dvbpsi_ChainSectionsDecoder(DVBPSI_DECODER(p_tot_decoder));
/* Decode the sections */
dvbpsi_DecodeTOTSections(p_dvbpsi, p_tot_decoder->p_building_tot,
p_tot_decoder->ap_sections[0]);
......
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