diff --git a/src/Extension/Frame.cpp b/src/Extension/Frame.cpp index b97a840e..dda876ca 100644 --- a/src/Extension/Frame.cpp +++ b/src/Extension/Frame.cpp @@ -210,5 +210,39 @@ void FrameMerger::flush() { } clear(); } +/** + * 写帧接口转function,辅助类 + */ +class FrameWriterInterfaceHelper : public FrameWriterInterface { +public: + typedef std::shared_ptr Ptr; + typedef std::function onWriteFrame; + + /** + * inputFrame后触发onWriteFrame回调 + */ + FrameWriterInterfaceHelper(const onWriteFrame& cb){ + _writeCallback = cb; + } + + virtual ~FrameWriterInterfaceHelper(){} + + /** + * 写入帧数据 + */ + bool inputFrame(const Frame::Ptr &frame) override { + return _writeCallback(frame); + } + +private: + onWriteFrame _writeCallback; +}; + +FrameWriterInterface* FrameDispatcher::addDelegate(const std::function &cb) { + auto delegate = std::make_shared(cb); + std::lock_guard lck(_mtx); + _delegates.emplace(delegate.get(), delegate); + return delegate.get(); +} }//namespace mediakit diff --git a/src/Extension/Frame.h b/src/Extension/Frame.h index 10a046a8..aa096681 100644 --- a/src/Extension/Frame.h +++ b/src/Extension/Frame.h @@ -278,29 +278,6 @@ public: virtual void flush() {}; }; -/** - * 写帧接口转function,辅助类 - */ -class FrameWriterInterfaceHelper : public FrameWriterInterface { -public: - typedef std::shared_ptr Ptr; - typedef std::function onWriteFrame; - - /** - * inputFrame后触发onWriteFrame回调 - */ - FrameWriterInterfaceHelper(const onWriteFrame &cb) { _writeCallback = cb; } - virtual ~FrameWriterInterfaceHelper() = default; - - /** - * 写入帧数据 - */ - bool inputFrame(const Frame::Ptr &frame) override { return _writeCallback(frame); } - -private: - onWriteFrame _writeCallback; -}; - /** * 支持代理转发的帧环形缓存 */ @@ -318,12 +295,7 @@ public: _delegates.emplace(delegate.get(), delegate); } - FrameWriterInterface* addDelegate(const std::function &cb) { - auto delegate = std::make_shared(cb); - std::lock_guard lck(_mtx); - _delegates.emplace(delegate.get(), delegate); - return delegate.get(); - } + FrameWriterInterface* addDelegate(const std::function &cb); /** * 删除代理 */