]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
udp: add tx buffer size setup for udp_bind(_double)
authorJaroslav Kysela <perex@perex.cz>
Tue, 24 Feb 2015 14:10:53 +0000 (15:10 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 11 Mar 2015 20:41:12 +0000 (21:41 +0100)
src/input/mpegts/iptv/iptv_udp.c
src/input/mpegts/satip/satip_frontend.c
src/udp.c
src/udp.h
src/upnp.c

index feaa1e1168813b1e73284a1f85e7ddf8b615d233..3989cc1d032c5a322b492452f4917c5354207001 100644 (file)
@@ -41,7 +41,7 @@ iptv_udp_start ( iptv_mux_t *im, const char *raw, const url_t *url )
   mpegts_mux_nice_name((mpegts_mux_t*)im, name, sizeof(name));
 
   conn = udp_bind("iptv", name, url->host, url->port,
-                  im->mm_iptv_interface, IPTV_BUF_SIZE);
+                  im->mm_iptv_interface, IPTV_BUF_SIZE, 4*1024);
   if (conn == UDP_FATAL_ERROR)
     return SM_CODE_TUNING_FAILED;
   if (conn == NULL)
index 64fd9f54c1e79febb6d8065da40b9a1b8b0ec356..f36f0d42429c8fd1e235864f355d5a34f621f1c2 100644 (file)
@@ -1271,7 +1271,7 @@ new_tune:
   if (udp_bind_double(&rtp, &rtcp,
                       "satip", "rtp", "rtpc",
                       satip_frontend_bindaddr(lfe), lfe->sf_udp_rtp_port,
-                      NULL, SATIP_BUF_SIZE, 16384) < 0) {
+                      NULL, SATIP_BUF_SIZE, 16384, 4*1024, 4*1024) < 0) {
     satip_frontend_tuning_error(lfe, tr);
     goto done;
   }
index 0732f7c16fc82b394c1469e62b8d1561e6dc1915..58f41b54022fc5321120b74f4bec812a5e1c651a 100644 (file)
--- a/src/udp.c
+++ b/src/udp.c
@@ -151,7 +151,7 @@ udp_get_solip( void )
 udp_connection_t *
 udp_bind ( const char *subsystem, const char *name,
            const char *bindaddr, int port,
-           const char *ifname, int rxsize )
+           const char *ifname, int rxsize, int txsize )
 {
   int fd, ifindex, reuse = 1;
   udp_connection_t *uc;
@@ -271,9 +271,16 @@ udp_bind ( const char *subsystem, const char *name,
     goto error;
   }
     
-  /* Increase RX buffer size */
-  if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rxsize, sizeof(rxsize)) == -1)
-    tvhwarn(subsystem, "%s - cannot increase UDP rx buffer size [%s]",
+  /* Increase/Decrease RX buffer size */
+  if (rxsize > 0 &&
+      setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rxsize, sizeof(rxsize)) == -1)
+    tvhwarn(subsystem, "%s - cannot change UDP rx buffer size [%s]",
+            name, strerror(errno));
+
+  /* Increase/Decrease TX buffer size */
+  if (txsize > 0 &&
+      setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &txsize, sizeof(txsize)) == -1)
+    tvhwarn(subsystem, "%s - cannot change UDP tx buffer size [%s]",
             name, strerror(errno));
 
   uc->fd = fd;
@@ -288,7 +295,8 @@ int
 udp_bind_double ( udp_connection_t **_u1, udp_connection_t **_u2,
                   const char *subsystem, const char *name1,
                   const char *name2, const char *host, int port,
-                  const char *ifname, int rxsize1, int rxsize2 )
+                  const char *ifname, int rxsize1, int rxsize2,
+                  int txsize1, int txsize2 )
 {
   udp_connection_t *u1 = NULL, *u2 = NULL;
   udp_connection_t *ucs[10];
@@ -296,13 +304,13 @@ udp_bind_double ( udp_connection_t **_u1, udp_connection_t **_u2,
 
   memset(&ucs, 0, sizeof(ucs));
   while (1) {
-    u1 = udp_bind(subsystem, name1, host, port, ifname, rxsize1);
+    u1 = udp_bind(subsystem, name1, host, port, ifname, rxsize1, txsize1);
     if (u1 == NULL || u1 == UDP_FATAL_ERROR)
       goto fail;
     port2 = ntohs(IP_PORT(u1->ip));
     /* RTP port should be even, RTCP port should be odd */
     if ((port2 % 2) == 0) {
-      u2 = udp_bind(subsystem, name2, host, port2 + 1, ifname, rxsize2);
+      u2 = udp_bind(subsystem, name2, host, port2 + 1, ifname, rxsize2, txsize2);
       if (u2 != NULL && u2 != UDP_FATAL_ERROR)
         break;
     }
index 20a9d216feea1e5f0f7ada17b39b964d938418d2..995bfa650e3a7e11940e583bd4c446b37989b302 100644 (file)
--- a/src/udp.h
+++ b/src/udp.h
@@ -40,12 +40,13 @@ typedef struct udp_connection {
 udp_connection_t *
 udp_bind ( const char *subsystem, const char *name,
            const char *bindaddr, int port,
-           const char *ifname, int rxsize );
+           const char *ifname, int rxsize, int txsize );
 int
 udp_bind_double ( udp_connection_t **_u1, udp_connection_t **_u2,
                   const char *subsystem, const char *name1,
                   const char *name2, const char *host, int port,
-                  const char *ifname, int rxsize1, int rxsize2 );
+                  const char *ifname, int rxsize1, int rxsize2,
+                  int txsize1, int txsize2 );
 udp_connection_t *
 udp_connect ( const char *subsystem, const char *name,
               const char *host, int port,
index 23485e5a70180b66d923e7cd0a23b4a21b378d22..6d832d3ae1da712bfc346d36e316c2aea63d60f4 100644 (file)
@@ -136,11 +136,11 @@ upnp_thread( void *aux )
 
   multicast = udp_bind("upnp", "upnp_thread_multicast",
                        "239.255.255.250", 1900,
-                       NULL, 32*1024);
+                       NULL, 32*1024, 32*1024);
   if (multicast == NULL || multicast == UDP_FATAL_ERROR)
     goto error;
   unicast = udp_bind("upnp", "upnp_thread_unicast", bindaddr, 0,
-                     NULL, 32*1024);
+                     NULL, 32*1024, 32*1024);
   if (unicast == NULL || unicast == UDP_FATAL_ERROR)
     goto error;