Commit 469444dd authored by Simon Morlat's avatar Simon Morlat

bugfix: socket buffer size settings were not applied when given after socket creation.

This is causing packet loss on high bandwidth video streams.
parent 7612f40d
......@@ -521,6 +521,7 @@ void rtp_session_set_recv_buf_size(RtpSession *session, int bufsize){
**/
void rtp_session_set_rtp_socket_send_buffer_size(RtpSession * session, unsigned int size){
session->rtp.snd_socket_size=size;
_rtp_session_apply_socket_sizes(session);
}
/**
......@@ -529,6 +530,7 @@ void rtp_session_set_rtp_socket_send_buffer_size(RtpSession * session, unsigned
**/
void rtp_session_set_rtp_socket_recv_buffer_size(RtpSession * session, unsigned int size){
session->rtp.rcv_socket_size=size;
_rtp_session_apply_socket_sizes(session);
}
/**
......
......@@ -281,14 +281,20 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
return sock;
}
static void set_socket_sizes(ortp_socket_t sock, unsigned int sndbufsz, unsigned int rcvbufsz){
void _rtp_session_apply_socket_sizes(RtpSession * session){
int err;
bool_t done=FALSE;
ortp_socket_t sock = session->rtp.gs.socket;
unsigned int sndbufsz = session->rtp.snd_socket_size;
unsigned int rcvbufsz = session->rtp.rcv_socket_size;
if (sock == (ortp_socket_t)-1) return;
if (sndbufsz>0){
#ifdef SO_SNDBUFFORCE
err = setsockopt(sock, SOL_SOCKET, SO_SNDBUFFORCE, (void *)&sndbufsz, sizeof(sndbufsz));
if (err == -1) {
ortp_error("Fail to increase socket's send buffer size with SO_SNDBUFFORCE: %s.", getSocketError());
ortp_warning("Fail to increase socket's send buffer size with SO_SNDBUFFORCE: %s.", getSocketError());
}else done=TRUE;
#endif
if (!done){
......@@ -303,7 +309,7 @@ static void set_socket_sizes(ortp_socket_t sock, unsigned int sndbufsz, unsigned
#ifdef SO_RCVBUFFORCE
err = setsockopt(sock, SOL_SOCKET, SO_RCVBUFFORCE, (void *)&rcvbufsz, sizeof(rcvbufsz));
if (err == -1) {
ortp_error("Fail to increase socket's recv buffer size with SO_RCVBUFFORCE: %s.", getSocketError());
ortp_warning("Fail to increase socket's recv buffer size with SO_RCVBUFFORCE: %s.", getSocketError());
}
#endif
if (!done){
......@@ -345,10 +351,10 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
sock=create_and_bind(addr,&rtp_port,&sockfamily,session->reuseaddr,&session->rtp.gs.loc_addr,&session->rtp.gs.loc_addrlen);
if (sock!=-1){
set_socket_sizes(sock,session->rtp.snd_socket_size,session->rtp.rcv_socket_size);
session->rtp.gs.sockfamily=sockfamily;
session->rtp.gs.socket=sock;
session->rtp.gs.loc_port=rtp_port;
_rtp_session_apply_socket_sizes(session);
/*try to bind rtcp port */
sock=create_and_bind(addr,&rtcp_port,&sockfamily,session->reuseaddr,&session->rtcp.gs.loc_addr,&session->rtcp.gs.loc_addrlen);
if (sock!=(ortp_socket_t)-1){
......
......@@ -109,5 +109,7 @@ int rtp_session_update_remote_sock_addr(RtpSession * session, mblk_t * mp, bool_
void rtp_session_process_incoming(RtpSession * session, mblk_t *mp, bool_t is_rtp_packet, uint32_t ts, bool_t received_via_rtcp_mux);
void update_sent_bytes(OrtpStream *os, int nbytes);
void _rtp_session_apply_socket_sizes(RtpSession *session);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment