简化代码

This commit is contained in:
xiongziliang 2019-12-25 20:07:42 +08:00
parent b219a82ff5
commit d59a706cc1
5 changed files with 9 additions and 74 deletions

View File

@ -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: public:
typedef std::shared_ptr<FrameRingInterfaceDelegate> Ptr; typedef std::shared_ptr<FrameDispatcher> Ptr;
FrameRingInterfaceDelegate(){} FrameDispatcher(){}
virtual ~FrameRingInterfaceDelegate(){} virtual ~FrameDispatcher(){}
void addDelegate(const FrameWriterInterface::Ptr &delegate){ void addDelegate(const FrameWriterInterface::Ptr &delegate){
lock_guard<mutex> lck(_mtx); lock_guard<mutex> lck(_mtx);
@ -287,7 +223,6 @@ public:
* @param frame * @param frame
*/ */
void inputFrame(const Frame::Ptr &frame) override{ void inputFrame(const Frame::Ptr &frame) override{
FrameRing::inputFrame(frame);
lock_guard<mutex> lck(_mtx); lock_guard<mutex> lck(_mtx);
for(auto &pr : _delegateMap){ for(auto &pr : _delegateMap){
pr.second->inputFrame(frame); pr.second->inputFrame(frame);

View File

@ -39,7 +39,7 @@ namespace mediakit{
/** /**
* *
*/ */
class Track : public FrameRingInterfaceDelegate , public CodecInfo{ class Track : public FrameDispatcher , public CodecInfo{
public: public:
typedef std::shared_ptr<Track> Ptr; typedef std::shared_ptr<Track> Ptr;
Track(){} Track(){}

View File

@ -207,7 +207,7 @@ void PlayerProxy::onNoneReader(MediaSource &sender) {
MediaSourceEvent::onNoneReader(sender); MediaSourceEvent::onNoneReader(sender);
} }
class MuteAudioMaker : public FrameRingInterfaceDelegate{ class MuteAudioMaker : public FrameDispatcher{
public: public:
typedef std::shared_ptr<MuteAudioMaker> Ptr; typedef std::shared_ptr<MuteAudioMaker> Ptr;
@ -221,7 +221,7 @@ public:
auto aacFrame = std::make_shared<AACFrameNoCacheAble>((char *)MUTE_ADTS_DATA, auto aacFrame = std::make_shared<AACFrameNoCacheAble>((char *)MUTE_ADTS_DATA,
MUTE_ADTS_DATA_LEN, MUTE_ADTS_DATA_LEN,
_iAudioIndex * MUTE_ADTS_DATA_MS); _iAudioIndex * MUTE_ADTS_DATA_MS);
FrameRingInterfaceDelegate::inputFrame(aacFrame); FrameDispatcher::inputFrame(aacFrame);
} }
} }
} }

View File

@ -90,7 +90,7 @@ protected:
}; };
class RtmpCodec : public RtmpRing, public FrameRingInterfaceDelegate , public CodecInfo{ class RtmpCodec : public RtmpRing, public FrameDispatcher , public CodecInfo{
public: public:
typedef std::shared_ptr<RtmpCodec> Ptr; typedef std::shared_ptr<RtmpCodec> Ptr;
RtmpCodec(){} RtmpCodec(){}

View File

@ -147,7 +147,7 @@ protected:
uint32_t _ui32TimeStamp = 0; uint32_t _ui32TimeStamp = 0;
}; };
class RtpCodec : public RtpRing, public FrameRingInterfaceDelegate , public CodecInfo{ class RtpCodec : public RtpRing, public FrameDispatcher , public CodecInfo{
public: public:
typedef std::shared_ptr<RtpCodec> Ptr; typedef std::shared_ptr<RtpCodec> Ptr;
RtpCodec(){} RtpCodec(){}