summaryrefslogtreecommitdiff
path: root/pjsip-apps
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2008-07-17 14:54:03 +0000
committerNanang Izzuddin <nanang@teluu.com>2008-07-17 14:54:03 +0000
commit322986cdc4140ab97c1eb0a1a2500e28b66398b6 (patch)
treea24d744d6c8ac7021fb7f6c5a8651fd7bb06149d /pjsip-apps
parentb51b8659c27905c821d70db79d90daa2e7553b3d (diff)
Added ability to dump extended statistics (RTCP XR) in pjsua.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2152 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps')
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index de9c736e..b2b2e76c 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -127,7 +127,7 @@ static const char *stdout_refresh_text = "STDOUT_REFRESH";
static pj_bool_t stdout_refresh_quit = PJ_FALSE;
static pj_str_t uri_arg;
-static char some_buf[2048];
+static char some_buf[1024 * 3];
#ifdef STEREO_DEMO
static void stereo_demo();
@@ -1762,6 +1762,42 @@ static void app_dump(pj_bool_t detail)
pjsua_dump(detail);
}
+/*
+ * Print log of call states. Since call states may be too long for logger,
+ * printing it is a bit tricky, it should be printed part by part as long
+ * as the logger can accept.
+ */
+static void log_call_dump(int call_id) {
+ unsigned call_dump_len;
+ unsigned part_len;
+ unsigned part_idx;
+ unsigned log_decor;
+
+ pjsua_call_dump(call_id, PJ_TRUE, some_buf,
+ sizeof(some_buf), " ");
+ call_dump_len = strlen(some_buf);
+
+ log_decor = pj_log_get_decor();
+ pj_log_set_decor(log_decor & ~(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR));
+ PJ_LOG(3,(THIS_FILE, "\n"));
+ pj_log_set_decor(0);
+
+ part_idx = 0;
+ part_len = PJ_LOG_MAX_SIZE-80;
+ while (part_idx < call_dump_len) {
+ char p_orig, *p;
+
+ p = &some_buf[part_idx];
+ if (part_idx + part_len > call_dump_len)
+ part_len = call_dump_len - part_idx;
+ p_orig = p[part_len];
+ p[part_len] = '\0';
+ PJ_LOG(3,(THIS_FILE, "%s", p));
+ p[part_len] = p_orig;
+ part_idx += part_len;
+ }
+ pj_log_set_decor(log_decor);
+}
/*****************************************************************************
* Console application
@@ -1962,11 +1998,10 @@ static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
/* Dump media state upon disconnected */
if (1) {
- pjsua_call_dump(call_id, PJ_TRUE, some_buf,
- sizeof(some_buf), " ");
PJ_LOG(5,(THIS_FILE,
- "Call %d disconnected, dumping media stats\n%s",
- call_id, some_buf));
+ "Call %d disconnected, dumping media stats..",
+ call_id));
+ log_call_dump(call_id);
}
} else {
@@ -3719,9 +3754,7 @@ void console_app_main(const pj_str_t *uri_to_call)
} else if (menuin[1] == 'q') {
if (current_call != PJSUA_INVALID_ID) {
- pjsua_call_dump(current_call, PJ_TRUE, some_buf,
- sizeof(some_buf), " ");
- PJ_LOG(3,(THIS_FILE, "\n%s", some_buf));
+ log_call_dump(current_call);
} else {
PJ_LOG(3,(THIS_FILE, "No current call"));
}