Changeset 5562 for pjproject


Ignore:
Timestamp:
Mar 3, 2017 2:11:02 AM (8 years ago)
Author:
ming
Message:

Fixed #1966:

  • Add option to specify default address family in ICE default candidate
  • As answerer, match the address family in the SDP offer if possible.
Location:
pjproject/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/include/pjnath/ice_strans.h

    r5339 r5562  
    339339{ 
    340340    /** 
    341      * Warning: this field is deprecated and will be ignored. Please specify 
    342      * transport address family in STUN and TURN transport setting, i.e: 
    343      * \a stun_tp and \a turn_tp. 
     341     * The address family which will be used as the default address 
     342     * in the SDP offer. Setting this to pj_AF_UNSPEC() means that 
     343     * the address family will not be considered during the process 
     344     * of default candidate selection. 
     345     * 
     346     * The default value is pj_AF_INET() (IPv4). 
    344347     */ 
    345348    int                  af; 
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r5521 r5562  
    232232    pj_bzero(cfg, sizeof(*cfg)); 
    233233 
     234    cfg->af = pj_AF_INET(); 
    234235    pj_stun_config_init(&cfg->stun_cfg, NULL, 0, NULL, NULL); 
    235236    pj_ice_strans_stun_cfg_default(&cfg->stun); 
     
    346347                if (comp->cand_list[i].type == PJ_ICE_CAND_TYPE_SRFLX) { 
    347348                    comp->default_cand = i; 
    348                     break; 
     349                    if (ice_st->cfg.af == pj_AF_UNSPEC() || 
     350                        comp->cand_list[i].base_addr.addr.sa_family == 
     351                        ice_st->cfg.af) 
     352                    { 
     353                        break; 
     354                    } 
    349355                } 
    350356            } 
     
    548554 
    549555        /* Set default candidate to srflx */ 
    550         comp->default_cand = (unsigned)(cand - comp->cand_list); 
     556        if (comp->cand_list[comp->default_cand].type != PJ_ICE_CAND_TYPE_SRFLX 
     557            || (ice_st->cfg.af != pj_AF_UNSPEC() && 
     558                comp->cand_list[comp->default_cand].base_addr.addr.sa_family 
     559                != ice_st->cfg.af)) 
     560        { 
     561            comp->default_cand = (unsigned)(cand - comp->cand_list); 
     562        } 
    551563 
    552564        pj_log_pop_indent(); 
     
    639651                                   cand->type, &cand->base_addr); 
    640652 
     653            /* Set default candidate with the preferred default 
     654             * address family 
     655             */ 
     656            if (comp->ice_st->cfg.af != pj_AF_UNSPEC() && 
     657                comp->cand_list[comp->default_cand].addr.addr.sa_family != 
     658                ice_st->cfg.af) 
     659            { 
     660                comp->default_cand = (unsigned)(cand - comp->cand_list); 
     661            } 
     662 
    641663            PJ_LOG(4,(ice_st->obj_name, 
    642664                      "Comp %d/%d: host candidate %s (tpid=%d) added", 
     
    20042026 
    20052027        /* Set default candidate to relay */ 
    2006         comp->default_cand = (unsigned)(cand - comp->cand_list); 
     2028        if (comp->cand_list[comp->default_cand].type!=PJ_ICE_CAND_TYPE_RELAYED 
     2029            || (comp->ice_st->cfg.af != pj_AF_UNSPEC() && 
     2030                comp->cand_list[comp->default_cand].addr.addr.sa_family 
     2031                != comp->ice_st->cfg.af)) 
     2032        { 
     2033            comp->default_cand = (unsigned)(cand - comp->cand_list); 
     2034        } 
    20072035 
    20082036        /* Prefer IPv4 relay as default candidate for better connectivity 
    20092037         * with IPv4 endpoints. 
    20102038         */ 
     2039        /* 
    20112040        if (cand->addr.addr.sa_family != pj_AF_INET()) { 
    20122041            for (i=0; i<comp->cand_cnt; ++i) { 
     
    20202049            } 
    20212050        } 
     2051        */ 
    20222052 
    20232053        PJ_LOG(4,(comp->ice_st->obj_name, 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r5535 r5562  
    852852     
    853853    ice_cfg.opt = acc_cfg->ice_cfg.ice_opt; 
     854 
     855    if (call_med->call->async_call.rem_sdp) { 
     856        /* Match the default address family according to the offer */ 
     857        const pj_str_t ID_IP6 = { "IP6", 3}; 
     858        const pjmedia_sdp_media *m; 
     859        const pjmedia_sdp_conn *c; 
     860 
     861        m = call_med->call->async_call.rem_sdp->media[call_med->idx]; 
     862        c = m->conn? m->conn : call_med->call->async_call.rem_sdp->conn; 
     863 
     864        if (pj_stricmp(&c->addr_type, &ID_IP6) == 0) 
     865            ice_cfg.af = pj_AF_INET6(); 
     866    } else if (use_ipv6) { 
     867        ice_cfg.af = pj_AF_INET6(); 
     868    } 
    854869 
    855870    /* If STUN transport is configured, initialize STUN transport settings */ 
Note: See TracChangeset for help on using the changeset viewer.