Ignore:
Timestamp:
Feb 9, 2006 12:13:40 AM (18 years ago)
Author:
bennylp
Message:

Integration of pjmedia and pjsip error subsystem to pjlib

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r160 r162  
    2424#include <pjmedia/sdp.h> 
    2525#include <pjmedia/sdp_neg.h> 
     26#include <pjmedia/errno.h> 
    2627#include <pj/string.h> 
    2728#include <pj/pool.h> 
     
    761762                                                      &inv->neg); 
    762763    } else { 
    763         pj_assert(!"UAS dialog without remote and local offer is not supported!"); 
    764         PJ_TODO(IMPLEMENT_DELAYED_UAS_OFFER); 
    765         status = PJ_ENOTSUP; 
     764        status = PJ_SUCCESS; 
    766765    } 
    767766 
     
    874873} 
    875874 
     875 
     876/* 
     877 * Negotiate SDP. 
     878 */ 
     879static pj_status_t inv_negotiate_sdp( pjsip_inv_session *inv ) 
     880{ 
     881    pj_status_t status; 
     882 
     883    PJ_ASSERT_RETURN(pjmedia_sdp_neg_get_state(inv->neg) == 
     884                     PJMEDIA_SDP_NEG_STATE_WAIT_NEGO,  
     885                     PJMEDIA_SDPNEG_EINSTATE); 
     886 
     887    status = pjmedia_sdp_neg_negotiate(inv->pool, inv->neg, 0); 
     888 
     889    if (mod_inv.cb.on_media_update) 
     890        (*mod_inv.cb.on_media_update)(inv, status); 
     891 
     892    return status; 
     893} 
    876894 
    877895/* 
     
    899917     * offer before.  
    900918     */ 
    901     PJ_ASSERT_RETURN(!local_sdp || 
    902                      (pjmedia_sdp_neg_get_state(inv->neg)==PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER), 
    903                      PJ_EINVALIDOP); 
    904919    if (local_sdp) { 
    905         status = pjmedia_sdp_neg_set_local_answer(inv->pool, inv->neg, 
    906                                                   local_sdp); 
     920 
     921        if (inv->neg == NULL) { 
     922            status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, local_sdp, 
     923                                                          &inv->neg); 
     924        } else if (pjmedia_sdp_neg_get_state(inv->neg)== 
     925                   PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER) 
     926        { 
     927            status = pjmedia_sdp_neg_set_local_answer(inv->pool, inv->neg, 
     928                                                      local_sdp); 
     929        } else { 
     930 
     931            /* Can not specify local SDP at this state. */ 
     932            pj_assert(0); 
     933            status = PJMEDIA_SDPNEG_EINSTATE; 
     934        } 
     935 
    907936        if (status != PJ_SUCCESS) 
    908937            return status; 
     
    916945        return status; 
    917946 
    918     /* Include SDP for 18x and 2xx response. */ 
     947    /* Include SDP for 18x and 2xx response.  
     948     * Also if SDP negotiator is ready, start negotiation. 
     949     */ 
    919950    if (st_code/10 == 18 || st_code/10 == 20) { 
    920951        const pjmedia_sdp_session *local; 
     
    923954        if (status == PJ_SUCCESS) 
    924955            last_res->msg->body = create_sdp_body(last_res->pool, local); 
    925                                               ; 
    926     } 
    927  
    928     /* Do we need to increment tdata'inv reference counter? */ 
    929     PJ_TODO(INV_ANSWER_MAY_HAVE_TO_INCREMENT_REF_COUNTER); 
     956 
     957        /* Start negotiation, if ready. */ 
     958        if (pjmedia_sdp_neg_get_state(inv->neg) == PJMEDIA_SDP_NEG_STATE_WAIT_NEGO) { 
     959            status = inv_negotiate_sdp(inv); 
     960            if (status != PJ_SUCCESS) { 
     961                pjsip_tx_data_dec_ref(last_res); 
     962                return status; 
     963            } 
     964        } 
     965    } 
     966 
    930967 
    931968    *p_tdata = last_res; 
Note: See TracChangeset for help on using the changeset viewer.