Ignore:
Timestamp:
Feb 13, 2013 8:20:33 AM (7 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.