summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-04-02 20:43:06 +0000
committerBenny Prijono <bennylp@teluu.com>2007-04-02 20:43:06 +0000
commit11af5d6767e0dcbc4884fb66209428cb6c5c352c (patch)
tree7496129de5035bcc9efd47e52ed0387c7e961e78 /pjsip
parent7e0fee875ce0f5eaaba5e67e84539ebf6bf79a6f (diff)
Added pjsua_dump(), and fix STUN DNS SRV resolution error in pjsua
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1135 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h9
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c76
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c7
3 files changed, 88 insertions, 4 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index b6ba7d53..76a27d33 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -1327,7 +1327,14 @@ PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
pj_status_t status);
-
+/**
+ * This is a utility function to dump the stack states to log, using
+ * verbosity level 3.
+ *
+ * @param detail Will print detailed output (such as list of
+ * SIP transactions) when non-zero.
+ */
+PJ_DECL(void) pjsua_dump(pj_bool_t detail);
/**
* @}
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 477f5ce9..81723484 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -743,6 +743,7 @@ pj_status_t pjsua_resolve_stun_server(pj_bool_t wait)
*/
if (pjsua_var.ua_cfg.stun_domain.slen) {
pj_str_t res_type;
+ pj_status_t status;
/* Fail if resolver is not configured */
if (pjsua_var.resolver == NULL) {
@@ -752,14 +753,17 @@ pj_status_t pjsua_resolve_stun_server(pj_bool_t wait)
return PJLIB_UTIL_EDNSNONS;
}
res_type = pj_str("_stun._udp");
- pjsua_var.stun_status =
+ status =
pj_dns_srv_resolve(&pjsua_var.ua_cfg.stun_domain, &res_type,
3478, pjsua_var.pool, pjsua_var.resolver,
- 0, NULL, stun_dns_srv_resolver_cb);
- if (pjsua_var.stun_status != PJ_SUCCESS) {
+ 0, NULL, &stun_dns_srv_resolver_cb);
+ if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error starting DNS SRV resolution",
pjsua_var.stun_status);
+ pjsua_var.stun_status = status;
return pjsua_var.stun_status;
+ } else {
+ pjsua_var.stun_status = PJ_EPENDING;
}
}
/* Otherwise if stun_host is specified, resolve STUN server with
@@ -1690,3 +1694,69 @@ PJ_DEF(pj_status_t) pjsua_verify_sip_url(const char *c_url)
pj_pool_release(pool);
return p ? 0 : -1;
}
+
+
+/*
+ * This is a utility function to dump the stack states to log, using
+ * verbosity level 3.
+ */
+PJ_DEF(void) pjsua_dump(pj_bool_t detail)
+{
+ unsigned old_decor;
+ unsigned i;
+ char buf[1024];
+
+ PJ_LOG(3,(THIS_FILE, "Start dumping application states:"));
+
+ old_decor = pj_log_get_decor();
+ pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR));
+
+ if (detail)
+ pj_dump_config();
+
+ pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail);
+
+ pjmedia_endpt_dump(pjsua_get_pjmedia_endpt());
+
+ PJ_LOG(3,(THIS_FILE, "Dumping media transports:"));
+ for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) {
+ pjsua_call *call = &pjsua_var.calls[i];
+ pjmedia_sock_info skinfo;
+
+ pjmedia_transport_get_info(call->med_tp, &skinfo);
+
+ PJ_LOG(3,(THIS_FILE, " %s: %s:%d",
+ (pjsua_var.media_cfg.enable_ice ? "ICE" : "UDP"),
+ pj_inet_ntoa(skinfo.rtp_addr_name.sin_addr),
+ (int)pj_ntohs(skinfo.rtp_addr_name.sin_port)));
+ }
+
+ pjsip_tsx_layer_dump(detail);
+ pjsip_ua_dump(detail);
+
+
+ /* Dump all invite sessions: */
+ PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:"));
+
+ if (pjsua_call_get_count() == 0) {
+
+ PJ_LOG(3,(THIS_FILE, " - no sessions -"));
+
+ } else {
+ unsigned i;
+
+ for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) {
+ if (pjsua_call_is_active(i)) {
+ pjsua_call_dump(i, detail, buf, sizeof(buf), " ");
+ PJ_LOG(3,(THIS_FILE, "%s", buf));
+ }
+ }
+ }
+
+ /* Dump presence status */
+ pjsua_pres_dump(detail);
+
+ pj_log_set_decor(old_decor);
+ PJ_LOG(3,(THIS_FILE, "Dump complete"));
+}
+
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index e4f6ec14..d06f39d1 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -557,6 +557,13 @@ static pj_status_t create_ice_media_transports(pjsua_transport_config *cfg)
pj_sockaddr_in addr;
pj_status_t status;
+ /* Make sure STUN server resolution has completed */
+ status = pjsua_resolve_stun_server(PJ_TRUE);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "Error resolving STUN server", status);
+ return status;
+ }
+
pj_sockaddr_in_init(&addr, 0, (pj_uint16_t)cfg->port);
/* Create each media transport */