8 #ifndef _INCLUDED_MPBUF_H // [ 9 #define _INCLUDED_MPBUF_H 182 if (mpBuffer != NULL) {
184 mpBuffer->mpDestroy = NULL;
190 osPrintf(
"mpBuffer == NULL!\n");
198 if (mpBuffer != NULL)
204 : mpBuffer(buffer.mpBuffer)
206 if (mpBuffer != NULL)
245 if (&bufferPtr ==
this) {
249 if (mpBuffer != NULL)
252 if (mpBuffer != NULL)
264 return (mpBuffer == pBuffer.
mpBuffer);
273 return (mpBuffer != pBuffer.
mpBuffer);
282 if (mpBuffer != NULL)
313 if (mpBuffer == NULL)
332 if (mpBuffer == NULL)
335 return mpBuffer->mpPool->getBufferNumber(mpBuffer);
342 mpBuffer->setFlowGraph(flowgraph);
354 if(mpBuffer)
return(mpBuffer->getType());
365 bool isValid()
const {
return mpBuffer != NULL;};
371 bool isWritable() {
return (mpBuffer != NULL) && (mpBuffer->mRefCounter == 1);};
387 #define MPBUF_DEFAULT_CONSTRUCTOR(classname) \ 390 #define MPBUF_FROM_BASE_CONSTRUCTOR_INIT(classname, buffer_type) \ 391 classname *pBuffer = (classname*)mpBuffer; \ 392 assert(pBuffer->mpPool->getBlockSize() >= sizeof(classname)); \ 393 pBuffer->mType = buffer_type; \ 396 #define MPBUF_FROM_BASE_CONSTRUCTOR(classname, buffer_type, base_classname) \ 398 classname##Ptr(MpBuf *buffer) \ 399 : base_classname##Ptr(buffer) \ 401 if (mpBuffer != NULL) { \ 402 MPBUF_FROM_BASE_CONSTRUCTOR_INIT(classname, buffer_type) \ 407 #define MPBUF_TYPECHECKED_COPY(classname, buffer_type, base_classname) \ 408 classname##Ptr(const MpBufPtr &buffer) \ 409 : base_classname##Ptr(buffer) \ 411 assert( (!buffer.isValid()) \ 412 || ( buffer->getType() >= buffer_type \ 413 && buffer->getType() < buffer_type##_END)); \ 417 #define MPBUF_MEMBER_ACCESS_OPERATOR(classname) \ 418 classname *operator->() \ 419 {assert(mpBuffer!=NULL); return (classname*)mpBuffer;}; 422 #define MPBUF_CONST_MEMBER_ACCESS_OPERATOR(classname) \ 423 const classname *operator->() const \ 424 {assert(mpBuffer!=NULL); return (classname*)mpBuffer;}; 426 #endif // _INCLUDED_MPBUF_H ] MpBufPtr(MpBuf *buffer)
This constructor owns MpBuf object.
Definition: MpBuf.h:179
Begin of the MpArrayBuf type.
Definition: MpBuf.h:47
MpBuf & operator=(const MpBuf &)
Disable assignment operator.
End of the MpAudioBuf type.
Definition: MpBuf.h:51
unsigned getBlockSize() const
Return size of the one block in the pool (in bytes).
Definition: MpBufPool.h:69
MpBuf * mpBuffer
Pointer to real buffer.
Definition: MpBuf.h:379
End of the MpDataBuf type.
Definition: MpBuf.h:58
void setFlowGraph(MpFlowGraphBase *flowgraph)
Definition: MpBuf.h:338
MP_BUFFERS_TREE getType() const
Definition: MpBuf.h:352
int getBufferNumber() const
Return number of the buffer in the pool. Use this for debug output.
Definition: MpBuf.h:330
MpFlowGraphBase * mpFlowGraph
Debug pointer to flowgraph in which this buf is used.
Definition: MpBuf.h:128
MpBufPtr clone() const
Definition: MpBuf.h:210
MpBufPtr & operator=(const MpBufPtr &bufferPtr)
Smart assignment.
Definition: MpBuf.h:242
Flow graph for coordinating the execution of media processing resources.
Definition: MpFlowGraphBase.h:91
static void sInitClone(MpBuf *pBuffer)
Function that initialize buffer after cloning. It adjusts reference counters.
Definition: MpBuf.cpp:64
~MpBufPtr()
Destructor. It decrements buffer's reference counter.
Definition: MpBuf.h:196
MpBuf * operator->()
Return pointer to MpBuf.
Definition: MpBuf.h:347
bool operator!=(const MpBufPtr &pBuffer)
Compare two smart pointers.
Definition: MpBuf.h:271
void swap(MpBufPtr &pBuffer)
Swap to buffers.
Definition: MpBuf.h:293
MpBufPtr(const MpBufPtr &buffer)
Copy buffer pointer and increment its reference counter.
Definition: MpBuf.h:203
void(* mpInitClone)(MpBuf *)
Definition: MpBuf.h:131
void setFlowGraph(MpFlowGraphBase *flowgraph)
Definition: MpBuf.h:103
MpBuf * getBuffer()
Get free block from pool.
Definition: MpBufPool.cpp:150
const MpBuf * operator->() const
Return readonly pointer to MpBuf.
Definition: MpBuf.h:350
Begin of the MpDataBuf type.
Definition: MpBuf.h:49
MpBufPool * getBufferPool() const
Get parent pool of this buffer.
Definition: MpBuf.h:112
void detach()
Decrements reference counter and free buffer if needed.
Definition: MpBuf.cpp:34
bool requestWrite()
Check if buffer is writable and create copy if no.
Definition: MpBuf.h:306
End of the MpArrayBuf type.
Definition: MpBuf.h:48
int mRefCounter
Reference counter for use with MpBufPtr.
Definition: MpBuf.h:126
void attach()
Increments reference counter.
Definition: MpBuf.cpp:23
MpBufPool * mpPool
Parent memory pool.
Definition: MpBuf.h:127
MP_BUFFERS_TREE getType() const
Get buffer type.
Definition: MpBuf.h:109
bool operator==(const MpBufPtr &pBuffer)
Compare two smart pointers.
Definition: MpBuf.h:262
Smart pointer to MpBuf.
Definition: MpBuf.h:160
End of the MpBuf type.
Definition: MpBuf.h:59
End of the MpUdpBuf type.
Definition: MpBuf.h:57
MP_BUFFERS_TREE mType
Buffer class type. Used for type safety.
Definition: MpBuf.h:125
void release()
Release buffer we are pointing to.
Definition: MpBuf.h:280
void(* mpDestroy)(MpBuf *)
Definition: MpBuf.h:129
Base class for all media buffers.
Definition: MpBuf.h:74
bool isValid() const
Can this pointer be dereferenced? Use this function instead of NULL comparison.
Definition: MpBuf.h:365
Begin of the MpBuf type.
Definition: MpBuf.h:46
End of the MpVideoBuf type.
Definition: MpBuf.h:53
Begin of the MpAudioBuf type.
Definition: MpBuf.h:50
Begin of the MpUdpBuf type.
Definition: MpBuf.h:54
Begin of the MpVideoBuf type.
Definition: MpBuf.h:52
End of the MpRtpBuf type.
Definition: MpBuf.h:56
MP_BUFFERS_TREE
Enum used for runtime type checks.
Definition: MpBuf.h:45
MpBuf(const MpBuf &)
Disable copy (and other) constructor.
Pool of buffers.
Definition: MpBufPool.h:32
Begin of the MpRtpBuf type.
Definition: MpBuf.h:55
MpBufPtr()
Default constructor - construct invalid pointer.
Definition: MpBuf.h:171
Stores data in the external buffer.
Definition: MpDataBuf.h:42