Commit 0c2c5155 authored by Jean-Paul Saman's avatar Jean-Paul Saman

dvbpsi decoder cleanup

- rename p_dvbpsi->p_private to p_dvbpsi->p_decoder
- use dvbpsi_NewDecoder() where possible
parent f2b2ab34
...@@ -54,7 +54,7 @@ bool dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi, ...@@ -54,7 +54,7 @@ bool dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
void * p_new_cb_data) void * p_new_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private == NULL); assert(p_dvbpsi->p_decoder == NULL);
dvbpsi_demux_t *p_demux; dvbpsi_demux_t *p_demux;
p_demux = (dvbpsi_demux_t*) dvbpsi_NewDecoder(&dvbpsi_Demux, 4096, true, p_demux = (dvbpsi_demux_t*) dvbpsi_NewDecoder(&dvbpsi_Demux, 4096, true,
...@@ -67,7 +67,7 @@ bool dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi, ...@@ -67,7 +67,7 @@ bool dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
p_demux->pf_new_callback = pf_new_cb; p_demux->pf_new_callback = pf_new_cb;
p_demux->p_new_cb_data = p_new_cb_data; p_demux->p_new_cb_data = p_new_cb_data;
p_dvbpsi->p_private = (void *)p_demux; p_dvbpsi->p_decoder = DVBPSI_DECODER(p_demux);
return true; return true;
} }
...@@ -102,9 +102,9 @@ dvbpsi_demux_subdec_t * dvbpsi_demuxGetSubDec(dvbpsi_demux_t * p_demux, ...@@ -102,9 +102,9 @@ dvbpsi_demux_subdec_t * dvbpsi_demuxGetSubDec(dvbpsi_demux_t * p_demux,
void dvbpsi_Demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section) void dvbpsi_Demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t * p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private; dvbpsi_demux_t * p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t * p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id, dvbpsi_demux_subdec_t * p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension); p_section->i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
...@@ -133,9 +133,9 @@ void dvbpsi_Demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section) ...@@ -133,9 +133,9 @@ void dvbpsi_Demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi) void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec = p_demux->p_first_subdec; dvbpsi_demux_subdec_t* p_subdec = p_demux->p_first_subdec;
while (p_subdec) while (p_subdec)
...@@ -149,8 +149,8 @@ void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi) ...@@ -149,8 +149,8 @@ void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi)
else free(p_subdec_temp); else free(p_subdec_temp);
} }
dvbpsi_DeleteDecoder((dvbpsi_decoder_t *)p_dvbpsi->p_private); dvbpsi_DeleteDecoder(p_dvbpsi->p_decoder);
p_dvbpsi->p_private = NULL; p_dvbpsi->p_decoder = NULL;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -146,24 +146,24 @@ uint32_t dvbpsi_crc32_table[256] = ...@@ -146,24 +146,24 @@ uint32_t dvbpsi_crc32_table[256] =
*****************************************************************************/ *****************************************************************************/
dvbpsi_t *dvbpsi_NewHandle(dvbpsi_message_cb callback, enum dvbpsi_msg_level level) dvbpsi_t *dvbpsi_NewHandle(dvbpsi_message_cb callback, enum dvbpsi_msg_level level)
{ {
dvbpsi_t *handle = calloc(1, sizeof(dvbpsi_t)); dvbpsi_t *p_dvbpsi = calloc(1, sizeof(dvbpsi_t));
if (handle != NULL) if (p_dvbpsi != NULL)
{ {
handle->p_private = NULL; p_dvbpsi->p_decoder = NULL;
handle->pf_message = callback; p_dvbpsi->pf_message = callback;
handle->i_msg_level = level; p_dvbpsi->i_msg_level = level;
} }
return handle; return p_dvbpsi;
} }
/***************************************************************************** /*****************************************************************************
* dvbpsi_DeleteHandle * dvbpsi_DeleteHandle
*****************************************************************************/ *****************************************************************************/
void dvbpsi_DeleteHandle(dvbpsi_t *handle) void dvbpsi_DeleteHandle(dvbpsi_t *p_dvbpsi)
{ {
assert(handle->p_private == NULL); assert(p_dvbpsi->p_decoder == NULL);
handle->pf_message = NULL; p_dvbpsi->pf_message = NULL;
free(handle); free(p_dvbpsi);
} }
/***************************************************************************** /*****************************************************************************
...@@ -299,7 +299,7 @@ void dvbpsi_DeleteDecoder(dvbpsi_decoder_t *p_decoder) ...@@ -299,7 +299,7 @@ void dvbpsi_DeleteDecoder(dvbpsi_decoder_t *p_decoder)
*****************************************************************************/ *****************************************************************************/
bool dvbpsi_HasDecoder(dvbpsi_t *p_dvbpsi) bool dvbpsi_HasDecoder(dvbpsi_t *p_dvbpsi)
{ {
if (p_dvbpsi && p_dvbpsi->p_private) if (p_dvbpsi && p_dvbpsi->p_decoder)
return true; return true;
else else
return false; return false;
...@@ -310,7 +310,7 @@ bool dvbpsi_HasDecoder(dvbpsi_t *p_dvbpsi) ...@@ -310,7 +310,7 @@ bool dvbpsi_HasDecoder(dvbpsi_t *p_dvbpsi)
***************************************************************************** *****************************************************************************
* Injection of a TS packet into a PSI decoder. * Injection of a TS packet into a PSI decoder.
*****************************************************************************/ *****************************************************************************/
bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data) bool dvbpsi_PushPacket(dvbpsi_t *p_dvbpsi, uint8_t* p_data)
{ {
uint8_t i_expected_counter; /* Expected continuity counter */ uint8_t i_expected_counter; /* Expected continuity counter */
dvbpsi_psi_section_t* p_section; /* Current section */ dvbpsi_psi_section_t* p_section; /* Current section */
...@@ -321,13 +321,13 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data) ...@@ -321,13 +321,13 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
int i_available; /* Byte count available in the int i_available; /* Byte count available in the
packet */ packet */
dvbpsi_decoder_t *p_decoder = (dvbpsi_decoder_t *)handle->p_private; dvbpsi_decoder_t *p_decoder = p_dvbpsi->p_decoder;
assert(p_decoder); assert(p_decoder);
/* TS start code */ /* TS start code */
if (p_data[0] != 0x47) if (p_data[0] != 0x47)
{ {
dvbpsi_error(handle, "PSI decoder", "not a TS packet"); dvbpsi_error(p_dvbpsi, "PSI decoder", "not a TS packet");
return false; return false;
} }
...@@ -343,7 +343,7 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data) ...@@ -343,7 +343,7 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
if (i_expected_counter == ((p_decoder->i_continuity_counter + 1) & 0xf) if (i_expected_counter == ((p_decoder->i_continuity_counter + 1) & 0xf)
&& !p_decoder->b_discontinuity) && !p_decoder->b_discontinuity)
{ {
dvbpsi_error(handle, "PSI decoder", dvbpsi_error(p_dvbpsi, "PSI decoder",
"TS duplicate (received %d, expected %d) for PID %d", "TS duplicate (received %d, expected %d) for PID %d",
p_decoder->i_continuity_counter, i_expected_counter, p_decoder->i_continuity_counter, i_expected_counter,
((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]); ((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
...@@ -352,7 +352,7 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data) ...@@ -352,7 +352,7 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
if (i_expected_counter != p_decoder->i_continuity_counter) if (i_expected_counter != p_decoder->i_continuity_counter)
{ {
dvbpsi_error(handle, "PSI decoder", dvbpsi_error(p_dvbpsi, "PSI decoder",
"TS discontinuity (received %d, expected %d) for PID %d", "TS discontinuity (received %d, expected %d) for PID %d",
p_decoder->i_continuity_counter, i_expected_counter, p_decoder->i_continuity_counter, i_expected_counter,
((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]); ((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
...@@ -436,7 +436,7 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data) ...@@ -436,7 +436,7 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
/* Check that the section isn't too long */ /* Check that the section isn't too long */
if (p_decoder->i_need > p_decoder->i_section_max_size - 3) if (p_decoder->i_need > p_decoder->i_section_max_size - 3)
{ {
dvbpsi_error(handle, "PSI decoder", "PSI section too long"); dvbpsi_error(p_dvbpsi, "PSI decoder", "PSI section too long");
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
p_decoder->p_current_section = NULL; p_decoder->p_current_section = NULL;
/* If there is a new section not being handled then go forward /* If there is a new section not being handled then go forward
...@@ -494,16 +494,16 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data) ...@@ -494,16 +494,16 @@ bool dvbpsi_PushPacket(dvbpsi_t *handle, uint8_t* p_data)
p_section->p_payload_start = p_section->p_data + 3; p_section->p_payload_start = p_section->p_data + 3;
} }
if (p_decoder->pf_gather) if (p_decoder->pf_gather)
p_decoder->pf_gather(handle, p_section); p_decoder->pf_gather(p_dvbpsi, p_section);
p_decoder->p_current_section = NULL; p_decoder->p_current_section = NULL;
} }
else else
{ {
if (!dvbpsi_ValidPSISection(p_section)) if (!dvbpsi_ValidPSISection(p_section))
dvbpsi_error(handle, "misc PSI", "Bad CRC_32 table 0x%x !!!", dvbpsi_error(p_dvbpsi, "misc PSI", "Bad CRC_32 table 0x%x !!!",
p_section->p_data[0]); p_section->p_data[0]);
else else
dvbpsi_error(handle, "misc PSI", "table 0x%x", p_section->p_data[0]); dvbpsi_error(p_dvbpsi, "misc PSI", "table 0x%x", p_section->p_data[0]);
/* PSI section isn't valid => trash it */ /* PSI section isn't valid => trash it */
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
......
...@@ -76,6 +76,12 @@ typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle, ...@@ -76,6 +76,12 @@ typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle,
const dvbpsi_msg_level_t level, const dvbpsi_msg_level_t level,
const char* msg); const char* msg);
/*!
* \typedef struct dvbpsi_decoder_s dvbpsi_decoder_t
* \brief dvbpsi_decoder_t type definition.
*/
typedef struct dvbpsi_decoder_s dvbpsi_decoder_t;
/***************************************************************************** /*****************************************************************************
* dvbpsi_t * dvbpsi_t
*****************************************************************************/ *****************************************************************************/
...@@ -92,9 +98,8 @@ typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle, ...@@ -92,9 +98,8 @@ typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle,
*/ */
struct dvbpsi_s struct dvbpsi_s
{ {
void *p_private; /*!< private pointer to dvbpsi_decoder_t *p_decoder; /*!< private pointer to
specific decoder or specific decoder */
encoder */
/* Messages callback */ /* Messages callback */
dvbpsi_message_cb pf_message; /*!< Log message callback */ dvbpsi_message_cb pf_message; /*!< Log message callback */
enum dvbpsi_msg_level i_msg_level; /*!< Log level */ enum dvbpsi_msg_level i_msg_level; /*!< Log level */
...@@ -161,12 +166,6 @@ bool dvbpsi_PushPacket(dvbpsi_t *p_dvbpsi, uint8_t* p_data); ...@@ -161,12 +166,6 @@ bool dvbpsi_PushPacket(dvbpsi_t *p_dvbpsi, uint8_t* p_data);
*/ */
typedef struct dvbpsi_psi_section_s dvbpsi_psi_section_t; typedef struct dvbpsi_psi_section_s dvbpsi_psi_section_t;
/*!
* \typedef struct dvbpsi_decoder_s dvbpsi_decoder_t
* \brief dvbpsi_decoder_t type definition.
*/
typedef struct dvbpsi_decoder_s dvbpsi_decoder_t;
/*! /*!
* \def DVBPSI_DECODER(x) * \def DVBPSI_DECODER(x)
* \brief Helper macro for casting a private decoder into a dvbpsi_decoder_t * \brief Helper macro for casting a private decoder into a dvbpsi_decoder_t
......
...@@ -84,9 +84,9 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -84,9 +84,9 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_eit_callback pf_callback, void* p_cb_data) dvbpsi_atsc_eit_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -97,7 +97,8 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -97,7 +97,8 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
} }
dvbpsi_atsc_eit_decoder_t* p_eit_decoder; dvbpsi_atsc_eit_decoder_t* p_eit_decoder;
p_eit_decoder = (dvbpsi_atsc_eit_decoder_t*)malloc(sizeof(dvbpsi_atsc_eit_decoder_t)); p_eit_decoder = (dvbpsi_atsc_eit_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_atsc_eit_decoder_t));
if (p_eit_decoder == NULL) if (p_eit_decoder == NULL)
return false; return false;
...@@ -106,7 +107,7 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -106,7 +107,7 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_GatherEITSections, DVBPSI_DECODER(p_eit_decoder)); dvbpsi_atsc_GatherEITSections, DVBPSI_DECODER(p_eit_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_eit_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_eit_decoder));
return false; return false;
} }
...@@ -129,9 +130,9 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -129,9 +130,9 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
void dvbpsi_atsc_DetachEIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) void dvbpsi_atsc_DetachEIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
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)
...@@ -375,7 +376,7 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi, ...@@ -375,7 +376,7 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi,
dvbpsi_psi_section_t * p_section) dvbpsi_psi_section_t * p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCB, "ATSC EIT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCB, "ATSC EIT decoder"))
{ {
...@@ -384,7 +385,7 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi, ...@@ -384,7 +385,7 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi,
} }
/* 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_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_atsc_eit_decoder_t *p_eit_decoder = (dvbpsi_atsc_eit_decoder_t*)p_decoder; dvbpsi_atsc_eit_decoder_t *p_eit_decoder = (dvbpsi_atsc_eit_decoder_t*)p_decoder;
if (!p_eit_decoder) if (!p_eit_decoder)
{ {
......
...@@ -87,9 +87,9 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -87,9 +87,9 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
dvbpsi_atsc_ett_callback pf_callback, void* p_cb_data) dvbpsi_atsc_ett_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -100,7 +100,8 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -100,7 +100,8 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
} }
dvbpsi_atsc_ett_decoder_t* p_ett_decoder; dvbpsi_atsc_ett_decoder_t* p_ett_decoder;
p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)malloc(sizeof(dvbpsi_atsc_ett_decoder_t)); p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_atsc_ett_decoder_t));
if (p_ett_decoder == NULL) if (p_ett_decoder == NULL)
return false; return false;
...@@ -110,7 +111,7 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -110,7 +111,7 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
dvbpsi_atsc_GatherETTSections, DVBPSI_DECODER(p_ett_decoder)); dvbpsi_atsc_GatherETTSections, DVBPSI_DECODER(p_ett_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_ett_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_ett_decoder));
return false; return false;
} }
...@@ -133,9 +134,9 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -133,9 +134,9 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
...@@ -319,7 +320,7 @@ static void dvbpsi_atsc_GatherETTSections(dvbpsi_t* p_dvbpsi, ...@@ -319,7 +320,7 @@ static void dvbpsi_atsc_GatherETTSections(dvbpsi_t* p_dvbpsi,
dvbpsi_psi_section_t* p_section) dvbpsi_psi_section_t* p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCC, "ATSC ETT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCC, "ATSC ETT decoder"))
{ {
...@@ -328,7 +329,7 @@ static void dvbpsi_atsc_GatherETTSections(dvbpsi_t* p_dvbpsi, ...@@ -328,7 +329,7 @@ static void dvbpsi_atsc_GatherETTSections(dvbpsi_t* p_dvbpsi,
} }
/* We have a valid ETT section */ /* We have a valid ETT section */
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_atsc_ett_decoder_t* p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)p_decoder; dvbpsi_atsc_ett_decoder_t* p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)p_decoder;
if (!p_ett_decoder) if (!p_ett_decoder)
{ {
......
...@@ -88,9 +88,9 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -88,9 +88,9 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_mgt_callback pf_callback, void* p_cb_data) dvbpsi_atsc_mgt_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -101,7 +101,8 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -101,7 +101,8 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
} }
dvbpsi_atsc_mgt_decoder_t* p_mgt_decoder; dvbpsi_atsc_mgt_decoder_t* p_mgt_decoder;
p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)malloc(sizeof(dvbpsi_atsc_mgt_decoder_t)); p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_atsc_mgt_decoder_t));
if(p_mgt_decoder == NULL) if(p_mgt_decoder == NULL)
return false; return false;
...@@ -110,7 +111,7 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -110,7 +111,7 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_GatherMGTSections, DVBPSI_DECODER(p_mgt_decoder)); dvbpsi_atsc_GatherMGTSections, DVBPSI_DECODER(p_mgt_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_mgt_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_mgt_decoder));
return false; return false;
} }
...@@ -133,9 +134,9 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -133,9 +134,9 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
void dvbpsi_atsc_DetachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) void dvbpsi_atsc_DetachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
...@@ -404,7 +405,7 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi, ...@@ -404,7 +405,7 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi,
dvbpsi_psi_section_t * p_section) dvbpsi_psi_section_t * p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xC7, "ATSC MGT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xC7, "ATSC MGT decoder"))
{ {
...@@ -413,7 +414,7 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi, ...@@ -413,7 +414,7 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi,
} }
/* We have a valid MGT section */ /* We have a valid MGT section */
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_atsc_mgt_decoder_t * p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)p_decoder; dvbpsi_atsc_mgt_decoder_t * p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)p_decoder;
if (!p_mgt_decoder) if (!p_mgt_decoder)
{ {
......
...@@ -74,9 +74,9 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -74,9 +74,9 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_stt_callback pf_stt_callback, void* p_cb_data) dvbpsi_atsc_stt_callback pf_stt_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, 0)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, 0))
{ {
dvbpsi_error(p_dvbpsi, "ATSC STT decoder", dvbpsi_error(p_dvbpsi, "ATSC STT decoder",
...@@ -86,7 +86,8 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -86,7 +86,8 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
} }
dvbpsi_atsc_stt_decoder_t* p_stt_decoder; dvbpsi_atsc_stt_decoder_t* p_stt_decoder;
p_stt_decoder = (dvbpsi_atsc_stt_decoder_t*)malloc(sizeof(dvbpsi_atsc_stt_decoder_t)); p_stt_decoder = (dvbpsi_atsc_stt_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_atsc_stt_decoder_t));
if (p_stt_decoder == NULL) if (p_stt_decoder == NULL)
return false; return false;
...@@ -96,7 +97,7 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -96,7 +97,7 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_GatherSTTSections, DVBPSI_DECODER(p_stt_decoder)); dvbpsi_atsc_GatherSTTSections, DVBPSI_DECODER(p_stt_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_stt_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_stt_decoder));
return false; return false;
} }
...@@ -119,9 +120,9 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -119,9 +120,9 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
i_extension = 0; i_extension = 0;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
...@@ -304,7 +305,7 @@ static void dvbpsi_atsc_GatherSTTSections(dvbpsi_t *p_dvbpsi, ...@@ -304,7 +305,7 @@ static void dvbpsi_atsc_GatherSTTSections(dvbpsi_t *p_dvbpsi,
dvbpsi_psi_section_t * p_section) dvbpsi_psi_section_t * p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCD, "ATSC STT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xCD, "ATSC STT decoder"))
{ {
...@@ -313,7 +314,7 @@ static void dvbpsi_atsc_GatherSTTSections(dvbpsi_t *p_dvbpsi, ...@@ -313,7 +314,7 @@ static void dvbpsi_atsc_GatherSTTSections(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_decoder;
dvbpsi_atsc_stt_decoder_t *p_stt_decoder = (dvbpsi_atsc_stt_decoder_t*)p_decoder; dvbpsi_atsc_stt_decoder_t *p_stt_decoder = (dvbpsi_atsc_stt_decoder_t*)p_decoder;
if (!p_stt_decoder) if (!p_stt_decoder)
{ {
......
...@@ -96,9 +96,9 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -96,9 +96,9 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_vct_callback pf_vct_callback, void* p_cb_data) dvbpsi_atsc_vct_callback pf_vct_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -110,7 +110,8 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -110,7 +110,8 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
} }
dvbpsi_atsc_vct_decoder_t* p_vct_decoder; dvbpsi_atsc_vct_decoder_t* p_vct_decoder;
p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)calloc(1, sizeof(dvbpsi_atsc_vct_decoder_t)); p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_atsc_vct_decoder_t));
if (p_vct_decoder == NULL) if (p_vct_decoder == NULL)
return false; return false;
...@@ -120,7 +121,7 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -120,7 +121,7 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_GatherVCTSections, DVBPSI_DECODER(p_vct_decoder)); dvbpsi_atsc_GatherVCTSections, DVBPSI_DECODER(p_vct_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_vct_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_vct_decoder));
return false; return false;
} }
...@@ -143,9 +144,9 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -143,9 +144,9 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
...@@ -443,7 +444,7 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi, ...@@ -443,7 +444,7 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi,
dvbpsi_psi_section_t *p_section) dvbpsi_psi_section_t *p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
const uint8_t i_table_id = (p_section->i_table_id == 0x8C || const uint8_t i_table_id = (p_section->i_table_id == 0x8C ||
p_section->i_table_id == 0x9C) ? p_section->i_table_id == 0x9C) ?
...@@ -456,7 +457,7 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi, ...@@ -456,7 +457,7 @@ static void dvbpsi_atsc_GatherVCTSections(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_decoder;
dvbpsi_atsc_vct_decoder_t *p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_decoder; dvbpsi_atsc_vct_decoder_t *p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_decoder;
/* TS discontinuity check */ /* TS discontinuity check */
......
...@@ -59,9 +59,9 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -59,9 +59,9 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_bat_callback pf_callback, void* p_cb_data) uint16_t i_extension, dvbpsi_bat_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
dvbpsi_error(p_dvbpsi, "BAT decoder", dvbpsi_error(p_dvbpsi, "BAT decoder",
...@@ -72,7 +72,8 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -72,7 +72,8 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
} }
dvbpsi_bat_decoder_t* p_bat_decoder; dvbpsi_bat_decoder_t* p_bat_decoder;
p_bat_decoder = (dvbpsi_bat_decoder_t*)calloc(1, sizeof(dvbpsi_bat_decoder_t)); p_bat_decoder = (dvbpsi_bat_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_bat_decoder_t));
if (p_bat_decoder == NULL) if (p_bat_decoder == NULL)
return false; return false;
...@@ -82,7 +83,7 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -82,7 +83,7 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
dvbpsi_GatherBATSections, DVBPSI_DECODER(p_bat_decoder)); dvbpsi_GatherBATSections, DVBPSI_DECODER(p_bat_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_bat_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_bat_decoder));
return false; return false;
} }
...@@ -105,9 +106,9 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -105,9 +106,9 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
...@@ -363,11 +364,11 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi, ...@@ -363,11 +364,11 @@ void dvbpsi_GatherBATSections(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; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
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;
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x4a, "BAT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x4a, "BAT decoder"))
{ {
......
...@@ -58,7 +58,7 @@ bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback, ...@@ -58,7 +58,7 @@ bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
void* p_cb_data) void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private == NULL); assert(p_dvbpsi->p_decoder == NULL);
dvbpsi_cat_decoder_t* p_cat_decoder; dvbpsi_cat_decoder_t* p_cat_decoder;
p_cat_decoder = (dvbpsi_cat_decoder_t*) dvbpsi_NewDecoder(&dvbpsi_GatherCATSections, p_cat_decoder = (dvbpsi_cat_decoder_t*) dvbpsi_NewDecoder(&dvbpsi_GatherCATSections,
...@@ -71,7 +71,7 @@ bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback, ...@@ -71,7 +71,7 @@ bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
p_cat_decoder->p_cb_data = p_cb_data; p_cat_decoder->p_cb_data = p_cb_data;
p_cat_decoder->p_building_cat = NULL; p_cat_decoder->p_building_cat = NULL;
p_dvbpsi->p_private = p_cat_decoder; p_dvbpsi->p_decoder = DVBPSI_DECODER(p_cat_decoder);
return true; return true;
} }
...@@ -83,16 +83,16 @@ bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback, ...@@ -83,16 +83,16 @@ bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi) void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_cat_decoder_t* p_cat_decoder dvbpsi_cat_decoder_t* p_cat_decoder
= (dvbpsi_cat_decoder_t*)p_dvbpsi->p_private; = (dvbpsi_cat_decoder_t*)p_dvbpsi->p_decoder;
if (p_cat_decoder->p_building_cat) if (p_cat_decoder->p_building_cat)
dvbpsi_DeleteCAT(p_cat_decoder->p_building_cat); dvbpsi_DeleteCAT(p_cat_decoder->p_building_cat);
p_cat_decoder->p_building_cat = NULL; p_cat_decoder->p_building_cat = NULL;
dvbpsi_DeleteDecoder(p_dvbpsi->p_private); dvbpsi_DeleteDecoder(p_dvbpsi->p_decoder);
p_dvbpsi->p_private = NULL; p_dvbpsi->p_decoder = NULL;
} }
/***************************************************************************** /*****************************************************************************
...@@ -188,10 +188,10 @@ static void dvbpsi_ReInitCAT(dvbpsi_cat_decoder_t* p_decoder, const bool b_force ...@@ -188,10 +188,10 @@ static void dvbpsi_ReInitCAT(dvbpsi_cat_decoder_t* p_decoder, const bool b_force
static bool dvbpsi_CheckCAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section) static bool dvbpsi_CheckCAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
{ {
bool b_reinit = false; bool b_reinit = false;
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_cat_decoder_t* p_cat_decoder; dvbpsi_cat_decoder_t* p_cat_decoder;
p_cat_decoder = (dvbpsi_cat_decoder_t *)p_dvbpsi->p_private; p_cat_decoder = (dvbpsi_cat_decoder_t *)p_dvbpsi->p_decoder;
/* Perform a few sanity checks */ /* Perform a few sanity checks */
#if 0 #if 0
...@@ -260,7 +260,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -260,7 +260,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_psi_section_t* p_section) dvbpsi_psi_section_t* p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x01, "CAT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x01, "CAT decoder"))
{ {
...@@ -270,7 +270,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -270,7 +270,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
/* */ /* */
dvbpsi_cat_decoder_t* p_cat_decoder dvbpsi_cat_decoder_t* p_cat_decoder
= (dvbpsi_cat_decoder_t*)p_dvbpsi->p_private; = (dvbpsi_cat_decoder_t*)p_dvbpsi->p_decoder;
/* TS discontinuity check */ /* TS discontinuity check */
if (p_cat_decoder->b_discontinuity) if (p_cat_decoder->b_discontinuity)
......
...@@ -58,9 +58,9 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -58,9 +58,9 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_eit_callback pf_callback, void* p_cb_data) dvbpsi_eit_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension) != NULL) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension) != NULL)
{ {
...@@ -72,7 +72,8 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -72,7 +72,8 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
} }
dvbpsi_eit_decoder_t* p_eit_decoder; dvbpsi_eit_decoder_t* p_eit_decoder;
p_eit_decoder = (dvbpsi_eit_decoder_t*)calloc(1, sizeof(dvbpsi_eit_decoder_t)); p_eit_decoder = (dvbpsi_eit_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_eit_decoder_t));
if (p_eit_decoder == NULL) if (p_eit_decoder == NULL)
return false; return false;
...@@ -82,7 +83,7 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -82,7 +83,7 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_GatherEITSections, DVBPSI_DECODER(p_eit_decoder)); dvbpsi_GatherEITSections, DVBPSI_DECODER(p_eit_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_eit_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_eit_decoder));
return false; return false;
} }
...@@ -106,9 +107,9 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -106,9 +107,9 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension) uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
...@@ -403,7 +404,7 @@ void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_de ...@@ -403,7 +404,7 @@ void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_de
dvbpsi_psi_section_t *p_section) dvbpsi_psi_section_t *p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
const uint8_t i_table_id = (p_section->i_table_id >= 0x4e && const uint8_t i_table_id = (p_section->i_table_id >= 0x4e &&
p_section->i_table_id <= 0x6f) ? p_section->i_table_id <= 0x6f) ?
...@@ -416,7 +417,7 @@ void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_de ...@@ -416,7 +417,7 @@ void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_de
} }
/* 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_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_eit_decoder_t* p_eit_decoder dvbpsi_eit_decoder_t* p_eit_decoder
= (dvbpsi_eit_decoder_t*)p_private_decoder; = (dvbpsi_eit_decoder_t*)p_private_decoder;
......
...@@ -60,9 +60,9 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -60,9 +60,9 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
void* p_cb_data) void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -74,7 +74,8 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -74,7 +74,8 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
} }
dvbpsi_nit_decoder_t* p_nit_decoder; dvbpsi_nit_decoder_t* p_nit_decoder;
p_nit_decoder = (dvbpsi_nit_decoder_t*)calloc(1, sizeof(dvbpsi_nit_decoder_t)); p_nit_decoder = (dvbpsi_nit_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_nit_decoder_t));
if (p_nit_decoder == NULL) if (p_nit_decoder == NULL)
return false; return false;
...@@ -84,7 +85,7 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -84,7 +85,7 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
dvbpsi_GatherNITSections, DVBPSI_DECODER(p_nit_decoder)); dvbpsi_GatherNITSections, DVBPSI_DECODER(p_nit_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_nit_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_nit_decoder));
return false; return false;
} }
...@@ -108,7 +109,7 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -108,7 +109,7 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension) uint16_t i_extension)
{ {
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
......
...@@ -54,7 +54,7 @@ bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, ...@@ -54,7 +54,7 @@ bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback,
void* p_cb_data) void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private == NULL); assert(p_dvbpsi->p_decoder == NULL);
/* PSI decoder configuration and initial state */ /* PSI decoder configuration and initial state */
dvbpsi_pat_decoder_t *p_pat_decoder; dvbpsi_pat_decoder_t *p_pat_decoder;
...@@ -68,7 +68,7 @@ bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, ...@@ -68,7 +68,7 @@ bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback,
p_pat_decoder->p_cb_data = p_cb_data; p_pat_decoder->p_cb_data = p_cb_data;
p_pat_decoder->p_building_pat = NULL; p_pat_decoder->p_building_pat = NULL;
p_dvbpsi->p_private = (void *)p_pat_decoder; p_dvbpsi->p_decoder = DVBPSI_DECODER(p_pat_decoder);
return true; return true;
} }
...@@ -80,15 +80,15 @@ bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, ...@@ -80,15 +80,15 @@ bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback,
void dvbpsi_DetachPAT(dvbpsi_t *p_dvbpsi) void dvbpsi_DetachPAT(dvbpsi_t *p_dvbpsi)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_pat_decoder_t* p_pat_decoder = (dvbpsi_pat_decoder_t*)p_dvbpsi->p_private; dvbpsi_pat_decoder_t* p_pat_decoder = (dvbpsi_pat_decoder_t*)p_dvbpsi->p_decoder;
if (p_pat_decoder->p_building_pat) if (p_pat_decoder->p_building_pat)
dvbpsi_DeletePAT(p_pat_decoder->p_building_pat); dvbpsi_DeletePAT(p_pat_decoder->p_building_pat);
p_pat_decoder->p_building_pat = NULL; p_pat_decoder->p_building_pat = NULL;
dvbpsi_DeleteDecoder(p_dvbpsi->p_private); dvbpsi_DeleteDecoder(p_dvbpsi->p_decoder);
p_dvbpsi->p_private = NULL; p_dvbpsi->p_decoder = NULL;
} }
/***************************************************************************** /*****************************************************************************
...@@ -202,10 +202,10 @@ static void dvbpsi_ReInitPAT(dvbpsi_pat_decoder_t* p_decoder, const bool b_force ...@@ -202,10 +202,10 @@ static void dvbpsi_ReInitPAT(dvbpsi_pat_decoder_t* p_decoder, const bool b_force
static bool dvbpsi_CheckPAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section) static bool dvbpsi_CheckPAT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
{ {
bool b_reinit = false; bool b_reinit = false;
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_pat_decoder_t* p_pat_decoder; dvbpsi_pat_decoder_t* p_pat_decoder;
p_pat_decoder = (dvbpsi_pat_decoder_t *)p_dvbpsi->p_private; p_pat_decoder = (dvbpsi_pat_decoder_t *)p_dvbpsi->p_decoder;
/* Perform a few sanity checks */ /* Perform a few sanity checks */
if (p_pat_decoder->p_building_pat->i_ts_id != p_section->i_extension) if (p_pat_decoder->p_building_pat->i_ts_id != p_section->i_extension)
...@@ -271,7 +271,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio ...@@ -271,7 +271,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
dvbpsi_pat_decoder_t* p_pat_decoder; dvbpsi_pat_decoder_t* p_pat_decoder;
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x00, "PAT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x00, "PAT decoder"))
{ {
...@@ -280,7 +280,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio ...@@ -280,7 +280,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
} }
/* Now we have a valid PAT section */ /* Now we have a valid PAT section */
p_pat_decoder = (dvbpsi_pat_decoder_t *)p_dvbpsi->p_private; p_pat_decoder = (dvbpsi_pat_decoder_t *)p_dvbpsi->p_decoder;
/* TS discontinuity check */ /* TS discontinuity check */
if (p_pat_decoder->b_discontinuity) if (p_pat_decoder->b_discontinuity)
......
...@@ -56,7 +56,7 @@ bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number, ...@@ -56,7 +56,7 @@ bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number,
dvbpsi_pmt_callback pf_callback, void* p_cb_data) dvbpsi_pmt_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private == NULL); assert(p_dvbpsi->p_decoder == NULL);
dvbpsi_pmt_decoder_t* p_pmt_decoder; dvbpsi_pmt_decoder_t* p_pmt_decoder;
p_pmt_decoder = (dvbpsi_pmt_decoder_t*) dvbpsi_NewDecoder(&dvbpsi_GatherPMTSections, p_pmt_decoder = (dvbpsi_pmt_decoder_t*) dvbpsi_NewDecoder(&dvbpsi_GatherPMTSections,
...@@ -64,7 +64,7 @@ bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number, ...@@ -64,7 +64,7 @@ bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number,
if (p_pmt_decoder == NULL) if (p_pmt_decoder == NULL)
return false; return false;
p_dvbpsi->p_private = (void *)p_pmt_decoder; p_dvbpsi->p_decoder = DVBPSI_DECODER(p_pmt_decoder);
/* PMT decoder configuration */ /* PMT decoder configuration */
p_pmt_decoder->i_program_number = i_program_number; p_pmt_decoder->i_program_number = i_program_number;
...@@ -83,16 +83,16 @@ bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number, ...@@ -83,16 +83,16 @@ bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number,
void dvbpsi_DetachPMT(dvbpsi_t *p_dvbpsi) void dvbpsi_DetachPMT(dvbpsi_t *p_dvbpsi)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_pmt_decoder_t* p_pmt_decoder; dvbpsi_pmt_decoder_t* p_pmt_decoder;
p_pmt_decoder = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_private; p_pmt_decoder = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_decoder;
if (p_pmt_decoder->p_building_pmt) if (p_pmt_decoder->p_building_pmt)
dvbpsi_DeletePMT(p_pmt_decoder->p_building_pmt); dvbpsi_DeletePMT(p_pmt_decoder->p_building_pmt);
p_pmt_decoder->p_building_pmt = NULL; p_pmt_decoder->p_building_pmt = NULL;
dvbpsi_DeleteDecoder((dvbpsi_decoder_t *)p_dvbpsi->p_private); dvbpsi_DeleteDecoder(p_dvbpsi->p_decoder);
p_dvbpsi->p_private = NULL; p_dvbpsi->p_decoder = NULL;
} }
/***************************************************************************** /*****************************************************************************
...@@ -261,10 +261,10 @@ static void dvbpsi_ReInitPMT(dvbpsi_pmt_decoder_t* p_decoder, const bool b_force ...@@ -261,10 +261,10 @@ static void dvbpsi_ReInitPMT(dvbpsi_pmt_decoder_t* p_decoder, const bool b_force
static bool dvbpsi_CheckPMT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section) static bool dvbpsi_CheckPMT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
{ {
bool b_reinit = false; bool b_reinit = false;
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_pmt_decoder_t* p_pmt_decoder; dvbpsi_pmt_decoder_t* p_pmt_decoder;
p_pmt_decoder = (dvbpsi_pmt_decoder_t *)p_dvbpsi->p_private; p_pmt_decoder = (dvbpsi_pmt_decoder_t *)p_dvbpsi->p_decoder;
if (p_pmt_decoder->p_building_pmt->i_version != p_section->i_version) if (p_pmt_decoder->p_building_pmt->i_version != p_section->i_version)
{ {
...@@ -322,7 +322,7 @@ static bool dvbpsi_AddSectionPMT(dvbpsi_t *p_dvbpsi, dvbpsi_pmt_decoder_t *p_pmt ...@@ -322,7 +322,7 @@ static bool dvbpsi_AddSectionPMT(dvbpsi_t *p_dvbpsi, dvbpsi_pmt_decoder_t *p_pmt
void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section) void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x02, "PMT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x02, "PMT decoder"))
{ {
...@@ -331,7 +331,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio ...@@ -331,7 +331,7 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio
} }
/* */ /* */
dvbpsi_pmt_decoder_t* p_pmt_decoder = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_private; dvbpsi_pmt_decoder_t* p_pmt_decoder = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_decoder;
assert(p_pmt_decoder); assert(p_pmt_decoder);
/* We have a valid PMT section */ /* We have a valid PMT section */
......
...@@ -57,9 +57,9 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -57,9 +57,9 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_sdt_callback pf_callback, void* p_cb_data) dvbpsi_sdt_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -71,7 +71,8 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -71,7 +71,8 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
} }
dvbpsi_sdt_decoder_t* p_sdt_decoder; dvbpsi_sdt_decoder_t* p_sdt_decoder;
p_sdt_decoder = (dvbpsi_sdt_decoder_t*)calloc(1, sizeof(dvbpsi_sdt_decoder_t)); p_sdt_decoder = (dvbpsi_sdt_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_sdt_decoder_t));
if (p_sdt_decoder == NULL) if (p_sdt_decoder == NULL)
return false; return false;
...@@ -81,7 +82,7 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -81,7 +82,7 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_GatherSDTSections, DVBPSI_DECODER(p_sdt_decoder)); dvbpsi_GatherSDTSections, DVBPSI_DECODER(p_sdt_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_sdt_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_sdt_decoder));
return false; return false;
} }
...@@ -104,9 +105,9 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -104,9 +105,9 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension) void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
...@@ -345,7 +346,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi, ...@@ -345,7 +346,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
dvbpsi_psi_section_t * p_section) dvbpsi_psi_section_t * p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x42, "SDT decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0x42, "SDT decoder"))
{ {
...@@ -354,7 +355,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi, ...@@ -354,7 +355,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
} }
/* We have a valid SDT section */ /* We have a valid SDT section */
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_decoder;
dvbpsi_sdt_decoder_t *p_sdt_decoder dvbpsi_sdt_decoder_t *p_sdt_decoder
= (dvbpsi_sdt_decoder_t*)p_private_decoder; = (dvbpsi_sdt_decoder_t*)p_private_decoder;
......
...@@ -57,9 +57,9 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -57,9 +57,9 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_sis_callback pf_callback, void* p_cb_data) dvbpsi_sis_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
i_extension = 0; i_extension = 0;
...@@ -73,7 +73,8 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -73,7 +73,8 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
} }
dvbpsi_sis_decoder_t* p_sis_decoder; dvbpsi_sis_decoder_t* p_sis_decoder;
p_sis_decoder = (dvbpsi_sis_decoder_t*)malloc(sizeof(dvbpsi_sis_decoder_t)); p_sis_decoder = (dvbpsi_sis_decoder_t*) dvbpsi_NewDecoder(NULL,
0, true, sizeof(dvbpsi_sis_decoder_t));
if (p_sis_decoder == NULL) if (p_sis_decoder == NULL)
return false; return false;
...@@ -83,7 +84,7 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -83,7 +84,7 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_GatherSISSections, DVBPSI_DECODER(p_sis_decoder)); dvbpsi_GatherSISSections, DVBPSI_DECODER(p_sis_decoder));
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
free(p_sis_decoder); dvbpsi_DeleteDecoder(DVBPSI_DECODER(p_sis_decoder));
return false; return false;
} }
...@@ -107,9 +108,9 @@ void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -107,9 +108,9 @@ void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension) uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
i_extension = 0; i_extension = 0;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
...@@ -329,7 +330,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -329,7 +330,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
dvbpsi_psi_section_t * p_section) dvbpsi_psi_section_t * p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xFC, "SIS decoder")) if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, 0xFC, "SIS decoder"))
{ {
...@@ -338,7 +339,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -338,7 +339,7 @@ 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_decoder;
dvbpsi_sis_decoder_t * p_sis_decoder = (dvbpsi_sis_decoder_t*)p_decoder; 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)
......
...@@ -59,9 +59,9 @@ bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -59,9 +59,9 @@ bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_tot_callback pf_callback, void* p_cb_data) dvbpsi_tot_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder;
i_extension = 0; /* NOTE: force to 0 when handling TDT/TOT */ i_extension = 0; /* NOTE: force to 0 when handling TDT/TOT */
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
...@@ -109,9 +109,9 @@ void dvbpsi_DetachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -109,9 +109,9 @@ void dvbpsi_DetachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension) uint16_t i_extension)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
i_extension = 0; /* NOTE: force to 0 when handling TDT/TOT */ i_extension = 0; /* NOTE: force to 0 when handling TDT/TOT */
...@@ -308,7 +308,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi, ...@@ -308,7 +308,7 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
dvbpsi_psi_section_t* p_section) dvbpsi_psi_section_t* p_section)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_decoder);
const uint8_t i_table_id = ((p_section->i_table_id == 0x70 || /* TDT */ const uint8_t i_table_id = ((p_section->i_table_id == 0x70 || /* TDT */
p_section->i_table_id == 0x73)) ? /* TOT */ p_section->i_table_id == 0x73)) ? /* TOT */
......
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