Fixed #1205: Configurable delay before registration refresh setting in pjsua_acc_config
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@3441 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
aa3c0d393f
commit
9b80d51c09
|
@ -1658,6 +1658,7 @@ typedef struct
|
|||
PyObject *force_contact;
|
||||
PyListObject *proxy;
|
||||
unsigned reg_timeout;
|
||||
unsigned reg_delay_before_refresh;
|
||||
PyListObject *cred_info;
|
||||
int transport_id;
|
||||
int auth_initial_send;
|
||||
|
@ -1720,6 +1721,7 @@ static void PyObj_pjsua_acc_config_import(PyObj_pjsua_acc_config *obj,
|
|||
}
|
||||
|
||||
obj->reg_timeout = cfg->reg_timeout;
|
||||
obj->reg_delay_before_refresh = cfg->reg_delay_before_refresh;
|
||||
|
||||
Py_XDECREF(obj->cred_info);
|
||||
obj->cred_info = (PyListObject *)PyList_New(0);
|
||||
|
@ -1776,6 +1778,7 @@ static void PyObj_pjsua_acc_config_export(pjsua_acc_config *cfg,
|
|||
}
|
||||
|
||||
cfg->reg_timeout = obj->reg_timeout;
|
||||
cfg->reg_delay_before_refresh = obj->reg_delay_before_refresh;
|
||||
|
||||
cfg->cred_count = PyList_Size((PyObject*)obj->cred_info);
|
||||
if (cfg->cred_count > PJ_ARRAY_SIZE(cfg->cred_info))
|
||||
|
@ -1898,6 +1901,13 @@ static PyMemberDef PyObj_pjsua_acc_config_members[] =
|
|||
"If the value is zero, default interval will be used "
|
||||
"(PJSUA_REG_INTERVAL, 55 seconds). "
|
||||
},
|
||||
{
|
||||
"reg_delay_before_refresh", T_INT,
|
||||
offsetof(PyObj_pjsua_acc_config, reg_delay_before_refresh), 0,
|
||||
"Specify the number of seconds to refresh the client registration"
|
||||
"before the registration expires."
|
||||
"(PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds). "
|
||||
},
|
||||
{
|
||||
"cred_info", T_OBJECT_EX,
|
||||
offsetof(PyObj_pjsua_acc_config, cred_info), 0,
|
||||
|
|
|
@ -190,6 +190,20 @@ PJ_DECL(pj_status_t) pjsip_regc_init(pjsip_regc *regc,
|
|||
const pj_str_t contact[],
|
||||
pj_uint32_t expires);
|
||||
|
||||
/**
|
||||
* Set the number of seconds to refresh the client registration before
|
||||
* the registration expires.
|
||||
*
|
||||
* @param regc The registration structure.
|
||||
* @param delay The number of seconds to refresh the client
|
||||
* registration before the registration expires.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t)
|
||||
pjsip_regc_set_delay_before_refresh( pjsip_regc *regc,
|
||||
pj_uint32_t delay );
|
||||
|
||||
|
||||
/**
|
||||
* Set authentication credentials to use by this registration.
|
||||
|
|
|
@ -2268,6 +2268,14 @@ typedef struct pjsua_acc_config
|
|||
*/
|
||||
unsigned reg_timeout;
|
||||
|
||||
/**
|
||||
* Specify the number of seconds to refresh the client registration
|
||||
* before the registration expires.
|
||||
*
|
||||
* Default: PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds
|
||||
*/
|
||||
unsigned reg_delay_before_refresh;
|
||||
|
||||
/**
|
||||
* Specify the maximum time to wait for unregistration requests to
|
||||
* complete during library shutdown sequence.
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
|
||||
#define REFRESH_TIMER 1
|
||||
#define DELAY_BEFORE_REFRESH PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH
|
||||
#define DELAY_BEFORE_REFRESH PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH
|
||||
#define THIS_FILE "sip_reg.c"
|
||||
|
||||
/* Outgoing transaction timeout when server sends 100 but never replies
|
||||
|
@ -87,6 +87,7 @@ struct pjsip_regc
|
|||
pjsip_contact_hdr removed_contact_hdr_list;
|
||||
pjsip_expires_hdr *expires_hdr;
|
||||
pj_uint32_t expires;
|
||||
pj_uint32_t delay_before_refresh;
|
||||
pjsip_route_hdr route_set;
|
||||
pjsip_hdr hdr_list;
|
||||
|
||||
|
@ -375,6 +376,7 @@ PJ_DEF(pj_status_t) pjsip_regc_init( pjsip_regc *regc,
|
|||
|
||||
/* Set "Expires" header, if required. */
|
||||
set_expires( regc, expires);
|
||||
regc->delay_before_refresh = DELAY_BEFORE_REFRESH;
|
||||
|
||||
/* Set "Call-ID" header. */
|
||||
regc->cid_hdr = pjsip_cid_hdr_create(regc->pool);
|
||||
|
@ -389,6 +391,15 @@ PJ_DEF(pj_status_t) pjsip_regc_init( pjsip_regc *regc,
|
|||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
PJ_DEF(pj_status_t)
|
||||
pjsip_regc_set_delay_before_refresh( pjsip_regc *regc,
|
||||
pj_uint32_t delay )
|
||||
{
|
||||
PJ_ASSERT_RETURN(regc, PJ_EINVAL);
|
||||
regc->delay_before_refresh = delay;
|
||||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
PJ_DEF(pj_status_t) pjsip_regc_set_credentials( pjsip_regc *regc,
|
||||
int count,
|
||||
const pjsip_cred_info cred[] )
|
||||
|
@ -1119,7 +1130,7 @@ handle_err:
|
|||
if (regc->auto_reg && expiration > 0) {
|
||||
pj_time_val delay = { 0, 0};
|
||||
|
||||
delay.sec = expiration - DELAY_BEFORE_REFRESH;
|
||||
delay.sec = expiration - regc->delay_before_refresh;
|
||||
if (regc->expires != PJSIP_REGC_EXPIRATION_NOT_SPECIFIED &&
|
||||
delay.sec > (pj_int32_t)regc->expires)
|
||||
{
|
||||
|
|
|
@ -99,6 +99,7 @@ PJ_DEF(void) pjsua_acc_config_dup( pj_pool_t *pool,
|
|||
pj_strdup_with_null(pool, &dst->proxy[i], &src->proxy[i]);
|
||||
|
||||
dst->reg_timeout = src->reg_timeout;
|
||||
dst->reg_delay_before_refresh = src->reg_delay_before_refresh;
|
||||
dst->cred_count = src->cred_count;
|
||||
|
||||
for (i=0; i<src->cred_count; ++i) {
|
||||
|
@ -392,11 +393,15 @@ PJ_DEF(pj_status_t) pjsua_acc_add( const pjsua_acc_config *cfg,
|
|||
/* Copy config */
|
||||
pjsua_acc_config_dup(acc->pool, &pjsua_var.acc[id].cfg, cfg);
|
||||
|
||||
/* Normalize registration timeout */
|
||||
if (pjsua_var.acc[id].cfg.reg_uri.slen &&
|
||||
pjsua_var.acc[id].cfg.reg_timeout == 0)
|
||||
{
|
||||
pjsua_var.acc[id].cfg.reg_timeout = PJSUA_REG_INTERVAL;
|
||||
/* Normalize registration timeout and refresh delay */
|
||||
if (pjsua_var.acc[id].cfg.reg_uri.slen) {
|
||||
if (pjsua_var.acc[id].cfg.reg_timeout == 0) {
|
||||
pjsua_var.acc[id].cfg.reg_timeout = PJSUA_REG_INTERVAL;
|
||||
}
|
||||
if (pjsua_var.acc[id].cfg.reg_delay_before_refresh == 0) {
|
||||
pjsua_var.acc[id].cfg.reg_delay_before_refresh =
|
||||
PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get CRC of account proxy setting */
|
||||
|
@ -940,14 +945,22 @@ PJ_DEF(pj_status_t) pjsua_acc_modify( pjsua_acc_id acc_id,
|
|||
|
||||
/* Registration */
|
||||
acc->cfg.reg_timeout = cfg->reg_timeout;
|
||||
acc->cfg.reg_delay_before_refresh = cfg->reg_delay_before_refresh;
|
||||
acc->cfg.unreg_timeout = cfg->unreg_timeout;
|
||||
acc->cfg.allow_contact_rewrite = cfg->allow_contact_rewrite;
|
||||
acc->cfg.reg_retry_interval = cfg->reg_retry_interval;
|
||||
acc->cfg.drop_calls_on_reg_fail = cfg->drop_calls_on_reg_fail;
|
||||
|
||||
/* Normalize registration timeout */
|
||||
if (acc->cfg.reg_uri.slen && acc->cfg.reg_timeout == 0)
|
||||
acc->cfg.reg_timeout = PJSUA_REG_INTERVAL;
|
||||
/* Normalize registration timeout and refresh delay */
|
||||
if (acc->cfg.reg_uri.slen ) {
|
||||
if (acc->cfg.reg_timeout == 0) {
|
||||
acc->cfg.reg_timeout = PJSUA_REG_INTERVAL;
|
||||
}
|
||||
if (acc->cfg.reg_delay_before_refresh == 0) {
|
||||
acc->cfg.reg_delay_before_refresh =
|
||||
PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH;
|
||||
}
|
||||
}
|
||||
|
||||
/* Registrar URI */
|
||||
if (pj_strcmp(&acc->cfg.reg_uri, &cfg->reg_uri)) {
|
||||
|
@ -1816,6 +1829,10 @@ static pj_status_t pjsua_regc_init(int acc_id)
|
|||
pjsip_regc_set_credentials( acc->regc, acc->cred_cnt, acc->cred);
|
||||
}
|
||||
|
||||
/* Set delay before registration refresh */
|
||||
pjsip_regc_set_delay_before_refresh(acc->regc,
|
||||
acc->cfg.reg_delay_before_refresh);
|
||||
|
||||
/* Set authentication preference */
|
||||
pjsip_regc_set_prefs(acc->regc, &acc->cfg.auth_pref);
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
|
|||
pj_bzero(cfg, sizeof(*cfg));
|
||||
|
||||
cfg->reg_timeout = PJSUA_REG_INTERVAL;
|
||||
cfg->reg_delay_before_refresh = PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH;
|
||||
cfg->unreg_timeout = PJSUA_UNREG_TIMEOUT;
|
||||
pjsip_publishc_opt_default(&cfg->publish_opt);
|
||||
cfg->unpublish_max_wait_time_msec = PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC;
|
||||
|
|
Loading…
Reference in New Issue