优化代码

空构造和析构函数替换为缺省
去除多余分号
This commit is contained in:
xiongziliang 2023-04-22 21:59:26 +08:00
parent e8a425945d
commit 7a95c87a29
21 changed files with 50 additions and 57 deletions

View File

@ -24,7 +24,7 @@ public:
MediaPlayerForC(){
_player = std::make_shared<MediaPlayer>();
}
~MediaPlayerForC(){}
~MediaPlayerForC() = default;
MediaPlayer *operator->(){
return _player.get();

View File

@ -260,16 +260,16 @@ int start_main(int argc,char *argv[]) {
auto shellSrv = std::make_shared<TcpServer>();
//rtsp[s]服务器, 可用于诸如亚马逊echo show这样的设备访问
auto rtspSrv = std::make_shared<TcpServer>();;
auto rtspSSLSrv = std::make_shared<TcpServer>();;
auto rtspSrv = std::make_shared<TcpServer>();
auto rtspSSLSrv = std::make_shared<TcpServer>();
//rtmp[s]服务器
auto rtmpSrv = std::make_shared<TcpServer>();;
auto rtmpsSrv = std::make_shared<TcpServer>();;
auto rtmpSrv = std::make_shared<TcpServer>();
auto rtmpsSrv = std::make_shared<TcpServer>();
//http[s]服务器
auto httpSrv = std::make_shared<TcpServer>();;
auto httpsSrv = std::make_shared<TcpServer>();;
auto httpSrv = std::make_shared<TcpServer>();
auto httpsSrv = std::make_shared<TcpServer>();
#if defined(ENABLE_RTPPROXY)
//GB28181 rtp推流端口支持UDP/TCP

View File

@ -24,9 +24,8 @@ namespace mediakit{
class Track : public FrameDispatcher , public CodecInfo{
public:
using Ptr = std::shared_ptr<Track>;
Track(){}
virtual ~Track(){}
Track() = default;
virtual ~Track() = default;
/**
* sps pps等信息
@ -177,8 +176,8 @@ private:
class TrackSource{
public:
TrackSource(){}
virtual ~TrackSource(){}
TrackSource() = default;
virtual ~TrackSource() = default;
/**
* Track

View File

@ -189,7 +189,7 @@ public:
_data = map_addr.get() + offset;
_size = size;
}
~BufferMmap() override {};
~BufferMmap() override = default;
//返回数据长度
char *data() const override { return _data; }
size_t size() const override { return _size; }

View File

@ -30,9 +30,9 @@ namespace mediakit {
class HttpBody : public std::enable_shared_from_this<HttpBody>{
public:
using Ptr = std::shared_ptr<HttpBody>;
HttpBody(){}
HttpBody() = default;
virtual ~HttpBody(){}
virtual ~HttpBody() = default;
/**
* -1, content-length
@ -151,7 +151,7 @@ public:
* @param boundary boundary字符串
*/
HttpMultiFormBody(const HttpArgs &args,const std::string &filePath,const std::string &boundary = "0xKhTmLbOuNdArY");
virtual ~HttpMultiFormBody(){}
virtual ~HttpMultiFormBody() = default;
int64_t remainSize() override ;
toolkit::Buffer::Ptr readData(size_t size) override;

View File

@ -27,8 +27,8 @@ class HttpCookie {
public:
using Ptr = std::shared_ptr<HttpCookie>;
friend class HttpCookieStorage;
HttpCookie(){}
~HttpCookie(){}
HttpCookie() = default;
~HttpCookie() = default;
void setPath(const std::string &path);
void setHost(const std::string &host);
@ -52,12 +52,14 @@ private:
*/
class HttpCookieStorage{
public:
~HttpCookieStorage(){}
~HttpCookieStorage() = default;
static HttpCookieStorage &Instance();
void set(const HttpCookie::Ptr &cookie);
std::vector<HttpCookie::Ptr> get(const std::string &host,const std::string &path);
private:
HttpCookieStorage(){};
HttpCookieStorage() = default;
private:
std::unordered_map<std::string/*host*/, std::map<std::string/*cookie path*/,std::map<std::string/*cookie_key*/, HttpCookie::Ptr> > > _all_cookie;
std::mutex _mtx_cookie;

View File

@ -24,8 +24,8 @@ public:
typedef std::function<void(int code, const StrCaseMap &headerOut, const HttpBody::Ptr &body)> HttpResponseInvokerLambda0;
typedef std::function<void(int code, const StrCaseMap &headerOut, const std::string &body)> HttpResponseInvokerLambda1;
HttpResponseInvokerImp(){}
~HttpResponseInvokerImp(){}
HttpResponseInvokerImp() = default;
~HttpResponseInvokerImp() = default;
template<typename C>
HttpResponseInvokerImp(const C &c):HttpResponseInvokerImp(typename toolkit::function_traits<C>::stl_function_type(c)) {}
HttpResponseInvokerImp(const HttpResponseInvokerLambda0 &lambda);

View File

@ -18,8 +18,8 @@ namespace mediakit {
class HttpRequestSplitter {
public:
HttpRequestSplitter(){};
virtual ~HttpRequestSplitter(){};
HttpRequestSplitter() = default;
virtual ~HttpRequestSplitter() = default;
/**
*

View File

@ -37,7 +37,7 @@ public:
template <typename... ArgsType>
ClientTypeImp(ArgsType &&...args) : ClientType(std::forward<ArgsType>(args)...) {}
~ClientTypeImp() override {};
~ClientTypeImp() override = default;
protected:
/**

View File

@ -82,7 +82,7 @@ template<typename Creator, typename HttpSessionType = mediakit::HttpSession, med
class WebSocketSessionBase : public HttpSessionType {
public:
WebSocketSessionBase(const toolkit::Socket::Ptr &pSock) : HttpSessionType(pSock){}
virtual ~WebSocketSessionBase(){}
virtual ~WebSocketSessionBase() = default;
//收到eof或其他导致脱离TcpServer事件的回调
void onError(const toolkit::SockException &err) override{
@ -248,7 +248,7 @@ template<typename SessionType,typename HttpSessionType = mediakit::HttpSession,
class WebSocketSession : public WebSocketSessionBase<SessionCreator<SessionType>,HttpSessionType,DataType>{
public:
WebSocketSession(const toolkit::Socket::Ptr &pSock) : WebSocketSessionBase<SessionCreator<SessionType>,HttpSessionType,DataType>(pSock){}
virtual ~WebSocketSession(){}
virtual ~WebSocketSession() = default;
};
#endif //ZLMEDIAKIT_WEBSOCKETSESSION_H

View File

@ -51,7 +51,7 @@ public:
//根据内存地址设置掩码随机数
_mask.assign((uint8_t*)(&ptr), (uint8_t*)(&ptr) + 4);
}
virtual ~WebSocketHeader(){}
virtual ~WebSocketHeader() = default;
public:
bool _fin;
@ -71,7 +71,7 @@ public:
WebSocketBuffer(WebSocketHeader::Type headType, bool fin, ARGS &&...args)
: toolkit::BufferString(std::forward<ARGS>(args)...), _fin(fin), _head_type(headType){}
~WebSocketBuffer() override {}
~WebSocketBuffer() override = default;
WebSocketHeader::Type headType() const { return _head_type; }
@ -84,8 +84,8 @@ private:
class WebSocketSplitter : public WebSocketHeader{
public:
WebSocketSplitter(){}
virtual ~WebSocketSplitter(){}
WebSocketSplitter() = default;
virtual ~WebSocketSplitter() = default;
/**
* 便webSocket数据以及处理粘包问题

View File

@ -86,7 +86,7 @@ namespace mediakit {
class MpegMuxer : public MediaSinkInterface {
public:
MpegMuxer(bool is_ps) {};
MpegMuxer(bool is_ps) = default;
~MpegMuxer() override = default;
bool addTrack(const Track::Ptr &track) override { return false; }
void resetTracks() override {}

View File

@ -242,11 +242,9 @@ vector<RtcpHeader *> RtcpHeader::loadFromBytes(char *data, size_t len) {
class BufferRtcp : public Buffer {
public:
BufferRtcp(std::shared_ptr<RtcpHeader> rtcp) { _rtcp = std::move(rtcp); }
~BufferRtcp() override {}
~BufferRtcp() override = default;
char *data() const override { return (char *)_rtcp.get(); }
size_t size() const override { return _rtcp->getSize(); }
private:

View File

@ -207,8 +207,8 @@ class Metadata : public CodecInfo{
public:
using Ptr = std::shared_ptr<Metadata>;
Metadata():_metadata(AMF_OBJECT){}
virtual ~Metadata(){}
Metadata(): _metadata(AMF_OBJECT) {}
virtual ~Metadata() = default;
const AMFValue &getMetadata() const{
return _metadata;
}
@ -239,7 +239,7 @@ public:
using Ptr = std::shared_ptr<VideoMeta>;
VideoMeta(const VideoTrack::Ptr &video);
virtual ~VideoMeta(){}
virtual ~VideoMeta() = default;
CodecId getCodecId() const override{
return _codecId;
@ -253,8 +253,7 @@ public:
using Ptr = std::shared_ptr<AudioMeta>;
AudioMeta(const AudioTrack::Ptr &audio);
virtual ~AudioMeta(){}
virtual ~AudioMeta() = default;
CodecId getCodecId() const override{
return _codecId;

View File

@ -181,13 +181,13 @@ void RtmpProtocol::sendRequest(int cmd, const string& str) {
class BufferPartial : public Buffer {
public:
BufferPartial(const Buffer::Ptr &buffer, size_t offset, size_t size){
BufferPartial(const Buffer::Ptr &buffer, size_t offset, size_t size) {
_buffer = buffer;
_data = buffer->data() + offset;
_size = size;
}
~BufferPartial() override{}
~BufferPartial() override = default;
char *data() const override {
return _data;

View File

@ -13,12 +13,8 @@
#include "RtpSplitter.h"
namespace mediakit{
static const char kEHOME_MAGIC[] = "\x01\x00\x01\x00";
static const int kEHOME_OFFSET = 256;
RtpSplitter::RtpSplitter() {}
RtpSplitter::~RtpSplitter() {}
ssize_t RtpSplitter::onRecvHeader(const char *data,size_t len){
//忽略偏移量
data += _offset;
@ -38,11 +34,10 @@ static bool isEhome(const char *data, size_t len){
if (len < 4) {
return false;
}
if((data[0] == 0x01) && (data[1] == 0x00) && (data[2] >=0x01)){
if ((data[0] == 0x01) && (data[1] == 0x00) && (data[2] >= 0x01)) {
return true;
}
return false;
//return memcmp(data, kEHOME_MAGIC, sizeof(kEHOME_MAGIC) - 1) == 0;
}
const char *RtpSplitter::onSearchPacketTail(const char *data, size_t len) {

View File

@ -18,8 +18,8 @@ namespace mediakit{
class RtpSplitter : public HttpRequestSplitter{
public:
RtpSplitter();
~RtpSplitter() override;
RtpSplitter() = default;
~RtpSplitter() override = default;
protected:
/**

View File

@ -25,7 +25,7 @@ class TSSegment : public HttpRequestSplitter {
public:
typedef std::function<void(const char *data,size_t len)> onSegment;
TSSegment(size_t size = TS_PACKET_SIZE) : _size(size){}
~TSSegment(){}
~TSSegment() = default;
void setOnSegment(onSegment cb);
static bool isTSPacket(const char *data, size_t len);

View File

@ -74,7 +74,7 @@ public:
_interleaved = interleaved;
}
virtual ~RtpInfo() {}
virtual ~RtpInfo() = default;
//返回rtp负载最大长度
size_t getMaxSize() const {

View File

@ -237,9 +237,9 @@ class SdpParser {
public:
using Ptr = std::shared_ptr<SdpParser>;
SdpParser() {}
SdpParser() = default;
SdpParser(const std::string &sdp) { load(sdp); }
~SdpParser() {}
~SdpParser() = default;
void load(const std::string &sdp);
bool available() const;
@ -268,7 +268,7 @@ public:
_payload_type = payload_type;
}
virtual ~Sdp(){}
virtual ~Sdp() = default;
/**
* sdp字符串

View File

@ -18,8 +18,8 @@ namespace mediakit{
class RtspSplitter : public HttpRequestSplitter{
public:
RtspSplitter(){}
virtual ~RtspSplitter(){}
RtspSplitter() = default;
virtual ~RtspSplitter() = default;
/**
* rtp包