Bayonne2 / Common C++ 2 Framework
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
queuebase.h
Go to the documentation of this file.
1 // Copyright (C) 2001,2002,2004 Federico Montesino Pouzols <fedemp@altern.org>.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // ccRTP. If you copy code from other releases into a copy of GNU
28 // ccRTP, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU ccRTP, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
44 #ifndef CCXX_RTP_QUEUEBASE_H_
45 #define CCXX_RTP_QUEUEBASE_H_
46 
47 #include <cc++/pointer.h>
48 #include <ccrtp/rtppkt.h>
49 #include <ccrtp/sources.h>
50 
51 #ifdef CCXX_NAMESPACES
52 namespace ost {
53 #endif
54 
72 {
73 public:
74  AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src);
75 
76  inline ~AppDataUnit()
77  { }
78 
82  AppDataUnit(const AppDataUnit& src);
83 
91  operator=(const AppDataUnit& source);
92 
96  inline PayloadType
97  getType() const
98  { return datablock->getPayloadType(); }
99 
107  inline const uint8* const
108  getData() const
109  { return datablock->getPayload(); }
110 
114  size_t
115  getSize() const
116  { return datablock->getPayloadSize(); }
117 
121  inline const SyncSource&
122  getSource() const
123  { return *source; }
124 
130  inline bool
131  isMarked() const
132  { return datablock->isMarked(); }
133 
137  inline uint16
138  getSeqNum() const
139  { return datablock->getSeqNum(); }
140 
144  inline uint8
146  { return (uint8)datablock->getCSRCsCount(); }
147 
153  inline const uint32*
155  { return datablock->getCSRCs(); }
156 
157 private:
160 };
161 
170 {
171 public:
179  inline bool
181  {
182  currentPayloadType = pf.getPayloadType();
183  currentRTPClockRate = pf.getRTPClockRate();
184  return true;
185  }
186 
187  inline uint32 getLocalSSRC() const
188  { return localSSRC; }
189 
198  inline uint32 getCurrentRTPClockRate() const
199  { return currentRTPClockRate; }
200 
202  { return currentPayloadType; }
203 
204  inline timeval getInitialTime() const
205  { return initialTime; }
206 
207 protected:
212  RTPQueueBase(uint32 *ssrc = NULL);
213 
214  inline void setLocalSSRC(uint32 ssrc)
215  { localSSRC = ssrc; localSSRCNetwork = htonl(ssrc); }
216 
217  inline uint32 getLocalSSRCNetwork() const
218  { return localSSRCNetwork; }
219 
220  virtual
222  { }
223 
230  inline virtual size_t
231  dispatchBYE(const std::string&)
232  { return 0; }
233 
234  inline virtual void
236  { }
237 
238 private:
239  // local SSRC 32-bit identifier
240  uint32 localSSRC;
241  // SSRC in network byte order
243  // RTP clock rate for the current payload type.
245  // Current payload type set for outgoing packets and expected
246  // from incoming packets.
248  // when the queue is created
249  timeval initialTime;
250 };
251 
258  public virtual RTPQueueBase
259 {
260 public:
261  inline size_t
263  { return defaultMaxSendSegmentSize;}
264 
271  inline void
273  { maxSendSegmentSize = size; }
274 
275  inline size_t
277  { return maxSendSegmentSize; }
278 
279 protected:
281 
282  inline virtual
284  { }
285 
286 private:
287  static const size_t defaultMaxSendSegmentSize;
288  // maximum packet size before fragmenting sends.
290 };
291 
298  public virtual RTPQueueBase
299 {
300 public:
301  inline size_t getDefaultMaxRecvPacketSize() const
302  { return defaultMaxRecvPacketSize; }
303 
304  inline size_t
306  { return maxRecvPacketSize; }
307 
318  inline void
319  setMaxRecvPacketSize(size_t maxsize)
320  { maxRecvPacketSize = maxsize; }
321 
322 protected:
324  { setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); }
325 
326  inline virtual
328  { }
329 
330 private:
331  static const size_t defaultMaxRecvPacketSize;
332  // filter value for received packets length.
334 };
335  // queuebase
337 
338 #ifdef CCXX_NAMESPACES
339 }
340 #endif
341 
342 #endif //CCXX_RTP_QUEUEBASE_H_
343 
virtual ~OutgoingDataQueueBase()
Definition: queuebase.h:283
uint32 localSSRC
Definition: queuebase.h:240
bool isMarked() const
Is this data unit marked?.
Definition: queuebase.h:131
virtual size_t dispatchBYE(const std::string &)
A plugin point for posting of BYE messages.
Definition: queuebase.h:231
PayloadType getType() const
Definition: queuebase.h:97
Synchronization source in an RTP session.
Definition: sources.h:195
Interface (envelope) to data received over RTP packets.
Definition: queuebase.h:71
uint16 getSeqNum() const
Get data unit sequence number.
Definition: queuebase.h:138
RTP packets received from other participants.
Definition: rtppkt.h:707
Base payload format class.
Definition: formats.h:132
bool setPayloadFormat(const PayloadFormat &pf)
Set the payload format in use, for timing and payload type identification purposes.
Definition: queuebase.h:180
size_t getDefaultMaxSendSegmentSize()
Definition: queuebase.h:262
virtual ~IncomingDataQueueBase()
Definition: queuebase.h:327
virtual void renewLocalSSRC()
Definition: queuebase.h:235
Sources of synchronization and participants related clases.
size_t getMaxRecvPacketSize() const
Definition: queuebase.h:305
PayloadType getCurrentPayloadType() const
Definition: queuebase.h:201
uint32 localSSRCNetwork
Definition: queuebase.h:242
timeval getInitialTime() const
Definition: queuebase.h:204
Pointer< const IncomingRTPPkt > datablock
Definition: queuebase.h:158
PayloadType getPayloadType() const
Get payload type numeric identifier carried in RTP packets.
Definition: formats.h:140
void setLocalSSRC(uint32 ssrc)
Definition: queuebase.h:214
void setMaxSendSegmentSize(size_t size)
Set maximum payload segment size before fragmenting sends.
Definition: queuebase.h:272
A virtual base class for RTP queue hierarchies.
Definition: queuebase.h:169
size_t getMaxSendSegmentSize()
Definition: queuebase.h:276
uint32 getLocalSSRCNetwork() const
Definition: queuebase.h:217
#define __EXPORT
Definition: audio2.h:51
const SyncSource * source
Definition: queuebase.h:159
uint32 getRTPClockRate() const
Get RTP clock rate for this payload format.
Definition: formats.h:151
virtual ~RTPQueueBase()
Definition: queuebase.h:221
PayloadType currentPayloadType
Definition: queuebase.h:247
uint32 getLocalSSRC() const
Definition: queuebase.h:187
size_t getDefaultMaxRecvPacketSize() const
Definition: queuebase.h:301
timeval initialTime
Definition: queuebase.h:249
const SyncSource & getSource() const
Definition: queuebase.h:122
size_t getSize() const
Definition: queuebase.h:115
void setMaxRecvPacketSize(size_t maxsize)
Definition: queuebase.h:319
uint8 getContributorsCount() const
Get the number of contributing sources in the CSRC list.
Definition: queuebase.h:145
const uint32 * getContributorsID() const
Get the array of 32-bit CSRC identifiers.
Definition: queuebase.h:154
~AppDataUnit()
Definition: queuebase.h:76
const uint8 *const getData() const
Get data as it is received in RTP packets (i.e.
Definition: queuebase.h:108
uint32 getCurrentRTPClockRate() const
Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU, or 90000 units per second for MP2T).
Definition: queuebase.h:198
static const size_t defaultMaxRecvPacketSize
Definition: queuebase.h:331
Template for creating reference count managed smart pointers.
uint32 currentRTPClockRate
Definition: queuebase.h:244
RTP packets handling.
static const size_t defaultMaxSendSegmentSize
Definition: queuebase.h:287
uint8 PayloadType
RTP payload type numeric identifier.
Definition: formats.h:65