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

dvbinfo: use chained decoders iso of old demux API

parent d6e0e5c6
......@@ -47,8 +47,8 @@
/* The libdvbpsi distribution defines DVBPSI_DIST */
#ifdef DVBPSI_DIST
# include "../../src/dvbpsi.h"
# include "../../src/demux.h"
# include "../../src/psi.h"
# include "../../src/chain.h"
# include "../../src/descriptor.h"
# include "../../src/tables/pat.h"
# include "../../src/tables/pmt.h"
......@@ -68,8 +68,8 @@
# include "../../src/tables/atsc_vct.h"
#else
# include <dvbpsi/dvbpsi.h>
# include <dvbpsi/demux.h>
# include <dvbpsi/psi.h>
# include <dvbpsi/chain.h>
# include <dvbpsi/descriptor.h>
# include <dvbpsi/pat.h>
# include <dvbpsi/pmt.h>
......@@ -285,7 +285,7 @@ struct ts_stream_t
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static void handle_PAT(void* p_data, dvbpsi_pat_t* p_pat);
static void handle_PMT(void* p_data, dvbpsi_pmt_t* p_pmt);
static void handle_CAT(void* p_data, dvbpsi_cat_t* p_cat);
static void handle_SDT(void* p_data, dvbpsi_sdt_t* p_sdt);
......@@ -304,6 +304,8 @@ static void handle_atsc_ETT(void* p_data, dvbpsi_atsc_ett_t *p_ett);
static void handle_atsc_STT(void* p_data, dvbpsi_atsc_stt_t *p_stt);
static const char *AACProfileToString(dvbpsi_aac_profile_and_level_t profile);
static void DeleteTableDecoder(dvbpsi_t *p_dvbpsi, uint8_t i_table, uint16_t i_extension);
/*****************************************************************************
* mdate: current time in milliseconds
*****************************************************************************/
......@@ -592,9 +594,15 @@ static void handle_subtable(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_e
{
switch (i_table_id)
{
#if 0 /* already handled */
case 0x00: // PAT
if (!dvbpsi_pat_attach(p_dvbpsi, i_table_id, i_extension, handle_PAT, p_data))
fprintf(stderr, "dvbinfo: Failed to attach PAT decoder\n");
break;
case 0x01: // CAT
if (!dvbpsi_cat_attach(p_dvbpsi, i_table_id, i_extension, handle_CAT, p_data))
fprintf(stderr, "dvbinfo: Failed to attach CAT decoder\n");
break;
#if 0 /* already handled */
case 0x02: // program_map_section
case 0x03: // transport_stream_description_section
case 0x04: /* ISO_IEC_14496_scene_description_section */
......@@ -666,8 +674,11 @@ static void handle_subtable(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_e
if (!dvbpsi_tot_attach(p_dvbpsi, i_table_id, i_extension, handle_TOT, p_data))
fprintf(stderr, "dvbinfo: Failed to attach TOT subdecoder\n");
break;
#if 0
case 0x71: // RST running_status_section
if (!dvbpsi_rst_attach(p_dvbpsi, i_table_id, i_extension, handle_RST, p_data))
fprintf(stderr, "dvbinfo: Failed to attach RST subdecoder\n");
break;
#if 0
case 0x72: // ST stuffing_section
case 0x74: // application information section (TS 102 812 [15])
case 0x75: // container section (TS 102 323 [13])
......@@ -747,7 +758,9 @@ static void handle_PAT(void* p_data, dvbpsi_pat_t* p_pat)
p_pmt->pid_pmt->i_pid = p_program->i_pid;
p_pmt->p_next = NULL;
if (!dvbpsi_pmt_attach(p_pmt->handle, p_program->i_number, handle_PMT, p_stream))
/* PMT table_id == 0x02 and extenion == 0x0 */
if (!dvbpsi_pmt_attach(p_pmt->handle, 0x02, 0x0,
p_program->i_number, handle_PMT, p_stream))
{
fprintf(stderr, "dvbinfo: Failed to attach new pmt decoder\n");
dvbpsi_delete(p_pmt->handle);
......@@ -1937,7 +1950,7 @@ static void handle_atsc_MGT(void *p_data, dvbpsi_atsc_mgt_t *p_mgt)
p->pid->i_pid = p_table->i_table_type_pid;
p->p_next = NULL;
if (!dvbpsi_AttachDemux(p->handle, handle_subtable, p_stream))
if (!dvbpsi_decoder_chain_new(p->handle, handle_subtable, DeleteTableDecoder, p_stream))
{
fprintf(stderr, "dvbinfo: Failed to attach new ATSC EIT decoder\n");
dvbpsi_delete(p->handle);
......@@ -2282,6 +2295,99 @@ static void handle_CAT(void *p_data, dvbpsi_cat_t *p_cat)
dvbpsi_cat_delete(p_cat);
}
/*****************************************************************************
* Delete decoder from chain
*****************************************************************************/
static void DeleteTableDecoder(dvbpsi_t *p_dvbpsi, uint8_t i_table, uint16_t i_extension)
{
switch (i_table)
{
case 0x00: dvbpsi_pat_detach(p_dvbpsi, i_table, i_extension); break;
case 0x01: dvbpsi_cat_detach(p_dvbpsi, i_table, i_extension); break;
#if 0 /* already handled */
case 0x02: // program_map_section
case 0x03: // transport_stream_description_section
case 0x04: /* ISO_IEC_14496_scene_description_section */
case 0x05: /* ISO_IEC_14496_object_descriptor_section */
case 0x06: /* Metadata_section */
case 0x07: /* IPMP_Control_Information_section (defined in ISO/IEC 13818-11) */
/* 0x08-0x3F: ITU-T Rec. H.222.0 | ISO/IEC 13818-1 reserved */
#endif
case 0x40: // NIT network_information_section - actual_network
case 0x41: dvbpsi_nit_detach(p_dvbpsi, i_table, i_extension); break; // NIT network_information_section - other_network
case 0x42: dvbpsi_sdt_detach(p_dvbpsi, i_table, i_extension); break;
#if 0
/* 0x43 to 0x45 reserved for future use */
case 0x46: // service_description_section - other_transport_stream
/* 0x47 to 0x49 reserved for future use */
#endif
case 0x4A: dvbpsi_bat_detach(p_dvbpsi, i_table, i_extension); break; // BAT bouquet_association_section
//0x4B to 0x4D reserved for future use
case 0x4E: // EIT event_information_section - actual_transport_stream, present/following
case 0x4F: // EIT event_information_section - other_transport_stream, present/following
//0x50 to 0x5F event_information_section - actual_transport_stream, schedule
case 0x50:
case 0x51:
case 0x52:
case 0x53:
case 0x54:
case 0x55:
case 0x56:
case 0x57:
case 0x58:
case 0x59:
case 0x5A:
case 0x5B:
case 0x5C:
case 0x5D:
case 0x5E:
case 0x5F:
//0x60 to 0x6F event_information_section - other_transport_stream, schedule
case 0x60:
case 0x61:
case 0x62:
case 0x63:
case 0x64:
case 0x65:
case 0x66:
case 0x67:
case 0x68:
case 0x69:
case 0x6A:
case 0x6B:
case 0x6C:
case 0x6D:
case 0x6E:
case 0x6F: dvbpsi_eit_detach(p_dvbpsi, i_table, i_extension); break;
case 0x70: /* TDT */
case 0x73: dvbpsi_tot_detach(p_dvbpsi, i_table, i_extension); break; /* TOT only */
case 0x71: dvbpsi_rst_detach(p_dvbpsi, i_table, i_extension); break; /* RST running_status_section */
#if 0
case 0x72: // ST stuffing_section
case 0x74: // application information section (TS 102 812 [15])
case 0x75: // container section (TS 102 323 [13])
case 0x76: // related content section (TS 102 323 [13])
case 0x77: // content identifier section (TS 102 323 [13])
case 0x78: // MPE-FEC section (EN 301 192 [4])
case 0x79: // resolution notification section (TS 102 323 [13])
#endif
/* Handle ATSC PSI tables */
case 0xC7: dvbpsi_atsc_DetachMGT(p_dvbpsi, i_table, i_extension); break; /* ATSC MGT */
case 0xC8: /* ATSC VCT */
case 0xC9: dvbpsi_atsc_DetachVCT(p_dvbpsi, i_table, i_extension); break; /* ATSC VCT */
case 0xCB: dvbpsi_atsc_DetachEIT(p_dvbpsi, i_table, i_extension); break; /* ATSC EIT */
case 0xCC: dvbpsi_atsc_DetachETT(p_dvbpsi, i_table, i_extension); break; /* ATSC ETT */
case 0xCD: dvbpsi_atsc_DetachSTT(p_dvbpsi, i_table, i_extension); break; /* ATSC STT */
#ifdef TS_USE_SCTE_SIS
case 0xFC: dvbpsi_sis_detach(p_dvbpsi, i_table, i_extension); break; /* SIS */
#endif
default:
fprintf(stderr, "dvbinfo: Failed to detach table decoder (table_id: %d, extension: %d)\n",
i_table, i_extension);
break;
}
}
/*****************************************************************************
* Public API
*****************************************************************************/
......@@ -2310,7 +2416,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->pat.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->pat.handle == NULL)
goto error;
if (!dvbpsi_pat_attach(stream->pat.handle, handle_PAT, stream))
if (!dvbpsi_decoder_chain_new(stream->pat.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->pat.handle);
stream->pat.handle = NULL;
......@@ -2320,7 +2426,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->cat.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->cat.handle == NULL)
goto error;
if (!dvbpsi_cat_attach(stream->cat.handle, handle_CAT, stream))
if (!dvbpsi_decoder_chain_new(stream->cat.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->cat.handle);
stream->cat.handle = NULL;
......@@ -2330,7 +2436,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->sdt.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->sdt.handle == NULL)
goto error;
if (!dvbpsi_AttachDemux(stream->sdt.handle, handle_subtable, stream))
if (!dvbpsi_decoder_chain_new(stream->sdt.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->sdt.handle);
stream->sdt.handle = NULL;
......@@ -2340,7 +2446,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->rst.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->rst.handle == NULL)
goto error;
if (!dvbpsi_rst_attach(stream->rst.handle, handle_RST, stream))
if (!dvbpsi_decoder_chain_new(stream->rst.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->rst.handle);
stream->rst.handle = NULL;
......@@ -2350,7 +2456,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->eit.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->eit.handle == NULL)
goto error;
if (!dvbpsi_AttachDemux(stream->eit.handle, handle_subtable, stream))
if (!dvbpsi_decoder_chain_new(stream->eit.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->eit.handle);
stream->eit.handle = NULL;
......@@ -2360,7 +2466,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->tdt.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->tdt.handle == NULL)
goto error;
if (!dvbpsi_AttachDemux(stream->tdt.handle, handle_subtable, stream))
if (!dvbpsi_decoder_chain_new(stream->tdt.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->tdt.handle);
stream->tdt.handle = NULL;
......@@ -2371,7 +2477,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->atsc.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->atsc.handle == NULL)
goto error;
if (!dvbpsi_AttachDemux(stream->atsc.handle, handle_subtable, stream))
if (!dvbpsi_decoder_chain_new(stream->atsc.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->atsc.handle);
stream->atsc.handle = NULL;
......@@ -2393,20 +2499,20 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
return stream;
error:
if (dvbpsi_decoder_present(stream->pat.handle))
dvbpsi_pat_detach(stream->pat.handle);
if (dvbpsi_decoder_present(stream->cat.handle))
dvbpsi_cat_detach(stream->cat.handle);
if (dvbpsi_decoder_present(stream->sdt.handle))
dvbpsi_DetachDemux(stream->sdt.handle);
if (dvbpsi_decoder_present(stream->eit.handle))
dvbpsi_DetachDemux(stream->eit.handle);
if (dvbpsi_decoder_present(stream->rst.handle))
dvbpsi_rst_detach(stream->rst.handle);
if (dvbpsi_decoder_present(stream->tdt.handle))
dvbpsi_DetachDemux(stream->tdt.handle);
if (dvbpsi_decoder_present(stream->atsc.handle))
dvbpsi_DetachDemux(stream->atsc.handle);
if (dvbpsi_decoder_chain_delete(stream->pat.handle))
fprintf(stderr, "dvbinfo: failed to delete PAT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->cat.handle))
fprintf(stderr, "dvbinfo: failed to delete CAT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->sdt.handle))
fprintf(stderr, "dvbinfo: failed to delete SDT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->eit.handle))
fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->rst.handle))
fprintf(stderr, "dvbinfo: failed to delete RST decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->tdt.handle))
fprintf(stderr, "dvbinfo: failed to delete TDT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->atsc.handle))
fprintf(stderr, "dvbinfo: failed to delete ATSC decoder chain! .. possibly leaking memory!!\n");
if (stream->pat.handle)
dvbpsi_delete(stream->pat.handle);
......@@ -2432,19 +2538,18 @@ void libdvbpsi_exit(ts_stream_t *stream)
{
summary(stdout, stream);
if (dvbpsi_decoder_present(stream->pat.handle))
dvbpsi_pat_detach(stream->pat.handle);
if (dvbpsi_decoder_chain_delete(stream->pat.handle))
fprintf(stderr, "dvbinfo: failed to delete PAT decoder chain! .. possibly leaking memory!!\n");
ts_pmt_t *p_pmt = stream->pmt;
ts_pmt_t *p_prev = NULL;
while (p_pmt)
{
dvbpsi_t *handle = p_pmt->handle;
if (dvbpsi_decoder_present(handle))
{
dvbpsi_pmt_detach(handle);
if (!dvbpsi_decoder_chain_delete(handle))
fprintf(stderr, "dvbinfo: failed to delete PMT decoder chain! .. possibly leaking memory!!\n");
dvbpsi_delete(p_pmt->handle);
}
stream->i_pmt--;
p_prev = p_pmt;
p_pmt = p_pmt->p_next;
......@@ -2458,11 +2563,10 @@ void libdvbpsi_exit(ts_stream_t *stream)
while (p_atsc_eit)
{
dvbpsi_t *handle = p_atsc_eit->handle;
if (dvbpsi_decoder_present(handle))
{
dvbpsi_DetachDemux(handle);
if (!dvbpsi_decoder_chain_delete(handle))
fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n");
dvbpsi_delete(p_atsc_eit->handle);
}
stream->i_atsc_eit--;
p_atsc_prev = p_atsc_eit;
p_atsc_eit = p_atsc_eit->p_next;
......@@ -2471,18 +2575,18 @@ void libdvbpsi_exit(ts_stream_t *stream)
free(p_atsc_prev);
}
if (dvbpsi_decoder_present(stream->cat.handle))
dvbpsi_cat_detach(stream->cat.handle);
if (dvbpsi_decoder_present(stream->sdt.handle))
dvbpsi_DetachDemux(stream->sdt.handle);
if (dvbpsi_decoder_present(stream->rst.handle))
dvbpsi_rst_detach(stream->rst.handle);
if (dvbpsi_decoder_present(stream->eit.handle))
dvbpsi_DetachDemux(stream->eit.handle);
if (dvbpsi_decoder_present(stream->tdt.handle))
dvbpsi_DetachDemux(stream->tdt.handle);
if (dvbpsi_decoder_present(stream->atsc.handle))
dvbpsi_DetachDemux(stream->atsc.handle);
if (dvbpsi_decoder_chain_delete(stream->cat.handle))
fprintf(stderr, "dvbinfo: failed to delete CAT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->sdt.handle))
fprintf(stderr, "dvbinfo: failed to delete SDT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->eit.handle))
fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->rst.handle))
fprintf(stderr, "dvbinfo: failed to delete RST decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->tdt.handle))
fprintf(stderr, "dvbinfo: failed to delete TDT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->atsc.handle))
fprintf(stderr, "dvbinfo: failed to delete ATSC decoder chain! .. possibly leaking memory!!\n");
if (stream->pat.handle)
dvbpsi_delete(stream->pat.handle);
......
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