void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const char *message){
LinphoneCore *lc=call->core;
+ bool_t finalize_call=FALSE;
if (call->state!=cstate){
if (cstate!=LinphoneCallRefered){
/*LinphoneCallRefered is rather an event, not a state.
Indeed it does not change the state of the call (still paused or running)*/
call->state=cstate;
}
+ if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){
+ finalize_call=TRUE;
+ linphone_call_ref(call);
+ linphone_call_set_terminated (call);
+ }
if (lc->vtable.call_state_changed)
lc->vtable.call_state_changed(lc,call,cstate,message);
+ if (finalize_call)
+ linphone_call_unref(call);
}
- if (call->state==LinphoneCallEnd || call->state==LinphoneCallError)
- linphone_call_set_terminated (call);
}
static void linphone_call_destroy(LinphoneCall *obj)
return call->refer_pending;
}
+/**
+ * Returns call's duration in seconds.
+**/
+int linphone_call_get_duration(const LinphoneCall *call){
+ if (call->media_start_time==0) return 0;
+ return time(NULL)-call->media_start_time;
+}
+
/**
* @}
**/