Commit 7e1ae788 authored by Jean-Paul Saman's avatar Jean-Paul Saman

dvbpsi_AttachXXX() functions now return a boolean iso of pointer to dvbpsi_t *handle.

- dvbpsi_AttachDemux()
- dvbpsi_AttachPAT()
- dvbpsi_AttachPMT()
- dvbpsi_AttachSDT()
- dvbpsi-AttachCAT()
- dvbpsi-AttachBAT()
- dvbpsi-AttachEIT()
- dvbpsi-AttachNIT()
- dvbpsi-AttachTOT()
- dvbpsi-AttachSIS()
parent fc83f896
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -202,7 +203,8 @@ static void NewSubtableBAT(void * p_zero, dvbpsi_t *p_dvbpsi, ...@@ -202,7 +203,8 @@ static void NewSubtableBAT(void * p_zero, dvbpsi_t *p_dvbpsi,
{ {
if(i_table_id == 0x4a) if(i_table_id == 0x4a)
{ {
dvbpsi_AttachBAT(p_dvbpsi, i_table_id, i_extension, DumpBAT, NULL); if (!dvbpsi_AttachBAT(p_dvbpsi, i_table_id, i_extension, DumpBAT, NULL))
fprintf(stderr, "failed to attach BAT subdecoder\n");
} }
} }
...@@ -231,8 +233,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -231,8 +233,7 @@ int main(int i_argc, char* pa_argv[])
p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG); p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL) if (p_dvbpsi == NULL)
goto out; goto out;
dvbpsi_t *p_demux = dvbpsi_AttachDemux(p_dvbpsi, NewSubtableBAT, NULL); if (!dvbpsi_AttachDemux(p_dvbpsi, NewSubtableBAT, NULL))
if(p_demux == NULL)
goto out; goto out;
b_ok = ReadPacket(i_fd, data); b_ok = ReadPacket(i_fd, data);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -327,16 +328,15 @@ static void DumpPAT(void* p_data, dvbpsi_pat_t* p_pat) ...@@ -327,16 +328,15 @@ static void DumpPAT(void* p_data, dvbpsi_pat_t* p_pat)
p_stream->pmt.i_number = p_program->i_number; p_stream->pmt.i_number = p_program->i_number;
p_stream->pmt.pid_pmt = &p_stream->pid[p_program->i_pid]; p_stream->pmt.pid_pmt = &p_stream->pid[p_program->i_pid];
p_stream->pmt.pid_pmt->i_pid = p_program->i_pid; p_stream->pmt.pid_pmt->i_pid = p_program->i_pid;
dvbpsi_t *p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG); p_stream->pmt.handle = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL) if (p_stream->pmt.handle == NULL)
{ {
fprintf(stderr, "could not allocate new dvbpsi_t handle\n"); fprintf(stderr, "could not allocate new dvbpsi_t handle\n");
break; break;
} }
p_stream->pmt.handle = dvbpsi_AttachPMT(p_dvbpsi, p_program->i_number, DumpPMT, p_stream ); if (!dvbpsi_AttachPMT(p_stream->pmt.handle, p_program->i_number, DumpPMT, p_stream ))
if (p_stream->pmt.handle == NULL)
{ {
dvbpsi_DeleteHandle(p_dvbpsi); dvbpsi_DeleteHandle(p_stream->pmt.handle);
fprintf(stderr, "could not attach PMT\n"); fprintf(stderr, "could not attach PMT\n");
break; break;
} }
...@@ -667,14 +667,12 @@ int main(int i_argc, char* pa_argv[]) ...@@ -667,14 +667,12 @@ int main(int i_argc, char* pa_argv[])
report_Header( i_report ); report_Header( i_report );
#endif #endif
dvbpsi_t *p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG); p_stream->pat.handle = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL)
goto dvbpsi_out;
p_stream->pat.handle = dvbpsi_AttachPAT(p_dvbpsi, DumpPAT, p_stream);
if (p_stream->pat.handle == NULL) if (p_stream->pat.handle == NULL)
{
goto dvbpsi_out; goto dvbpsi_out;
} if (!dvbpsi_AttachPAT(p_stream->pat.handle, DumpPAT, p_stream))
goto dvbpsi_out;
/* Enter infinite loop */ /* Enter infinite loop */
while( i_len > 0 ) while( i_len > 0 )
{ {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -121,8 +122,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -121,8 +122,7 @@ int main(int i_argc, char* pa_argv[])
if (p_dvbpsi == NULL) if (p_dvbpsi == NULL)
goto out; goto out;
dvbpsi_t *p_tmp = dvbpsi_AttachPAT(p_dvbpsi, DumpPAT, NULL); if (!dvbpsi_AttachPAT(p_dvbpsi, DumpPAT, NULL))
if (p_tmp == NULL)
goto out; goto out;
b_ok = ReadPacket(i_fd, data); b_ok = ReadPacket(i_fd, data);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <math.h> #include <math.h>
...@@ -268,8 +269,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -268,8 +269,7 @@ int main(int i_argc, char* pa_argv[])
if (p_dvbpsi == NULL) if (p_dvbpsi == NULL)
goto out; goto out;
dvbpsi_t *p_tmp = dvbpsi_AttachPMT(p_dvbpsi, i_program_number, DumpPMT, NULL); if (!dvbpsi_AttachPMT(p_dvbpsi, i_program_number, DumpPMT, NULL))
if (p_tmp == NULL)
goto out; goto out;
b_ok = ReadPacket(i_fd, data); b_ok = ReadPacket(i_fd, data);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -137,7 +138,8 @@ static void NewSubtable(void * p_zero, dvbpsi_t *p_dvbpsi, ...@@ -137,7 +138,8 @@ static void NewSubtable(void * p_zero, dvbpsi_t *p_dvbpsi,
{ {
if(i_table_id == 0x42) if(i_table_id == 0x42)
{ {
dvbpsi_AttachSDT(p_dvbpsi, i_table_id, i_extension, DumpSDT, NULL); if (!dvbpsi_AttachSDT(p_dvbpsi, i_table_id, i_extension, DumpSDT, NULL))
fprintf(stderr, "Failed to attach SDT subdecoder\n");
} }
} }
...@@ -162,8 +164,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -162,8 +164,7 @@ int main(int i_argc, char* pa_argv[])
if (p_dvbpsi == NULL) if (p_dvbpsi == NULL)
goto out; goto out;
dvbpsi_t *p_demux= dvbpsi_AttachDemux(p_dvbpsi, NewSubtable, NULL); if (!dvbpsi_AttachDemux(p_dvbpsi, NewSubtable, NULL))
if (p_demux == NULL)
goto out; goto out;
b_ok = ReadPacket(i_fd, data); b_ok = ReadPacket(i_fd, data);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
...@@ -113,15 +114,13 @@ static void PATCallback( void *_unused, dvbpsi_pat_t *p_pat ) ...@@ -113,15 +114,13 @@ static void PATCallback( void *_unused, dvbpsi_pat_t *p_pat )
if( p_program->i_number != 0 if( p_program->i_number != 0
&& (!i_program || i_program == p_program->i_number) ) && (!i_program || i_program == p_program->i_number) )
{ {
dvbpsi_t *p_dvbpsi;
pi_pmt_pids[i_nb_programs] = p_program->i_pid; pi_pmt_pids[i_nb_programs] = p_program->i_pid;
p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG); p_pmt_dvbpsi_fds[i_nb_programs] = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi) if (p_pmt_dvbpsi_fds[i_nb_programs])
{ {
p_pmt_dvbpsi_fds[i_nb_programs] = if (dvbpsi_AttachPMT(p_pmt_dvbpsi_fds[i_nb_programs],
dvbpsi_AttachPMT(p_dvbpsi, p_program->i_number, PMTCallback, p_program->i_number, PMTCallback, NULL))
NULL ); i_nb_programs++;
i_nb_programs++;
} }
} }
} }
...@@ -171,7 +170,6 @@ static void TSHandle( uint8_t *p_ts ) ...@@ -171,7 +170,6 @@ static void TSHandle( uint8_t *p_ts )
*****************************************************************************/ *****************************************************************************/
int main( int i_argc, char **pp_argv ) int main( int i_argc, char **pp_argv )
{ {
dvbpsi_t *p_dvbpsi;
uint8_t *p_buffer; uint8_t *p_buffer;
int result = EXIT_FAILURE; int result = EXIT_FAILURE;
...@@ -191,12 +189,11 @@ int main( int i_argc, char **pp_argv ) ...@@ -191,12 +189,11 @@ int main( int i_argc, char **pp_argv )
if ( i_argc == 3 ) if ( i_argc == 3 )
i_program = strtol( pp_argv[2], NULL, 0 ); i_program = strtol( pp_argv[2], NULL, 0 );
p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG); p_pat_dvbpsi_fd = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL) if (p_pat_dvbpsi_fd == NULL)
goto out; goto out;
p_pat_dvbpsi_fd = dvbpsi_AttachPAT(p_dvbpsi, PATCallback, NULL ); if (!dvbpsi_AttachPAT(p_pat_dvbpsi_fd, PATCallback, NULL ))
if (p_pat_dvbpsi_fd == NULL)
goto out; goto out;
p_buffer = malloc( TS_SIZE * READ_ONCE ); p_buffer = malloc( TS_SIZE * READ_ONCE );
...@@ -238,10 +235,10 @@ int main( int i_argc, char **pp_argv ) ...@@ -238,10 +235,10 @@ int main( int i_argc, char **pp_argv )
result = EXIT_SUCCESS; result = EXIT_SUCCESS;
out: out:
if (p_dvbpsi) if (p_pat_dvbpsi_fd)
{ {
dvbpsi_DetachPAT(p_dvbpsi); dvbpsi_DetachPAT(p_pat_dvbpsi_fd);
dvbpsi_DeleteHandle(p_dvbpsi); dvbpsi_DeleteHandle(p_pat_dvbpsi_fd);
} }
close( i_fd ); close( i_fd );
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
#include <inttypes.h> #include <inttypes.h>
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
#include <inttypes.h> #include <inttypes.h>
......
...@@ -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>
...@@ -48,16 +49,16 @@ ...@@ -48,16 +49,16 @@
***************************************************************************** *****************************************************************************
* Creation of the demux structure * Creation of the demux structure
*****************************************************************************/ *****************************************************************************/
dvbpsi_t *dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi, bool dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
dvbpsi_demux_new_cb_t pf_new_cb, dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data) void * p_new_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private == NULL);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t*)malloc(sizeof(dvbpsi_demux_t)); dvbpsi_demux_t *p_demux = (dvbpsi_demux_t*)malloc(sizeof(dvbpsi_demux_t));
if (p_demux == NULL) if (p_demux == NULL)
return NULL; return false;
/* PSI decoder configuration */ /* PSI decoder configuration */
p_demux->pf_callback = &dvbpsi_Demux; p_demux->pf_callback = &dvbpsi_Demux;
...@@ -74,7 +75,7 @@ dvbpsi_t *dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi, ...@@ -74,7 +75,7 @@ dvbpsi_t *dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
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_private = (void *)p_demux;
return p_dvbpsi; return true;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -126,14 +126,14 @@ struct dvbpsi_demux_s ...@@ -126,14 +126,14 @@ struct dvbpsi_demux_s
* dvbpsi_AttachDemux * dvbpsi_AttachDemux
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn dvbpsi_t *dvbpsi_AttachDemux(dvbpsi_t *p_dvbpsi, dvbpsi_demux_new_cb_t pf_new_cb, void * p_new_cb_data) * \fn bool dvbpsi_AttachDemux(dvbpsi_t *p_dvbpsi, dvbpsi_demux_new_cb_t pf_new_cb, void * p_new_cb_data)
* \brief Creates a new demux structure. * \brief Attaches a new demux structure on dvbpsi_t* handle.
* \param p_dvbpsi pointer to dvbpsi_t handle * \param p_dvbpsi pointer to dvbpsi_t handle
* \param pf_new_cb A callcack called when a new type of subtable is found. * \param pf_new_cb A callcack called when a new type of subtable is found.
* \param p_new_cb_data Data given to the previous callback. * \param p_new_cb_data Data given to the previous callback.
* \return a handle to the new attached demux structure. * \return true on success, false on failure
*/ */
dvbpsi_t *dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi, bool dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
dvbpsi_demux_new_cb_t pf_new_cb, dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data); void * p_new_cb_data);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
...@@ -39,6 +40,8 @@ ...@@ -39,6 +40,8 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <assert.h>
#include "../dvbpsi.h" #include "../dvbpsi.h"
#include "../dvbpsi_private.h" #include "../dvbpsi_private.h"
#include "../psi.h" #include "../psi.h"
...@@ -52,9 +55,12 @@ ...@@ -52,9 +55,12 @@
***************************************************************************** *****************************************************************************
* Initialize a BAT subtable decoder. * Initialize a BAT subtable decoder.
*****************************************************************************/ *****************************************************************************/
int dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, 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->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_bat_decoder_t* p_bat_decoder; dvbpsi_bat_decoder_t* p_bat_decoder;
...@@ -65,20 +71,18 @@ int dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -65,20 +71,18 @@ int dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
"Already a decoder for (table_id == 0x%02x," "Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)", "extension == 0x%02x)",
i_table_id, i_extension); i_table_id, i_extension);
return 1; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t)); p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t));
if (p_subdec == NULL) if (p_subdec == NULL)
{ return false;
return 1;
}
p_bat_decoder = (dvbpsi_bat_decoder_t*)malloc(sizeof(dvbpsi_bat_decoder_t)); p_bat_decoder = (dvbpsi_bat_decoder_t*)malloc(sizeof(dvbpsi_bat_decoder_t));
if (p_bat_decoder == NULL) if (p_bat_decoder == NULL)
{ {
free(p_subdec); free(p_subdec);
return 1; return false;
} }
/* subtable decoder configuration */ /* subtable decoder configuration */
...@@ -101,7 +105,7 @@ int dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -101,7 +105,7 @@ int dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
for (unsigned int i = 0; i < 256; i++) for (unsigned int i = 0; i < 256; i++)
p_bat_decoder->ap_sections[i] = NULL; p_bat_decoder->ap_sections[i] = NULL;
return 0; return true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -111,6 +115,9 @@ int dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -111,6 +115,9 @@ int 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->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec; dvbpsi_demux_subdec_t** pp_prev_subdec;
......
...@@ -115,18 +115,18 @@ typedef void (* dvbpsi_bat_callback)(void* p_cb_data, dvbpsi_bat_t* p_new_bat); ...@@ -115,18 +115,18 @@ typedef void (* dvbpsi_bat_callback)(void* p_cb_data, dvbpsi_bat_t* p_new_bat);
* dvbpsi_AttachBAT * dvbpsi_AttachBAT
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn void dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, * \fn bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_bat_callback pf_callback, uint16_t i_extension, dvbpsi_bat_callback pf_callback,
void* p_cb_data) void* p_cb_data)
* \brief Creation and initialization of a BAT decoder. * \brief Creation and initialization of a BAT decoder. It will be attached to p_dvbpsi.
* \param p_dvbpsi dvbpsi handle to Subtable demultiplexor to which the decoder is attached. * \param p_dvbpsi dvbpsi handle to Subtable demultiplexor to which the decoder is attached.
* \param i_table_id Table ID, 0x4a. * \param i_table_id Table ID, 0x4a.
* \param i_extension Table ID extension, here bouquet ID. * \param i_extension Table ID extension, here bouquet ID.
* \param pf_callback function to call back on new BAT. * \param pf_callback function to call back on new BAT.
* \param p_cb_data private data given in argument to the callback. * \param p_cb_data private data given in argument to the callback.
* \return 0 if everything went ok. * \return true on success, false on failure
*/ */
int dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_bat_callback pf_callback, uint16_t i_extension, dvbpsi_bat_callback pf_callback,
void* p_cb_data); void* p_cb_data);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
...@@ -53,15 +54,16 @@ ...@@ -53,15 +54,16 @@
***************************************************************************** *****************************************************************************
* Initialize a CAT decoder and return a handle on it. * Initialize a CAT decoder and return a handle on it.
*****************************************************************************/ *****************************************************************************/
dvbpsi_t *dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback, 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);
dvbpsi_cat_decoder_t* p_cat_decoder; dvbpsi_cat_decoder_t* p_cat_decoder;
p_cat_decoder = (dvbpsi_cat_decoder_t*)calloc(1, sizeof(dvbpsi_cat_decoder_t)); p_cat_decoder = (dvbpsi_cat_decoder_t*)calloc(1, sizeof(dvbpsi_cat_decoder_t));
if (p_cat_decoder == NULL) if (p_cat_decoder == NULL)
return NULL; return false;
/* PSI decoder configuration */ /* PSI decoder configuration */
p_cat_decoder->pf_callback = &dvbpsi_GatherCATSections; p_cat_decoder->pf_callback = &dvbpsi_GatherCATSections;
...@@ -81,7 +83,7 @@ dvbpsi_t *dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback, ...@@ -81,7 +83,7 @@ dvbpsi_t *dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
p_cat_decoder->ap_sections[i] = NULL; p_cat_decoder->ap_sections[i] = NULL;
return p_dvbpsi; return true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -91,6 +93,9 @@ dvbpsi_t *dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback, ...@@ -91,6 +93,9 @@ dvbpsi_t *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->p_private);
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_private;
free(p_cat_decoder->p_building_cat); free(p_cat_decoder->p_building_cat);
...@@ -165,6 +170,9 @@ dvbpsi_descriptor_t* dvbpsi_CATAddDescriptor(dvbpsi_cat_t* p_cat, ...@@ -165,6 +170,9 @@ dvbpsi_descriptor_t* dvbpsi_CATAddDescriptor(dvbpsi_cat_t* p_cat,
void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, 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->p_private);
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_private;
......
...@@ -77,16 +77,16 @@ typedef void (* dvbpsi_cat_callback)(void* p_cb_data, dvbpsi_cat_t* p_new_cat); ...@@ -77,16 +77,16 @@ typedef void (* dvbpsi_cat_callback)(void* p_cb_data, dvbpsi_cat_t* p_new_cat);
* dvbpsi_AttachCAT * dvbpsi_AttachCAT
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn dvbpsi_t *dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, * \fn bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi,
dvbpsi_cat_callback pf_callback, void* p_cb_data) dvbpsi_cat_callback pf_callback, void* p_cb_data)
* \brief Creation and initialization of a CAT decoder. * \brief Creation and initialization of a CAT decoder. It will be attached to p_dvbpsi
* \param p_dvbpsi is a pointer to dvbpsi_t which holds a pointer to the decoder * \param p_dvbpsi is a pointer to dvbpsi_t which holds a pointer to the decoder
* \param pf_callback function to call back on new CAT * \param pf_callback function to call back on new CAT
* \param p_cb_data private data given in argument to the callback * \param p_cb_data private data given in argument to the callback
* \return a pointer to dvbpsi_t holding the decoder for future calls. * \return true on success, false on failure
*/ */
dvbpsi_t *dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback, bool dvbpsi_AttachCAT(dvbpsi_t *p_dvbpsi, dvbpsi_cat_callback pf_callback,
void* p_cb_data); void* p_cb_data);
/***************************************************************************** /*****************************************************************************
* dvbpsi_DetachCAT * dvbpsi_DetachCAT
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
...@@ -38,6 +39,8 @@ ...@@ -38,6 +39,8 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <assert.h>
#include "../dvbpsi.h" #include "../dvbpsi.h"
#include "../dvbpsi_private.h" #include "../dvbpsi_private.h"
#include "../psi.h" #include "../psi.h"
...@@ -51,9 +54,12 @@ ...@@ -51,9 +54,12 @@
***************************************************************************** *****************************************************************************
* Initialize a EIT subtable decoder. * Initialize a EIT subtable decoder.
*****************************************************************************/ *****************************************************************************/
dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension, bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
dvbpsi_eit_callback pf_callback, void* p_cb_data) dvbpsi_eit_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_eit_decoder_t* p_eit_decoder; dvbpsi_eit_decoder_t* p_eit_decoder;
...@@ -64,18 +70,18 @@ dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -64,18 +70,18 @@ dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
"Already a decoder for (table_id == 0x%02x," "Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)", "extension == 0x%02x)",
i_table_id, i_extension); i_table_id, i_extension);
return NULL; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t));
if (p_subdec == NULL) if (p_subdec == NULL)
return NULL; return false;
p_eit_decoder = (dvbpsi_eit_decoder_t*)calloc(1, sizeof(dvbpsi_eit_decoder_t)); p_eit_decoder = (dvbpsi_eit_decoder_t*)calloc(1, sizeof(dvbpsi_eit_decoder_t));
if (p_eit_decoder == NULL) if (p_eit_decoder == NULL)
{ {
free(p_subdec); free(p_subdec);
return NULL; return false;
} }
/* subtable decoder configuration */ /* subtable decoder configuration */
...@@ -97,7 +103,7 @@ dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -97,7 +103,7 @@ dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
p_eit_decoder->ap_sections[i] = NULL; p_eit_decoder->ap_sections[i] = NULL;
return p_dvbpsi; return true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -108,6 +114,9 @@ dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -108,6 +114,9 @@ dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, 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->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec; dvbpsi_demux_subdec_t** pp_prev_subdec;
......
...@@ -111,7 +111,7 @@ typedef void (* dvbpsi_eit_callback)(void* p_cb_data, dvbpsi_eit_t* p_new_eit); ...@@ -111,7 +111,7 @@ typedef void (* dvbpsi_eit_callback)(void* p_cb_data, dvbpsi_eit_t* p_new_eit);
* dvbpsi_AttachEIT * dvbpsi_AttachEIT
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, * \fn bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_eit_callback pf_callback, uint16_t i_extension, dvbpsi_eit_callback pf_callback,
void* p_cb_data) void* p_cb_data)
* \brief Creation and initialization of a EIT decoder. * \brief Creation and initialization of a EIT decoder.
...@@ -120,11 +120,10 @@ typedef void (* dvbpsi_eit_callback)(void* p_cb_data, dvbpsi_eit_t* p_new_eit); ...@@ -120,11 +120,10 @@ typedef void (* dvbpsi_eit_callback)(void* p_cb_data, dvbpsi_eit_t* p_new_eit);
* \param i_extension Table ID extension, here service ID. * \param i_extension Table ID extension, here service ID.
* \param pf_callback function to call back on new EIT. * \param pf_callback function to call back on new EIT.
* \param p_cb_data private data given in argument to the callback. * \param p_cb_data private data given in argument to the callback.
* \return p_dvbpsi or NULL on error * \return true on success, false on failure
*/ */
dvbpsi_t *dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_eit_callback pf_callback, uint16_t i_extension, dvbpsi_eit_callback pf_callback, void* p_cb_data);
void* p_cb_data);
/***************************************************************************** /*****************************************************************************
* dvbpsi_DetachEIT * dvbpsi_DetachEIT
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
...@@ -39,6 +40,8 @@ ...@@ -39,6 +40,8 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <assert.h>
#include "../dvbpsi.h" #include "../dvbpsi.h"
#include "../dvbpsi_private.h" #include "../dvbpsi_private.h"
#include "../psi.h" #include "../psi.h"
...@@ -52,10 +55,13 @@ ...@@ -52,10 +55,13 @@
***************************************************************************** *****************************************************************************
* Initialize a NIT subtable decoder. * Initialize a NIT subtable decoder.
*****************************************************************************/ *****************************************************************************/
int dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_nit_callback pf_callback, uint16_t i_extension, dvbpsi_nit_callback pf_callback,
void* p_cb_data) void* p_cb_data)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_nit_decoder_t* p_nit_decoder; dvbpsi_nit_decoder_t* p_nit_decoder;
...@@ -66,18 +72,18 @@ int dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -66,18 +72,18 @@ int dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
"Already a decoder for (table_id == 0x%02x," "Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)", "extension == 0x%02x)",
i_table_id, i_extension); i_table_id, i_extension);
return 1; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t));
if (p_subdec == NULL) if (p_subdec == NULL)
return 1; return false;
p_nit_decoder = (dvbpsi_nit_decoder_t*)calloc(1, sizeof(dvbpsi_nit_decoder_t)); p_nit_decoder = (dvbpsi_nit_decoder_t*)calloc(1, sizeof(dvbpsi_nit_decoder_t));
if (p_nit_decoder == NULL) if (p_nit_decoder == NULL)
{ {
free(p_subdec); free(p_subdec);
return 1; return false;
} }
/* subtable decoder configuration */ /* subtable decoder configuration */
...@@ -100,7 +106,7 @@ int dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -100,7 +106,7 @@ int dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
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;
return 0; return true;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -106,18 +106,18 @@ typedef void (* dvbpsi_nit_callback)(void* p_cb_data, dvbpsi_nit_t* p_new_nit); ...@@ -106,18 +106,18 @@ typedef void (* dvbpsi_nit_callback)(void* p_cb_data, dvbpsi_nit_t* p_new_nit);
* dvbpsi_AttachNIT * dvbpsi_AttachNIT
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn int dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, * \fn bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_nit_callback pf_callback, uint16_t i_extension, dvbpsi_nit_callback pf_callback,
void* p_cb_data) void* p_cb_data)
* \brief Creation and initialization of a NIT decoder. * \brief Creation and initialization of a NIT decoder. It is attached to p_dvbpsi.
* \param p_dvbpsi dvbpsi handle to Subtable demultiplexor to which the decoder is attached. * \param p_dvbpsi dvbpsi handle to Subtable demultiplexor to which the decoder is attached.
* \param i_table_id Table ID, 0x4E, 0x4F, or 0x50-0x6F. * \param i_table_id Table ID, 0x4E, 0x4F, or 0x50-0x6F.
* \param i_extension Table ID extension, here service ID. * \param i_extension Table ID extension, here service ID.
* \param pf_callback function to call back on new NIT. * \param pf_callback function to call back on new NIT.
* \param p_cb_data private data given in argument to the callback. * \param p_cb_data private data given in argument to the callback.
* \return 0 if everything went ok. * \return true on success, false on failure
*/ */
int dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_nit_callback pf_callback, uint16_t i_extension, dvbpsi_nit_callback pf_callback,
void* p_cb_data); void* p_cb_data);
......
...@@ -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>
...@@ -49,14 +50,15 @@ ...@@ -49,14 +50,15 @@
***************************************************************************** *****************************************************************************
* Initialize a PAT decoder and return a handle on it. * Initialize a PAT decoder and return a handle on it.
*****************************************************************************/ *****************************************************************************/
dvbpsi_t *dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, 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);
dvbpsi_pat_decoder_t* p_pat_decoder = (dvbpsi_pat_decoder_t*) calloc(1, sizeof(dvbpsi_pat_decoder_t)); dvbpsi_pat_decoder_t* p_pat_decoder = (dvbpsi_pat_decoder_t*) calloc(1, sizeof(dvbpsi_pat_decoder_t));
if (p_pat_decoder == NULL) if (p_pat_decoder == NULL)
return NULL; return false;
/* PSI decoder configuration */ /* PSI decoder configuration */
p_pat_decoder->pf_callback = &dvbpsi_GatherPATSections; p_pat_decoder->pf_callback = &dvbpsi_GatherPATSections;
...@@ -79,7 +81,7 @@ dvbpsi_t *dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, ...@@ -79,7 +81,7 @@ dvbpsi_t *dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback,
p_pat_decoder->ap_sections[i] = NULL; p_pat_decoder->ap_sections[i] = NULL;
p_dvbpsi->p_private = (void *)p_pat_decoder; p_dvbpsi->p_private = (void *)p_pat_decoder;
return p_dvbpsi; return true;
} }
...@@ -90,6 +92,9 @@ dvbpsi_t *dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, ...@@ -90,6 +92,9 @@ dvbpsi_t *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->p_private);
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_private;
free(p_pat_decoder->p_building_pat); free(p_pat_decoder->p_building_pat);
...@@ -183,6 +188,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio ...@@ -183,6 +188,7 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
int b_append = 1; int b_append = 1;
int b_reinit = 0; int b_reinit = 0;
assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_debug(p_dvbpsi, "PAT decoder", dvbpsi_debug(p_dvbpsi, "PAT decoder",
......
...@@ -102,15 +102,15 @@ typedef void (* dvbpsi_pat_callback)(void* p_cb_data, dvbpsi_pat_t* p_new_pat); ...@@ -102,15 +102,15 @@ typedef void (* dvbpsi_pat_callback)(void* p_cb_data, dvbpsi_pat_t* p_new_pat);
* dvbpsi_AttachPAT * dvbpsi_AttachPAT
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn dvbpsi_t *dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, void* p_cb_data) * \fn bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, void* p_cb_data)
* \brief Creation and initialization of a PAT decoder. * \brief Creation and initialization of a PAT decoder. The decoder will be attached to 'p_dvbpsi' argument.
* \param p_dvbpsi handle to dvbpsi with attached decoder * \param p_dvbpsi handle to dvbpsi with attached decoder
* \param pf_callback function to call back on new PAT * \param pf_callback function to call back on new PAT
* \param p_cb_data private data given in argument to the callback * \param p_cb_data private data given in argument to the callback
* \return a pointer to the decoder for future calls. * \return true on success, false on failure
*/ */
dvbpsi_t *dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback, bool dvbpsi_AttachPAT(dvbpsi_t *p_dvbpsi, dvbpsi_pat_callback pf_callback,
void* p_cb_data); void* p_cb_data);
/***************************************************************************** /*****************************************************************************
* dvbpsi_DetachPAT * dvbpsi_DetachPAT
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
...@@ -51,15 +52,16 @@ ...@@ -51,15 +52,16 @@
***************************************************************************** *****************************************************************************
* Initialize a PMT decoder and return a handle on it. * Initialize a PMT decoder and return a handle on it.
*****************************************************************************/ *****************************************************************************/
dvbpsi_t *dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number, bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number,
dvbpsi_pmt_callback pf_callback, dvbpsi_pmt_callback pf_callback, void* p_cb_data)
void* p_cb_data)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private == NULL);
dvbpsi_pmt_decoder_t* p_pmt_decoder; dvbpsi_pmt_decoder_t* p_pmt_decoder;
p_pmt_decoder = (dvbpsi_pmt_decoder_t*)malloc(sizeof(dvbpsi_pmt_decoder_t)); p_pmt_decoder = (dvbpsi_pmt_decoder_t*)malloc(sizeof(dvbpsi_pmt_decoder_t));
if (p_pmt_decoder == NULL) if (p_pmt_decoder == NULL)
return NULL; return false;
p_dvbpsi->p_private = (void *)p_pmt_decoder; p_dvbpsi->p_private = (void *)p_pmt_decoder;
...@@ -83,7 +85,7 @@ dvbpsi_t *dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number, ...@@ -83,7 +85,7 @@ dvbpsi_t *dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number,
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
p_pmt_decoder->ap_sections[i] = NULL; p_pmt_decoder->ap_sections[i] = NULL;
return p_dvbpsi; return true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -93,6 +95,9 @@ dvbpsi_t *dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number, ...@@ -93,6 +95,9 @@ dvbpsi_t *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->p_private);
dvbpsi_pmt_decoder_t* p_pmt_decoder dvbpsi_pmt_decoder_t* p_pmt_decoder
= (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_private; = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_private;
free(p_pmt_decoder->p_building_pmt); free(p_pmt_decoder->p_building_pmt);
...@@ -236,6 +241,9 @@ dvbpsi_descriptor_t* dvbpsi_PMTESAddDescriptor(dvbpsi_pmt_es_t* p_es, ...@@ -236,6 +241,9 @@ dvbpsi_descriptor_t* dvbpsi_PMTESAddDescriptor(dvbpsi_pmt_es_t* p_es,
*****************************************************************************/ *****************************************************************************/
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->p_private);
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_private;
assert(p_pmt_decoder); assert(p_pmt_decoder);
......
...@@ -106,21 +106,20 @@ typedef void (* dvbpsi_pmt_callback)(void* p_cb_data, dvbpsi_pmt_t* p_new_pmt); ...@@ -106,21 +106,20 @@ typedef void (* dvbpsi_pmt_callback)(void* p_cb_data, dvbpsi_pmt_t* p_new_pmt);
* dvbpsi_AttachPMT * dvbpsi_AttachPMT
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn dvbpsi_t *dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, * \fn bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi,
uint16_t i_program_number, uint16_t i_program_number,
dvbpsi_pmt_callback pf_callback, dvbpsi_pmt_callback pf_callback,
void* p_cb_data) void* p_cb_data)
* \brief Creates and initialization of a PMT decoder and attaches it to dvbpsi_t * \brief Creates and initialization of a PMT decoder and attaches it to dvbpsi_t
* handle * handle
* \param p_dvbpsi handle * \param p_dvbpsi handle
* \param i_program_number program number * \param i_program_number program number
* \param pf_callback function to call back on new PMT * \param pf_callback function to call back on new PMT
* \param p_cb_data private data given in argument to the callback * \param p_cb_data private data given in argument to the callback
* \return a pointer to the decoder for future calls. * \return true on success, false on failure
*/ */
dvbpsi_t *dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number, bool dvbpsi_AttachPMT(dvbpsi_t *p_dvbpsi, uint16_t i_program_number,
dvbpsi_pmt_callback pf_callback, dvbpsi_pmt_callback pf_callback, void* p_cb_data);
void* p_cb_data);
/***************************************************************************** /*****************************************************************************
* dvbpsi_DetachPMT * dvbpsi_DetachPMT
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
...@@ -37,6 +38,8 @@ ...@@ -37,6 +38,8 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <assert.h>
#include "../dvbpsi.h" #include "../dvbpsi.h"
#include "../dvbpsi_private.h" #include "../dvbpsi_private.h"
#include "../psi.h" #include "../psi.h"
...@@ -50,10 +53,12 @@ ...@@ -50,10 +53,12 @@
***************************************************************************** *****************************************************************************
* Initialize a SDT subtable decoder. * Initialize a SDT subtable decoder.
*****************************************************************************/ *****************************************************************************/
dvbpsi_t *dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
uint16_t i_extension, dvbpsi_sdt_callback pf_callback, dvbpsi_sdt_callback pf_callback, void* p_cb_data)
void* p_cb_data)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_sdt_decoder_t* p_sdt_decoder; dvbpsi_sdt_decoder_t* p_sdt_decoder;
...@@ -64,18 +69,18 @@ dvbpsi_t *dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -64,18 +69,18 @@ dvbpsi_t *dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
"Already a decoder for (table_id == 0x%02x," "Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)", "extension == 0x%02x)",
i_table_id, i_extension); i_table_id, i_extension);
return NULL; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t));
if(p_subdec == NULL) if(p_subdec == NULL)
return NULL; return false;
p_sdt_decoder = (dvbpsi_sdt_decoder_t*)calloc(1, sizeof(dvbpsi_sdt_decoder_t)); p_sdt_decoder = (dvbpsi_sdt_decoder_t*)calloc(1, sizeof(dvbpsi_sdt_decoder_t));
if (p_sdt_decoder == NULL) if (p_sdt_decoder == NULL)
{ {
free(p_subdec); free(p_subdec);
return NULL; return false;
} }
/* subtable decoder configuration */ /* subtable decoder configuration */
...@@ -98,7 +103,7 @@ dvbpsi_t *dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -98,7 +103,7 @@ dvbpsi_t *dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
p_sdt_decoder->ap_sections[i] = NULL; p_sdt_decoder->ap_sections[i] = NULL;
return p_dvbpsi; return true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -108,6 +113,9 @@ dvbpsi_t *dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -108,6 +113,9 @@ dvbpsi_t *dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
*****************************************************************************/ *****************************************************************************/
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->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec; dvbpsi_demux_subdec_t** pp_prev_subdec;
......
...@@ -110,20 +110,19 @@ typedef void (* dvbpsi_sdt_callback)(void* p_cb_data, dvbpsi_sdt_t* p_new_sdt); ...@@ -110,20 +110,19 @@ typedef void (* dvbpsi_sdt_callback)(void* p_cb_data, dvbpsi_sdt_t* p_new_sdt);
* dvbpsi_AttachSDT * dvbpsi_AttachSDT
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn int dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, * \fn bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_sdt_callback pf_callback, uint16_t i_extension, dvbpsi_sdt_callback pf_callback,
void* p_cb_data) void* p_cb_data)
* \brief Creation and initialization of a SDT decoder. * \brief Creation and initialization of a SDT decoder. It is attached to p_dvbpsi.
* \param p_dvbpsi pointer to dvbpsi to hold decoder/demuxer structure * \param p_dvbpsi pointer to dvbpsi to hold decoder/demuxer structure
* \param i_table_id Table ID, 0x42 or 0x46. * \param i_table_id Table ID, 0x42 or 0x46.
* \param i_extension Table ID extension, here TS ID. * \param i_extension Table ID extension, here TS ID.
* \param pf_callback function to call back on new SDT. * \param pf_callback function to call back on new SDT.
* \param p_cb_data private data given in argument to the callback. * \param p_cb_data private data given in argument to the callback.
* \return pointer to dvbpsi handle or NULL on error * \return true on success, false on failure
*/ */
dvbpsi_t *dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
uint16_t i_extension, dvbpsi_sdt_callback pf_callback, dvbpsi_sdt_callback pf_callback, void* p_cb_data);
void* p_cb_data);
/***************************************************************************** /*****************************************************************************
* dvbpsi_DetachSDT * dvbpsi_DetachSDT
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
...@@ -52,10 +53,12 @@ ...@@ -52,10 +53,12 @@
***************************************************************************** *****************************************************************************
* Initialize a SIS subtable decoder. * Initialize a SIS subtable decoder.
*****************************************************************************/ *****************************************************************************/
int dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
uint16_t i_extension, dvbpsi_sis_callback pf_callback, dvbpsi_sis_callback pf_callback, void* p_cb_data)
void* p_cb_data)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_sis_decoder_t* p_sis_decoder; dvbpsi_sis_decoder_t* p_sis_decoder;
...@@ -68,20 +71,18 @@ int dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -68,20 +71,18 @@ int dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
"Already a decoder for (table_id == 0x%02x," "Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)", "extension == 0x%02x)",
i_table_id, i_extension); i_table_id, i_extension);
return 1; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t)); p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t));
if (p_subdec == NULL) if (p_subdec == NULL)
{ return false;
return 1;
}
p_sis_decoder = (dvbpsi_sis_decoder_t*)malloc(sizeof(dvbpsi_sis_decoder_t)); p_sis_decoder = (dvbpsi_sis_decoder_t*)malloc(sizeof(dvbpsi_sis_decoder_t));
if (p_sis_decoder == NULL) if (p_sis_decoder == NULL)
{ {
free(p_subdec); free(p_subdec);
return 1; return false;
} }
/* subtable decoder configuration */ /* subtable decoder configuration */
...@@ -98,7 +99,7 @@ int dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -98,7 +99,7 @@ int dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
p_sis_decoder->pf_sis_callback = pf_callback; p_sis_decoder->pf_sis_callback = pf_callback;
p_sis_decoder->p_cb_data = p_cb_data; p_sis_decoder->p_cb_data = p_cb_data;
return 0; return true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -109,6 +110,9 @@ int dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -109,6 +110,9 @@ int dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
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)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec; dvbpsi_demux_subdec_t** pp_prev_subdec;
...@@ -220,6 +224,9 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi, ...@@ -220,6 +224,9 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
void * p_private_decoder, void * p_private_decoder,
dvbpsi_psi_section_t * p_section) dvbpsi_psi_section_t * p_section)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
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;
......
...@@ -108,20 +108,19 @@ typedef void (* dvbpsi_sis_callback)(void* p_cb_data, dvbpsi_sis_t* p_new_sis); ...@@ -108,20 +108,19 @@ typedef void (* dvbpsi_sis_callback)(void* p_cb_data, dvbpsi_sis_t* p_new_sis);
* dvbpsi_AttachSIS * dvbpsi_AttachSIS
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn void dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, * \fn bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_sis_callback pf_callback, uint16_t i_extension, dvbpsi_sis_callback pf_callback,
void* p_cb_data) void* p_cb_data)
* \brief Creation and initialization of a SIS decoder. * \brief Creation and initialization of a SIS decoder. It is attached to p_dvbpsi.
* \param p_dvbpsi pointer to dvbpsi to hold decoder/demuxer structure * \param p_dvbpsi pointer to dvbpsi to hold decoder/demuxer structure
* \param i_table_id Table ID, 0xFC. * \param i_table_id Table ID, 0xFC.
* \param i_extension Table ID extension, here TS ID. * \param i_extension Table ID extension, here TS ID.
* \param pf_callback function to call back on new SIS. * \param pf_callback function to call back on new SIS.
* \param p_cb_data private data given in argument to the callback. * \param p_cb_data private data given in argument to the callback.
* \return 0 if everything went ok. * \return true on success, false on failure
*/ */
int dvbpsi_AttachSIS(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachSIS(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
uint16_t i_extension, dvbpsi_sis_callback pf_callback, dvbpsi_sis_callback pf_callback, void* p_cb_data);
void* p_cb_data);
/***************************************************************************** /*****************************************************************************
* dvbpsi_DetachSIS * dvbpsi_DetachSIS
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#if defined(HAVE_INTTYPES_H) #if defined(HAVE_INTTYPES_H)
...@@ -39,6 +40,8 @@ ...@@ -39,6 +40,8 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <assert.h>
#include "../dvbpsi.h" #include "../dvbpsi.h"
#include "../dvbpsi_private.h" #include "../dvbpsi_private.h"
#include "../psi.h" #include "../psi.h"
...@@ -52,9 +55,12 @@ ...@@ -52,9 +55,12 @@
***************************************************************************** *****************************************************************************
* Initialize a TDT/TOT subtable decoder. * Initialize a TDT/TOT subtable decoder.
*****************************************************************************/ *****************************************************************************/
int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extension, bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
dvbpsi_tot_callback pf_callback, void* p_cb_data) dvbpsi_tot_callback pf_callback, void* p_cb_data)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_tot_decoder_t* p_tot_decoder; dvbpsi_tot_decoder_t* p_tot_decoder;
...@@ -65,18 +71,18 @@ int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensio ...@@ -65,18 +71,18 @@ int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensio
"Already a decoder for (table_id == 0x%02x," "Already a decoder for (table_id == 0x%02x,"
"extension == 0x%02x)", "extension == 0x%02x)",
i_table_id, 0); i_table_id, 0);
return 1; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t));
if(p_subdec == NULL) if(p_subdec == NULL)
return 1; return false;
p_tot_decoder = (dvbpsi_tot_decoder_t*)calloc(1, sizeof(dvbpsi_tot_decoder_t)); p_tot_decoder = (dvbpsi_tot_decoder_t*)calloc(1, sizeof(dvbpsi_tot_decoder_t));
if (p_tot_decoder == NULL) if (p_tot_decoder == NULL)
{ {
free(p_subdec); free(p_subdec);
return 1; return false;
} }
/* subtable decoder configuration */ /* subtable decoder configuration */
...@@ -93,7 +99,7 @@ int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensio ...@@ -93,7 +99,7 @@ int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensio
p_tot_decoder->pf_tot_callback = pf_callback; p_tot_decoder->pf_tot_callback = pf_callback;
p_tot_decoder->p_cb_data = p_cb_data; p_tot_decoder->p_cb_data = p_cb_data;
return 0; return true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -104,6 +110,9 @@ int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensio ...@@ -104,6 +110,9 @@ int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensio
void dvbpsi_DetachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, 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->p_private);
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_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec; dvbpsi_demux_subdec_t** pp_prev_subdec;
...@@ -186,6 +195,9 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi, ...@@ -186,6 +195,9 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
void * p_private_decoder, void * p_private_decoder,
dvbpsi_psi_section_t* p_section) dvbpsi_psi_section_t* p_section)
{ {
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
dvbpsi_tot_decoder_t* p_tot_decoder dvbpsi_tot_decoder_t* p_tot_decoder
= (dvbpsi_tot_decoder_t*)p_private_decoder; = (dvbpsi_tot_decoder_t*)p_private_decoder;
int b_append = 1; int b_append = 1;
......
...@@ -78,7 +78,7 @@ typedef void (* dvbpsi_tot_callback)(void* p_cb_data, dvbpsi_tot_t* p_new_tot); ...@@ -78,7 +78,7 @@ typedef void (* dvbpsi_tot_callback)(void* p_cb_data, dvbpsi_tot_t* p_new_tot);
* dvbpsi_AttachTOT * dvbpsi_AttachTOT
*****************************************************************************/ *****************************************************************************/
/*! /*!
* \fn int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extension, * \fn bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
dvbpsi_tot_callback pf_callback, void* p_cb_data) dvbpsi_tot_callback pf_callback, void* p_cb_data)
* \brief Creation and initialization of a TDT/TOT decoder. * \brief Creation and initialization of a TDT/TOT decoder.
* \param p_dvbpsi dvbpsi handle pointing to Subtable demultiplexor to which the decoder is attached. * \param p_dvbpsi dvbpsi handle pointing to Subtable demultiplexor to which the decoder is attached.
...@@ -86,11 +86,10 @@ typedef void (* dvbpsi_tot_callback)(void* p_cb_data, dvbpsi_tot_t* p_new_tot); ...@@ -86,11 +86,10 @@ typedef void (* dvbpsi_tot_callback)(void* p_cb_data, dvbpsi_tot_t* p_new_tot);
* \param i_extension Table ID extension, unused in the TDT/TOT * \param i_extension Table ID extension, unused in the TDT/TOT
* \param pf_callback function to call back on new TDT/TOT. * \param pf_callback function to call back on new TDT/TOT.
* \param p_cb_data private data given in argument to the callback. * \param p_cb_data private data given in argument to the callback.
* \return 0 if everything went ok. * \return true on success, false on failure
*/ */
int dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
uint16_t i_extension, dvbpsi_tot_callback pf_callback, void* p_cb_data);
dvbpsi_tot_callback pf_callback, void* p_cb_data);
/***************************************************************************** /*****************************************************************************
* dvbpsi_DetachTOT * dvbpsi_DetachTOT
......
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