2018-10-25 10:00:17 +08:00
|
|
|
|
/*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
2018-10-25 10:00:17 +08:00
|
|
|
|
*
|
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
|
|
|
|
*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* Use of this source code is governed by MIT license that can be found in the
|
|
|
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
|
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
2018-10-25 10:00:17 +08:00
|
|
|
|
*/
|
2018-10-18 23:48:00 +08:00
|
|
|
|
|
|
|
|
|
#ifndef ZLMEDIAKIT_AACRTPCODEC_H
|
|
|
|
|
#define ZLMEDIAKIT_AACRTPCODEC_H
|
|
|
|
|
|
2019-06-28 17:30:13 +08:00
|
|
|
|
#include "Rtsp/RtpCodec.h"
|
2018-10-30 14:59:42 +08:00
|
|
|
|
#include "Extension/AAC.h"
|
2018-10-24 17:17:55 +08:00
|
|
|
|
namespace mediakit{
|
2018-10-21 22:24:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* aac rtp转adts类
|
|
|
|
|
*/
|
2018-10-24 12:01:40 +08:00
|
|
|
|
class AACRtpDecoder : public RtpCodec , public ResourcePoolHelper<AACFrame> {
|
2018-10-18 23:48:00 +08:00
|
|
|
|
public:
|
2018-10-23 18:39:17 +08:00
|
|
|
|
typedef std::shared_ptr<AACRtpDecoder> Ptr;
|
|
|
|
|
|
2019-01-24 12:21:29 +08:00
|
|
|
|
AACRtpDecoder(const Track::Ptr &track);
|
2018-10-21 21:45:44 +08:00
|
|
|
|
~AACRtpDecoder() {}
|
|
|
|
|
|
2018-10-21 22:24:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 输入rtp并解码
|
|
|
|
|
* @param rtp rtp数据包
|
|
|
|
|
* @param key_pos 此参数内部强制转换为false,请忽略之
|
|
|
|
|
*/
|
2018-10-23 18:39:17 +08:00
|
|
|
|
bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = false) override;
|
2018-10-23 11:09:21 +08:00
|
|
|
|
|
2020-06-11 19:21:46 +08:00
|
|
|
|
CodecId getCodecId() const override {
|
2018-10-23 11:09:21 +08:00
|
|
|
|
return CodecAAC;
|
|
|
|
|
}
|
2020-06-11 19:21:46 +08:00
|
|
|
|
|
2019-01-24 12:21:29 +08:00
|
|
|
|
protected:
|
|
|
|
|
AACRtpDecoder();
|
2020-06-11 19:21:46 +08:00
|
|
|
|
|
2018-10-18 23:48:00 +08:00
|
|
|
|
private:
|
2018-10-23 11:09:21 +08:00
|
|
|
|
AACFrame::Ptr obtainFrame();
|
2020-03-11 18:52:28 +08:00
|
|
|
|
void flushData();
|
2020-06-11 19:21:46 +08:00
|
|
|
|
|
2018-10-18 23:48:00 +08:00
|
|
|
|
private:
|
2020-06-11 19:21:46 +08:00
|
|
|
|
AACFrame::Ptr _frame;
|
2019-01-24 12:21:29 +08:00
|
|
|
|
string _aac_cfg;
|
2018-10-18 23:48:00 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2018-10-21 22:24:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* aac adts转rtp类
|
|
|
|
|
*/
|
2018-10-23 11:38:56 +08:00
|
|
|
|
class AACRtpEncoder : public AACRtpDecoder , public RtpInfo {
|
2018-10-21 21:45:44 +08:00
|
|
|
|
public:
|
2018-10-23 18:39:17 +08:00
|
|
|
|
typedef std::shared_ptr<AACRtpEncoder> Ptr;
|
|
|
|
|
|
2018-10-21 22:24:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* @param ui32Ssrc ssrc
|
|
|
|
|
* @param ui32MtuSize mtu 大小
|
|
|
|
|
* @param ui32SampleRate 采样率
|
2020-05-25 13:51:00 +08:00
|
|
|
|
* @param ui8PayloadType pt类型
|
2018-10-21 22:24:24 +08:00
|
|
|
|
* @param ui8Interleaved rtsp interleaved 值
|
|
|
|
|
*/
|
2018-10-21 21:45:44 +08:00
|
|
|
|
AACRtpEncoder(uint32_t ui32Ssrc,
|
|
|
|
|
uint32_t ui32MtuSize,
|
|
|
|
|
uint32_t ui32SampleRate,
|
2020-05-25 13:51:00 +08:00
|
|
|
|
uint8_t ui8PayloadType = 97,
|
2018-10-21 21:45:44 +08:00
|
|
|
|
uint8_t ui8Interleaved = TrackAudio * 2);
|
|
|
|
|
~AACRtpEncoder() {}
|
|
|
|
|
|
2018-10-21 22:24:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 输入aac 数据,必须带dats头
|
|
|
|
|
* @param frame 带dats头的aac数据
|
|
|
|
|
*/
|
2018-10-23 21:41:45 +08:00
|
|
|
|
void inputFrame(const Frame::Ptr &frame) override;
|
2020-06-11 19:21:46 +08:00
|
|
|
|
|
2018-10-21 21:45:44 +08:00
|
|
|
|
private:
|
|
|
|
|
void makeAACRtp(const void *pData, unsigned int uiLen, bool bMark, uint32_t uiStamp);
|
2020-06-11 19:21:46 +08:00
|
|
|
|
|
2018-10-21 21:45:44 +08:00
|
|
|
|
private:
|
2018-10-24 15:43:52 +08:00
|
|
|
|
unsigned char _aucSectionBuf[1600];
|
2018-10-21 21:45:44 +08:00
|
|
|
|
};
|
|
|
|
|
|
2018-10-24 17:17:55 +08:00
|
|
|
|
}//namespace mediakit
|
2018-10-21 21:21:14 +08:00
|
|
|
|
|
2018-10-18 23:48:00 +08:00
|
|
|
|
#endif //ZLMEDIAKIT_AACRTPCODEC_H
|