ZLMediaKit/src/Rtmp/RtmpCodec.h

67 lines
1.5 KiB
C++
Raw Normal View History

2018-10-25 10:00:17 +08:00
/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
2018-10-25 10:00:17 +08:00
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
2018-10-25 10:00:17 +08:00
*
2020-04-04 20:30:09 +08:00
* 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.
2018-10-25 10:00:17 +08:00
*/
2018-10-24 12:01:40 +08:00
#ifndef ZLMEDIAKIT_RTMPCODEC_H
#define ZLMEDIAKIT_RTMPCODEC_H
#include "Rtmp/Rtmp.h"
2018-10-30 14:59:42 +08:00
#include "Extension/Frame.h"
2018-10-24 12:01:40 +08:00
#include "Util/RingBuffer.h"
2018-10-24 17:17:55 +08:00
namespace mediakit{
2018-10-24 12:01:40 +08:00
class RtmpRing {
2018-10-24 12:01:40 +08:00
public:
using Ptr = std::shared_ptr<RtmpRing>;
using RingType = toolkit::RingBuffer<RtmpPacket::Ptr>;
2018-10-24 12:01:40 +08:00
RtmpRing() = default;
virtual ~RtmpRing() = default;
2018-10-24 12:01:40 +08:00
/**
* rtmp环形缓存
*/
2020-08-30 10:48:34 +08:00
virtual RingType::Ptr getRtmpRing() const {
return _ring;
2019-12-26 09:43:44 +08:00
}
2018-10-24 12:01:40 +08:00
/**
* rtmp环形缓存
*/
2020-08-30 10:48:34 +08:00
virtual void setRtmpRing(const RingType::Ptr &ring) {
_ring = ring;
2019-12-26 09:43:44 +08:00
}
2018-10-24 12:01:40 +08:00
/**
* rtmp包
* @param rtmp rtmp包
*/
virtual void inputRtmp(const RtmpPacket::Ptr &rtmp) {
if (_ring) {
_ring->write(rtmp, rtmp->isVideoKeyFrame());
2018-10-26 22:07:01 +08:00
}
2018-10-24 12:01:40 +08:00
}
2020-08-30 10:48:34 +08:00
2018-10-24 12:01:40 +08:00
protected:
RingType::Ptr _ring;
2018-10-24 12:01:40 +08:00
};
2019-12-25 20:07:42 +08:00
class RtmpCodec : public RtmpRing, public FrameDispatcher , public CodecInfo{
2018-10-24 12:01:40 +08:00
public:
typedef std::shared_ptr<RtmpCodec> Ptr;
RtmpCodec(){}
virtual ~RtmpCodec(){}
virtual void makeConfigPacket() {};
2018-10-24 12:01:40 +08:00
};
2018-10-24 17:17:55 +08:00
}//namespace mediakit
2018-10-24 12:01:40 +08:00
#endif //ZLMEDIAKIT_RTMPCODEC_H