summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsua-lib/pjsua_media.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-09-14 18:51:01 +0000
committerBenny Prijono <bennylp@teluu.com>2006-09-14 18:51:01 +0000
commitb6b613a4e59e2177a2e899dc4e21ab660c05de3d (patch)
treeab3821c5de8972a5006c4590ec631ff40ef61e15 /pjsip/src/pjsua-lib/pjsua_media.c
parente015ebe064c6f5120ef2af2b73ce52796a06f790 (diff)
Fix the local IP address resolution issue in PJSIP, PJMEDIA, and PJSUA, by adding a new API pj_gethostip() to resolve the default local IP address of local host. This new function will work even when local hostname resolution is not set correctly, by detecting the default IP interface in the system.
Also fix compile warnings in iLBC. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@721 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_media.c')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 0e24e4de..e37275a2 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -286,23 +286,15 @@ static pj_status_t create_rtp_rtcp_sock(const pjsua_transport_config *cfg,
sock[1] = PJ_INVALID_SOCKET;
} else {
- const pj_str_t *hostname;
- pj_sockaddr_in addr;
+ pj_in_addr addr;
/* Get local IP address. */
- hostname = pj_gethostname();
-
- pj_bzero( &addr, sizeof(addr));
- addr.sin_family = PJ_AF_INET;
- status = pj_sockaddr_in_set_str_addr( &addr, hostname);
- if (status != PJ_SUCCESS) {
- pjsua_perror(THIS_FILE, "Unresolvable local hostname",
- status);
+ status = pj_gethostip(&addr);
+ if (status != PJ_SUCCESS)
goto on_error;
- }
for (i=0; i<2; ++i)
- pj_memcpy(&mapped_addr[i], &addr, sizeof(addr));
+ mapped_addr[i].sin_addr = addr;
mapped_addr[0].sin_port=pj_htons((pj_uint16_t)rtp_port);
mapped_addr[1].sin_port=pj_htons((pj_uint16_t)(rtp_port+1));