Ignore:
Timestamp:
Feb 13, 2013 7:43:32 AM (12 years ago)
Author:
nanang
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r4343 r4345  
    22492249#if PJSUA_MEDIA_HAS_PJMEDIA || PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO 
    22502250 
     2251static pj_bool_t is_ice_running(pjmedia_transport *tp) 
     2252{ 
     2253    pjmedia_transport_info tpinfo; 
     2254    pjmedia_ice_transport_info *ice_info; 
     2255 
     2256    pjmedia_transport_info_init(&tpinfo); 
     2257    pjmedia_transport_get_info(tp, &tpinfo); 
     2258    ice_info = (pjmedia_ice_transport_info*) 
     2259               pjmedia_transport_info_get_spc_info(&tpinfo, 
     2260                                                   PJMEDIA_TRANSPORT_TYPE_ICE); 
     2261    return (ice_info && ice_info->sess_state == PJ_ICE_STRANS_STATE_RUNNING); 
     2262} 
     2263 
     2264 
    22512265static pj_bool_t is_media_changed(const pjsua_call *call, 
    22522266                                  unsigned med_idx, 
     
    22882302        } 
    22892303 
    2290         /* Compare remote RTP address */ 
    2291         if (pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) 
     2304        /* Compare remote RTP address. If ICE is running, change in default 
     2305         * address can happen after negotiation, this can be handled 
     2306         * internally by ICE and does not need to cause media restart. 
     2307         */ 
     2308        if (!is_ice_running(call_med->tp) && 
     2309            pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) 
     2310        { 
    22922311            return PJ_TRUE; 
     2312        } 
    22932313 
    22942314        /* Compare codec info */ 
     
    23442364        } 
    23452365 
    2346         /* Compare remote RTP address */ 
    2347         if (pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) 
     2366        /* Compare remote RTP address. If ICE is running, change in default 
     2367         * address can happen after negotiation, this can be handled 
     2368         * internally by ICE and does not need to cause media restart. 
     2369         */ 
     2370        if (!is_ice_running(call_med->tp) && 
     2371            pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) 
     2372        { 
    23482373            return PJ_TRUE; 
     2374        } 
    23492375 
    23502376        /* Compare codec info */ 
     
    25552581            } else { 
    25562582                pjmedia_transport_info tp_info; 
     2583                pjmedia_srtp_info *srtp_info; 
    25572584 
    25582585                /* Start/restart media transport based on info in SDP */ 
     
    25732600                pjmedia_transport_info_init(&tp_info); 
    25742601                pjmedia_transport_get_info(call_med->tp, &tp_info); 
    2575                 if (tp_info.specific_info_cnt > 0) { 
    2576                     unsigned i; 
    2577                     for (i = 0; i < tp_info.specific_info_cnt; ++i) { 
    2578                         if (tp_info.spc_info[i].type ==  
    2579                             PJMEDIA_TRANSPORT_TYPE_SRTP) 
    2580                         { 
    2581                             pjmedia_srtp_info *srtp_info = 
    2582                                 (pjmedia_srtp_info*)tp_info.spc_info[i].buffer; 
    2583  
    2584                             call_med->rem_srtp_use = srtp_info->peer_use; 
    2585                             break; 
    2586                         } 
    2587                     } 
     2602                srtp_info = (pjmedia_srtp_info*) 
     2603                            pjmedia_transport_info_get_spc_info( 
     2604                                    &tp_info, PJMEDIA_TRANSPORT_TYPE_SRTP); 
     2605                if (srtp_info) { 
     2606                    call_med->rem_srtp_use = srtp_info->peer_use; 
    25882607                } 
    25892608 
     
    26922711            } else { 
    26932712                pjmedia_transport_info tp_info; 
     2713                pjmedia_srtp_info *srtp_info; 
    26942714 
    26952715                /* Start/restart media transport */ 
     
    27102730                pjmedia_transport_info_init(&tp_info); 
    27112731                pjmedia_transport_get_info(call_med->tp, &tp_info); 
    2712                 if (tp_info.specific_info_cnt > 0) { 
    2713                     unsigned i; 
    2714                     for (i = 0; i < tp_info.specific_info_cnt; ++i) { 
    2715                         if (tp_info.spc_info[i].type == 
    2716                                 PJMEDIA_TRANSPORT_TYPE_SRTP) 
    2717                         { 
    2718                             pjmedia_srtp_info *sri; 
    2719                             sri=(pjmedia_srtp_info*)tp_info.spc_info[i].buffer; 
    2720                             call_med->rem_srtp_use = sri->peer_use; 
    2721                             break; 
    2722                         } 
    2723                     } 
     2732                srtp_info = (pjmedia_srtp_info*) 
     2733                            pjmedia_transport_info_get_spc_info( 
     2734                                    &tp_info, PJMEDIA_TRANSPORT_TYPE_SRTP); 
     2735                if (srtp_info) { 
     2736                    call_med->rem_srtp_use = srtp_info->peer_use; 
    27242737                } 
    27252738 
Note: See TracChangeset for help on using the changeset viewer.