Changeset 2945 for pjproject/trunk
- Timestamp:
- Oct 14, 2009 1:13:18 PM (15 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/transport.h
r2394 r2945 504 504 * Specifies number of transport specific info included. 505 505 */ 506 intspecific_info_cnt;506 unsigned specific_info_cnt; 507 507 508 508 /** -
pjproject/trunk/pjmedia/include/pjmedia/transport_ice.h
r2394 r2945 61 61 62 62 } pjmedia_ice_cb; 63 64 65 /** 66 * This structure specifies ICE transport specific info. This structure 67 * will be filled in media transport specific info. 68 */ 69 typedef struct pjmedia_ice_transport_info 70 { 71 /** 72 * ICE sesion state. 73 */ 74 pj_ice_strans_state sess_state; 75 76 /** 77 * Session role. 78 */ 79 pj_ice_sess_role role; 80 81 /** 82 * Number of components in the component array. Before ICE negotiation 83 * is complete, the number represents the number of components of the 84 * local agent. After ICE negotiation has been completed successfully, 85 * the number represents the number of common components between local 86 * and remote agents. 87 */ 88 unsigned comp_cnt; 89 90 /** 91 * Array of ICE components. Typically the first element denotes RTP and 92 * second element denotes RTCP. 93 */ 94 struct 95 { 96 /** 97 * Local candidate type. 98 */ 99 pj_ice_cand_type lcand_type; 100 101 /** 102 * Remote candidate type. 103 */ 104 pj_ice_cand_type rcand_type; 105 106 } comp[2]; 107 108 } pjmedia_ice_transport_info; 63 109 64 110 -
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r2896 r2945 1474 1474 } 1475 1475 1476 /* Fill up transport specific info */ 1477 if (info->specific_info_cnt < PJ_ARRAY_SIZE(info->spc_info)) { 1478 pjmedia_transport_specific_info *tsi; 1479 pjmedia_ice_transport_info *ii; 1480 unsigned i; 1481 1482 pj_assert(sizeof(*ii) <= sizeof(tsi->buffer)); 1483 tsi = &info->spc_info[info->specific_info_cnt++]; 1484 tsi->type = PJMEDIA_TRANSPORT_TYPE_ICE; 1485 tsi->cbsize = sizeof(*ii); 1486 1487 ii = (pjmedia_ice_transport_info*) tsi->buffer; 1488 pj_bzero(ii, sizeof(*ii)); 1489 1490 if (pj_ice_strans_has_sess(tp_ice->ice_st)) 1491 ii->role = pj_ice_strans_get_role(tp_ice->ice_st); 1492 else 1493 ii->role = PJ_ICE_SESS_ROLE_UNKNOWN; 1494 ii->sess_state = pj_ice_strans_get_state(tp_ice->ice_st); 1495 ii->comp_cnt = pj_ice_strans_get_running_comp_cnt(tp_ice->ice_st); 1496 1497 for (i=1; i<=ii->comp_cnt && i<=PJ_ARRAY_SIZE(ii->comp); ++i) { 1498 const pj_ice_sess_check *chk; 1499 1500 chk = pj_ice_strans_get_valid_pair(tp_ice->ice_st, i); 1501 if (chk) { 1502 ii->comp[i-1].lcand_type = chk->lcand->type; 1503 ii->comp[i-1].rcand_type = chk->rcand->type; 1504 } 1505 } 1506 } 1507 1476 1508 return PJ_SUCCESS; 1477 1509 } -
pjproject/trunk/pjnath/include/pjnath/ice_strans.h
r2724 r2945 328 328 329 329 330 /** 331 * ICE stream transport's state. 332 */ 333 typedef enum pj_ice_strans_state 334 { 335 /** 336 * ICE stream transport is not created. 337 */ 338 PJ_ICE_STRANS_STATE_NULL, 339 340 /** 341 * ICE candidate gathering process is in progress. 342 */ 343 PJ_ICE_STRANS_STATE_INIT, 344 345 /** 346 * ICE stream transport initialization/candidate gathering process is 347 * complete, ICE session may be created on this stream transport. 348 */ 349 PJ_ICE_STRANS_STATE_READY, 350 351 /** 352 * New session has been created and the session is ready. 353 */ 354 PJ_ICE_STRANS_STATE_SESS_READY, 355 356 /** 357 * ICE negotiation is in progress. 358 */ 359 PJ_ICE_STRANS_STATE_NEGO, 360 361 /** 362 * ICE negotiation has completed successfully and media is ready 363 * to be used. 364 */ 365 PJ_ICE_STRANS_STATE_RUNNING, 366 367 /** 368 * ICE negotiation has completed with failure. 369 */ 370 PJ_ICE_STRANS_STATE_FAILED 371 372 } pj_ice_strans_state; 373 374 330 375 /** 331 376 * Initialize ICE transport configuration with default values. … … 370 415 const pj_ice_strans_cb *cb, 371 416 pj_ice_strans **p_ice_st); 417 418 /** 419 * Get ICE session state. 420 * 421 * @param ice_st The ICE stream transport. 422 * 423 * @return ICE session state. 424 */ 425 PJ_DECL(pj_ice_strans_state) pj_ice_strans_get_state(pj_ice_strans *ice_st); 426 427 428 /** 429 * Get string representation of ICE state. 430 * 431 * @param state ICE stream transport state. 432 * 433 * @return String. 434 */ 435 PJ_DECL(const char*) pj_ice_strans_state_name(pj_ice_strans_state state); 436 372 437 373 438 /** -
pjproject/trunk/pjnath/src/pjnath/ice_strans.c
r2724 r2945 174 174 pj_lock_t *init_lock; /**< Initialization mutex. */ 175 175 176 pj_ice_strans_state state; /**< Session state. */ 176 177 pj_ice_sess *ice; /**< ICE session. */ 177 178 pj_time_val start_time;/**< Time when ICE was started */ … … 488 489 ice_st->comp = (pj_ice_strans_comp**) 489 490 pj_pool_calloc(pool, comp_cnt, sizeof(pj_ice_strans_comp*)); 491 492 /* Move state to candidate gathering */ 493 ice_st->state = PJ_ICE_STRANS_STATE_INIT; 490 494 491 495 /* Acquire initialization mutex to prevent callback to be … … 562 566 } 563 567 568 /* Get ICE session state. */ 569 PJ_DEF(pj_ice_strans_state) pj_ice_strans_get_state(pj_ice_strans *ice_st) 570 { 571 return ice_st->state; 572 } 573 574 /* State string */ 575 PJ_DEF(const char*) pj_ice_strans_state_name(pj_ice_strans_state state) 576 { 577 const char *names[] = { 578 "Null", 579 "Candidate Gathering", 580 "Candidate Gathering Complete", 581 "Session Initialized", 582 "Negotiation In Progress", 583 "Negotiation Success", 584 "Negotiation Failed" 585 }; 586 587 PJ_ASSERT_RETURN(state <= PJ_ICE_STRANS_STATE_FAILED, "???"); 588 return names[state]; 589 } 590 564 591 /* Notification about failure */ 565 592 static void sess_fail(pj_ice_strans *ice_st, pj_ice_strans_op op, … … 604 631 /* All candidates have been gathered */ 605 632 ice_st->cb_called = PJ_TRUE; 633 ice_st->state = PJ_ICE_STRANS_STATE_READY; 606 634 if (ice_st->cb.on_ice_complete) 607 635 (*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_INIT, … … 783 811 } 784 812 813 /* ICE session is ready for negotiation */ 814 ice_st->state = PJ_ICE_STRANS_STATE_SESS_READY; 815 785 816 return PJ_SUCCESS; 786 817 … … 983 1014 } 984 1015 1016 ice_st->state = PJ_ICE_STRANS_STATE_NEGO; 985 1017 return status; 986 1018 } … … 1012 1044 } 1013 1045 1046 ice_st->state = PJ_ICE_STRANS_STATE_INIT; 1014 1047 return PJ_SUCCESS; 1015 1048 } … … 1170 1203 } 1171 1204 1205 ice_st->state = (status==PJ_SUCCESS) ? PJ_ICE_STRANS_STATE_RUNNING : 1206 PJ_ICE_STRANS_STATE_FAILED; 1207 1172 1208 (*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_NEGOTIATION, 1173 1209 status); -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r2874 r2945 83 83 pj_bool_t med_tp_auto_del; /**< May delete media transport */ 84 84 pjsua_med_tp_st med_tp_st; /**< Media transport state */ 85 pj_sockaddr med_rtp_addr; /**< Current RTP source address 86 (used to update ICE default 87 address) */ 85 88 pj_stun_nat_type rem_nat_type; /**< NAT type of remote endpoint. */ 86 89 pjmedia_srtp_use rem_srtp_use; /**< Remote's SRTP usage policy. */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r2943 r2945 2830 2830 } 2831 2831 2832 /* Get SRTP status */2832 /* Get and ICE SRTP status */ 2833 2833 pjmedia_transport_info_init(&tp_info); 2834 2834 pjmedia_transport_get_info(call->med_tp, &tp_info); 2835 2835 if (tp_info.specific_info_cnt > 0) { 2836 inti;2836 unsigned i; 2837 2837 for (i = 0; i < tp_info.specific_info_cnt; ++i) { 2838 2838 if (tp_info.spc_info[i].type == PJMEDIA_TRANSPORT_TYPE_SRTP) … … 2851 2851 *p = '\0'; 2852 2852 } 2853 break; 2853 } else if (tp_info.spc_info[i].type==PJMEDIA_TRANSPORT_TYPE_ICE) { 2854 const pjmedia_ice_transport_info *ii; 2855 2856 ii = (const pjmedia_ice_transport_info*) 2857 tp_info.spc_info[i].buffer; 2858 2859 len = pj_ansi_snprintf(p, end-p, 2860 "%s ICE role: %s, state: %s, comp_cnt: %u", 2861 indent, 2862 pj_ice_sess_role_name(ii->role), 2863 pj_ice_strans_state_name(ii->sess_state), 2864 ii->comp_cnt); 2865 if (len > 0 && len < end-p) { 2866 p += len; 2867 *p++ = '\n'; 2868 *p = '\0'; 2869 } 2854 2870 } 2855 2871 } -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r2943 r2945 822 822 pjsua_var.ua_cfg.cb.on_call_media_state(id); 823 823 } 824 } else { 825 /* Send UPDATE if default transport address is different than 826 * what was advertised (ticket #881) 827 */ 828 pjmedia_transport_info tpinfo; 829 pjmedia_ice_transport_info *ii = NULL; 830 unsigned i; 831 832 pjmedia_transport_info_init(&tpinfo); 833 pjmedia_transport_get_info(tp, &tpinfo); 834 for (i=0; i<tpinfo.specific_info_cnt; ++i) { 835 if (tpinfo.spc_info[i].type==PJMEDIA_TRANSPORT_TYPE_ICE) { 836 ii = (pjmedia_ice_transport_info*) 837 tpinfo.spc_info[i].buffer; 838 break; 839 } 840 } 841 842 if (ii && ii->role==PJ_ICE_SESS_ROLE_CONTROLLING && 843 pj_sockaddr_cmp(&tpinfo.sock_info.rtp_addr_name, 844 &pjsua_var.calls[id].med_rtp_addr)) 845 { 846 PJ_LOG(4,(THIS_FILE, 847 "ICE default transport address has changed for " 848 "call %d, sending UPDATE", id)); 849 pjsua_call_update(id, 0, NULL); 850 } 824 851 } 825 852 break; … … 1321 1348 } 1322 1349 1350 /* Update currently advertised RTP source address */ 1351 pj_memcpy(&call->med_rtp_addr, &tpinfo.sock_info.rtp_addr_name, 1352 sizeof(pj_sockaddr)); 1353 1323 1354 *p_sdp = sdp; 1324 1355 return PJ_SUCCESS; … … 1483 1514 pjmedia_transport_get_info(call->med_tp, &tp_info); 1484 1515 if (tp_info.specific_info_cnt > 0) { 1485 inti;1516 unsigned i; 1486 1517 for (i = 0; i < tp_info.specific_info_cnt; ++i) { 1487 1518 if (tp_info.spc_info[i].type == PJMEDIA_TRANSPORT_TYPE_SRTP)
Note: See TracChangeset
for help on using the changeset viewer.