Changeset 5788
- Timestamp:
- May 9, 2018 6:58:48 AM (6 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/stream.h
r5748 r5788 99 99 sin_family is zero, the RTP address 100 100 will be calculated from RTP. */ 101 pj_bool_t rtcp_mux; /**< Use RTP and RTCP multiplexing. */ 101 102 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 102 103 pj_bool_t rtcp_xr_enabled; -
pjproject/trunk/pjmedia/include/pjmedia/transport.h
r5752 r5788 258 258 * transport SRTP. 259 259 */ 260 PJMEDIA_TPMED_NO_TRANSPORT_CHECKING = 1 260 PJMEDIA_TPMED_NO_TRANSPORT_CHECKING = 1, 261 262 /** 263 * When this flag is specified, the transport will allow multiplexing 264 * RTP and RTCP, i.e. if the remote agrees, RTCP will be sent using 265 * the same socket for RTP. 266 */ 267 PJMEDIA_TPMED_RTCP_MUX = 2 261 268 262 269 } pjmedia_tranport_media_option; -
pjproject/trunk/pjmedia/include/pjmedia/vid_stream.h
r5748 r5788 156 156 sin_family is zero, the RTP address 157 157 will be calculated from RTP. */ 158 pj_bool_t rtcp_mux; /**< Use RTP and RTCP multiplexing. */ 158 159 unsigned tx_pt; /**< Outgoing codec paylaod type. */ 159 160 unsigned rx_pt; /**< Incoming codec paylaod type. */ -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r5786 r5788 272 272 } 273 273 274 static void on_rx_rtcp( void *data, 275 void *pkt, 276 pj_ssize_t bytes_read); 274 277 275 278 static pj_status_t send_rtcp(pjmedia_stream *stream, … … 1716 1719 stream->rtcp.stat.rx.discard++; 1717 1720 return; 1721 } 1722 1723 /* Check if multiplexing is allowed and the payload indicates RTCP. */ 1724 if (stream->si.rtcp_mux && hdr->pt >= 64 && hdr->pt <= 95) { 1725 on_rx_rtcp(stream, pkt, bytes_read); 1726 return; 1718 1727 } 1719 1728 … … 2504 2513 pj_sockaddr_cp(&att_param.rem_addr, &info->rem_addr); 2505 2514 pj_sockaddr_cp(&stream->rem_rtp_addr, &info->rem_addr); 2506 if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) 2515 if (stream->si.rtcp_mux) { 2516 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr); 2517 } else if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) { 2507 2518 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp); 2519 } 2508 2520 att_param.addr_len = pj_sockaddr_get_len(&info->rem_addr); 2509 2521 att_param.rtp_cb2 = &on_rx_rtp; -
pjproject/trunk/pjmedia/src/pjmedia/stream_info.c
r5748 r5788 526 526 } 527 527 528 /* Check if "rtcp-mux" is present in the SDP. */ 529 attr = pjmedia_sdp_attr_find2(rem_m->attr_count, rem_m->attr, 530 "rtcp-mux", NULL); 531 if (attr) 532 si->rtcp_mux = PJ_TRUE; 533 528 534 /* If "rtcp" attribute is present in the SDP, set the RTCP address 529 535 * from that attribute. Otherwise, calculate from RTP address. -
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r5752 r5788 82 82 pj_sockaddr rtcp_src_addr; /**< Actual source RTCP address. */ 83 83 unsigned rtcp_src_cnt; /**< How many pkt from this addr. */ 84 pj_bool_t enable_rtcp_mux;/**< Enable RTP& RTCP multiplexing?*/ 85 pj_bool_t use_rtcp_mux; /**< Use RTP & RTCP multiplexing? */ 84 86 85 87 unsigned tx_drop_pct; /**< Percent of tx pkts to drop. */ … … 194 196 static const pj_str_t STR_IP6 = { "IP6", 3 }; 195 197 static const pj_str_t STR_RTCP = { "rtcp", 4 }; 198 static const pj_str_t STR_RTCP_MUX = { "rtcp-mux", 8 }; 196 199 static const pj_str_t STR_BANDW_RR = { "RR", 2 }; 197 200 static const pj_str_t STR_BANDW_RS = { "RS", 2 }; … … 505 508 unsigned media_index, 506 509 unsigned comp_cnt, 507 pj_bool_t restart_session) 510 pj_bool_t restart_session, 511 pj_bool_t rtcp_mux) 508 512 { 509 513 enum { … … 759 763 } 760 764 } 761 765 766 /* Add a=rtcp-mux attribute */ 767 if (rtcp_mux) { 768 pjmedia_sdp_attr *attr; 769 770 attr = PJ_POOL_ZALLOC_T(sdp_pool, pjmedia_sdp_attr); 771 attr->name = STR_RTCP_MUX; 772 m->attr[m->attr_count++] = attr; 773 } 762 774 763 775 return PJ_SUCCESS; … … 895 907 /* Encode ICE in SDP */ 896 908 status = encode_session_in_sdp(tp_ice, sdp_pool, loc_sdp, media_index, 897 tp_ice->comp_cnt, PJ_FALSE); 909 tp_ice->comp_cnt, PJ_FALSE, 910 tp_ice->enable_rtcp_mux); 898 911 if (status != PJ_SUCCESS) { 899 912 set_no_ice(tp_ice, "Error encoding SDP answer", status); … … 923 936 924 937 rem_m = rem_sdp->media[media_index]; 938 939 /* Check if remote wants RTCP mux */ 940 if (tp_ice->enable_rtcp_mux) { 941 pjmedia_sdp_attr *attr; 942 943 attr = pjmedia_sdp_attr_find(rem_m->attr_count, rem_m->attr, 944 &STR_RTCP_MUX, NULL); 945 tp_ice->use_rtcp_mux = (attr? PJ_TRUE: PJ_FALSE); 946 } 925 947 926 948 /* Get the "ice-ufrag" and "ice-pwd" attributes */ … … 1064 1086 1065 1087 /* Check matched component count and ice_mismatch */ 1066 if (comp1_found && (tp_ice->comp_cnt==1 || !has_rtcp)) { 1088 if (comp1_found && 1089 (tp_ice->comp_cnt==1 || !has_rtcp || tp_ice->use_rtcp_mux)) 1090 { 1067 1091 sdp_state->match_comp_cnt = 1; 1068 1092 sdp_state->ice_mismatch = PJ_FALSE; … … 1123 1147 } 1124 1148 1149 /* Encode information in SDP if ICE is not used */ 1150 static pj_status_t encode_no_ice_in_sdp( struct transport_ice *tp_ice, 1151 pj_pool_t *pool, 1152 pjmedia_sdp_session *sdp_local, 1153 const pjmedia_sdp_session *rem_sdp, 1154 unsigned media_index) 1155 { 1156 if (tp_ice->enable_rtcp_mux) { 1157 pjmedia_sdp_media *m = sdp_local->media[media_index]; 1158 pjmedia_sdp_attr *attr; 1159 pj_bool_t add_rtcp_mux = PJ_TRUE; 1160 1161 if (rem_sdp) 1162 add_rtcp_mux = tp_ice->use_rtcp_mux; 1163 else { 1164 /* For subsequent offer, set it to false first since 1165 * we are still waiting for remote answer. 1166 */ 1167 tp_ice->use_rtcp_mux = PJ_FALSE; 1168 } 1169 1170 /* Remove RTCP attribute because for subsequent offers/answers, 1171 * the address (obtained from transport_get_info() ) may be 1172 * incorrect if we are not yet confirmed to use RTCP mux 1173 * (because we are still waiting for remote answer) or 1174 * if remote rejects it. 1175 */ 1176 pjmedia_sdp_attr_remove_all(&m->attr_count, m->attr, "rtcp"); 1177 1178 if (!tp_ice->use_rtcp_mux && tp_ice->comp_cnt > 1) { 1179 pj_ice_sess_cand cand; 1180 pj_status_t status; 1181 1182 status = pj_ice_strans_get_def_cand(tp_ice->ice_st, 2, &cand); 1183 if (status == PJ_SUCCESS) { 1184 /* Add RTCP attribute if the remote doesn't offer or 1185 * rejects it. 1186 */ 1187 attr = pjmedia_sdp_attr_create_rtcp(pool, &cand.addr); 1188 if (attr) 1189 pjmedia_sdp_attr_add(&m->attr_count, m->attr, attr); 1190 } 1191 } 1192 1193 /* Add a=rtcp-mux attribute. */ 1194 if (add_rtcp_mux) { 1195 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 1196 attr->name = STR_RTCP_MUX; 1197 m->attr[m->attr_count++] = attr; 1198 } 1199 } 1200 return PJ_SUCCESS; 1201 } 1202 1125 1203 1126 1204 /* Verify incoming offer and create initial answer */ … … 1151 1229 if (tp_ice->rem_offer_state.match_comp_cnt==0) { 1152 1230 set_no_ice(tp_ice, "No ICE found in SDP offer", PJ_SUCCESS); 1231 encode_no_ice_in_sdp(tp_ice, sdp_pool, loc_sdp, rem_sdp, 1232 media_index); 1153 1233 return PJ_SUCCESS; 1154 1234 } … … 1164 1244 status = encode_session_in_sdp(tp_ice, sdp_pool, loc_sdp, media_index, 1165 1245 tp_ice->rem_offer_state.match_comp_cnt, 1166 PJ_FALSE );1246 PJ_FALSE, tp_ice->use_rtcp_mux); 1167 1247 if (status != PJ_SUCCESS) { 1168 1248 set_no_ice(tp_ice, "Error encoding SDP answer", status); … … 1184 1264 if (pj_ice_strans_has_sess(tp_ice->ice_st) == PJ_FALSE) { 1185 1265 /* We don't have ICE */ 1266 encode_no_ice_in_sdp(tp_ice, sdp_pool, loc_sdp, NULL, media_index); 1186 1267 return PJ_SUCCESS; 1187 1268 } … … 1189 1270 comp_cnt = pj_ice_strans_get_running_comp_cnt(tp_ice->ice_st); 1190 1271 return encode_session_in_sdp(tp_ice, sdp_pool, loc_sdp, media_index, 1191 comp_cnt, PJ_FALSE );1272 comp_cnt, PJ_FALSE, tp_ice->enable_rtcp_mux); 1192 1273 } 1193 1274 … … 1218 1299 if (tp_ice->rem_offer_state.match_comp_cnt == 0) { 1219 1300 /* Remote no longer offers ICE */ 1301 encode_no_ice_in_sdp(tp_ice, sdp_pool, loc_sdp, rem_sdp, 1302 media_index); 1220 1303 return PJ_SUCCESS; 1221 1304 } … … 1228 1311 status = encode_session_in_sdp(tp_ice, sdp_pool, loc_sdp, media_index, 1229 1312 tp_ice->rem_offer_state.match_comp_cnt, 1230 tp_ice->rem_offer_state.ice_restart); 1313 tp_ice->rem_offer_state.ice_restart, 1314 tp_ice->use_rtcp_mux); 1231 1315 if (status != PJ_SUCCESS) 1232 1316 return status; … … 1241 1325 if (tp_ice->rem_offer_state.match_comp_cnt == 0) { 1242 1326 /* Remote does not support ICE */ 1327 encode_no_ice_in_sdp(tp_ice, sdp_pool, loc_sdp, rem_sdp, 1328 media_index); 1243 1329 return PJ_SUCCESS; 1244 1330 } … … 1262 1348 status = encode_session_in_sdp(tp_ice, sdp_pool, loc_sdp, media_index, 1263 1349 tp_ice->rem_offer_state.match_comp_cnt, 1264 tp_ice->rem_offer_state.ice_restart); 1350 tp_ice->rem_offer_state.ice_restart, 1351 tp_ice->use_rtcp_mux); 1265 1352 if (status != PJ_SUCCESS) 1266 1353 return status; … … 1291 1378 1292 1379 tp_ice->media_option = options; 1380 tp_ice->enable_rtcp_mux = ((options & PJMEDIA_TPMED_RTCP_MUX) != 0); 1293 1381 tp_ice->oa_role = ROLE_NONE; 1294 1382 tp_ice->initial_sdp = PJ_TRUE; … … 1402 1490 } 1403 1491 1404 cand_cnt++; 1492 if (!tp_ice->use_rtcp_mux || cand[cand_cnt].comp_id < 2) 1493 cand_cnt++; 1405 1494 } 1406 1495 … … 1655 1744 1656 1745 /* Get RTCP default address */ 1657 if (tp_ice->comp_cnt > 1) { 1746 if (tp_ice->use_rtcp_mux) { 1747 pj_sockaddr_cp(&info->sock_info.rtcp_addr_name, &cand.addr); 1748 } else if (tp_ice->comp_cnt > 1) { 1658 1749 status = pj_ice_strans_get_def_cand(tp_ice->ice_st, 2, &cand); 1659 1750 if (status != PJ_SUCCESS) … … 1750 1841 tp_ice->rtcp_cb = att_param->rtcp_cb; 1751 1842 1843 /* Check again if we are multiplexing RTP & RTCP. */ 1844 tp_ice->use_rtcp_mux = (pj_sockaddr_has_addr(&att_param->rem_addr) && 1845 pj_sockaddr_cmp(&att_param->rem_addr, 1846 &att_param->rem_rtcp) == 0); 1847 1752 1848 pj_memcpy(&tp_ice->remote_rtp, &att_param->rem_addr, att_param->addr_len); 1753 1849 pj_memcpy(&tp_ice->remote_rtcp, &att_param->rem_rtcp, att_param->addr_len); … … 1815 1911 { 1816 1912 struct transport_ice *tp_ice = (struct transport_ice*)tp; 1817 if (tp_ice->comp_cnt > 1) { 1913 1914 if (tp_ice->comp_cnt > 1 || tp_ice->use_rtcp_mux) { 1915 unsigned comp_id = (tp_ice->use_rtcp_mux? 1: 2); 1818 1916 if (addr == NULL) { 1819 1917 addr = &tp_ice->remote_rtcp; 1820 1918 addr_len = pj_sockaddr_get_len(addr); 1821 } 1822 return pj_ice_strans_sendto(tp_ice->ice_st, 2, pkt, size,1919 } 1920 return pj_ice_strans_sendto(tp_ice->ice_st, comp_id, pkt, size, 1823 1921 addr, addr_len); 1824 1922 } else { … … 1889 1987 sizeof(addr_text), 3))); 1890 1988 1891 /* Also update remote RTCP address if actual RTCP source 1892 * address is not heard yet. 1893 */ 1894 if (!pj_sockaddr_has_addr(&tp_ice->rtcp_src_addr)) { 1989 if (tp_ice->use_rtcp_mux) { 1990 pj_sockaddr_cp(&tp_ice->remote_rtcp, &tp_ice->remote_rtp); 1991 } else if (!pj_sockaddr_has_addr(&tp_ice->rtcp_src_addr)) { 1992 /* Also update remote RTCP address if actual RTCP source 1993 * address is not heard yet. 1994 */ 1895 1995 pj_uint16_t port; 1896 1996 -
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
r5781 r5788 234 234 pjmedia_srtp_setting setting; 235 235 unsigned media_option; 236 pj_bool_t use_rtcp_mux; /**< Use RTP& RTCP multiplexing?*/ 236 237 237 238 /* SRTP policy */ … … 1138 1139 } 1139 1140 1141 /* Check if we are multiplexing RTP & RTCP. */ 1142 srtp->use_rtcp_mux = (pj_sockaddr_has_addr(¶m->rem_addr) && 1143 pj_sockaddr_cmp(¶m->rem_addr, 1144 ¶m->rem_rtcp) == 0); 1140 1145 srtp->member_tp_attached = PJ_TRUE; 1141 1146 return PJ_SUCCESS; … … 1347 1352 return; 1348 1353 } 1354 1355 /* Check if multiplexing is allowed and the payload indicates RTCP. */ 1356 if (srtp->use_rtcp_mux) { 1357 pjmedia_rtp_hdr *hdr = (pjmedia_rtp_hdr *)pkt; 1358 1359 if (hdr->pt >= 64 && hdr->pt <= 95) { 1360 pj_lock_release(srtp->mutex); 1361 srtp_rtcp_cb(srtp, pkt, size); 1362 return; 1363 } 1364 } 1365 1349 1366 err = srtp_unprotect(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len); 1367 1350 1368 if (srtp->probation_cnt > 0 && 1351 1369 (err == srtp_err_status_replay_old || -
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp_dtls.c
r5783 r5788 986 986 pj_sockaddr_cp(&ap.rem_addr, &ds->rem_addr); 987 987 ap.addr_len = pj_sockaddr_get_len(&ap.rem_addr); 988 if (pj_sockaddr_has_addr(&ds->rem_rtcp)) { 988 if (pj_sockaddr_cmp(&info.sock_info.rtp_addr_name, 989 &info.sock_info.rtcp_addr_name) == 0) 990 { 991 /* Using RTP & RTCP multiplexing */ 992 pj_sockaddr_cp(&ds->rem_rtcp, &ds->rem_addr); 993 pj_sockaddr_cp(&ap.rem_rtcp, &ds->rem_rtcp); 994 } else if (pj_sockaddr_has_addr(&ds->rem_rtcp)) { 989 995 pj_sockaddr_cp(&ap.rem_rtcp, &ds->rem_rtcp); 990 996 } else { … … 1187 1193 { 1188 1194 pjmedia_transport_attach_param ap; 1195 pjmedia_transport_info info; 1196 1189 1197 pj_bzero(&ap, sizeof(ap)); 1190 1198 ap.user_data = ds->srtp; 1199 pjmedia_transport_get_info(ds->srtp->member_tp, &info); 1191 1200 1192 1201 if (sdp_remote) 1193 1202 get_rem_addrs(ds, sdp_remote, media_index); 1194 1203 1195 if (pj_sockaddr_has_addr(&ds->rem_addr)) 1204 if (pj_sockaddr_has_addr(&ds->rem_addr)) { 1196 1205 pj_sockaddr_cp(&ap.rem_addr, &ds->rem_addr); 1197 else 1206 } else if (pj_sockaddr_has_addr(&info.sock_info.rtp_addr_name)) { 1207 pj_sockaddr_cp(&ap.rem_addr, &info.sock_info.rtp_addr_name); 1208 } else { 1198 1209 pj_sockaddr_init(pj_AF_INET(), &ap.rem_addr, 0, 0); 1199 1200 if (pj_sockaddr_has_addr(&ds->rem_rtcp)) 1210 } 1211 1212 if (pj_sockaddr_cmp(&info.sock_info.rtp_addr_name, 1213 &info.sock_info.rtcp_addr_name) == 0) 1214 { 1215 /* Using RTP & RTCP multiplexing */ 1216 pj_sockaddr_cp(&ap.rem_rtcp, &ap.rem_addr); 1217 } else if (pj_sockaddr_has_addr(&ds->rem_rtcp)) { 1201 1218 pj_sockaddr_cp(&ap.rem_rtcp, &ds->rem_rtcp); 1202 else 1219 } else if (pj_sockaddr_has_addr(&info.sock_info.rtcp_addr_name)) { 1220 pj_sockaddr_cp(&ap.rem_rtcp, &info.sock_info.rtcp_addr_name); 1221 } else { 1203 1222 pj_sockaddr_init(pj_AF_INET(), &ap.rem_rtcp, 0, 0); 1223 } 1204 1224 1205 1225 ap.addr_len = pj_sockaddr_get_len(&ap.rem_addr); -
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 } -
pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c
r5752 r5788 219 219 pj_bool_t with_bye); 220 220 221 static void on_rx_rtcp( void *data, 222 void *pkt, 223 pj_ssize_t bytes_read); 221 224 222 225 #if TRACE_JB … … 650 653 stream->rtcp.stat.rx.discard++; 651 654 return; 655 } 656 657 /* Check if multiplexing is allowed and the payload indicates RTCP. */ 658 if (stream->info.rtcp_mux && hdr->pt >= 64 && hdr->pt <= 95) { 659 on_rx_rtcp(stream, pkt, bytes_read); 660 return; 652 661 } 653 662 … … 1737 1746 pj_sockaddr_cp(&att_param.rem_addr, &info->rem_addr); 1738 1747 pj_sockaddr_cp(&stream->rem_rtp_addr, &info->rem_addr); 1739 if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) 1740 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp); 1748 if (info->rtcp_mux) { 1749 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr); 1750 } else if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) { 1751 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp); 1752 } 1741 1753 att_param.addr_len = pj_sockaddr_get_len(&info->rem_addr); 1742 1754 att_param.rtp_cb2 = &on_rx_rtp; -
pjproject/trunk/pjmedia/src/pjmedia/vid_stream_info.c
r5748 r5788 349 349 } 350 350 351 /* Check if "rtcp-mux" is present in the SDP. */ 352 attr = pjmedia_sdp_attr_find2(rem_m->attr_count, rem_m->attr, 353 "rtcp-mux", NULL); 354 if (attr) 355 si->rtcp_mux = PJ_TRUE; 356 351 357 /* If "rtcp" attribute is present in the SDP, set the RTCP address 352 358 * from that attribute. Otherwise, calculate from RTP address. -
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_config.c
r5755 r5788 192 192 puts (" --turn-user TURN username"); 193 193 puts (" --turn-passwd TURN password"); 194 puts (" --rtcp-mux Enable RTP & RTCP multiplexing (default: no)"); 194 195 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 195 196 puts (" --srtp-keying SRTP keying method for outgoing SDP offer."); … … 360 361 OPT_USE_ICE, OPT_ICE_REGULAR, OPT_USE_SRTP, OPT_SRTP_SECURE, 361 362 OPT_USE_TURN, OPT_ICE_MAX_HOSTS, OPT_ICE_NO_RTCP, OPT_TURN_SRV, 362 OPT_TURN_TCP, OPT_TURN_USER, OPT_TURN_PASSWD, OPT_SRTP_KEYING, 363 OPT_TURN_TCP, OPT_TURN_USER, OPT_TURN_PASSWD, OPT_RTCP_MUX, 364 OPT_SRTP_KEYING, 363 365 OPT_PLAY_FILE, OPT_PLAY_TONE, OPT_RTP_PORT, OPT_ADD_CODEC, 364 366 OPT_ILBC_MODE, OPT_REC_FILE, OPT_AUTO_REC, … … 453 455 { "turn-user", 1, 0, OPT_TURN_USER}, 454 456 { "turn-passwd",1, 0, OPT_TURN_PASSWD}, 457 { "rtcp-mux", 0, 0, OPT_RTCP_MUX}, 455 458 456 459 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) … … 1022 1025 break; 1023 1026 1027 case OPT_RTCP_MUX: 1028 cur_acc->enable_rtcp_mux = PJ_TRUE; 1029 break; 1030 1024 1031 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 1025 1032 case OPT_USE_SRTP: … … 1761 1768 pj_strcat2(result, line); 1762 1769 } 1770 1771 if (acc_cfg->enable_rtcp_mux) 1772 pj_strcat2(result, "--rtcp-mux\n"); 1763 1773 } 1764 1774 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r5755 r5788 3908 3908 pjsua_ip_change_acc_cfg ip_change_cfg; 3909 3909 3910 /** 3911 * Enable RTP and RTCP multiplexing. 3912 */ 3913 pj_bool_t enable_rtcp_mux; 3914 3910 3915 } pjsua_acc_config; 3911 3916 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r5748 r5788 84 84 pjsua_med_tp_st tp_st; /**< Media transport state */ 85 85 pj_bool_t use_custom_med_tp;/**< Use custom media transport? */ 86 pj_bool_t enable_rtcp_mux;/**< Enable RTP& RTCP multiplexing?*/ 86 87 pj_sockaddr rtp_addr; /**< Current RTP source address 87 88 (used to update ICE default -
pjproject/trunk/pjsip/include/pjsua2/account.hpp
r5775 r5788 850 850 pjsua_ipv6_use ipv6Use; 851 851 852 /** 853 * Enable RTP and RTCP multiplexing. 854 */ 855 pj_bool_t rtcpMuxEnabled; 856 852 857 public: 853 858 /** -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r5784 r5788 1339 1339 acc->cfg.nat64_opt = cfg->nat64_opt; 1340 1340 acc->cfg.ipv6_media_use = cfg->ipv6_media_use; 1341 acc->cfg.enable_rtcp_mux = cfg->enable_rtcp_mux; 1341 1342 1342 1343 /* STUN and Media customization */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r5748 r5788 4389 4389 pjmedia_transport_media_stop(call_med->tp); 4390 4390 pjmedia_transport_media_create(call_med->tp, call->inv->pool_prov, 4391 0, NULL, mi); 4391 (call_med->enable_rtcp_mux? 4392 PJMEDIA_TPMED_RTCP_MUX: 0), 4393 NULL, mi); 4392 4394 4393 4395 PJ_LOG(4, (THIS_FILE, "Restarting ICE for media %d", mi)); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r5774 r5788 579 579 pj_sockaddr_cp(&skinfo->rtcp_addr_name, &mapped_addr[1]); 580 580 581 PJ_LOG(4,(THIS_FILE, "RTP socket reachable at %s", 581 PJ_LOG(4,(THIS_FILE, "RTP%s socket reachable at %s", 582 (call_med->enable_rtcp_mux? " & RTCP": ""), 582 583 pj_sockaddr_print(&skinfo->rtp_addr_name, addr_buf, 583 584 sizeof(addr_buf), 3))); … … 1832 1833 1833 1834 if (call_med->tp) { 1835 unsigned options = (call_med->enable_rtcp_mux? 1836 PJMEDIA_TPMED_RTCP_MUX: 0); 1834 1837 status = pjmedia_transport_media_create( 1835 1838 call_med->tp, tmp_pool, 1836 0, call->async_call.rem_sdp, mi);1839 options, call->async_call.rem_sdp, mi); 1837 1840 } 1838 1841 if (status != PJ_SUCCESS) { … … 2154 2157 2155 2158 if (enabled) { 2159 call_med->enable_rtcp_mux = acc->cfg.enable_rtcp_mux; 2160 2156 2161 status = pjsua_call_media_init(call_med, media_type, 2157 2162 &acc->cfg.rtp_cfg, … … 2790 2795 * internally by ICE and does not need to cause media restart. 2791 2796 */ 2797 if (old_si->rtcp_mux != new_si->rtcp_mux) 2798 return PJ_TRUE; 2792 2799 if (!is_ice_running(call_med->tp) && 2793 2800 pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) … … 2852 2859 * internally by ICE and does not need to cause media restart. 2853 2860 */ 2861 if (old_si->rtcp_mux != new_si->rtcp_mux) 2862 return PJ_TRUE; 2854 2863 if (!is_ice_running(call_med->tp) && 2855 2864 pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) … … 3027 3036 call_id, mi)); 3028 3037 goto on_check_med_status; 3038 } 3039 3040 /* Check if remote wants RTP and RTCP multiplexing, 3041 * but we don't enable it. 3042 */ 3043 if (si->rtcp_mux && !call_med->enable_rtcp_mux) { 3044 si->rtcp_mux = PJ_FALSE; 3029 3045 } 3030 3046 … … 3071 3087 3072 3088 if (call->inv->following_fork) { 3089 unsigned options = (call_med->enable_rtcp_mux? 3090 PJMEDIA_TPMED_RTCP_MUX: 0); 3073 3091 /* Normally media transport will automatically restart 3074 3092 * itself (if needed, based on info from the SDP) in … … 3088 3106 status = pjmedia_transport_media_create(call_med->tp, 3089 3107 tmp_pool, 3090 0, NULL, mi);3108 options, NULL, mi); 3091 3109 if (status != PJ_SUCCESS) { 3092 3110 PJ_PERROR(1,(THIS_FILE, status, … … 3205 3223 } 3206 3224 3225 /* Check if remote wants RTP and RTCP multiplexing, 3226 * but we don't enable it. 3227 */ 3228 if (si->rtcp_mux && !call_med->enable_rtcp_mux) { 3229 si->rtcp_mux = PJ_FALSE; 3230 } 3231 3207 3232 /* Check if this media is changed */ 3208 3233 stream_info.type = PJMEDIA_TYPE_VIDEO; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c
r5748 r5788 1720 1720 pjmedia_sdp_media *sdp_m; 1721 1721 pjmedia_transport_info tpinfo; 1722 unsigned options; 1722 1723 pj_status_t status; 1723 1724 … … 1758 1759 1759 1760 /* Init transport media */ 1760 status = pjmedia_transport_media_create(call_med->tp, pool, 0, 1761 options = (call_med->enable_rtcp_mux? PJMEDIA_TPMED_RTCP_MUX: 0); 1762 status = pjmedia_transport_media_create(call_med->tp, pool, options, 1761 1763 NULL, call_med->idx); 1762 1764 if (status != PJ_SUCCESS) … … 1909 1911 /* Init transport media */ 1910 1912 if (call_med->tp && call_med->tp_st == PJSUA_MED_TP_IDLE) { 1911 status = pjmedia_transport_media_create(call_med->tp, pool, 0, 1912 NULL, call_med->idx); 1913 unsigned options = (call_med->enable_rtcp_mux? 1914 PJMEDIA_TPMED_RTCP_MUX: 0); 1915 status = pjmedia_transport_media_create(call_med->tp, pool, 1916 options, NULL, 1917 call_med->idx); 1913 1918 if (status != PJ_SUCCESS) 1914 1919 goto on_error; -
pjproject/trunk/pjsip/src/pjsua2/account.cpp
r5755 r5788 359 359 NODE_READ_NUM_T ( this_node, pjsua_ipv6_use, ipv6Use); 360 360 NODE_READ_OBJ ( this_node, transportConfig); 361 NODE_READ_BOOL ( this_node, rtcpMuxEnabled); 361 362 } 362 363 … … 372 373 NODE_WRITE_NUM_T ( this_node, pjsua_ipv6_use, ipv6Use); 373 374 NODE_WRITE_OBJ ( this_node, transportConfig); 375 NODE_WRITE_BOOL ( this_node, rtcpMuxEnabled); 374 376 } 375 377 … … 560 562 ret.srtp_opt = mediaConfig.srtpOpt.toPj(); 561 563 ret.ipv6_media_use = mediaConfig.ipv6Use; 564 ret.enable_rtcp_mux = mediaConfig.rtcpMuxEnabled; 562 565 563 566 // AccountVideoConfig … … 735 738 mediaConfig.srtpOpt.fromPj(prm.srtp_opt); 736 739 mediaConfig.ipv6Use = prm.ipv6_media_use; 740 mediaConfig.rtcpMuxEnabled = prm.enable_rtcp_mux; 737 741 738 742 // AccountVideoConfig
Note: See TracChangeset
for help on using the changeset viewer.