From d59a706cc1a3b970fe1780672d4e1515677741fa Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Wed, 25 Dec 2019 20:07:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/Frame.h | 73 +++----------------------------------- src/Extension/Track.h | 2 +- src/Player/PlayerProxy.cpp | 4 +-- src/Rtmp/RtmpCodec.h | 2 +- src/Rtsp/RtpCodec.h | 2 +- 5 files changed, 9 insertions(+), 74 deletions(-) diff --git a/src/Extension/Frame.h b/src/Extension/Frame.h index 5e4234f7..5e5121f9 100644 --- a/src/Extension/Frame.h +++ b/src/Extension/Frame.h @@ -198,79 +198,15 @@ private: }; -/** - * 帧环形缓存接口类 - */ -class FrameRingInterface : public FrameWriterInterface{ -public: - typedef RingBuffer RingType; - typedef std::shared_ptr 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 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 Ptr; + typedef std::shared_ptr Ptr; - FrameRingInterfaceDelegate(){} - virtual ~FrameRingInterfaceDelegate(){} + FrameDispatcher(){} + virtual ~FrameDispatcher(){} void addDelegate(const FrameWriterInterface::Ptr &delegate){ lock_guard lck(_mtx); @@ -287,7 +223,6 @@ public: * @param frame 帧 */ void inputFrame(const Frame::Ptr &frame) override{ - FrameRing::inputFrame(frame); lock_guard lck(_mtx); for(auto &pr : _delegateMap){ pr.second->inputFrame(frame); diff --git a/src/Extension/Track.h b/src/Extension/Track.h index 229a13ea..ccd675e9 100644 --- a/src/Extension/Track.h +++ b/src/Extension/Track.h @@ -39,7 +39,7 @@ namespace mediakit{ /** * 媒体通道描述类,也支持帧输入输出 */ -class Track : public FrameRingInterfaceDelegate , public CodecInfo{ +class Track : public FrameDispatcher , public CodecInfo{ public: typedef std::shared_ptr Ptr; Track(){} diff --git a/src/Player/PlayerProxy.cpp b/src/Player/PlayerProxy.cpp index 2babb7c4..656c9230 100644 --- a/src/Player/PlayerProxy.cpp +++ b/src/Player/PlayerProxy.cpp @@ -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 Ptr; @@ -221,7 +221,7 @@ public: auto aacFrame = std::make_shared((char *)MUTE_ADTS_DATA, MUTE_ADTS_DATA_LEN, _iAudioIndex * MUTE_ADTS_DATA_MS); - FrameRingInterfaceDelegate::inputFrame(aacFrame); + FrameDispatcher::inputFrame(aacFrame); } } } diff --git a/src/Rtmp/RtmpCodec.h b/src/Rtmp/RtmpCodec.h index 525a32da..4772a0c1 100644 --- a/src/Rtmp/RtmpCodec.h +++ b/src/Rtmp/RtmpCodec.h @@ -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 Ptr; RtmpCodec(){} diff --git a/src/Rtsp/RtpCodec.h b/src/Rtsp/RtpCodec.h index 7ce212c7..0ea893c8 100644 --- a/src/Rtsp/RtpCodec.h +++ b/src/Rtsp/RtpCodec.h @@ -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 Ptr; RtpCodec(){}