整理代码

This commit is contained in:
xiongziliang 2021-01-31 21:09:25 +08:00
parent ddd3438fc3
commit e695d76ce9

View File

@ -166,32 +166,22 @@ public:
uint32_t sample_rate; uint32_t sample_rate;
}; };
Buffer::Ptr makeRtpOverTcpPrefix(uint16_t size, uint8_t interleaved); class RtpPayload {
class RtpPayload{
public: public:
static int getClockRate(int pt); static int getClockRate(int pt);
static TrackType getTrackType(int pt); static TrackType getTrackType(int pt);
static int getAudioChannel(int pt); static int getAudioChannel(int pt);
static const char *getName(int pt); static const char *getName(int pt);
static CodecId getCodecId(int pt); static CodecId getCodecId(int pt);
private: private:
RtpPayload() = delete; RtpPayload() = delete;
~RtpPayload() = delete; ~RtpPayload() = delete;
}; };
class RtcpCounter {
public:
uint32_t pktCnt = 0;
uint32_t octCount = 0;
//网络字节序
uint32_t timeStamp = 0;
uint32_t lastTimeStamp = 0;
};
class SdpTrack { class SdpTrack {
public: public:
typedef std::shared_ptr<SdpTrack> Ptr; using Ptr = std::shared_ptr<SdpTrack>;
string _m; string _m;
string _o; string _o;
@ -211,36 +201,40 @@ public:
string toString() const; string toString() const;
string getName() const; string getName() const;
public: public:
int _pt; int _pt;
string _codec;
int _samplerate;
int _channel; int _channel;
int _samplerate;
TrackType _type;
string _codec;
string _fmtp; string _fmtp;
string _control; string _control;
string _control_surffix; string _control_surffix;
TrackType _type;
public: public:
uint8_t _interleaved = 0;
bool _inited = false; bool _inited = false;
uint32_t _ssrc = 0; uint8_t _interleaved = 0;
uint16_t _seq = 0; uint16_t _seq = 0;
uint32_t _ssrc = 0;
//时间戳,单位毫秒 //时间戳,单位毫秒
uint32_t _time_stamp = 0; uint32_t _time_stamp = 0;
}; };
class SdpParser { class SdpParser {
public: public:
typedef std::shared_ptr<SdpParser> Ptr; using Ptr = std::shared_ptr<SdpParser>;
SdpParser() {} SdpParser() {}
SdpParser(const string &sdp) { load(sdp); } SdpParser(const string &sdp) { load(sdp); }
~SdpParser() {} ~SdpParser() {}
void load(const string &sdp); void load(const string &sdp);
bool available() const; bool available() const;
SdpTrack::Ptr getTrack(TrackType type) const; SdpTrack::Ptr getTrack(TrackType type) const;
vector<SdpTrack::Ptr> getAvailableTrack() const; vector<SdpTrack::Ptr> getAvailableTrack() const;
string toString() const ; string toString() const;
private: private:
vector<SdpTrack::Ptr> _track_vec; vector<SdpTrack::Ptr> _track_vec;
}; };
@ -250,16 +244,18 @@ private:
*/ */
class RtspUrl{ class RtspUrl{
public: public:
bool _is_ssl;
uint16_t _port;
string _url; string _url;
string _user; string _user;
string _passwd; string _passwd;
string _host; string _host;
uint16_t _port;
bool _is_ssl;
public: public:
RtspUrl() = default; RtspUrl() = default;
~RtspUrl() = default; ~RtspUrl() = default;
bool parse(const string &url); bool parse(const string &url);
private: private:
bool setup(bool,const string &, const string &, const string &); bool setup(bool,const string &, const string &, const string &);
}; };
@ -269,7 +265,7 @@ private:
*/ */
class Sdp : public CodecInfo{ class Sdp : public CodecInfo{
public: public:
typedef std::shared_ptr<Sdp> Ptr; using Ptr = std::shared_ptr<Sdp>;
/** /**
* sdp * sdp
@ -304,6 +300,7 @@ public:
uint32_t getSampleRate() const{ uint32_t getSampleRate() const{
return _sample_rate; return _sample_rate;
} }
private: private:
uint8_t _payload_type; uint8_t _payload_type;
uint32_t _sample_rate; uint32_t _sample_rate;
@ -357,7 +354,11 @@ private:
_StrPrinter _printer; _StrPrinter _printer;
}; };
//创建rtp over tcp4个字节的头
Buffer::Ptr makeRtpOverTcpPrefix(uint16_t size, uint8_t interleaved);
//创建rtp-rtcp端口对
void makeSockPair(std::pair<Socket::Ptr, Socket::Ptr> &pair, const string &local_ip); void makeSockPair(std::pair<Socket::Ptr, Socket::Ptr> &pair, const string &local_ip);
//十六进制方式打印ssrc
string printSSRC(uint32_t ui32Ssrc); string printSSRC(uint32_t ui32Ssrc);
} //namespace mediakit } //namespace mediakit