mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 02:34:26 +08:00
优化代码
空构造和析构函数替换为缺省 去除多余分号
This commit is contained in:
parent
e8a425945d
commit
7a95c87a29
@ -24,7 +24,7 @@ public:
|
||||
MediaPlayerForC(){
|
||||
_player = std::make_shared<MediaPlayer>();
|
||||
}
|
||||
~MediaPlayerForC(){}
|
||||
~MediaPlayerForC() = default;
|
||||
|
||||
MediaPlayer *operator->(){
|
||||
return _player.get();
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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; }
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -18,8 +18,8 @@ namespace mediakit {
|
||||
|
||||
class HttpRequestSplitter {
|
||||
public:
|
||||
HttpRequestSplitter(){};
|
||||
virtual ~HttpRequestSplitter(){};
|
||||
HttpRequestSplitter() = default;
|
||||
virtual ~HttpRequestSplitter() = default;
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
template <typename... ArgsType>
|
||||
ClientTypeImp(ArgsType &&...args) : ClientType(std::forward<ArgsType>(args)...) {}
|
||||
~ClientTypeImp() override {};
|
||||
~ClientTypeImp() override = default;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -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数据以及处理粘包问题
|
||||
|
@ -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 {}
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -18,8 +18,8 @@ namespace mediakit{
|
||||
|
||||
class RtpSplitter : public HttpRequestSplitter{
|
||||
public:
|
||||
RtpSplitter();
|
||||
~RtpSplitter() override;
|
||||
RtpSplitter() = default;
|
||||
~RtpSplitter() override = default;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -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);
|
||||
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
_interleaved = interleaved;
|
||||
}
|
||||
|
||||
virtual ~RtpInfo() {}
|
||||
virtual ~RtpInfo() = default;
|
||||
|
||||
//返回rtp负载最大长度
|
||||
size_t getMaxSize() const {
|
||||
|
@ -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字符串
|
||||
|
@ -18,8 +18,8 @@ namespace mediakit{
|
||||
|
||||
class RtspSplitter : public HttpRequestSplitter{
|
||||
public:
|
||||
RtspSplitter(){}
|
||||
virtual ~RtspSplitter(){}
|
||||
RtspSplitter() = default;
|
||||
virtual ~RtspSplitter() = default;
|
||||
|
||||
/**
|
||||
* 是否允许接收rtp包
|
||||
|
Loading…
Reference in New Issue
Block a user