Commit 943c19b2 authored by Guillaume Beraudo's avatar Guillaume Beraudo

API for defining SO_REUSEADDR in rtp session.

parent 88ace8ad
......@@ -273,19 +273,6 @@ if test "$memcheck_enabled" = "yes" ; then
fi
fi
AC_ARG_ENABLE(so-reuseaddr,
[AS_HELP_STRING([--enable-so-reuseaddr], [Enable SO_REUSEADDR socket option in the rtp_session_set_local_addr() function (default=yes)])],
[case "${enableval}" in
yes) so_reuseaddr_enabled=yes;;
no) so_reuseaddr_enabled=no;;
*) AC_MSG_ERROR("Bad value for --enable-so-reuseaddr");;
esac],
[so_reuseaddr_enabled=yes])
if test "$so_reuseaddr_enabled" = "yes" ; then
AC_DEFINE(SO_REUSE_ADDR,1,[Defined when SO_REUSEADDR socket option in the rtp_session_set_local_addr() function is enabled])
fi
dnl Checks for header files.
AC_HEADER_STDC
......
......@@ -247,6 +247,7 @@ struct _RtpSession
bool_t permissive; /*use the permissive algorithm*/
bool_t use_connect; /* use connect() on the socket */
bool_t ssrc_set;
bool_t reuseaddr; /*setsockopt SO_REUSEADDR */
};
......@@ -421,6 +422,8 @@ ORTP_PUBLIC void rtp_session_init(RtpSession *session, int mode);
ORTP_PUBLIC void rtp_session_uninit(RtpSession *session);
ORTP_PUBLIC void rtp_session_dispatch_event(RtpSession *session, OrtpEvent *ev);
ORTP_PUBLIC void rtp_session_set_reuseaddr(RtpSession *session, bool_t yes);
#ifdef __cplusplus
}
#endif
......
......@@ -288,6 +288,7 @@ rtp_session_init (RtpSession * session, int mode)
session->recv_buf_size = UDP_MAX_SIZE;
session->symmetric_rtp = FALSE;
session->permissive=FALSE;
session->reuseaddr=TRUE;
msgb_allocator_init(&session->allocator);
}
......@@ -1841,3 +1842,6 @@ void rtp_session_process (RtpSession * session, uint32_t time, RtpScheduler *sch
wait_point_unlock(&session->rcv.wp);
}
void rtp_session_set_reuseaddr(RtpSession *session, bool_t yes) {
session->reuseaddr=yes;
}
......@@ -307,19 +307,13 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
{
ortp_socket_t sock;
int sockfamily;
bool_t reuse_addr;
if (session->rtp.socket!=(ortp_socket_t)-1){
/* don't rebind, but close before*/
rtp_session_release_sockets(session);
}
#ifdef SO_REUSE_ADDR
reuse_addr=TRUE;
#else
reuse_addr=FALSE;
#endif
/* try to bind the rtp port */
if (rtp_port>0)
sock=create_and_bind(addr,rtp_port,&sockfamily,reuse_addr);
sock=create_and_bind(addr,rtp_port,&sockfamily,session->reuseaddr);
else
sock=create_and_bind_random(addr,&sockfamily,&rtp_port);
if (sock!=-1){
......@@ -329,7 +323,7 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
session->rtp.loc_port=rtp_port;
/*try to bind rtcp port */
if (rtcp_port<0) rtcp_port=rtp_port+1;
sock=create_and_bind(addr,rtcp_port,&sockfamily,reuse_addr);
sock=create_and_bind(addr,rtcp_port,&sockfamily,session->reuseaddr);
if (sock!=(ortp_socket_t)-1){
session->rtcp.sockfamily=sockfamily;
session->rtcp.socket=sock;
......
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