Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 3902)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 3903)
@@ -567,4 +567,41 @@
 
 /**
+ * Call settings.
+ */
+typedef struct pjsua_call_setting
+{
+    /**
+     * Bitmask of #pjsua_call_flag constants.
+     *
+     * Default: 0
+     */
+    unsigned	     flag;
+
+    /**
+     * This flag controls what methods to request keyframe are allowed on
+     * the call. Value is bitmask of #pjsua_vid_req_keyframe_method.
+     */
+    unsigned	     req_keyframe_method;
+
+    /**
+     * Number of simultaneous active audio streams for this call. Setting
+     * this to zero will disable audio in this call.
+     *
+     * Default: 1
+     */
+    unsigned         audio_cnt;
+
+    /**
+     * Number of simultaneous active video streams for this call. Setting
+     * this to zero will disable video in this call.
+     *
+     * Default: 1 (if video feature is enabled, otherwise it is zero)
+     */
+    unsigned         video_cnt;
+
+} pjsua_call_setting;
+
+
+/**
  * This structure describes application callback to receive various event
  * notification from PJSUA-API. All of these callbacks are OPTIONAL,
@@ -666,5 +703,6 @@
      * by setting the code (default is 202). When this callback
      * is not defined, the default behavior is to accept the
-     * transfer.
+     * transfer. See also on_call_transfer_request2() callback for
+     * the version with \a pjsua_call_setting in the argument list.
      *
      * @param call_id	The call index.
@@ -677,4 +715,24 @@
 				     const pj_str_t *dst,
 				     pjsip_status_code *code);
+
+    /**
+     * Notify application on call being transfered (i.e. REFER is received).
+     * Application can decide to accept/reject transfer request
+     * by setting the code (default is 202). When this callback
+     * is not defined, the default behavior is to accept the
+     * transfer.
+     *
+     * @param call_id	The call index.
+     * @param dst	The destination where the call will be 
+     *			transfered to.
+     * @param code	Status code to be returned for the call transfer
+     *			request. On input, it contains status code 200.
+     * @param opt	The current call setting, application can update
+     *			this setting for the call being transfered.
+     */
+    void (*on_call_transfer_request2)(pjsua_call_id call_id,
+				      const pj_str_t *dst,
+				      pjsip_status_code *code,
+				      pjsua_call_setting *opt);
 
     /**
@@ -704,4 +762,6 @@
      * Notify application about incoming INVITE with Replaces header.
      * Application may reject the request by setting non-2xx code.
+     * See also on_call_replace_request2() callback for the version
+     * with \a pjsua_call_setting in the argument list.
      *
      * @param call_id	    The call ID to be replaced.
@@ -715,4 +775,22 @@
 				    int *st_code,
 				    pj_str_t *st_text);
+
+    /**
+     * Notify application about incoming INVITE with Replaces header.
+     * Application may reject the request by setting non-2xx code.
+     *
+     * @param call_id	    The call ID to be replaced.
+     * @param rdata	    The incoming INVITE request to replace the call.
+     * @param st_code	    Status code to be set by application. Application
+     *			    should only return a final status (200-699).
+     * @param st_text	    Optional status text to be set by application.
+     * @param opt	    The current call setting, application can update
+     *			    this setting for the call being replaced.
+     */
+    void (*on_call_replace_request2)(pjsua_call_id call_id,
+				     pjsip_rx_data *rdata,
+				     int *st_code,
+				     pj_str_t *st_text,
+				     pjsua_call_setting *opt);
 
     /**
@@ -3405,41 +3483,4 @@
 
 /**
- * Call settings.
- */
-typedef struct pjsua_call_setting
-{
-    /**
-     * Bitmask of #pjsua_call_flag constants.
-     *
-     * Default: 0
-     */
-    unsigned	     flag;
-
-    /**
-     * This flag controls what methods to request keyframe are allowed on
-     * the call. Value is bitmask of #pjsua_vid_req_keyframe_method.
-     */
-    unsigned	     req_keyframe_method;
-
-    /**
-     * Number of simultaneous active audio streams for this call. Setting
-     * this to zero will disable audio in this call.
-     *
-     * Default: 1
-     */
-    unsigned         audio_cnt;
-
-    /**
-     * Number of simultaneous active video streams for this call. Setting
-     * this to zero will disable video in this call.
-     *
-     * Default: 1 (if video feature is enabled, otherwise it is zero)
-     */
-    unsigned         video_cnt;
-
-} pjsua_call_setting;
-
-
-/**
  * This structure describes the information and current status of a call.
  */
