适配ZLToolKit代码,简化程序退出流程代码

This commit is contained in:
xiongziliang
2018-12-28 16:47:50 +08:00
parent 315cd180d4
commit cc7844a994
11 changed files with 337 additions and 387 deletions

View File

@@ -26,18 +26,14 @@
#include "UDPServer.h"
#include "Util/TimeTicker.h"
#include "Util/onceToken.h"
using namespace toolkit;
namespace mediakit {
UDPServer &UDPServer::Instance() {
static UDPServer *instance(new UDPServer());
return *instance;
}
void UDPServer::Destory() {
delete &UDPServer::Instance();
}
INSTANCE_IMP(UDPServer);
UDPServer::UDPServer() {
}

View File

@@ -27,8 +27,9 @@
#ifndef RTSP_UDPSERVER_H_
#define RTSP_UDPSERVER_H_
#include <mutex>
#include <stdint.h>
#include <mutex>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include "Util/util.h"
@@ -40,18 +41,23 @@ using namespace toolkit;
namespace mediakit {
class UDPServer {
class UDPServer : public std::enable_shared_from_this<UDPServer> {
public:
typedef function< bool(int, const Buffer::Ptr &, struct sockaddr *)> onRecvData;
UDPServer();
virtual ~UDPServer();
~UDPServer();
static UDPServer &Instance();
static void Destory();
/**
* 废弃的接口,无实际操作
* @deprecated
*/
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);
private:
UDPServer();
void onRcvData(int iTrackId, const Buffer::Ptr &pBuf,struct sockaddr *pPeerAddr);
void onErr(const string &strKey,const SockException &err);
unordered_map<string, Socket::Ptr> _mapUpdSock;

View File

@@ -142,7 +142,7 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
return false;
}
WarnL << "不支持的rtp类型:" << nal.type << " " << rtppack->sequence;
WarnL << "不支持的rtp类型:" << (int)nal.type << " " << rtppack->sequence;
return false;
// 29 FU-B 单NAL单元B模式
// 24 STAP-A 单一时间的组合包