From: Jaroslav Kysela Date: Tue, 13 Mar 2018 14:29:10 +0000 (+0100) Subject: hbbtv: parse hbbtv outside elementary stream X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5ccff6b6c913c3a21cb0f03b53123f2b284190da;p=thirdparty%2Ftvheadend.git hbbtv: parse hbbtv outside elementary stream --- diff --git a/src/esstream.c b/src/esstream.c index c13d39ff1..c8d94e824 100644 --- a/src/esstream.c +++ b/src/esstream.c @@ -94,10 +94,6 @@ static void elementary_stream_init(elementary_stream_t *es) { es->es_cc = -1; - - if (es->es_type == SCT_HBBTV && es->es_psi.mt_name == NULL) - dvb_table_parse_init(&es->es_psi, "hbbtv", LS_TS, es->es_pid, - DVB_HBBTV_BASE, DVB_HBBTV_MASK, es); } /** @@ -107,9 +103,6 @@ static void elementary_stream_clean(elementary_stream_t *es) { tvhlog_limit_reset(&es->es_cc_log); - - if (es->es_psi.mt_name) - dvb_table_reset(&es->es_psi); } /** @@ -155,9 +148,6 @@ elementary_set_stream_destroy(elementary_set_t *set, elementary_stream_t *es) elementary_stream_t *es1; caid_t *c; - if (es->es_psi.mt_name) - dvb_table_parse_done(&es->es_psi); - if (set->set_last_es == es) { set->set_last_pid = -1; set->set_last_es = NULL; diff --git a/src/esstream.h b/src/esstream.h index ec1b49f42..cb9c70fa3 100644 --- a/src/esstream.h +++ b/src/esstream.h @@ -134,8 +134,6 @@ struct elementary_stream { tvhlog_limit_t es_cc_log; /* CC error log limiter */ uint32_t es_filter; /* Filter temporary variable */ - - mpegts_psi_table_t es_psi; /* HBBTV PSI table (AIT) */ }; /* diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 3481aab69..42cdd4681 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -166,30 +166,31 @@ typedef struct mpegts_pid_sub #define MPS_TABLES 0x40 #define MPS_NOPOSTDEMUX 0x80 int mps_type; -#define MPS_WEIGHT_PAT 1000 -#define MPS_WEIGHT_CAT 999 -#define MPS_WEIGHT_SDT 999 -#define MPS_WEIGHT_NIT 999 -#define MPS_WEIGHT_BAT 999 -#define MPS_WEIGHT_VCT 999 -#define MPS_WEIGHT_EIT 999 -#define MPS_WEIGHT_ETT 999 -#define MPS_WEIGHT_MGT 999 -#define MPS_WEIGHT_PMT 998 -#define MPS_WEIGHT_PCR 997 -#define MPS_WEIGHT_CA 996 -#define MPS_WEIGHT_VIDEO 900 -#define MPS_WEIGHT_AUDIO 800 -#define MPS_WEIGHT_SUBTITLE 700 -#define MPS_WEIGHT_ESOTHER 500 -#define MPS_WEIGHT_RAW 400 -#define MPS_WEIGHT_NIT2 300 -#define MPS_WEIGHT_SDT2 300 -#define MPS_WEIGHT_ALLLIMIT 200 /* values under this limit does not switch */ - /* input to the unfiltered PIDs (all) mode */ -#define MPS_WEIGHT_TDT 101 -#define MPS_WEIGHT_STT 101 -#define MPS_WEIGHT_PMT_SCAN 100 +#define MPS_WEIGHT_PAT 1000 +#define MPS_WEIGHT_CAT 999 +#define MPS_WEIGHT_SDT 999 +#define MPS_WEIGHT_NIT 999 +#define MPS_WEIGHT_BAT 999 +#define MPS_WEIGHT_VCT 999 +#define MPS_WEIGHT_EIT 999 +#define MPS_WEIGHT_ETT 999 +#define MPS_WEIGHT_MGT 999 +#define MPS_WEIGHT_PMT 998 +#define MPS_WEIGHT_PCR 997 +#define MPS_WEIGHT_CA 996 +#define MPS_WEIGHT_VIDEO 900 +#define MPS_WEIGHT_AUDIO 800 +#define MPS_WEIGHT_SUBTITLE 700 +#define MPS_WEIGHT_ESOTHER 500 +#define MPS_WEIGHT_RAW 400 +#define MPS_WEIGHT_NIT2 300 +#define MPS_WEIGHT_SDT2 300 +#define MPS_WEIGHT_ALLLIMIT 200 /* values under this limit does not switch */ + /* input to the unfiltered PIDs (all) mode */ +#define MPS_WEIGHT_TDT 102 +#define MPS_WEIGHT_STT 102 +#define MPS_WEIGHT_PMT_SCAN 101 +#define MPS_WEIGHT_HBBTV_SCAN 100 int mps_weight; void *mps_owner; } mpegts_pid_sub_t; diff --git a/src/input/mpegts/dvb_psi_hbbtv.c b/src/input/mpegts/dvb_psi_hbbtv.c index 41df6645a..89c06d00f 100644 --- a/src/input/mpegts/dvb_psi_hbbtv.c +++ b/src/input/mpegts/dvb_psi_hbbtv.c @@ -18,14 +18,15 @@ #include "tvheadend.h" #include "service.h" +#include "input.h" #include "dvb_psi_hbbtv.h" /** * Extract Hbbtv */ htsmsg_t * -ts_recv_hbbtv(mpegts_psi_table_t *mt, elementary_stream_t *st, - const uint8_t *buf, int len, int *_sect) +dvb_psi_parse_hbbtv + (mpegts_psi_table_t *mt, const uint8_t *buf, int len, int *_sect) { static const char *visibility_table[4] = { "none", @@ -165,12 +166,12 @@ dvberr: } void -ts_recv_hbbtv_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len) +dvb_psi_hbbtv_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len) { elementary_stream_t *st = (elementary_stream_t *)mt->mt_opaque; service_t *t = st->es_service; int sect; - htsmsg_t *apps = ts_recv_hbbtv(mt, st, buf, len, §); + htsmsg_t *apps = dvb_psi_parse_hbbtv(mt, buf, len, §); if (apps == NULL) return; if (t->s_hbbtv == NULL) @@ -182,3 +183,10 @@ ts_recv_hbbtv_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len) service_request_save(t); } } + +int +dvb_hbbtv_callback(mpegts_table_t *mt, const uint8_t *buf, int len, int tableid) +{ + dvb_psi_hbbtv_cb((mpegts_psi_table_t *)mt, buf, len); + return 0; +} diff --git a/src/input/mpegts/dvb_psi_pmt.c b/src/input/mpegts/dvb_psi_pmt.c index 4800a18de..6a55ea86b 100644 --- a/src/input/mpegts/dvb_psi_pmt.c +++ b/src/input/mpegts/dvb_psi_pmt.c @@ -23,6 +23,7 @@ #include "descrambler/caid.h" #include "descrambler/dvbcam.h" #include "dvb_psi_pmt.h" +#include "dvb_psi_hbbtv.h" /* * PMT processing @@ -552,12 +553,14 @@ int dvb_pmt_callback (mpegts_table_t *mt, const uint8_t *ptr, int len, int tableid) { - int r, sect, last, ver, restart; + int r, sect, last, ver, restart, hbbtv = 0; uint32_t update; uint16_t sid; mpegts_mux_t *mm = mt->mt_mux; mpegts_service_t *s; + elementary_stream_t *es; mpegts_psi_table_state_t *st = NULL; + uint16_t hbbtv_pids[16]; /* Start */ if (len < 2) return -1; @@ -582,6 +585,10 @@ dvb_pmt_callback if (update) { if (s->s_status == SERVICE_RUNNING) elementary_set_filter_build(&s->s_components); + TAILQ_FOREACH(es, &s->s_components.set_filter, es_filter_link) { + if (hbbtv >= ARRAY_SIZE(hbbtv_pids)) break; + hbbtv_pids[hbbtv++] = es->es_pid; + } service_request_save((service_t*)s); } /* Only restart if something that our clients worry about did change */ @@ -606,6 +613,11 @@ dvb_pmt_callback if (update & (PMT_UPDATE_NEW_CA_STREAM|PMT_UPDATE_NEW_CAID| PMT_UPDATE_CAID_DELETED|PMT_UPDATE_CAID_PID)) descrambler_caid_changed((service_t *)s); + for (r = 0; r < hbbtv; r++) + mpegts_table_add(mm, DVB_HBBTV_BASE, DVB_HBBTV_MASK, + dvb_hbbtv_callback, NULL, "hbbtv", LS_TBL_BASE, + MT_CRC | MT_FULL | MT_QUICKREQ | MT_ONESHOT | MT_SCANSUBS, + hbbtv_pids[r], MPS_WEIGHT_HBBTV_SCAN); #if ENABLE_LINUXDVB_CA dvbcam_pmt_data(s, ptr, len); diff --git a/src/input/mpegts/tsdemux.c b/src/input/mpegts/tsdemux.c index 894a7d1f9..38d26d04a 100644 --- a/src/input/mpegts/tsdemux.c +++ b/src/input/mpegts/tsdemux.c @@ -68,11 +68,6 @@ ts_recv_packet0 if (tsb2[3] & 0xc0) /* scrambled */ continue; - - if (st->es_type == SCT_HBBTV) { - dvb_table_parse(&st->es_psi, "ts", tsb2, 188, 1, 0, ts_recv_hbbtv_cb); - continue; - } } if (!t->s_scrambled_pass && (st->es_type == SCT_CA || st->es_type == SCT_CAT)) diff --git a/src/parsers/message.c b/src/parsers/message.c index e5b9febcb..06586c396 100644 --- a/src/parsers/message.c +++ b/src/parsers/message.c @@ -161,7 +161,7 @@ ts_recv_hbbtv1_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len) { parser_es_t *pes = (parser_es_t *)mt->mt_opaque; parser_t *prs = pes->es_parser; - htsmsg_t *apps = ts_recv_hbbtv(mt, (elementary_stream_t *)pes, buf, len, NULL); + htsmsg_t *apps = dvb_psi_parse_hbbtv(mt, buf, len, NULL); if (apps) { void *bin; @@ -374,9 +374,14 @@ parser_destroy(streaming_target_t *pad) { parser_t *prs = (parser_t *)pad; elementary_stream_t *es; + parser_es_t *pes; - TAILQ_FOREACH(es, &prs->prs_components.set_all, es_link) - parser_clean_es((parser_es_t *)es); + TAILQ_FOREACH(es, &prs->prs_components.set_all, es_link) { + pes = (parser_es_t *)es; + parser_clean_es(pes); + if (pes->es_psi.mt_name) + dvb_table_parse_done(&pes->es_psi); + } elementary_set_clean(&prs->prs_components); free(prs); } diff --git a/src/parsers/parsers.h b/src/parsers/parsers.h index fb5760df3..0f7ac9870 100644 --- a/src/parsers/parsers.h +++ b/src/parsers/parsers.h @@ -57,6 +57,7 @@ struct parser_es { struct th_pkt *es_curpkt; struct streaming_message_queue es_backlog; tvhlog_limit_t es_pes_log; + mpegts_psi_table_t es_psi; /* Clocks */ int64_t es_curpts; int64_t es_curdts;