From f2fb070bb2bbb0c555bfdfa5c75d4c9c123eac7d Mon Sep 17 00:00:00 2001 From: Riza Sulistyo Date: Fri, 27 May 2016 02:55:12 +0000 Subject: Re #1923: Delay call-hangup triggered from simulated onIncomingCall() to avoid assertion. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5323 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua-lib/pjsua_internal.h | 3 ++- pjsip/src/pjsua-lib/pjsua_call.c | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h index 1dec7c57..24a87fc0 100644 --- a/pjsip/include/pjsua-lib/pjsua_internal.h +++ b/pjsip/include/pjsua-lib/pjsua_internal.h @@ -172,8 +172,9 @@ struct pjsua_call pjsua_msg_data *msg_data;/**< Headers for outgoing INVITE. */ pj_bool_t hangup; /**< Call is hangup? */ } out_call; - struct { + struct { call_answer answers;/**< A list of call answers. */ + pj_bool_t hangup;/**< Call is hangup? */ pjsip_dialog *replaced_dlg; /**< Replaced dialog. */ } inc_call; } call_var; diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 2c269e67..22a394b1 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -1637,11 +1637,16 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) /* onIncomingCall() may be simulated by onCreateMediaTransport() * when media init is done synchrounously (see #1916). And if app - * happens to answer the call from the callback, the answer should - * have been delayed (see #1923), so let's process the answer now. + * happens to answer/hangup the call from the callback, the + * answer/hangup should have been delayed (see #1923), + * so let's process the answer/hangup now. */ - if (call->med_ch_cb == NULL) + if (call->async_call.call_var.inc_call.hangup) { + pjsua_call_hangup(call_id, call->last_code, &call->last_text, + NULL); + } else if (call->med_ch_cb == NULL) { process_pending_call_answer(call); + } } else { pjsua_call_hangup(call_id, PJSIP_SC_TEMPORARILY_UNAVAILABLE, NULL, NULL); @@ -2336,10 +2341,17 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id, /* If media transport creation is not yet completed, we will hangup * the call in the media transport creation callback instead. */ - if (call->med_ch_cb && !call->inv) { + if ((call->med_ch_cb && !call->inv) || + ((call->inv != NULL) && (call->inv->state == PJSIP_INV_STATE_NULL))) + { PJ_LOG(4,(THIS_FILE, "Pending call %d hangup upon completion " "of media transport", call_id)); - call->async_call.call_var.out_call.hangup = PJ_TRUE; + + if (call->inv->role == PJSIP_ROLE_UAS) + call->async_call.call_var.inc_call.hangup = PJ_TRUE; + else + call->async_call.call_var.out_call.hangup = PJ_TRUE; + if (code == 0) call->last_code = PJSIP_SC_REQUEST_TERMINATED; else -- cgit v1.2.3