Skip to content
Snippets Groups Projects
Commit cdda2110 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

[#2462] Set explicitly the transport on incoming call too

parent 07732536
Branches
Tags
No related merge requests found
...@@ -682,11 +682,16 @@ SIPVoIPLink::newOutgoingCall (const CallID& id, const std::string& toUrl) ...@@ -682,11 +682,16 @@ SIPVoIPLink::newOutgoingCall (const CallID& id, const std::string& toUrl)
call->setPeerNumber (toUri); call->setPeerNumber (toUri);
// TODO May use the published address as well
localAddr = account->getLocalAddress (); localAddr = account->getLocalAddress ();
account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress (); if (localAddr == "0.0.0.0")
loadSIPLocalIP (&localAddr);
setCallAudioLocal (call, localAddr); setCallAudioLocal (call, localAddr);
// May use the published address as well
account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress ();
if (addrSdp == "0.0.0.0")
loadSIPLocalIP (&addrSdp);
try { try {
_debug ("Creating new rtp session in newOutgoingCall\n"); _debug ("Creating new rtp session in newOutgoingCall\n");
call->getAudioRtp()->initAudioRtpSession (call); call->getAudioRtp()->initAudioRtpSession (call);
...@@ -942,7 +947,7 @@ int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction) ...@@ -942,7 +947,7 @@ int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction)
return !PJ_SUCCESS; return !PJ_SUCCESS;
} }
// reinvite only if connected // Reinvite only if connected
// Build the local SDP offer // Build the local SDP offer
status = call->getLocalSDP()->create_initial_offer(); status = call->getLocalSDP()->create_initial_offer();
...@@ -956,7 +961,6 @@ int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction) ...@@ -956,7 +961,6 @@ int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction)
pjmedia_sdp_media_add_attr (local_sdp->media[0], attr); pjmedia_sdp_media_add_attr (local_sdp->media[0], attr);
// Build the reinvite request // Build the reinvite request
status = pjsip_inv_reinvite (call->getInvSession(), NULL, status = pjsip_inv_reinvite (call->getInvSession(), NULL,
local_sdp, &tdata); local_sdp, &tdata);
...@@ -1437,7 +1441,7 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to) ...@@ -1437,7 +1441,7 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
pjsip_dialog *dialog; pjsip_dialog *dialog;
pjsip_inv_session *inv; pjsip_inv_session *inv;
pjsip_tx_data *tdata; pjsip_tx_data *tdata;
std::string localAddress; std::string localAddress, addrSdp;
/* Create the call */ /* Create the call */
call = new SIPCall (id, Call::Outgoing, _pool); call = new SIPCall (id, Call::Outgoing, _pool);
...@@ -1456,9 +1460,10 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to) ...@@ -1456,9 +1460,10 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
return !PJ_SUCCESS; return !PJ_SUCCESS;
} }
// Set the local address
localAddress = account->getLocalAddress ();
// Set SDP parameters - Set to local or published address // Set SDP parameters - Set to local or published address
// account->isStunEnabled () ? localAddress = account->getPublishedAddress () : localAddress = account->getLocalAddress (); account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress ();
account->isStunEnabled () ? localAddress = account->getLocalAddress () : localAddress = account->getLocalAddress ();
_debug ("new_ip_to_ip_call localAddress: %s\n", localAddress.c_str()); _debug ("new_ip_to_ip_call localAddress: %s\n", localAddress.c_str());
...@@ -1467,6 +1472,10 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to) ...@@ -1467,6 +1472,10 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
loadSIPLocalIP (&localAddress); loadSIPLocalIP (&localAddress);
} }
if (addrSdp == "0.0.0.0") {
addrSdp = localAddress;
}
setCallAudioLocal (call, localAddress); setCallAudioLocal (call, localAddress);
_debug ("toUri received in new_ip_to_ip call %s\n", to.c_str()); _debug ("toUri received in new_ip_to_ip call %s\n", to.c_str());
...@@ -1475,8 +1484,7 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to) ...@@ -1475,8 +1484,7 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
call->setPeerNumber (toUri); call->setPeerNumber (toUri);
_debug ("toUri in new_ip_to_ip call %s\n", toUri.c_str()); _debug ("toUri in new_ip_to_ip call %s\n", toUri.c_str());
// Building the local SDP offer // Building the local SDP offer
account->isStunEnabled () ? localAddress = account->getPublishedAddress () : localAddress = account->getLocalAddress (); call->getLocalSDP()->set_ip_address (addrSdp);
call->getLocalSDP()->set_ip_address (localAddress);
call->getLocalSDP()->create_initial_offer(); call->getLocalSDP()->create_initial_offer();
try { try {
...@@ -3097,24 +3105,30 @@ mod_on_rx_request (pjsip_rx_data *rdata) ...@@ -3097,24 +3105,30 @@ mod_on_rx_request (pjsip_rx_data *rdata)
return false; return false;
} }
std::string addrToUse, addrSdp; std::string addrToUse, addrSdp ="0.0.0.0";
pjsip_tpselector *tp;
account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id)); account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id));
if (account != NULL) { if (account != NULL) {
// TODO May use the published address as well // May use the published address as well
addrToUse = addrToUse = account->getLocalAddress (); addrToUse = account->getLocalAddress ();
account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress (); account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress ();
// Set the appropriate transport to have the right VIA header
link->init_transport_selector (account->getAccountTransport (), &tp);
} }
if (addrToUse == "0.0.0.0") { if (addrToUse == "0.0.0.0") {
link->loadSIPLocalIP (&addrToUse); link->loadSIPLocalIP (&addrToUse);
} }
if (addrSdp == "0.0.0.0") {
addrSdp = addrToUse;
}
// Have to do some stuff with the SDP // Have to do some stuff with the SDP
// Set the codec map, IP, peer number and so on... for the SIPCall object // Set the codec map, IP, peer number and so on... for the SIPCall object
setCallAudioLocal (call, addrToUse); setCallAudioLocal (call, addrToUse);
// We retrieve the remote sdp offer in the rdata struct to begin the negociation // We retrieve the remote sdp offer in the rdata struct to begin the negociation
call->getLocalSDP()->set_ip_address (addrSdp); call->getLocalSDP()->set_ip_address (addrSdp);
...@@ -3161,6 +3175,9 @@ mod_on_rx_request (pjsip_rx_data *rdata) ...@@ -3161,6 +3175,9 @@ mod_on_rx_request (pjsip_rx_data *rdata)
// Specify media capability during invite session creation // Specify media capability during invite session creation
status = pjsip_inv_create_uas (dialog, rdata, call->getLocalSDP()->get_local_sdp_session(), 0, &inv); status = pjsip_inv_create_uas (dialog, rdata, call->getLocalSDP()->get_local_sdp_session(), 0, &inv);
// Explicitly set the transport
status = pjsip_dlg_set_transport (dialog, tp);
PJ_ASSERT_RETURN (status == PJ_SUCCESS, 1); PJ_ASSERT_RETURN (status == PJ_SUCCESS, 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment