Changeset 3745
- Timestamp:
- Sep 8, 2011 6:47:28 AM (13 years ago)
- Location:
- pjproject/branches/1.x/pjmedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjmedia/include/pjmedia/config.h
r3553 r3745 388 388 389 389 /** 390 * Number of packets received from different source IP address from the390 * Number of RTP packets received from different source IP address from the 391 391 * remote address required to make the stream switch transmission 392 392 * to the source address. … … 394 394 #ifndef PJMEDIA_RTP_NAT_PROBATION_CNT 395 395 # define PJMEDIA_RTP_NAT_PROBATION_CNT 10 396 #endif 397 398 399 /** 400 * Number of RTCP packets received from different source IP address from the 401 * remote address required to make the stream switch RTCP transmission 402 * to the source address. 403 */ 404 #ifndef PJMEDIA_RTCP_NAT_PROBATION_CNT 405 # define PJMEDIA_RTCP_NAT_PROBATION_CNT 3 396 406 #endif 397 407 -
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 -
pjproject/branches/1.x/pjmedia/src/pjmedia/transport_udp.c
r3553 r3745 84 84 pj_sockaddr rtcp_addr_name; /**< Published RTCP address. */ 85 85 pj_sockaddr rtcp_src_addr; /**< Actual source RTCP address. */ 86 unsigned rtcp_src_cnt; /**< How many pkt from this addr. */ 86 87 int rtcp_addr_len; /**< Length of RTCP src address. */ 87 88 pj_ioqueue_key_t *rtcp_key; /**< RTCP socket key in ioqueue */ … … 453 454 void (*cb)(void*,void*,pj_ssize_t); 454 455 void *user_data; 456 pj_bool_t discard = PJ_FALSE; 455 457 456 458 cb = udp->rtp_cb; … … 463 465 "RX RTP packet dropped because of pkt lost " 464 466 "simulation")); 465 goto read_next_packet;467 discard = PJ_TRUE; 466 468 } 467 469 } 468 469 470 if (udp->attached && cb)471 (*cb)(user_data, udp->rtp_pkt, bytes_read);472 470 473 471 /* See if source address of RTP packet is different than the … … 479 477 (udp->options & PJMEDIA_UDP_NO_SRC_ADDR_CHECKING)==0) 480 478 { 481 if (pj_sockaddr_cmp(&udp->rem_rtp_addr, &udp->rtp_src_addr) != 0) { 482 479 if (pj_sockaddr_cmp(&udp->rem_rtp_addr, &udp->rtp_src_addr) == 0) { 480 /* We're still receiving from rem_rtp_addr. Don't switch. */ 481 udp->rtp_src_cnt = 0; 482 } else { 483 483 udp->rtp_src_cnt++; 484 484 485 if (udp->rtp_src_cnt >= PJMEDIA_RTP_NAT_PROBATION_CNT) { 485 if (udp->rtp_src_cnt < PJMEDIA_RTP_NAT_PROBATION_CNT) { 486 discard = PJ_TRUE; 487 } else { 486 488 487 489 char addr_text[80]; … … 517 519 518 520 PJ_LOG(4,(udp->base.name, 519 "Remote RTCP address switched to %s", 521 "Remote RTCP address switched to predicted" 522 " address %s", 520 523 pj_sockaddr_print(&udp->rtcp_src_addr, 521 524 addr_text, … … 527 530 } 528 531 529 read_next_packet: 532 if (!discard && udp->attached && cb) 533 (*cb)(user_data, udp->rtp_pkt, bytes_read); 534 530 535 bytes_read = sizeof(udp->rtp_pkt); 531 536 udp->rtp_addrlen = sizeof(udp->rtp_src_addr); … … 569 574 */ 570 575 if (bytes_read>0 && 571 (udp->options & PJMEDIA_UDP_NO_SRC_ADDR_CHECKING)==0 && 572 pj_sockaddr_cmp(&udp->rem_rtcp_addr, &udp->rtcp_src_addr) != 0) 576 (udp->options & PJMEDIA_UDP_NO_SRC_ADDR_CHECKING)==0) 573 577 { 574 char addr_text[80]; 575 576 pj_memcpy(&udp->rem_rtcp_addr, &udp->rtcp_src_addr, 577 sizeof(pj_sockaddr)); 578 579 PJ_LOG(4,(udp->base.name, 580 "Remote RTCP address switched to %s", 581 pj_sockaddr_print(&udp->rtcp_src_addr, addr_text, 582 sizeof(addr_text), 3))); 578 if (pj_sockaddr_cmp(&udp->rem_rtcp_addr, &udp->rtcp_src_addr) == 0) { 579 /* Still receiving from rem_rtcp_addr, don't switch */ 580 udp->rtcp_src_cnt = 0; 581 } else { 582 ++udp->rtcp_src_cnt; 583 584 if (udp->rtcp_src_cnt >= PJMEDIA_RTCP_NAT_PROBATION_CNT ) { 585 char addr_text[80]; 586 587 udp->rtcp_src_cnt = 0; 588 pj_memcpy(&udp->rem_rtcp_addr, &udp->rtcp_src_addr, 589 sizeof(pj_sockaddr)); 590 591 PJ_LOG(4,(udp->base.name, 592 "Remote RTCP address switched to %s", 593 pj_sockaddr_print(&udp->rtcp_src_addr, addr_text, 594 sizeof(addr_text), 3))); 595 } 596 } 583 597 } 584 598 … … 678 692 pj_bzero(&udp->rtcp_src_addr, sizeof(udp->rtcp_src_addr)); 679 693 udp->rtp_src_cnt = 0; 694 udp->rtcp_src_cnt = 0; 680 695 681 696 /* Unlock keys */
Note: See TracChangeset
for help on using the changeset viewer.