mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
精简Frame对象实例化相关代码
This commit is contained in:
parent
57e91054af
commit
186c15364a
@ -22,34 +22,6 @@ namespace toolkit {
|
||||
|
||||
namespace mediakit{
|
||||
|
||||
template<typename C>
|
||||
std::shared_ptr<C> FrameImp::create_l() {
|
||||
#if 0
|
||||
static ResourcePool<C> 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<C>(new C());
|
||||
#endif
|
||||
}
|
||||
|
||||
#define CREATE_FRAME_IMP(C) \
|
||||
template<> \
|
||||
std::shared_ptr<C> FrameImp::create<C>() { \
|
||||
return create_l<C>(); \
|
||||
}
|
||||
|
||||
CREATE_FRAME_IMP(FrameImp);
|
||||
CREATE_FRAME_IMP(H264Frame);
|
||||
CREATE_FRAME_IMP(H265Frame);
|
||||
|
||||
/**
|
||||
* 该对象的功能是把一个不可缓存的帧转换成可缓存的帧
|
||||
*/
|
||||
|
@ -179,7 +179,22 @@ public:
|
||||
using Ptr = std::shared_ptr<FrameImp>;
|
||||
|
||||
template<typename C=FrameImp>
|
||||
static std::shared_ptr<C> create();
|
||||
static std::shared_ptr<C> create() {
|
||||
#if 0
|
||||
static ResourcePool<C> 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<C>(new C());
|
||||
#endif
|
||||
}
|
||||
|
||||
char *data() const override{
|
||||
return (char *)_buffer.data();
|
||||
@ -227,9 +242,6 @@ private:
|
||||
protected:
|
||||
friend class ResourcePool_l<FrameImp>;
|
||||
FrameImp() = default;
|
||||
|
||||
template<typename C>
|
||||
static std::shared_ptr<C> create_l();
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user