Changeset 2031 for pjproject/trunk/pjnath/src/pjnath/ice_strans.c
- Timestamp:
- Jun 19, 2008 1:54:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath/ice_strans.c
r1988 r2031 701 701 702 702 /* 703 * Check if the ICE stream transport has the ICE session created. 704 */ 705 PJ_DEF(pj_bool_t) pj_ice_strans_has_sess(pj_ice_strans *ice_st) 706 { 707 PJ_ASSERT_RETURN(ice_st, PJ_FALSE); 708 return ice_st->ice != NULL; 709 } 710 711 /* 712 * Check if ICE negotiation is still running. 713 */ 714 PJ_DEF(pj_bool_t) pj_ice_strans_sess_is_running(pj_ice_strans *ice_st) 715 { 716 return ice_st && ice_st->ice && ice_st->ice->rcand_cnt && 717 !pj_ice_strans_sess_is_complete(ice_st); 718 } 719 720 721 /* 722 * Check if ICE negotiation has completed. 723 */ 724 PJ_DEF(pj_bool_t) pj_ice_strans_sess_is_complete(pj_ice_strans *ice_st) 725 { 726 return ice_st && ice_st->ice && ice_st->ice->is_complete; 727 } 728 729 730 /* 731 * Get the current/running component count. 732 */ 733 PJ_DEF(unsigned) pj_ice_strans_get_running_comp_cnt(pj_ice_strans *ice_st) 734 { 735 PJ_ASSERT_RETURN(ice_st, PJ_EINVAL); 736 737 if (ice_st->ice && ice_st->ice->rcand_cnt) { 738 return (ice_st->comp_cnt < ice_st->ice->rcand_cnt) ? 739 ice_st->comp_cnt : ice_st->ice->rcand_cnt; 740 } else { 741 return ice_st->comp_cnt; 742 } 743 } 744 745 746 /* 747 * Get the ICE username fragment and password of the ICE session. 748 */ 749 PJ_DEF(pj_status_t) pj_ice_strans_get_ufrag_pwd( pj_ice_strans *ice_st, 750 pj_str_t *loc_ufrag, 751 pj_str_t *loc_pwd, 752 pj_str_t *rem_ufrag, 753 pj_str_t *rem_pwd) 754 { 755 PJ_ASSERT_RETURN(ice_st && ice_st->ice, PJ_EINVALIDOP); 756 757 if (loc_ufrag) *loc_ufrag = ice_st->ice->rx_ufrag; 758 if (loc_pwd) *loc_pwd = ice_st->ice->rx_pass; 759 760 if (rem_ufrag || rem_pwd) { 761 PJ_ASSERT_RETURN(ice_st->ice->rcand_cnt != 0, PJ_EINVALIDOP); 762 if (rem_ufrag) *rem_ufrag = ice_st->ice->tx_ufrag; 763 if (rem_pwd) *rem_pwd = ice_st->ice->tx_pass; 764 } 765 766 return PJ_SUCCESS; 767 } 768 769 /* 703 770 * Enum candidates 704 771 */ … … 709 776 { 710 777 unsigned i, cnt; 711 pj_ice_strans_comp *comp; 712 713 PJ_ASSERT_RETURN(ice_st && comp_id && comp_id <= ice_st->comp_cnt && 714 count && cand, PJ_EINVAL); 715 716 comp = ice_st->comp[comp_id - 1];717 cnt = comp->cand_cnt; 718 cnt = (cnt > *count) ? *count : cnt;719 720 for (i=0; i<cnt; ++i) { 721 pj_memcpy(&cand[i], &comp->cand_list[i], sizeof(pj_ice_sess_cand));778 779 PJ_ASSERT_RETURN(ice_st && ice_st->ice && comp_id && 780 comp_id <= ice_st->comp_cnt && count && cand, PJ_EINVAL); 781 782 cnt = 0; 783 for (i=0; i<ice_st->ice->lcand_cnt && cnt<*count; ++i) { 784 if (ice_st->ice->lcand[i].comp_id != comp_id) 785 continue; 786 pj_memcpy(&cand[cnt], &ice_st->ice->lcand[i], 787 sizeof(pj_ice_sess_cand)); 788 ++cnt; 722 789 } 723 790
Note: See TracChangeset
for help on using the changeset viewer.