Commit 5f7b669f authored by Simon Morlat's avatar Simon Morlat

implement RTP socket refresh (re-create, re-bind as identical) in order to...

implement RTP socket refresh (re-create, re-bind as identical) in order to have the new sockets using the new routing rules applied externally to the process (possible on Android).
parent 81695704
......@@ -475,6 +475,7 @@ ORTP_PUBLIC void rtp_session_get_transports(const RtpSession *session, RtpTransp
/*those methods are provided for people who wants to send non-RTP messages using the RTP/RTCP sockets */
ORTP_PUBLIC ortp_socket_t rtp_session_get_rtp_socket(const RtpSession *session);
ORTP_PUBLIC ortp_socket_t rtp_session_get_rtcp_socket(const RtpSession *session);
ORTP_PUBLIC void rtp_session_refresh_sockets(RtpSession *session);
/* QOS / DSCP */
......@@ -344,7 +344,7 @@ static void set_socket_sizes(ortp_socket_t sock, unsigned int sndbufsz, unsigned
* In case where the rtp session is send-only, then it is not required to call this function:
* when calling rtp_session_set_remote_addr(), if no local address has been set, then the
* default INADRR_ANY ( IP address with a random port will be used. Calling
* rtp_sesession_set_local_addr() is mandatory when the session is recv-only or duplex.
* rtp_session_set_local_addr() is mandatory when the session is recv-only or duplex.
* Returns: 0 on success.
......@@ -388,6 +388,35 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
return -1;
static void _rtp_session_recreate_sockets(RtpSession *session){
char addr[NI_MAXHOST];
int err = getnameinfo((struct sockaddr*)&session->, session->, addr, sizeof(addr), NULL, 0, NI_NUMERICHOST);
if (err != 0){
ortp_error("_rtp_session_recreate_sockets(): getnameinfo() error: %s", gai_strerror(err));
/*re create and bind sockets as they were done previously*/
ortp_message("RtpSession %p is going to re-create its socket.", session);
rtp_session_set_local_addr(session, addr, session->, session->;
static void _rtp_session_check_socket_refresh(RtpSession *session){
* Requests the session to re-create and bind its RTP and RTCP sockets same as they are currently.
* This is used when a change in the routing rules of the host or process was made, in order to have
* this routing rules change taking effect on the RTP/RTCP packets sent by the session.
void rtp_session_refresh_sockets(RtpSession *session){
if (session-> != (ortp_socket_t) -1){
int rtp_session_join_multicast_group(RtpSession *session, const char *ip){
int err;
......@@ -1039,6 +1068,7 @@ int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockad
int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen){
int ret;
if (session->net_sim_ctx && (session->net_sim_ctx->params.mode==OrtpNetworkSimulatorOutbound
|| session->net_sim_ctx->params.mode==OrtpNetworkSimulatorOutboundControlled)){
......@@ -43,7 +43,8 @@ typedef enum {
#define rtp_session_using_transport(s, stream) (((s)->flags & RTP_SESSION_USING_TRANSPORT) && (s-> != 0))
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