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
|
|
|
|
*
|
2021-01-17 18:31:50 +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
|
|
|
|
|
2022-02-02 20:34:50 +08:00
|
|
|
|
class RtmpRing {
|
2018-10-24 12:01:40 +08:00
|
|
|
|
public:
|
2022-02-02 20:34:50 +08:00
|
|
|
|
using Ptr = std::shared_ptr<RtmpRing>;
|
|
|
|
|
using RingType = toolkit::RingBuffer<RtmpPacket::Ptr>;
|
2018-10-24 12:01:40 +08:00
|
|
|
|
|
2022-02-02 20:34:50 +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 {
|
2022-02-02 20:34:50 +08:00
|
|
|
|
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) {
|
2022-02-02 20:34:50 +08:00
|
|
|
|
_ring = ring;
|
2019-12-26 09:43:44 +08:00
|
|
|
|
}
|
2018-10-24 12:01:40 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 输入rtmp包
|
|
|
|
|
* @param rtmp rtmp包
|
|
|
|
|
*/
|
2020-09-06 18:22:04 +08:00
|
|
|
|
virtual void inputRtmp(const RtmpPacket::Ptr &rtmp) {
|
2022-02-02 20:34:50 +08:00
|
|
|
|
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:
|
2022-02-02 20:34:50 +08:00
|
|
|
|
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;
|
2022-11-12 21:59:48 +08:00
|
|
|
|
RtmpCodec() = default;
|
|
|
|
|
~RtmpCodec() override = default;
|
2020-01-15 11:46:15 +08:00
|
|
|
|
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
|