Changeset 4346 for pjproject


Ignore:
Timestamp:
Feb 13, 2013 8:20:33 AM (12 years ago)
Author:
nanang
Message:

Re #1568: (PJSIP 1.x) No need to restart media when remote RTP address changed but ICE transport is running.

Location:
pjproject/branches/1.x
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjmedia/include/pjmedia/transport.h

    r3553 r4346  
    534534 * 
    535535 * @param tp        The transport. 
    536  * @param info      Media socket info to be initialized. 
     536 * @param info      Media transport info to be initialized. 
    537537 * 
    538538 * @return          PJ_SUCCESS on success. 
     
    545545     
    546546    return PJ_ENOTSUP; 
     547} 
     548 
     549 
     550/** 
     551 * Utility API to get transport type specific info from the specified media 
     552 * transport info. 
     553 *  
     554 * @param info      Media transport info. 
     555 * @param type      Media transport type. 
     556 * 
     557 * @return          Pointer to media transport specific info, or NULL if 
     558 *                  specific info for the transport type is not found. 
     559 */ 
     560PJ_INLINE(void*) pjmedia_transport_info_get_spc_info( 
     561                                                pjmedia_transport_info *info, 
     562                                                pjmedia_transport_type type) 
     563{ 
     564    unsigned i; 
     565    for (i = 0; i < info->specific_info_cnt; ++i) { 
     566        if (info->spc_info[i].type == type) 
     567            return (void*)info->spc_info[i].buffer; 
     568    } 
     569    return NULL; 
    547570} 
    548571 
  • pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_media.c

    r4338 r4346  
    858858            pjmedia_transport_info tpinfo; 
    859859            pjmedia_ice_transport_info *ii = NULL; 
    860             unsigned i; 
    861860 
    862861            pjmedia_transport_info_init(&tpinfo); 
    863862            pjmedia_transport_get_info(tp, &tpinfo); 
    864             for (i=0; i<tpinfo.specific_info_cnt; ++i) { 
    865                 if (tpinfo.spc_info[i].type==PJMEDIA_TRANSPORT_TYPE_ICE) { 
    866                     ii = (pjmedia_ice_transport_info*) 
    867                          tpinfo.spc_info[i].buffer; 
    868                     break; 
    869                 } 
    870             } 
    871  
     863            ii = (pjmedia_ice_transport_info*) 
     864                 pjmedia_transport_info_get_spc_info( 
     865                                         &tpinfo, PJMEDIA_TRANSPORT_TYPE_ICE); 
    872866            if (ii && ii->role==PJ_ICE_SESS_ROLE_CONTROLLING && 
    873867                pj_sockaddr_cmp(&tpinfo.sock_info.rtp_addr_name, 
     
    15871581 
    15881582 
     1583static pj_bool_t is_ice_running(pjmedia_transport *tp) 
     1584{ 
     1585    pjmedia_transport_info tpinfo; 
     1586    pjmedia_ice_transport_info *ice_info; 
     1587 
     1588    pjmedia_transport_info_init(&tpinfo); 
     1589    pjmedia_transport_get_info(tp, &tpinfo); 
     1590    ice_info = (pjmedia_ice_transport_info*) 
     1591               pjmedia_transport_info_get_spc_info(&tpinfo, 
     1592                                                   PJMEDIA_TRANSPORT_TYPE_ICE); 
     1593    return (ice_info && ice_info->sess_state == PJ_ICE_STRANS_STATE_RUNNING); 
     1594} 
     1595 
     1596 
    15891597static pj_bool_t is_media_changed(const pjsua_call *call, 
    15901598                                  int new_audio_idx, 
     
    16261634        return PJ_TRUE; 
    16271635 
    1628     /* Compare remote RTP address */ 
    1629     if (pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) 
     1636    /* Compare remote RTP address. If ICE is running, change in default 
     1637     * address can happen after negotiation, this can be handled 
     1638     * internally by ICE and does not need to cause media restart. 
     1639     */ 
     1640    if (!is_ice_running(call->med_tp) && 
     1641        pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) 
     1642    { 
    16301643        return PJ_TRUE; 
     1644    } 
    16311645 
    16321646    /* Compare codec info */ 
     
    19211935    } else { 
    19221936        pjmedia_transport_info tp_info; 
     1937        pjmedia_srtp_info *srtp_info; 
    19231938 
    19241939        /* Start/restart media transport */ 
     
    19351950        pjmedia_transport_info_init(&tp_info); 
    19361951        pjmedia_transport_get_info(call->med_tp, &tp_info); 
    1937         if (tp_info.specific_info_cnt > 0) { 
    1938             unsigned i; 
    1939             for (i = 0; i < tp_info.specific_info_cnt; ++i) { 
    1940                 if (tp_info.spc_info[i].type == PJMEDIA_TRANSPORT_TYPE_SRTP)  
    1941                 { 
    1942                     pjmedia_srtp_info *srtp_info =  
    1943                                 (pjmedia_srtp_info*) tp_info.spc_info[i].buffer; 
    1944  
    1945                     call->rem_srtp_use = srtp_info->peer_use; 
    1946                     break; 
    1947                 } 
    1948             } 
     1952        srtp_info = (pjmedia_srtp_info*) 
     1953                    pjmedia_transport_info_get_spc_info( 
     1954                            &tp_info, PJMEDIA_TRANSPORT_TYPE_SRTP); 
     1955        if (srtp_info) { 
     1956            call->rem_srtp_use = srtp_info->peer_use; 
    19491957        } 
    19501958 
Note: See TracChangeset for help on using the changeset viewer.