Commit 8f6e9ac3 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#9910: fix sending call with new transport

parent 904f7882
...@@ -793,7 +793,7 @@ void SIPAccount::setContactHeader(std::string address, std::string port) ...@@ -793,7 +793,7 @@ void SIPAccount::setContactHeader(std::string address, std::string port)
std::string SIPAccount::getContactHeader() const std::string SIPAccount::getContactHeader() const
{ {
if (transport_ == NULL) if (transport_ == NULL)
ERROR("Transport not created yet"); ERROR("SipAccount: Transport not created yet");
// The transport type must be specified, in our case START_OTHER refers to stun transport // The transport type must be specified, in our case START_OTHER refers to stun transport
pjsip_transport_type_e transportType = transportType_; pjsip_transport_type_e transportType = transportType_;
......
...@@ -457,7 +457,7 @@ SipTransport::createUdpTransport(const std::string &interface, unsigned int port ...@@ -457,7 +457,7 @@ SipTransport::createUdpTransport(const std::string &interface, unsigned int port
{ {
// init socket to bind this transport to // init socket to bind this transport to
pj_uint16_t listeningPort = (pj_uint16_t) port; pj_uint16_t listeningPort = (pj_uint16_t) port;
pjsip_transport *transport; pjsip_transport *transport = NULL;
DEBUG("SipTransport: Update UDP transport on %s:%d with public addr %s:%d", interface.c_str(), port, publicAddr.c_str(), publicPort); DEBUG("SipTransport: Update UDP transport on %s:%d with public addr %s:%d", interface.c_str(), port, publicAddr.c_str(), publicPort);
......
...@@ -524,6 +524,9 @@ void SIPVoIPLink::sendRegister(Account *a) ...@@ -524,6 +524,9 @@ void SIPVoIPLink::sendRegister(Account *a)
account->setReceivedParameter(""); account->setReceivedParameter("");
// Explicitely set the bound address port to 0 so that pjsip determine a random port by itself // Explicitely set the bound address port to 0 so that pjsip determine a random port by itself
account->transport_= sipTransport.createUdpTransport(account->getLocalInterface(), 0, received, account->getLocalPort()); account->transport_= sipTransport.createUdpTransport(account->getLocalInterface(), 0, received, account->getLocalPort());
if(account->transport_ == NULL) {
ERROR("UserAgent: Could not create new udp transport with public address: %s:%d", received.c_str(), account->getLocalPort());
}
} }
if (pjsip_regc_init(regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, account->getRegistrationExpire()) != PJ_SUCCESS) if (pjsip_regc_init(regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, account->getRegistrationExpire()) != PJ_SUCCESS)
...@@ -1617,7 +1620,6 @@ void registration_cb(pjsip_regc_cbparam *param) ...@@ -1617,7 +1620,6 @@ void registration_cb(pjsip_regc_cbparam *param)
if (param->status != PJ_SUCCESS) { if (param->status != PJ_SUCCESS) {
account->setRegistrationState(ErrorAuth); account->setRegistrationState(ErrorAuth);
account->setRegister(false); account->setRegister(false);
SIPVoIPLink::instance()->sipTransport.shutdownSipTransport(*account); SIPVoIPLink::instance()->sipTransport.shutdownSipTransport(*account);
return; return;
} }
...@@ -1633,29 +1635,33 @@ void registration_cb(pjsip_regc_cbparam *param) ...@@ -1633,29 +1635,33 @@ void registration_cb(pjsip_regc_cbparam *param)
case PJSIP_SC_SERVICE_UNAVAILABLE: case PJSIP_SC_SERVICE_UNAVAILABLE:
case PJSIP_SC_REQUEST_TIMEOUT: case PJSIP_SC_REQUEST_TIMEOUT:
account->setRegistrationState(ErrorHost); account->setRegistrationState(ErrorHost);
account->setRegister(false);
SIPVoIPLink::instance()->sipTransport.shutdownSipTransport(*account);
break; break;
case PJSIP_SC_UNAUTHORIZED: case PJSIP_SC_UNAUTHORIZED:
case PJSIP_SC_FORBIDDEN: case PJSIP_SC_FORBIDDEN:
case PJSIP_SC_NOT_FOUND: case PJSIP_SC_NOT_FOUND:
account->setRegistrationState(ErrorAuth); account->setRegistrationState(ErrorAuth);
account->setRegister(false);
SIPVoIPLink::instance()->sipTransport.shutdownSipTransport(*account);
break; break;
case PJSIP_SC_INTERVAL_TOO_BRIEF: case PJSIP_SC_INTERVAL_TOO_BRIEF:
// Expiration Interval Too Brief // Expiration Interval Too Brief
account->doubleRegistrationExpire(); account->doubleRegistrationExpire();
account->registerVoIPLink(); account->registerVoIPLink();
account->setRegister(false);
SIPVoIPLink::instance()->sipTransport.shutdownSipTransport(*account);
break; break;
default: default:
account->setRegistrationState(Error); account->setRegistrationState(Error);
account->setRegister(false);
SIPVoIPLink::instance()->sipTransport.shutdownSipTransport(*account);
break; break;
} }
account->setRegister(false);
SIPVoIPLink::instance()->sipTransport.shutdownSipTransport(*account);
} else { } else {
if (account->isRegistered()) if (account->isRegistered())
account->setRegistrationState(Registered); account->setRegistrationState(Registered);
......
Supports Markdown
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