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
|
|
|
|
*
|
2021-01-17 18:31:50 +08:00
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
2018-10-25 10:00:17 +08:00
|
|
|
|
*
|
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类
|
|
|
|
|
*/
|
2021-02-05 11:51:16 +08:00
|
|
|
|
class AACRtmpDecoder : public RtmpCodec{
|
2018-10-24 14:21:59 +08:00
|
|
|
|
public:
|
|
|
|
|
typedef std::shared_ptr<AACRtmpDecoder> Ptr;
|
|
|
|
|
|
2020-06-11 19:21:46 +08:00
|
|
|
|
AACRtmpDecoder() {}
|
2018-10-24 14:21:59 +08:00
|
|
|
|
~AACRtmpDecoder() {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 输入Rtmp并解码
|
2020-09-06 18:22:04 +08:00
|
|
|
|
* @param rtmp Rtmp数据包
|
2018-10-24 14:21:59 +08:00
|
|
|
|
*/
|
2020-09-06 18:22:04 +08:00
|
|
|
|
void inputRtmp(const RtmpPacket::Ptr &rtmp) override;
|
2018-10-24 14:21:59 +08:00
|
|
|
|
|
|
|
|
|
CodecId getCodecId() const override{
|
|
|
|
|
return CodecAAC;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-11 19:21:46 +08:00
|
|
|
|
private:
|
2021-01-17 18:31:50 +08:00
|
|
|
|
void onGetAAC(const char *data, size_t len, uint32_t stamp);
|
2020-06-11 17:40:09 +08:00
|
|
|
|
|
2020-06-11 19:21:46 +08:00
|
|
|
|
private:
|
2018-10-24 14:21:59 +08:00
|
|
|
|
string _aac_cfg;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* aac adts转Rtmp类
|
|
|
|
|
*/
|
2021-02-04 17:58:51 +08:00
|
|
|
|
class AACRtmpEncoder : public AACRtmpDecoder{
|
2018-10-24 14:21:59 +08:00
|
|
|
|
public:
|
|
|
|
|
typedef std::shared_ptr<AACRtmpEncoder> Ptr;
|
|
|
|
|
|
2018-10-25 14:16:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* 构造函数,track可以为空,此时则在inputFrame时输入adts头
|
|
|
|
|
* 如果track不为空且包含adts头相关信息,
|
|
|
|
|
* 那么inputFrame时可以不输入adts头
|
|
|
|
|
* @param track
|
|
|
|
|
*/
|
|
|
|
|
AACRtmpEncoder(const Track::Ptr &track);
|
2018-10-24 14:21:59 +08:00
|
|
|
|
~AACRtmpEncoder() {}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-10-25 14:16:40 +08:00
|
|
|
|
* 输入aac 数据,可以不带adts头
|
|
|
|
|
* @param frame aac数据
|
2018-10-24 14:21:59 +08:00
|
|
|
|
*/
|
|
|
|
|
void inputFrame(const Frame::Ptr &frame) override;
|
|
|
|
|
|
2020-01-15 11:46:15 +08:00
|
|
|
|
/**
|
|
|
|
|
* 生成config包
|
|
|
|
|
*/
|
|
|
|
|
void makeConfigPacket() override;
|
2020-06-11 17:40:09 +08:00
|
|
|
|
|
2018-10-24 14:21:59 +08:00
|
|
|
|
private:
|
|
|
|
|
void makeAudioConfigPkt();
|
2020-06-11 17:40:09 +08:00
|
|
|
|
|
2018-10-25 14:16:40 +08:00
|
|
|
|
private:
|
2020-04-18 22:13:11 +08:00
|
|
|
|
uint8_t _audio_flv_flags;
|
2020-06-11 19:21:46 +08:00
|
|
|
|
AACTrack::Ptr _track;
|
|
|
|
|
string _aac_cfg;
|
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
|