Index: pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 1183)
+++ pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 1184)
@@ -914,5 +914,6 @@
 
     /**
-     * Specify STUN server to be used.
+     * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
+     * not specified, default port 3478 will be used.
      */
     pj_str_t	    stun_host;
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 1183)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 1184)
@@ -679,12 +679,32 @@
 	 */
 	if (pjsua_var.ua_cfg.stun_host.slen) {
+	    pj_str_t str_host, str_port;
+	    int port;
 	    pj_hostent he;
 
-	    pjsua_var.stun_status = pj_gethostbyname(&pjsua_var.ua_cfg.stun_host, &he);
+	    str_port.ptr = pj_strchr(&pjsua_var.ua_cfg.stun_host, ':');
+	    if (str_port.ptr != NULL) {
+		str_host.ptr = pjsua_var.ua_cfg.stun_host.ptr;
+		str_host.slen = (str_port.ptr - str_host.ptr);
+		str_port.ptr++;
+		str_port.slen = pjsua_var.ua_cfg.stun_host.slen - 
+				str_host.slen - 1;
+		port = (int)pj_strtoul(&str_port);
+		if (port < 1 || port > 65535) {
+		    pjsua_perror(THIS_FILE, "Invalid STUN server", PJ_EINVAL);
+		    pjsua_var.stun_status = PJ_EINVAL;
+		    return;
+		}
+	    } else {
+		str_host = pjsua_var.ua_cfg.stun_host;
+		port = 3478;
+	    }
+
+	    pjsua_var.stun_status = pj_gethostbyname(&str_host, &he);
 
 	    if (pjsua_var.stun_status == PJ_SUCCESS) {
 		pj_sockaddr_in_init(&pjsua_var.stun_srv.ipv4, NULL, 0);
 		pjsua_var.stun_srv.ipv4.sin_addr = *(pj_in_addr*)he.h_addr;
-		pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)3478);
+		pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)port);
 
 		PJ_LOG(3,(THIS_FILE, 
@@ -773,12 +793,33 @@
 	 */
 	else if (pjsua_var.ua_cfg.stun_host.slen) {
+	    pj_str_t str_host, str_port;
+	    int port;
 	    pj_hostent he;
 
-	    pjsua_var.stun_status = pj_gethostbyname(&pjsua_var.ua_cfg.stun_host, &he);
+	    str_port.ptr = pj_strchr(&pjsua_var.ua_cfg.stun_host, ':');
+	    if (str_port.ptr != NULL) {
+		str_host.ptr = pjsua_var.ua_cfg.stun_host.ptr;
+		str_host.slen = (str_port.ptr - str_host.ptr);
+		str_port.ptr++;
+		str_port.slen = pjsua_var.ua_cfg.stun_host.slen - 
+				str_host.slen - 1;
+		port = (int)pj_strtoul(&str_port);
+		if (port < 1 || port > 65535) {
+		    pjsua_perror(THIS_FILE, "Invalid STUN server", PJ_EINVAL);
+		    pjsua_var.stun_status = PJ_EINVAL;
+		    return pjsua_var.stun_status;
+		}
+	    } else {
+		str_host = pjsua_var.ua_cfg.stun_host;
+		port = 3478;
+	    }
+
+
+	    pjsua_var.stun_status = pj_gethostbyname(&str_host, &he);
 
 	    if (pjsua_var.stun_status == PJ_SUCCESS) {
 		pj_sockaddr_in_init(&pjsua_var.stun_srv.ipv4, NULL, 0);
 		pjsua_var.stun_srv.ipv4.sin_addr = *(pj_in_addr*)he.h_addr;
-		pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)3478);
+		pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)port);
 
 		PJ_LOG(3,(THIS_FILE, 
@@ -1056,6 +1097,6 @@
 	 */
 	status = pjstun_get_mapped_addr(&pjsua_var.cp.factory, 1, &sock,
-				         &stun_srv, 3478,
-					 &stun_srv, 3478,
+				         &stun_srv, pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port),
+					 &stun_srv, pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port),
 				         p_pub_addr);
 	if (status != PJ_SUCCESS) {
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1183)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1184)
@@ -290,6 +290,6 @@
 
 	    status=pjstun_get_mapped_addr(&pjsua_var.cp.factory, 2, sock,
-					   &stun_srv, 3478,
-					   &stun_srv, 3478,
+					   &stun_srv, pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port),
+					   &stun_srv, pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port),
 					   mapped_addr);
 	    if (status != PJ_SUCCESS) {
