Ignore:
Timestamp:
Mar 3, 2017 2:11:02 AM (7 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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, 
Note: See TracChangeset for help on using the changeset viewer.