// // Created by xzl on 2018/10/24. // #ifndef ZLMEDIAKIT_RTMPCODEC_H #define ZLMEDIAKIT_RTMPCODEC_H #include "Rtmp/Rtmp.h" #include "Player/Frame.h" #include "Util/RingBuffer.h" using namespace toolkit; namespace mediakit{ class RtmpRingInterface { public: typedef RingBuffer RingType; typedef std::shared_ptr Ptr; RtmpRingInterface(){} virtual ~RtmpRingInterface(){} /** * 获取rtmp环形缓存 * @return */ virtual RingType::Ptr getRtmpRing() const = 0; /** * 设置rtmp环形缓存 * @param ring */ virtual void setRtmpRing(const RingType::Ptr &ring) = 0; /** * 输入rtmp包 * @param rtmp rtmp包 * @param key_pos 是否为关键帧 * @return 是否为关键帧 */ virtual bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) = 0; }; class RtmpRing : public RtmpRingInterface { public: typedef std::shared_ptr Ptr; RtmpRing(){ _rtmpRing = std::make_shared(); } virtual ~RtmpRing(){} RingType::Ptr getRtmpRing() const override { return _rtmpRing; } void setRtmpRing(const RingType::Ptr &ring) override { _rtmpRing = ring; } bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) override{ _rtmpRing->write(rtmp,key_pos); return key_pos; } protected: RingType::Ptr _rtmpRing; }; class RtmpCodec : public RtmpRing, public FrameRingInterfaceDelegate , public CodecInfo{ public: typedef std::shared_ptr Ptr; RtmpCodec(){} virtual ~RtmpCodec(){} }; }//namespace mediakit #endif //ZLMEDIAKIT_RTMPCODEC_H