Changeset 1135


Ignore:
Timestamp:
Apr 2, 2007 8:43:06 PM (17 years ago)
Author:
bennylp
Message:

Added pjsua_dump(), and fix STUN DNS SRV resolution error in pjsua

Location:
pjproject/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r1127 r1135  
    13181318static void app_dump(pj_bool_t detail) 
    13191319{ 
    1320     unsigned old_decor; 
    1321     char buf[1024]; 
    1322  
    1323     PJ_LOG(3,(THIS_FILE, "Start dumping application states:")); 
    1324  
    1325     old_decor = pj_log_get_decor(); 
    1326     pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR)); 
    1327  
    1328     if (detail) 
    1329         pj_dump_config(); 
    1330  
    1331     pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail); 
    1332     pjmedia_endpt_dump(pjsua_get_pjmedia_endpt()); 
    1333     pjsip_tsx_layer_dump(detail); 
    1334     pjsip_ua_dump(detail); 
    1335  
    1336  
    1337     /* Dump all invite sessions: */ 
    1338     PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:")); 
    1339  
    1340     if (pjsua_call_get_count() == 0) { 
    1341  
    1342         PJ_LOG(3,(THIS_FILE, "  - no sessions -")); 
    1343  
    1344     } else { 
    1345         unsigned i; 
    1346  
    1347         for (i=0; i<app_config.cfg.max_calls; ++i) { 
    1348             if (pjsua_call_is_active(i)) { 
    1349                 pjsua_call_dump(i, detail, buf, sizeof(buf), "  "); 
    1350                 PJ_LOG(3,(THIS_FILE, "%s", buf)); 
    1351             } 
    1352         } 
    1353     } 
    1354  
    1355     /* Dump presence status */ 
    1356     pjsua_pres_dump(detail); 
    1357  
    1358     pj_log_set_decor(old_decor); 
    1359     PJ_LOG(3,(THIS_FILE, "Dump complete")); 
     1320    pjsua_dump(detail); 
    13601321} 
    13611322 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r1127 r1135  
    13281328 
    13291329 
    1330  
     1330/** 
     1331 * This is a utility function to dump the stack states to log, using 
     1332 * verbosity level 3. 
     1333 * 
     1334 * @param detail        Will print detailed output (such as list of 
     1335 *                      SIP transactions) when non-zero. 
     1336 */ 
     1337PJ_DECL(void) pjsua_dump(pj_bool_t detail); 
    13311338 
    13321339/** 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r1134 r1135  
    744744        if (pjsua_var.ua_cfg.stun_domain.slen) { 
    745745            pj_str_t res_type; 
     746            pj_status_t status; 
    746747 
    747748            /* Fail if resolver is not configured */ 
     
    753754            } 
    754755            res_type = pj_str("_stun._udp"); 
    755             pjsua_var.stun_status =  
     756            status =  
    756757                pj_dns_srv_resolve(&pjsua_var.ua_cfg.stun_domain, &res_type, 
    757758                                   3478, pjsua_var.pool, pjsua_var.resolver, 
    758                                    0, NULL, stun_dns_srv_resolver_cb); 
    759             if (pjsua_var.stun_status != PJ_SUCCESS) { 
     759                                   0, NULL, &stun_dns_srv_resolver_cb); 
     760            if (status != PJ_SUCCESS) { 
    760761                pjsua_perror(THIS_FILE, "Error starting DNS SRV resolution",  
    761762                             pjsua_var.stun_status); 
     763                pjsua_var.stun_status = status; 
    762764                return pjsua_var.stun_status; 
     765            } else { 
     766                pjsua_var.stun_status = PJ_EPENDING; 
    763767            } 
    764768        } 
     
    16911695    return p ? 0 : -1; 
    16921696} 
     1697 
     1698 
     1699/* 
     1700 * This is a utility function to dump the stack states to log, using 
     1701 * verbosity level 3. 
     1702 */ 
     1703PJ_DEF(void) pjsua_dump(pj_bool_t detail) 
     1704{ 
     1705    unsigned old_decor; 
     1706    unsigned i; 
     1707    char buf[1024]; 
     1708 
     1709    PJ_LOG(3,(THIS_FILE, "Start dumping application states:")); 
     1710 
     1711    old_decor = pj_log_get_decor(); 
     1712    pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR)); 
     1713 
     1714    if (detail) 
     1715        pj_dump_config(); 
     1716 
     1717    pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail); 
     1718 
     1719    pjmedia_endpt_dump(pjsua_get_pjmedia_endpt()); 
     1720 
     1721    PJ_LOG(3,(THIS_FILE, "Dumping media transports:")); 
     1722    for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) { 
     1723        pjsua_call *call = &pjsua_var.calls[i]; 
     1724        pjmedia_sock_info skinfo; 
     1725 
     1726        pjmedia_transport_get_info(call->med_tp, &skinfo); 
     1727 
     1728        PJ_LOG(3,(THIS_FILE, " %s: %s:%d", 
     1729                  (pjsua_var.media_cfg.enable_ice ? "ICE" : "UDP"), 
     1730                  pj_inet_ntoa(skinfo.rtp_addr_name.sin_addr), 
     1731                  (int)pj_ntohs(skinfo.rtp_addr_name.sin_port))); 
     1732    } 
     1733 
     1734    pjsip_tsx_layer_dump(detail); 
     1735    pjsip_ua_dump(detail); 
     1736 
     1737 
     1738    /* Dump all invite sessions: */ 
     1739    PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:")); 
     1740 
     1741    if (pjsua_call_get_count() == 0) { 
     1742 
     1743        PJ_LOG(3,(THIS_FILE, "  - no sessions -")); 
     1744 
     1745    } else { 
     1746        unsigned i; 
     1747 
     1748        for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) { 
     1749            if (pjsua_call_is_active(i)) { 
     1750                pjsua_call_dump(i, detail, buf, sizeof(buf), "  "); 
     1751                PJ_LOG(3,(THIS_FILE, "%s", buf)); 
     1752            } 
     1753        } 
     1754    } 
     1755 
     1756    /* Dump presence status */ 
     1757    pjsua_pres_dump(detail); 
     1758 
     1759    pj_log_set_decor(old_decor); 
     1760    PJ_LOG(3,(THIS_FILE, "Dump complete")); 
     1761} 
     1762 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r1134 r1135  
    557557    pj_sockaddr_in addr; 
    558558    pj_status_t status; 
     559 
     560    /* Make sure STUN server resolution has completed */ 
     561    status = pjsua_resolve_stun_server(PJ_TRUE); 
     562    if (status != PJ_SUCCESS) { 
     563        pjsua_perror(THIS_FILE, "Error resolving STUN server", status); 
     564        return status; 
     565    } 
    559566 
    560567    pj_sockaddr_in_init(&addr, 0, (pj_uint16_t)cfg->port); 
Note: See TracChangeset for help on using the changeset viewer.