]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
SAT>IP client: add experimental network limiter for satip-axe
authorJaroslav Kysela <perex@perex.cz>
Wed, 16 Mar 2016 18:18:24 +0000 (19:18 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 16 Mar 2016 18:18:24 +0000 (19:18 +0100)
src/input/mpegts/satip/satip.c
src/input/mpegts/satip/satip_frontend.c
src/input/mpegts/satip/satip_private.h
src/input/mpegts/satip/satip_satconf.c

index f1fa49559a9099ae3f8b1f6ed3fe50adabdf7cd8..f67ac92522a3c72fb84b4bf62ec6894f3cd456bd 100644 (file)
@@ -328,7 +328,7 @@ const idclass_t satip_device_class =
       .id       = "skip_ts",
       .name     = N_("Skip TS packets (0-200)"),
       .desc     = N_("Skip x number of transport packets."),
-      .opts     = PO_ADVANCED,
+      .opts     = PO_EXPERT,
       .off      = offsetof(satip_device_t, sd_skip_ts),
     },
     {
index 822faa85be5db2d443d177c18351f6005729a5b6..159d50047221118a1f5e20652bd0fab963ac7da1 100644 (file)
@@ -466,7 +466,7 @@ satip_frontend_match_satcfg ( satip_frontend_t *lfe2, mpegts_mux_t *mm2 )
     lfe_master = satip_frontend_find_by_number(lfe2->sf_device, lfe2->sf_master) ?: lfe2;
 
   mm1 = lfe2->sf_req->sf_mmi->mmi_mux;
-  position = satip_satconf_get_position(lfe2, mm2);
+  position = satip_satconf_get_position(lfe2, mm2, 0);
   if (position <= 0 || lfe_master->sf_position != position)
     return 0;
   mc1 = &((dvb_mux_t *)mm1)->lm_tuning;
@@ -495,7 +495,7 @@ satip_frontend_is_enabled ( mpegts_input_t *mi, mpegts_mux_t *mm, int flags )
   if (lfe->sf_device->sd_dbus_allow <= 0) return 0;
   if (lfe->sf_type != DVB_TYPE_S) return 1;
   /* check if the position is enabled */
-  position = satip_satconf_get_position(lfe, mm);
+  position = satip_satconf_get_position(lfe, mm, 1);
   if (position <= 0)
     return 0;
   /* check if any "blocking" tuner is running */
@@ -555,7 +555,7 @@ satip_frontend_start_mux
   char buf1[256], buf2[256];
 
   if (lfe->sf_positions > 0) {
-    lfe->sf_position = satip_satconf_get_position(lfe, mmi->mmi_mux);
+    lfe->sf_position = satip_satconf_get_position(lfe, mmi->mmi_mux, 1);
     if (lfe->sf_position <= 0)
       return SM_CODE_TUNING_FAILED;
   }
index 99c36ade122f978c660d4dc69e9d1ace8a722cff..0db9a4a0fe9d69d00aee3094372328a34cd57be8 100644 (file)
@@ -182,6 +182,7 @@ struct satip_satconf
   int                        sfc_priority;
   int                        sfc_grace;
   char                      *sfc_name;
+  int                        sfc_network_limit;
 
   /*
    * Assigned networks to this SAT configuration
@@ -234,7 +235,7 @@ int satip_satconf_get_grace
   ( satip_frontend_t *lfe, mpegts_mux_t *mm );
 
 int satip_satconf_get_position
-  ( satip_frontend_t *lfe, mpegts_mux_t *mm );
+  ( satip_frontend_t *lfe, mpegts_mux_t *mm, int check );
 
 /*
  * RTSP part
index 8ec90440a304862bff082ac815d7c8b3333647de..fc046c3c5e60f8c504752f598cd4385c8cbfeb62 100644 (file)
@@ -65,13 +65,36 @@ satip_satconf_get_grace
   return sfc ? sfc->sfc_grace : 0;
 }
 
+static int
+satip_satconf_check_network_limit
+  ( satip_frontend_t *lfe, satip_satconf_t *sfc, idnode_t *mn )
+{
+  satip_frontend_t *lfe2;
+  satip_satconf_t *sfc2;
+  int count;
+
+  count = 0;
+  TAILQ_FOREACH(lfe2, &lfe->sf_device->sd_frontends, sf_link)
+    TAILQ_FOREACH(sfc2, &lfe2->sf_satconf, sfc_link)
+      if (idnode_set_exists(sfc->sfc_networks, mn))
+        count++;
+
+  return count <= sfc->sfc_network_limit;
+}
+
 int
 satip_satconf_get_position
-  ( satip_frontend_t *lfe, mpegts_mux_t *mm )
+  ( satip_frontend_t *lfe, mpegts_mux_t *mm, int check )
 {
   satip_satconf_t *sfc;
   sfc = satip_satconf_find_ele(lfe, mm);
-  return sfc && sfc->sfc_enabled ? sfc->sfc_position : 0;
+  if (sfc && sfc->sfc_enabled) {
+    if (!check || sfc->sfc_network_limit <= 0)
+      return sfc->sfc_position;
+    if (satip_satconf_check_network_limit(lfe, sfc, &mm->mm_network->mn_id))
+      return sfc->sfc_position;
+  }
+  return 0;
 }
 
 /* **************************************************************************
@@ -224,6 +247,17 @@ const idclass_t satip_satconf_class =
       .def.i    = 1,
       .opts     = PO_RDONLY | PO_ADVANCED,
     },
+    {
+      .type     = PT_INT,
+      .id       = "network_limit",
+      .name     = N_("Network limit per position"),
+      .desc     = N_("A comma separated list with tuner limits per network "
+                     "position (src=) for satellite SAT>IP tuners. "
+                     "The first limit number is for src=1 (AA), second "
+                     "for src=2 (AB) etc."),
+      .opts     = PO_EXPERT,
+      .off      = offsetof(satip_satconf_t, sfc_network_limit),
+    },
     {
       .type     = PT_STR,
       .id       = "networks",