mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
简化代码
This commit is contained in:
parent
b219a82ff5
commit
d59a706cc1
@ -198,79 +198,15 @@ private:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 帧环形缓存接口类
|
||||
*/
|
||||
class FrameRingInterface : public FrameWriterInterface{
|
||||
public:
|
||||
typedef RingBuffer<Frame::Ptr> RingType;
|
||||
typedef std::shared_ptr<FrameRingInterface> Ptr;
|
||||
|
||||
FrameRingInterface(){}
|
||||
virtual ~FrameRingInterface(){}
|
||||
|
||||
/**
|
||||
* 获取帧环形缓存
|
||||
* @return
|
||||
*/
|
||||
virtual RingType::Ptr getFrameRing() const = 0;
|
||||
|
||||
/**
|
||||
* 设置帧环形缓存
|
||||
* @param ring
|
||||
*/
|
||||
virtual void setFrameRing(const RingType::Ptr &ring) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* 帧环形缓存
|
||||
*/
|
||||
class FrameRing : public FrameRingInterface{
|
||||
public:
|
||||
typedef std::shared_ptr<FrameRing> Ptr;
|
||||
|
||||
FrameRing(){
|
||||
}
|
||||
virtual ~FrameRing(){}
|
||||
|
||||
/**
|
||||
* 获取帧环形缓存
|
||||
* @return
|
||||
*/
|
||||
RingType::Ptr getFrameRing() const override {
|
||||
return _frameRing;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置帧环形缓存
|
||||
* @param ring
|
||||
*/
|
||||
void setFrameRing(const RingType::Ptr &ring) override {
|
||||
_frameRing = ring;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入数据帧
|
||||
* @param frame
|
||||
*/
|
||||
void inputFrame(const Frame::Ptr &frame) override{
|
||||
if(_frameRing){
|
||||
_frameRing->write(frame,frame->keyFrame());
|
||||
}
|
||||
}
|
||||
protected:
|
||||
RingType::Ptr _frameRing;
|
||||
};
|
||||
|
||||
/**
|
||||
* 支持代理转发的帧环形缓存
|
||||
*/
|
||||
class FrameRingInterfaceDelegate : public FrameRing {
|
||||
class FrameDispatcher : public FrameWriterInterface {
|
||||
public:
|
||||
typedef std::shared_ptr<FrameRingInterfaceDelegate> Ptr;
|
||||
typedef std::shared_ptr<FrameDispatcher> Ptr;
|
||||
|
||||
FrameRingInterfaceDelegate(){}
|
||||
virtual ~FrameRingInterfaceDelegate(){}
|
||||
FrameDispatcher(){}
|
||||
virtual ~FrameDispatcher(){}
|
||||
|
||||
void addDelegate(const FrameWriterInterface::Ptr &delegate){
|
||||
lock_guard<mutex> lck(_mtx);
|
||||
@ -287,7 +223,6 @@ public:
|
||||
* @param frame 帧
|
||||
*/
|
||||
void inputFrame(const Frame::Ptr &frame) override{
|
||||
FrameRing::inputFrame(frame);
|
||||
lock_guard<mutex> lck(_mtx);
|
||||
for(auto &pr : _delegateMap){
|
||||
pr.second->inputFrame(frame);
|
||||
|
@ -39,7 +39,7 @@ namespace mediakit{
|
||||
/**
|
||||
* 媒体通道描述类,也支持帧输入输出
|
||||
*/
|
||||
class Track : public FrameRingInterfaceDelegate , public CodecInfo{
|
||||
class Track : public FrameDispatcher , public CodecInfo{
|
||||
public:
|
||||
typedef std::shared_ptr<Track> Ptr;
|
||||
Track(){}
|
||||
|
@ -207,7 +207,7 @@ void PlayerProxy::onNoneReader(MediaSource &sender) {
|
||||
MediaSourceEvent::onNoneReader(sender);
|
||||
}
|
||||
|
||||
class MuteAudioMaker : public FrameRingInterfaceDelegate{
|
||||
class MuteAudioMaker : public FrameDispatcher{
|
||||
public:
|
||||
typedef std::shared_ptr<MuteAudioMaker> Ptr;
|
||||
|
||||
@ -221,7 +221,7 @@ public:
|
||||
auto aacFrame = std::make_shared<AACFrameNoCacheAble>((char *)MUTE_ADTS_DATA,
|
||||
MUTE_ADTS_DATA_LEN,
|
||||
_iAudioIndex * MUTE_ADTS_DATA_MS);
|
||||
FrameRingInterfaceDelegate::inputFrame(aacFrame);
|
||||
FrameDispatcher::inputFrame(aacFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
class RtmpCodec : public RtmpRing, public FrameRingInterfaceDelegate , public CodecInfo{
|
||||
class RtmpCodec : public RtmpRing, public FrameDispatcher , public CodecInfo{
|
||||
public:
|
||||
typedef std::shared_ptr<RtmpCodec> Ptr;
|
||||
RtmpCodec(){}
|
||||
|
@ -147,7 +147,7 @@ protected:
|
||||
uint32_t _ui32TimeStamp = 0;
|
||||
};
|
||||
|
||||
class RtpCodec : public RtpRing, public FrameRingInterfaceDelegate , public CodecInfo{
|
||||
class RtpCodec : public RtpRing, public FrameDispatcher , public CodecInfo{
|
||||
public:
|
||||
typedef std::shared_ptr<RtpCodec> Ptr;
|
||||
RtpCodec(){}
|
||||
|
Loading…
Reference in New Issue
Block a user