Commit a39ac177 authored by Jean-Paul Saman's avatar Jean-Paul Saman

libdvbpsi: API changes

- Add pointer to dvbpsi_t * to dvbpsi_BuildPSISection()
- Make dvbpsi_ValidTOTSection() return a boolean
- Make dvbpsi_ValidPSISection() return a boolean
parent f6f2cc05
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
#include <inttypes.h> #include <inttypes.h>
...@@ -99,7 +100,7 @@ void dvbpsi_DeletePSISections(dvbpsi_psi_section_t * p_section) ...@@ -99,7 +100,7 @@ void dvbpsi_DeletePSISections(dvbpsi_psi_section_t * p_section)
***************************************************************************** *****************************************************************************
* Check the CRC_32 if the section has b_syntax_indicator set. * Check the CRC_32 if the section has b_syntax_indicator set.
*****************************************************************************/ *****************************************************************************/
int dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section) bool dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section)
{ {
if(p_section->b_syntax_indicator) if(p_section->b_syntax_indicator)
{ {
...@@ -114,14 +115,14 @@ int dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section) ...@@ -114,14 +115,14 @@ int dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section)
} }
if(i_crc == 0) if(i_crc == 0)
return 1; return true;
else else
return 0; return false;
} }
else else
{ {
/* No check to do if b_syntax_indicator is 0 */ /* No check to do if b_syntax_indicator is 0 */
return 0; return false;
} }
} }
...@@ -131,7 +132,7 @@ int dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section) ...@@ -131,7 +132,7 @@ int dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section)
***************************************************************************** *****************************************************************************
* Build the section based on the information in the structure. * Build the section based on the information in the structure.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_BuildPSISection(dvbpsi_psi_section_t* p_section) void dvbpsi_BuildPSISection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section)
{ {
uint8_t* p_byte = p_section->p_data; uint8_t* p_byte = p_section->p_data;
...@@ -177,16 +178,14 @@ void dvbpsi_BuildPSISection(dvbpsi_psi_section_t* p_section) ...@@ -177,16 +178,14 @@ void dvbpsi_BuildPSISection(dvbpsi_psi_section_t* p_section)
p_section->p_payload_end[2] = (p_section->i_crc >> 8) & 0xff; p_section->p_payload_end[2] = (p_section->i_crc >> 8) & 0xff;
p_section->p_payload_end[3] = p_section->i_crc & 0xff; p_section->p_payload_end[3] = p_section->i_crc & 0xff;
#if 0
if(!dvbpsi_ValidPSISection(p_section)) if(!dvbpsi_ValidPSISection(p_section))
{ {
dvbpsi_error(handle,"misc PSI", "********************************************"); dvbpsi_error(p_dvbpsi, "misc PSI", "********************************************");
dvbpsi_error(handle,"misc PSI", "* Generated PSI section has a bad CRC_32. *"); dvbpsi_error(p_dvbpsi, "misc PSI", "* Generated PSI section has a bad CRC_32. *");
dvbpsi_error(handle,"misc PSI", "* THIS IS A BUG, PLEASE REPORT TO THE LIST *"); dvbpsi_error(p_dvbpsi, "misc PSI", "* THIS IS A BUG, PLEASE REPORT TO THE LIST *");
dvbpsi_error(handle,"misc PSI", "* --- libdvbpsi-devel@videolan.org --- *"); dvbpsi_error(p_dvbpsi, "misc PSI", "* --- libdvbpsi-devel@videolan.org --- *");
dvbpsi_error(handle,"misc PSI", "********************************************"); dvbpsi_error(p_dvbpsi, "misc PSI", "********************************************");
} }
#endif
} }
} }
...@@ -127,26 +127,27 @@ void dvbpsi_DeletePSISections(dvbpsi_psi_section_t * p_section); ...@@ -127,26 +127,27 @@ void dvbpsi_DeletePSISections(dvbpsi_psi_section_t * p_section);
* dvbpsi_ValidPSISection * dvbpsi_ValidPSISection
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn int dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section) * \fn bool dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section)
* \brief Validity check of a PSI section. * \brief Validity check of a PSI section.
* \param p_section pointer to the PSI section structure * \param p_section pointer to the PSI section structure
* \return boolean value (false if the section is not valid). * \return boolean value (false if the section is not valid).
* *
* Check the CRC_32 if the section has b_syntax_indicator set. * Check the CRC_32 if the section has b_syntax_indicator set.
*/ */
int dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section); bool dvbpsi_ValidPSISection(dvbpsi_psi_section_t* p_section);
/***************************************************************************** /*****************************************************************************
* dvbpsi_BuildPSISection * dvbpsi_BuildPSISection
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn void dvbpsi_BuildPSISection(dvbpsi_psi_section_t* p_section) * \fn void dvbpsi_BuildPSISection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section)
* \brief Build a valid section based on the information in the structure. * \brief Build a valid section based on the information in the structure.
* \param p_dvbpsi dvbpsi handle
* \param p_section pointer to the PSI section structure * \param p_section pointer to the PSI section structure
* \return nothing. * \return nothing.
*/ */
void dvbpsi_BuildPSISection(dvbpsi_psi_section_t* p_section); void dvbpsi_BuildPSISection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -717,7 +717,7 @@ dvbpsi_psi_section_t* dvbpsi_GenBATSections(dvbpsi_t *p_dvbpsi, dvbpsi_bat_t* p_ ...@@ -717,7 +717,7 @@ dvbpsi_psi_section_t* dvbpsi_GenBATSections(dvbpsi_t *p_dvbpsi, dvbpsi_bat_t* p_
while (p_prev != NULL) while (p_prev != NULL)
{ {
p_prev->i_last_number = p_current->i_number; p_prev->i_last_number = p_current->i_number;
dvbpsi_BuildPSISection(p_prev); dvbpsi_BuildPSISection(p_dvbpsi, p_prev);
p_prev = p_prev->p_next; p_prev = p_prev->p_next;
} }
return p_result; return p_result;
......
...@@ -427,7 +427,7 @@ dvbpsi_psi_section_t* dvbpsi_GenCATSections(dvbpsi_t* p_dvbpsi, dvbpsi_cat_t* p_ ...@@ -427,7 +427,7 @@ dvbpsi_psi_section_t* dvbpsi_GenCATSections(dvbpsi_t* p_dvbpsi, dvbpsi_cat_t* p_
while (p_prev != NULL) while (p_prev != NULL)
{ {
p_prev->i_last_number = p_current->i_number; p_prev->i_last_number = p_current->i_number;
dvbpsi_BuildPSISection(p_prev); dvbpsi_BuildPSISection(p_dvbpsi, p_prev);
p_prev = p_prev->p_next; p_prev = p_prev->p_next;
} }
return p_result; return p_result;
......
...@@ -705,7 +705,7 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_t *p_dvbpsi, ...@@ -705,7 +705,7 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_t *p_dvbpsi,
while (p_prev != NULL) while (p_prev != NULL)
{ {
p_prev->i_last_number = p_current->i_number; p_prev->i_last_number = p_current->i_number;
dvbpsi_BuildPSISection(p_prev); dvbpsi_BuildPSISection(p_dvbpsi, p_prev);
p_prev = p_prev->p_next; p_prev = p_prev->p_next;
} }
......
...@@ -459,7 +459,7 @@ dvbpsi_psi_section_t* dvbpsi_GenPATSections(dvbpsi_t *p_dvbpsi, ...@@ -459,7 +459,7 @@ dvbpsi_psi_section_t* dvbpsi_GenPATSections(dvbpsi_t *p_dvbpsi,
while(p_prev != NULL) while(p_prev != NULL)
{ {
p_prev->i_last_number = p_current->i_number; p_prev->i_last_number = p_current->i_number;
dvbpsi_BuildPSISection(p_prev); dvbpsi_BuildPSISection(p_dvbpsi, p_prev);
p_prev = p_prev->p_next; p_prev = p_prev->p_next;
} }
......
...@@ -654,7 +654,7 @@ dvbpsi_psi_section_t* dvbpsi_GenPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_pmt_t* p_ ...@@ -654,7 +654,7 @@ dvbpsi_psi_section_t* dvbpsi_GenPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_pmt_t* p_
while (p_prev != NULL) while (p_prev != NULL)
{ {
p_prev->i_last_number = p_current->i_number; p_prev->i_last_number = p_current->i_number;
dvbpsi_BuildPSISection(p_prev); dvbpsi_BuildPSISection(p_dvbpsi, p_prev);
p_prev = p_prev->p_next; p_prev = p_prev->p_next;
} }
......
...@@ -578,7 +578,7 @@ dvbpsi_psi_section_t *dvbpsi_GenSDTSections(dvbpsi_t *p_dvbpsi, dvbpsi_sdt_t* p_ ...@@ -578,7 +578,7 @@ dvbpsi_psi_section_t *dvbpsi_GenSDTSections(dvbpsi_t *p_dvbpsi, dvbpsi_sdt_t* p_
while (p_prev != NULL) while (p_prev != NULL)
{ {
p_prev->i_last_number = p_current->i_number; p_prev->i_last_number = p_current->i_number;
dvbpsi_BuildPSISection(p_prev); dvbpsi_BuildPSISection(p_dvbpsi, p_prev);
p_prev = p_prev->p_next; p_prev = p_prev->p_next;
} }
return p_result; return p_result;
......
...@@ -477,6 +477,6 @@ dvbpsi_psi_section_t *dvbpsi_GenSISSections(dvbpsi_t *p_dvbpsi, dvbpsi_sis_t* p_ ...@@ -477,6 +477,6 @@ dvbpsi_psi_section_t *dvbpsi_GenSISSections(dvbpsi_t *p_dvbpsi, dvbpsi_sis_t* p_
assert( i_desc_length == p_sis->i_descriptors_length); assert( i_desc_length == p_sis->i_descriptors_length);
/* Finalization */ /* Finalization */
dvbpsi_BuildPSISection(p_current); dvbpsi_BuildPSISection(p_dvbpsi, p_current);
return p_current; return p_current;
} }
...@@ -258,7 +258,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi, ...@@ -258,7 +258,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
***************************************************************************** *****************************************************************************
* Check the CRC_32 if the section has b_syntax_indicator set. * Check the CRC_32 if the section has b_syntax_indicator set.
*****************************************************************************/ *****************************************************************************/
int dvbpsi_ValidTOTSection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section) bool dvbpsi_ValidTOTSection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section)
{ {
if (p_section->i_table_id != 0x73) if (p_section->i_table_id != 0x73)
{ {
...@@ -268,9 +268,9 @@ int dvbpsi_ValidTOTSection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section) ...@@ -268,9 +268,9 @@ int dvbpsi_ValidTOTSection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section)
dvbpsi_error(p_dvbpsi, "TDT/TOT decoder", dvbpsi_error(p_dvbpsi, "TDT/TOT decoder",
"TDT has an invalid payload size (%d bytes) !!!", "TDT has an invalid payload size (%d bytes) !!!",
p_section->i_length); p_section->i_length);
return 0; return false;
} }
return 1; return true;
} }
/* Check the CRC_32 if it's a TOT */ /* Check the CRC_32 if it's a TOT */
...@@ -284,15 +284,15 @@ int dvbpsi_ValidTOTSection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section) ...@@ -284,15 +284,15 @@ int dvbpsi_ValidTOTSection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section)
} }
if (i_crc == 0) if (i_crc == 0)
return 1; return true;
else else
{ {
dvbpsi_error(p_dvbpsi, "TDT/TOT decoder", dvbpsi_error(p_dvbpsi, "TDT/TOT decoder",
"Bad CRC_32 (0x%08x) !!!", i_crc); "Bad CRC_32 (0x%08x) !!!", i_crc);
return 0; return false;
} }
return 1; return true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -413,7 +413,7 @@ dvbpsi_psi_section_t* dvbpsi_GenTOTSections(dvbpsi_t *p_dvbpsi, dvbpsi_tot_t* p_ ...@@ -413,7 +413,7 @@ dvbpsi_psi_section_t* dvbpsi_GenTOTSections(dvbpsi_t *p_dvbpsi, dvbpsi_tot_t* p_
p_result->i_length += 4; p_result->i_length += 4;
} }
dvbpsi_BuildPSISection(p_result); dvbpsi_BuildPSISection(p_dvbpsi, p_result);
if (p_result->i_table_id == 0x73) if (p_result->i_table_id == 0x73)
{ {
......
...@@ -59,7 +59,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi, ...@@ -59,7 +59,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
***************************************************************************** *****************************************************************************
* Check the CRC_32 if the section has b_syntax_indicator set. * Check the CRC_32 if the section has b_syntax_indicator set.
*****************************************************************************/ *****************************************************************************/
int dvbpsi_ValidTOTSection(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_section); bool dvbpsi_ValidTOTSection(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_section);
/***************************************************************************** /*****************************************************************************
* dvbpsi_DecodeTOTSections * dvbpsi_DecodeTOTSections
......
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