Commit 9c8a0728 authored by Jean-Paul Saman's avatar Jean-Paul Saman

EIT: implement as chained decoder

parent 1f4b9517
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include "../dvbpsi_private.h" #include "../dvbpsi_private.h"
#include "../psi.h" #include "../psi.h"
#include "../descriptor.h" #include "../descriptor.h"
#include "../demux.h" #include "../chain.h"
#include "eit.h" #include "eit.h"
#include "eit_private.h" #include "eit_private.h"
...@@ -58,11 +58,9 @@ bool dvbpsi_eit_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens ...@@ -58,11 +58,9 @@ bool dvbpsi_eit_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
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_decoder);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_decoder; dvbpsi_decoder_t *p_dec = dvbpsi_decoder_chain_get(p_dvbpsi, i_table_id, i_extension);
if (p_dec != NULL)
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension) != NULL)
{ {
dvbpsi_error(p_dvbpsi, "EIT decoder", dvbpsi_error(p_dvbpsi, "EIT decoder",
"Already a decoder for (table_id == 0x%02x," "Already a decoder for (table_id == 0x%02x,"
...@@ -72,29 +70,26 @@ bool dvbpsi_eit_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens ...@@ -72,29 +70,26 @@ bool dvbpsi_eit_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
} }
dvbpsi_eit_decoder_t* p_eit_decoder; dvbpsi_eit_decoder_t* p_eit_decoder;
p_eit_decoder = (dvbpsi_eit_decoder_t*) dvbpsi_decoder_new(NULL, p_eit_decoder = (dvbpsi_eit_decoder_t*) dvbpsi_decoder_new(dvbpsi_eit_sections_gather,
0, true, sizeof(dvbpsi_eit_decoder_t)); 4096, true, sizeof(dvbpsi_eit_decoder_t));
if (p_eit_decoder == NULL) if (p_eit_decoder == NULL)
return false; return false;
/* subtable decoder configuration */
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_eit_detach,
dvbpsi_eit_sections_gather, DVBPSI_DECODER(p_eit_decoder));
if (p_subdec == NULL)
{
dvbpsi_decoder_delete(DVBPSI_DECODER(p_eit_decoder));
return false;
}
/* Attach the subtable decoder to the demux */
dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
/* EIT decoder information */ /* EIT decoder information */
p_eit_decoder->pf_eit_callback = pf_callback; p_eit_decoder->pf_eit_callback = pf_callback;
p_eit_decoder->p_cb_data = p_cb_data; p_eit_decoder->p_cb_data = p_cb_data;
p_eit_decoder->p_building_eit = NULL; p_eit_decoder->p_building_eit = NULL;
p_eit_decoder->i_table_id = i_table_id;
p_eit_decoder->i_extension = i_extension;
/* add sdt decoder to decoder chain */
if (!dvbpsi_decoder_chain_add(p_dvbpsi, DVBPSI_DECODER(p_eit_decoder)))
{
dvbpsi_decoder_delete(DVBPSI_DECODER(p_eit_decoder));
return false;
}
return true; return true;
} }
...@@ -103,17 +98,12 @@ bool dvbpsi_eit_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens ...@@ -103,17 +98,12 @@ bool dvbpsi_eit_attach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extens
***************************************************************************** *****************************************************************************
* Close a EIT decoder. * Close a EIT decoder.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_eit_detach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, void dvbpsi_eit_detach(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_decoder);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_decoder_t *p_dec = dvbpsi_decoder_chain_get(p_dvbpsi, i_table_id, i_extension);
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); if (p_dec == NULL)
if (p_subdec == NULL)
{ {
dvbpsi_error(p_dvbpsi, "EIT Decoder", dvbpsi_error(p_dvbpsi, "EIT Decoder",
"No such EIT decoder (table_id == 0x%02x," "No such EIT decoder (table_id == 0x%02x,"
...@@ -122,14 +112,22 @@ void dvbpsi_eit_detach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -122,14 +112,22 @@ void dvbpsi_eit_detach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
return; return;
} }
dvbpsi_eit_decoder_t* p_eit_decoder; /* Remove table decoder from decoder chain */
p_eit_decoder = (dvbpsi_eit_decoder_t*)p_subdec->p_decoder; if (!dvbpsi_decoder_chain_remove(p_dvbpsi, p_dec))
{
dvbpsi_error(p_dvbpsi, "EIT Decoder",
"Failed to remove"
"extension == 0x%02x)",
i_table_id, i_extension);
return;
}
dvbpsi_eit_decoder_t* p_eit_decoder = (dvbpsi_eit_decoder_t*)p_dec;
if (p_eit_decoder->p_building_eit) if (p_eit_decoder->p_building_eit)
dvbpsi_eit_delete(p_eit_decoder->p_building_eit); dvbpsi_eit_delete(p_eit_decoder->p_building_eit);
p_eit_decoder->p_building_eit = NULL; p_eit_decoder->p_building_eit = NULL;
dvbpsi_decoder_delete(p_dec);
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); p_dec = NULL;
dvbpsi_DeleteDemuxSubDecoder(p_subdec);
} }
/***************************************************************************** /*****************************************************************************
...@@ -421,11 +419,9 @@ static bool dvbpsi_AddSectionEIT(dvbpsi_t *p_dvbpsi, dvbpsi_eit_decoder_t *p_eit ...@@ -421,11 +419,9 @@ static bool dvbpsi_AddSectionEIT(dvbpsi_t *p_dvbpsi, dvbpsi_eit_decoder_t *p_eit
***************************************************************************** *****************************************************************************
* Callback for the subtable demultiplexor. * Callback for the subtable demultiplexor.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_eit_sections_gather(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_decoder, void dvbpsi_eit_sections_gather(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_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) ?
...@@ -437,17 +433,21 @@ void dvbpsi_eit_sections_gather(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_ ...@@ -437,17 +433,21 @@ void dvbpsi_eit_sections_gather(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_
return; return;
} }
dvbpsi_decoder_t *p_dec = dvbpsi_decoder_chain_get(p_dvbpsi, i_table_id, p_section->i_extension);
if (!p_dec)
{
dvbpsi_DeletePSISections(p_section);
return;
}
/* We have a valid EIT section */ /* We have a valid EIT section */
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_decoder; dvbpsi_eit_decoder_t* p_eit_decoder = (dvbpsi_eit_decoder_t*)p_dec;
dvbpsi_eit_decoder_t* p_eit_decoder
= (dvbpsi_eit_decoder_t*)p_private_decoder;
/* TS discontinuity check */ /* TS discontinuity check */
if (p_demux->b_discontinuity) if (p_eit_decoder->b_discontinuity)
{ {
dvbpsi_ReInitEIT(p_eit_decoder, true); dvbpsi_ReInitEIT(p_eit_decoder, true);
p_eit_decoder->b_discontinuity = false; p_eit_decoder->b_discontinuity = false;
p_demux->b_discontinuity = false;
} }
else else
{ {
......
...@@ -52,9 +52,7 @@ typedef struct dvbpsi_eit_decoder_s ...@@ -52,9 +52,7 @@ typedef struct dvbpsi_eit_decoder_s
***************************************************************************** *****************************************************************************
* Callback for the PSI decoder. * Callback for the PSI decoder.
*****************************************************************************/ *****************************************************************************/
void dvbpsi_eit_sections_gather(dvbpsi_t *p_dvbpsi, void dvbpsi_eit_sections_gather(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section);
dvbpsi_decoder_t *p_private_decoder,
dvbpsi_psi_section_t *p_section);
/***************************************************************************** /*****************************************************************************
* dvbpsi_eit_sections_decode * dvbpsi_eit_sections_decode
......
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