diff options
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 1 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 44 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_core.c | 15 |
3 files changed, 16 insertions, 44 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 18467129..a3c0c3a4 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -102,6 +102,7 @@ struct pjsua_call pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this call was triggered by xfer. */ pjmedia_sock_info skinfo; /**< Preallocated media sockets. */ + pjmedia_transport *med_tp; /**< Media transport. */ void *app_data; /**< Application data. */ pj_timer_entry refresh_tm;/**< Timer to send re-INVITE. */ pj_timer_entry hangup_tm; /**< Timer to hangup call. */ diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 73f5aac1..4dbfb596 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -97,26 +97,6 @@ static void schedule_call_timer( pjsua_call *call, pj_timer_entry *e, } -/* Close and reopen socket. */ -static pj_status_t reopen_sock( pj_sock_t *sock, pj_sockaddr_in *addr) -{ - pj_status_t status; - - status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, sock); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to create socket", status); - return status; - } - - status = pj_sock_bind(*sock, addr, sizeof(pj_sockaddr_in)); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to re-bind RTP/RTCP socket", status); - return status; - } - - return PJ_SUCCESS; -} - /* * Destroy the call's media */ @@ -130,27 +110,8 @@ static pj_status_t call_destroy_media(int call_index) } if (call->session) { - pj_sockaddr_in rtp_addr, rtcp_addr; - int addrlen; - - addrlen = sizeof(rtp_addr); - pj_sock_getsockname(call->skinfo.rtp_sock, &rtp_addr, &addrlen); - - addrlen = sizeof(rtcp_addr); - pj_sock_getsockname(call->skinfo.rtcp_sock, &rtcp_addr, &addrlen); - /* Destroy session (this will also close RTP/RTCP sockets). */ pjmedia_session_destroy(call->session); - - /* Close and reopen RTP socket. - * This is necessary to get the socket unregistered from ioqueue, - * when IOCompletionPort is used. - */ - reopen_sock(&call->skinfo.rtp_sock, &rtp_addr); - - /* Close and reopen RTCP socket too. */ - reopen_sock(&call->skinfo.rtcp_sock, &rtcp_addr); - call->session = NULL; PJ_LOG(3,(THIS_FILE, "Media session for call %d is destroyed", @@ -1011,8 +972,8 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv, * We only support one stream per session at the moment */ status = pjmedia_session_info_from_sdp( call->inv->dlg->pool, - pjsua.med_endpt, 1, - &sess_info, &call->skinfo, + pjsua.med_endpt, + 1,&sess_info, local_sdp, remote_sdp); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Unable to create media session", @@ -1035,6 +996,7 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv, /* Create session based on session info. */ status = pjmedia_session_create( pjsua.med_endpt, &sess_info, + &call->med_tp, call, &call->session ); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Unable to create media session", diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index eafcd78b..5959d065 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -320,7 +320,7 @@ static pj_status_t init_sockets(pj_bool_t sip, PJ_LOG(4,(THIS_FILE, "RTP socket reachable at %s:%d", pj_inet_ntoa(skinfo->rtp_addr_name.sin_addr), pj_ntohs(skinfo->rtp_addr_name.sin_port))); - PJ_LOG(4,(THIS_FILE, "RTCP UDP socket reachable at %s:%d", + PJ_LOG(4,(THIS_FILE, "RTCP socket reachable at %s:%d", pj_inet_ntoa(skinfo->rtcp_addr_name.sin_addr), pj_ntohs(skinfo->rtcp_addr_name.sin_port))); @@ -779,6 +779,10 @@ pj_status_t pjsua_start(void) /* Init sockets (STUN etc): */ for (i=0; i<(int)pjsua.max_calls; ++i) { status = init_sockets(i==0, &pjsua.calls[i].skinfo); + if (status == PJ_SUCCESS) + status = pjmedia_transport_udp_attach(pjsua.med_endpt, NULL, + &pjsua.calls[i].skinfo, + &pjsua.calls[i].med_tp); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "init_sockets() has returned error", status); @@ -786,8 +790,7 @@ pj_status_t pjsua_start(void) if (i >= 0) pj_sock_close(pjsua.sip_sock); while (i >= 0) { - pj_sock_close(pjsua.calls[i].skinfo.rtp_sock); - pj_sock_close(pjsua.calls[i].skinfo.rtcp_sock); + pjmedia_transport_udp_close(pjsua.calls[i].med_tp); } return status; } @@ -1048,6 +1051,12 @@ pj_status_t pjsua_destroy(void) pjmedia_codec_l16_deinit(); #endif /* PJMEDIA_HAS_L16_CODEC */ + + /* Close transports */ + for (i=0; i<pjsua.call_cnt; ++i) { + pjmedia_transport_udp_close(pjsua.calls[i].med_tp); + } + /* Destroy media endpoint. */ pjmedia_endpt_destroy(pjsua.med_endpt); |