From b09919d3742706e9a7afc15e9a59f93022b7a397 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 23 Apr 2020 16:14:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BF=E6=8D=A2inet=5Fntoa=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- src/Rtp/RtpProcess.cpp | 7 ++++--- src/Rtsp/RtpMultiCaster.cpp | 2 +- src/Rtsp/RtpMultiCaster.h | 2 +- src/Rtsp/RtspPlayer.cpp | 4 ++-- src/Rtsp/RtspSession.cpp | 2 +- src/Rtsp/UDPServer.cpp | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 987683f1..f0608fb7 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 987683f1045613098e2bcd534bc90a13d16df8a4 +Subproject commit f0608fb75660682150f45f857d5d8051880b13aa diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index fd725a4a..784e7b8e 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -15,6 +15,7 @@ #include "Extension/H265.h" #include "Extension/AAC.h" #include "Extension/G711.h" +#define RTP_APP_NAME "rtp" namespace mediakit{ @@ -57,7 +58,7 @@ string printSSRC(uint32_t ui32Ssrc) { } static string printAddress(const struct sockaddr *addr){ - return StrPrinter << inet_ntoa(((struct sockaddr_in *) addr)->sin_addr) << ":" << ntohs(((struct sockaddr_in *) addr)->sin_port); + return StrPrinter << SockUtil::inet_ntoa(((struct sockaddr_in *) addr)->sin_addr) << ":" << ntohs(((struct sockaddr_in *) addr)->sin_port); } RtpProcess::RtpProcess(uint32_t ssrc) { @@ -73,7 +74,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) { GET_CONFIG(bool,toHls,General::kPublishToHls); GET_CONFIG(bool,toMP4,General::kPublishToMP4); - _muxer = std::make_shared(DEFAULT_VHOST,"rtp",printSSRC(_ssrc),0,toRtxp,toRtxp,toHls,toMP4); + _muxer = std::make_shared(DEFAULT_VHOST,RTP_APP_NAME,printSSRC(_ssrc),0,toRtxp,toRtxp,toHls,toMP4); GET_CONFIG(string,dump_dir,RtpProxy::kDumpDir); { @@ -310,7 +311,7 @@ bool RtpProcess::alive() { } string RtpProcess::get_peer_ip() { - return inet_ntoa(((struct sockaddr_in *) _addr)->sin_addr); + return SockUtil::inet_ntoa(((struct sockaddr_in *) _addr)->sin_addr); } uint16_t RtpProcess::get_peer_port() { diff --git a/src/Rtsp/RtpMultiCaster.cpp b/src/Rtsp/RtpMultiCaster.cpp index 88a38244..b341a0fb 100644 --- a/src/Rtsp/RtpMultiCaster.cpp +++ b/src/Rtsp/RtpMultiCaster.cpp @@ -141,7 +141,7 @@ uint16_t RtpMultiCaster::getPort(TrackType trackType){ return _apUdpSock[trackType]->get_local_port(); } string RtpMultiCaster::getIP(){ - return inet_ntoa(_aPeerUdpAddr[0].sin_addr); + return SockUtil::inet_ntoa(_aPeerUdpAddr[0].sin_addr); } RtpMultiCaster::Ptr RtpMultiCaster::make(const EventPoller::Ptr &poller,const string &strLocalIp,const string &strVhost,const string &strApp,const string &strStream){ try{ diff --git a/src/Rtsp/RtpMultiCaster.h b/src/Rtsp/RtpMultiCaster.h index 3e960cdb..d3893ad7 100644 --- a/src/Rtsp/RtpMultiCaster.h +++ b/src/Rtsp/RtpMultiCaster.h @@ -38,7 +38,7 @@ public: } static string toString(uint32_t iAddr){ iAddr = htonl(iAddr); - return ::inet_ntoa((struct in_addr &)(iAddr)); + return SockUtil::inet_ntoa((struct in_addr &)(iAddr)); } virtual ~MultiCastAddressMaker(){} std::shared_ptr obtain(uint32_t iTry = 10); diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 4b79d93d..24f6d1f1 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -337,7 +337,7 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int uiTrackIndex) return; } if (((struct sockaddr_in *) addr)->sin_addr.s_addr != srcIP) { - WarnL << "收到其他地址的rtp数据:" << inet_ntoa(((struct sockaddr_in *) addr)->sin_addr); + WarnL << "收到其他地址的rtp数据:" << SockUtil::inet_ntoa(((struct sockaddr_in *) addr)->sin_addr); return; } strongSelf->handleOneRtp(uiTrackIndex, strongSelf->_aTrackInfo[uiTrackIndex], (unsigned char *) buf->data(), buf->size()); @@ -351,7 +351,7 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int uiTrackIndex) return; } if (((struct sockaddr_in *) addr)->sin_addr.s_addr != srcIP) { - WarnL << "收到其他地址的rtcp数据:" << inet_ntoa(((struct sockaddr_in *) addr)->sin_addr); + WarnL << "收到其他地址的rtcp数据:" << SockUtil::inet_ntoa(((struct sockaddr_in *) addr)->sin_addr); return; } strongSelf->onRtcpPacket(uiTrackIndex, strongSelf->_aTrackInfo[uiTrackIndex], (unsigned char *) buf->data(), buf->size()); diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index d1e07a82..0e7f3213 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -955,7 +955,7 @@ inline void RtspSession::startListenPeerUdpData(int trackIdx) { if (((struct sockaddr_in *) pPeerAddr)->sin_addr.s_addr != srcIP) { WarnP(strongSelf.get()) << ((intervaled % 2 == 0) ? "收到其他地址的rtp数据:" : "收到其他地址的rtcp数据:") - << inet_ntoa(((struct sockaddr_in *) pPeerAddr)->sin_addr); + << SockUtil::inet_ntoa(((struct sockaddr_in *) pPeerAddr)->sin_addr); return true; } diff --git a/src/Rtsp/UDPServer.cpp b/src/Rtsp/UDPServer.cpp index 7dd47615..a31b3815 100644 --- a/src/Rtsp/UDPServer.cpp +++ b/src/Rtsp/UDPServer.cpp @@ -76,7 +76,7 @@ void UDPServer::onErr(const string& strKey, const SockException& err) { void UDPServer::onRcvData(int intervaled, const Buffer::Ptr &pBuf, struct sockaddr* pPeerAddr) { //TraceL << trackIndex; struct sockaddr_in *in = (struct sockaddr_in *) pPeerAddr; - string peerIp = inet_ntoa(in->sin_addr); + string peerIp = SockUtil::inet_ntoa(in->sin_addr); lock_guard lck(_mtxDataHandler); auto it0 = _mapDataHandler.find(peerIp); if (it0 == _mapDataHandler.end()) {