mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-19 14:52:20 +08:00
文件夹Rtp干脆RtpCodec
This commit is contained in:
79
src/RtpCodec/AACRtpCodec.h
Normal file
79
src/RtpCodec/AACRtpCodec.h
Normal file
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// Created by xzl on 2018/10/18.
|
||||
//
|
||||
|
||||
#ifndef ZLMEDIAKIT_AACRTPCODEC_H
|
||||
#define ZLMEDIAKIT_AACRTPCODEC_H
|
||||
|
||||
#include "RtpCodec.h"
|
||||
|
||||
/**
|
||||
* aac rtp转adts类
|
||||
*/
|
||||
class AACRtpDecoder : public RtpCodec , public ResourcePoolHelper<AACFrame> {
|
||||
public:
|
||||
typedef std::shared_ptr<AACRtpDecoder> Ptr;
|
||||
|
||||
/**
|
||||
* @param ui32SampleRate 采样率,用于时间戳转换用
|
||||
*/
|
||||
AACRtpDecoder(uint32_t ui32SampleRate);
|
||||
~AACRtpDecoder() {}
|
||||
|
||||
/**
|
||||
* 输入rtp并解码
|
||||
* @param rtp rtp数据包
|
||||
* @param key_pos 此参数内部强制转换为false,请忽略之
|
||||
*/
|
||||
bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = false) override;
|
||||
|
||||
TrackType getTrackType() const override{
|
||||
return TrackAudio;
|
||||
}
|
||||
|
||||
CodecId getCodecId() const override{
|
||||
return CodecAAC;
|
||||
}
|
||||
private:
|
||||
void onGetAAC(const AACFrame::Ptr &frame);
|
||||
AACFrame::Ptr obtainFrame();
|
||||
private:
|
||||
AACFrame::Ptr _adts;
|
||||
uint32_t _sampleRate;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* aac adts转rtp类
|
||||
*/
|
||||
class AACRtpEncoder : public AACRtpDecoder , public RtpInfo {
|
||||
public:
|
||||
typedef std::shared_ptr<AACRtpEncoder> Ptr;
|
||||
|
||||
/**
|
||||
* @param ui32Ssrc ssrc
|
||||
* @param ui32MtuSize mtu 大小
|
||||
* @param ui32SampleRate 采样率
|
||||
* @param ui8PlayloadType pt类型
|
||||
* @param ui8Interleaved rtsp interleaved 值
|
||||
*/
|
||||
AACRtpEncoder(uint32_t ui32Ssrc,
|
||||
uint32_t ui32MtuSize,
|
||||
uint32_t ui32SampleRate,
|
||||
uint8_t ui8PlayloadType = 97,
|
||||
uint8_t ui8Interleaved = TrackAudio * 2);
|
||||
~AACRtpEncoder() {}
|
||||
|
||||
/**
|
||||
* 输入aac 数据,必须带dats头
|
||||
* @param frame 带dats头的aac数据
|
||||
*/
|
||||
void inputFrame(const Frame::Ptr &frame) override;
|
||||
private:
|
||||
void makeAACRtp(const void *pData, unsigned int uiLen, bool bMark, uint32_t uiStamp);
|
||||
private:
|
||||
unsigned char _aucSectionBuf[1600];
|
||||
};
|
||||
|
||||
|
||||
#endif //ZLMEDIAKIT_AACRTPCODEC_H
|
||||
Reference in New Issue
Block a user