]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
SAT>IP server: Don't enable SAT>IP server by default, fix some locking issues
authorJaroslav Kysela <perex@perex.cz>
Tue, 17 Mar 2015 13:14:34 +0000 (14:14 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 17 Mar 2015 14:51:46 +0000 (15:51 +0100)
src/satip/rtsp.c
src/satip/server.c
src/webui/static/app/config.js

index f57df44dbdd823a2d762a2dd2a9ac18b19c99d2b..87ffa6387ac6ff98d4b6e8d46454cad747fffaee 100644 (file)
@@ -1331,9 +1331,7 @@ void satip_server_rtsp_init(const char *bindaddr, int port, int descramble)
     satip_rtp_init();
   }
   if (rtsp_port != port && rtsp_server) {
-    pthread_mutex_lock(&rtsp_lock);
     rtsp_close_sessions();
-    pthread_mutex_unlock(&rtsp_lock);
     tcp_server_delete(rtsp_server);
     rtsp_server = NULL;
     reg = 1;
index 150c11bcfa398897197f7d669d192c226e074c10..afb8c8c34fd9cb907b2497d027e827063ee1eaaf 100644 (file)
@@ -474,27 +474,59 @@ satips_upnp_discovery_destroy(upnp_service_t *upnp)
 /*
  *
  */
-void satip_server_config_changed(void)
+static void satips_rtsp_port(int def)
 {
-  int rtsp_port, descramble;
+  int rtsp_port = satip_server_rtsp_port;
+  if (!satip_server_rtsp_port_locked)
+    rtsp_port = config_get_int("satip_rtsp", def);
+  if (getuid() != 0 && rtsp_port > 0 && rtsp_port < 1024) {
+    tvherror("satips", "RTSP port %d specified but no root perms, using 9983", rtsp_port);
+    rtsp_port = 9983;
+  }
+  satip_server_rtsp_port = rtsp_port;
 
-  if (!satip_server_rtsp_port_locked) {
-    rtsp_port = config_get_int("satip_rtsp", 0);
-    satip_server_rtsp_port = rtsp_port;
-    if (rtsp_port > 0) {
-      descramble = config_get_int("satip_descramble", 1);
-      satip_server_rtsp_init(http_server_ip, rtsp_port, descramble);
-      tvhinfo("satips", "SAT>IP Server reinitialized (HTTP %s:%d, RTSP %s:%d, descramble %d, DVB-T %d, DVB-S2 %d, DVB-C %d)",
-              http_server_ip, http_server_port, http_server_ip, rtsp_port,
+}
+
+/*
+ *
+ */
+
+static void satip_server_info(const char *prefix, int descramble)
+{
+  tvhinfo("satips", "SAT>IP Server %sinitialized "
+                    "(HTTP %s:%d, RTSP %s:%d, "
+                    "descramble %d, DVB-T %d, DVB-S2 %d, DVB-C %d)",
+              prefix,
+              http_server_ip, http_server_port,
+              http_server_ip, satip_server_rtsp_port,
               descramble,
               config_get_int("satip_dvbt", 0),
               config_get_int("satip_dvbs", 0),
               config_get_int("satip_dvbc", 0));
+}
+
+/*
+ *
+ */
+void satip_server_config_changed(void)
+{
+  int descramble;
+
+  if (!satip_server_rtsp_port_locked) {
+    satips_rtsp_port(0);
+    if (satip_server_rtsp_port > 0) {
+      descramble = config_get_int("satip_descramble", 1);
+      pthread_mutex_unlock(&global_lock);
+      satip_server_rtsp_init(http_server_ip, satip_server_rtsp_port, descramble);
+      satip_server_info("re", descramble);
       satips_upnp_send_announce();
+      pthread_mutex_lock(&global_lock);
     } else {
+      pthread_mutex_unlock(&global_lock);
       tvhinfo("satips", "SAT>IP Server shutdown");
       satip_server_rtsp_done();
       satips_upnp_send_byebye();
+      pthread_mutex_lock(&global_lock);
     }
   }
 }
@@ -522,25 +554,18 @@ void satip_server_init(int rtsp_port)
   http_server_ip = strdup(http_ip);
   http_server_port = ntohs(IP_PORT(http));
 
-  satip_server_rtsp_port_locked = 1;
-  if (rtsp_port == 0) {
-    satip_server_rtsp_port_locked = 0;
-    rtsp_port = config_get_int("satip_rtsp", getuid() == 0 ? 554 : 9983);
-  }
+  satip_server_rtsp_port_locked = rtsp_port > 0;
   satip_server_rtsp_port = rtsp_port;
-  if (rtsp_port <= 0)
+  satips_rtsp_port(rtsp_port);
+
+  if (satip_server_rtsp_port <= 0)
     return;
 
   descramble = config_get_int("satip_descramble", 1);
 
-  satip_server_rtsp_init(http_server_ip, rtsp_port, descramble);
+  satip_server_rtsp_init(http_server_ip, satip_server_rtsp_port, descramble);
 
-  tvhinfo("satips", "SAT>IP Server initialized (HTTP %s:%d, RTSP %s:%d, descramble %d, DVB-T %d, DVB-S2 %d, DVB-C %d)",
-          http_server_ip, http_server_port, http_server_ip, rtsp_port,
-          descramble,
-          config_get_int("satip_dvbt", 0),
-          config_get_int("satip_dvbs", 0),
-          config_get_int("satip_dvbc", 0));
+  satip_server_info("", descramble);
 }
 
 void satip_server_register(void)
index 2189e22a7414749e7089fa74c7a87adccf44c5d3..14d7877958228352d3a0ed11f37f67aa5dab442e 100644 (file)
@@ -224,7 +224,7 @@ tvheadend.miscconf = function(panel, index) {
     if (tvheadend.capabilities.indexOf('satip_server') !== -1) {
         var rtsp = new Ext.form.NumberField({
              name: 'satip_rtsp',
-             fieldLabel: 'RTSP Port (554), 0 = disable'
+             fieldLabel: 'RTSP Port (554 or 9983), 0 = disable'
         });
         var weight = new Ext.form.NumberField({
              name: 'satip_weight',