如何获取 pjsip iOS API 呼叫状态,如占线、正在响铃或不可用

How to get pjsip iOS API call status like busy, ringing or not available

我能够将 pjsip 集成并连接到 iOS,但我想在通话初始化期间获得不同的状态,例如占线、正在响铃和无法接通。为了创建呼叫,我正在使用此代码

void makeCall(char* destUri)
{
    pj_status_t status;
    pj_str_t uri = pj_str(destUri);

    status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL);
    if (status != PJ_SUCCESS) error_exit("Error making call", status);
} 

但我没有找到任何如何获得不同呼叫状态的地方..

程序简单但令人困惑

有一个静态方法

static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, pjsip_rx_data *rdata);

然后进入你的 pjusa_config 设置为

// Init the config structure
        pjsua_config cfg;
        cfg.cb.on_call_state = &on_call_state;

那么你会在这里收到回调

/* 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));
}