Commit 98184467 authored by Michael Krufky's avatar Michael Krufky Committed by Jean-Paul Saman

fix broken interfaces in ETT parser

Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
parent 5d461d8a
...@@ -26,8 +26,10 @@ Decode PSIP Extended Text Table. ...@@ -26,8 +26,10 @@ Decode PSIP Extended Text Table.
#include <string.h> #include <string.h>
#include "dvbpsi.h" #include "dvbpsi.h"
#include "dvbpsi_private.h"
#include "psi.h" #include "psi.h"
#include "descriptor.h" #include "descriptor.h"
#include "demux.h"
#include "atsc_ett.h" #include "atsc_ett.h"
/***************************************************************************** /*****************************************************************************
...@@ -60,7 +62,8 @@ typedef struct dvbpsi_atsc_ett_decoder_s ...@@ -60,7 +62,8 @@ typedef struct dvbpsi_atsc_ett_decoder_s
***************************************************************************** *****************************************************************************
* Callback for the PSI decoder. * Callback for the PSI decoder.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_atsc_GatherETTSections(dvbpsi_decoder_t* p_decoder, void dvbpsi_atsc_GatherETTSections(dvbpsi_decoder_t * p_psi_decoder,
void * p_private_decoder,
dvbpsi_psi_section_t* p_section); dvbpsi_psi_section_t* p_section);
/***************************************************************************** /*****************************************************************************
* dvbpsi_atsc_DecodeETTSection * dvbpsi_atsc_DecodeETTSection
...@@ -75,37 +78,52 @@ void dvbpsi_atsc_DecodeETTSection(dvbpsi_atsc_ett_t* p_ett, ...@@ -75,37 +78,52 @@ void dvbpsi_atsc_DecodeETTSection(dvbpsi_atsc_ett_t* p_ett,
***************************************************************************** *****************************************************************************
* Initialize a ETT decoder and return a handle on it. * Initialize a ETT decoder and return a handle on it.
*****************************************************************************/ *****************************************************************************/
dvbpsi_handle dvbpsi_atsc_AttachETT(dvbpsi_atsc_ett_callback pf_callback, void* p_cb_data) int dvbpsi_atsc_AttachETT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id, uint16_t i_extension,
dvbpsi_atsc_ett_callback pf_callback, void* p_cb_data)
{ {
dvbpsi_handle h_dvbpsi = (dvbpsi_decoder_t*)malloc(sizeof(dvbpsi_decoder_t)); dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_psi_decoder->p_private_decoder;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_atsc_ett_decoder_t* p_ett_decoder; dvbpsi_atsc_ett_decoder_t* p_ett_decoder;
if(h_dvbpsi == NULL) if(dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
return NULL; {
DVBPSI_ERROR_ARG("ETT decoder",
"Already a decoder for (table_id == 0x%02x extension == 0x%04x)",
i_table_id, i_extension);
return 1;
}
p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t));
if(p_subdec == NULL)
{
return 1;
}
p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)malloc(sizeof(dvbpsi_atsc_ett_decoder_t)); p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)malloc(sizeof(dvbpsi_atsc_ett_decoder_t));
if(p_ett_decoder == NULL) if(p_ett_decoder == NULL)
{ {
free(h_dvbpsi); free(p_subdec);
return NULL; return 1;
} }
/* PSI decoder configuration */ /* PSI decoder configuration */
h_dvbpsi->pf_callback = &dvbpsi_atsc_GatherETTSections; p_subdec->pf_callback = &dvbpsi_atsc_GatherETTSections;
h_dvbpsi->p_private_decoder = p_ett_decoder; p_subdec->p_cb_data = p_ett_decoder;
h_dvbpsi->i_section_max_size = 4096; p_subdec->i_id = ((uint32_t)i_table_id << 16) | i_extension;
/* PSI decoder initial state */ p_subdec->pf_detach = dvbpsi_atsc_DetachETT;
h_dvbpsi->i_continuity_counter = 31;
h_dvbpsi->b_discontinuity = 1; /* Attach the subtable decoder to the demux */
h_dvbpsi->p_current_section = NULL; p_subdec->p_next = p_demux->p_first_subdec;
p_demux->p_first_subdec = p_subdec;
/* ETT decoder information */ /* ETT decoder information */
p_ett_decoder->pf_callback = pf_callback; p_ett_decoder->pf_callback = pf_callback;
p_ett_decoder->p_cb_data = p_cb_data; p_ett_decoder->p_cb_data = p_cb_data;
p_ett_decoder->p_etm_versions = NULL; p_ett_decoder->p_etm_versions = NULL;
return h_dvbpsi; return 0;
} }
...@@ -114,10 +132,23 @@ dvbpsi_handle dvbpsi_atsc_AttachETT(dvbpsi_atsc_ett_callback pf_callback, void* ...@@ -114,10 +132,23 @@ dvbpsi_handle dvbpsi_atsc_AttachETT(dvbpsi_atsc_ett_callback pf_callback, void*
***************************************************************************** *****************************************************************************
* Close a ETT decoder. The handle isn't valid any more. * Close a ETT decoder. The handle isn't valid any more.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_atsc_DetachETT(dvbpsi_handle h_dvbpsi) void dvbpsi_atsc_DetachETT(dvbpsi_demux_t * p_demux, uint8_t i_table_id, uint16_t i_extension)
{ {
dvbpsi_atsc_ett_decoder_t* p_ett_decoder dvbpsi_demux_subdec_t* p_subdec;
= (dvbpsi_atsc_ett_decoder_t*)h_dvbpsi->p_private_decoder; dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_atsc_ett_decoder_t* p_ett_decoder;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if(p_demux == NULL)
{
DVBPSI_ERROR_ARG("ETT Decoder",
"No such ETT decoder (table_id == 0x%02x,"
"extension == 0x%04x)",
i_table_id, i_extension);
return;
}
p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)p_subdec->p_cb_data;
dvbpsi_atsc_ett_etm_version_t *p_etm_version, *p_next; dvbpsi_atsc_ett_etm_version_t *p_etm_version, *p_next;
for (p_etm_version = p_ett_decoder->p_etm_versions; p_etm_version; p_etm_version = p_next) for (p_etm_version = p_ett_decoder->p_etm_versions; p_etm_version; p_etm_version = p_next)
{ {
...@@ -125,10 +156,14 @@ void dvbpsi_atsc_DetachETT(dvbpsi_handle h_dvbpsi) ...@@ -125,10 +156,14 @@ void dvbpsi_atsc_DetachETT(dvbpsi_handle h_dvbpsi)
free(p_etm_version); free(p_etm_version);
} }
free(h_dvbpsi->p_private_decoder); free(p_subdec->p_cb_data);
if(h_dvbpsi->p_current_section)
dvbpsi_DeletePSISections(h_dvbpsi->p_current_section); pp_prev_subdec = &p_demux->p_first_subdec;
free(h_dvbpsi); while(*pp_prev_subdec != p_subdec)
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
} }
...@@ -178,11 +213,12 @@ void dvbpsi_atsc_EmptyETT(dvbpsi_atsc_ett_t *p_ett) ...@@ -178,11 +213,12 @@ void dvbpsi_atsc_EmptyETT(dvbpsi_atsc_ett_t *p_ett)
***************************************************************************** *****************************************************************************
* Callback for the PSI decoder. * Callback for the PSI decoder.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_atsc_GatherETTSections(dvbpsi_decoder_t* p_decoder, void dvbpsi_atsc_GatherETTSections(dvbpsi_decoder_t* p_psi_decoder,
void * p_private_decoder,
dvbpsi_psi_section_t* p_section) dvbpsi_psi_section_t* p_section)
{ {
dvbpsi_atsc_ett_decoder_t* p_ett_decoder dvbpsi_atsc_ett_decoder_t* p_ett_decoder
= (dvbpsi_atsc_ett_decoder_t*)p_decoder->p_private_decoder; = (dvbpsi_atsc_ett_decoder_t*)p_private_decoder;
if(p_section->i_table_id == 0xCC) if(p_section->i_table_id == 0xCC)
{ {
......
...@@ -23,6 +23,9 @@ Decode PSIP Extended Text Table. ...@@ -23,6 +23,9 @@ Decode PSIP Extended Text Table.
#ifndef _ATSC_ETT_H #ifndef _ATSC_ETT_H
#define _ATSC_ETT_H #define _ATSC_ETT_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************** /*****************************************************************************
* dvbpsi_atsc_ett_t * dvbpsi_atsc_ett_t
...@@ -68,11 +71,13 @@ typedef void (* dvbpsi_atsc_ett_callback)(void* p_cb_data, dvbpsi_atsc_ett_t* p_ ...@@ -68,11 +71,13 @@ typedef void (* dvbpsi_atsc_ett_callback)(void* p_cb_data, dvbpsi_atsc_ett_t* p_
dvbpsi_atsc_ett_callback pf_callback, void* p_cb_data) dvbpsi_atsc_ett_callback pf_callback, void* p_cb_data)
* *
* \brief Creation and initialization of a ETT decoder. * \brief Creation and initialization of a ETT decoder.
* \param i_extension Table ID extension, normally 0x0000.
* \param pf_callback function to call back on new ETT. * \param pf_callback function to call back on new ETT.
* \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 0 if everything went ok.
*/ */
dvbpsi_handle dvbpsi_atsc_AttachETT(dvbpsi_atsc_ett_callback pf_callback, void* p_cb_data); int dvbpsi_atsc_AttachETT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id,
uint16_t i_extension, dvbpsi_atsc_ett_callback pf_callback, void* p_cb_data);
/***************************************************************************** /*****************************************************************************
...@@ -84,11 +89,11 @@ dvbpsi_handle dvbpsi_atsc_AttachETT(dvbpsi_atsc_ett_callback pf_callback, void* ...@@ -84,11 +89,11 @@ dvbpsi_handle dvbpsi_atsc_AttachETT(dvbpsi_atsc_ett_callback pf_callback, void*
* \brief Destroy a ETT decoder. * \brief Destroy a ETT decoder.
* \param p_demux Subtable demultiplexor to which the decoder is attached. * \param p_demux Subtable demultiplexor to which the decoder is attached.
* \param i_table_id Table ID, 0xCD. * \param i_table_id Table ID, 0xCD.
* \param i_extension Table extension, ignored as this should always be 0. * \param i_extension Table ID extension, normally 0x0000.
* (Required to match prototype for demux)
* \return nothing. * \return nothing.
*/ */
void dvbpsi_atsc_DetachETT(dvbpsi_handle h_dvbpsi); void dvbpsi_atsc_DetachETT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
uint16_t i_extension);
/***************************************************************************** /*****************************************************************************
...@@ -148,4 +153,8 @@ void dvbpsi_atsc_EmptyETT(dvbpsi_atsc_ett_t *p_ett); ...@@ -148,4 +153,8 @@ void dvbpsi_atsc_EmptyETT(dvbpsi_atsc_ett_t *p_ett);
free(p_ett); \ free(p_ett); \
} while(0); } while(0);
#ifdef __cplusplus
};
#endif
#endif #endif
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