From a3e628449e6424836f02e0b6aee181a7b7ef4455 Mon Sep 17 00:00:00 2001 From: JayChen0519 <97513129+JayChen0519@users.noreply.github.com> Date: Fri, 14 Jan 2022 13:14:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3rtsp=E4=BB=A5MULTICAST?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E6=8B=89=E6=B5=81=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E5=A5=94=E6=BA=83=E9=97=AE=E9=A2=98=20(#1368)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtspPlayer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 8e584de6..a358ad28 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -300,6 +300,20 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) { if (-1 == SockUtil::joinMultiAddrFilter(fd, multiAddr.data(), get_peer_ip().data(),get_local_ip().data())) { SockUtil::joinMultiAddr(fd, multiAddr.data(),get_local_ip().data()); } + + //设置rtcp发送端口 + pRtcpSockRef = createSocket(); + if (!pRtcpSockRef->bindUdpSock(0, "0.0.0.0")) { + //分配端口失败 + throw runtime_error("open udp socket failed"); + } + + //设置发送地址和发送端口 + struct sockaddr_in rtpto; + rtpto.sin_port = ntohs(rtcp_port); + rtpto.sin_family = AF_INET; + rtpto.sin_addr.s_addr = inet_addr(get_peer_ip().data()); + pRtcpSockRef->bindPeerAddr((struct sockaddr *)&(rtpto)); } else { createUdpSockIfNecessary(track_idx); //udp单播