]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
SAT>IP Client: allow to specify the tuner config manually, fixes #2851
authorJaroslav Kysela <perex@perex.cz>
Mon, 18 May 2015 18:55:29 +0000 (20:55 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 19 May 2015 07:38:43 +0000 (09:38 +0200)
- the tuner configuration string in the XML is optional per spec
- remove "Override tuner count" which duplicates the functionality

src/input/mpegts/satip/satip.c
src/input/mpegts/satip/satip_private.h

index dd3d2a627b17adb85b9a2407e4c6008ce9078175..3fa7a3cf5aa4c5820880cea675b97157d512e1c2 100644 (file)
@@ -145,6 +145,49 @@ satip_device_class_get_title( idnode_t *in )
   return buf;
 }
 
+static const char *satip_tunercfg_tab[] = {
+  "DVBS2-1",
+  "DVBS2-2",
+  "DVBS2-4",
+  "DVBS2-8",
+  "DVBC-1",
+  "DVBC-2",
+  "DVBC-4",
+  "DVBC-8",
+  "DVBT-1",
+  "DVBT-2",
+  "DVBT-4",
+  "DVBT-8",
+  "DVBS2-1,DVBT-1",
+  "DVBS2-2,DVBT-2",
+  "DVBT-1,DVBS2-1",
+  "DVBT-2,DVBS2-2",
+  "DVBS2-1,DVB-C1",
+  "DVBS2-2,DVB-C2",
+  "DVBC-1,DVBS2-1",
+  "DVBC-2,DVBS2-2",
+  NULL
+};
+
+static htsmsg_t *
+satip_device_class_tunercfg_list ( void *o )
+{
+  htsmsg_t *l = htsmsg_create_list();
+  const char **p;
+  htsmsg_add_str(l, NULL, "Auto");
+  for (p = satip_tunercfg_tab; *p; p++)
+    htsmsg_add_str(l, NULL, *p);
+  return l;
+}
+
+static void
+satip_device_class_tunercfg_notify ( void *o )
+{
+  satip_device_t *sd = (satip_device_t *)o;
+  if (!sd->sd_inload)
+    satip_device_destroy_later(sd, 100);
+}
+
 const idclass_t satip_device_class =
 {
   .ic_class      = "satip_client",
@@ -153,6 +196,16 @@ const idclass_t satip_device_class =
   .ic_get_childs = satip_device_class_get_childs,
   .ic_get_title  = satip_device_class_get_title,
   .ic_properties = (const property_t[]){
+    {
+      .type     = PT_STR,
+      .id       = "tunercfgu",
+      .name     = "Tuner Configuration",
+      .opts     = PO_SORTKEY,
+      .off      = offsetof(satip_device_t, sd_tunercfg),
+      .list     = satip_device_class_tunercfg_list,
+      .notify   = satip_device_class_tunercfg_notify,
+      .def.s    = "Auto"
+    },
     {
       .type     = PT_BOOL,
       .id       = "fullmux_ok",
@@ -209,13 +262,6 @@ const idclass_t satip_device_class =
       .opts     = PO_ADVANCED,
       .off      = offsetof(satip_device_t, sd_pids21),
     },
-    {
-      .type     = PT_INT,
-      .id       = "tunercfgoverride",
-      .name     = "Override tuner count",
-      .opts     = PO_ADVANCED,
-      .off      = offsetof(satip_device_t, sd_tunercfg_override),
-    },
     {
       .type     = PT_STR,
       .id       = "bindaddr",
@@ -422,11 +468,13 @@ satip_device_create( satip_device_info_t *info )
   satip_device_t *sd = calloc(1, sizeof(satip_device_t));
   tvh_uuid_t uuid;
   htsmsg_t *conf = NULL, *feconf = NULL;
-  char *argv[10];
+  char *argv[10], *tunercfg;
   int i, j, n, m, fenum, v2, save = 0;
   dvb_fe_type_t type;
   char buf2[60];
 
+  sd->sd_inload = 1;
+
   satip_device_calc_uuid(&uuid, info->uuid);
 
   conf = hts_settings_load("input/satip/adapters/%s", uuid.hex);
@@ -439,6 +487,7 @@ satip_device_create( satip_device_info_t *info )
   sd->sd_sig_scale   = 240;
   sd->sd_dbus_allow  = 1;
 
+
   if (!tvh_hardware_create0((tvh_hardware_t*)sd, &satip_device_class,
                             uuid.hex, conf)) {
     /* Note: sd is freed in above fcn */
@@ -484,7 +533,13 @@ satip_device_create( satip_device_info_t *info )
     feconf = htsmsg_get_map(conf, "frontends");
   save = !conf || !feconf;
 
-  n = http_tokenize(sd->sd_info.tunercfg, argv, 10, ',');
+  tunercfg = sd->sd_tunercfg;
+  if (tunercfg == NULL)
+    tunercfg = sd->sd_tunercfg = strdup("Auto");
+  if (strncmp(tunercfg, "DVB", 3) && strncmp(tunercfg, "ATSC", 4))
+    tunercfg = sd->sd_info.tunercfg;
+
+  n = http_tokenize(tvh_strdupa(tunercfg), argv, 10, ',');
   for (i = m = 0, fenum = 1; i < n; i++) {
     type = DVB_TYPE_NONE;
     v2 = 0;
@@ -516,8 +571,6 @@ satip_device_create( satip_device_info_t *info )
       m = atoi(argv[i] + 6);
       v2 = 2;
     }
-    if (sd->sd_tunercfg_override > 0 && sd->sd_tunercfg_override < 33)
-             m = sd->sd_tunercfg_override;
     if (type == DVB_TYPE_NONE) {
       tvhlog(LOG_ERR, "satip", "%s: bad tuner type [%s]",
              satip_device_nicename(sd, buf2, sizeof(buf2)), argv[i]);
@@ -536,6 +589,8 @@ satip_device_create( satip_device_info_t *info )
   if (save)
     satip_device_save(sd);
 
+  sd->sd_inload = 0;
+
   htsmsg_destroy(conf);
 
   satip_device_dbus_notify(sd, "start");
@@ -627,6 +682,7 @@ satip_device_destroy( satip_device_t *sd )
   FREEM(tunercfg);
 #undef FREEM
   free(sd->sd_bindaddr);
+  free(sd->sd_tunercfg);
 
   tvh_hardware_delete((tvh_hardware_t*)sd);
   free(sd);
@@ -798,7 +854,7 @@ satip_discovery_http_closed(http_client_t *hc, int errn)
   if ((udn          = htsmsg_xml_get_cdata_str(device, "UDN")) == NULL)
     goto finish;
   if ((tunercfg     = htsmsg_xml_get_cdata_str(device, "urn:ses-com:satipX_SATIPCAP")) == NULL)
-    goto finish;
+    tunercfg = "";
 
   uuid = NULL;
   n = http_tokenize((char *)udn, argv, ARRAY_SIZE(argv), ':');
index 616d84b8d4f10e1ac15495a7c3475249a8453547..ce905a5b3d418a4c50a2bc2ed80ebe8c64ea4b2e 100644 (file)
@@ -62,6 +62,7 @@ struct satip_device
   tvh_hardware_t;
 
   gtimer_t                   sd_destroy_timer;
+  int                        sd_inload;
   int                        sd_nosave;
 
   /*
@@ -84,7 +85,7 @@ struct satip_device
   int                        sd_pids_deladd;
   int                        sd_sig_scale;
   int                        sd_pids0;
-  int                        sd_tunercfg_override;
+  char                      *sd_tunercfg;
   int                        sd_pids21;
   int                        sd_pilot_on;
   int                        sd_no_univ_lnb;