From b7304808b39f373532a8709c82486b6cdf7c8ede Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 3 Jul 2018 17:10:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BE=8B=E6=8E=A5=E5=8F=A3=E6=94=BE?= =?UTF-8?q?=E7=BD=AE=E5=9C=A8cpp=E6=96=87=E4=BB=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtpBroadCaster.cpp | 5 +++++ src/Rtsp/RtpBroadCaster.h | 6 ++---- src/Rtsp/UDPServer.cpp | 8 ++++++++ src/Rtsp/UDPServer.h | 10 +++------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Rtsp/RtpBroadCaster.cpp b/src/Rtsp/RtpBroadCaster.cpp index 0e004916..431924d0 100644 --- a/src/Rtsp/RtpBroadCaster.cpp +++ b/src/Rtsp/RtpBroadCaster.cpp @@ -37,6 +37,11 @@ using namespace ZL::Network; namespace ZL { namespace Rtsp { +MultiCastAddressMaker &MultiCastAddressMaker::Instance() { + static MultiCastAddressMaker instance; + return instance; +} + static uint32_t addressToInt(const string &ip){ struct in_addr addr; bzero(&addr,sizeof(addr)); diff --git a/src/Rtsp/RtpBroadCaster.h b/src/Rtsp/RtpBroadCaster.h index 0f318d39..9c5df0d4 100644 --- a/src/Rtsp/RtpBroadCaster.h +++ b/src/Rtsp/RtpBroadCaster.h @@ -47,10 +47,8 @@ namespace Rtsp { class MultiCastAddressMaker { public: - static MultiCastAddressMaker &Instance(){ - static MultiCastAddressMaker instance; - return instance; - } + static MultiCastAddressMaker &Instance(); + static bool isMultiCastAddress(uint32_t iAddr){ static uint32_t addrMin = mINI::Instance()[Config::MultiCast::kAddrMin].as(); static uint32_t addrMax = mINI::Instance()[Config::MultiCast::kAddrMax].as(); diff --git a/src/Rtsp/UDPServer.cpp b/src/Rtsp/UDPServer.cpp index e37d2a33..467b0871 100644 --- a/src/Rtsp/UDPServer.cpp +++ b/src/Rtsp/UDPServer.cpp @@ -32,6 +32,14 @@ using namespace ZL::Util; namespace ZL { namespace Rtsp { +UDPServer &UDPServer::Instance() { + static UDPServer *instance(new UDPServer()); + return *instance; +} +void UDPServer::Destory() { + delete &UDPServer::Instance(); +} + UDPServer::UDPServer() { } diff --git a/src/Rtsp/UDPServer.h b/src/Rtsp/UDPServer.h index 0ce34208..6b1c0b9a 100644 --- a/src/Rtsp/UDPServer.h +++ b/src/Rtsp/UDPServer.h @@ -47,13 +47,9 @@ public: typedef function< bool(int, const Buffer::Ptr &, struct sockaddr *)> onRecvData; UDPServer(); virtual ~UDPServer(); - static UDPServer &Instance() { - static UDPServer *instance(new UDPServer()); - return *instance; - } - static void Destory() { - delete &UDPServer::Instance(); - } + static UDPServer &Instance(); + static void Destory(); + Socket::Ptr getSock(const char *strLocalIp, int iTrackIndex,uint16_t iLocalPort = 0); void listenPeer(const char *strPeerIp, void *pSelf, const onRecvData &cb); void stopListenPeer(const char *strPeerIp, void *pSelf);