summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsua-lib/pjsua_call.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-04-09 16:46:05 +0000
committerBenny Prijono <bennylp@teluu.com>2006-04-09 16:46:05 +0000
commit7c33ce56e9b9399e0f437553102d9a4d612502f7 (patch)
treee783ecf01cb824448a6d9fbf8dc0bef7eee53f78 /pjsip/src/pjsua-lib/pjsua_call.c
parent3cbe17249a51ff90ecb1eac049d2d655229bb6c9 (diff)
Added call duration in pjsua
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@398 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_call.c')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 55976880..b5e32780 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -192,8 +192,13 @@ pj_status_t pjsua_make_call(int acc_index,
return PJ_ETOOMANY;
}
- /* Create outgoing dialog: */
+ /* Mark call start time. */
+ pj_gettimeofday(&pjsua.calls[call_index].start_time);
+
+ /* Reset first response time */
+ pjsua.calls[call_index].res_time.sec = 0;
+ /* Create outgoing dialog: */
status = pjsip_dlg_create_uac( pjsip_ua_instance(),
&pjsua.acc[acc_index].local_uri,
&pjsua.acc[acc_index].contact_uri,
@@ -358,6 +363,11 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
return PJ_TRUE;
}
+ /* Mark call start time. */
+ pj_gettimeofday(&pjsua.calls[call_index].start_time);
+
+ /* Reset first response time */
+ pjsua.calls[call_index].res_time.sec = 0;
/* Get media capability from media endpoint: */
@@ -497,10 +507,28 @@ static void pjsua_call_on_state_changed(pjsip_inv_session *inv,
{
pjsua_call *call = inv->dlg->mod_data[pjsua.mod.id];
+ if (!call)
+ return;
+
+ /* Get call times */
+ switch (inv->state) {
+ case PJSIP_INV_STATE_EARLY:
+ case PJSIP_INV_STATE_CONNECTING:
+ if (call->res_time.sec == 0)
+ pj_gettimeofday(&call->res_time);
+ break;
+ case PJSIP_INV_STATE_CONFIRMED:
+ pj_gettimeofday(&call->conn_time);
+ break;
+ case PJSIP_INV_STATE_DISCONNECTED:
+ pj_gettimeofday(&call->dis_time);
+ break;
+ }
+
/* If this is an outgoing INVITE that was created because of
* REFER/transfer, send NOTIFY to transferer.
*/
- if (call && call->xfer_sub && e->type==PJSIP_EVENT_TSX_STATE) {
+ if (call->xfer_sub && e->type==PJSIP_EVENT_TSX_STATE) {
int st_code = -1;
pjsip_evsub_state ev_state = PJSIP_EVSUB_STATE_ACTIVE;