ZLMediaKit/src/Extension/AACRtmp.h

89 lines
2.2 KiB
C++
Raw Normal View History

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-24 14:21:59 +08:00
#ifndef ZLMEDIAKIT_AACRTMPCODEC_H
#define ZLMEDIAKIT_AACRTMPCODEC_H
2019-06-28 17:30:13 +08:00
#include "Rtmp/RtmpCodec.h"
2018-10-30 14:59:42 +08:00
#include "Extension/Track.h"
#include "Extension/AAC.h"
2018-10-24 14:21:59 +08:00
2018-10-24 17:17:55 +08:00
namespace mediakit{
2018-10-24 14:21:59 +08:00
/**
* aac Rtmp转adts类
*/
class AACRtmpDecoder : public RtmpCodec , public ResourcePoolHelper<AACFrame> {
public:
typedef std::shared_ptr<AACRtmpDecoder> Ptr;
AACRtmpDecoder();
~AACRtmpDecoder() {}
/**
* Rtmp并解码
* @param Rtmp Rtmp数据包
* @param key_pos false,
*/
bool inputRtmp(const RtmpPacket::Ptr &Rtmp, bool key_pos = false) override;
TrackType getTrackType() const override{
return TrackAudio;
}
CodecId getCodecId() const override{
return CodecAAC;
}
protected:
void onGetAAC(const char* pcData, int iLen, uint32_t ui32TimeStamp);
AACFrame::Ptr obtainFrame();
protected:
AACFrame::Ptr _adts;
string _aac_cfg;
};
/**
* aac adts转Rtmp类
*/
class AACRtmpEncoder : public AACRtmpDecoder , public ResourcePoolHelper<RtmpPacket> {
public:
typedef std::shared_ptr<AACRtmpEncoder> Ptr;
/**
* track可以为空inputFrame时输入adts头
* track不为空且包含adts头相关信息
* inputFrame时可以不输入adts头
* @param track
*/
AACRtmpEncoder(const Track::Ptr &track);
2018-10-24 14:21:59 +08:00
~AACRtmpEncoder() {}
/**
* aac adts头
* @param frame aac数据
2018-10-24 14:21:59 +08:00
*/
void inputFrame(const Frame::Ptr &frame) override;
/**
* config包
*/
void makeConfigPacket() override;
2018-10-24 14:21:59 +08:00
private:
void makeAudioConfigPkt();
private:
2020-04-18 22:13:11 +08:00
uint8_t _audio_flv_flags;
AACTrack::Ptr _track;
2018-10-24 14:21:59 +08:00
};
2018-10-24 17:17:55 +08:00
}//namespace mediakit
2018-10-24 14:21:59 +08:00
#endif //ZLMEDIAKIT_AACRTMPCODEC_H