From f08802c585d30e01ea5dce2bdc222b8ecaa47552 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 28 Sep 2012 10:07:22 +0000 Subject: Re #1587: Respond to call replace request with the last provisional response sent in the replaced call. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4269 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_call.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index c374f0dc..d5856f5b 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -811,8 +811,8 @@ static pj_status_t process_incoming_call_replace(pjsua_call *call, { pjsip_inv_session *replaced_inv; struct pjsua_call *replaced_call; - pjsip_tx_data *tdata; - pj_status_t status; + pjsip_tx_data *tdata = NULL; + pj_status_t status = PJ_SUCCESS; /* Get the invite session in the dialog */ replaced_inv = pjsip_dlg_get_inv_session(replaced_dlg); @@ -828,9 +828,17 @@ static pj_status_t process_incoming_call_replace(pjsua_call *call, if (replaced_call->inv->state <= PJSIP_INV_STATE_EARLY && replaced_call->inv->role != PJSIP_ROLE_UAC) { - /* Replaced call is not in confirmed state yet and we are not - * the call initiator, should not answer with 200 response here. - */ + if (replaced_call->last_code > 100 && replaced_call->last_code < 200) + { + pjsip_status_code code = replaced_call->last_code; + pj_str_t *text = &replaced_call->last_text; + + PJ_LOG(4,(THIS_FILE, "Answering replacement call %d with %d/%.*s", + call->index, code, text->slen, text->ptr)); + + /* Answer the new call with last response in the replaced call */ + status = pjsip_inv_answer(call->inv, code, text, NULL, &tdata); + } } else { PJ_LOG(4,(THIS_FILE, "Answering replacement call %d with 200/OK", call->index)); @@ -839,7 +847,7 @@ static pj_status_t process_incoming_call_replace(pjsua_call *call, status = pjsip_inv_answer(call->inv, 200, NULL, NULL, &tdata); } - if (status == PJ_SUCCESS) + if (status == PJ_SUCCESS && tdata) status = pjsip_inv_send_msg(call->inv, tdata); if (status != PJ_SUCCESS) -- cgit v1.2.3