Ticket #528: ticket528.patch
File ticket528.patch, 7.7 KB (added by nanang, 17 years ago) |
---|
-
pjmedia/include/pjmedia/transport.h
306 306 pj_size_t size); 307 307 308 308 /** 309 * This function is called by the stream to send RTCP packet using the 310 * transport with destination address other than default specified in 311 * #pjmedia_transport_attach(). 312 * 313 * Application should call #pjmedia_transport_send_rtcp2() instead of 314 * calling this function directly. 315 */ 316 pj_status_t (*send_rtcp2)(pjmedia_transport *tp, 317 const pj_sockaddr_t *addr, 318 unsigned addr_len, 319 const void *pkt, 320 pj_size_t size); 321 322 /** 309 323 * This function is called by application to generate the SDP parts 310 324 * related to transport type, e.g: ICE, SRTP. 311 325 * … … 587 601 588 602 589 603 /** 604 * Send RTCP packet with the specified media transport. This is just a simple 605 * wrapper which calls <tt>send_rtcp2()</tt> member of the transport. The 606 * RTCP packet will be delivered to the destination address specified in 607 * param addr, if addr is NULL, RTCP packet will be delivered to destination 608 * address specified in #pjmedia_transport_attach() function. 609 * 610 * @param tp The media transport. 611 * @param addr The destination address. 612 * @param addr_len Length of destination address. 613 * @param pkt The packet to send. 614 * @param size Size of the packet. 615 * 616 * @return PJ_SUCCESS on success, or the appropriate error code. 617 */ 618 PJ_INLINE(pj_status_t) pjmedia_transport_send_rtcp2(pjmedia_transport *tp, 619 const pj_sockaddr_t *addr, 620 unsigned addr_len, 621 const void *pkt, 622 pj_size_t size) 623 { 624 return (*tp->op->send_rtcp2)(tp, addr, addr_len, pkt, size); 625 } 626 627 628 /** 590 629 * Generate local SDP parts that are related to the specified media transport. 591 630 * Remote SDP might be needed as reference when application is in deciding 592 631 * side of negotiation (callee side), otherwise it should be NULL. -
pjmedia/src/pjmedia/transport_udp.c
121 121 static pj_status_t transport_send_rtcp(pjmedia_transport *tp, 122 122 const void *pkt, 123 123 pj_size_t size); 124 static pj_status_t transport_send_rtcp2(pjmedia_transport *tp, 125 const pj_sockaddr_t *addr, 126 unsigned addr_len, 127 const void *pkt, 128 pj_size_t size); 124 129 static pj_status_t transport_media_create(pjmedia_transport *tp, 125 130 pj_pool_t *pool, 126 131 unsigned options, … … 146 151 &transport_detach, 147 152 &transport_send_rtp, 148 153 &transport_send_rtcp, 154 &transport_send_rtcp2, 149 155 &transport_media_create, 150 156 &transport_media_start, 151 157 &transport_media_stop, … … 748 754 const void *pkt, 749 755 pj_size_t size) 750 756 { 757 return transport_send_rtcp2(tp, NULL, 0, pkt, size); 758 } 759 760 761 /* Called by application to send RTCP packet */ 762 static pj_status_t transport_send_rtcp2(pjmedia_transport *tp, 763 const pj_sockaddr_t *addr, 764 unsigned addr_len, 765 const void *pkt, 766 pj_size_t size) 767 { 751 768 struct transport_udp *udp = (struct transport_udp*)tp; 752 769 pj_ssize_t sent; 753 770 pj_status_t status; 754 771 755 772 PJ_ASSERT_RETURN(udp->attached, PJ_EINVALIDOP); 756 773 774 if (addr == NULL) { 775 addr = &udp->rem_rtcp_addr; 776 addr_len = udp->addr_len; 777 } 778 757 779 sent = size; 758 780 status = pj_ioqueue_sendto( udp->rtcp_key, &udp->rtcp_write_op, 759 pkt, &sent, 0, 760 &udp->rem_rtcp_addr, udp->addr_len); 781 pkt, &sent, 0, addr, addr_len); 761 782 762 783 if (status==PJ_SUCCESS || status==PJ_EPENDING) 763 784 return PJ_SUCCESS; -
pjmedia/src/pjmedia/transport_ice.c
75 75 static pj_status_t transport_send_rtcp(pjmedia_transport *tp, 76 76 const void *pkt, 77 77 pj_size_t size); 78 static pj_status_t transport_send_rtcp2(pjmedia_transport *tp, 79 const pj_sockaddr_t *addr, 80 unsigned addr_len, 81 const void *pkt, 82 pj_size_t size); 78 83 static pj_status_t transport_media_create(pjmedia_transport *tp, 79 84 pj_pool_t *pool, 80 85 unsigned options, … … 110 115 &transport_detach, 111 116 &transport_send_rtp, 112 117 &transport_send_rtcp, 118 &transport_send_rtcp2, 113 119 &transport_media_create, 114 120 &transport_media_start, 115 121 &transport_media_stop, … … 770 776 const void *pkt, 771 777 pj_size_t size) 772 778 { 779 return transport_send_rtcp2(tp, NULL, 0, pkt, size); 780 } 781 782 static pj_status_t transport_send_rtcp2(pjmedia_transport *tp, 783 const pj_sockaddr_t *addr, 784 unsigned addr_len, 785 const void *pkt, 786 pj_size_t size) 787 { 773 788 struct transport_ice *tp_ice = (struct transport_ice*)tp; 774 789 if (tp_ice->ice_st->comp_cnt > 1) { 775 return pj_ice_strans_sendto(tp_ice->ice_st, 2, 776 pkt, size, &tp_ice->remote_rtcp, 777 sizeof(pj_sockaddr_in)); 790 if (addr == NULL) { 791 addr = &tp_ice->remote_rtcp; 792 addr_len = pj_sockaddr_get_len(addr); 793 } 794 return pj_ice_strans_sendto(tp_ice->ice_st, 2, pkt, size, 795 addr, addr_len); 778 796 } else { 779 797 return PJ_SUCCESS; 780 798 } -
pjmedia/src/pjmedia/transport_srtp.c
145 145 static pj_status_t transport_send_rtcp(pjmedia_transport *tp, 146 146 const void *pkt, 147 147 pj_size_t size); 148 static pj_status_t transport_send_rtcp2(pjmedia_transport *tp, 149 const pj_sockaddr_t *addr, 150 unsigned addr_len, 151 const void *pkt, 152 pj_size_t size); 148 153 static pj_status_t transport_media_create(pjmedia_transport *tp, 149 154 pj_pool_t *pool, 150 155 unsigned options, … … 171 176 &transport_detach, 172 177 &transport_send_rtp, 173 178 &transport_send_rtcp, 179 &transport_send_rtcp2, 174 180 &transport_media_create, 175 181 &transport_media_start, 176 182 &transport_media_stop, … … 657 663 const void *pkt, 658 664 pj_size_t size) 659 665 { 666 return transport_send_rtcp2(tp, NULL, 0, pkt, size); 667 } 668 669 static pj_status_t transport_send_rtcp2(pjmedia_transport *tp, 670 const pj_sockaddr_t *addr, 671 unsigned addr_len, 672 const void *pkt, 673 pj_size_t size) 674 { 660 675 pj_status_t status; 661 676 transport_srtp *srtp = (transport_srtp*) tp; 662 677 int len = size; 663 678 err_status_t err; 664 679 665 if (srtp->bypass_srtp) 666 return pjmedia_transport_send_rtcp(srtp->real_tp, pkt, size); 680 if (srtp->bypass_srtp) { 681 return pjmedia_transport_send_rtcp2(srtp->real_tp, addr, addr_len, 682 pkt, size); 683 } 667 684 668 685 if (!srtp->session_inited) 669 686 return PJ_SUCCESS; … … 677 694 err = srtp_protect_rtcp(srtp->srtp_tx_ctx, srtp->tx_buffer, &len); 678 695 679 696 if (err == err_status_ok) { 680 status = pjmedia_transport_send_rtcp (srtp->real_tp, srtp->tx_buffer,681 len);697 status = pjmedia_transport_send_rtcp2(srtp->real_tp, addr, addr_len, 698 srtp->tx_buffer, len); 682 699 } else { 683 700 status = PJMEDIA_ERRNO_FROM_LIBSRTP(err); 684 701 } … … 688 705 return status; 689 706 } 690 707 708 691 709 static pj_status_t transport_simulate_lost(pjmedia_transport *tp, 692 710 pjmedia_dir dir, 693 711 unsigned pct_lost)