检测结束通话 PJSIP

Detecting end off a call PJSIP

我正在使用 PJSUA/PJSIP 在 Ubuntu 16.04 上编写应用程序。
我需要检测呼叫何时挂断。是否有排序 call_state() 功能?

谢谢!

找到解决方案 here and here :
您必须像这样修改 static void on_call_state(pjsua_call_id call_id, pjsip_event *e) 函数:

/* 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*/

    }
}