- Timestamp:
- Jun 25, 2008 9:16:46 PM (16 years ago)
- Location:
- pjproject/trunk/pjnath
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/include/pjnath/config.h
r1988 r2054 245 245 246 246 /** 247 * The number of bits to represent component IDs. This will affect 248 * the maximum number of components (PJ_ICE_MAX_COMP) value. 249 */ 250 #ifndef PJ_ICE_COMP_BITS 251 # define PJ_ICE_COMP_BITS 3 252 #endif 253 254 255 /** 247 256 * Maximum number of ICE components. 248 * 249 * Default: 8 250 */ 251 #ifndef PJ_ICE_MAX_COMP 252 # define PJ_ICE_MAX_COMP 8 257 */ 258 #define PJ_ICE_MAX_COMP (2<<PJ_ICE_COMP_BITS) 259 260 261 /** 262 * The number of bits to represent candidate type preference. 263 */ 264 #ifndef PJ_ICE_CAND_TYPE_PREF_BITS 265 # define PJ_ICE_CAND_TYPE_PREF_BITS 2 266 #endif 267 268 269 /** 270 * The number of bits to represent ICE candidate's local preference. The 271 * local preference is used to specify preference among candidates with 272 * the same type, and ICE draft suggests 65535 as the default local 273 * preference, which means we need 16 bits to represent the value. But 274 * since we don't have the facility to specify local preference, we'll 275 * just disable this feature and let the preference sorted by the 276 * type only. 277 * 278 * Default: 0 279 */ 280 #ifndef PJ_ICE_LOCAL_PREF_BITS 281 # define PJ_ICE_LOCAL_PREF_BITS 0 253 282 #endif 254 283 -
pjproject/trunk/pjnath/src/pjnath/ice_session.c
r2047 r2054 66 66 }; 67 67 68 /* Default ICE session preferences, according to draft-ice */68 /* Candidate type preference */ 69 69 static pj_uint8_t cand_type_prefs[4] = 70 70 { 71 #if PJ_ICE_CAND_TYPE_PREF_BITS < 8 72 /* Keep it to 2 bits */ 73 3, /**< PJ_ICE_HOST_PREF */ 74 1, /**< PJ_ICE_SRFLX_PREF. */ 75 2, /**< PJ_ICE_PRFLX_PREF */ 76 0 /**< PJ_ICE_RELAYED_PREF */ 77 #else 78 /* Default ICE session preferences, according to draft-ice */ 71 79 126, /**< PJ_ICE_HOST_PREF */ 72 80 100, /**< PJ_ICE_SRFLX_PREF. */ 73 81 110, /**< PJ_ICE_PRFLX_PREF */ 74 82 0 /**< PJ_ICE_RELAYED_PREF */ 83 #endif 75 84 }; 76 85 … … 216 225 const pj_sockaddr *base_addr) 217 226 { 227 #if 0 218 228 char buf[64]; 219 229 pj_uint32_t val; … … 228 238 get_type_prefix(type), val); 229 239 pj_strdup2(pool, foundation, buf); 240 #else 241 /* Much shorter version, valid for candidates added by 242 * pj_ice_strans. 243 */ 244 foundation->ptr = (char*) pj_pool_alloc(pool, 1); 245 *foundation->ptr = (char)get_type_prefix(type); 246 foundation->slen = 1; 247 248 PJ_UNUSED_ARG(base_addr); 249 #endif 230 250 } 231 251 … … 451 471 const pj_uint8_t prefs[4]) 452 472 { 473 unsigned i; 453 474 PJ_ASSERT_RETURN(ice && prefs, PJ_EINVAL); 454 475 ice->prefs = (pj_uint8_t*) pj_pool_calloc(ice->pool, PJ_ARRAY_SIZE(prefs), 455 476 sizeof(pj_uint8_t)); 456 pj_memcpy(ice->prefs, prefs, sizeof(prefs)); 477 for (i=0; i<4; ++i) { 478 pj_assert(prefs[i] < (2 << PJ_ICE_CAND_TYPE_PREF_BITS)); 479 ice->prefs[i] = prefs[i]; 480 } 457 481 return PJ_SUCCESS; 458 482 } … … 579 603 pj_uint32_t comp_id) 580 604 { 605 #if 0 581 606 return ((ice->prefs[type] & 0xFF) << 24) + 582 607 ((local_pref & 0xFFFF) << 8) + 583 608 (((256 - comp_id) & 0xFF) << 0); 609 #else 610 enum { 611 type_mask = ((2 << PJ_ICE_CAND_TYPE_PREF_BITS) - 1), 612 local_mask = ((2 << PJ_ICE_LOCAL_PREF_BITS) - 1), 613 comp_mask = ((2 << PJ_ICE_COMP_BITS) - 1), 614 615 comp_shift = 0, 616 local_shift = (PJ_ICE_COMP_BITS), 617 type_shift = (comp_shift + local_shift), 618 619 max_comp = (2<<PJ_ICE_COMP_BITS), 620 }; 621 622 return ((ice->prefs[type] & type_mask) << type_shift) + 623 ((local_pref & local_mask) << local_shift) + 624 (((max_comp - comp_id) & comp_mask) << comp_shift); 625 #endif 584 626 } 585 627 … … 1430 1472 1431 1473 /* Add PRIORITY */ 1432 prio = CALC_CAND_PRIO(ice, PJ_ICE_CAND_TYPE_PRFLX, 65535,1474 prio = CALC_CAND_PRIO(ice, PJ_ICE_CAND_TYPE_PRFLX, 0, 1433 1475 lcand->comp_id); 1434 1476 pj_stun_msg_add_uint_attr(check->tdata->pool, check->tdata->msg, -
pjproject/trunk/pjnath/src/pjnath/ice_strans.c
r2043 r2054 46 46 }; 47 47 48 /* Candidate preference default values */ 49 #define SRFLX_PREF 65535 50 #define HOST_PREF 65530 51 #define RELAY_PREF 65525 48 /* Candidate's local preference values. This is mostly used to 49 * specify preference among candidates with the same type. Since 50 * we don't have the facility to specify that, we'll just set it 51 * all to zero. 52 */ 53 #define SRFLX_PREF 0 54 #define HOST_PREF 0 55 #define RELAY_PREF 0 56 57 /* The candidate type preference when STUN candidate is used */ 58 static pj_uint8_t srflx_pref_table[4] = 59 { 60 /* Keep it to 2 bits */ 61 1, /**< PJ_ICE_HOST_PREF */ 62 2, /**< PJ_ICE_SRFLX_PREF */ 63 3, /**< PJ_ICE_PRFLX_PREF */ 64 0 /**< PJ_ICE_RELAYED_PREF */ 65 }; 52 66 53 67 … … 640 654 ice_st->ice->user_data = (void*)ice_st; 641 655 642 #if 0643 656 /* If default candidate for components are SRFLX one, upload a custom 644 657 * type priority to ICE session so that SRFLX candidates will get … … 649 662 == PJ_ICE_CAND_TYPE_SRFLX) 650 663 { 651 pj_ice_sess_set_prefs(ice_st->ice, srflx_prio); 652 } 653 #endif 664 pj_ice_sess_set_prefs(ice_st->ice, srflx_pref_table); 665 } 654 666 655 667 /* Add components/candidates */
Note: See TracChangeset
for help on using the changeset viewer.