diff --git a/configure.ac b/configure.ac index 3d09d0958..34b41d70d 100644 --- a/configure.ac +++ b/configure.ac @@ -1161,7 +1161,7 @@ then AC_SUBST(RTDXT_COMPRESS_LIB_TARGET, "lib/ultragrid/vcompress_rtdxt.so.$video_compress_abi_version") AC_SUBST(RTDXT_DECOMPRESS_LIB_TARGET, "lib/ultragrid/vdecompress_rtdxt.so.$video_decompress_abi_version") LIB_TARGETS+=" $RTDXT_COMPRESS_LIB_TARGET $RTDXT_DECOMPRESS_LIB_TARGET" - LIB_OBJS+=" $RTDXT_COMMON_OBJ $RTDXT_COMMON_HEADERS $RTDXT_COMPRESS_OBJ $RTDXT_DECOMPRESS_OBJ" + LIB_OBJS+=" $RTDXT_COMMON_OBJ $RTDXT_COMPRESS_OBJ $RTDXT_DECOMPRESS_OBJ" LIB_HEADERS="$RTDXT_COMMON_HEADERS" fi diff --git a/src/main.c b/src/main.c index 29b655fc1..422d30a23 100644 --- a/src/main.c +++ b/src/main.c @@ -424,10 +424,33 @@ static struct rtp **initialize_network(char *addrs, int recv_port_base, int send RTCP_SDES_TOOL, PACKAGE_STRING, strlen(PACKAGE_STRING)); #ifdef HAVE_MACOSX - rtp_set_recv_buf(devices[index], 5944320); + int size = 5944320; #else - rtp_set_recv_buf(devices[index], 8*1024*1024); + int size = 8*1024*1024; #endif + int ret = rtp_set_recv_buf(devices[index], size); + if(!ret) { + fprintf(stderr, "\n***\n" + "Unable to set buffer size to %d B.\n" + "Please set net.core.rmem_max value to %d or greater. (see also\n" + "https://www.sitola.cz/igrid/index.php/Setup_UltraGrid)\n" +#ifdef HAVE_MACOSX + "\tsysctl -w kern.ipc.maxsockbuf=%d\n" + "\tsysctl -w net.inet.udp.recvspace=%d\n" +#else + "\tsysctl -w net.core.rmem_max=%d\n" +#endif + "To make this persistent, add these options (key=value) to /etc/sysctl.conf\n" + "\n***\n\n", + size, size, +#ifdef HAVE_MACOSX + size * 4, +#endif /* HAVE_MACOSX */ + size); + + } + + rtp_set_send_buf(devices[index], 1024 * 56); pdb_add(participants, rtp_my_ssrc(devices[index])); } diff --git a/src/rtp/net_udp.c b/src/rtp/net_udp.c index 834322aaa..2d6153c41 100644 --- a/src/rtp/net_udp.c +++ b/src/rtp/net_udp.c @@ -458,7 +458,7 @@ int udp_set_recv_buf(socket_udp *s, int size) if(SETSOCKOPT (s->fd, SOL_SOCKET, SO_RCVBUF, (const void *)&size, sizeof(size)) != 0) { perror("Unable to set socket buffer size"); - goto error; + return FALSE; } opt_size = sizeof(opt); @@ -469,32 +469,38 @@ int udp_set_recv_buf(socket_udp *s, int size) } if(opt < size) { - goto error; + return FALSE; } debug_msg("Socket buffer size set to %d B.\n", opt); return TRUE; +} -error: - fprintf(stderr, "\n***\n" - "Unable to set buffer size to %d B.\n" - "Please set net.core.rmem_max value to %d or greater. (see also\n" - "https://www.sitola.cz/igrid/index.php/Setup_UltraGrid)\n" -#ifdef HAVE_MACOSX - "\tsysctl -w kern.ipc.maxsockbuf=%d\n" - "\tsysctl -w net.inet.udp.recvspace=%d\n" -#else - "\tsysctl -w net.core.rmem_max=%d\n" -#endif - "To make this persistent, add these options (key=value) to /etc/sysctl.conf\n" - "\n***\n\n", - size, size, -#ifdef HAVE_MACOSX - size * 4, -#endif /* HAVE_MACOSX */ - size); - return FALSE; +int udp_set_send_buf(socket_udp *s, int size) +{ + int opt = 0; + socklen_t opt_size; + if(SETSOCKOPT (s->fd, SOL_SOCKET, SO_SNDBUF, (const void *)&size, + sizeof(size)) != 0) { + perror("Unable to set socket buffer size"); + return FALSE; + } + + opt_size = sizeof(opt); + if(GETSOCKOPT (s->fd, SOL_SOCKET, SO_SNDBUF, (void *)&opt, + &opt_size) != 0) { + perror("Unable to get socket buffer size"); + return FALSE; + } + + if(opt < size) { + return FALSE; + } + + debug_msg("Socket buffer size set to %d B.\n", opt); + + return TRUE; } /*****************************************************************************/ diff --git a/src/rtp/net_udp.h b/src/rtp/net_udp.h index fea8bfd0e..3fc518939 100644 --- a/src/rtp/net_udp.h +++ b/src/rtp/net_udp.h @@ -66,6 +66,7 @@ void udp_fd_set(socket_udp *s); int udp_fd_isset(socket_udp *s); int udp_set_recv_buf(socket_udp *s, int size); +int udp_set_send_buf(socket_udp *s, int size); struct udp_fd_r { fd_set rfd; diff --git a/src/rtp/rtp.c b/src/rtp/rtp.c index 247a7a3e2..9f41efe78 100644 --- a/src/rtp/rtp.c +++ b/src/rtp/rtp.c @@ -3730,3 +3730,16 @@ int rtp_set_recv_buf(struct rtp *session, int bufsize) return udp_set_recv_buf(session->rtp_socket, bufsize); } +/** + * rtp_set_send_buf: + * Sets sender buffer size + * @session: The RTP Session. + * + * Returns: TRUE if succeeded + * FALSE otherwise + */ +int rtp_set_send_buf(struct rtp *session, int bufsize) +{ + return udp_set_send_buf(session->rtp_socket, bufsize); +} + diff --git a/src/rtp/rtp.h b/src/rtp/rtp.h index db4a58676..72d7babf8 100644 --- a/src/rtp/rtp.h +++ b/src/rtp/rtp.h @@ -265,4 +265,5 @@ uint8_t *rtp_get_userdata(struct rtp *session); void rtp_set_recv_iov(struct rtp *session, struct msghdr *m); int rtp_set_recv_buf(struct rtp *session, int bufsize); +int rtp_set_send_buf(struct rtp *session, int bufsize); #endif /* __RTP_H__ */