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

src/table/sis*: Cleanup

- Use bool for structure members that are used as bools
- Indentation
parent 9441b000
/***************************************************************************** /*****************************************************************************
* sis.c: SIS decoder/generator * sis.c: SIS decoder/generator
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* Copyright (C) 2010 VideoLAN * Copyright (C) 2010-2011 VideoLAN
* $Id:$ * $Id:$
* *
* Authors: Jean-Paul Saman <jpsaman@videolan.org> * Authors: Jean-Paul Saman <jpsaman@videolan.org>
...@@ -153,7 +153,7 @@ void dvbpsi_InitSIS(dvbpsi_sis_t *p_sis, uint8_t i_protocol_version) ...@@ -153,7 +153,7 @@ void dvbpsi_InitSIS(dvbpsi_sis_t *p_sis, uint8_t i_protocol_version)
p_sis->i_protocol_version = 0; /* must be 0 */ p_sis->i_protocol_version = 0; /* must be 0 */
/* encryption */ /* encryption */
p_sis->b_encrypted_packet = 0; p_sis->b_encrypted_packet = false;
p_sis->i_encryption_algorithm = 0; p_sis->i_encryption_algorithm = 0;
p_sis->i_pts_adjustment = (uint64_t)0; p_sis->i_pts_adjustment = (uint64_t)0;
...@@ -230,8 +230,6 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -230,8 +230,6 @@ void dvbpsi_GatherSISSections(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_sis_decoder_t * p_sis_decoder dvbpsi_sis_decoder_t * p_sis_decoder
= (dvbpsi_sis_decoder_t*)p_private_decoder; = (dvbpsi_sis_decoder_t*)p_private_decoder;
int b_append = 1;
int b_reinit = 0;
dvbpsi_debug(p_dvbpsi, "SIS decoder", dvbpsi_debug(p_dvbpsi, "SIS decoder",
"Table version %2d, " "i_table_id %2d, " "i_extension %5d, " "Table version %2d, " "i_table_id %2d, " "i_extension %5d, "
...@@ -247,32 +245,34 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -247,32 +245,34 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
dvbpsi_error(p_dvbpsi, "SIS decoder", dvbpsi_error(p_dvbpsi, "SIS 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 (p_section->b_syntax_indicator != 0) if (p_section->b_syntax_indicator)
{ {
/* Invalid section_syntax_indicator */ /* Invalid section_syntax_indicator */
dvbpsi_error(p_dvbpsi, "SIS decoder", dvbpsi_error(p_dvbpsi, "SIS decoder",
"invalid section (section_syntax_indicator != 0)"); "invalid section (section_syntax_indicator != false)");
b_append = 0; dvbpsi_DeletePSISections(p_section);
return;
} }
if (p_section->b_private_indicator != 0) if (p_section->b_private_indicator)
{ {
/* Invalid private_syntax_indicator */ /* Invalid private_syntax_indicator */
dvbpsi_error(p_dvbpsi, "SIS decoder", dvbpsi_error(p_dvbpsi, "SIS decoder",
"invalid private section (private_syntax_indicator != 0)"); "invalid private section (private_syntax_indicator != false)");
b_append = 0; dvbpsi_DeletePSISections(p_section);
return;
} }
/* Now if b_append is true then we have a valid SIS section */ bool b_reinit = false;
if (b_append)
{
/* TS discontinuity check */ /* TS discontinuity check */
if (p_demux->b_discontinuity) if (p_demux->b_discontinuity)
{ {
b_reinit = 1; b_reinit = true;
p_demux->b_discontinuity = false; p_demux->b_discontinuity = false;
} }
else else
...@@ -285,7 +285,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -285,7 +285,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
/* transport_stream_id */ /* transport_stream_id */
dvbpsi_error(p_dvbpsi, "SIS decoder", dvbpsi_error(p_dvbpsi, "SIS decoder",
"'protocol_version' differs"); "'protocol_version' differs");
b_reinit = 1; b_reinit = true;
} }
} }
else else
...@@ -293,8 +293,8 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -293,8 +293,8 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
if (p_sis_decoder->b_current_valid) if (p_sis_decoder->b_current_valid)
{ {
/* 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;
} }
} }
} }
...@@ -303,7 +303,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -303,7 +303,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
if (b_reinit) if (b_reinit)
{ {
/* Force redecoding */ /* Force redecoding */
p_sis_decoder->b_current_valid = 0; p_sis_decoder->b_current_valid = false;
/* Free structures */ /* Free structures */
if (p_sis_decoder->p_building_sis) if (p_sis_decoder->p_building_sis)
...@@ -313,24 +313,15 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -313,24 +313,15 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
} }
} }
/* Append the section to the list if wanted */
if (b_append)
{
/* Initialize the structures if it's the first section received */ /* Initialize the structures if it's the first section received */
if (!p_sis_decoder->p_building_sis) if (!p_sis_decoder->p_building_sis)
{ {
p_sis_decoder->p_building_sis = p_sis_decoder->p_building_sis = (dvbpsi_sis_t*)malloc(sizeof(dvbpsi_sis_t));
(dvbpsi_sis_t*)malloc(sizeof(dvbpsi_sis_t));
if (p_sis_decoder->p_building_sis) if (p_sis_decoder->p_building_sis)
dvbpsi_InitSIS(p_sis_decoder->p_building_sis, 0); dvbpsi_InitSIS(p_sis_decoder->p_building_sis, 0);
else else
dvbpsi_error(p_dvbpsi, "SIS decoder", "failed decoding section"); dvbpsi_error(p_dvbpsi, "SIS decoder", "failed decoding section");
} }
}
else
{
dvbpsi_DeletePSISections(p_section);
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -351,7 +342,7 @@ void dvbpsi_DecodeSISSections(dvbpsi_t* p_dvbpsi, dvbpsi_sis_t* p_sis, ...@@ -351,7 +342,7 @@ void dvbpsi_DecodeSISSections(dvbpsi_t* p_dvbpsi, dvbpsi_sis_t* p_sis,
p_sis->i_protocol_version = p_byte[3]; p_sis->i_protocol_version = p_byte[3];
p_sis->b_encrypted_packet = ((p_byte[4] & 0x80)>>8); p_sis->b_encrypted_packet = ((p_byte[4] & 0x80)>>8);
/* NOTE: cannot handle encrypted packet */ /* NOTE: cannot handle encrypted packet */
assert(p_sis->b_encrypted_packet == 1); assert(p_sis->b_encrypted_packet);
p_sis->i_encryption_algorithm = ((p_byte[4] & 0x7E) >> 1); p_sis->i_encryption_algorithm = ((p_byte[4] & 0x7E) >> 1);
p_sis->i_pts_adjustment = ((((uint64_t)p_byte[4] & 0x01) << 32) | p_sis->i_pts_adjustment = ((((uint64_t)p_byte[4] & 0x01) << 32) |
((uint64_t)p_byte[5] << 24) | ((uint64_t)p_byte[5] << 24) |
...@@ -388,7 +379,7 @@ void dvbpsi_DecodeSISSections(dvbpsi_t* p_dvbpsi, dvbpsi_sis_t* p_sis, ...@@ -388,7 +379,7 @@ void dvbpsi_DecodeSISSections(dvbpsi_t* p_dvbpsi, dvbpsi_sis_t* p_sis,
p_desc += 2 + i_length; p_desc += 2 + i_length;
} }
if (p_sis->b_encrypted_packet == 1) if (p_sis->b_encrypted_packet)
{ {
/* FIXME: Currently ignored */ /* FIXME: Currently ignored */
/* Calculate crc32 over decoded /* Calculate crc32 over decoded
...@@ -417,8 +408,8 @@ dvbpsi_psi_section_t *dvbpsi_GenSISSections(dvbpsi_t *p_dvbpsi, dvbpsi_sis_t* p_ ...@@ -417,8 +408,8 @@ dvbpsi_psi_section_t *dvbpsi_GenSISSections(dvbpsi_t *p_dvbpsi, dvbpsi_sis_t* p_
dvbpsi_psi_section_t * p_current = dvbpsi_NewPSISection(1024); dvbpsi_psi_section_t * p_current = dvbpsi_NewPSISection(1024);
p_current->i_table_id = 0xFC; p_current->i_table_id = 0xFC;
p_current->b_syntax_indicator = 0; p_current->b_syntax_indicator = false;
p_current->b_private_indicator = 0; p_current->b_private_indicator = false;
p_current->i_length = 3; /* header + CRC_32 */ p_current->i_length = 3; /* header + CRC_32 */
/* FIXME: looks weird */ /* FIXME: looks weird */
...@@ -428,7 +419,7 @@ dvbpsi_psi_section_t *dvbpsi_GenSISSections(dvbpsi_t *p_dvbpsi, dvbpsi_sis_t* p_ ...@@ -428,7 +419,7 @@ dvbpsi_psi_section_t *dvbpsi_GenSISSections(dvbpsi_t *p_dvbpsi, dvbpsi_sis_t* p_
p_current->p_data[3] = p_sis->i_protocol_version; p_current->p_data[3] = p_sis->i_protocol_version;
p_current->p_data[4] = p_sis->b_encrypted_packet ? 0x80 : 0x0; p_current->p_data[4] = p_sis->b_encrypted_packet ? 0x80 : 0x0;
/* NOTE: cannot handle encrypted packet */ /* NOTE: cannot handle encrypted packet */
assert(p_sis->b_encrypted_packet == 1); assert(p_sis->b_encrypted_packet);
p_current->p_data[4] |= ((p_sis->i_encryption_algorithm << 1) & 0x7E); p_current->p_data[4] |= ((p_sis->i_encryption_algorithm << 1) & 0x7E);
p_current->p_data[4] |= ((p_sis->i_pts_adjustment & 0x00800) >> 32); p_current->p_data[4] |= ((p_sis->i_pts_adjustment & 0x00800) >> 32);
......
/***************************************************************************** /*****************************************************************************
* sis.h * sis.h
* Copyright (c) 2010 VideoLAN * Copyright (c) 2010-2011 VideoLAN
* $Id$ * $Id$
* *
* Authors: Jean-Paul Saman <jpsaman@videolan.org> * Authors: Jean-Paul Saman <jpsaman@videolan.org>
...@@ -58,7 +58,7 @@ typedef struct dvbpsi_sis_s ...@@ -58,7 +58,7 @@ typedef struct dvbpsi_sis_s
shall be 0 */ shall be 0 */
/* encryption */ /* encryption */
int b_encrypted_packet; /*!< 1 when packet is bool b_encrypted_packet; /*!< 1 when packet is
encrypted */ encrypted */
uint8_t i_encryption_algorithm; /*!< Encryption algorithm uint8_t i_encryption_algorithm; /*!< Encryption algorithm
used */ used */
...@@ -134,8 +134,7 @@ bool dvbpsi_AttachSIS(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -134,8 +134,7 @@ bool dvbpsi_AttachSIS(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
* \param i_extension Table ID extension, here TS ID. * \param i_extension Table ID extension, here TS ID.
* \return nothing. * \return nothing.
*/ */
void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension);
uint16_t i_extension);
/***************************************************************************** /*****************************************************************************
* dvbpsi_InitSIS/dvbpsi_NewSIS * dvbpsi_InitSIS/dvbpsi_NewSIS
......
/***************************************************************************** /*****************************************************************************
* sis_private.h: private SIS structures * sis_private.h: private SIS structures
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* Copyright (c) 2010 VideoLAN * Copyright (c) 2010-2011 VideoLAN
* $Id$ * $Id$
* *
* Authors: Jean-Paul Saman <jpsaman@videolan.org> * Authors: Jean-Paul Saman <jpsaman@videolan.org>
...@@ -43,7 +43,7 @@ typedef struct dvbpsi_sis_decoder_s ...@@ -43,7 +43,7 @@ typedef struct dvbpsi_sis_decoder_s
dvbpsi_sis_t *current_sis; dvbpsi_sis_t *current_sis;
dvbpsi_sis_t *p_building_sis; dvbpsi_sis_t *p_building_sis;
int b_current_valid; bool b_current_valid;
} dvbpsi_sis_decoder_t; } dvbpsi_sis_decoder_t;
......
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