How to change pjsip registry account during re-registration?

I work with pjsip for iOS, I configured pjsip and was able to register and re-register for a certain period of time, but there is a scenario where I want to change pjsip account information during re register with new details, but I did not find anything in google, which can help change it.

If anyone has an idea about this, please help me on how to change pjsua_acc_config data during re-registration, I get a method call during 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)); } 
+7
ios objective-c voip sip pjsip
source share
3 answers

Get the account configuration for the account ID and set the fields to the value required for the 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; } 
+2
source share

This is like registering. delete current account and add new

 if (_sip_acc_id != PJSUA_INVALID_ID){ // pjsua_acc_info info; // pjsua_acc_get_info(_sip_acc_id, &info); // // if (info.has_registration){ pj_status_t statusDelete = pjsua_acc_del(_sip_acc_id); if (statusDelete != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Error removing new account", status); [app displayParameterError: @"Error removing new account."]; } // } } status = pjsua_acc_add(&acc_cfg, PJ_TRUE, &_sip_acc_id); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Error adding new account", status); [app displayParameterError: @"Error adding new account."]; } 
0
source share

This is a PJSIP recommendation guide. You can click this PJSIP link

-one
source share

All Articles