Changeset 5129


Ignore:
Timestamp:
Jul 8, 2015 10:17:26 AM (9 years ago)
Author:
nanang
Message:

Fix #1866: Refactored the management of initial SDP in SDP negotiator considering flip-flop memory pools used by the application/invite sesion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c

    r5114 r5129  
    3939 
    4040    pjmedia_sdp_session *initial_sdp,       /**< Initial local SDP           */ 
     41                        *initial_sdp_tmp,   /**< Temporary initial local SDP */ 
    4142                        *active_local_sdp,  /**< Currently active local SDP. */ 
    4243                        *active_remote_sdp, /**< Currently active remote's.  */ 
     
    399400 
    400401    /* New_offer fixed */ 
     402    neg->initial_sdp_tmp = neg->initial_sdp; 
    401403    neg->initial_sdp = new_offer; 
    402404    neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, new_offer); 
     
    424426        PJ_ASSERT_RETURN(neg->active_local_sdp, PJMEDIA_SDPNEG_ENOACTIVE); 
    425427 
     428        /* Retain initial SDP */ 
     429        if (neg->initial_sdp) { 
     430            neg->initial_sdp_tmp = neg->initial_sdp; 
     431            neg->initial_sdp = pjmedia_sdp_session_clone(pool, 
     432                                                         neg->initial_sdp); 
     433        } 
     434 
    426435        neg->state = PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER; 
    427436        neg->neg_local_sdp = pjmedia_sdp_session_clone(pool,  
    428437                                                       neg->active_local_sdp); 
    429         neg->initial_sdp = pjmedia_sdp_session_clone(pool, 
    430                                                      neg->active_local_sdp); 
    431438        *offer = neg->active_local_sdp; 
    432439 
     
    438445    } 
    439446 
    440      
    441447    return PJ_SUCCESS; 
    442448} 
     
    506512        if (neg->initial_sdp) { 
    507513            /* Retain initial_sdp value. */ 
     514            neg->initial_sdp_tmp = neg->initial_sdp; 
    508515            neg->initial_sdp = pjmedia_sdp_session_clone(pool, 
    509516                                                         neg->initial_sdp); 
     
    521528    } else { 
    522529        PJ_ASSERT_RETURN(neg->initial_sdp, PJMEDIA_SDPNEG_ENOINITIAL); 
     530        neg->initial_sdp_tmp = neg->initial_sdp; 
    523531        neg->initial_sdp = pjmedia_sdp_session_clone(pool, neg->initial_sdp); 
    524532        neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, neg->initial_sdp); 
     
    14001408                     PJMEDIA_SDPNEG_EINSTATE); 
    14011409 
    1402     /* Clear temporary SDP */ 
    1403     neg->neg_local_sdp = neg->neg_remote_sdp = NULL; 
    1404     neg->has_remote_answer = PJ_FALSE; 
    1405  
    14061410    if (neg->state == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER && 
    14071411        neg->active_local_sdp)  
     
    14141418    } 
    14151419 
     1420    /* Revert back initial SDP */ 
     1421    if (neg->state == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) 
     1422        neg->initial_sdp = neg->initial_sdp_tmp; 
     1423 
     1424    /* Clear temporary SDP */ 
     1425    neg->initial_sdp_tmp = NULL; 
     1426    neg->neg_local_sdp = neg->neg_remote_sdp = NULL; 
     1427    neg->has_remote_answer = PJ_FALSE; 
     1428 
    14161429    /* Reset state to done */ 
    14171430    neg->state = PJMEDIA_SDP_NEG_STATE_DONE; 
     
    14771490    neg->answer_was_remote = neg->has_remote_answer; 
    14781491 
     1492    /* Revert back initial SDP if nego fails */ 
     1493    if (status != PJ_SUCCESS) 
     1494        neg->initial_sdp = neg->initial_sdp_tmp; 
     1495 
    14791496    /* Clear temporary SDP */ 
     1497    neg->initial_sdp_tmp = NULL; 
    14801498    neg->neg_local_sdp = neg->neg_remote_sdp = NULL; 
    14811499    neg->has_remote_answer = PJ_FALSE; 
Note: See TracChangeset for help on using the changeset viewer.