linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Linphone-developers] Set call duration!


From: bilal khan
Subject: Re: [Linphone-developers] Set call duration!
Date: Wed, 28 Oct 2015 10:44:57 +0000 (UTC)

Hi Sylvain,

I might be using old version of liblinphone that's why I could not find call->log->connected_date_time = ms_time(NULL); statement in linphone_call_set_state method of linphonecall.c.

linphone_call_set_state method looks like:

void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const char *message){
    LinphoneCore *lc=call->core;

    if (call->state!=cstate){
        call->prevstate=call->state;
        if (call->state==LinphoneCallEnd || call->state==LinphoneCallError){
            if (cstate!=LinphoneCallReleased){
                ms_warning("Spurious call state change from %s to %s, ignored.",linphone_call_state_to_string(call->state),
                   linphone_call_state_to_string(cstate));
                return;
            }
        }

        ms_message("Call %p: moving from state %s to %s",call,linphone_call_state_to_string(call->state),
                               linphone_call_state_to_string(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){
            switch(call->reason){
                case LinphoneReasonDeclined:
                    call->log->status=LinphoneCallDeclined;
                    break;
                case LinphoneReasonNotAnswered:
                    call->log->status=LinphoneCallMissed;
                break;
                default:
                break;
            }
            linphone_call_set_terminated(call);
        }
        if (cstate == LinphoneCallConnected) {
            if (ms_list_size(lc->calls)==1){
                LinphonePresenceModel *model;
                /*there were no call, and now there is a call, send an on-the-phone presence notification automatically*/
                model = linphone_presence_model_new_with_activity(LinphonePresenceActivityOnThePhone, NULL);
                linphone_core_send_presence(call->core,model);
                linphone_presence_model_unref(model);
            }
            call->log->status=LinphoneCallSuccess;
            call->media_start_time=time(NULL);
        }
       //  isTimeSet is global variable of type bool_t, initialized with FALSE
        if (cstate == LinphoneCallStreamsRunning) {
            if(isTimeSet == FALSE) {
                call->media_start_time=time(NULL);
                call->start_time = time(NULL);
                isTimeSet = TRUE;
            }
        }


        if (lc->vtable.call_state_changed)
            lc->vtable.call_state_changed(lc,call,cstate,message);
        if (cstate==LinphoneCallReleased){
            if (call->op!=NULL) {
                /* so that we cannot have anymore upcalls for SAL
                 concerning this call*/
                sal_op_release(call->op);
                call->op=NULL;
            }
            /*it is necessary to reset pointers to other call to prevent circular references that would result in memory never freed.*/
            if (call->referer){
                linphone_call_unref(call->referer);
                call->referer=NULL;
            }
            if (call->transfer_target){
                linphone_call_unref(call->transfer_target);
                call->transfer_target=NULL;
            }
            linphone_call_unref(call);
        }
    }
}



In this method, I have injected code highlighted in red color.

I just want to make sure if I am doing it in right way?

Thanks in advance.
 
Bilal Baloch
Software Engineer
+46-760-604756



On Tuesday, October 27, 2015 5:11 PM, Sylvain Berfini <address@hidden> wrote:


Hi Bilal,

Yes it would work because the call time is stored in it's matching call log (even while the call is running).

Cheers.
Sylvain Berfini
Software Engineer @ Belledonne Communications
Le 27/10/2015 16:55, bilal khan a écrit :
Hi Sylvain

Thank you so much for your quick response. In call history page, how I fix real call time for all calls? Would the above solution work for it.

Thanks in advance.
 
Bilal Baloch
 Software Engineer 
+46-760-604756



On Tuesday, October 27, 2015 3:28 PM, Sylvain Berfini <address@hidden> wrote:


Hi Bilal,

In coreapi/linphonecall.c, in the method linphone_call_set_state, you'll see a call->log->connected_date_time = ms_time(NULL) for the state LinphoneCallConnected.
If you move/copy this statement into the LinphoneCallStreamsRunning, the getDuration() method will return the time since the call has really started.
Beware that a single call can go multiple times through the state LinphoneCallStreamsRunning!

If you don't want to touch the source code, you can always store somewhere the time difference between the first time your call went into LinphoneCallStreamsRunning state and the getDuration() value at this time, and then always substract this value to the getDuration() result...

Cheers.
Sylvain Berfini
Software Engineer @ Belledonne Communications
Le 27/10/2015 15:10, bilal khan a écrit :
Hi

My name is Bilal, software engineer by profession. I am using Linphone to learn about VOIP technology. 

When SIP call is made, linphone starts counting time even call is not picked yet. I have gone through core lib files and found getDuration() method. Is there any api to set call duration. Actually I want linphone to start count seconds when call is picked excluding the waiting time. 

Any help or way to stairs would highly be appreciated. Thanks

 
Bilal Baloch 
Software Engineer
+46-760-604756


_______________________________________________
Linphone-developers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/linphone-developers


!DSPAM:562f86be17972129964501!


_______________________________________________
Linphone-developers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/linphone-developers


!DSPAM:562f9e7317971999088793!


_______________________________________________ Linphone-developers mailing list address@hidden https://lists.nongnu.org/mailman/listinfo/linphone-developers
!DSPAM:562f9e7317971999088793!


_______________________________________________
Linphone-developers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/linphone-developers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]