Ignore:
Timestamp:
Apr 2, 2007 11:30:14 AM (17 years ago)
Author:
bennylp
Message:

ICE: work in progress

File:
1 edited

Legend:

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

    r1114 r1126  
    8989 
    9090 
    91  
     91/* 
     92 * Create ICE media transport. 
     93 */ 
    9294PJ_DEF(pj_status_t) pjmedia_ice_create(pjmedia_endpt *endpt, 
    9395                                       const char *name, 
     
    132134 
    133135 
     136/* 
     137 * Destroy ICE media transport. 
     138 */ 
    134139PJ_DEF(pj_status_t) pjmedia_ice_destroy(pjmedia_transport *tp) 
    135140{ 
     
    138143    if (tp_ice->ice_st) { 
    139144        pj_ice_strans_destroy(tp_ice->ice_st); 
    140         //Must not touch tp_ice after ice_st is destroyed! 
    141         //(it has the pool) 
    142         //tp_ice->ice_st = NULL; 
     145        /*Must not touch tp_ice after ice_st is destroyed! 
     146         (it has the pool) 
     147         tp_ice->ice_st = NULL; 
     148         */ 
    143149    } 
    144150 
     
    147153 
    148154 
     155/* 
     156 * Start media transport initialization. 
     157 */ 
    149158PJ_DEF(pj_status_t) pjmedia_ice_start_init( pjmedia_transport *tp, 
    150159                                            unsigned options, 
     
    186195 
    187196 
     197/* 
     198 * Get the status of media transport initialization. 
     199 */ 
    188200PJ_DEF(pj_status_t) pjmedia_ice_get_init_status(pjmedia_transport *tp) 
    189201{ 
     
    193205 
    194206 
     207/* 
     208 * Get the component for the specified component ID. 
     209 */ 
    195210PJ_DEF(pj_status_t) pjmedia_ice_get_comp( pjmedia_transport *tp, 
    196211                                          unsigned comp_id, 
     
    205220} 
    206221 
    207 PJ_DEF(pj_ice_strans*) pjmedia_ice_get_ice_st(pjmedia_transport *tp) 
    208 { 
    209     struct transport_ice *tp_ice = (struct transport_ice*)tp; 
    210     return tp_ice->ice_st; 
    211 } 
    212  
    213  
     222 
     223/* 
     224 * Create ICE! This happens when: 
     225 *  - UAC is ready to send offer 
     226 *  - UAS have just received an offer. 
     227 */ 
    214228PJ_DEF(pj_status_t) pjmedia_ice_init_ice(pjmedia_transport *tp, 
    215229                                         pj_ice_sess_role role, 
     
    222236 
    223237 
     238/* 
     239 * For both UAC and UAS, pass in the SDP before sending it to remote. 
     240 * This will add ICE attributes to the SDP. 
     241 */ 
    224242PJ_DEF(pj_status_t) pjmedia_ice_modify_sdp(pjmedia_transport *tp, 
    225243                                           pj_pool_t *pool, 
     
    306324 
    307325 
     326/* Parse a=candidate line */ 
    308327static pj_status_t parse_cand(pj_pool_t *pool, 
    309328                              const pj_str_t *orig_input, 
     
    391410} 
    392411 
    393 static void set_no_ice(struct transport_ice *tp_ice) 
     412 
     413/* Disable ICE when SDP from remote doesn't contain a=candidate line */ 
     414static void set_no_ice(struct transport_ice *tp_ice, const char *reason) 
    394415{ 
    395416    PJ_LOG(4,(tp_ice->ice_st->obj_name,  
    396               "Remote does not support ICE, disabling local ICE")); 
     417              "Disabling local ICE, reason=%s", reason)); 
    397418    pjmedia_ice_stop_ice(&tp_ice->base); 
    398419} 
    399420 
    400421 
     422/* 
     423 * Start ICE checks when both offer and answer are available. 
     424 */ 
    401425PJ_DEF(pj_status_t) pjmedia_ice_start_ice(pjmedia_transport *tp, 
    402426                                          pj_pool_t *pool, 
     
    410434    const pjmedia_sdp_media *sdp_med; 
    411435    pj_bool_t remote_is_lite = PJ_FALSE; 
     436    pj_bool_t ice_mismatch = PJ_FALSE; 
    412437    const pj_str_t STR_CANDIDATE = {"candidate", 9}; 
    413438    const pj_str_t STR_ICE_LITE = {"ice-lite", 8}; 
     439    const pj_str_t STR_ICE_MISMATCH = {"ice-mismatch", 12}; 
    414440    pj_str_t uname, pass; 
    415441    pj_status_t status; 
     
    428454                                      "ice-ufrag", NULL); 
    429455        if (attr == NULL) { 
    430             set_no_ice(tp_ice); 
     456            set_no_ice(tp_ice, "ice-ufrag attribute not found"); 
    431457            return PJ_SUCCESS; 
    432458        } 
     
    442468                                      "ice-pwd", NULL); 
    443469        if (attr == NULL) { 
    444             set_no_ice(tp_ice); 
     470            set_no_ice(tp_ice, "ice-pwd attribute not found"); 
    445471            return PJ_SUCCESS; 
    446472        } 
     
    455481        attr = sdp_med->attr[i]; 
    456482 
    457         if (pj_strcmp(&attr->name, &STR_ICE_LITE)==0) 
     483        if (pj_strcmp(&attr->name, &STR_ICE_LITE)==0) { 
    458484            remote_is_lite = PJ_TRUE; 
     485            continue; 
     486        } 
     487 
     488        if (pj_strcmp(&attr->name, &STR_ICE_MISMATCH)==0) { 
     489            ice_mismatch = PJ_TRUE; 
     490            continue; 
     491        } 
    459492 
    460493        if (pj_strcmp(&attr->name, &STR_CANDIDATE)!=0) 
     
    466499 
    467500        cand_cnt++; 
     501    } 
     502 
     503    /* Handle ice-mismatch case */ 
     504    if (ice_mismatch) { 
     505        set_no_ice(tp_ice, "ice-mismatch detected"); 
     506        return PJ_SUCCESS; 
    468507    } 
    469508 
Note: See TracChangeset for help on using the changeset viewer.