Commit 6a65c6c9 authored by Jean-Paul Saman's avatar Jean-Paul Saman

DVB PSI tables: use dvbpsi_CheckPSISection() utility functions.

Refactor out common code for checking PSI sections for PSI tables.
parent 58617799
...@@ -315,35 +315,24 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi, ...@@ -315,35 +315,24 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi,
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCB, "ATSC EIT decoder"))
dvbpsi_atsc_eit_decoder_t * p_eit_decoder = (dvbpsi_atsc_eit_decoder_t*)p_decoder;
if (!p_eit_decoder)
{ {
dvbpsi_error(p_dvbpsi, "ATSC EIT decoder", "No decoder specified");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
if (!p_section->b_syntax_indicator) /* We have a valid EIT section */
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_atsc_eit_decoder_t * p_eit_decoder = (dvbpsi_atsc_eit_decoder_t*)p_decoder;
if (!p_eit_decoder)
{ {
/* Invalid section_syntax_indicator */ dvbpsi_error(p_dvbpsi, "ATSC EIT decoder", "No decoder specified");
dvbpsi_error(p_dvbpsi, "ATSC EIT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
dvbpsi_debug(p_dvbpsi,"ATSC EIT decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
bool b_reinit = false; bool b_reinit = false;
/* We have a valid EIT section */
/* TS discontinuity check */ /* TS discontinuity check */
if (p_demux->b_discontinuity) if (p_demux->b_discontinuity)
{ {
......
...@@ -242,41 +242,24 @@ static void dvbpsi_atsc_GatherETTSections(dvbpsi_t* p_dvbpsi, ...@@ -242,41 +242,24 @@ static void dvbpsi_atsc_GatherETTSections(dvbpsi_t* p_dvbpsi,
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
// FIXME: Gather*Sections needs updating if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCC, "ATSC ETT decoder"))
// dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_atsc_ett_decoder_t* p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)p_decoder;
if (!p_ett_decoder)
{ {
dvbpsi_error(p_dvbpsi, "ATSC ETT decoder", "No decoder specified");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
if (!p_section->b_syntax_indicator) /* We have a valid ETT section */
{
/* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "ATSC ETT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section);
return;
}
if (p_section->i_table_id != 0xCC) // FIXME: Gather*Sections needs updating
// dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_atsc_ett_decoder_t* p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)p_decoder;
if (!p_ett_decoder)
{ {
/* Invalid section_syntax_indicator */ dvbpsi_error(p_dvbpsi, "ATSC ETT decoder", "No decoder specified");
dvbpsi_error(p_dvbpsi, "ATSC ETT decoder",
"invalid table id (0x%x)", p_section->i_table_id);
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
dvbpsi_debug(p_dvbpsi,"ATSC ETT decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
#if 0 #if 0
/* We have a valid ETT section */ /* We have a valid ETT section */
/* TS discontinuity check */ /* TS discontinuity check */
......
...@@ -344,36 +344,27 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi, ...@@ -344,36 +344,27 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi,
dvbpsi_decoder_t *p_decoder, dvbpsi_decoder_t *p_decoder,
dvbpsi_psi_section_t * p_section) dvbpsi_psi_section_t * p_section)
{ {
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
dvbpsi_atsc_mgt_decoder_t * p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)p_decoder; if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xC7, "ATSC MGT decoder"))
if (!p_mgt_decoder)
{ {
dvbpsi_error(p_dvbpsi, "ATSC MGT decoder", "No decoder specified");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
if(!p_section->b_syntax_indicator) /* We have a valid MGT section */
dvbpsi_atsc_mgt_decoder_t * p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)p_decoder;
if (!p_mgt_decoder)
{ {
/* Invalid section_syntax_indicator */ dvbpsi_error(p_dvbpsi, "ATSC MGT decoder", "No decoder specified");
dvbpsi_error(p_dvbpsi, "ATSC MGT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
dvbpsi_debug(p_dvbpsi, "ATSC MGT decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
bool b_reinit = false; bool b_reinit = false;
/* We have a valid MGT section */ dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
/* TS discontinuity check */ /* TS discontinuity check */
if (p_demux->b_discontinuity) if (p_demux->b_discontinuity)
{ {
......
...@@ -78,7 +78,7 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -78,7 +78,7 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, 0)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, 0))
{ {
dvbpsi_error(p_dvbpsi, "STT decoder", dvbpsi_error(p_dvbpsi, "ATSC STT decoder",
"Already a decoder for (table_id == 0x%02x)", "Already a decoder for (table_id == 0x%02x)",
i_table_id); i_table_id);
return false; return false;
...@@ -126,7 +126,7 @@ void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -126,7 +126,7 @@ void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
dvbpsi_error(p_dvbpsi, "STT Decoder", dvbpsi_error(p_dvbpsi, "ATSC STT Decoder",
"No such STT decoder (table_id == 0x%02x," "No such STT decoder (table_id == 0x%02x,"
"extension == 0x00)", "extension == 0x00)",
i_table_id); i_table_id);
...@@ -237,32 +237,22 @@ static void dvbpsi_atsc_GatherSTTSections(dvbpsi_t *p_dvbpsi, ...@@ -237,32 +237,22 @@ static void dvbpsi_atsc_GatherSTTSections(dvbpsi_t *p_dvbpsi,
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_atsc_stt_decoder_t *p_stt_decoder = (dvbpsi_atsc_stt_decoder_t*)p_decoder; if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCD, "ATSC STT decoder"))
if (!p_stt_decoder)
{ {
dvbpsi_error(p_dvbpsi, "EIT decoder", "No decoder specified");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
if (!p_section->b_syntax_indicator) /* */
dvbpsi_atsc_stt_decoder_t *p_stt_decoder = (dvbpsi_atsc_stt_decoder_t*)p_decoder;
if (!p_stt_decoder)
{ {
/* Invalid section_syntax_indicator */ dvbpsi_error(p_dvbpsi, "ATSC STT decoder", "No decoder specified");
dvbpsi_error(p_dvbpsi, "STT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
/* FIXME: looks different then from other tables decoders */ /* FIXME: looks different then from other tables decoders */
dvbpsi_debug(p_dvbpsi, "STT decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
dvbpsi_atsc_stt_t *p_stt; dvbpsi_atsc_stt_t *p_stt;
p_stt = dvbpsi_atsc_NewSTT(p_section->i_version, p_section->b_current_next); p_stt = dvbpsi_atsc_NewSTT(p_section->i_version, p_section->b_current_next);
if (p_stt) if (p_stt)
......
...@@ -107,7 +107,7 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -107,7 +107,7 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
dvbpsi_error(p_dvbpsi, "VCT decoder", dvbpsi_error(p_dvbpsi, "ATSC VCT decoder",
"Already a decoder for (table_id == 0x%02x," "Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)", "extension == 0x%02x)",
i_table_id, i_extension); i_table_id, i_extension);
...@@ -161,7 +161,7 @@ void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -161,7 +161,7 @@ void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if(p_subdec == NULL) if(p_subdec == NULL)
{ {
dvbpsi_error(p_dvbpsi, "VCT Decoder", dvbpsi_error(p_dvbpsi, "ATSC VCT Decoder",
"No such VCT decoder (table_id == 0x%02x," "No such VCT decoder (table_id == 0x%02x,"
"extension == 0x%04x)", "extension == 0x%04x)",
i_table_id, i_extension); i_table_id, i_extension);
...@@ -382,25 +382,22 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi, ...@@ -382,25 +382,22 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi,
dvbpsi_decoder_t *p_decoder, dvbpsi_decoder_t *p_decoder,
dvbpsi_psi_section_t * p_section) dvbpsi_psi_section_t * p_section)
{ {
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; assert(p_dvbpsi);
dvbpsi_atsc_vct_decoder_t * p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_decoder; assert(p_dvbpsi->p_private);
if (!p_section->b_syntax_indicator) const uint8_t i_table_id = (p_section->i_table_id == 0x8C ||
p_section->i_table_id == 0x9C) ?
p_section->i_table_id : 0x8C;
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, i_table_id, "ATSC VCT decoder"))
{ {
/* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "VCT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
dvbpsi_debug(p_dvbpsi, "VCT decoder", /* */
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, " dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
"section %3d up to %3d, " "current %1d", dvbpsi_atsc_vct_decoder_t * p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_decoder;
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
bool b_reinit = false; bool b_reinit = false;
......
...@@ -304,27 +304,17 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi, ...@@ -304,27 +304,17 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_bat_decoder_t * p_bat_decoder = (dvbpsi_bat_decoder_t *) p_decoder; dvbpsi_bat_decoder_t * p_bat_decoder = (dvbpsi_bat_decoder_t *) p_decoder;
bool b_reinit = false;
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
if (!p_section->b_syntax_indicator) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x4a, "BAT decoder"))
{ {
/* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "BAT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
dvbpsi_debug(p_dvbpsi, "BAT decoder", /* */
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, " bool b_reinit = false;
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
/* We have a valid BAT section */ /* We have a valid BAT section */
/* TS discontinuity check */ /* TS discontinuity check */
......
...@@ -188,36 +188,17 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -188,36 +188,17 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_cat_decoder_t* p_cat_decoder if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x01, "CAT decoder"))
= (dvbpsi_cat_decoder_t*)p_dvbpsi->p_private;
bool b_reinit = false;
if (p_section->i_table_id != 0x01)
{ {
/* Invalid table_id value */
dvbpsi_error(p_dvbpsi, "CAT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
if (!p_section->b_syntax_indicator) /* */
{ dvbpsi_cat_decoder_t* p_cat_decoder
/* Invalid section_syntax_indicator */ = (dvbpsi_cat_decoder_t*)p_dvbpsi->p_private;
dvbpsi_error(p_dvbpsi, "CAT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section);
return;
}
dvbpsi_debug(p_dvbpsi, "CAT decoder", bool b_reinit = false;
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
/* TS discontinuity check */ /* TS discontinuity check */
if (p_cat_decoder->b_discontinuity) if (p_cat_decoder->b_discontinuity)
......
...@@ -276,32 +276,24 @@ dvbpsi_descriptor_t* dvbpsi_EITEventAddDescriptor( dvbpsi_eit_event_t* p_event, ...@@ -276,32 +276,24 @@ dvbpsi_descriptor_t* dvbpsi_EITEventAddDescriptor( dvbpsi_eit_event_t* p_event,
void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_decoder, void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_decoder,
dvbpsi_psi_section_t *p_section) dvbpsi_psi_section_t *p_section)
{ {
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_eit_decoder_t* p_eit_decoder
= (dvbpsi_eit_decoder_t*)p_private_decoder;
bool b_reinit = false;
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_debug(p_dvbpsi, "EIT decoder", const uint8_t i_table_id = (p_section->i_table_id >= 0x4e &&
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, " p_section->i_table_id <= 0x6f) ?
"section %3d up to %3d, " "current %1d", p_section->i_table_id : 0x4e;
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
if (!p_section->b_syntax_indicator) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, i_table_id, "EIT decoder"))
{ {
/* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "EIT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
/* We have a valid EIT section */ /* We have a valid EIT section */
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_eit_decoder_t* p_eit_decoder
= (dvbpsi_eit_decoder_t*)p_private_decoder;
bool b_reinit = false;
/* TS discontinuity check */ /* TS discontinuity check */
if (p_demux->b_discontinuity) if (p_demux->b_discontinuity)
......
...@@ -296,36 +296,21 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -296,36 +296,21 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
dvbpsi_decoder_t *p_private_decoder, dvbpsi_decoder_t *p_private_decoder,
dvbpsi_psi_section_t *p_section) dvbpsi_psi_section_t *p_section)
{ {
dvbpsi_nit_decoder_t* p_nit_decoder
= (dvbpsi_nit_decoder_t*)p_private_decoder;
assert(p_dvbpsi); assert(p_dvbpsi);
dvbpsi_debug(p_dvbpsi, "NIT decoder", const uint8_t i_table_id = ((p_section->i_table_id == 0x40) ||
"Table version %2d, " "i_extension %5d, " (p_section->i_table_id == 0x41)) ?
"section %3d up to %3d, " "current %1d", p_section->i_table_id : 0x40;
p_section->i_version, p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
if (p_section->i_table_id != 0x40 && p_section->i_table_id != 0x41) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, i_table_id, "NIT decoder"))
{ {
/* Invalid table_id value */
dvbpsi_error(p_dvbpsi, "NIT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
if (!p_section->b_syntax_indicator) /* */
{ dvbpsi_nit_decoder_t* p_nit_decoder
/* Invalid section_syntax_indicator */ = (dvbpsi_nit_decoder_t*)p_private_decoder;
dvbpsi_error(p_dvbpsi, "NIT decoder",
"invalid section (section_syntax_indicator == false)");
dvbpsi_DeletePSISections(p_section);
return;
}
/* Now if b_append is true then we have a valid NIT section */ /* Now if b_append is true then we have a valid NIT section */
if (p_nit_decoder->i_network_id != p_section->i_extension) if (p_nit_decoder->i_network_id != p_section->i_extension)
......
...@@ -255,37 +255,6 @@ static bool dvbpsi_CheckPAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section) ...@@ -255,37 +255,6 @@ static bool dvbpsi_CheckPAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
return b_reinit; return b_reinit;
} }
static bool dvbpsi_CheckTable(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section,
const uint8_t table_id, const char *psz_table_name)
{
assert(p_dvbpsi);
assert(p_section);
if (p_section->i_table_id != table_id)
{
/* Invalid table_id value */
dvbpsi_error(p_dvbpsi, psz_table_name,
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
goto error;
}
if (!p_section->b_syntax_indicator)
{
/* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, psz_table_name,
"invalid section (section_syntax_indicator == 0)");
goto error;
}
return true;
error:
dvbpsi_DeletePSISections(p_section);
p_section = NULL;
return false;
}
/***************************************************************************** /*****************************************************************************
* dvbpsi_GatherPATSections * dvbpsi_GatherPATSections
***************************************************************************** *****************************************************************************
...@@ -298,17 +267,13 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio ...@@ -298,17 +267,13 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
if (!dvbpsi_CheckTable(p_dvbpsi, p_section, 0x00, "PAT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x00, "PAT decoder"))
{
dvbpsi_DeletePSISections(p_section);
return; return;
}
/* Now we have a valid PAT section */ /* Now we have a valid PAT section */
dvbpsi_debug(p_dvbpsi, "PAT decoder",
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
p_pat_decoder = (dvbpsi_pat_decoder_t *)p_dvbpsi->p_private; p_pat_decoder = (dvbpsi_pat_decoder_t *)p_dvbpsi->p_private;
/* TS discontinuity check */ /* TS discontinuity check */
......
...@@ -263,36 +263,15 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio ...@@ -263,36 +263,15 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_pmt_decoder_t* p_pmt_decoder = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_private; if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x02, "PMT decoder"))
assert(p_pmt_decoder);
bool b_reinit = false;
dvbpsi_debug(p_dvbpsi, "PMT decoder",
"Table version %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
if (p_section->i_table_id != 0x02)
{ {
/* Invalid table_id value */
dvbpsi_error(p_dvbpsi, "PMT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
if (!p_section->b_syntax_indicator) /* */
{ dvbpsi_pmt_decoder_t* p_pmt_decoder = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_private;
/* Invalid section_syntax_indicator */ assert(p_pmt_decoder);
dvbpsi_error(p_dvbpsi, "PMT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section);
return;
}
/* Now if b_append is true then we have a valid PMT section */ /* Now if b_append is true then we have a valid PMT section */
if (p_pmt_decoder->i_program_number != p_section->i_extension) if (p_pmt_decoder->i_program_number != p_section->i_extension)
...@@ -303,6 +282,8 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio ...@@ -303,6 +282,8 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio
return; return;
} }
bool b_reinit = false;
/* TS discontinuity check */ /* TS discontinuity check */
if (p_pmt_decoder->b_discontinuity) if (p_pmt_decoder->b_discontinuity)
{ {
......
...@@ -283,27 +283,17 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi, ...@@ -283,27 +283,17 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private; if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x42, "SDT decoder"))
dvbpsi_sdt_decoder_t *p_sdt_decoder
= (dvbpsi_sdt_decoder_t*)p_private_decoder;
dvbpsi_debug(p_dvbpsi, "SDT decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
if (!p_section->b_syntax_indicator)
{ {
/* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "SDT decoder",
"invalid section (section_syntax_indicator == 0)");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
/* */
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private;
dvbpsi_sdt_decoder_t *p_sdt_decoder
= (dvbpsi_sdt_decoder_t*)p_private_decoder;
bool b_reinit = false; bool b_reinit = false;
/* TS discontinuity check */ /* TS discontinuity check */
......
...@@ -236,36 +236,16 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -236,36 +236,16 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xFC, "SIS decoder"))
dvbpsi_sis_decoder_t * p_sis_decoder = (dvbpsi_sis_decoder_t*)p_decoder;
dvbpsi_debug(p_dvbpsi, "SIS decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
"section %3d up to %3d, " "current %1d",
p_section->i_version, p_section->i_table_id,
p_section->i_extension,
p_section->i_number, p_section->i_last_number,
p_section->b_current_next);
if (p_section->i_table_id != 0xFC)
{
/* Invalid table_id value */
dvbpsi_error(p_dvbpsi, "SIS decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
dvbpsi_DeletePSISections(p_section);
return;
}
if (p_section->b_syntax_indicator)
{ {
/* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "SIS decoder",
"invalid section (section_syntax_indicator != false)");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
/* */
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_sis_decoder_t * p_sis_decoder = (dvbpsi_sis_decoder_t*)p_decoder;
if (p_section->b_private_indicator) if (p_section->b_private_indicator)
{ {
/* Invalid private_syntax_indicator */ /* Invalid private_syntax_indicator */
......
...@@ -74,7 +74,8 @@ bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -74,7 +74,8 @@ bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
} }
dvbpsi_tot_decoder_t *p_tot_decoder; dvbpsi_tot_decoder_t *p_tot_decoder;
p_tot_decoder = (dvbpsi_tot_decoder_t*)calloc(1, sizeof(dvbpsi_tot_decoder_t)); p_tot_decoder = (dvbpsi_tot_decoder_t *) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_tot_decoder_t));
if (p_tot_decoder == NULL) if (p_tot_decoder == NULL)
return false; return false;
...@@ -213,29 +214,20 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi, ...@@ -213,29 +214,20 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_tot_decoder_t* p_tot_decoder const uint8_t i_table_id = ((p_section->i_table_id == 0x70 ||
= (dvbpsi_tot_decoder_t*)p_decoder; p_section->i_table_id == 0x73)) ?
p_section->i_table_id : 0x70;
dvbpsi_debug(p_dvbpsi, "TDT/TOT decoder", "got a section");
if (p_section->i_table_id != 0x70 && p_section->i_table_id != 0x73) p_section->b_syntax_indicator = true;
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, i_table_id, "TDT/TOT decoder"))
{ {
/* Invalid table_id value */
dvbpsi_error(p_dvbpsi, "TDT/TOT decoder",
"invalid section (table_id == 0x%02x)",
p_section->i_table_id);
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
if (p_section->b_syntax_indicator != false) /* Valid TDT/TOT section */
{ dvbpsi_tot_decoder_t* p_tot_decoder
/* Invalid section_syntax_indicator */ = (dvbpsi_tot_decoder_t*)p_decoder;
dvbpsi_error(p_dvbpsi, "TDT/TOT decoder",
"invalid section (section_syntax_indicator != 0)");
dvbpsi_DeletePSISections(p_section);
return;
}
/* TS discontinuity check */ /* TS discontinuity check */
if (p_tot_decoder->b_discontinuity) if (p_tot_decoder->b_discontinuity)
......
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