From aad3b7e30bba72ca7dbdbed746c66bb1f3fe0fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 11 Apr 2017 11:13:51 +0200 Subject: [PATCH] Fix bad call duration computation when the call has not passed by the Connected state --- coreapi/linphonecall.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index bd2bcc58f..322ef88d4 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2181,23 +2181,20 @@ bool_t linphone_call_has_transfer_pending(const LinphoneCall *call){ return call->refer_pending; } -static int _linphone_call_get_duration (const LinphoneCall *call) { - return (int)(ms_time(NULL) - call->log->connected_date_time); +static int _linphone_call_compute_duration (const LinphoneCall *call) { + if (call->log->connected_date_time == 0) return 0; + else return (int)(ms_time(NULL) - call->log->connected_date_time); } -int linphone_call_get_duration(const LinphoneCall *call){ - if (call->log->connected_date_time==0) return 0; - +int linphone_call_get_duration(const LinphoneCall *call) { switch (call->state) { case LinphoneCallEnd: case LinphoneCallError: case LinphoneCallReleased: return call->log->duration; - - default: break; + default: + return _linphone_call_compute_duration(call); } - - return _linphone_call_get_duration(call); } LinphoneCall *linphone_call_get_replaced_call(LinphoneCall *call){ @@ -4694,7 +4691,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse void linphone_call_log_completed(LinphoneCall *call){ LinphoneCore *lc=call->core; - call->log->duration=_linphone_call_get_duration(call); /*store duration since connected*/ + call->log->duration= _linphone_call_compute_duration(call); /*store duration since connected*/ call->log->error_info = linphone_error_info_ref((LinphoneErrorInfo*)linphone_call_get_error_info(call)); if (call->log->status==LinphoneCallMissed){