summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-09-11 22:56:26 +0000
committerBenny Prijono <bennylp@teluu.com>2006-09-11 22:56:26 +0000
commit025890b11ac3daf0b3bfc5f7b002b48746c373c8 (patch)
tree24c783215ce9569d8bf48118f292684ec258940a
parent18fd894546492261e3abff8d5d1d7b45c352e4cc (diff)
Fixed bug in media UDP transport: when transport is created with create(), no IP address is given. This caused get_info() to return 0.0.0.0 as the transport address.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@705 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjmedia/src/pjmedia/transport_udp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/pjmedia/src/pjmedia/transport_udp.c b/pjmedia/src/pjmedia/transport_udp.c
index 4928c0ce..a92c3edb 100644
--- a/pjmedia/src/pjmedia/transport_udp.c
+++ b/pjmedia/src/pjmedia/transport_udp.c
@@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pjmedia/transport_udp.h>
+#include <pj/addr_resolv.h>
#include <pj/assert.h>
#include <pj/errno.h>
#include <pj/ioqueue.h>
@@ -242,6 +243,21 @@ PJ_DEF(pj_status_t) pjmedia_transport_udp_attach( pjmedia_endpt *endpt,
tp->rtcp_sock = si->rtcp_sock;
tp->rtcp_addr_name = si->rtcp_addr_name;
+ /* If address is 0.0.0.0, use host's IP address */
+ if (tp->rtp_addr_name.sin_addr.s_addr == 0) {
+ pj_hostent he;
+ const pj_str_t *hostname = pj_gethostname();
+ status = pj_gethostbyname(hostname, &he);
+ if (status != PJ_SUCCESS) {
+ goto on_error;
+ }
+ tp->rtp_addr_name.sin_addr = *(pj_in_addr*)he.h_addr;
+ }
+
+ /* Same with RTCP */
+ if (tp->rtcp_addr_name.sin_addr.s_addr == 0) {
+ tp->rtcp_addr_name.sin_addr.s_addr = tp->rtp_addr_name.sin_addr.s_addr;
+ }
/* Setup RTP socket with the ioqueue */
pj_bzero(&rtp_cb, sizeof(rtp_cb));