Index: pjproject/branches/1.x/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- pjproject/branches/1.x/pjsip-apps/src/pjsua/pjsua_app.c	(revision 3569)
+++ pjproject/branches/1.x/pjsip-apps/src/pjsua/pjsua_app.c	(revision 3570)
@@ -881,6 +881,6 @@
 
 	case OPT_100REL: /** 100rel */
-	    cur_acc->require_100rel = PJ_TRUE;
-	    cfg->cfg.require_100rel = PJ_TRUE;
+	    cur_acc->require_100rel = PJSUA_100REL_MANDATORY;
+	    cfg->cfg.require_100rel = PJSUA_100REL_MANDATORY;
 	    break;
 
Index: pjproject/branches/1.x/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- pjproject/branches/1.x/pjsip/include/pjsua-lib/pjsua.h	(revision 3569)
+++ pjproject/branches/1.x/pjsip/include/pjsua-lib/pjsua.h	(revision 3570)
@@ -955,4 +955,32 @@
 
 /**
+ * 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().
@@ -1090,11 +1118,11 @@
 
     /**
-     * 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
-     */
-    pj_bool_t	    require_100rel;
+     * Default: PJSUA_100REL_NOT_USED
+     */
+    pjsua_100rel_use require_100rel;
 
     /**
@@ -2223,10 +2251,12 @@
 
     /**
-     * Specify whether support for reliable provisional response (100rel and
-     * PRACK) should be required for all sessions of this account.
-     *
-     * Default: PJ_FALSE
-     */
-    pj_bool_t	    require_100rel;
+     * 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: The default value is taken from the value of
+     *          require_100rel in pjsua_config.
+     */
+    pjsua_100rel_use require_100rel;
 
     /**
Index: pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_call.c	(revision 3569)
+++ pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_call.c	(revision 3570)
@@ -500,5 +500,5 @@
     /* 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) {
@@ -849,5 +849,5 @@
     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)
@@ -930,4 +930,17 @@
     {
 	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;
     }
 
