]> sjero.net Git - linphone/blobdiff - coreapi/linphonecall.c
multicall support in gtk interface
[linphone] / coreapi / linphonecall.c
index b5c3e8e9405bfeafbb53948d2f827112353f45f4..3244aac7edfb801cf3f8814200f0baa27ade3c88 100644 (file)
@@ -229,17 +229,23 @@ static void linphone_call_set_terminated(LinphoneCall *call){
 
 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)
@@ -369,6 +375,14 @@ bool_t linphone_call_has_transfer_pending(const LinphoneCall *call){
        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;
+}
+
 /**
  * @}
 **/