mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
openRtpServer udp多端口模式默认绑定发送端地址,防止多路同时推流时ssrc冲突问题
This commit is contained in:
parent
fcf70c6ef1
commit
44f4e9acd4
@ -192,12 +192,18 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_
|
|||||||
helper = std::make_shared<RtcpHelper>(std::move(rtcp_socket), stream_id);
|
helper = std::make_shared<RtcpHelper>(std::move(rtcp_socket), stream_id);
|
||||||
helper->startRtcp();
|
helper->startRtcp();
|
||||||
helper->setRtpServerInfo(local_port,tcp_mode,re_use_port,ssrc);
|
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();
|
RtpHeader *header = (RtpHeader *)buf->data();
|
||||||
auto rtp_ssrc = ntohl(header->ssrc);
|
auto rtp_ssrc = ntohl(header->ssrc);
|
||||||
if (ssrc && rtp_ssrc != ssrc) {
|
if (ssrc && rtp_ssrc != ssrc) {
|
||||||
WarnL << "ssrc不匹配,rtp已丢弃:" << rtp_ssrc << " != " << ssrc;
|
WarnL << "ssrc不匹配,rtp已丢弃:" << rtp_ssrc << " != " << ssrc;
|
||||||
} else {
|
} else {
|
||||||
|
if (!bind_peer_addr) {
|
||||||
|
//绑定对方ip+端口,防止多个设备或一个设备多次推流从而日志报ssrc不匹配问题
|
||||||
|
bind_peer_addr = true;
|
||||||
|
rtp_socket->bindPeerAddr(addr, addr_len);
|
||||||
|
}
|
||||||
helper->onRecvRtp(rtp_socket, buf, addr);
|
helper->onRecvRtp(rtp_socket, buf, addr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user