]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
auto create mux
authorGlenn-1990 <g_christiaensen@msn.com>
Tue, 3 Mar 2015 14:20:43 +0000 (15:20 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 9 Mar 2015 15:15:37 +0000 (16:15 +0100)
data/conf/fastscan
src/input/mpegts/dvb_psi.c
src/input/mpegts/fastscan.c
src/input/mpegts/fastscan.h
src/input/mpegts/mpegts_network_scan.c

index 84065f0411baf11759146aaeff0ffc968928ac20..599ce86e24c2f2134b0acfb6284bbe446f78e0f5 100644 (file)
     "name": "Canal Digitaal Astra1",
     "position": 192,
     "frequency": 12515000,
+    "symbolrate" : 22000000,
+    "polarisation" : "H",
+    "delsys" : "dvbs",
     "pid": 900
   },
   {
     "name": "TV Vlaanderen Astra1",
     "position": 192,
     "frequency": 12515000,
+    "symbolrate" : 22000000,
+    "polarisation" : "H",
+    "delsys" : "dvbs",
     "pid": 910
   },
   {
     "name": "TéléSAT Astra1",
     "position": 192,
     "frequency": 12515000,
+    "symbolrate" : 22000000,
+    "polarisation" : "H",
+    "delsys" : "dvbs",
     "pid": 920
   },
   {
     "name": "Mobistar NL Astra1",
     "position": 192,
     "frequency": 12515000,
+    "symbolrate" : 22000000,
+    "polarisation" : "H",
+    "delsys" : "dvbs",
     "pid": 930
   },
   {
     "name": "Mobistar FR Astra1",
     "position": 192,
     "frequency": 12515000,
+    "symbolrate" : 22000000,
+    "polarisation" : "H",
+    "delsys" : "dvbs",
     "pid": 940
   },
   {
     "name": "AustriaSat Astra1",
     "position": 192,
     "frequency": 12515000,
+    "symbolrate" : 22000000,
+    "polarisation" : "H",
+    "delsys" : "dvbs",
     "pid": 950
   },
   {
     "name": "Canal Digitaal Astra3",
     "position": 235,
     "frequency": 12187000,
+    "symbolrate" : 27500000,
+    "polarisation" : "H",
+    "delsys" : "dvbs2",
     "pid": 900
   },
   {
     "name": "TV Vlaanderen Astra3",
     "position": 235,
     "frequency": 12187000,
+    "symbolrate" : 27500000,
+    "polarisation" : "H",
+    "delsys" : "dvbs2",
     "pid": 910
   },
     {
     "name": "TéléSAT Astra3",
     "position": 235,
     "frequency": 12187000,
+    "symbolrate" : 27500000,
+    "polarisation" : "H",
+    "delsys" : "dvbs2",
     "pid": 920
   },
   {
     "name": "Mobistar NL Astra3",
     "position": 235,
     "frequency": 12187000,
+    "symbolrate" : 27500000,
+    "polarisation" : "H",
+    "delsys" : "dvbs2",
     "pid": 930
   },
   {
     "name": "Mobistar FR Astra3",
     "position": 235,
     "frequency": 12187000,
+    "symbolrate" : 27500000,
+    "polarisation" : "H",
+    "delsys" : "dvbs2",
     "pid": 940
   },
   {
     "name": "AustriaSat Astra3",
     "position": 235,
     "frequency": 12187000,
+    "symbolrate" : 27500000,
+    "polarisation" : "H",
+    "delsys" : "dvbs2",
     "pid": 950
   },
   {
     "name": "Skylink: Czech Republic",
     "position": 235,
     "frequency": 12070000,
+    "symbolrate" : 27500000,
+    "polarisation" : "H",
+    "delsys" : "dvbs",
     "pid": 30
   },
   {
     "name": "Skylink: Slovak Republic",
     "position": 235,
     "frequency": 12070000,
+    "symbolrate" : 27500000,
+    "polarisation" : "H",
+    "delsys" : "dvbs",
     "pid": 31
   }
 ]
index f6150c4f4c869da1bfadce9a5b2d0c82aacb200d..e8dabf7d754f25815b06fd7e798cfc542ba54484 100644 (file)
@@ -2623,7 +2623,7 @@ psi_tables_dvb ( mpegts_mux_t *mm )
     dvb_mux_conf_t *mc = &((dvb_mux_t *)mm)->lm_tuning;
     if (mc->dmc_fe_type == DVB_TYPE_S)
       dvb_fastscan_each(mm, mc->u.dmc_fe_qpsk.orbital_pos,
-                        mc->dmc_fe_freq, psi_tables_dvb_fastscan);
+                        mc->dmc_fe_freq, mc->u.dmc_fe_qpsk.polarisation, psi_tables_dvb_fastscan);
   }
 #endif
 }
