ZLMediaKit/src/Rtmp/RtmpCodec.h

70 lines
1.6 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/xiongziliang/ZLMediaKit).
*
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
using namespace toolkit;
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
2019-12-26 09:43:44 +08:00
class RtmpRing{
2018-10-24 12:01:40 +08:00
public:
2019-12-26 09:43:44 +08:00
typedef std::shared_ptr<RtmpRing> Ptr;
2018-10-24 12:01:40 +08:00
typedef RingBuffer<RtmpPacket::Ptr> RingType;
2020-08-30 10:48:34 +08:00
RtmpRing() {}
virtual ~RtmpRing() {}
2018-10-24 12:01:40 +08:00
/**
* rtmp环形缓存
* @return
*/
2020-08-30 10:48:34 +08:00
virtual RingType::Ptr getRtmpRing() const {
2019-12-26 09:43:44 +08:00
return _rtmpRing;
}
2018-10-24 12:01:40 +08:00
/**
* rtmp环形缓存
* @param ring
*/
2020-08-30 10:48:34 +08:00
virtual void setRtmpRing(const RingType::Ptr &ring) {
2019-12-26 09:43:44 +08:00
_rtmpRing = ring;
}
2018-10-24 12:01:40 +08:00
/**
* rtmp包
* @param rtmp rtmp包
*/
virtual void inputRtmp(const RtmpPacket::Ptr &rtmp) {
2020-08-30 10:48:34 +08:00
if (_rtmpRing) {
_rtmpRing->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 _rtmpRing;
};
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