- Timestamp:
- May 13, 2016 10:56:48 AM (9 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r5283 r5297 1582 1582 * start if it fails to resolve or contact any of the STUN servers. 1583 1583 * 1584 * This setting will also determine what happens if STUN servers are 1585 * unavailable during runtime (if set to PJ_FALSE, calls will 1586 * directly fail, otherwise (if PJ_TRUE) call medias will 1587 * fallback to proceed as though not using STUN servers. 1588 * 1584 1589 * Default: PJ_TRUE 1585 1590 */ … … 2083 2088 */ 2084 2089 PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type); 2090 2091 2092 /** 2093 * Update the STUN servers list. The #pjsua_init() must have been called 2094 * before calling this function. 2095 * 2096 * @param count Number of STUN server entries. 2097 * @param srv Array of STUN server entries to try. Please see 2098 * the \a stun_srv field in the #pjsua_config 2099 * documentation about the format of this entry. 2100 * @param wait Specify non-zero to make the function block until 2101 * it gets the result. In this case, the function 2102 * will block while the resolution is being done, 2103 * and the callback will be called before this function 2104 * returns. 2105 * 2106 * @return If \a wait parameter is non-zero, this will return 2107 * PJ_SUCCESS if one usable STUN server is found. 2108 * Otherwise it will always return PJ_SUCCESS, and 2109 * application will be notified about the result in 2110 * the callback #on_stun_resolution_complete. 2111 */ 2112 PJ_DECL(pj_status_t) pjsua_update_stun_servers(unsigned count, pj_str_t srv[], 2113 pj_bool_t wait); 2085 2114 2086 2115 … … 2723 2752 * this setting has no effect. 2724 2753 */ 2725 PJSUA_STUN_USE_DISABLED 2754 PJSUA_STUN_USE_DISABLED, 2755 2756 /** 2757 * Retry other STUN servers if the STUN server selected during 2758 * startup (#pjsua_init()) or after calling #pjsua_update_stun_servers() 2759 * is unavailable during runtime. This setting is valid only for 2760 * account's media STUN setting and if the call is using UDP media 2761 * transport. 2762 */ 2763 PJSUA_STUN_RETRY_ON_FAILURE 2726 2764 2727 2765 } pjsua_stun_use; -
pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp
r5278 r5297 903 903 */ 904 904 pj_stun_nat_type natGetType() throw(Error); 905 906 /** 907 * Update the STUN servers list. The libInit() must have been called 908 * before calling this function. 909 * 910 * @param prmServers Array of STUN servers to try. The endpoint 911 * will try to resolve and contact each of the 912 * STUN server entry until it finds one that is 913 * usable. Each entry may be a domain name, host 914 * name, IP address, and it may contain an 915 * optional port number. For example: 916 * - "pjsip.org" (domain name) 917 * - "sip.pjsip.org" (host name) 918 * - "pjsip.org:33478" (domain name and a non- 919 * standard port number) 920 * - "10.0.0.1:3478" (IP address and port number) 921 * @param prmWait Specify if the function should block until 922 * it gets the result. In this case, the 923 * function will block while the resolution 924 * is being done, and the callback 925 * onNatCheckStunServersComplete() will be called 926 * before this function returns. 927 * 928 */ 929 void natUpdateStunServers(const StringVector &prmServers, 930 bool prmWait) throw(Error); 905 931 906 932 /** … … 1190 1216 * Callback when the Endpoint has finished performing STUN server 1191 1217 * checking that is initiated when calling libInit(), or by 1192 * calling natCheckStunServers() .1218 * calling natCheckStunServers() or natUpdateStunServers(). 1193 1219 * 1194 1220 * @param prm Callback parameters. -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r5283 r5297 1377 1377 1378 1378 /* 1379 * Update STUN servers. 1380 */ 1381 PJ_DEF(pj_status_t) pjsua_update_stun_servers(unsigned count, pj_str_t srv[], 1382 pj_bool_t wait) 1383 { 1384 unsigned i; 1385 pj_status_t status; 1386 1387 PJ_ASSERT_RETURN(count && srv, PJ_EINVAL); 1388 1389 PJSUA_LOCK(); 1390 1391 pjsua_var.ua_cfg.stun_srv_cnt = count; 1392 for (i = 0; i < count; i++) { 1393 if (pj_strcmp(&pjsua_var.ua_cfg.stun_srv[i], &srv[i])) 1394 pj_strdup(pjsua_var.pool, &pjsua_var.ua_cfg.stun_srv[i], &srv[i]); 1395 } 1396 pjsua_var.stun_status = PJ_EUNKNOWN; 1397 1398 status = resolve_stun_server(wait); 1399 if (wait == PJ_FALSE && status == PJ_EPENDING) 1400 status = PJ_SUCCESS; 1401 1402 PJSUA_UNLOCK(); 1403 1404 return status; 1405 } 1406 1407 1408 /* 1379 1409 * Resolve STUN server. 1380 1410 */ … … 1482 1512 /* Perform NAT type detection if not yet */ 1483 1513 if (pjsua_var.nat_type == PJ_STUN_NAT_TYPE_UNKNOWN && 1514 !pjsua_var.nat_in_progress && 1484 1515 pjsua_var.ua_cfg.nat_type_in_sdp) 1485 1516 { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r5283 r5297 390 390 else 391 391 #endif 392 393 if (status != PJ_SUCCESS && pjsua_var.ua_cfg.stun_srv_cnt > 1 && 394 ((acc->cfg.media_stun_use & PJSUA_STUN_RETRY_ON_FAILURE)!=0)) 395 { 396 PJ_LOG(4,(THIS_FILE, "Failed to get STUN mapped address, " 397 "retrying other STUN servers")); 398 status=pjsua_update_stun_servers(pjsua_var.ua_cfg.stun_srv_cnt, 399 pjsua_var.ua_cfg.stun_srv, 400 PJ_TRUE); 401 if (status == PJ_SUCCESS) { 402 if (pjsua_var.stun_srv.addr.sa_family != 0) { 403 pj_ansi_strcpy(ip_addr, 404 pj_inet_ntoa(pjsua_var.stun_srv.ipv4.sin_addr)); 405 stun_srv = pj_str(ip_addr); 406 } else { 407 stun_srv.slen = 0; 408 } 409 410 stun_opt.srv1 = stun_opt.srv2 = stun_srv; 411 stun_opt.port1 = stun_opt.port2 = 412 pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port); 413 status = pjstun_get_mapped_addr2(&pjsua_var.cp.factory, 414 &stun_opt, 2, sock, 415 resolved_addr); 416 } 417 } 418 392 419 if (status != PJ_SUCCESS) { 393 420 if (!pjsua_var.ua_cfg.stun_ignore_failure) { -
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5288 r5297 1562 1562 } 1563 1563 1564 void Endpoint::natUpdateStunServers(const StringVector &servers, 1565 bool wait) throw(Error) 1566 { 1567 pj_str_t srv[MAX_STUN_SERVERS]; 1568 unsigned i, count = 0; 1569 1570 for (i=0; i<servers.size() && i<MAX_STUN_SERVERS; ++i) { 1571 srv[count].ptr = (char*)servers[i].c_str(); 1572 srv[count].slen = servers[i].size(); 1573 ++count; 1574 } 1575 1576 PJSUA2_CHECK_EXPR(pjsua_update_stun_servers(count, srv, wait) ); 1577 } 1578 1564 1579 void Endpoint::natCheckStunServers(const StringVector &servers, 1565 1580 bool wait,
Note: See TracChangeset
for help on using the changeset viewer.