udp: add tx buffer size setup for udp_bind(_double)
This commit is contained in:
parent
56ac461d06
commit
83f94f6f0c
5 changed files with 22 additions and 13 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
22
src/udp.c
22
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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue