ZLMediaKit/src/RTP/H264RtpCodec.h

55 lines
1.2 KiB
C
Raw Normal View History

2018-10-18 23:48:00 +08:00
//
// Created by xzl on 2018/10/18.
//
#ifndef ZLMEDIAKIT_H264RTPCODEC_H
#define ZLMEDIAKIT_H264RTPCODEC_H
#include "RtpCodec.h"
2018-10-21 21:21:14 +08:00
#include "Util/ResourcePool.h"
2018-10-18 23:48:00 +08:00
2018-10-21 21:21:14 +08:00
using namespace ZL::Util;
2018-10-21 21:45:44 +08:00
class H264RtpDecoder : public RtpCodec {
2018-10-18 23:48:00 +08:00
public:
2018-10-21 21:45:44 +08:00
H264RtpDecoder() {
2018-10-21 21:21:14 +08:00
m_framePool.setSize(32);
m_h264frame = m_framePool.obtain();
2018-10-18 23:48:00 +08:00
}
2018-10-21 21:45:44 +08:00
~H264RtpDecoder() {}
void inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) override;
2018-10-18 23:48:00 +08:00
private:
2018-10-21 21:21:14 +08:00
bool decodeRtp(const RtpPacket::Ptr &rtp, bool key_pos);
2018-10-21 21:45:44 +08:00
2018-10-21 21:21:14 +08:00
void onGetH264(const H264Frame::Ptr &frame);
2018-10-21 21:45:44 +08:00
2018-10-18 23:48:00 +08:00
private:
2018-10-21 21:21:14 +08:00
H264Frame::Ptr m_h264frame;
ResourcePool<H264Frame> m_framePool;
2018-10-18 23:48:00 +08:00
};
2018-10-21 21:45:44 +08:00
class H264RtpEncoder : public RtpInfo, public RtpCodec {
public:
H264RtpEncoder(uint32_t ui32Ssrc,
uint32_t ui32MtuSize = 1400,
uint32_t ui32SampleRate = 90000,
uint8_t ui8PlayloadType = 96,
uint8_t ui8Interleaved = TrackVideo * 2);
~H264RtpEncoder() {}
void inputFame(const Frame::Ptr &frame, bool key_pos) override;
private:
void makeH264Rtp(const void *pData, unsigned int uiLen, bool bMark, uint32_t uiStamp);
private:
unsigned char m_aucSectionBuf[1600];
};
2018-10-18 23:48:00 +08:00
#endif //ZLMEDIAKIT_H264RTPCODEC_H