index 7fd1cac65131e6672aa365064480d83cfb0a4e17..14b3ba64b9e2de3113e6387e227fcd88db31ee1a 100644 (file)
@@ -37,8 +37,11 @@ typedef struct dvb_fastscan {
 
   LIST_HEAD(,dvb_fastscan_item) items;
 
-  int      position;
-  uint32_t frequency;
+  int                       position;
+  dvb_fe_delivery_system_t  delsys;
+  dvb_polarisation_t        polarisation;
+  uint32_t                  frequency;
+  uint32_t                  symbolRate;
 } dvb_fastscan_t;
 
 static RB_HEAD(,dvb_fastscan) fastscan_rb;
@@ -51,13 +54,13 @@ _fs_cmp(const void *a, const void *b)
   if (r == 0) {
     r = ((dvb_fastscan_t *)a)->frequency - ((dvb_fastscan_t *)b)->frequency;
     if (abs(r) < 2000)
-      return 0;
+      return (((dvb_fastscan_t *)a)->polarisation - ((dvb_fastscan_t *)b)->polarisation);
   }
   return r;
 }
 
 void
-dvb_fastscan_each(void *aux, int position, uint32_t frequency,
+dvb_fastscan_each(void *aux, int position, uint32_t frequency, dvb_polarisation_t polarisation,
                   void (*job)(void *aux, bouquet_t *bq,
                               const char *name, int pid))
 {
@@ -69,13 +72,14 @@ dvb_fastscan_each(void *aux, int position, uint32_t frequency,
   SKEL_ALLOC(fastscan_rb_skel);
   fastscan_rb_skel->position = position;
   fastscan_rb_skel->frequency = frequency;
+  fastscan_rb_skel->polarisation = polarisation;
   fs = RB_FIND(&fastscan_rb, fastscan_rb_skel, link, _fs_cmp);
   if (!fs)
     return;
   LIST_FOREACH(fsi, &fs->items, ilink) {
     dvb_sat_position_to_str(fs->position, buf, sizeof(buf));
-    snprintf(url, sizeof(url), "dvb-fastscan://dvbs,%s,%u,%d",
-             buf, fs->frequency, fsi->pid);
+    snprintf(url, sizeof(url), "dvb-fastscan://%s,%s,%u,%s,%u,%d", dvb_delsys2str(fastscan_rb_skel->delsys),
+             buf, fs->frequency, dvb_pol2str(fs->polarisation), fs->symbolRate, fsi->pid);
     bq = bouquet_find_by_source(NULL, url, 0);
     if (bq == NULL || !bq->bq_enabled)
       continue;
@@ -90,7 +94,7 @@ dvb_fastscan_create(htsmsg_t *e)
   dvb_fastscan_t *fs;
   dvb_fastscan_item_t *fsi;
   bouquet_t *bq;
-  const char *name;
+  const char *name, *polarisation, *delsys;
   int pid;
   char url[64], buf[16];
 
@@ -103,10 +107,18 @@ dvb_fastscan_create(htsmsg_t *e)
     goto fail;
   if ((name = htsmsg_get_str(e, "name")) == NULL)
     goto fail;
+  if (htsmsg_get_u32(e, "symbolrate", &fastscan_rb_skel->symbolRate))
+    goto fail;
+  if ((delsys = htsmsg_get_str(e, "delsys")) == NULL)
+    goto fail;
+  if ((polarisation = htsmsg_get_str(e, "polarisation")) == NULL)
+    goto fail;
 
+  fastscan_rb_skel->polarisation = dvb_str2pol(polarisation);
+  fastscan_rb_skel->delsys = dvb_str2delsys(delsys);
   dvb_sat_position_to_str(fastscan_rb_skel->position, buf, sizeof(buf));
-  snprintf(url, sizeof(url), "dvb-fastscan://dvbs,%s,%u,%d",
-           buf, fastscan_rb_skel->frequency, pid);
+  snprintf(url, sizeof(url), "dvb-fastscan://%s,%s,%u,%s,%u,%d", dvb_delsys2str(fastscan_rb_skel->delsys),
+           buf, fastscan_rb_skel->frequency, dvb_pol2str(fastscan_rb_skel->polarisation), fastscan_rb_skel->symbolRate, pid);
   bq = bouquet_find_by_source(name, url, 1);
   if (bq == NULL)
     goto fail;
index 85eb2aa54ba7c7ced9abde941ff9745ccfa8d0d6..ca57742009d91d01be7dbb49b0acbf29bc066517 100644 (file)
@@ -24,7 +24,7 @@
 struct bouquet;
 
 void
-dvb_fastscan_each(void *aux, int position, uint32_t frequency,
+dvb_fastscan_each(void *aux, int position, uint32_t frequency, dvb_polarisation_t polarisation,
                   void (*job)(void *aux, struct bouquet *,
                               const char *name, int pid));
 
index e4d86f63e2d79f8a0603da12678de65846ecb76e..711e350bce26ae85dca81a9e1a9d5bf9b4781109 100644 (file)
@@ -321,24 +321,83 @@ tsid_lookup:
     if (!extra)
       return;
     freq = strtod(extra, NULL) * 1000;
-    goto freq;
+
+    LIST_FOREACH(mn, &mpegts_network_all, mn_global_link)
+      LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link)
+        if (idnode_is_instance(&mm->mm_id, &dvb_mux_dvbs_class) &&
+            abs(((dvb_mux_t *)mm)->lm_tuning.dmc_fe_freq - freq) < 2000 &&
+            ((dvb_mux_t *)mm)->lm_tuning.u.dmc_fe_qpsk.orbital_pos == satpos)
+          mpegts_mux_scan_state_set(mm, MM_SCAN_STATE_PEND);
+    return;
   }
-  if ((l = startswith(src, "dvb-fastscan://dvbs,")) > 0) {
-    uint32_t pid;
+  if ((l = startswith(src, "dvb-fastscan://")) > 0) {
+    uint32_t pid, symbol, dvbs2;
+    char pol[2];
+    pol[1] = '\0';
     src += l;
+
+    if ((l = startswith(src, "DVBS2,")) > 0)
+      dvbs2 = 1;
+    else if ((l = startswith(src, "DVBS,")) > 0)
+      dvbs2 = 0;
+    else
+      return;
+    src += l;
+
     if ((satpos = dvb_sat_position_from_str(src)) == INT_MAX)
       return;
     while (*src && *src != ',')
       src++;
-    if (sscanf(src, ",%u,%u", &freq, &pid) != 2)
+    if (sscanf(src, ",%u,%c,%u,%u", &freq, &pol[0], &symbol, &pid) != 4)
       return;
-freq:
+
+    // search for fastscan mux
     LIST_FOREACH(mn, &mpegts_network_all, mn_global_link)
       LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link)
         if (idnode_is_instance(&mm->mm_id, &dvb_mux_dvbs_class) &&
             abs(((dvb_mux_t *)mm)->lm_tuning.dmc_fe_freq - freq) < 2000 &&
+            ((dvb_mux_t *)mm)->lm_tuning.u.dmc_fe_qpsk.polarisation == dvb_str2pol(pol) &&
             ((dvb_mux_t *)mm)->lm_tuning.u.dmc_fe_qpsk.orbital_pos == satpos)
+        {
+          char buf[256];
+          mpegts_mux_nice_name(mm, buf, sizeof(buf));
+          tvhinfo("mpegts", "fastscan mux found '%s', set scan state 'PENDING'", buf);
           mpegts_mux_scan_state_set(mm, MM_SCAN_STATE_PEND);
+          return;
+        }
+    tvhinfo("mpegts", "fastscan mux not found, position:%i, frequency:%i, polarisation:%c", satpos, freq, pol[0]);
+
+    // fastscan mux not found, try to add it automatically
+    LIST_FOREACH(mn, &mpegts_network_all, mn_global_link)
+      if (mn->mn_satpos != INT_MAX && mn->mn_satpos == satpos)
+      {
+        dvb_mux_conf_t *mux;
+        mpegts_mux_t *mm = NULL;
+
+        mux = malloc(sizeof(dvb_mux_conf_t));
+        dvb_mux_conf_init(mux, dvbs2 ? DVB_SYS_DVBS2 : DVB_SYS_DVBS);
+        mux->dmc_fe_freq = freq;
+        mux->u.dmc_fe_qpsk.symbol_rate = symbol;
+        mux->u.dmc_fe_qpsk.polarisation = dvb_str2pol(pol);
+        mux->u.dmc_fe_qpsk.orbital_pos = satpos;
+        mux->u.dmc_fe_qpsk.fec_inner = DVB_FEC_AUTO;
+        mux->dmc_fe_modulation = DVB_MOD_AUTO;
+        mux->dmc_fe_rolloff = DVB_ROLLOFF_AUTO;
+        mux->dmc_fe_pls_code = 1;
+
+        mm = (mpegts_mux_t*)dvb_mux_create0((dvb_network_t*)mn,
+                                            MPEGTS_ONID_NONE,
+                                            MPEGTS_TSID_NONE,
+                                            mux, NULL, NULL);
+        if (mm)
+        {
+          mm->mm_config_save(mm);
+          char buf[256];
+          mn->mn_display_name(mn, buf, sizeof(buf));
+          tvhinfo("mpegts", "fastscan mux add to network '%s'", buf);
+        }
+        free(mux);
+      }
     return;
   }
 #endif