diff options
author | Liong Sauw Ming <ming@teluu.com> | 2012-11-26 02:04:17 +0000 |
---|---|---|
committer | Liong Sauw Ming <ming@teluu.com> | 2012-11-26 02:04:17 +0000 |
commit | 4829490aa8a2c178a8dba4933a0056c8c8e80499 (patch) | |
tree | df5a36665807d08614ab047086c5c066242f8744 /pjsip/src/pjsua-lib | |
parent | aa8a3b9e20ce37f09abfe1336b335a5f93d713c2 (diff) |
Fixes #1595: Allow call hangup immediately after outgoing call
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4300 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 35 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_dump.c | 6 |
2 files changed, 37 insertions, 4 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 490561c8..8fe7f5ef 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -388,9 +388,16 @@ on_make_call_med_tp_complete(pjsua_call_id call_id, goto on_error; } - /* pjsua_media_channel_deinit() has been called. */ - if (call->async_call.med_ch_deinit) + /* pjsua_media_channel_deinit() has been called or + * call has been hung up. + */ + if (call->async_call.med_ch_deinit || + call->async_call.call_var.out_call.hangup) + { + PJ_LOG(4,(THIS_FILE, "Call has been hung up or media channel has " + "been deinitialized")); goto on_error; + } /* Create offer */ status = pjsua_media_channel_create_sdp(call->index, dlg->pool, NULL, @@ -487,6 +494,7 @@ on_make_call_med_tp_complete(pjsua_call_id call_id, } /* Done. */ + call->med_ch_cb = NULL; pjsip_dlg_dec_lock(dlg); PJSUA_UNLOCK(); @@ -514,6 +522,10 @@ on_error: pjsua_media_channel_deinit(call_id); } + call->med_ch_cb = NULL; + + pjsua_check_snd_dev_idle(); + PJSUA_UNLOCK(); return status; } @@ -2145,6 +2157,25 @@ PJ_DEF(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id, if (status != PJ_SUCCESS) goto on_return; + /* 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) { + 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 (code == 0) + call->last_code = PJSIP_SC_REQUEST_TERMINATED; + else + call->last_code = code; + if (reason) { + pj_strncpy(&call->last_text, reason, + sizeof(call->last_text_buf_)); + } + + goto on_return; + } + if (code==0) { if (call->inv->state == PJSIP_INV_STATE_CONFIRMED) code = PJSIP_SC_OK; diff --git a/pjsip/src/pjsua-lib/pjsua_dump.c b/pjsip/src/pjsua-lib/pjsua_dump.c index 87201cc8..1a78558f 100644 --- a/pjsip/src/pjsua-lib/pjsua_dump.c +++ b/pjsip/src/pjsua-lib/pjsua_dump.c @@ -888,11 +888,12 @@ void print_call(const char *title, { int len; pjsip_inv_session *inv = pjsua_var.calls[call_id].inv; - pjsip_dialog *dlg = inv->dlg; + pjsip_dialog *dlg; char userinfo[128]; /* Dump invite sesion info. */ + dlg = (inv? inv->dlg: pjsua_var.calls[call_id].async_call.dlg); len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); if (len < 0) pj_ansi_strcpy(userinfo, "<--uri too long-->"); @@ -901,7 +902,8 @@ void print_call(const char *title, len = pj_ansi_snprintf(buf, size, "%s[%s] %s", title, - pjsip_inv_state_name(inv->state), + pjsip_inv_state_name(inv? inv->state: + PJSIP_INV_STATE_DISCONNECTED), userinfo); if (len < 1 || len >= (int)size) { pj_ansi_strcpy(buf, "<--uri too long-->"); |