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

#ifndef ZLMEDIAKIT_G711RTMPCODEC_H
#define ZLMEDIAKIT_G711RTMPCODEC_H

#include "Rtmp/RtmpCodec.h"
#include "Extension/Track.h"
#include "Extension/G711.h"

namespace mediakit{
/**
xiongziliang committed
20
 * G711 Rtmp转G711 Frame类
21 22 23 24 25
 */
class G711RtmpDecoder : public RtmpCodec , public ResourcePoolHelper<G711Frame> {
public:
    typedef std::shared_ptr<G711RtmpDecoder> Ptr;

xiongziliang committed
26
    G711RtmpDecoder(CodecId codecId);
27 28 29 30 31 32 33 34 35 36
    ~G711RtmpDecoder() {}

    /**
     * 输入Rtmp并解码
     * @param Rtmp Rtmp数据包
     * @param key_pos 此参数内部强制转换为false,请忽略之
     */
    bool inputRtmp(const RtmpPacket::Ptr &Rtmp, bool key_pos = false) override;

    CodecId getCodecId() const override{
xiongziliang committed
37
        return _codecId;
38
    }
xiongziliang committed
39
private:
40
    G711Frame::Ptr obtainFrame();
xiongziliang committed
41 42 43
private:
    G711Frame::Ptr _frame;
    CodecId _codecId;
44 45 46
};

/**
xiongziliang committed
47
 * G711 RTMP打包类
48 49 50 51 52 53 54 55 56
 */
class G711RtmpEncoder : public G711RtmpDecoder ,  public ResourcePoolHelper<RtmpPacket> {
public:
    typedef std::shared_ptr<G711RtmpEncoder> Ptr;

    G711RtmpEncoder(const Track::Ptr &track);
    ~G711RtmpEncoder() {}

    /**
xiongziliang committed
57
     * 输入G711 数据
58 59 60
     */
    void inputFrame(const Frame::Ptr &frame) override;
private:
xiongziliang committed
61
    uint8_t _audio_flv_flags = 0;
62 63 64 65 66
};

}//namespace mediakit

#endif //ZLMEDIAKIT_G711RTMPCODEC_H