diff options
author | Benny Prijono <bennylp@teluu.com> | 2011-05-19 04:36:01 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2011-05-19 04:36:01 +0000 |
commit | f8901ea61be686ac4f76e86aa6ec550d11388ffb (patch) | |
tree | 8a179a2d1e83763081527973e296430dad86ff81 /pjsip | |
parent | dc90133cf657d9bb8e043f19a44aac477b3c7bcb (diff) |
Fixed #1259: Option to use of 100rel in UAS if UAC supports it (thanks Marcus Froeschl for the suggestion)
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3570 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 46 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 17 |
2 files changed, 53 insertions, 10 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index d3c2c759..404b140c 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -954,6 +954,34 @@ typedef enum pjsua_sip_timer_use /** + * This constants controls the use of 100rel extension. + */ +typedef enum pjsua_100rel_use +{ + /** + * Not used. For UAC, support for 100rel will be indicated in Supported + * header so that peer can opt to use it if it wants to. As UAS, this + * option will NOT cause 100rel to be used even if UAC indicates that + * it supports this feature. + */ + PJSUA_100REL_NOT_USED, + + /** + * Mandatory. UAC will place 100rel in Require header, and UAS will + * reject incoming calls unless it has 100rel in Supported header. + */ + PJSUA_100REL_MANDATORY, + + /** + * Optional. Similar to PJSUA_100REL_NOT_USED, except that as UAS, this + * option will cause 100rel to be used if UAC indicates that it supports it. + */ + PJSUA_100REL_OPTIONAL + +} pjsua_100rel_use; + + +/** * This structure describes the settings to control the API and * user agent behavior, and can be specified when calling #pjsua_init(). * Before setting the values, application must call #pjsua_config_default() @@ -1089,13 +1117,13 @@ typedef struct pjsua_config int nat_type_in_sdp; /** - * Specify whether support for reliable provisional response (100rel and - * PRACK) should be required by default. Note that this setting can be + * Specify how the support for reliable provisional response (100rel/ + * PRACK) should be used by default. Note that this setting can be * further customized in account configuration (#pjsua_acc_config). * - * Default: PJ_FALSE + * Default: PJSUA_100REL_NOT_USED */ - pj_bool_t require_100rel; + pjsua_100rel_use require_100rel; /** * Specify the usage of Session Timers for all sessions. See the @@ -2222,12 +2250,14 @@ typedef struct pjsua_acc_config pj_str_t contact_uri_params; /** - * Specify whether support for reliable provisional response (100rel and - * PRACK) should be required for all sessions of this account. + * Specify how support for reliable provisional response (100rel/ + * PRACK) should be used for all sessions in this account. See the + * documentation of pjsua_100rel_use enumeration for more info. * - * Default: PJ_FALSE + * Default: The default value is taken from the value of + * require_100rel in pjsua_config. */ - pj_bool_t require_100rel; + pjsua_100rel_use require_100rel; /** * Specify the usage of Session Timers for all sessions. See the diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 8c9f16db..b58fd758 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -499,7 +499,7 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id, /* Create the INVITE session: */ options |= PJSIP_INV_SUPPORT_100REL; - if (acc->cfg.require_100rel) + if (acc->cfg.require_100rel == PJSUA_100REL_MANDATORY) options |= PJSIP_INV_REQUIRE_100REL; if (acc->cfg.use_timer != PJSUA_SIP_TIMER_INACTIVE) { options |= PJSIP_INV_SUPPORT_TIMER; @@ -848,7 +848,7 @@ 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) + if (pjsua_var.acc[acc_id].cfg.require_100rel == PJSUA_100REL_MANDATORY) options |= PJSIP_INV_REQUIRE_100REL; if (pjsua_var.media_cfg.enable_ice) options |= PJSIP_INV_SUPPORT_ICE; @@ -931,6 +931,19 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) options &= ~(PJSIP_INV_SUPPORT_TIMER); } + /* If 100rel is optional and UAC supports it, use it. */ + if ((options & PJSIP_INV_REQUIRE_100REL)==0 && + pjsua_var.acc[acc_id].cfg.require_100rel == PJSUA_100REL_OPTIONAL) + { + const pj_str_t token = { "100rel", 6}; + pjsip_dialog_cap_status cap_status; + + cap_status = pjsip_dlg_remote_has_cap(dlg, PJSIP_H_SUPPORTED, NULL, + &token); + if (cap_status == PJSIP_DIALOG_CAP_SUPPORTED) + options |= PJSIP_INV_REQUIRE_100REL; + } + /* Create invite session: */ status = pjsip_inv_create_uas( dlg, rdata, answer, options, &inv); if (status != PJ_SUCCESS) { |