]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
opentv: add bouquet filter to avoid heavy LCN switches
authorJaroslav Kysela <perex@perex.cz>
Fri, 23 Jan 2015 17:15:02 +0000 (18:15 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 23 Jan 2015 17:15:02 +0000 (18:15 +0100)
data/conf/epggrab/opentv/prov/ausat
data/conf/epggrab/opentv/prov/skyit
data/conf/epggrab/opentv/prov/skyuk
src/epggrab/module/opentv.c
src/input/mpegts.h
src/input/mpegts/dvb_psi.c

index fb6607f350c7affecccab640775083789af3bf6f..44d0da729c185f746621f744373c546cf39aea01 100644 (file)
@@ -5,6 +5,7 @@
   "nid": 4096,
   "tsid": 17,
   "sid": 17008,
+  "bouquetid": 0,
   "channel" : [
     17
   ],
index 1a2eefbe4800c30e37041b3081d90d3d55c7430e..db5aec0a4f917e38776d9f52304631fd85b761b3 100644 (file)
@@ -5,6 +5,7 @@
   "nid": 64511,
   "tsid": 5800,
   "sid": 3635,
+  "bouquetid": 0,
   "channel" : [
     17
   ],
index f58707777e051e47709f992583dbe7ff033de49a..bb25ef82095767e71810ea7b1c2709740da0f3f8 100644 (file)
@@ -5,6 +5,7 @@
   "nid": 2,
   "tsid": 2004,
   "sid": 4152,
+  "bouquetid": 4101,
   "channel" : [
     17
   ],
index b17949cb58deade21aac210da60c22b24ed9a01a..fceadf027f051e92ff2452e941171b70d818298e 100644 (file)
@@ -76,6 +76,8 @@ typedef struct opentv_module_t
   int                   onid;
   int                   tsid;
   int                   sid;
+  int                   bouquetid;
+  int                   bouquet_auto;
   int                   *channel;
   int                   *title;
   int                   *summary;
@@ -435,7 +437,7 @@ done:
 
 static int
 opentv_desc_channels
-  ( mpegts_table_t *mt, mpegts_mux_t *mm,
+  ( mpegts_table_t *mt, mpegts_mux_t *mm, uint16_t nbid,
     const uint8_t dtag, const uint8_t *buf, int len )
 {
   opentv_status_t *sta = mt->mt_opaque;
@@ -444,21 +446,39 @@ opentv_desc_channels
   epggrab_channel_link_t *ecl;
   mpegts_service_t *svc;
   channel_t *ch;
-  int sid, cid, cnum;
+  int sid, type, cid, cnum, unk;
   int save = 0;
   int i = 2;
+
+  if (mod->bouquetid != nbid) {
+    if (mod->bouquet_auto) {
+      if (nbid < mod->bouquetid) {
+        tvhwarn(mt->mt_name, "bouquet id set to %d, report this!", nbid);
+        mod->bouquetid = nbid;
+      } else
+        return 0;
+    } else {
+      return 0;
+    }
+  }
+
   while (i < len) {
     sid  = ((int)buf[i] << 8) | buf[i+1];
+    type = buf[2];
     cid  = ((int)buf[i+3] << 8) | buf[i+4];
     cnum = ((int)buf[i+5] << 8) | buf[i+6];
-    tvhtrace(mt->mt_name, "     sid %04X cid %04X cnum %d", sid, cid, cnum);
+    unk  = ((int)buf[i+7] << 8) | buf[i+8];
+    tvhtrace(mt->mt_name, "     sid %04X type %02X cid %04X cnum %d unk %04X", sid, type, cid, cnum, unk);
     cnum = cnum < 65535 ? cnum : 0;
 
     /* Find the service */
     svc = mpegts_service_find(mm, sid, 0, 0, NULL);
     tvhtrace(mt->mt_name, "     svc %p [%s]", svc, svc ? svc->s_nicename : NULL);
-    if (svc && svc->s_dvb_opentv_chnum != cnum) {
+    if (svc && svc->s_dvb_opentv_chnum != cnum &&
+        (!svc->s_dvb_opentv_id || svc->s_dvb_opentv_id == unk)) {
+      tvhtrace(mt->mt_name, "      cnum changed (%i != %i)", cnum, (int)svc->s_dvb_opentv_chnum);
       svc->s_dvb_opentv_chnum = cnum;
+      svc->s_dvb_opentv_id = unk;
       service_request_save((service_t *)svc, 0);
     }
     if (svc && LIST_FIRST(&svc->s_channels)) {
@@ -815,7 +835,7 @@ static int _opentv_prov_load_one ( const char *id, htsmsg_t *m )
 {
   char ibuf[100], nbuf[1000];
   htsmsg_t *cl, *tl, *sl;
-  uint32_t tsid, sid, onid;
+  uint32_t tsid, sid, onid, bouquetid;
   const char *str, *name;
   opentv_dict_t *dict;
   opentv_genre_t *genre;
@@ -837,6 +857,7 @@ static int _opentv_prov_load_one ( const char *id, htsmsg_t *m )
     if (htsmsg_get_u32(m, "nid", &onid)) return -1;
   if (htsmsg_get_u32(m, "tsid", &tsid)) return -1;
   if (htsmsg_get_u32(m, "sid", &sid)) return -1;
+  if (htsmsg_get_u32(m, "bouquetid", &bouquetid)) return -1;
 
   /* Genre map (optional) */
   str = htsmsg_get_str(m, "genre");
@@ -861,6 +882,8 @@ static int _opentv_prov_load_one ( const char *id, htsmsg_t *m )
   mod->onid     = onid;
   mod->tsid     = tsid;
   mod->sid      = sid;
+  mod->bouquetid = bouquetid;
+  mod->bouquet_auto = bouquetid == 0;
   mod->channel  = _pid_list_to_array(cl);
   mod->title    = _pid_list_to_array(tl);
   mod->summary  = _pid_list_to_array(sl);
index 3c8a4916b73aff6aeab55ee05ef6a76c06b02ef4..707d9e146b66081db4f08128443802eacd725feb 100644 (file)
@@ -94,7 +94,7 @@ typedef void (*mpegts_psi_section_callback_t)
 struct mpegts_table_mux_cb
 {
   int tag;
-  int (*cb) ( mpegts_table_t*, mpegts_mux_t *mm,
+  int (*cb) ( mpegts_table_t*, mpegts_mux_t *mm, uint16_t nbid,
               const uint8_t dtag, const uint8_t *dptr, int dlen );
 };
 
@@ -473,6 +473,7 @@ struct mpegts_service
 
   int      s_dvb_eit_enable;
   uint64_t s_dvb_opentv_chnum;
+  uint16_t s_dvb_opentv_id;
 
   /*
    * Link to carrying multiplex and active adapter
index 8c7678d1188e4bfe6700eb67fc1bb00e5e95a236..4b554fdced5d3d5259ab75ba726c9ac875048977 100644 (file)
@@ -1321,7 +1321,7 @@ dvb_nit_mux
         i++;
         }
       if (mt->mt_mux_cb[i].cb) {
-        if (mt->mt_mux_cb[i].cb(mt, mux, dtag, dptr, dlen))
+        if (mt->mt_mux_cb[i].cb(mt, mux, bi ? bi->nbid : 0, dtag, dptr, dlen))
           return -1;
         dtag = 0;
       }