From 44f4e9acd434e5549276332aa454be18844db3a8 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 8 Jan 2023 21:35:50 +0800 Subject: [PATCH] =?UTF-8?q?openRtpServer=20udp=E5=A4=9A=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E9=BB=98=E8=AE=A4=E7=BB=91=E5=AE=9A=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=AB=AF=E5=9C=B0=E5=9D=80=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=A4=9A=E8=B7=AF=E5=90=8C=E6=97=B6=E6=8E=A8=E6=B5=81=E6=97=B6?= =?UTF-8?q?ssrc=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtp/RtpServer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Rtp/RtpServer.cpp b/src/Rtp/RtpServer.cpp index f355ed14..fc256110 100644 --- a/src/Rtp/RtpServer.cpp +++ b/src/Rtp/RtpServer.cpp @@ -192,12 +192,18 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_ helper = std::make_shared(std::move(rtcp_socket), stream_id); helper->startRtcp(); helper->setRtpServerInfo(local_port,tcp_mode,re_use_port,ssrc); - rtp_socket->setOnRead([rtp_socket, helper, ssrc](const Buffer::Ptr &buf, struct sockaddr *addr, int addr_len) { + bool bind_peer_addr = false; + rtp_socket->setOnRead([rtp_socket, helper, ssrc, bind_peer_addr](const Buffer::Ptr &buf, struct sockaddr *addr, int addr_len) mutable { RtpHeader *header = (RtpHeader *)buf->data(); auto rtp_ssrc = ntohl(header->ssrc); if (ssrc && rtp_ssrc != ssrc) { WarnL << "ssrc不匹配,rtp已丢弃:" << rtp_ssrc << " != " << ssrc; } else { + if (!bind_peer_addr) { + //绑定对方ip+端口,防止多个设备或一个设备多次推流从而日志报ssrc不匹配问题 + bind_peer_addr = true; + rtp_socket->bindPeerAddr(addr, addr_len); + } helper->onRecvRtp(rtp_socket, buf, addr); } });