]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
hbbtv: parse hbbtv outside elementary stream
authorJaroslav Kysela <perex@perex.cz>
Tue, 13 Mar 2018 14:29:10 +0000 (15:29 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 23 Mar 2018 17:05:29 +0000 (18:05 +0100)
src/esstream.c
src/esstream.h
src/input/mpegts.h
src/input/mpegts/dvb_psi_hbbtv.c
src/input/mpegts/dvb_psi_pmt.c
src/input/mpegts/tsdemux.c
src/parsers/message.c
src/parsers/parsers.h

index c13d39ff1d31109d67cbf20b0ba288a10d3b5a49..c8d94e8240d61001e21c1bd36eaad865401a0c5d 100644 (file)
@@ -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;
index ec1b49f4231b7f05be8655be741dab41747dace4..cb9c70fa3b20a80aa528fe1fd8cfedf090125c77 100644 (file)
@@ -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) */
 };
 
 /*
index 3481aab698ba173d9078749a4d6682d89b45669d..42cdd46811cd9bc8bad3de664872e92ca354ab95 100644 (file)
@@ -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;
index 41df6645ab33e169408036dba06d8f3f93a9d5da..89c06d00f97b74a085227bd8bebd9613811e4eb6 100644 (file)
 
 #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, &sect);
+  htsmsg_t *apps = dvb_psi_parse_hbbtv(mt, buf, len, &sect);
   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;
+}
index 4800a18de20faa9b867667f264704f5c6702b11c..6a55ea86bba71b738bbaa960144d8cf25e228734 100644 (file)
@@ -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);
index 894a7d1f9dc88117ad2479492819b87cc36fb4cc..38d26d04a3a1317a3ca688a227a13f90320fba79 100644 (file)
@@ -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))
index e5b9febcb08f2f8ad0e471e2d71e77f60f846622..06586c39634062d1755a5a35ad6f314e47a698a0 100644 (file)
@@ -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);
 }
index fb5760df3bd67ca7a8aacd4adfe44f1c8862e3da..0f7ac987035256c685208089afce180d07b54f02 100644 (file)
@@ -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;