Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
FrameFactory.h
1#pragma once
2#include <boost/pool/object_pool.hpp>
3#include <boost/shared_ptr.hpp>
4#include <boost/thread/mutex.hpp>
5#include <atomic>
6
7#include "CommonDefs.h"
8#include "FrameMetadata.h"
9#include "Allocators.h"
10#include <memory>
11
13{
14private:
15 boost::object_pool<Frame> frame_allocator;
16 std::shared_ptr<HostAllocator> memory_allocator;
17
18 frame_sp eosFrame;
19 frame_sp emptyFrame;
20 boost::mutex m_mutex;
21
22 std::atomic_uint counter;
23 std::atomic_size_t numberOfChunks;
25 framemetadata_sp mMetadata;
26public:
27 FrameFactory(framemetadata_sp metadata, size_t _maxConcurrentFrames=0);
28 virtual ~FrameFactory();
29 frame_sp create(size_t size, boost::shared_ptr<FrameFactory>& mother);
30 // Intended only for command, props, pauseplay
31 // don't use it for normal output frames - Module when sending EOP is using it and some other modules
32 frame_sp create(size_t size, boost::shared_ptr<FrameFactory>& mother,framemetadata_sp& metadata);
33 frame_sp create(boost::shared_ptr<FrameFactory>& mother);
34 frame_sp create(frame_sp &frame, size_t size, boost::shared_ptr<FrameFactory>& mother);
35 void destroy(Frame* pointer);
36 frame_sp getEOSFrame() {
37 return eosFrame;
38 }
39 size_t getNumberOfChunks(size_t size);
40 framemetadata_sp getFrameMetadata(){return mMetadata;}
41 void setMetadata(framemetadata_sp metadata) { mMetadata = metadata;}
42
43 frame_sp getEmptyFrame() { return emptyFrame; }
44
45 std::string getPoolHealthRecord();
46};
Definition FrameFactory.h:13
frame_sp create(boost::shared_ptr< FrameFactory > &mother)
std::atomic_size_t numberOfChunks
Definition FrameFactory.h:23
void destroy(Frame *pointer)
Definition FrameFactory.cpp:78
std::string getPoolHealthRecord()
Definition FrameFactory.cpp:130
boost::object_pool< Frame > frame_allocator
Definition FrameFactory.h:15
size_t maxConcurrentFrames
Definition FrameFactory.h:24
size_t getNumberOfChunks(size_t size)
Definition FrameFactory.cpp:48
frame_sp getEmptyFrame()
Definition FrameFactory.h:43
frame_sp eosFrame
Definition FrameFactory.h:18
framemetadata_sp mMetadata
Definition FrameFactory.h:25
framemetadata_sp getFrameMetadata()
Definition FrameFactory.h:40
std::atomic_uint counter
Definition FrameFactory.h:22
frame_sp emptyFrame
Definition FrameFactory.h:19
FrameFactory(framemetadata_sp metadata, size_t _maxConcurrentFrames=0)
Definition FrameFactory.cpp:13
boost::mutex m_mutex
Definition FrameFactory.h:20
void setMetadata(framemetadata_sp metadata)
Definition FrameFactory.h:41
frame_sp create(size_t size, boost::shared_ptr< FrameFactory > &mother)
Definition FrameFactory.cpp:54
std::shared_ptr< HostAllocator > memory_allocator
Definition FrameFactory.h:16
virtual ~FrameFactory()
Definition FrameFactory.cpp:44
frame_sp getEOSFrame()
Definition FrameFactory.h:36
Definition Frame.h:10