RtmpMuxer.h 1.54 KB
Newer Older
xiongziliang committed
1
/*
xiongziliang committed
2 3 4 5 6 7 8 9
 * 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.
 */
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 24
    typedef std::shared_ptr<RtmpMuxer> Ptr;

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

    /**
     * 获取完整的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 46 47

    /**
     * 添加ready状态的track
     */
    void addTrack(const Track::Ptr & track) override;

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

    /**
     * 重置所有track
     */
    void resetTracks() override ;
58 59 60 61 62

    /**
     * 生成config包
     */
     void makeConfigPacket();
xiongziliang committed
63
private:
xiongziliang committed
64
    RtmpRing::RingType::Ptr _rtmp_ring;
65
    AMFValue _metadata;
xiongziliang committed
66
    RtmpCodec::Ptr _encoder[TrackMax];
xiongziliang committed
67 68 69 70 71 72
};


} /* namespace mediakit */

#endif //ZLMEDIAKIT_RTMPMUXER_H