Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the pjsip register account at the time of re-registration?

I am working on with pjsip for iOS, I have configured the pjsip and able to register and reregister for specific time interval, but there is a scenario where I want to change the pjsip account details at the time of re register with new details but I havent found anything on google which can guide how to change it.

If someone have a idea about this please guide me through how to change the pjsua_acc_config details at time of re registration, I get the method call at the time of re registration.

static void on_reg_state2(pjsua_acc_id acc_id, pjsua_reg_info *info) {
    PJ_LOG(3,(__FILE__, "%s: Account %d Reason %.*s Status %d code %d CurrentOp %d",
              __FUNCTION__, acc_id, info->cbparam->reason.slen, info->cbparam->reason.ptr,
              info->cbparam->status,info->cbparam->code, info->cbparam->regc));
}
like image 444
Retro Avatar asked Apr 24 '15 07:04

Retro


1 Answers

get account configuration for account id, and set the fields to whatever required in on_reg_state2 function.

if (pjsua_acc_is_valid(acc_id))
 {
    pjsua_acc_set_default(acc_id);
    pjsua_acc_config acc_cfg;
    pj_status_t status;
    pjsua_acc_config_default(&acc_cfg);

    acc_cfg.id = pj_str(id);
    acc_cfg.reg_uri = pj_str(registrar);
    acc_cfg.cred_count = 1;
    acc_cfg.cred_info[0].scheme = pj_str("Digest");
    acc_cfg.cred_info[0].realm = pj_str(realm);
    acc_cfg.cred_info[0].username = pj_str(uname);
    acc_cfg.cred_info[0].data_type = 0;
    acc_cfg.cred_info[0].data = pj_str(passwd);

    acc_cfg.publish_enabled = PJ_TRUE;

  }
like image 151
jkr Avatar answered Sep 20 '22 03:09

jkr