ccRTP
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 <commoncpp/pointer.h>
48#include <ccrtp/rtppkt.h>
49#include <ccrtp/sources.h>
50
51NAMESPACE_COMMONCPP
52
69class __EXPORT AppDataUnit
70{
71public:
72 AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src);
73
74 inline ~AppDataUnit()
75 { }
76
81
89 operator=(const AppDataUnit& source);
90
94 inline PayloadType
95 getType() const
96 { return datablock->getPayloadType(); }
97
105 inline const uint8* const
106 getData() const
107 { return datablock->getPayload(); }
108
112 size_t
113 getSize() const
114 { return datablock->getPayloadSize(); }
115
119 inline const SyncSource&
120 getSource() const
121 { return *source; }
122
128 inline bool
129 isMarked() const
130 { return datablock->isMarked(); }
131
135 inline uint16
136 getSeqNum() const
137 { return datablock->getSeqNum(); }
138
142 inline uint8
144 { return (uint8)datablock->getCSRCsCount(); }
145
151 inline const uint32*
153 { return datablock->getCSRCs(); }
154
155private:
156 Pointer<const IncomingRTPPkt> datablock;
157 const SyncSource* source;
158};
159
167class __EXPORT RTPQueueBase
168{
169public:
177 inline bool
179 {
180 currentPayloadType = pf.getPayloadType();
181 currentRTPClockRate = pf.getRTPClockRate();
182 return true;
183 }
184
185 inline uint32 getLocalSSRC() const
186 { return localSSRC; }
187
196 inline uint32 getCurrentRTPClockRate() const
197 { return currentRTPClockRate; }
198
200 { return currentPayloadType; }
201
202 inline timeval getInitialTime() const
203 { return initialTime; }
204
205protected:
210 RTPQueueBase(uint32 *ssrc = NULL);
211
212 inline void setLocalSSRC(uint32 ssrc)
213 { localSSRC = ssrc; localSSRCNetwork = htonl(ssrc); }
214
215 inline uint32 getLocalSSRCNetwork() const
216 { return localSSRCNetwork; }
217
218 virtual
220 { }
221
228 inline virtual size_t
229 dispatchBYE(const std::string&)
230 { return 0; }
231
232 inline virtual void
234 { }
235
236private:
237 // local SSRC 32-bit identifier
238 uint32 localSSRC;
239 // SSRC in network byte order
240 uint32 localSSRCNetwork;
241 // RTP clock rate for the current payload type.
242 uint32 currentRTPClockRate;
243 // Current payload type set for outgoing packets and expected
244 // from incoming packets.
245 PayloadType currentPayloadType;
246 // when the queue is created
247 timeval initialTime;
248};
249
256 public virtual RTPQueueBase
257{
258public:
259 inline size_t
261 { return defaultMaxSendSegmentSize;}
262
269 inline void
271 { maxSendSegmentSize = size; }
272
273 inline size_t
275 { return maxSendSegmentSize; }
276
277protected:
279
280 inline virtual
282 { }
283
284private:
285 static const size_t defaultMaxSendSegmentSize;
286 // maximum packet size before fragmenting sends.
287 size_t maxSendSegmentSize;
288};
289
296 public virtual RTPQueueBase
297{
298public:
299 inline size_t getDefaultMaxRecvPacketSize() const
300 { return defaultMaxRecvPacketSize; }
301
302 inline size_t
304 { return maxRecvPacketSize; }
305
316 inline void
317 setMaxRecvPacketSize(size_t maxsize)
318 { maxRecvPacketSize = maxsize; }
319
320protected:
322 { setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); }
323
324 inline virtual
326 { }
327
328private:
329 static const size_t defaultMaxRecvPacketSize;
330 // filter value for received packets length.
331 size_t maxRecvPacketSize;
332};
333
// queuebase
335
336END_NAMESPACE
337
338#endif //CCXX_RTP_QUEUEBASE_H_
339
Interface (envelope) to data received over RTP packets.
Definition queuebase.h:70
uint8 getContributorsCount() const
Get the number of contributing sources in the CSRC list.
Definition queuebase.h:143
PayloadType getType() const
Definition queuebase.h:95
uint16 getSeqNum() const
Get data unit sequence number.
Definition queuebase.h:136
bool isMarked() const
Is this data unit marked?.
Definition queuebase.h:129
size_t getSize() const
Definition queuebase.h:113
AppDataUnit & operator=(const AppDataUnit &source)
Assignment operator.
AppDataUnit(const AppDataUnit &src)
const uint8 *const getData() const
Get data as it is received in RTP packets (i.e.
Definition queuebase.h:106
const SyncSource & getSource() const
Definition queuebase.h:120
~AppDataUnit()
Definition queuebase.h:74
AppDataUnit(const IncomingRTPPkt &packet, const SyncSource &src)
const uint32 * getContributorsID() const
Get the array of 32-bit CSRC identifiers.
Definition queuebase.h:152
Definition queuebase.h:297
size_t getMaxRecvPacketSize() const
Definition queuebase.h:303
void setMaxRecvPacketSize(size_t maxsize)
Definition queuebase.h:317
virtual ~IncomingDataQueueBase()
Definition queuebase.h:325
IncomingDataQueueBase()
Definition queuebase.h:321
size_t getDefaultMaxRecvPacketSize() const
Definition queuebase.h:299
RTP packets received from other participants.
Definition rtppkt.h:706
Definition queuebase.h:257
size_t getMaxSendSegmentSize()
Definition queuebase.h:274
void setMaxSendSegmentSize(size_t size)
Set maximum payload segment size before fragmenting sends.
Definition queuebase.h:270
virtual ~OutgoingDataQueueBase()
Definition queuebase.h:281
size_t getDefaultMaxSendSegmentSize()
Definition queuebase.h:260
Base payload format class.
Definition formats.h:131
PayloadType getPayloadType() const
Get payload type numeric identifier carried in RTP packets.
Definition formats.h:138
uint32 getRTPClockRate() const
Get RTP clock rate for this payload format.
Definition formats.h:149
A virtual base class for RTP queue hierarchies.
Definition queuebase.h:168
uint32 getLocalSSRC() const
Definition queuebase.h:185
RTPQueueBase(uint32 *ssrc=NULL)
PayloadType getCurrentPayloadType() const
Definition queuebase.h:199
bool setPayloadFormat(const PayloadFormat &pf)
Set the payload format in use, for timing and payload type identification purposes.
Definition queuebase.h:178
uint32 getLocalSSRCNetwork() const
Definition queuebase.h:215
timeval getInitialTime() const
Definition queuebase.h:202
void setLocalSSRC(uint32 ssrc)
Definition queuebase.h:212
uint32 getCurrentRTPClockRate() const
Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU,...
Definition queuebase.h:196
virtual void renewLocalSSRC()
Definition queuebase.h:233
virtual size_t dispatchBYE(const std::string &)
A plugin point for posting of BYE messages.
Definition queuebase.h:229
virtual ~RTPQueueBase()
Definition queuebase.h:219
Synchronization source in an RTP session.
Definition sources.h:195
uint8 PayloadType
RTP payload type numeric identifier.
Definition formats.h:63
RTP packets handling.
Sources of synchronization and participants related clases.