Commit 616164fa authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Adrien Béraud

sip: unuse default sip port and do implicit port binding

- solve the registration failure issue in android due to the possible
  occupied Default sip port (Address already in use)

Change-Id: I4794a4a1f6d3a0128aea2c21d18868de23cbbcee
parent 2f7f75fa
......@@ -44,6 +44,7 @@ namespace jami { namespace sip_utils {
static constexpr int DEFAULT_SIP_PORT {5060};
static constexpr int DEFAULT_SIP_TLS_PORT {5061};
static constexpr int DEFAULT_AUTO_SELECT_PORT {0};
enum class KeyExchangeProtocol { NONE, SDES };
......
......@@ -614,6 +614,10 @@ void SIPAccount::setAccountDetails(const std::map<std::string, std::string> &det
v.push_back(map);
setCredentials(v);
}
if (isIP2IP()) {
localPort_ = (localPort_ == sip_utils::DEFAULT_AUTO_SELECT_PORT) ? sip_utils::DEFAULT_SIP_PORT : localPort_;
tlsListenerPort_ = (tlsListenerPort_ == sip_utils::DEFAULT_AUTO_SELECT_PORT) ? sip_utils::DEFAULT_SIP_TLS_PORT : tlsListenerPort_;
}
}
std::map<std::string, std::string>
......
......@@ -702,7 +702,7 @@ class SIPAccount : public SIPAccountBase {
/**
* Local port to whih this account is bound
*/
pj_uint16_t localPort_ {sip_utils::DEFAULT_SIP_PORT};
pj_uint16_t localPort_ {sip_utils::DEFAULT_AUTO_SELECT_PORT};
/**
* Potential ip addresss on which this account is bound
......@@ -712,7 +712,7 @@ class SIPAccount : public SIPAccountBase {
/**
* The TLS listener port
*/
pj_uint16_t tlsListenerPort_ {sip_utils::DEFAULT_SIP_TLS_PORT};
pj_uint16_t tlsListenerPort_ {sip_utils::DEFAULT_AUTO_SELECT_PORT};
/**
* Send Request Callback
......
......@@ -329,7 +329,6 @@ SipTransportBroker::getUdpTransport(const IpAddr& ipAddress)
std::shared_ptr<SipTransport>
SipTransportBroker::createUdpTransport(const IpAddr& ipAddress)
{
RETURN_IF_FAIL(ipAddress.getPort() != 0, nullptr, "Could not determine port for this transport");
RETURN_IF_FAIL(ipAddress, nullptr, "Could not determine IP address for this transport");
pjsip_udp_transport_cfg pj_cfg;
......
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