diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 0d11a09d..442f682b 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 0d11a09d5e6d76dc9f91b796cd303edb4c9d573a +Subproject commit 442f682b1aebc67ee60a1c43718b8bf66e3c1667 diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 2a044006..2224f068 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1056,7 +1056,7 @@ void installWebApi() { } RtpServer::Ptr server = std::make_shared(); - server->start(allArgs["port"], stream_id, allArgs["enable_tcp"].as(), "0.0.0.0", + server->start(allArgs["port"], stream_id, allArgs["enable_tcp"].as(), "::", allArgs["re_use_port"].as(), allArgs["ssrc"].as()); server->setOnDetach([stream_id]() { //设置rtp超时移除事件 diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index ba28bcbb..1a8eeb6b 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -209,7 +209,7 @@ string RtpProcess::get_local_ip() { if (_sock) { return _sock->get_local_ip(); } - return "0.0.0.0"; + return "::"; } uint16_t RtpProcess::get_local_port() { diff --git a/src/Rtp/RtpSender.cpp b/src/Rtp/RtpSender.cpp index b870a821..e4154fc5 100644 --- a/src/Rtp/RtpSender.cpp +++ b/src/Rtp/RtpSender.cpp @@ -37,13 +37,13 @@ void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const funct } else { auto pr = std::make_pair(std::move(_socket), Socket::createSocket(_poller, false)); //从端口池获取随机端口 - makeSockPair(pr, "0.0.0.0", true); + makeSockPair(pr, "::", true); _socket = std::move(pr.first); } auto poller = _poller; auto local_port = _socket->get_local_port(); WorkThreadPool::Instance().getPoller()->async([cb, args, weak_self, poller, local_port]() { - struct sockaddr addr; + struct sockaddr_storage addr; //切换线程目的是为了dns解析放在后台线程执行 if (!SockUtil::getDomainIP(args.dst_url.data(), args.dst_port, addr)) { poller->async([args, cb, local_port]() { @@ -59,7 +59,7 @@ void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const funct cb(local_port, SockException()); auto strong_self = weak_self.lock(); if (strong_self) { - strong_self->_socket->bindPeerAddr(&addr); + strong_self->_socket->bindPeerAddr((struct sockaddr *)&addr); strong_self->onConnect(); } }); @@ -76,7 +76,7 @@ void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const funct } else { cb(0, err); } - }, 5.0F, "0.0.0.0", args.src_port); + }, 5.0F, "::", args.src_port); } } diff --git a/src/Rtp/RtpServer.h b/src/Rtp/RtpServer.h index 8c6ce4c4..e68abb5c 100644 --- a/src/Rtp/RtpServer.h +++ b/src/Rtp/RtpServer.h @@ -40,7 +40,7 @@ public: * @param re_use_port 是否设置socket为re_use属性 */ void start(uint16_t local_port, const std::string &stream_id = "", bool enable_tcp = true, - const char *local_ip = "0.0.0.0", bool re_use_port = true, uint32_t ssrc = 0); + const char *local_ip = "::", bool re_use_port = true, uint32_t ssrc = 0); /** * 获取绑定的本地端口 diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 30c18d7a..bb23d07a 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -292,7 +292,7 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) { //udp组播 auto multiAddr = transport_map["destination"]; pRtpSockRef = createSocket(); - if (!pRtpSockRef->bindUdpSock(rtp_port, "0.0.0.0")) { + if (!pRtpSockRef->bindUdpSock(rtp_port, "::")) { pRtpSockRef.reset(); throw std::runtime_error("open udp sock err"); } @@ -303,7 +303,7 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) { //设置rtcp发送端口 pRtcpSockRef = createSocket(); - if (!pRtcpSockRef->bindUdpSock(0, "0.0.0.0")) { + if (!pRtcpSockRef->bindUdpSock(0, "::")) { //分配端口失败 throw runtime_error("open udp socket failed"); }