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;
|
|
|
|
|
|
2019-12-26 09:43:44 +08:00
|
|
|
|
RtmpRing(){}
|
|
|
|
|
virtual ~RtmpRing(){}
|
2018-10-24 12:01:40 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取rtmp环形缓存
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2019-12-26 09:43:44 +08:00
|
|
|
|
virtual RingType::Ptr getRtmpRing() const{
|
|
|
|
|
return _rtmpRing;
|
|
|
|
|
}
|
2018-10-24 12:01:40 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置rtmp环形缓存
|
|
|
|
|
* @param ring
|
|
|
|
|
*/
|
2019-12-26 09:43:44 +08:00
|
|
|
|
virtual void setRtmpRing(const RingType::Ptr &ring){
|
|
|
|
|
_rtmpRing = ring;
|
|
|
|
|
}
|
2018-10-24 12:01:40 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 输入rtmp包
|
|
|
|
|
* @param rtmp rtmp包
|
|
|
|
|
* @param key_pos 是否为关键帧
|
|
|
|
|
* @return 是否为关键帧
|
|
|
|
|
*/
|
2019-12-26 09:43:44 +08:00
|
|
|
|
virtual bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos){
|
2018-10-26 22:07:01 +08:00
|
|
|
|
if(_rtmpRing){
|
|
|
|
|
_rtmpRing->write(rtmp,key_pos);
|
|
|
|
|
}
|
2018-10-24 12:01:40 +08:00
|
|
|
|
return key_pos;
|
|
|
|
|
}
|
|
|
|
|
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(){}
|
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
|