summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-11-25 14:50:25 +0000
committerBenny Prijono <bennylp@teluu.com>2006-11-25 14:50:25 +0000
commit0bda7ac4e953db4a1c6dc1fff1d2c0959ee81ebb (patch)
tree86acf0170dfef8b3adbf2561c72b978261ac0ee1
parent3db966e7ebb20d9bb51cdb3a3b6d1993984ab547 (diff)
Print media statistic when call is disconnected in pjsua, to assist tracing media problems
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@831 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib/src/pj/config.c2
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c38
-rw-r--r--pjsip/src/pjsip-ua/sip_inv.c8
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c12
4 files changed, 50 insertions, 10 deletions
diff --git a/pjlib/src/pj/config.c b/pjlib/src/pj/config.c
index 75eb314e..ed657dff 100644
--- a/pjlib/src/pj/config.c
+++ b/pjlib/src/pj/config.c
@@ -21,7 +21,7 @@
#include <pj/ioqueue.h>
static const char *id = "config.c";
-const char *PJ_VERSION = "0.5.8.5";
+const char *PJ_VERSION = "0.5.8.9";
PJ_DEF(void) pj_dump_config(void)
{
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 94dfa548..f79bf6f9 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -1327,6 +1327,16 @@ static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
find_next_call();
}
+ /* Dump media state upon disconnected */
+ if (1) {
+ char buf[1024];
+ pjsua_call_dump(call_id, PJ_TRUE, buf,
+ sizeof(buf), " ");
+ PJ_LOG(5,(THIS_FILE,
+ "Call %d disconnected, dumping media stats\n%s",
+ call_id, buf));
+ }
+
} else {
if (app_config.duration!=NO_LIMIT &&
@@ -1343,9 +1353,31 @@ static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
pjsip_endpt_schedule_timer(endpt, &cd->timer, &delay);
}
- PJ_LOG(3,(THIS_FILE, "Call %d state changed to %s",
- call_id,
- call_info.state_text.ptr));
+ if (call_info.state == PJSIP_INV_STATE_EARLY) {
+ int code;
+ pj_str_t reason;
+ pjsip_msg *msg;
+
+ /* This can only occur because of TX or RX message */
+ pj_assert(e->type == PJSIP_EVENT_TSX_STATE);
+
+ if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) {
+ msg = e->body.tsx_state.src.rdata->msg_info.msg;
+ } else {
+ msg = e->body.tsx_state.src.tdata->msg;
+ }
+
+ code = msg->line.status.code;
+ reason = msg->line.status.reason;
+
+ PJ_LOG(3,(THIS_FILE, "Call %d state changed to %s (%d %.*s)",
+ call_id, call_info.state_text.ptr,
+ code, (int)reason.slen, reason.ptr));
+ } else {
+ PJ_LOG(3,(THIS_FILE, "Call %d state changed to %s",
+ call_id,
+ call_info.state_text.ptr));
+ }
if (current_call==PJSUA_INVALID_ID)
current_call = call_id;
diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c
index 8c6b4ccd..b6215d4b 100644
--- a/pjsip/src/pjsip-ua/sip_inv.c
+++ b/pjsip/src/pjsip-ua/sip_inv.c
@@ -35,10 +35,10 @@
static const char *inv_state_names[] =
{
- "NULL ",
- "CALLING ",
- "INCOMING ",
- "EARLY ",
+ "NULL",
+ "CALLING",
+ "INCOMING",
+ "EARLY",
"CONNECTING",
"CONFIRMED ",
"DISCONNCTD",
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index d5530570..679bc6fd 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -90,6 +90,10 @@ static void reset_call(pjsua_call_id id)
call->conf_slot = PJSUA_INVALID_ID;
call->last_text.ptr = call->last_text_buf_;
call->last_text.slen = 0;
+ call->conn_time.sec = 0;
+ call->conn_time.msec = 0;
+ call->res_time.sec = 0;
+ call->res_time.msec = 0;
}
@@ -1776,7 +1780,7 @@ PJ_DEF(pj_status_t) pjsua_call_dump( pjsua_call_id call_id,
*p++ = '\n';
/* Calculate call duration */
- if (call->inv->state >= PJSIP_INV_STATE_CONFIRMED) {
+ if (call->conn_time.sec != 0) {
pj_gettimeofday(&duration);
PJ_TIME_VAL_SUB(duration, call->conn_time);
con_delay = call->conn_time;
@@ -1787,7 +1791,7 @@ PJ_DEF(pj_status_t) pjsua_call_dump( pjsua_call_id call_id,
}
/* Calculate first response delay */
- if (call->inv->state >= PJSIP_INV_STATE_EARLY) {
+ if (call->res_time.sec != 0) {
res_delay = call->res_time;
PJ_TIME_VAL_SUB(res_delay, call->start_time);
} else {
@@ -1976,6 +1980,10 @@ static void pjsua_call_on_state_changed(pjsip_inv_session *inv,
/* Free call */
call->inv = NULL;
--pjsua_var.call_cnt;
+
+ /* Reset call */
+ reset_call(call->index);
+
}
PJSUA_UNLOCK();