Ignore:
Timestamp:
Nov 11, 2006 4:16:04 PM (17 years ago)
Author:
bennylp
Message:

Attended call transfer implementation. The changes involves:

  • Added support for SIP Replaces extension (RFC 3891)
  • Added pjsua_call_xfer_replaces() to perform attended call transfer.
  • PJSUA checks and process Replaces header in incoming calls
  • Added pjsip_ua_find_dialog() API.
  • Added pjsip_endpt_has_capability() API.
  • Added pjsip_endpt_send_response2() API.
  • etc.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_ua_layer.c

    r729 r797  
    410410 
    411411 
     412/*  
     413 * Find a dialog. 
     414 */ 
     415PJ_DEF(pjsip_dialog*) pjsip_ua_find_dialog(const pj_str_t *call_id, 
     416                                           const pj_str_t *local_tag, 
     417                                           const pj_str_t *remote_tag, 
     418                                           pj_bool_t lock_dialog) 
     419{ 
     420    struct dlg_set *dlg_set; 
     421    pjsip_dialog *dlg; 
     422 
     423    PJ_ASSERT_RETURN(call_id && local_tag && remote_tag, NULL); 
     424 
     425    /* Lock user agent. */ 
     426    pj_mutex_lock(mod_ua.mutex); 
     427 
     428    /* Lookup the dialog set. */ 
     429    dlg_set = pj_hash_get(mod_ua.dlg_table, local_tag->ptr, local_tag->slen, 
     430                          NULL); 
     431    if (dlg_set == NULL) { 
     432        /* Not found */ 
     433        pj_mutex_unlock(mod_ua.mutex); 
     434        return NULL; 
     435    } 
     436 
     437    /* Dialog set is found, now find the matching dialog based on the 
     438     * remote tag. 
     439     */ 
     440    dlg = dlg_set->dlg_list.next; 
     441    while (dlg != (pjsip_dialog*)&dlg_set->dlg_list) {   
     442        if (pj_strcmp(&dlg->remote.info->tag, remote_tag) == 0) 
     443            break; 
     444        dlg = dlg->next; 
     445    } 
     446 
     447    if (dlg == (pjsip_dialog*)&dlg_set->dlg_list) { 
     448        /* Not found */ 
     449        pj_mutex_unlock(mod_ua.mutex); 
     450        return NULL; 
     451    } 
     452 
     453    /* Dialog has been found. It SHOULD have the right Call-ID!! */ 
     454    PJ_ASSERT_ON_FAIL(pj_strcmp(&dlg->call_id->id, call_id)==0,  
     455                        {pj_mutex_unlock(mod_ua.mutex); return NULL;}); 
     456 
     457    if (lock_dialog) { 
     458        if (pjsip_dlg_try_inc_lock(dlg) != PJ_SUCCESS) { 
     459 
     460            /* 
     461             * Unable to acquire dialog's lock while holding the user 
     462             * agent's mutex. Release the UA mutex before retrying once 
     463             * more. 
     464             * 
     465             * THIS MAY CAUSE RACE CONDITION! 
     466             */ 
     467 
     468            /* Unlock user agent. */ 
     469            pj_mutex_unlock(mod_ua.mutex); 
     470            /* Lock dialog */ 
     471            pjsip_dlg_inc_lock(dlg); 
     472 
     473        } else { 
     474            /* Unlock user agent. */ 
     475            pj_mutex_unlock(mod_ua.mutex); 
     476        } 
     477 
     478    } else { 
     479        /* Unlock user agent. */ 
     480        pj_mutex_unlock(mod_ua.mutex); 
     481    } 
     482 
     483    return dlg; 
     484} 
     485 
     486 
    412487/* 
    413488 * Find the first dialog in dialog set in hash table for an incoming message. 
Note: See TracChangeset for help on using the changeset viewer.