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

src/table/nit*: Cleanup

- Use bool for structure members that are used as bools
- Indentation
parent e950dbfb
/***************************************************************************** /*****************************************************************************
* nit.c: NIT decoder/generator * nit.c: NIT decoder/generator
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN * Copyright (C) 2001-2011 VideoLAN
* $Id$ * $Id$
* *
* Authors: Johann Hanne * Authors: Johann Hanne
...@@ -101,7 +101,7 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -101,7 +101,7 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
p_nit_decoder->pf_nit_callback = pf_callback; p_nit_decoder->pf_nit_callback = pf_callback;
p_nit_decoder->p_cb_data = p_cb_data; p_nit_decoder->p_cb_data = p_cb_data;
/* NIT decoder initial state */ /* NIT decoder initial state */
p_nit_decoder->b_current_valid = 0; p_nit_decoder->b_current_valid = false;
p_nit_decoder->p_building_nit = NULL; p_nit_decoder->p_building_nit = NULL;
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
p_nit_decoder->ap_sections[i] = NULL; p_nit_decoder->ap_sections[i] = NULL;
...@@ -157,7 +157,7 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, ...@@ -157,7 +157,7 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id,
* Initialize a pre-allocated dvbpsi_nit_t structure. * Initialize a pre-allocated dvbpsi_nit_t structure.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id, void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id,
uint8_t i_version, int b_current_next) uint8_t i_version, bool b_current_next)
{ {
p_nit->i_network_id = i_network_id; p_nit->i_network_id = i_network_id;
p_nit->i_version = i_version; p_nit->i_version = i_version;
...@@ -281,8 +281,8 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -281,8 +281,8 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
{ {
dvbpsi_nit_decoder_t* p_nit_decoder dvbpsi_nit_decoder_t* p_nit_decoder
= (dvbpsi_nit_decoder_t*)p_private_decoder; = (dvbpsi_nit_decoder_t*)p_private_decoder;
int b_append = 1;
int b_reinit = 0; assert(p_dvbpsi);
dvbpsi_debug(p_dvbpsi, "NIT decoder", dvbpsi_debug(p_dvbpsi, "NIT decoder",
"Table version %2d, " "i_extension %5d, " "Table version %2d, " "i_extension %5d, "
...@@ -297,31 +297,34 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -297,31 +297,34 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
dvbpsi_error(p_dvbpsi, "NIT decoder", dvbpsi_error(p_dvbpsi, "NIT decoder",
"invalid section (table_id == 0x%02x)", "invalid section (table_id == 0x%02x)",
p_section->i_table_id); p_section->i_table_id);
b_append = 0; dvbpsi_DeletePSISections(p_section);
return;
} }
if (b_append && !p_section->b_syntax_indicator) if (!p_section->b_syntax_indicator)
{ {
/* Invalid section_syntax_indicator */ /* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "NIT decoder", dvbpsi_error(p_dvbpsi, "NIT decoder",
"invalid section (section_syntax_indicator == 0)"); "invalid section (section_syntax_indicator == false)");
b_append = 0; 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 (b_append && (p_nit_decoder->i_network_id != p_section->i_extension)) if (p_nit_decoder->i_network_id != p_section->i_extension)
{ {
/* Invalid program_number */ /* Invalid program_number */
dvbpsi_error(p_dvbpsi, "NIT decoder", "'network_id' don't match"); dvbpsi_error(p_dvbpsi, "NIT decoder", "'network_id' don't match");
b_append = 0; dvbpsi_DeletePSISections(p_section);
return;
} }
if (b_append) bool b_reinit = false;
{
/* TS discontinuity check */ /* TS discontinuity check */
if (p_nit_decoder->b_discontinuity) if (p_nit_decoder->b_discontinuity)
{ {
b_reinit = 1; b_reinit = true;
p_nit_decoder->b_discontinuity = false; p_nit_decoder->b_discontinuity = false;
} }
else else
...@@ -335,7 +338,7 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -335,7 +338,7 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
dvbpsi_error(p_dvbpsi, "NIT decoder", dvbpsi_error(p_dvbpsi, "NIT decoder",
"'version_number' differs" "'version_number' differs"
" whereas no discontinuity has occured"); " whereas no discontinuity has occured");
b_reinit = 1; b_reinit = true;
} }
else if (p_nit_decoder->i_last_section_number else if (p_nit_decoder->i_last_section_number
!= p_section->i_last_number) != p_section->i_last_number)
...@@ -344,19 +347,18 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -344,19 +347,18 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
dvbpsi_error(p_dvbpsi, "NIT decoder", dvbpsi_error(p_dvbpsi, "NIT decoder",
"'last_section_number' differs" "'last_section_number' differs"
" whereas no discontinuity has occured"); " whereas no discontinuity has occured");
b_reinit = 1; b_reinit = true;
} }
} }
else else
{ {
if ( (p_nit_decoder->b_current_valid) if ( (p_nit_decoder->b_current_valid)
&& (p_nit_decoder->current_nit.i_version == p_section->i_version) && (p_nit_decoder->current_nit.i_version == p_section->i_version)
&& (p_nit_decoder->current_nit.b_current_next == && (p_nit_decoder->current_nit.b_current_next == p_section->b_current_next))
p_section->b_current_next))
{ {
/* Don't decode since this version is already decoded */ /* Don't decode since this version is already decoded */
b_append = 0; dvbpsi_DeletePSISections(p_section);
} return;;
} }
} }
} }
...@@ -365,7 +367,7 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -365,7 +367,7 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
if (b_reinit) if (b_reinit)
{ {
/* Force redecoding */ /* Force redecoding */
p_nit_decoder->b_current_valid = 0; p_nit_decoder->b_current_valid = false;
/* Free structures */ /* Free structures */
if(p_nit_decoder->p_building_nit) if(p_nit_decoder->p_building_nit)
{ {
...@@ -383,11 +385,6 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -383,11 +385,6 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
} }
} }
/* Append the section to the list if wanted */
if (b_append)
{
int b_complete;
/* Initialize the structures if it's the first section received */ /* Initialize the structures if it's the first section received */
if (!p_nit_decoder->p_building_nit) if (!p_nit_decoder->p_building_nit)
{ {
...@@ -412,20 +409,21 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -412,20 +409,21 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
p_nit_decoder->ap_sections[p_section->i_number] = p_section; p_nit_decoder->ap_sections[p_section->i_number] = p_section;
/* Check if we have all the sections */ /* Check if we have all the sections */
b_complete = 0; bool b_complete = false;
for (unsigned int i = 0; i <= p_nit_decoder->i_last_section_number; i++) for (unsigned int i = 0; i <= p_nit_decoder->i_last_section_number; i++)
{ {
if (!p_nit_decoder->ap_sections[i]) if (!p_nit_decoder->ap_sections[i])
break; break;
if (i == p_nit_decoder->i_last_section_number) if (i == p_nit_decoder->i_last_section_number)
b_complete = 1; b_complete = true;
} }
if (b_complete) if (b_complete)
{ {
/* Save the current information */ /* Save the current information */
p_nit_decoder->current_nit = *p_nit_decoder->p_building_nit; p_nit_decoder->current_nit = *p_nit_decoder->p_building_nit;
p_nit_decoder->b_current_valid = 1; p_nit_decoder->b_current_valid = true;
/* Chain the sections */ /* Chain the sections */
if (p_nit_decoder->i_last_section_number) if (p_nit_decoder->i_last_section_number)
{ {
...@@ -446,11 +444,6 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -446,11 +444,6 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
for (unsigned int i = 0; i <= p_nit_decoder->i_last_section_number; i++) for (unsigned int i = 0; i <= p_nit_decoder->i_last_section_number; i++)
p_nit_decoder->ap_sections[i] = NULL; p_nit_decoder->ap_sections[i] = NULL;
} }
}
else
{
dvbpsi_DeletePSISections(p_section);
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -531,8 +524,8 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_t *p_dvbpsi, ...@@ -531,8 +524,8 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_t *p_dvbpsi,
uint8_t * p_transport_stream_loop_length; uint8_t * p_transport_stream_loop_length;
p_current->i_table_id = i_table_id; p_current->i_table_id = i_table_id;
p_current->b_syntax_indicator = 1; p_current->b_syntax_indicator = true;
p_current->b_private_indicator = 0; p_current->b_private_indicator = false;
p_current->i_length = 13; /* including CRC_32 */ p_current->i_length = 13; /* including CRC_32 */
p_current->i_extension = p_nit->i_network_id; p_current->i_extension = p_nit->i_network_id;
p_current->i_version = p_nit->i_version; p_current->i_version = p_nit->i_version;
...@@ -564,8 +557,8 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_t *p_dvbpsi, ...@@ -564,8 +557,8 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_t *p_dvbpsi,
p_prev->p_next = p_current; p_prev->p_next = p_current;
p_current->i_table_id = i_table_id; p_current->i_table_id = i_table_id;
p_current->b_syntax_indicator = 1; p_current->b_syntax_indicator = true;
p_current->b_private_indicator = 0; p_current->b_private_indicator = false;
p_current->i_length = 13; /* including CRC_32 */ p_current->i_length = 13; /* including CRC_32 */
p_current->i_extension = p_nit->i_network_id; p_current->i_extension = p_nit->i_network_id;
p_current->i_version = p_nit->i_version; p_current->i_version = p_nit->i_version;
...@@ -635,8 +628,8 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_t *p_dvbpsi, ...@@ -635,8 +628,8 @@ dvbpsi_psi_section_t* dvbpsi_GenNITSections(dvbpsi_t *p_dvbpsi,
p_prev->p_next = p_current; p_prev->p_next = p_current;
p_current->i_table_id = i_table_id; p_current->i_table_id = i_table_id;
p_current->b_syntax_indicator = 1; p_current->b_syntax_indicator = true;
p_current->b_private_indicator = 0; p_current->b_private_indicator = false;
p_current->i_length = 13; /* including CRC_32 */ p_current->i_length = 13; /* including CRC_32 */
p_current->i_extension = p_nit->i_network_id; p_current->i_extension = p_nit->i_network_id;
p_current->i_version = p_nit->i_version; p_current->i_version = p_nit->i_version;
......
/***************************************************************************** /*****************************************************************************
* nit.h * nit.h
* Copyright (C) 2001-2010 VideoLAN * Copyright (C) 2001-2011 VideoLAN
* $Id$ * $Id$
* *
* Authors: Johann Hanne * Authors: Johann Hanne
...@@ -84,7 +84,7 @@ typedef struct dvbpsi_nit_s ...@@ -84,7 +84,7 @@ typedef struct dvbpsi_nit_s
{ {
uint16_t i_network_id; /*!< network_id */ uint16_t i_network_id; /*!< network_id */
uint8_t i_version; /*!< version_number */ uint8_t i_version; /*!< version_number */
int b_current_next; /*!< current_next_indicator */ bool b_current_next; /*!< current_next_indicator */
dvbpsi_descriptor_t * p_first_descriptor; /*!< descriptor list */ dvbpsi_descriptor_t * p_first_descriptor; /*!< descriptor list */
...@@ -141,7 +141,7 @@ void dvbpsi_DetachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -141,7 +141,7 @@ void dvbpsi_DetachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id, * \fn void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id,
uint8_t i_version, int b_current_next) uint8_t i_version, bool b_current_next)
* \brief Initialize a user-allocated dvbpsi_nit_t structure. * \brief Initialize a user-allocated dvbpsi_nit_t structure.
* \param p_nit pointer to the NIT structure * \param p_nit pointer to the NIT structure
* \param i_network_id network id * \param i_network_id network id
...@@ -150,7 +150,7 @@ void dvbpsi_DetachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -150,7 +150,7 @@ void dvbpsi_DetachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
* \return nothing. * \return nothing.
*/ */
void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id, void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id,
uint8_t i_version, int b_current_next); uint8_t i_version, bool b_current_next);
/*! /*!
* \def dvbpsi_NewNIT(p_nit, i_network_id, * \def dvbpsi_NewNIT(p_nit, i_network_id,
...@@ -208,9 +208,9 @@ do { \ ...@@ -208,9 +208,9 @@ do { \
* \param p_data descriptor's data * \param p_data descriptor's data
* \return a pointer to the added descriptor. * \return a pointer to the added descriptor.
*/ */
dvbpsi_descriptor_t* dvbpsi_NITAddDescriptor(dvbpsi_nit_t* p_nit, dvbpsi_descriptor_t* dvbpsi_NITAddDescriptor(dvbpsi_nit_t *p_nit,
uint8_t i_tag, uint8_t i_length, uint8_t i_tag, uint8_t i_length,
uint8_t* p_data); uint8_t *p_data);
/***************************************************************************** /*****************************************************************************
* dvbpsi_NITAddTS * dvbpsi_NITAddTS
......
/***************************************************************************** /*****************************************************************************
* nit_private.h: private NIT structures * nit_private.h: private NIT structures
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN * Copyright (C) 2001-2011 VideoLAN
* $Id$ * $Id$
* *
* Authors: Johann Hanne * Authors: Johann Hanne
...@@ -47,7 +47,7 @@ typedef struct dvbpsi_nit_decoder_s ...@@ -47,7 +47,7 @@ typedef struct dvbpsi_nit_decoder_s
dvbpsi_nit_t current_nit; dvbpsi_nit_t current_nit;
dvbpsi_nit_t * p_building_nit; dvbpsi_nit_t * p_building_nit;
int b_current_valid; bool b_current_valid;
uint8_t i_last_section_number; uint8_t i_last_section_number;
dvbpsi_psi_section_t * ap_sections [256]; dvbpsi_psi_section_t * ap_sections [256];
......
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