1 /*
2 
3   This file is a part of JRTPLIB
4   Copyright (c) 1999-2017 Jori Liesenborgs
5 
6   Contact: jori.liesenborgs@gmail.com
7 
8   This library was developed at the Expertise Centre for Digital Media
9   (http://www.edm.uhasselt.be), a research center of the Hasselt University
10   (http://www.uhasselt.be). The library is based upon work done for
11   my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
12 
13   Permission is hereby granted, free of charge, to any person obtaining a
14   copy of this software and associated documentation files (the "Software"),
15   to deal in the Software without restriction, including without limitation
16   the rights to use, copy, modify, merge, publish, distribute, sublicense,
17   and/or sell copies of the Software, and to permit persons to whom the
18   Software is furnished to do so, subject to the following conditions:
19 
20   The above copyright notice and this permission notice shall be included
21   in all copies or substantial portions of the Software.
22 
23   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
26   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29   IN THE SOFTWARE.
30 
31 */
32 
33 /**
34  * \file rtpsourcedata.h
35  */
36 
37 #ifndef RTPSOURCEDATA_H
38 
39 #define RTPSOURCEDATA_H
40 
41 #include "rtpconfig.h"
42 #include "rtptimeutilities.h"
43 #include "rtppacket.h"
44 #include "rtcpsdesinfo.h"
45 #include "rtptypes.h"
46 #include "rtpsources.h"
47 #include "rtpmemoryobject.h"
48 #include <list>
49 
50 namespace jrtplib
51 {
52 
53 class RTPAddress;
54 
55 class JRTPLIB_IMPORTEXPORT RTCPSenderReportInfo
56 {
57 public:
RTCPSenderReportInfo()58 	RTCPSenderReportInfo():ntptimestamp(0,0),receivetime(0,0)		{ hasinfo = false; rtptimestamp = 0; packetcount = 0; bytecount = 0; }
Set(const RTPNTPTime & ntptime,uint32_t rtptime,uint32_t pcount,uint32_t bcount,const RTPTime & rcvtime)59 	void Set(const RTPNTPTime &ntptime,uint32_t rtptime,uint32_t pcount,
60 	         uint32_t bcount,const RTPTime &rcvtime)			{ ntptimestamp = ntptime; rtptimestamp = rtptime; packetcount = pcount; bytecount = bcount; receivetime = rcvtime; hasinfo = true; }
61 
HasInfo()62 	bool HasInfo() const							{ return hasinfo; }
GetNTPTimestamp()63 	RTPNTPTime GetNTPTimestamp() const					{ return ntptimestamp; }
GetRTPTimestamp()64 	uint32_t GetRTPTimestamp() const					{ return rtptimestamp; }
GetPacketCount()65 	uint32_t GetPacketCount() const						{ return packetcount; }
GetByteCount()66 	uint32_t GetByteCount() const						{ return bytecount; }
GetReceiveTime()67 	RTPTime GetReceiveTime() const						{ return receivetime; }
68 private:
69 	bool hasinfo;
70 	RTPNTPTime ntptimestamp;
71 	uint32_t rtptimestamp;
72 	uint32_t packetcount;
73 	uint32_t bytecount;
74 	RTPTime receivetime;
75 };
76 
77 class JRTPLIB_IMPORTEXPORT RTCPReceiverReportInfo
78 {
79 public:
RTCPReceiverReportInfo()80 	RTCPReceiverReportInfo():receivetime(0,0)				{ hasinfo = false; fractionlost = 0; packetslost = 0; exthighseqnr = 0; jitter = 0; lsr = 0; dlsr = 0; }
Set(uint8_t fraclost,int32_t plost,uint32_t exthigh,uint32_t jit,uint32_t l,uint32_t dl,const RTPTime & rcvtime)81 	void Set(uint8_t fraclost,int32_t plost,uint32_t exthigh,
82 	         uint32_t jit,uint32_t l,uint32_t dl,const RTPTime &rcvtime) 	{ fractionlost = ((double)fraclost)/256.0; packetslost = plost; exthighseqnr = exthigh; jitter = jit; lsr = l; dlsr = dl; receivetime = rcvtime; hasinfo = true; }
83 
HasInfo()84 	bool HasInfo() const							{ return hasinfo; }
GetFractionLost()85 	double GetFractionLost() const						{ return fractionlost; }
GetPacketsLost()86 	int32_t	GetPacketsLost() const						{ return packetslost; }
GetExtendedHighestSequenceNumber()87 	uint32_t GetExtendedHighestSequenceNumber() const			{ return exthighseqnr; }
GetJitter()88 	uint32_t GetJitter() const						{ return jitter; }
GetLastSRTimestamp()89 	uint32_t GetLastSRTimestamp() const					{ return lsr; }
GetDelaySinceLastSR()90 	uint32_t GetDelaySinceLastSR() const					{ return dlsr; }
GetReceiveTime()91 	RTPTime GetReceiveTime() const						{ return receivetime; }
92 private:
93 	bool hasinfo;
94 	double fractionlost;
95 	int32_t packetslost;
96 	uint32_t exthighseqnr;
97 	uint32_t jitter;
98 	uint32_t lsr;
99 	uint32_t dlsr;
100 	RTPTime receivetime;
101 };
102 
103 class JRTPLIB_IMPORTEXPORT RTPSourceStats
104 {
105 public:
106 	RTPSourceStats();
107 	void ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,double tsunit,bool ownpacket,bool *accept,bool applyprobation,bool *onprobation);
108 
HasSentData()109 	bool HasSentData() const						{ return sentdata; }
GetNumPacketsReceived()110 	uint32_t GetNumPacketsReceived() const					{ return packetsreceived; }
GetBaseSequenceNumber()111 	uint32_t GetBaseSequenceNumber() const					{ return baseseqnr; }
GetExtendedHighestSequenceNumber()112 	uint32_t GetExtendedHighestSequenceNumber() const			{ return exthighseqnr; }
GetJitter()113 	uint32_t GetJitter() const						{ return jitter; }
114 
GetNumPacketsReceivedInInterval()115 	int32_t GetNumPacketsReceivedInInterval() const				{ return numnewpackets; }
GetSavedExtendedSequenceNumber()116 	uint32_t GetSavedExtendedSequenceNumber() const			{ return savedextseqnr; }
StartNewInterval()117 	void StartNewInterval()							{ numnewpackets = 0; savedextseqnr = exthighseqnr; }
118 
SetLastMessageTime(const RTPTime & t)119 	void SetLastMessageTime(const RTPTime &t)				{ lastmsgtime = t; }
GetLastMessageTime()120 	RTPTime GetLastMessageTime() const					{ return lastmsgtime; }
SetLastRTPPacketTime(const RTPTime & t)121 	void SetLastRTPPacketTime(const RTPTime &t)				{ lastrtptime = t; }
GetLastRTPPacketTime()122 	RTPTime GetLastRTPPacketTime() const					{ return lastrtptime; }
123 
SetLastNoteTime(const RTPTime & t)124 	void SetLastNoteTime(const RTPTime &t)					{ lastnotetime = t; }
GetLastNoteTime()125 	RTPTime GetLastNoteTime() const						{ return lastnotetime; }
126 private:
127 	bool sentdata;
128 	uint32_t packetsreceived;
129 	uint32_t numcycles; // shifted left 16 bits
130 	uint32_t baseseqnr;
131 	uint32_t exthighseqnr,prevexthighseqnr;
132 	uint32_t jitter,prevtimestamp;
133 	double djitter;
134 	RTPTime prevpacktime;
135 	RTPTime lastmsgtime;
136 	RTPTime lastrtptime;
137 	RTPTime lastnotetime;
138 	uint32_t numnewpackets;
139 	uint32_t savedextseqnr;
140 #ifdef RTP_SUPPORT_PROBATION
141 	uint16_t prevseqnr;
142 	int probation;
143 #endif // RTP_SUPPORT_PROBATION
144 };
145 
RTPSourceStats()146 inline RTPSourceStats::RTPSourceStats():prevpacktime(0,0),lastmsgtime(0,0),lastrtptime(0,0),lastnotetime(0,0)
147 {
148 	sentdata = false;
149 	packetsreceived = 0;
150 	baseseqnr = 0;
151 	exthighseqnr = 0;
152 	prevexthighseqnr = 0;
153 	jitter = 0;
154 	numcycles = 0;
155 	numnewpackets = 0;
156 	prevtimestamp = 0;
157 	djitter = 0;
158 	savedextseqnr = 0;
159 #ifdef RTP_SUPPORT_PROBATION
160 	probation = 0;
161 	prevseqnr = 0;
162 #endif // RTP_SUPPORT_PROBATION
163 }
164 
165 /** Describes an entry in the RTPSources source table. */
166 class JRTPLIB_IMPORTEXPORT RTPSourceData : public RTPMemoryObject
167 {
168 	JRTPLIB_NO_COPY(RTPSourceData)
169 protected:
170 	RTPSourceData(uint32_t ssrc, RTPMemoryManager *mgr = 0);
171 	virtual ~RTPSourceData();
172 public:
173 	/** Extracts the first packet of this participants RTP packet queue. */
174 	RTPPacket *GetNextPacket();
175 
176 	/** Clears the participant's RTP packet list. */
177 	void FlushPackets();
178 
179 	/** Returns \c true if there are RTP packets which can be extracted. */
HasData()180 	bool HasData() const							{ if (!validated) return false; return packetlist.empty()?false:true; }
181 
182 	/** Returns the SSRC identifier for this member. */
GetSSRC()183 	uint32_t GetSSRC() const						{ return ssrc; }
184 
185 	/** Returns \c true if the participant was added using the RTPSources member function CreateOwnSSRC and
186 	 *  returns \c false otherwise.
187 	 */
IsOwnSSRC()188 	bool IsOwnSSRC() const							{ return ownssrc; }
189 
190 	/** Returns \c true if the source identifier is actually a CSRC from an RTP packet. */
IsCSRC()191 	bool IsCSRC() const							{ return iscsrc; }
192 
193 	/** Returns \c true if this member is marked as a sender and \c false if not. */
IsSender()194 	bool IsSender() const							{ return issender; }
195 
196 	/** Returns \c true if the participant is validated, which is the case if a number of
197 	 *  consecutive RTP packets have been received or if a CNAME item has been received for
198 	 *  this participant.
199 	 */
IsValidated()200 	bool IsValidated() const						{ return validated; }
201 
202 	/** Returns \c true if the source was validated and had not yet sent a BYE packet. */
IsActive()203 	bool IsActive() const							{ if (!validated) return false; if (receivedbye) return false; return true; }
204 
205 	/** This function is used by the RTCPPacketBuilder class to mark whether this participant's
206 	 *  information has been processed in a report block or not.
207 	 */
SetProcessedInRTCP(bool v)208 	void SetProcessedInRTCP(bool v)						{ processedinrtcp = v; }
209 
210 	/** This function is used by the RTCPPacketBuilder class and returns whether this participant
211 	 *  has been processed in a report block or not.
212 	 */
IsProcessedInRTCP()213 	bool IsProcessedInRTCP() const						{ return processedinrtcp; }
214 
215 	/** Returns \c true if the address from which this participant's RTP packets originate has
216 	 *  already been set.
217 	 */
IsRTPAddressSet()218 	bool IsRTPAddressSet() const						{ return isrtpaddrset; }
219 
220 	/** Returns \c true if the address from which this participant's RTCP packets originate has
221 	 * already been set.
222 	 */
IsRTCPAddressSet()223 	bool IsRTCPAddressSet() const						{ return isrtcpaddrset; }
224 
225 	/** Returns the address from which this participant's RTP packets originate.
226 	 *  Returns the address from which this participant's RTP packets originate. If the address has
227 	 *  been set and the returned value is NULL, this indicates that it originated from the local
228 	 *  participant.
229 	 */
GetRTPDataAddress()230 	const RTPAddress *GetRTPDataAddress() const				{ return rtpaddr; }
231 
232 	/** Returns the address from which this participant's RTCP packets originate.
233 	 *  Returns the address from which this participant's RTCP packets originate. If the address has
234 	 *  been set and the returned value is NULL, this indicates that it originated from the local
235 	 *  participant.
236 	 */
GetRTCPDataAddress()237 	const RTPAddress *GetRTCPDataAddress() const				{ return rtcpaddr; }
238 
239 	/** Returns \c true if we received a BYE message for this participant and \c false otherwise. */
ReceivedBYE()240 	bool ReceivedBYE() const						{ return receivedbye; }
241 
242 	/** Returns the reason for leaving contained in the BYE packet of this participant.
243 	 *  Returns the reason for leaving contained in the BYE packet of this participant. The length of
244 	 *  the reason is stored in \c len.
245 	 */
GetBYEReason(size_t * len)246 	uint8_t *GetBYEReason(size_t *len) const				{ *len = byereasonlen; return byereason; }
247 
248 	/** Returns the time at which the BYE packet was received. */
GetBYETime()249 	RTPTime GetBYETime() const						{ return byetime; }
250 
251 	/** Sets the value for the timestamp unit to be used in jitter calculations for data received from this participant.
252 	 *  Sets the value for the timestamp unit to be used in jitter calculations for data received from this participant.
253 	 *  If not set, the library uses an approximation for the timestamp unit which is calculated from two consecutive
254 	 *  RTCP sender reports. The timestamp unit is defined as a time interval divided by the corresponding timestamp
255 	 *  interval. For 8000 Hz audio this would be 1/8000. For video, often a timestamp unit of 1/90000 is used.
256 	 */
SetTimestampUnit(double tsu)257 	void SetTimestampUnit(double tsu)					{ timestampunit = tsu; }
258 
259 	/** Returns the timestamp unit used for this participant. */
GetTimestampUnit()260 	double GetTimestampUnit() const						{ return timestampunit; }
261 
262 	/** Returns \c true if an RTCP sender report has been received from this participant. */
SR_HasInfo()263 	bool SR_HasInfo() const								{ return SRinf.HasInfo(); }
264 
265 	/** Returns the NTP timestamp contained in the last sender report. */
SR_GetNTPTimestamp()266 	RTPNTPTime SR_GetNTPTimestamp() const				{ return SRinf.GetNTPTimestamp(); }
267 
268 	/** Returns the RTP timestamp contained in the last sender report. */
SR_GetRTPTimestamp()269 	uint32_t SR_GetRTPTimestamp() const					{ return SRinf.GetRTPTimestamp(); }
270 
271 	/** Returns the packet count contained in the last sender report. */
SR_GetPacketCount()272 	uint32_t SR_GetPacketCount() const					{ return SRinf.GetPacketCount(); }
273 
274 	/** Returns the octet count contained in the last sender report. */
SR_GetByteCount()275 	uint32_t SR_GetByteCount() const					{ return SRinf.GetByteCount(); }
276 
277 	/** Returns the time at which the last sender report was received. */
SR_GetReceiveTime()278 	RTPTime SR_GetReceiveTime() const					{ return SRinf.GetReceiveTime(); }
279 
280 	/** Returns \c true if more than one RTCP sender report has been received. */
SR_Prev_HasInfo()281 	bool SR_Prev_HasInfo() const						{ return SRprevinf.HasInfo(); }
282 
283 	/** Returns the NTP timestamp contained in the second to last sender report. */
SR_Prev_GetNTPTimestamp()284 	RTPNTPTime SR_Prev_GetNTPTimestamp() const				{ return SRprevinf.GetNTPTimestamp(); }
285 
286 	/** Returns the RTP timestamp contained in the second to last sender report. */
SR_Prev_GetRTPTimestamp()287 	uint32_t SR_Prev_GetRTPTimestamp() const				{ return SRprevinf.GetRTPTimestamp(); }
288 
289 	/** Returns the packet count contained in the second to last sender report. */
SR_Prev_GetPacketCount()290 	uint32_t SR_Prev_GetPacketCount() const				{ return SRprevinf.GetPacketCount(); }
291 
292 	/**  Returns the octet count contained in the second to last sender report. */
SR_Prev_GetByteCount()293 	uint32_t SR_Prev_GetByteCount() const					{ return SRprevinf.GetByteCount(); }
294 
295 	/** Returns the time at which the second to last sender report was received. */
SR_Prev_GetReceiveTime()296 	RTPTime SR_Prev_GetReceiveTime() const					{ return SRprevinf.GetReceiveTime(); }
297 
298 	/** Returns \c true if this participant sent a receiver report with information about the reception of our data. */
RR_HasInfo()299 	bool RR_HasInfo() const							{ return RRinf.HasInfo(); }
300 
301 	/** Returns the fraction lost value from the last report. */
RR_GetFractionLost()302 	double RR_GetFractionLost() const					{ return RRinf.GetFractionLost(); }
303 
304 	/** Returns the number of lost packets contained in the last report. */
RR_GetPacketsLost()305 	int32_t	RR_GetPacketsLost() const					{ return RRinf.GetPacketsLost(); }
306 
307 	/** Returns the extended highest sequence number contained in the last report. */
RR_GetExtendedHighestSequenceNumber()308 	uint32_t RR_GetExtendedHighestSequenceNumber() const			{ return RRinf.GetExtendedHighestSequenceNumber(); }
309 
310 	/** Returns the jitter value from the last report. */
RR_GetJitter()311 	uint32_t RR_GetJitter() const						{ return RRinf.GetJitter(); }
312 
313 	/** Returns the LSR value from the last report. */
RR_GetLastSRTimestamp()314 	uint32_t RR_GetLastSRTimestamp() const					{ return RRinf.GetLastSRTimestamp(); }
315 
316 	/** Returns the DLSR value from the last report. */
RR_GetDelaySinceLastSR()317 	uint32_t RR_GetDelaySinceLastSR() const				{ return RRinf.GetDelaySinceLastSR(); }
318 
319 	/** Returns the time at which the last report was received. */
RR_GetReceiveTime()320 	RTPTime RR_GetReceiveTime() const					{ return RRinf.GetReceiveTime(); }
321 
322 	/** Returns \c true if this participant sent more than one receiver report with information
323 	 *  about the reception of our data.
324 	 */
RR_Prev_HasInfo()325 	bool RR_Prev_HasInfo() const						{ return RRprevinf.HasInfo(); }
326 
327 	/** Returns the fraction lost value from the second to last report. */
RR_Prev_GetFractionLost()328 	double RR_Prev_GetFractionLost() const					{ return RRprevinf.GetFractionLost(); }
329 
330 	/** Returns the number of lost packets contained in the second to last report. */
RR_Prev_GetPacketsLost()331 	int32_t	RR_Prev_GetPacketsLost() const					{ return RRprevinf.GetPacketsLost(); }
332 
333 	/** Returns the extended highest sequence number contained in the second to last report. */
RR_Prev_GetExtendedHighestSequenceNumber()334 	uint32_t RR_Prev_GetExtendedHighestSequenceNumber() const		{ return RRprevinf.GetExtendedHighestSequenceNumber(); }
335 
336 	/** Returns the jitter value from the second to last report. */
RR_Prev_GetJitter()337 	uint32_t RR_Prev_GetJitter() const					{ return RRprevinf.GetJitter(); }
338 
339 	/** Returns the LSR value from the second to last report. */
RR_Prev_GetLastSRTimestamp()340 	uint32_t RR_Prev_GetLastSRTimestamp() const				{ return RRprevinf.GetLastSRTimestamp(); }
341 
342 	/** Returns the DLSR value from the second to last report. */
RR_Prev_GetDelaySinceLastSR()343 	uint32_t RR_Prev_GetDelaySinceLastSR() const				{ return RRprevinf.GetDelaySinceLastSR(); }
344 
345 	/** Returns the time at which the second to last report was received. */
RR_Prev_GetReceiveTime()346 	RTPTime RR_Prev_GetReceiveTime() const					{ return RRprevinf.GetReceiveTime(); }
347 
348 	/** Returns \c true if validated RTP packets have been received from this participant. */
INF_HasSentData()349 	bool INF_HasSentData() const						{ return stats.HasSentData(); }
350 
351 	/** Returns the total number of received packets from this participant. */
INF_GetNumPacketsReceived()352 	int32_t INF_GetNumPacketsReceived() const				{ return stats.GetNumPacketsReceived(); }
353 
354 	/** Returns the base sequence number of this participant. */
INF_GetBaseSequenceNumber()355 	uint32_t INF_GetBaseSequenceNumber() const				{ return stats.GetBaseSequenceNumber(); }
356 
357 	/** Returns the extended highest sequence number received from this participant. */
INF_GetExtendedHighestSequenceNumber()358 	uint32_t INF_GetExtendedHighestSequenceNumber() const			{ return stats.GetExtendedHighestSequenceNumber(); }
359 
360 	/** Returns the current jitter value for this participant. */
INF_GetJitter()361 	uint32_t INF_GetJitter() const						{ return stats.GetJitter(); }
362 
363 	/** Returns the time at which something was last heard from this member. */
INF_GetLastMessageTime()364 	RTPTime INF_GetLastMessageTime() const					{ return stats.GetLastMessageTime(); }
365 
366 	/** Returns the time at which the last RTP packet was received. */
INF_GetLastRTPPacketTime()367 	RTPTime INF_GetLastRTPPacketTime() const				{ return stats.GetLastRTPPacketTime(); }
368 
369 	/** Returns the estimated timestamp unit, calculated from two consecutive sender reports. */
370 	double INF_GetEstimatedTimestampUnit() const;
371 
372 	/** Returns the number of packets received since a new interval was started with INF_StartNewInterval. */
INF_GetNumPacketsReceivedInInterval()373 	uint32_t INF_GetNumPacketsReceivedInInterval() const			{ return stats.GetNumPacketsReceivedInInterval(); }
374 
375 	/** Returns the extended sequence number which was stored by the INF_StartNewInterval call. */
INF_GetSavedExtendedSequenceNumber()376 	uint32_t INF_GetSavedExtendedSequenceNumber() const			{ return stats.GetSavedExtendedSequenceNumber(); }
377 
378 	/** Starts a new interval to count received packets in; this also stores the current extended highest sequence
379 	 *  number to be able to calculate the packet loss during the interval.
380 	 */
INF_StartNewInterval()381 	void INF_StartNewInterval()						{ stats.StartNewInterval(); }
382 
383 	/** Estimates the round trip time by using the LSR and DLSR info from the last receiver report. */
384 	RTPTime INF_GetRoundtripTime() const;
385 
386 	/** Returns the time at which the last SDES NOTE item was received. */
INF_GetLastSDESNoteTime()387 	RTPTime INF_GetLastSDESNoteTime() const					{ return stats.GetLastNoteTime(); }
388 
389 	/** Returns a pointer to the SDES CNAME item of this participant and stores its length in \c len. */
SDES_GetCNAME(size_t * len)390 	uint8_t *SDES_GetCNAME(size_t *len) const				{ return SDESinf.GetCNAME(len); }
391 
392 	/** Returns a pointer to the SDES name item of this participant and stores its length in \c len. */
SDES_GetName(size_t * len)393 	uint8_t *SDES_GetName(size_t *len) const				{ return SDESinf.GetName(len); }
394 
395 	/** Returns a pointer to the SDES e-mail item of this participant and stores its length in \c len. */
SDES_GetEMail(size_t * len)396 	uint8_t *SDES_GetEMail(size_t *len) const				{ return SDESinf.GetEMail(len); }
397 
398 	/** Returns a pointer to the SDES phone item of this participant and stores its length in \c len. */
SDES_GetPhone(size_t * len)399 	uint8_t *SDES_GetPhone(size_t *len) const				{ return SDESinf.GetPhone(len); }
400 
401 	/** Returns a pointer to the SDES location item of this participant and stores its length in \c len. */
SDES_GetLocation(size_t * len)402 	uint8_t *SDES_GetLocation(size_t *len) const			{ return SDESinf.GetLocation(len); }
403 
404 	/** Returns a pointer to the SDES tool item of this participant and stores its length in \c len. */
SDES_GetTool(size_t * len)405 	uint8_t *SDES_GetTool(size_t *len) const				{ return SDESinf.GetTool(len); }
406 
407 	/** Returns a pointer to the SDES note item of this participant and stores its length in \c len. */
SDES_GetNote(size_t * len)408 	uint8_t *SDES_GetNote(size_t *len) const				{ return SDESinf.GetNote(len); }
409 
410 #ifdef RTP_SUPPORT_SDESPRIV
411 	/** Starts the iteration over the stored SDES private item prefixes and their associated values. */
SDES_GotoFirstPrivateValue()412 	void SDES_GotoFirstPrivateValue()										{ SDESinf.GotoFirstPrivateValue(); }
413 
414 	/** If available, returns \c true and stores the next SDES private item prefix in \c prefix and its length in
415 	 *  \c prefixlen; the associated value and its length are then stored in \c value and \c valuelen.
416 	 */
SDES_GetNextPrivateValue(uint8_t ** prefix,size_t * prefixlen,uint8_t ** value,size_t * valuelen)417 	bool SDES_GetNextPrivateValue(uint8_t **prefix,size_t *prefixlen,uint8_t **value,size_t *valuelen) 		{ return SDESinf.GetNextPrivateValue(prefix,prefixlen,value,valuelen); }
418 
419 	/**	Looks for the entry which corresponds to the SDES private item prefix \c prefix with length
420 	 *  \c prefixlen; if found, the function returns \c true and stores the associated value and
421 	 *  its length in \c value and \c valuelen respectively.
422 	 */
SDES_GetPrivateValue(uint8_t * prefix,size_t prefixlen,uint8_t ** value,size_t * valuelen)423 	bool SDES_GetPrivateValue(uint8_t *prefix,size_t prefixlen,uint8_t **value,size_t *valuelen) const 		{ return SDESinf.GetPrivateValue(prefix,prefixlen,value,valuelen); }
424 #endif // RTP_SUPPORT_SDESPRIV
425 
426 #ifdef RTPDEBUG
427 	virtual void Dump();
428 #endif // RTPDEBUG
429 protected:
430 	std::list<RTPPacket *> packetlist;
431 
432 	uint32_t ssrc;
433 	bool ownssrc;
434 	bool iscsrc;
435 	double timestampunit;
436 	bool receivedbye;
437 	bool validated;
438 	bool processedinrtcp;
439 	bool issender;
440 
441 	RTCPSenderReportInfo SRinf,SRprevinf;
442 	RTCPReceiverReportInfo RRinf,RRprevinf;
443 	RTPSourceStats stats;
444 	RTCPSDESInfo SDESinf;
445 
446 	bool isrtpaddrset,isrtcpaddrset;
447 	RTPAddress *rtpaddr,*rtcpaddr;
448 
449 	RTPTime byetime;
450 	uint8_t *byereason;
451 	size_t byereasonlen;
452 };
453 
GetNextPacket()454 inline RTPPacket *RTPSourceData::GetNextPacket()
455 {
456 	if (!validated)
457 		return 0;
458 
459 	RTPPacket *p;
460 
461 	if (packetlist.empty())
462 		return 0;
463 	p = *(packetlist.begin());
464 	packetlist.pop_front();
465 	return p;
466 }
467 
FlushPackets()468 inline void RTPSourceData::FlushPackets()
469 {
470 	std::list<RTPPacket *>::const_iterator it;
471 
472 	for (it = packetlist.begin() ; it != packetlist.end() ; ++it)
473 		RTPDelete(*it,GetMemoryManager());
474 	packetlist.clear();
475 }
476 
477 } // end namespace
478 
479 #endif // RTPSOURCEDATA_H
480 
481