summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2010-09-07 09:36:15 +0000
committerNanang Izzuddin <nanang@teluu.com>2010-09-07 09:36:15 +0000
commitb14c7d99d296b6e4de74581b1cdc1281b9f8255c (patch)
tree632dc15c04b4b7207137a70926ba9e5918a53625 /pjsip
parentc7f48f004e14c0be8b4c5fcd82c6a5ccc64c170a (diff)
Re #1120:
- Added enum pjsua_sip_timer_use for session timer usage types, containing: inactive, optional, required, always - Replaced require_timer (boolean) with above enum in global and account config setting. - Updated pjsua app --use-timer option accordingly. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3305 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h48
-rw-r--r--pjsip/src/pjsua-lib/pjsua_acc.c2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c25
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c3
4 files changed, 62 insertions, 16 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index b74a209e..0ab24942 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -886,6 +886,36 @@ typedef struct pjsua_callback
} pjsua_callback;
+/**
+ * This enumeration specifies the usage of SIP Session Timers extension.
+ */
+typedef enum pjsua_sip_timer_use
+{
+ /**
+ * When this flag is specified, Session Timers will not be used in any
+ * session, except it is explicitly required in the remote request.
+ */
+ PJSUA_SIP_TIMER_INACTIVE,
+
+ /**
+ * When this flag is specified, Session Timers will be used in all
+ * sessions whenever remote supports and uses it.
+ */
+ PJSUA_SIP_TIMER_OPTIONAL,
+
+ /**
+ * When this flag is specified, Session Timers support will be
+ * a requirement for the remote to be able to establish a session.
+ */
+ PJSUA_SIP_TIMER_REQUIRED,
+
+ /**
+ * When this flag is specified, Session Timers will always be used
+ * in all sessions, regardless whether remote supports/uses it or not.
+ */
+ PJSUA_SIP_TIMER_ALWAYS
+
+} pjsua_sip_timer_use;
/**
@@ -1033,13 +1063,13 @@ typedef struct pjsua_config
pj_bool_t require_100rel;
/**
- * Specify whether support for Session Timers should be required by
- * default. Note that this setting can be further customized in account
- * configuration (#pjsua_acc_config).
+ * Specify the usage of Session Timers for all sessions. See the
+ * #pjsua_sip_timer_use for possible values. Note that this setting can be
+ * further customized in account configuration (#pjsua_acc_config).
*
- * Default: PJ_FALSE
+ * Default: PJSUA_SIP_TIMER_OPTIONAL
*/
- pj_bool_t require_timer;
+ pjsua_sip_timer_use use_timer;
/**
* Handle unsolicited NOTIFY requests containing message waiting
@@ -2098,12 +2128,12 @@ typedef struct pjsua_acc_config
pj_bool_t require_100rel;
/**
- * Specify whether support for Session Timers should be required for all
- * sessions of this account.
+ * Specify the usage of Session Timers for all sessions. See the
+ * #pjsua_sip_timer_use for possible values.
*
- * Default: PJ_FALSE
+ * Default: PJSUA_SIP_TIMER_OPTIONAL
*/
- pj_bool_t require_timer;
+ pjsua_sip_timer_use use_timer;
/**
* Specify Session Timer settings, see #pjsip_timer_setting.
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index 5597dad1..fbda32c2 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -737,7 +737,7 @@ PJ_DEF(pj_status_t) pjsua_acc_modify( pjsua_acc_id acc_id,
acc->cfg.require_100rel = cfg->require_100rel;
/* Session timer */
- acc->cfg.require_timer = cfg->require_timer;
+ acc->cfg.use_timer = cfg->use_timer;
acc->cfg.timer_setting = cfg->timer_setting;
/* Transport and keep-alive */
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index ed5eb100..2caaee1e 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -493,11 +493,15 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id,
/* Create the INVITE session: */
options |= PJSIP_INV_SUPPORT_100REL;
- options |= PJSIP_INV_SUPPORT_TIMER;
if (acc->cfg.require_100rel)
options |= PJSIP_INV_REQUIRE_100REL;
- if (acc->cfg.require_timer)
- options |= PJSIP_INV_REQUIRE_TIMER;
+ if (acc->cfg.use_timer != PJSUA_SIP_TIMER_INACTIVE) {
+ options |= PJSIP_INV_SUPPORT_TIMER;
+ if (acc->cfg.use_timer == PJSUA_SIP_TIMER_REQUIRED)
+ options |= PJSIP_INV_REQUIRE_TIMER;
+ else if (acc->cfg.use_timer == PJSUA_SIP_TIMER_ALWAYS)
+ options |= PJSIP_INV_ALWAYS_USE_TIMER;
+ }
status = pjsip_inv_create_uac( dlg, offer, options, &inv);
if (status != PJ_SUCCESS) {
@@ -839,10 +843,12 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
options |= PJSIP_INV_SUPPORT_TIMER;
if (pjsua_var.acc[acc_id].cfg.require_100rel)
options |= PJSIP_INV_REQUIRE_100REL;
- if (pjsua_var.acc[acc_id].cfg.require_timer)
- options |= PJSIP_INV_REQUIRE_TIMER;
if (pjsua_var.media_cfg.enable_ice)
options |= PJSIP_INV_SUPPORT_ICE;
+ if (pjsua_var.acc[acc_id].cfg.use_timer == PJSUA_SIP_TIMER_REQUIRED)
+ options |= PJSIP_INV_REQUIRE_TIMER;
+ else if (pjsua_var.acc[acc_id].cfg.use_timer == PJSUA_SIP_TIMER_ALWAYS)
+ options |= PJSIP_INV_ALWAYS_USE_TIMER;
status = pjsip_inv_verify_request2(rdata, &options, offer, answer, NULL,
pjsua_var.endpt, &response);
@@ -909,6 +915,15 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
pjsip_auth_clt_set_prefs(&dlg->auth_sess,
&pjsua_var.acc[acc_id].cfg.auth_pref);
+ /* Disable Session Timers if not prefered and the incoming INVITE request
+ * did not require it.
+ */
+ if (pjsua_var.acc[acc_id].cfg.use_timer == PJSUA_SIP_TIMER_INACTIVE &&
+ (options & PJSIP_INV_REQUIRE_TIMER) == 0)
+ {
+ options &= ~(PJSIP_INV_SUPPORT_TIMER);
+ }
+
/* Create invite session: */
status = pjsip_inv_create_uas( dlg, rdata, answer, options, &inv);
if (status != PJ_SUCCESS) {
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 368996d1..a0e43b21 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -109,6 +109,7 @@ PJ_DEF(void) pjsua_config_default(pjsua_config *cfg)
#endif
cfg->hangup_forked_call = PJ_TRUE;
+ cfg->use_timer = PJSUA_SIP_TIMER_OPTIONAL;
pjsip_timer_setting_default(&cfg->timer_setting);
}
@@ -171,7 +172,7 @@ PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
cfg->transport_id = PJSUA_INVALID_ID;
cfg->allow_contact_rewrite = PJ_TRUE;
cfg->require_100rel = pjsua_var.ua_cfg.require_100rel;
- cfg->require_timer = pjsua_var.ua_cfg.require_timer;
+ cfg->use_timer = pjsua_var.ua_cfg.use_timer;
cfg->timer_setting = pjsua_var.ua_cfg.timer_setting;
cfg->ka_interval = 15;
cfg->ka_data = pj_str("\r\n");