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

#include "Frame.h"
#include "Rtmp/RtmpCodec.h"

namespace mediakit{

/**
 * 通用 rtmp解码类
 */
22
class CommonRtmpDecoder : public RtmpCodec {
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
public:
    typedef std::shared_ptr<CommonRtmpDecoder> Ptr;

    ~CommonRtmpDecoder() override {}

    /**
     * 构造函数
     * @param codec 编码id
     */
    CommonRtmpDecoder(CodecId codec);

    /**
     * 返回编码类型ID
     */
    CodecId getCodecId() const override;

    /**
     * 输入Rtmp并解码
     * @param rtmp Rtmp数据包
     */
43
    void inputRtmp(const RtmpPacket::Ptr &rtmp) override;
44 45 46 47 48 49 50 51 52 53 54 55

private:
    void obtainFrame();

private:
    CodecId _codec;
    FrameImp::Ptr _frame;
};

/**
 * 通用 rtmp编码类
 */
xia-chu committed
56
class CommonRtmpEncoder : public CommonRtmpDecoder {
57 58 59 60 61 62 63 64 65
public:
    typedef std::shared_ptr<CommonRtmpEncoder> Ptr;

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

    /**
     * 输入帧数据
     */
66
    bool inputFrame(const Frame::Ptr &frame) override;
67 68 69 70 71 72 73

private:
    uint8_t _audio_flv_flags = 0;
};

}//namespace mediakit
#endif //ZLMEDIAKIT_COMMONRTMP_H