summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiza Sulistyo <riza@teluu.com>2016-05-09 06:58:29 +0000
committerRiza Sulistyo <riza@teluu.com>2016-05-09 06:58:29 +0000
commite9d24a4e803c08ec00e4c1cd46bc8234aa888531 (patch)
treef275c22c9f7b9d40f4ccece1560a5bf5c00f69ab
parentbd669b9c601fa8c18e7fbfb6789d6135f1b4224b (diff)
Fixed #1914: Ignore STUN error after pjstun_get_mapped_addr2().
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5283 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c28
3 files changed, 28 insertions, 4 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 4887a97e..769cb4b3 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -1577,7 +1577,7 @@ typedef struct pjsua_config
pj_str_t stun_srv[8];
/**
- * This specifies if the library startup should ignore failure with the
+ * This specifies if the library should ignore failure with the
* STUN servers. If this is set to PJ_FALSE, the library will refuse to
* start if it fails to resolve or contact any of the STUN servers.
*
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 41254c4c..55e7ef10 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -2052,7 +2052,7 @@ static pj_status_t create_sip_udp_sock(int af,
pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port);
status = pjstun_get_mapped_addr2(&pjsua_var.cp.factory, &stun_opt,
1, &sock, &p_pub_addr->ipv4);
- if (status != PJ_SUCCESS) {
+ if (status != PJ_SUCCESS && !pjsua_var.ua_cfg.stun_ignore_failure) {
pjsua_perror(THIS_FILE, "Error contacting STUN server", status);
pj_sock_close(sock);
return status;
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 5f948973..37f81572 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -390,8 +390,32 @@ static pj_status_t create_rtp_rtcp_sock(pjsua_call_media *call_med,
else
#endif
if (status != PJ_SUCCESS) {
- pjsua_perror(THIS_FILE, "STUN resolve error", status);
- goto on_error;
+ if (!pjsua_var.ua_cfg.stun_ignore_failure) {
+ pjsua_perror(THIS_FILE, "STUN resolve error", status);
+ goto on_error;
+ }
+
+ PJ_LOG(4,(THIS_FILE, "Ignoring STUN resolve error %d",
+ status));
+
+ if (!pj_sockaddr_has_addr(&bound_addr)) {
+ pj_sockaddr addr;
+
+ /* Get local IP address. */
+ status = pj_gethostip(af, &addr);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ pj_sockaddr_copy_addr(&bound_addr, &addr);
+ }
+
+ for (i=0; i<2; ++i) {
+ pj_sockaddr_init(af, &mapped_addr[i], NULL, 0);
+ pj_sockaddr_copy_addr(&mapped_addr[i], &bound_addr);
+ pj_sockaddr_set_port(&mapped_addr[i],
+ (pj_uint16_t)(acc->next_rtp_port+i));
+ }
+ break;
}
pj_sockaddr_cp(&mapped_addr[0], &resolved_addr[0]);