- Timestamp:
- Dec 11, 2008 5:25:50 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r2355 r2376 595 595 } 596 596 597 /* Removing a=rtcp line when there is only one component. */ 598 if (comp_cnt == 1) { 599 attr = pjmedia_sdp_attr_find(m->attr_count, m->attr, &STR_RTCP, NULL); 600 if (attr) 601 pjmedia_sdp_attr_remove(&m->attr_count, m->attr, attr); 602 } 603 604 597 605 return PJ_SUCCESS; 598 606 } … … 749 757 { 750 758 const pjmedia_sdp_media *rem_m; 751 const pjmedia_sdp_attr * attr, *ufrag_attr, *pwd_attr;759 const pjmedia_sdp_attr *ufrag_attr, *pwd_attr; 752 760 const pjmedia_sdp_conn *rem_conn; 753 pj_bool_t comp1_found=PJ_FALSE, comp2_found=PJ_FALSE ;761 pj_bool_t comp1_found=PJ_FALSE, comp2_found=PJ_FALSE, has_rtcp=PJ_FALSE; 754 762 pj_sockaddr rem_conn_addr, rtcp_addr; 755 763 unsigned i; … … 768 776 769 777 /* Verify that default target for each component matches one of the 770 * candidate for the component. Otherwise stop ICE with ICE ice_mismatch778 * candidate for the component. Otherwise stop ICE with ICE ice_mismatch 771 779 * error. 772 780 */ … … 794 802 return status; 795 803 796 /* Component 2 is a=rtcp line, if present. */ 797 attr = pjmedia_sdp_attr_find(rem_m->attr_count, rem_m->attr, 798 &STR_RTCP, NULL); 799 if (attr && tp_ice->comp_cnt > 1) { 800 pjmedia_sdp_rtcp_attr rtcp_attr; 801 802 status = pjmedia_sdp_attr_get_rtcp(attr, &rtcp_attr); 803 if (status != PJ_SUCCESS) { 804 /* Error parsing a=rtcp attribute */ 805 return status; 806 } 807 808 if (rtcp_attr.addr.slen) { 809 /* Verify address family matches */ 810 if ((tp_ice->af==pj_AF_INET() && 811 pj_strcmp(&rtcp_attr.addr_type, &STR_IP4)!=0) || 812 (tp_ice->af==pj_AF_INET6() && 813 pj_strcmp(&rtcp_attr.addr_type, &STR_IP6)!=0)) 814 { 815 return PJMEDIA_SDP_ETPORTNOTEQUAL; 804 if (tp_ice->comp_cnt > 1) { 805 const pjmedia_sdp_attr *attr; 806 807 /* Get default RTCP candidate from a=rtcp line, if present, otherwise 808 * calculate default RTCP candidate from default RTP target. 809 */ 810 attr = pjmedia_sdp_attr_find(rem_m->attr_count, rem_m->attr, 811 &STR_RTCP, NULL); 812 has_rtcp = (attr != NULL); 813 814 if (attr) { 815 pjmedia_sdp_rtcp_attr rtcp_attr; 816 817 status = pjmedia_sdp_attr_get_rtcp(attr, &rtcp_attr); 818 if (status != PJ_SUCCESS) { 819 /* Error parsing a=rtcp attribute */ 820 return status; 816 821 } 817 818 /* Assign RTCP address */ 819 status = pj_sockaddr_init(tp_ice->af, &rtcp_addr, 820 &rtcp_attr.addr, 821 (pj_uint16_t)rtcp_attr.port); 822 if (status != PJ_SUCCESS) { 823 return PJMEDIA_SDP_EINRTCP; 822 823 if (rtcp_attr.addr.slen) { 824 /* Verify address family matches */ 825 if ((tp_ice->af==pj_AF_INET() && 826 pj_strcmp(&rtcp_attr.addr_type, &STR_IP4)!=0) || 827 (tp_ice->af==pj_AF_INET6() && 828 pj_strcmp(&rtcp_attr.addr_type, &STR_IP6)!=0)) 829 { 830 return PJMEDIA_SDP_ETPORTNOTEQUAL; 831 } 832 833 /* Assign RTCP address */ 834 status = pj_sockaddr_init(tp_ice->af, &rtcp_addr, 835 &rtcp_attr.addr, 836 (pj_uint16_t)rtcp_attr.port); 837 if (status != PJ_SUCCESS) { 838 return PJMEDIA_SDP_EINRTCP; 839 } 840 } else { 841 /* Assign RTCP address */ 842 status = pj_sockaddr_init(tp_ice->af, &rtcp_addr, 843 NULL, 844 (pj_uint16_t)rtcp_attr.port); 845 if (status != PJ_SUCCESS) { 846 return PJMEDIA_SDP_EINRTCP; 847 } 848 pj_sockaddr_copy_addr(&rtcp_addr, &rem_conn_addr); 824 849 } 825 850 } else { 826 /* Assign RTCP address */ 827 status = pj_sockaddr_init(tp_ice->af, &rtcp_addr, 828 NULL, 829 (pj_uint16_t)rtcp_attr.port); 830 if (status != PJ_SUCCESS) { 831 return PJMEDIA_SDP_EINRTCP; 832 } 833 pj_sockaddr_copy_addr(&rtcp_addr, &rem_conn_addr); 834 } 835 836 sdp_state->match_comp_cnt = 2; 837 838 } else { 839 /* Don't have RTCP component */ 840 comp2_found = PJ_TRUE; 841 sdp_state->match_comp_cnt = 1; 842 } 843 844 /* Find the default address in a=candidate attributes. 851 unsigned rtcp_port; 852 853 rtcp_port = pj_sockaddr_get_port(&rem_conn_addr) + 1; 854 pj_sockaddr_cp(&rtcp_addr, &rem_conn_addr); 855 pj_sockaddr_set_port(&rtcp_addr, (pj_uint16_t)rtcp_port); 856 } 857 } 858 859 /* Find the default addresses in a=candidate attributes. 845 860 */ 846 861 for (i=0; i<rem_m->attr_count; ++i) { … … 864 879 pj_sockaddr_cmp(&rem_conn_addr, &cand.addr)==0) 865 880 { 866 /* Found */867 881 comp1_found = PJ_TRUE; 868 if (comp1_found && comp2_found)869 break;870 882 } else if (!comp2_found && cand.comp_id==COMP_RTCP && 871 883 pj_sockaddr_cmp(&rtcp_addr, &cand.addr)==0) 872 884 { 873 /* Found */874 885 comp2_found = PJ_TRUE; 875 if (comp1_found && comp2_found) 876 break; 877 } 878 879 } 880 881 if (!comp1_found || !comp2_found) { 882 /* ICE ice_mismatch */ 886 } 887 888 if (cand.comp_id == COMP_RTCP) 889 has_rtcp = PJ_TRUE; 890 891 if (comp1_found && (comp2_found || tp_ice->comp_cnt==1)) 892 break; 893 } 894 895 /* Check matched component count and ice_mismatch */ 896 if (comp1_found && (tp_ice->comp_cnt==1 || !has_rtcp)) { 897 sdp_state->match_comp_cnt = 1; 898 sdp_state->ice_mismatch = PJ_FALSE; 899 } else if (comp1_found && comp2_found) { 900 sdp_state->match_comp_cnt = 2; 901 sdp_state->ice_mismatch = PJ_FALSE; 902 } else { 903 sdp_state->match_comp_cnt = (tp_ice->comp_cnt > 1 && has_rtcp)? 2 : 1; 883 904 sdp_state->ice_mismatch = PJ_TRUE; 884 } else { 885 sdp_state->ice_mismatch = PJ_FALSE; 886 } 905 } 906 887 907 888 908 /* Detect remote restarting session */
Note: See TracChangeset
for help on using the changeset viewer.