From 186c15364aca2c0a26ee4003b5368fe347dd77cb Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Thu, 2 Sep 2021 10:56:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80Frame=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E5=8C=96=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/Frame.cpp | 28 ---------------------------- src/Extension/Frame.h | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/Extension/Frame.cpp b/src/Extension/Frame.cpp index 498efee4..2f46d952 100644 --- a/src/Extension/Frame.cpp +++ b/src/Extension/Frame.cpp @@ -22,34 +22,6 @@ namespace toolkit { namespace mediakit{ -template -std::shared_ptr FrameImp::create_l() { -#if 0 - static ResourcePool packet_pool; - static onceToken token([]() { - packet_pool.setSize(1024); - }); - auto ret = packet_pool.obtain(); - ret->_buffer.clear(); - ret->_prefix_size = 0; - ret->_dts = 0; - ret->_pts = 0; - return ret; -#else - return std::shared_ptr(new C()); -#endif -} - -#define CREATE_FRAME_IMP(C) \ -template<> \ -std::shared_ptr FrameImp::create() { \ - return create_l(); \ -} - -CREATE_FRAME_IMP(FrameImp); -CREATE_FRAME_IMP(H264Frame); -CREATE_FRAME_IMP(H265Frame); - /** * 该对象的功能是把一个不可缓存的帧转换成可缓存的帧 */ diff --git a/src/Extension/Frame.h b/src/Extension/Frame.h index a256ecdb..ae3cf060 100644 --- a/src/Extension/Frame.h +++ b/src/Extension/Frame.h @@ -179,7 +179,22 @@ public: using Ptr = std::shared_ptr; template - static std::shared_ptr create(); + static std::shared_ptr create() { +#if 0 + static ResourcePool packet_pool; + static onceToken token([]() { + packet_pool.setSize(1024); + }); + auto ret = packet_pool.obtain(); + ret->_buffer.clear(); + ret->_prefix_size = 0; + ret->_dts = 0; + ret->_pts = 0; + return ret; +#else + return std::shared_ptr(new C()); +#endif + } char *data() const override{ return (char *)_buffer.data(); @@ -227,9 +242,6 @@ private: protected: friend class ResourcePool_l; FrameImp() = default; - - template - static std::shared_ptr create_l(); }; /**