Search code examples
csippjsippjsua2

Detecting end off a call PJSIP


I am writing an application on Ubuntu 16.04 with PJSUA/PJSIP.
I need to detect when a call is hanged-up. Is there a sort off call_state() function ?

Thank you !


Solution

  • Found the solution here and here :
    You have to modify the static void on_call_state(pjsua_call_id call_id, pjsip_event *e) function like so :

    /* Callback called by the library when call's state has changed */
    static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
    {
        pjsua_call_info ci;
    
        PJ_UNUSED_ARG(e);
    
        pjsua_call_get_info(call_id, &ci);
        PJ_LOG(3,(THIS_FILE, "Call %d state=%.*s", call_id,
                 (int)ci.state_text.slen,
                 ci.state_text.ptr));
    
    
        if (ci.state == PJSIP_INV_STATE_DISCONNECTED) { 
    
            /*YOUR CODE HERE*/
    
        }
    }