ccRTP
queuebase.h
Go to the documentation of this file.
1// Copyright (C) 2001-2015 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 Lesser General Public License
14// along with GNU ccRTP. If not, see <http://www.gnu.org/licenses/>.
15//
16// As a special exception, you may use this file as part of a free software
17// library without restriction. Specifically, if other files instantiate
18// templates or use macros or inline functions from this file, or you compile
19// this file and link it with other files to produce an executable, this
20// file does not by itself cause the resulting executable to be covered by
21// the GNU General Public License. This exception does not however
22// invalidate any other reasons why the executable file might be covered by
23// the GNU General Public License.
24//
25// This exception applies only to the code released under the name GNU
26// ccRTP. If you copy code from other releases into a copy of GNU
27// ccRTP, as the General Public License permits, the exception does
28// not apply to the code that you add in this way. To avoid misleading
29// anyone as to the status of such modified files, you must delete
30// this exception notice from them.
31//
32// If you write modifications of your own for GNU ccRTP, it is your choice
33// whether to permit this exception to apply to your modifications.
34// If you do not wish that, delete this exception notice.
35//
36
43#ifndef CCXX_RTP_QUEUEBASE_H_
44#define CCXX_RTP_QUEUEBASE_H_
45
46#include <commoncpp/pointer.h>
47#include <ccrtp/rtppkt.h>
48#include <ccrtp/sources.h>
49
50NAMESPACE_COMMONCPP
51
68class __EXPORT AppDataUnit
69{
70public:
71 AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src);
72
73 inline ~AppDataUnit()
74 { }
75
80
88 operator=(const AppDataUnit& source);
89
93 inline PayloadType
94 getType() const
95 { return datablock->getPayloadType(); }
96
104 inline const uint8* const
105 getData() const
106 { return datablock->getPayload(); }
107
111 size_t
112 getSize() const
113 { return datablock->getPayloadSize(); }
114
118 inline const SyncSource&
119 getSource() const
120 { return *source; }
121
127 inline bool
128 isMarked() const
129 { return datablock->isMarked(); }
130
134 inline uint16
135 getSeqNum() const
136 { return datablock->getSeqNum(); }
137
141 inline uint8
143 { return (uint8)datablock->getCSRCsCount(); }
144
150 inline const uint32*
152 { return datablock->getCSRCs(); }
153
154private:
155 Pointer<const IncomingRTPPkt> datablock;
156 const SyncSource* source;
157};
158
166class __EXPORT RTPQueueBase
167{
168public:
176 inline bool
178 {
179 currentPayloadType = pf.getPayloadType();
180 currentRTPClockRate = pf.getRTPClockRate();
181 return true;
182 }
183
184 inline uint32 getLocalSSRC() const
185 { return localSSRC; }
186
195 inline uint32 getCurrentRTPClockRate() const
196 { return currentRTPClockRate; }
197
199 { return currentPayloadType; }
200
201 inline timeval getInitialTime() const
202 { return initialTime; }
203
204protected:
209 RTPQueueBase(uint32 *ssrc = NULL);
210
211 inline void setLocalSSRC(uint32 ssrc)
212 { localSSRC = ssrc; localSSRCNetwork = htonl(ssrc); }
213
214 inline uint32 getLocalSSRCNetwork() const
215 { return localSSRCNetwork; }
216
217 virtual
219 { }
220
227 inline virtual size_t
228 dispatchBYE(const std::string&)
229 { return 0; }
230
231 inline virtual void
233 { }
234
235private:
236 // local SSRC 32-bit identifier
237 uint32 localSSRC;
238 // SSRC in network byte order
239 uint32 localSSRCNetwork;
240 // RTP clock rate for the current payload type.
241 uint32 currentRTPClockRate;
242 // Current payload type set for outgoing packets and expected
243 // from incoming packets.
244 PayloadType currentPayloadType;
245 // when the queue is created
246 timeval initialTime;
247};
248
255 public virtual RTPQueueBase
256{
257public:
258 inline size_t
260 { return defaultMaxSendSegmentSize;}
261
268 inline void
270 { maxSendSegmentSize = size; }
271
272 inline size_t
274 { return maxSendSegmentSize; }
275
276protected:
278
279 inline virtual
281 { }
282
283private:
284 static const size_t defaultMaxSendSegmentSize;
285 // maximum packet size before fragmenting sends.
286 size_t maxSendSegmentSize;
287};
288
295 public virtual RTPQueueBase
296{
297public:
298 inline size_t getDefaultMaxRecvPacketSize() const
299 { return defaultMaxRecvPacketSize; }
300
301 inline size_t
303 { return maxRecvPacketSize; }
304
315 inline void
316 setMaxRecvPacketSize(size_t maxsize)
317 { maxRecvPacketSize = maxsize; }
318
319protected:
321 { setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); }
322
323 inline virtual
325 { }
326
327private:
328 static const size_t defaultMaxRecvPacketSize;
329 // filter value for received packets length.
330 size_t maxRecvPacketSize;
331};
332 // queuebase
334
335END_NAMESPACE
336
337#endif //CCXX_RTP_QUEUEBASE_H_
338
Interface (envelope) to data received over RTP packets.
Definition queuebase.h:69
uint8 getContributorsCount() const
Get the number of contributing sources in the CSRC list.
Definition queuebase.h:142
PayloadType getType() const
Definition queuebase.h:94
uint16 getSeqNum() const
Get data unit sequence number.
Definition queuebase.h:135
bool isMarked() const
Is this data unit marked?.
Definition queuebase.h:128
size_t getSize() const
Definition queuebase.h:112
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:105
const SyncSource & getSource() const
Definition queuebase.h:119
~AppDataUnit()
Definition queuebase.h:73
AppDataUnit(const IncomingRTPPkt &packet, const SyncSource &src)
const uint32 * getContributorsID() const
Get the array of 32-bit CSRC identifiers.
Definition queuebase.h:151
Definition queuebase.h:296
size_t getMaxRecvPacketSize() const
Definition queuebase.h:302
void setMaxRecvPacketSize(size_t maxsize)
Definition queuebase.h:316
virtual ~IncomingDataQueueBase()
Definition queuebase.h:324
IncomingDataQueueBase()
Definition queuebase.h:320
size_t getDefaultMaxRecvPacketSize() const
Definition queuebase.h:298
RTP packets received from other participants.
Definition rtppkt.h:705
Definition queuebase.h:256
size_t getMaxSendSegmentSize()
Definition queuebase.h:273
void setMaxSendSegmentSize(size_t size)
Set maximum payload segment size before fragmenting sends.
Definition queuebase.h:269
virtual ~OutgoingDataQueueBase()
Definition queuebase.h:280
size_t getDefaultMaxSendSegmentSize()
Definition queuebase.h:259
Base payload format class.
Definition formats.h:130
PayloadType getPayloadType() const
Get payload type numeric identifier carried in RTP packets.
Definition formats.h:137
uint32 getRTPClockRate() const
Get RTP clock rate for this payload format.
Definition formats.h:148
A virtual base class for RTP queue hierarchies.
Definition queuebase.h:167
uint32 getLocalSSRC() const
Definition queuebase.h:184
RTPQueueBase(uint32 *ssrc=NULL)
PayloadType getCurrentPayloadType() const
Definition queuebase.h:198
bool setPayloadFormat(const PayloadFormat &pf)
Set the payload format in use, for timing and payload type identification purposes.
Definition queuebase.h:177
uint32 getLocalSSRCNetwork() const
Definition queuebase.h:214
timeval getInitialTime() const
Definition queuebase.h:201
void setLocalSSRC(uint32 ssrc)
Definition queuebase.h:211
uint32 getCurrentRTPClockRate() const
Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU,...
Definition queuebase.h:195
virtual void renewLocalSSRC()
Definition queuebase.h:232
virtual size_t dispatchBYE(const std::string &)
A plugin point for posting of BYE messages.
Definition queuebase.h:228
virtual ~RTPQueueBase()
Definition queuebase.h:218
Synchronization source in an RTP session.
Definition sources.h:193
uint8 PayloadType
RTP payload type numeric identifier.
Definition formats.h:62
RTP packets handling.
Sources of synchronization and participants related clases.