sipxmedialib  Version 3.3
MpUdpBuf.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2012 SIPez LLC. All rights reserved.
3 //
4 //
5 // $$
7 
8 #ifndef _INCLUDED_MPUDPBUF_H /* [ */
9 #define _INCLUDED_MPUDPBUF_H
10 
11 // SYSTEM INCLUDES
12 #ifdef __pingtel_on_posix__ // [
13 # include <netinet/in.h>
14 #endif // __pigntel_on_posix__ ]
15 
16 #ifdef WIN32
17 # include <winsock2.h>
18 #endif
19 
20 // APPLICATION INCLUDES
21 #include <mp/MpDataBuf.h>
22 #include <mp/MpMisc.h>
23 
24 // DEFINES
25 // MACROS
26 // EXTERNAL FUNCTIONS
27 // EXTERNAL VARIABLES
28 // CONSTANTS
29 // STRUCTS
30 // TYPEDEFS
31 
33 
37 struct MpUdpBuf : public MpDataBuf
38 {
39  friend class MpUdpBufPtr;
40 
41 /* //////////////////////////// PUBLIC //////////////////////////////////// */
42 public:
43 
45 
46 /* ============================ CREATORS ================================== */
48 
49 
50 
52 
53 /* ============================ MANIPULATORS ============================== */
55 
56 
58 
61  bool setPacketSize(int size)
62  {
63  if(!mpData.isValid())
64  {
66  }
67  return mpData->setDataSize(size);
68  }
69 
71  void setTimecode(unsigned timecode) {mTimecode=timecode;}
72 
74  void setIP(const in_addr &ip) {mIP=ip;}
75 
77  void setUdpPort(unsigned port) {mPort=port;}
78 
80 
81 /* ============================ ACCESSORS ================================= */
83 
84 
86  unsigned getPacketSize() const {return mpData->getDataSize();}
87 
89  unsigned getMaximumPacketSize() const {return mpData->getMaxDataSize();}
90 
92  unsigned getTimecode() const {return mTimecode;}
93 
95  const in_addr &getIP() const {return mIP;}
96 
98  unsigned getUdpPort() const {return mPort;}
99 
101 
102 /* ============================ INQUIRY =================================== */
104 
105 
106 
108 
109 /* //////////////////////////// PROTECTED ///////////////////////////////// */
110 protected:
111 
112  unsigned mTimecode;
113  in_addr mIP;
115  unsigned mPort;
116 
118  void init();
119 
120 /* //////////////////////////// PRIVATE /////////////////////////////////// */
121 private:
122 
124  MpUdpBuf(const MpBuf &);
129  MpUdpBuf &operator=(const MpBuf &);
134 };
135 
137 
142 class MpUdpBufPtr : public MpDataBufPtr {
143 
144 /* //////////////////////////// PUBLIC //////////////////////////////////// */
145 public:
146 
147 /* ============================ CREATORS ================================== */
149 
150 
153 
154 
156 
157 
159 
160 
161 
162 /* ============================ MANIPULATORS ============================== */
164 
165 
166 
167 
168 
169 /* ============================ ACCESSORS ================================= */
171 
172 
175 
176 
178 
179 
180 
181 /* ============================ INQUIRY =================================== */
183 
184 
185 
186 
187 
188 /* //////////////////////////// PROTECTED ///////////////////////////////// */
189 protected:
190 
191 
192 /* //////////////////////////// PRIVATE /////////////////////////////////// */
193 private:
194 
195 };
196 
197 #endif /* ] _INCLUDED_MPUDPBUF_H */
void setUdpPort(unsigned port)
Set source/destination UDP port for this packet.
Definition: MpUdpBuf.h:77
void setIP(const in_addr &ip)
Set source/destination address for this packet.
Definition: MpUdpBuf.h:74
#define MPBUF_TYPECHECKED_COPY(classname, buffer_type, base_classname)
Copy object from base type with type check.
Definition: MpBuf.h:407
unsigned getPacketSize() const
Get size of packet data in bytes.
Definition: MpUdpBuf.h:86
Buffer for raw UDP packet.
Definition: MpUdpBuf.h:37
MpBufPool * UdpPool
Memory pool for raw UDP packets.
Definition: MpMisc.h:77
MpArrayBufPtr mpData
Payload data.
Definition: MpDataBuf.h:93
void init()
This is called in place of constructor.
Definition: MpUdpBuf.cpp:31
#define MPBUFDATA_FROM_BASE_CONSTRUCTOR(classname, buffer_type, base_classname)
This constructor owns MpBuf object.
Definition: MpDataBuf.h:18
unsigned getMaximumPacketSize() const
Get maximum size of data this buffer can bear.
Definition: MpUdpBuf.h:89
MpUdpBuf(const MpBuf &)
Disable copy (and other) constructor.
unsigned mPort
Source/destination UDP-port of this packet.
Definition: MpUdpBuf.h:115
struct __MpGlobals MpMisc
Definition: MpMisc.cpp:101
int profileFlowgraphPoolUsage()
Syslog a histigram of buffers used by flowgraph.
Definition: MpBufPool.cpp:253
unsigned getTimecode() const
Get time code for this packet.
Definition: MpUdpBuf.h:92
Smart pointer to MpUdpBuf.
Definition: MpUdpBuf.h:142
unsigned mTimecode
Definition: MpUdpBuf.h:112
#define MPBUF_MEMBER_ACCESS_OPERATOR(classname)
Return pointer to buffer.
Definition: MpBuf.h:417
MpUdpBuf & operator=(const MpBuf &)
Disable assignment operator.
#define MPBUF_CONST_MEMBER_ACCESS_OPERATOR(classname)
Return readonly pointer to buffer.
Definition: MpBuf.h:422
static MpBufPool * smpDefaultPool
Default pool for this type of buffer.
Definition: MpUdpBuf.h:44
const in_addr & getIP() const
Get source/destination address for this packet.
Definition: MpUdpBuf.h:95
bool setPacketSize(int size)
Set size of packet data in bytes.
Definition: MpUdpBuf.h:61
unsigned getUdpPort() const
Get source/destination UDP port for this packet.
Definition: MpUdpBuf.h:98
Smart pointer to MpDataBuf.
Definition: MpDataBuf.h:127
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 MpUdpBuf type.
Definition: MpBuf.h:54
#define MPBUF_DEFAULT_CONSTRUCTOR(classname)
Default constructor - construct invalid pointer.
Definition: MpBuf.h:387
in_addr mIP
Source/destination IP-addres of this packet.
Definition: MpUdpBuf.h:114
Pool of buffers.
Definition: MpBufPool.h:32
void setTimecode(unsigned timecode)
Set time code for this packet.
Definition: MpUdpBuf.h:71
Stores data in the external buffer.
Definition: MpDataBuf.h:42