1 #ifndef sharedmem_HEADER_GUARD 2 #define sharedmem_HEADER_GUARD 42 #include <semaphore.h> 86 SharedMemSegment(
const char* name, std::size_t n_bytes,
bool is_server=
false);
91 virtual void serverInit() = 0;
92 virtual bool clientInit() = 0;
93 virtual void serverClose() = 0;
94 virtual void clientClose() = 0;
97 virtual std::size_t getSize() = 0;
99 virtual void put(std::vector<uint8_t> &inp_payload,
void *meta_) = 0;
100 virtual void put(uint8_t* buf_,
void* meta_) = 0;
102 virtual void copyMetaFrom(
void *meta_) = 0;
103 virtual void copyMetaTo(
void *meta_) = 0;
121 bool getClientState();
136 virtual void serverInit();
137 virtual bool clientInit();
138 virtual void serverClose();
139 virtual void clientClose();
142 virtual std::size_t getSize();
145 virtual void put(std::vector<uint8_t> &inp_payload,
void* meta_);
146 virtual void put(uint8_t* buf_,
void* meta_);
149 virtual void copyMetaFrom(
void *meta_);
150 virtual void copyMetaTo(
void *meta_);
156 void put(std::vector<uint8_t> &inp_payload);
170 long int mstimestamp;
186 virtual void serverInit();
187 virtual bool clientInit();
188 virtual void serverClose();
189 virtual void clientClose();
192 virtual std::size_t getSize();
194 virtual void put(std::vector<uint8_t> &inp_payload,
void* meta_);
195 virtual void put(uint8_t* buf_,
void* meta_);
198 virtual void copyMetaFrom(
void *meta_);
199 virtual void copyMetaTo(
void *meta_);
231 SharedMemRingBufferBase(
const char* name,
int n_cells, std::size_t n_bytes,
int mstimeout=0,
bool is_server=
false);
264 bool getClientState();
273 void serverPush(std::vector<uint8_t> &inp_payload,
void* meta);
275 void serverUseFd(
EventFd &event_fd);
288 bool clientPull(
int &index_out,
void* meta);
290 bool clientPullThread(
int &index_out,
void* meta);
291 PyObject *getBufferListPy();
293 void clientUseFd(
EventFd &event_fd);
301 SharedMemRingBuffer(
const char* name,
int n_cells, std::size_t n_bytes,
int mstimeout=0,
bool is_server=
false);
306 void serverPush(std::vector<uint8_t> &inp_payload);
307 bool clientPull(
int &index_out,
int &size_out);
320 SharedMemRingBufferRGB(
const char* name,
int n_cells,
int width,
int height,
int mstimeout=0,
bool is_server=
false);
336 bool clientPull(
int &index_out,
int &size_out);
338 bool clientPullFrame(
int &index_out,
RGB24Meta &meta);
340 bool clientPullFrameThread(
int &index_out,
RGB24Meta &meta);
341 bool serverPushPyRGB(PyObject *po, SlotNumber slot,
long int mstimestamp);
364 ShmemFrameFilter(
const char* name,
int n_cells, std::size_t n_bytes,
int mstimeout=0);
374 virtual void go(
Frame* frame);
391 RGBShmemFrameFilter(
const char* name,
int n_cells,
int width,
int height,
int mstimeout=0);
402 virtual void go(
Frame* frame);
Interprocess shared memory ring buffer synchronized with posix semaphores.
Definition: sharedmem.h:217
std::vector< SharedMemSegment * > shmems
Shared memory segments.
Definition: sharedmem.h:250
A file descriptor for running select and poll with shmem ring buffers.
Definition: sharedmem.h:49
std::string payload_name
Name to identify the posix memory mapped file.
Definition: sharedmem.h:107
Shared memory segment with metadata (the segment size)
Definition: sharedmem.h:76
uint8_t * payload
Pointer to payload.
Definition: sharedmem.h:114
A Shmem segment describing an RGB24 frame.
Definition: sharedmem.h:179
std::string flagsema_name
Name to identify the posix semaphore used for the overflow flag.
Definition: sharedmem.h:244
Definition: sharedmem.h:298
int index
The index of cell that has just been written. Remember: server and client see their own copies of thi...
Definition: sharedmem.h:245
Like ShmemFrameFilter.
Definition: sharedmem.h:386
std::string meta_name
Name to identify the posix memory mapped file for the metadata.
Definition: sharedmem.h:108
void * ptr_
Raw pointers to shared memory.
Definition: sharedmem.h:110
This FrameFilter writes frames into a SharedMemRingBuffer.
Definition: sharedmem.h:351
std::size_t n_bytes
Maximum size of the payload (this much is reserved)
Definition: sharedmem.h:116
std::string sema_name
Name to identify the posix semaphore counter.
Definition: sharedmem.h:243
SharedMemRingBuffer for AVRGBFrame.
Definition: sharedmem.h:316
bool is_server
Are we on the server side or not?
Definition: sharedmem.h:239
Definition of FrameFilter and derived classes for various purposes.
bool is_server
Client or server process?
Definition: sharedmem.h:109
Decoded YUV frame in a non-planar format (thus "NP")
Definition: frame.h:430
int fd
A file descriptor for poll and select.
Definition: sharedmem.h:247
bool client_state
Was the shmem acquisition succesfull?
Definition: sharedmem.h:111
Frame: An abstract queueable class.
Definition: frame.h:108
List of common header files.
std::string name
Name to identify the posix objects.
Definition: sharedmem.h:106
The mother class of all frame filters! FrameFilters are used to create "filter chains".
Definition: framefilter.h:46
int n_bytes
Parameters defining the shmem ring buffer (number, size)
Definition: sharedmem.h:237
int mstimeout
Semaphore timeout in milliseconds.
Definition: sharedmem.h:238
sem_t * flagsema
Posix semaphore objects (semaphore counter, semaphore for the overflow flag)
Definition: sharedmem.h:242
Shared mem segment with simple metadata : just the payload length.
Definition: sharedmem.h:129