sipxmedialib  Version 3.3
MpDataBuf.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2012 SIPez LLC. All rights reserved.
3 //
4 // $$
6 
7 #ifndef _INCLUDED_MPDATABUF_H // [
8 #define _INCLUDED_MPDATABUF_H
9 
10 // SYSTEM INCLUDES
11 // APPLICATION INCLUDES
12 #include "mp/MpBuf.h"
13 #include "mp/MpArrayBuf.h"
14 
15 // DEFINES
16 // MACROS
18 #define MPBUFDATA_FROM_BASE_CONSTRUCTOR(classname, buffer_type, base_classname) \
19  classname##Ptr( MpBuf *buffer \
20  , MpBufPool *pHeaderPool=classname::smpDefaultPool) \
21  : base_classname##Ptr(buffer, pHeaderPool) \
22  { \
23  if (mpBuffer != NULL) { \
24  MPBUF_FROM_BASE_CONSTRUCTOR_INIT(classname, buffer_type) \
25  } \
26  };
27 
28 // EXTERNAL FUNCTIONS
29 // EXTERNAL VARIABLES
30 // CONSTANTS
31 // STRUCTS
32 // TYPEDEFS
33 
35 
42 struct MpDataBuf : public MpBuf
43 {
44  friend class MpDataBufPtr;
45 /* //////////////////////////// PUBLIC //////////////////////////////////// */
46 public:
47 
50 
51 /* ============================ CREATORS ================================== */
53 
54 
55 
57 
58 /* ============================ MANIPULATORS ============================== */
60 
61 
63  void setData(const MpArrayBufPtr &pData)
64  { mpData = pData; };
65 
67 
68 /* ============================ ACCESSORS ================================= */
70 
71 
73  char *getDataWritePtr();
74 
76  const char *getDataPtr() const;
77 
79  MpArrayBufPtr getData() const {return mpData;};
80 
82 
83 /* ============================ INQUIRY =================================== */
85 
86 
87 
89 
90 /* //////////////////////////// PROTECTED ///////////////////////////////// */
91 protected:
92 
94 
96  void init();
97 
99  static void sDestroy(MpBuf *pBuffer);
100 
103  static void sInitClone(MpBuf *pBuffer);
104 
105 /* //////////////////////////// PRIVATE /////////////////////////////////// */
106 private:
107 
109  MpDataBuf(const MpBuf &);
114  MpDataBuf &operator=(const MpBuf &);
119 };
120 
122 
127 class MpDataBufPtr : public MpBufPtr {
128 
129 /* //////////////////////////// PUBLIC //////////////////////////////////// */
130 public:
131 
132 /* ============================ CREATORS ================================== */
134 
135 
138 
139 
140  MpDataBufPtr(MpBuf *pDataBuffer, MpBufPool *pHeaderPool=MpDataBuf::smpDefaultPool)
141  : MpBufPtr(pHeaderPool->getBuffer())
142  {
143  if (mpBuffer != NULL) {
145 
146  // Set data pointer
147  pBuffer->setData(MpArrayBufPtr(pDataBuffer));
148  }
149  };
150 
153 
154 
155 
156 /* ============================ MANIPULATORS ============================== */
158 
159 
160 
161 
162 
163 /* ============================ ACCESSORS ================================= */
165 
166 
167  void setFlowGraph(MpFlowGraphBase* flowgraph)
168  {
169  if(mpBuffer != NULL)
170  {
171  mpBuffer->setFlowGraph(flowgraph);
172  ((MpDataBuf*)mpBuffer)->mpData.setFlowGraph(flowgraph);
173  }
174  };
175 
178 
179 
181 
182 
183 
184 /* ============================ INQUIRY =================================== */
186 
187 
188 
189 
190 
191 /* //////////////////////////// PROTECTED ///////////////////////////////// */
192 protected:
193 
194 
195 /* //////////////////////////// PRIVATE /////////////////////////////////// */
196 private:
197 
198 };
199 
200 #endif // _INCLUDED_MPDATABUF_H ]
#define MPBUF_TYPECHECKED_COPY(classname, buffer_type, base_classname)
Copy object from base type with type check.
Definition: MpBuf.h:407
static void sDestroy(MpBuf *pBuffer)
Destructor for MpDataBuf.
Definition: MpDataBuf.cpp:26
char * getDataWritePtr()
Return pointer to payload data.
Definition: MpDataBuf.cpp:35
static MpBufPool * smpDefaultPool
Default pool for MpDataBuf objects.
Definition: MpDataBuf.h:49
const char * getDataPtr() const
Return pointer to payload data.
Definition: MpDataBuf.cpp:43
MpArrayBufPtr mpData
Payload data.
Definition: MpDataBuf.h:93
MpDataBuf & operator=(const MpBuf &)
Disable assignment operator.
static void sInitClone(MpBuf *pBuffer)
Function that initialize buffer after cloning. It makes clone of mpData.
Definition: MpDataBuf.cpp:72
Flow graph for coordinating the execution of media processing resources.
Definition: MpFlowGraphBase.h:91
#define MPBUF_FROM_BASE_CONSTRUCTOR_INIT(classname, buffer_type)
Definition: MpBuf.h:390
void init()
This is called in place of constructor.
Definition: MpDataBuf.cpp:56
void setFlowGraph(MpFlowGraphBase *flowgraph)
Definition: MpBuf.h:103
Begin of the MpDataBuf type.
Definition: MpBuf.h:49
#define MPBUF_MEMBER_ACCESS_OPERATOR(classname)
Return pointer to buffer.
Definition: MpBuf.h:417
#define MPBUF_CONST_MEMBER_ACCESS_OPERATOR(classname)
Return readonly pointer to buffer.
Definition: MpBuf.h:422
MpDataBuf(const MpBuf &)
Disable copy (and other) constructor.
Smart pointer to MpArrayBuf.
Definition: MpArrayBuf.h:128
Smart pointer to MpBuf.
Definition: MpBuf.h:160
Smart pointer to MpDataBuf.
Definition: MpDataBuf.h:127
void setData(const MpArrayBufPtr &pData)
Set new payload data.
Definition: MpDataBuf.h:63
MpArrayBufPtr getData() const
Get payload data.
Definition: MpDataBuf.h:79
Base class for all media buffers.
Definition: MpBuf.h:74
#define MPBUF_DEFAULT_CONSTRUCTOR(classname)
Default constructor - construct invalid pointer.
Definition: MpBuf.h:387
Pool of buffers.
Definition: MpBufPool.h:32
Stores data in the external buffer.
Definition: MpDataBuf.h:42