- Timestamp:
- Sep 8, 2011 6:47:28 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjmedia/src/pjmedia/transport_ice.c
r3553 r3745 73 73 pj_sockaddr rtcp_src_addr; /**< Actual source RTCP address. */ 74 74 unsigned rtp_src_cnt; /**< How many pkt from this addr. */ 75 unsigned rtcp_src_cnt; /**< How many pkt from this addr. */ 75 76 76 77 unsigned tx_drop_pct; /**< Percent of tx pkts to drop. */ … … 1500 1501 if (tp_ice->use_ice || tp_ice->rtp_src_cnt) { 1501 1502 info->src_rtp_name = tp_ice->rtp_src_addr; 1503 } 1504 if (tp_ice->use_ice || tp_ice->rtcp_src_cnt) { 1502 1505 info->src_rtcp_name = tp_ice->rtcp_src_addr; 1503 1506 } … … 1565 1568 tp_ice->rtcp_src_addr = tp_ice->remote_rtcp; 1566 1569 tp_ice->rtp_src_cnt = 0; 1570 tp_ice->rtcp_src_cnt = 0; 1567 1571 1568 1572 return PJ_SUCCESS; … … 1640 1644 { 1641 1645 struct transport_ice *tp_ice; 1646 pj_bool_t discard = PJ_FALSE; 1642 1647 1643 1648 tp_ice = (struct transport_ice*) pj_ice_strans_get_user_data(ice_st); … … 1655 1660 } 1656 1661 1657 (*tp_ice->rtp_cb)(tp_ice->stream, pkt, size);1658 1659 1662 /* See if source address of RTP packet is different than the 1660 1663 * configured address, and switch RTP remote address to … … 1663 1666 */ 1664 1667 if (!tp_ice->use_ice) { 1665 1666 /* Increment counter and avoid zero */ 1667 if (++tp_ice->rtp_src_cnt == 0) 1668 tp_ice->rtp_src_cnt = 1; 1669 1670 if (pj_sockaddr_cmp(&tp_ice->remote_rtp, src_addr) != 0) { 1668 pj_bool_t enable_switch = 1669 ((tp_ice->options & PJMEDIA_ICE_NO_SRC_ADDR_CHECKING)==0); 1670 1671 if (!enable_switch || 1672 pj_sockaddr_cmp(&tp_ice->remote_rtp, src_addr) == 0) 1673 { 1674 /* Don't switch while we're receiving from remote_rtp */ 1675 tp_ice->rtp_src_cnt = 0; 1676 } else { 1677 1678 ++tp_ice->rtp_src_cnt; 1671 1679 1672 1680 /* Check if the source address is recognized. */ … … 1676 1684 /* Reset counter */ 1677 1685 tp_ice->rtp_src_cnt = 0; 1686 discard = PJ_TRUE; 1678 1687 } 1679 1688 1680 if ( (tp_ice->options & PJMEDIA_ICE_NO_SRC_ADDR_CHECKING)==0 &&1681 tp_ice->rtp_src_cnt >= PJMEDIA_RTP_NAT_PROBATION_CNT)1682 {1689 if (tp_ice->rtp_src_cnt < PJMEDIA_RTP_NAT_PROBATION_CNT) { 1690 discard = PJ_TRUE; 1691 } else { 1683 1692 char addr_text[80]; 1684 1693 … … 1709 1718 1710 1719 PJ_LOG(4,(tp_ice->base.name, 1711 "Remote RTCP address switched to %s", 1720 "Remote RTCP address switched to predicted " 1721 "address %s", 1712 1722 pj_sockaddr_print(&tp_ice->remote_rtcp, 1713 1723 addr_text, … … 1717 1727 } 1718 1728 } 1729 1730 if (!discard) 1731 (*tp_ice->rtp_cb)(tp_ice->stream, pkt, size); 1732 1719 1733 } else if (comp_id==2 && tp_ice->rtcp_cb) { 1720 (*tp_ice->rtcp_cb)(tp_ice->stream, pkt, size);1721 1734 1722 1735 /* Check if RTCP source address is the same as the configured … … 1725 1738 */ 1726 1739 if (!tp_ice->use_ice && 1727 pj_sockaddr_cmp(&tp_ice->remote_rtcp, src_addr) !=0)1740 (tp_ice->options & PJMEDIA_ICE_NO_SRC_ADDR_CHECKING)==0) 1728 1741 { 1729 pj_sockaddr_cp(&tp_ice->rtcp_src_addr, src_addr);1730 1731 if ((tp_ice->options & PJMEDIA_ICE_NO_SRC_ADDR_CHECKING)==0){1742 if (pj_sockaddr_cmp(&tp_ice->remote_rtcp, src_addr) == 0) { 1743 tp_ice->rtcp_src_cnt = 0; 1744 } else { 1732 1745 char addr_text[80]; 1733 1746 1734 pj_sockaddr_cp(&tp_ice->remote_rtcp, src_addr); 1735 1736 pj_assert(tp_ice->addr_len == pj_sockaddr_get_len(src_addr)); 1737 1738 PJ_LOG(4,(tp_ice->base.name, 1739 "Remote RTCP address switched to %s", 1740 pj_sockaddr_print(&tp_ice->remote_rtcp, addr_text, 1741 sizeof(addr_text), 3))); 1747 ++tp_ice->rtcp_src_cnt; 1748 if (tp_ice->rtcp_src_cnt < PJMEDIA_RTCP_NAT_PROBATION_CNT) { 1749 discard = PJ_TRUE; 1750 } else { 1751 tp_ice->rtcp_src_cnt = 0; 1752 pj_sockaddr_cp(&tp_ice->rtcp_src_addr, src_addr); 1753 pj_sockaddr_cp(&tp_ice->remote_rtcp, src_addr); 1754 1755 pj_assert(tp_ice->addr_len==pj_sockaddr_get_len(src_addr)); 1756 1757 PJ_LOG(4,(tp_ice->base.name, 1758 "Remote RTCP address switched to %s", 1759 pj_sockaddr_print(&tp_ice->remote_rtcp, 1760 addr_text, sizeof(addr_text), 1761 3))); 1762 } 1742 1763 } 1743 1764 } 1765 1766 if (!discard) 1767 (*tp_ice->rtcp_cb)(tp_ice->stream, pkt, size); 1744 1768 } 1745 1769
Note: See TracChangeset
for help on using the changeset viewer.