RtmpMuxer.h 1.62 KB
Newer Older
xiongziliang committed
1
/*
xiongziliang committed
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).
xiongziliang committed
5 6 7 8 9
 *
 * 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.
 */
xiongziliang committed
10 11 12 13

#ifndef ZLMEDIAKIT_RTMPMUXER_H
#define ZLMEDIAKIT_RTMPMUXER_H

xiongziliang committed
14
#include "Rtmp/Rtmp.h"
15
#include "Extension/Frame.h"
16
#include "Common/MediaSink.h"
xiongziliang committed
17
#include "RtmpCodec.h"
xiongziliang committed
18 19 20

namespace mediakit{

xiongziliang committed
21
class RtmpMuxer : public MediaSinkInterface {
xiongziliang committed
22
public:
23
    using Ptr = std::shared_ptr<RtmpMuxer>;
24

xiongziliang committed
25 26 27
    /**
     * 构造函数
     */
28
    RtmpMuxer(const TitleMeta::Ptr &title);
xiongziliang committed
29
    ~RtmpMuxer() override = default;
xiongziliang committed
30 31 32 33 34

    /**
     * 获取完整的SDP字符串
     * @return SDP字符串
     */
35
    const AMFValue &getMetadata() const ;
xiongziliang committed
36 37 38 39 40

    /**
     * 获取rtmp环形缓存
     * @return
     */
xiongziliang committed
41
    RtmpRing::RingType::Ptr getRtmpRing() const;
xiongziliang committed
42 43 44 45

    /**
     * 添加ready状态的track
     */
46
    bool addTrack(const Track::Ptr & track) override;
xiongziliang committed
47

48
    /**
xiongziliang committed
49 50 51
     * 写入帧数据
     * @param frame 帧
     */
52
    bool inputFrame(const Frame::Ptr &frame) override;
xiongziliang committed
53 54

    /**
55 56 57 58 59
     * 刷新输出所有frame缓存
     */
    void flush() override;

    /**
xiongziliang committed
60 61 62
     * 重置所有track
     */
    void resetTracks() override ;
63 64 65 66 67

    /**
     * 生成config包
     */
     void makeConfigPacket();
xiongziliang committed
68
private:
xiongziliang committed
69
    RtmpRing::RingType::Ptr _rtmp_ring;
70
    AMFValue _metadata;
xiongziliang committed
71
    RtmpCodec::Ptr _encoder[TrackMax];
xiongziliang committed
72 73 74 75 76 77
};


} /* namespace mediakit */

#endif //ZLMEDIAKIT_RTMPMUXER_H