]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
SAT>IP client: add all tuners mode (experimental)
authorJaroslav Kysela <perex@perex.cz>
Thu, 17 Mar 2016 12:39:53 +0000 (13:39 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 17 Mar 2016 16:36:08 +0000 (17:36 +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 f67ac92522a3c72fb84b4bf62ec6894f3cd456bd..6a20a598fde6e37bab25a7997aea9644211726c8 100644 (file)
@@ -331,6 +331,14 @@ const idclass_t satip_device_class =
       .opts     = PO_EXPERT,
       .off      = offsetof(satip_device_t, sd_skip_ts),
     },
+    {
+      .type     = PT_BOOL,
+      .id       = "all_tuners",
+      .name     = N_("All tuners (limited networks)"),
+      .desc     = N_("Try to use all tuners for the limited networks mode."),
+      .opts     = PO_EXPERT,
+      .off      = offsetof(satip_device_t, sd_all_tuners),
+    },
     {
       .type     = PT_BOOL,
       .id       = "disableworkarounds",
index e0d5dd6d23527a7ceb5e9dfad2ae55590a2771be..462145d8d0c08c3f45bc57b5b479cafcd210e10c 100644 (file)
@@ -454,7 +454,7 @@ static int
 satip_frontend_match_satcfg ( satip_frontend_t *lfe2, mpegts_mux_t *mm2 )
 {
   satip_frontend_t *lfe_master;
-  mpegts_mux_t *mm1;
+  mpegts_mux_t *mm1 = NULL;
   dvb_mux_conf_t *mc1, *mc2;
   int position, high1, high2;
 
@@ -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, 0);
+  position = satip_satconf_get_position(lfe2, mm2, NULL, 0);
   if (position <= 0 || lfe_master->sf_position != position)
     return 0;
   mc1 = &((dvb_mux_t *)mm1)->lm_tuning;
@@ -487,18 +487,31 @@ satip_frontend_is_enabled ( mpegts_input_t *mi, mpegts_mux_t *mm, int flags )
 {
   satip_frontend_t *lfe = (satip_frontend_t*)mi;
   satip_frontend_t *lfe2;
-  int position;
+  int position, netlimit;
 
   lock_assert(&global_lock);
 
   if (!mpegts_input_is_enabled(mi, mm, flags)) return 0;
   if (lfe->sf_device->sd_dbus_allow <= 0) return 0;
   if (lfe->sf_type != DVB_TYPE_S) return 1;
+  /* try to reuse any input for limited networks if allowed */
+  if (lfe->sf_device->sd_all_tuners) {
+    position = satip_satconf_get_position(lfe, mm, &netlimit, 0);
+    if (position <= 0) return 0;
+    if (netlimit <= 0) goto cont;
+    /* try to reuse any tuner input as slave */
+    TAILQ_FOREACH(lfe2, &lfe->sf_device->sd_frontends, sf_link) {
+      if (lfe2 == lfe) continue;
+      if (satip_frontend_match_satcfg(lfe2, mm))
+        return 1;
+    }
+  }
   /* check if the position is enabled */
-  position = satip_satconf_get_position(lfe, mm, 1);
+  position = satip_satconf_get_position(lfe, mm, NULL, 1);
   if (position <= 0)
     return 0;
   /* check if any "blocking" tuner is running */
+cont:
   TAILQ_FOREACH(lfe2, &lfe->sf_device->sd_frontends, sf_link) {
     if (lfe2 == lfe) continue;
     if (lfe2->sf_type != DVB_TYPE_S) continue;
@@ -555,7 +568,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, 1);
+    lfe->sf_position = satip_satconf_get_position(lfe, mmi->mmi_mux, NULL, 0);
     if (lfe->sf_position <= 0)
       return SM_CODE_TUNING_FAILED;
   }
index 0db9a4a0fe9d69d00aee3094372328a34cd57be8..59a6d1c62578a1ce278401405b5adcc1441e50e3 100644 (file)
@@ -95,6 +95,7 @@ struct satip_device
   int                        sd_can_weight;
   int                        sd_dbus_allow;
   int                        sd_skip_ts;
+  int                        sd_all_tuners;
   int                        sd_disable_workarounds;
   pthread_mutex_t            sd_tune_mutex;
 };
@@ -235,7 +236,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, int check );
+  ( satip_frontend_t *lfe, mpegts_mux_t *mm, int *netlimit, int check );
 
 /*
  * RTSP part
index fc046c3c5e60f8c504752f598cd4385c8cbfeb62..7fd96c9f617b068b1d761299fa9544b029b2ca17 100644 (file)
@@ -76,7 +76,7 @@ satip_satconf_check_network_limit
   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))
+      if (idnode_set_exists(sfc->sfc_networks, mn) && lfe2->sf_running)
         count++;
 
   return count <= sfc->sfc_network_limit;
@@ -84,15 +84,20 @@ satip_satconf_check_network_limit
 
 int
 satip_satconf_get_position
-  ( satip_frontend_t *lfe, mpegts_mux_t *mm, int check )
+  ( satip_frontend_t *lfe, mpegts_mux_t *mm, int *netlimit, int check )
 {
   satip_satconf_t *sfc;
   sfc = satip_satconf_find_ele(lfe, mm);
   if (sfc && sfc->sfc_enabled) {
+    if (netlimit)
+      *netlimit = sfc->sfc_network_limit;
     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;
+  } else {
+    if (netlimit)
+      *netlimit = 0;
   }
   return 0;
 }