AAC.h 1.77 KB
Newer Older
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
3
 *
4
 * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
5
 *
xiongziliang committed
6 7 8
 * 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.
9 10 11 12 13 14 15
 */

#ifndef ZLMEDIAKIT_AAC_H
#define ZLMEDIAKIT_AAC_H

#include "Frame.h"
#include "Track.h"
xiongziliang committed
16
#define ADTS_HEADER_LEN 7
17 18 19

namespace mediakit{

20 21 22
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);
23
bool parseAacConfig(const string &config, int &samplerate, int &channels);
24

3503207480@qq.com committed
25
/**
26 27 28 29
 * aac音频通道
 */
class AACTrack : public AudioTrack{
public:
30
    using Ptr = std::shared_ptr<AACTrack>;
31 32 33 34 35

    /**
     * 延后获取adts头信息
     * 在随后的inputFrame中获取adts头信息
     */
36
    AACTrack() = default;
37 38 39

    /**
     * 构造aac类型的媒体
40
     * @param aac_cfg aac配置信息
41
     */
42
    AACTrack(const string &aac_cfg);
43 44

    /**
45
     * 获取aac 配置信息
46
     */
47
    const string &getAacCfg() const;
48

49 50 51 52 53 54
    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;
55 56

private:
57 58 59 60
    void onReady();
    Sdp::Ptr getSdp() override;
    Track::Ptr clone() override;
    void inputFrame_l(const Frame::Ptr &frame);
xiongziliang committed
61

62 63
private:
    string _cfg;
64
    int _channel = 0;
65 66
    int _sampleRate = 0;
    int _sampleBit = 16;
67 68
};

69
}//namespace mediakit
xiongziliang committed
70
#endif //ZLMEDIAKIT_AAC_H