ccRTP 2.1.2
 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-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 
50 NAMESPACE_COMMONCPP
51 
69 {
70 public:
71  AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src);
72 
73  inline ~AppDataUnit()
74  { }
75 
79  AppDataUnit(const AppDataUnit& src);
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 
154 private:
155  Pointer<const IncomingRTPPkt> datablock;
157 };
158 
167 {
168 public:
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 
204 protected:
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 
235 private:
236  // local SSRC 32-bit identifier
237  uint32 localSSRC;
238  // SSRC in network byte order
240  // RTP clock rate for the current payload type.
242  // Current payload type set for outgoing packets and expected
243  // from incoming packets.
245  // when the queue is created
246  timeval initialTime;
247 };
248 
255  public virtual RTPQueueBase
256 {
257 public:
258  inline size_t
260  { return defaultMaxSendSegmentSize;}
261 
268  inline void
270  { maxSendSegmentSize = size; }
271 
272  inline size_t
274  { return maxSendSegmentSize; }
275 
276 protected:
278 
279  inline virtual
281  { }
282 
283 private:
284  static const size_t defaultMaxSendSegmentSize;
285  // maximum packet size before fragmenting sends.
287 };
288 
295  public virtual RTPQueueBase
296 {
297 public:
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 
319 protected:
321  { setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); }
322 
323  inline virtual
325  { }
326 
327 private:
328  static const size_t defaultMaxRecvPacketSize;
329  // filter value for received packets length.
331 };
332  // queuebase
334 
335 END_NAMESPACE
336 
337 #endif //CCXX_RTP_QUEUEBASE_H_
338 
virtual ~OutgoingDataQueueBase()
Definition: queuebase.h:280
uint32 localSSRC
Definition: queuebase.h:237
bool isMarked() const
Is this data unit marked?.
Definition: queuebase.h:128
virtual size_t dispatchBYE(const std::string &)
A plugin point for posting of BYE messages.
Definition: queuebase.h:228
PayloadType getType() const
Definition: queuebase.h:94
Synchronization source in an RTP session.
Definition: sources.h:192
Interface (envelope) to data received over RTP packets.
Definition: queuebase.h:68
uint16 getSeqNum() const
Get data unit sequence number.
Definition: queuebase.h:135
RTP packets received from other participants.
Definition: rtppkt.h:704
Base payload format class.
Definition: formats.h:129
bool setPayloadFormat(const PayloadFormat &pf)
Set the payload format in use, for timing and payload type identification purposes.
Definition: queuebase.h:177
size_t getDefaultMaxSendSegmentSize()
Definition: queuebase.h:259
virtual ~IncomingDataQueueBase()
Definition: queuebase.h:324
virtual void renewLocalSSRC()
Definition: queuebase.h:232
Sources of synchronization and participants related clases.
size_t getMaxRecvPacketSize() const
Definition: queuebase.h:302
PayloadType getCurrentPayloadType() const
Definition: queuebase.h:198
uint32 localSSRCNetwork
Definition: queuebase.h:239
timeval getInitialTime() const
Definition: queuebase.h:201
static const size_t defaultMaxRecvPacketSize
Definition: queuebase.h:328
Pointer< const IncomingRTPPkt > datablock
Definition: queuebase.h:155
PayloadType getPayloadType() const
Get payload type numeric identifier carried in RTP packets.
Definition: formats.h:137
void setLocalSSRC(uint32 ssrc)
Definition: queuebase.h:211
#define __EXPORT
Definition: ZrtpCallback.h:40
void setMaxSendSegmentSize(size_t size)
Set maximum payload segment size before fragmenting sends.
Definition: queuebase.h:269
A virtual base class for RTP queue hierarchies.
Definition: queuebase.h:166
size_t getMaxSendSegmentSize()
Definition: queuebase.h:273
uint32 getLocalSSRCNetwork() const
Definition: queuebase.h:214
const SyncSource * source
Definition: queuebase.h:156
uint32 getRTPClockRate() const
Get RTP clock rate for this payload format.
Definition: formats.h:148
virtual ~RTPQueueBase()
Definition: queuebase.h:218
PayloadType currentPayloadType
Definition: queuebase.h:244
uint32 getLocalSSRC() const
Definition: queuebase.h:184
size_t getDefaultMaxRecvPacketSize() const
Definition: queuebase.h:298
timeval initialTime
Definition: queuebase.h:246
const SyncSource & getSource() const
Definition: queuebase.h:119
size_t getSize() const
Definition: queuebase.h:112
void setMaxRecvPacketSize(size_t maxsize)
Definition: queuebase.h:316
uint8 getContributorsCount() const
Get the number of contributing sources in the CSRC list.
Definition: queuebase.h:142
const uint32 * getContributorsID() const
Get the array of 32-bit CSRC identifiers.
Definition: queuebase.h:151
~AppDataUnit()
Definition: queuebase.h:73
const uint8 *const getData() const
Get data as it is received in RTP packets (i.e.
Definition: queuebase.h:105
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:195
static const size_t defaultMaxSendSegmentSize
Definition: queuebase.h:284
uint32 currentRTPClockRate
Definition: queuebase.h:241
RTP packets handling.
uint8 PayloadType
RTP payload type numeric identifier.
Definition: formats.h:62