@@ -4067,5 +4108,6 @@
  *
  * @param call_id	Call identification.
- * @param opt		Optional call setting.
+ * @param opt		Optional call setting, if NULL, the current call
+ *			setting will remain unchanged.
  * @param msg_data	Optional message components to be sent with
  *			the request.
@@ -4097,5 +4139,6 @@
  *
  * @param call_id	Call identification.
- * @param opt		Optional call setting.
+ * @param opt		Optional call setting, if NULL, the current call
+ *			setting will remain unchanged.
  * @param msg_data	Optional message components to be sent with
  *			the request.
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 3902)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 3903)
@@ -965,5 +965,8 @@
      * if it wants to.
      */
-    if (replaced_dlg != NULL && pjsua_var.ua_cfg.cb.on_call_replace_request) {
+    if (replaced_dlg != NULL &&
+	(pjsua_var.ua_cfg.cb.on_call_replace_request ||
+	 pjsua_var.ua_cfg.cb.on_call_replace_request2))
+    {
 	pjsua_call *replaced_call;
 	int st_code = 200;
@@ -973,7 +976,20 @@
 	replaced_call = (pjsua_call*) replaced_dlg->mod_data[pjsua_var.mod.id];
 
+	/* Copy call setting from the replaced call */
+	call->opt = replaced_call->opt;
+
 	/* Notify application */
-	pjsua_var.ua_cfg.cb.on_call_replace_request(replaced_call->index,
-						    rdata, &st_code, &st_text);
+	if (pjsua_var.ua_cfg.cb.on_call_replace_request) {
+	    pjsua_var.ua_cfg.cb.on_call_replace_request(replaced_call->index,
+							rdata,
+							&st_code, &st_text);
+	}
+
+	if (pjsua_var.ua_cfg.cb.on_call_replace_request2) {
+	    pjsua_var.ua_cfg.cb.on_call_replace_request2(replaced_call->index,
+							 rdata,
+							 &st_code, &st_text,
+							 &call->opt);
+	}
 
 	/* Must specify final response */
@@ -3875,4 +3891,5 @@
     pjsip_status_code code;
     pjsip_evsub *sub;
+    pjsua_call_setting call_opt;
 
     pj_log_push_indent();
@@ -3911,8 +3928,17 @@
     /* Notify callback */
     code = PJSIP_SC_ACCEPTED;
-    if (pjsua_var.ua_cfg.cb.on_call_transfer_request)
+    if (pjsua_var.ua_cfg.cb.on_call_transfer_request) {
 	(*pjsua_var.ua_cfg.cb.on_call_transfer_request)(existing_call->index,
 							&refer_to->hvalue, 
 							&code);
+    }
+
+    call_opt = existing_call->opt;
+    if (pjsua_var.ua_cfg.cb.on_call_transfer_request2) {
+	(*pjsua_var.ua_cfg.cb.on_call_transfer_request2)(existing_call->index,
+							 &refer_to->hvalue, 
+							 &code,
+							 &call_opt);
+    }
 
     if (code < 200)
@@ -4041,5 +4067,5 @@
     /* Now make the outgoing call. */
     tmp = pj_str(uri);
-    status = pjsua_call_make_call(existing_call->acc_id, &tmp, 0,
+    status = pjsua_call_make_call(existing_call->acc_id, &tmp, &call_opt,
 				  existing_call->user_data, &msg_data, 
 				  &new_call);
