diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2009-08-11 12:42:38 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2009-08-11 12:42:38 +0000 |
commit | 6f204c13ce8519524eb4da79359ac9b2aea08252 (patch) | |
tree | fd03248a6aa6c121822cbca2507113cf5b86b0f0 /pjsip/src/pjsua-lib | |
parent | 04fbadef1554da3b61c412e030081d1f05c6a99a (diff) |
Ticket #833:
- Initial version of Session Timers (RFC 4028).
- Added new options in pjsua app to configure Session Timers settings.
- Added python tests for Session Timers.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2858 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 58 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_core.c | 13 |
2 files changed, 66 insertions, 5 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 19d516bb..013a249e 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -479,8 +479,11 @@ 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; status = pjsip_inv_create_uac( dlg, offer, options, &inv); if (status != PJ_SUCCESS) { @@ -488,6 +491,20 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id, goto on_error; } + /* Init Session Timers */ + { + pjsip_timer_setting timer_setting; + + pjsip_timer_default_setting(&timer_setting); + timer_setting.sess_expires = acc->cfg.timer_se; + timer_setting.min_se = acc->cfg.timer_min_se; + + status = pjsip_timer_init_session(inv, &timer_setting); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Session Timer init failed", status); + goto on_error; + } + } /* Create and associate our data in the session. */ call->acc_id = acc_id; @@ -805,8 +822,11 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) /* Verify that we can handle the request. */ options |= PJSIP_INV_SUPPORT_100REL; + 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; status = pjsip_inv_verify_request2(rdata, &options, offer, answer, NULL, pjsua_var.endpt, &response); @@ -895,6 +915,29 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) return PJ_TRUE; } + /* Init Session Timers */ + { + pjsip_timer_setting timer_setting; + + pjsip_timer_default_setting(&timer_setting); + timer_setting.sess_expires = pjsua_var.acc[acc_id].cfg.timer_se; + timer_setting.min_se = pjsua_var.acc[acc_id].cfg.timer_min_se; + + status = pjsip_timer_init_session(inv, &timer_setting); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Session Timer init failed", status); + status = pjsip_inv_end_session(inv, PJSIP_SC_INTERNAL_SERVER_ERROR, + NULL, &response); + if (status == PJ_SUCCESS && response) + status = pjsip_inv_send_msg(inv, response); + + pjsua_media_channel_deinit(call->index); + + PJSUA_UNLOCK(); + return PJ_TRUE; + } + } + /* Update NAT type of remote endpoint, only when there is SDP in * incoming INVITE! */ @@ -928,11 +971,16 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) status = pjsip_inv_initial_answer(inv, rdata, 100, NULL, NULL, &response); if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to send answer to incoming INVITE", - status); - - pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); - pjsip_inv_terminate(inv, 500, PJ_FALSE); + if (response == NULL) { + pjsua_perror(THIS_FILE, "Unable to send answer to incoming INVITE", + status); + pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); + pjsip_inv_terminate(inv, 500, PJ_FALSE); + } else { + pjsip_inv_send_msg(inv, response); + pjsip_inv_terminate(inv, PJSIP_ERRNO_TO_SIP_STATUS(status), + PJ_FALSE); + } pjsua_media_channel_deinit(call->index); PJSUA_UNLOCK(); return PJ_TRUE; diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index 30ae00e7..6cd9cac5 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -87,6 +87,8 @@ PJ_DEF(void) pjsua_logging_config_dup(pj_pool_t *pool, PJ_DEF(void) pjsua_config_default(pjsua_config *cfg) { + pjsip_timer_setting timer_setting; + pj_bzero(cfg, sizeof(*cfg)); cfg->max_calls = ((PJSUA_MAX_CALLS) < 4) ? (PJSUA_MAX_CALLS) : 4; @@ -98,6 +100,10 @@ PJ_DEF(void) pjsua_config_default(pjsua_config *cfg) cfg->srtp_secure_signaling = PJSUA_DEFAULT_SRTP_SECURE_SIGNALING; #endif cfg->hangup_forked_call = PJ_TRUE; + + pjsip_timer_default_setting(&timer_setting); + cfg->timer_se = timer_setting.sess_expires; + cfg->timer_min_se = timer_setting.min_se; } PJ_DEF(void) pjsua_config_dup(pj_pool_t *pool, @@ -150,6 +156,9 @@ 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->timer_se = pjsua_var.ua_cfg.timer_se; + cfg->timer_min_se = pjsua_var.ua_cfg.timer_min_se; cfg->ka_interval = 15; cfg->ka_data = pj_str("\r\n"); #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) @@ -721,6 +730,10 @@ PJ_DEF(pj_status_t) pjsua_init( const pjsua_config *ua_cfg, status = pjsip_100rel_init_module(pjsua_var.endpt); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); + /* Initialize session timer support */ + status = pjsip_timer_init_module(pjsua_var.endpt); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); + /* Initialize and register PJSUA application module. */ { const pjsip_module mod_initializer = |