summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2011-10-25 08:51:02 +0000
committerLiong Sauw Ming <ming@teluu.com>2011-10-25 08:51:02 +0000
commit9e4ddc18f6e2b4d9a68f1c93bfee541f315e80fc (patch)
tree8767cf3d0f107c80000087a590c48555f7be5639 /pjsip
parentd11fa21bf60ef14b9979ac3643dad1360f442c7f (diff)
Fixed #1398: TURN initialization failure scenario
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3849 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h2
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c26
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c19
3 files changed, 22 insertions, 25 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index cedb1d97..370e6679 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -563,7 +563,7 @@ typedef enum pjsua_create_media_transport_flag
typedef struct pjsua_callback
{
/**
- * Notify application when invite state has changed.
+ * Notify application when call state has changed.
* Application may then query the call info to get the
* detail call states by calling pjsua_call_get_info() function.
*
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 02a78b93..1e337dd6 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -464,6 +464,9 @@ on_make_call_med_tp_complete(pjsua_call_id call_id,
return PJ_SUCCESS;
on_error:
+ if (inv == NULL && call_id != -1 && pjsua_var.ua_cfg.cb.on_call_state)
+ (*pjsua_var.ua_cfg.cb.on_call_state)(call_id, NULL);
+
if (dlg) {
/* This may destroy the dialog */
pjsip_dlg_dec_lock(dlg);
@@ -1401,6 +1404,7 @@ PJ_DEF(pj_status_t) pjsua_call_get_info( pjsua_call_id call_id,
pjsua_call_info *info)
{
pjsua_call *call;
+ pjsip_dialog *dlg;
unsigned mi;
PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
@@ -1414,40 +1418,40 @@ PJ_DEF(pj_status_t) pjsua_call_get_info( pjsua_call_id call_id,
PJSUA_LOCK();
call = &pjsua_var.calls[call_id];
-
- if (!call->inv) {
+ dlg = (call->inv ? call->inv->dlg : call->async_call.dlg);
+ if (!dlg) {
PJSUA_UNLOCK();
return PJSIP_ESESSIONTERMINATED;
}
/* id and role */
info->id = call_id;
- info->role = call->inv->role;
+ info->role = dlg->role;
info->acc_id = call->acc_id;
/* local info */
info->local_info.ptr = info->buf_.local_info;
- pj_strncpy(&info->local_info, &call->inv->dlg->local.info_str,
+ pj_strncpy(&info->local_info, &dlg->local.info_str,
sizeof(info->buf_.local_info));
/* local contact */
info->local_contact.ptr = info->buf_.local_contact;
info->local_contact.slen = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR,
- call->inv->dlg->local.contact->uri,
+ dlg->local.contact->uri,
info->local_contact.ptr,
sizeof(info->buf_.local_contact));
/* remote info */
info->remote_info.ptr = info->buf_.remote_info;
- pj_strncpy(&info->remote_info, &call->inv->dlg->remote.info_str,
+ pj_strncpy(&info->remote_info, &dlg->remote.info_str,
sizeof(info->buf_.remote_info));
/* remote contact */
- if (call->inv->dlg->remote.contact) {
+ if (dlg->remote.contact) {
int len;
info->remote_contact.ptr = info->buf_.remote_contact;
len = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR,
- call->inv->dlg->remote.contact->uri,
+ dlg->remote.contact->uri,
info->remote_contact.ptr,
sizeof(info->buf_.remote_contact));
if (len < 0) len = 0;
@@ -1458,15 +1462,15 @@ PJ_DEF(pj_status_t) pjsua_call_get_info( pjsua_call_id call_id,
/* call id */
info->call_id.ptr = info->buf_.call_id;
- pj_strncpy(&info->call_id, &call->inv->dlg->call_id->id,
+ pj_strncpy(&info->call_id, &dlg->call_id->id,
sizeof(info->buf_.call_id));
/* state, state_text */
- info->state = call->inv->state;
+ info->state = (call->inv? call->inv->state: PJSIP_INV_STATE_DISCONNECTED);
info->state_text = pj_str((char*)pjsip_inv_state_name(info->state));
/* If call is disconnected, set the last_status from the cause code */
- if (call->inv->state >= PJSIP_INV_STATE_DISCONNECTED) {
+ if (call->inv && call->inv->state >= PJSIP_INV_STATE_DISCONNECTED) {
/* last_status, last_status_text */
info->last_status = call->inv->cause;
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 60aebbeb..57866983 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -777,10 +777,12 @@ static void on_ice_complete(pjmedia_transport *tp,
switch (op) {
case PJ_ICE_STRANS_OP_INIT:
+ PJSUA_LOCK();
call_med->tp_ready = result;
if (call_med->med_create_cb)
(*call_med->med_create_cb)(call_med, result,
call_med->call->secure_level, NULL);
+ PJSUA_UNLOCK();
break;
case PJ_ICE_STRANS_OP_NEGOTIATION:
if (result != PJ_SUCCESS) {
@@ -1419,24 +1421,15 @@ pj_status_t pjsua_call_media_init(pjsua_call_media *call_med,
set_media_tp_state(call_med, PJSUA_MED_TP_CREATING);
- if (async) {
- call_med->med_create_cb = &call_media_init_cb;
- call_med->med_init_cb = cb;
- }
-
if (pjsua_var.media_cfg.enable_ice) {
status = create_ice_media_transport(tcfg, call_med, async);
- if (async && status == PJ_SUCCESS) {
- /* Callback has been called. */
- call_med->med_init_cb = NULL;
- /* We cannot return PJ_SUCCESS here since we already call
- * the callback.
- */
- return PJ_EPENDING;
- } else if (async && status == PJ_EPENDING) {
+ if (async && status == PJ_EPENDING) {
/* We will resume call media initialization in the
* on_ice_complete() callback.
*/
+ call_med->med_create_cb = &call_media_init_cb;
+ call_med->med_init_cb = cb;
+
return PJ_EPENDING;
}
} else {