ZLMediaKit/src/Extension/AAC.h

70 lines
1.8 KiB
C++
Raw Normal View History

2018-10-30 14:59:42 +08:00
/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
2018-10-30 14:59:42 +08:00
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
2018-10-30 14:59:42 +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-30 14:59:42 +08:00
*/
#ifndef ZLMEDIAKIT_AAC_H
#define ZLMEDIAKIT_AAC_H
#include "Frame.h"
#include "Track.h"
2020-05-11 23:25:12 +08:00
#define ADTS_HEADER_LEN 7
2018-10-30 14:59:42 +08:00
namespace mediakit{
string makeAacConfig(const uint8_t *hex, size_t length);
int getAacFrameLength(const uint8_t *hex, size_t length);
int dumpAacConfig(const string &config, size_t length, uint8_t *out, size_t out_size);
2020-06-11 19:21:46 +08:00
bool parseAacConfig(const string &config, int &samplerate, int &channels);
2018-10-30 14:59:42 +08:00
/**
* aac音频通道
*/
class AACTrack : public AudioTrack{
public:
2021-02-05 11:51:16 +08:00
using Ptr = std::shared_ptr<AACTrack>;
2018-10-30 14:59:42 +08:00
/**
* adts头信息
* inputFrame中获取adts头信息
*/
2021-02-05 11:51:16 +08:00
AACTrack() = default;
2018-10-30 14:59:42 +08:00
/**
* aac类型的媒体
* @param aac_cfg aac配置信息
2018-10-30 14:59:42 +08:00
*/
2021-02-05 11:51:16 +08:00
AACTrack(const string &aac_cfg);
2018-10-30 14:59:42 +08:00
/**
* aac
2018-10-30 14:59:42 +08:00
*/
2021-02-05 11:51:16 +08:00
const string &getAacCfg() const;
2020-08-08 12:19:04 +08:00
2021-02-05 11:51:16 +08:00
bool ready() override;
CodecId getCodecId() const override;
int getAudioChannel() const override;
int getAudioSampleRate() const override;
int getAudioSampleBit() const override;
void inputFrame(const Frame::Ptr &frame) override;
2020-08-08 12:19:04 +08:00
private:
2021-02-05 11:51:16 +08:00
void onReady();
Sdp::Ptr getSdp() override;
Track::Ptr clone() override;
void inputFrame_l(const Frame::Ptr &frame);
2020-05-11 22:33:10 +08:00
2018-10-30 14:59:42 +08:00
private:
string _cfg;
2021-02-05 11:51:16 +08:00
int _channel = 0;
2018-10-30 14:59:42 +08:00
int _sampleRate = 0;
int _sampleBit = 16;
2018-10-30 17:58:10 +08:00
};
2018-10-30 14:59:42 +08:00
}//namespace mediakit
2020-05-11 22:33:10 +08:00
#endif //ZLMEDIAKIT_AAC_H