Changeset 3849


Ignore:
Timestamp:
Oct 25, 2011 8:51:02 AM (12 years ago)
Author:
ming
Message:

Fixed #1398: TURN initialization failure scenario

Location:
pjproject/trunk/pjsip
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r3841 r3849  
    564564{ 
    565565    /** 
    566      * Notify application when invite state has changed. 
     566     * Notify application when call state has changed. 
    567567     * Application may then query the call info to get the 
    568568     * detail call states by calling  pjsua_call_get_info() function. 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r3841 r3849  
    465465 
    466466on_error: 
     467    if (inv == NULL && call_id != -1 && pjsua_var.ua_cfg.cb.on_call_state) 
     468        (*pjsua_var.ua_cfg.cb.on_call_state)(call_id, NULL); 
     469 
    467470    if (dlg) { 
    468471        /* This may destroy the dialog */ 
     
    14021405{ 
    14031406    pjsua_call *call; 
     1407    pjsip_dialog *dlg; 
    14041408    unsigned mi; 
    14051409 
     
    14151419 
    14161420    call = &pjsua_var.calls[call_id]; 
    1417  
    1418     if (!call->inv) { 
     1421    dlg = (call->inv ? call->inv->dlg : call->async_call.dlg); 
     1422    if (!dlg) { 
    14191423        PJSUA_UNLOCK(); 
    14201424        return PJSIP_ESESSIONTERMINATED; 
     
    14231427    /* id and role */ 
    14241428    info->id = call_id; 
    1425     info->role = call->inv->role; 
     1429    info->role = dlg->role; 
    14261430    info->acc_id = call->acc_id; 
    14271431 
    14281432    /* local info */ 
    14291433    info->local_info.ptr = info->buf_.local_info; 
    1430     pj_strncpy(&info->local_info, &call->inv->dlg->local.info_str, 
     1434    pj_strncpy(&info->local_info, &dlg->local.info_str, 
    14311435               sizeof(info->buf_.local_info)); 
    14321436 
     
    14341438    info->local_contact.ptr = info->buf_.local_contact; 
    14351439    info->local_contact.slen = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, 
    1436                                                call->inv->dlg->local.contact->uri, 
     1440                                               dlg->local.contact->uri, 
    14371441                                               info->local_contact.ptr, 
    14381442                                               sizeof(info->buf_.local_contact)); 
     
    14401444    /* remote info */ 
    14411445    info->remote_info.ptr = info->buf_.remote_info; 
    1442     pj_strncpy(&info->remote_info, &call->inv->dlg->remote.info_str, 
     1446    pj_strncpy(&info->remote_info, &dlg->remote.info_str, 
    14431447               sizeof(info->buf_.remote_info)); 
    14441448 
    14451449    /* remote contact */ 
    1446     if (call->inv->dlg->remote.contact) { 
     1450    if (dlg->remote.contact) { 
    14471451        int len; 
    14481452        info->remote_contact.ptr = info->buf_.remote_contact; 
    14491453        len = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, 
    1450                               call->inv->dlg->remote.contact->uri, 
     1454                              dlg->remote.contact->uri, 
    14511455                              info->remote_contact.ptr, 
    14521456                              sizeof(info->buf_.remote_contact)); 
     
    14591463    /* call id */ 
    14601464    info->call_id.ptr = info->buf_.call_id; 
    1461     pj_strncpy(&info->call_id, &call->inv->dlg->call_id->id, 
     1465    pj_strncpy(&info->call_id, &dlg->call_id->id, 
    14621466               sizeof(info->buf_.call_id)); 
    14631467 
    14641468    /* state, state_text */ 
    1465     info->state = call->inv->state; 
     1469    info->state = (call->inv? call->inv->state: PJSIP_INV_STATE_DISCONNECTED); 
    14661470    info->state_text = pj_str((char*)pjsip_inv_state_name(info->state)); 
    14671471 
    14681472    /* If call is disconnected, set the last_status from the cause code */ 
    1469     if (call->inv->state >= PJSIP_INV_STATE_DISCONNECTED) { 
     1473    if (call->inv && call->inv->state >= PJSIP_INV_STATE_DISCONNECTED) { 
    14701474        /* last_status, last_status_text */ 
    14711475        info->last_status = call->inv->cause; 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r3841 r3849  
    778778    switch (op) { 
    779779    case PJ_ICE_STRANS_OP_INIT: 
     780        PJSUA_LOCK(); 
    780781        call_med->tp_ready = result; 
    781782        if (call_med->med_create_cb) 
    782783            (*call_med->med_create_cb)(call_med, result, 
    783784                                       call_med->call->secure_level, NULL); 
     785        PJSUA_UNLOCK(); 
    784786        break; 
    785787    case PJ_ICE_STRANS_OP_NEGOTIATION: 
     
    14201422        set_media_tp_state(call_med, PJSUA_MED_TP_CREATING); 
    14211423 
    1422         if (async) { 
    1423             call_med->med_create_cb = &call_media_init_cb; 
    1424             call_med->med_init_cb = cb; 
    1425         } 
    1426  
    14271424        if (pjsua_var.media_cfg.enable_ice) { 
    14281425            status = create_ice_media_transport(tcfg, call_med, async); 
    1429             if (async && status == PJ_SUCCESS) { 
    1430                 /* Callback has been called. */ 
    1431                 call_med->med_init_cb = NULL; 
    1432                 /* We cannot return PJ_SUCCESS here since we already call 
    1433                  * the callback. 
    1434                  */ 
    1435                 return PJ_EPENDING; 
    1436             } else if (async && status == PJ_EPENDING) { 
     1426            if (async && status == PJ_EPENDING) { 
    14371427                /* We will resume call media initialization in the 
    14381428                 * on_ice_complete() callback. 
    14391429                 */ 
     1430                call_med->med_create_cb = &call_media_init_cb; 
     1431                call_med->med_init_cb = cb; 
     1432 
    14401433                return PJ_EPENDING; 
    14411434            } 
Note: See TracChangeset for help on using the changeset viewer.