解决rtsp以MULTICAST方式拉流导致的奔溃问题 (#1368)

This commit is contained in:
JayChen0519 2022-01-14 13:14:30 +08:00 committed by GitHub
parent 30db79f4dd
commit a3e628449e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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())) { if (-1 == SockUtil::joinMultiAddrFilter(fd, multiAddr.data(), get_peer_ip().data(),get_local_ip().data())) {
SockUtil::joinMultiAddr(fd, multiAddr.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 { } else {
createUdpSockIfNecessary(track_idx); createUdpSockIfNecessary(track_idx);
//udp单播 //udp单播