Changeset 5788 for pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
- Timestamp:
- May 9, 2018 6:58:48 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
r5783 r5788 83 83 char rtp_pkt[RTP_LEN];/**< Incoming RTP packet buffer */ 84 84 85 pj_bool_t enable_rtcp_mux;/**< Enable RTP & RTCP multiplexing?*/ 86 pj_bool_t use_rtcp_mux; /**< Use RTP & RTCP multiplexing? */ 85 87 pj_sock_t rtcp_sock; /**< RTCP socket */ 86 88 pj_sockaddr rtcp_addr_name; /**< Published RTCP address. */ … … 179 181 }; 180 182 183 static const pj_str_t STR_RTCP_MUX = { "rtcp-mux", 8 }; 181 184 182 185 /** … … 398 401 if (status != PJ_EPENDING) 399 402 goto on_error; 400 #endif 403 #endif 401 404 402 405 tp->ioqueue = ioqueue; … … 535 538 sizeof(addr_text), 3))); 536 539 537 /* Also update remote RTCP address if actual RTCP source 538 * address is not heard yet. 539 */ 540 if (!pj_sockaddr_has_addr(&udp->rtcp_src_addr)) { 540 if (udp->use_rtcp_mux) { 541 pj_sockaddr_cp(&udp->rem_rtcp_addr, &udp->rem_rtp_addr); 542 pj_sockaddr_cp(&udp->rtcp_src_addr, &udp->rem_rtcp_addr); 543 } else if (!pj_sockaddr_has_addr(&udp->rtcp_src_addr)) { 544 /* Also update remote RTCP address if actual RTCP source 545 * address is not heard yet. 546 */ 541 547 pj_uint16_t port; 542 548 … … 666 672 info->sock_info.rtp_addr_name = udp->rtp_addr_name; 667 673 info->sock_info.rtcp_sock = udp->rtcp_sock; 668 info->sock_info.rtcp_addr_name = udp->rtcp_addr_name; 674 info->sock_info.rtcp_addr_name = (udp->use_rtcp_mux? 675 udp->rtp_addr_name: 676 udp->rtcp_addr_name); 669 677 670 678 /* Get remote address originating RTP & RTCP. */ … … 709 717 /* Must not be "attached" to existing application */ 710 718 //PJ_ASSERT_RETURN(!udp->attached, PJ_EINVALIDOP); 719 720 /* Check again if we are multiplexing RTP & RTCP. */ 721 udp->use_rtcp_mux = (pj_sockaddr_has_addr(rem_addr) && 722 pj_sockaddr_cmp(rem_addr, rem_rtcp) == 0); 711 723 712 724 /* Lock the ioqueue keys to make sure that callbacks are … … 978 990 979 991 sent = size; 980 status = pj_ioqueue_sendto( udp->rtcp_key, &udp->rtcp_write_op, 992 status = pj_ioqueue_sendto( (udp->use_rtcp_mux? udp->rtp_key: 993 udp->rtcp_key), &udp->rtcp_write_op, 981 994 pkt, &sent, 0, addr, addr_len); 982 995 … … 998 1011 PJ_ASSERT_RETURN(tp && pool, PJ_EINVAL); 999 1012 udp->media_options = options; 1013 udp->enable_rtcp_mux = ((options & PJMEDIA_TPMED_RTCP_MUX) != 0); 1000 1014 1001 1015 PJ_UNUSED_ARG(sdp_remote); … … 1026 1040 pjmedia_sdp_media_deactivate(pool, m_loc); 1027 1041 return PJMEDIA_SDP_EINPROTO; 1042 } 1043 } 1044 1045 if (udp->enable_rtcp_mux) { 1046 pjmedia_sdp_media *m = sdp_local->media[media_index]; 1047 pjmedia_sdp_attr *attr; 1048 pj_bool_t add_rtcp_mux = PJ_TRUE; 1049 1050 udp->use_rtcp_mux = PJ_FALSE; 1051 1052 /* Check if remote wants RTCP mux */ 1053 if (rem_sdp) { 1054 pjmedia_sdp_media *rem_m = rem_sdp->media[media_index]; 1055 1056 attr = pjmedia_sdp_attr_find(rem_m->attr_count, rem_m->attr, 1057 &STR_RTCP_MUX, NULL); 1058 udp->use_rtcp_mux = (attr? PJ_TRUE: PJ_FALSE); 1059 add_rtcp_mux = udp->use_rtcp_mux; 1060 } 1061 1062 /* Remove RTCP attribute because for subsequent offers/answers, 1063 * the address (obtained from transport_get_info() ) may be 1064 * incorrect if we are not yet confirmed to use RTCP mux 1065 * (because we are still waiting for remote answer) or 1066 * if remote rejects it. 1067 */ 1068 pjmedia_sdp_attr_remove_all(&m->attr_count, m->attr, "rtcp"); 1069 1070 if (!udp->use_rtcp_mux) { 1071 /* Add RTCP attribute if the remote doesn't offer or 1072 * rejects it. 1073 */ 1074 attr = pjmedia_sdp_attr_create_rtcp(pool, 1075 &udp->rtcp_addr_name); 1076 if (attr) 1077 pjmedia_sdp_attr_add(&m->attr_count, m->attr, attr); 1078 } 1079 1080 /* Add a=rtcp-mux attribute. */ 1081 if (add_rtcp_mux) { 1082 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 1083 attr->name = STR_RTCP_MUX; 1084 m->attr[m->attr_count++] = attr; 1028 1085 } 1029 1086 }
Note: See TracChangeset
for help on using the changeset viewer.