如何获得pjsip iOS API调用状态,如忙碌,响铃或不可用

时间:2015-03-29 11:56:02

标签: ios sip voip pjsip

我能够将pjsip集成并连接到iOS,但我希望在调用期间和初始化时获得不同的状态,如busy,ringing和un reachable。为了创建呼叫,我使用此代码

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

但我找不到如何获得不同的通话状态..

1 个答案:

答案 0 :(得分:2)

这是一个简单但令人困惑的程序

有一个静态方法

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