Commit 6d28f274 authored by Guillaume Beraudo's avatar Guillaume Beraudo

More robust rtp_session_set_local_addr for rtcp

* random rtcp port [ tries rtp+1 then 100 random ports]
* success in rtcp socket creation is mandatory.
parent 20b52714
...@@ -324,13 +324,21 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por ...@@ -324,13 +324,21 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
session->rtp.socket=sock; session->rtp.socket=sock;
session->rtp.loc_port=rtp_port; session->rtp.loc_port=rtp_port;
/*try to bind rtcp port */ /*try to bind rtcp port */
if (rtcp_port<0) rtcp_port=rtp_port+1; if (rtcp_port<0) {
sock=create_and_bind(addr,rtcp_port,&sockfamily,session->reuseaddr); rtcp_port=rtp_port+1;
sock=create_and_bind(addr,rtcp_port,&sockfamily,session->reuseaddr);
if (sock==(ortp_socket_t)-1) {
sock=create_and_bind_random(addr,&sockfamily,&rtcp_port);
}
} else {
sock=create_and_bind(addr,rtcp_port,&sockfamily,session->reuseaddr);
}
if (sock!=(ortp_socket_t)-1){ if (sock!=(ortp_socket_t)-1){
session->rtcp.sockfamily=sockfamily; session->rtcp.sockfamily=sockfamily;
session->rtcp.socket=sock; session->rtcp.socket=sock;
}else{ }else {
ortp_warning("Could not create and bind rtcp socket."); ortp_debug("Could not create and bind rtcp socket.");
return -1;
} }
/* set socket options (but don't change chosen states) */ /* set socket options (but don't change chosen states) */
......
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