SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Private Attributes | List of all members
qrtplib::RTPSourceStats Class Reference

#include <rtpsourcedata.h>

+ Collaboration diagram for qrtplib::RTPSourceStats:

Public Member Functions

 RTPSourceStats ()
 
void ProcessPacket (RTPPacket *pack, const RTPTime &receivetime, double tsunit, bool ownpacket, bool *accept)
 
bool HasSentData () const
 
uint32_t GetNumPacketsReceived () const
 
uint32_t GetBaseSequenceNumber () const
 
uint32_t GetExtendedHighestSequenceNumber () const
 
uint32_t GetJitter () const
 
int32_t GetNumPacketsReceivedInInterval () const
 
uint32_t GetSavedExtendedSequenceNumber () const
 
void StartNewInterval ()
 
void SetLastMessageTime (const RTPTime &t)
 
RTPTime GetLastMessageTime () const
 
void SetLastRTPPacketTime (const RTPTime &t)
 
RTPTime GetLastRTPPacketTime () const
 
void SetLastNoteTime (const RTPTime &t)
 
RTPTime GetLastNoteTime () const
 

Private Attributes

bool sentdata
 
uint32_t packetsreceived
 
uint32_t numcycles
 
uint32_t baseseqnr
 
uint32_t exthighseqnr
 
uint32_t prevexthighseqnr
 
uint32_t jitter
 
uint32_t prevtimestamp
 
double djitter
 
RTPTime prevpacktime
 
RTPTime lastmsgtime
 
RTPTime lastrtptime
 
RTPTime lastnotetime
 
uint32_t numnewpackets
 
uint32_t savedextseqnr
 

Detailed Description

Definition at line 179 of file rtpsourcedata.h.

Constructor & Destructor Documentation

◆ RTPSourceStats()

qrtplib::RTPSourceStats::RTPSourceStats ( )
inline

Definition at line 266 of file rtpsourcedata.h.

References baseseqnr, djitter, exthighseqnr, jitter, numcycles, numnewpackets, packetsreceived, prevexthighseqnr, prevtimestamp, savedextseqnr, and sentdata.

266  :
267  prevpacktime(0, 0), lastmsgtime(0, 0), lastrtptime(0, 0), lastnotetime(0, 0)
268 {
269  sentdata = false;
270  packetsreceived = 0;
271  baseseqnr = 0;
272  exthighseqnr = 0;
273  prevexthighseqnr = 0;
274  jitter = 0;
275  numcycles = 0;
276  numnewpackets = 0;
277  prevtimestamp = 0;
278  djitter = 0;
279  savedextseqnr = 0;
280 }

Member Function Documentation

◆ GetBaseSequenceNumber()

uint32_t qrtplib::RTPSourceStats::GetBaseSequenceNumber ( ) const
inline

Definition at line 198 of file rtpsourcedata.h.

199  {
200  return baseseqnr;
201  }

◆ GetExtendedHighestSequenceNumber()

uint32_t qrtplib::RTPSourceStats::GetExtendedHighestSequenceNumber ( ) const
inline

Definition at line 202 of file rtpsourcedata.h.

203  {
204  return exthighseqnr;
205  }

◆ GetJitter()

uint32_t qrtplib::RTPSourceStats::GetJitter ( ) const
inline

Definition at line 206 of file rtpsourcedata.h.

207  {
208  return jitter;
209  }

◆ GetLastMessageTime()

RTPTime qrtplib::RTPSourceStats::GetLastMessageTime ( ) const
inline

Definition at line 229 of file rtpsourcedata.h.

230  {
231  return lastmsgtime;
232  }

◆ GetLastNoteTime()

RTPTime qrtplib::RTPSourceStats::GetLastNoteTime ( ) const
inline

Definition at line 246 of file rtpsourcedata.h.

247  {
248  return lastnotetime;
249  }

◆ GetLastRTPPacketTime()

RTPTime qrtplib::RTPSourceStats::GetLastRTPPacketTime ( ) const
inline

Definition at line 237 of file rtpsourcedata.h.

238  {
239  return lastrtptime;
240  }

◆ GetNumPacketsReceived()

uint32_t qrtplib::RTPSourceStats::GetNumPacketsReceived ( ) const
inline

Definition at line 194 of file rtpsourcedata.h.

195  {
196  return packetsreceived;
197  }

◆ GetNumPacketsReceivedInInterval()

int32_t qrtplib::RTPSourceStats::GetNumPacketsReceivedInInterval ( ) const
inline

Definition at line 211 of file rtpsourcedata.h.

212  {
213  return numnewpackets;
214  }

◆ GetSavedExtendedSequenceNumber()

uint32_t qrtplib::RTPSourceStats::GetSavedExtendedSequenceNumber ( ) const
inline

Definition at line 215 of file rtpsourcedata.h.

216  {
217  return savedextseqnr;
218  }

◆ HasSentData()

bool qrtplib::RTPSourceStats::HasSentData ( ) const
inline

Definition at line 190 of file rtpsourcedata.h.

191  {
192  return sentdata;
193  }

◆ ProcessPacket()

void qrtplib::RTPSourceStats::ProcessPacket ( RTPPacket pack,
const RTPTime receivetime,
double  tsunit,
bool  ownpacket,
bool *  accept 
)

Definition at line 67 of file rtpsourcedata.cpp.

References ACCEPTPACKETCODE, djitter, exthighseqnr, qrtplib::RTPTime::GetDouble(), qrtplib::RTPPacket::GetExtendedSequenceNumber(), qrtplib::RTPPacket::GetTimestamp(), jitter, lastmsgtime, lastrtptime, numcycles, numnewpackets, packetsreceived, prevpacktime, prevtimestamp, sentdata, and qrtplib::RTPPacket::SetExtendedSequenceNumber().

Referenced by qrtplib::RTPInternalSourceData::ProcessRTPPacket().

73 {
74  // Note that the sequence number in the RTP packet is still just the
75  // 16 bit number contained in the RTP header
76 
77  if (!sentdata) // no valid packets received yet
78  {
80  }
81  else // already got packets
82  {
83  uint16_t maxseq16;
84  uint32_t extseqnr;
85 
86  // Adjust max extended sequence number and set extende seq nr of packet
87 
88  *accept = true;
90  numnewpackets++;
91 
92  maxseq16 = (uint16_t) (exthighseqnr & 0x0000FFFF);
93  if (pack->GetExtendedSequenceNumber() >= maxseq16)
94  {
95  extseqnr = numcycles + pack->GetExtendedSequenceNumber();
96  exthighseqnr = extseqnr;
97  }
98  else
99  {
100  uint16_t dif1, dif2;
101 
102  dif1 = ((uint16_t) pack->GetExtendedSequenceNumber());
103  dif1 -= maxseq16;
104  dif2 = maxseq16;
105  dif2 -= ((uint16_t) pack->GetExtendedSequenceNumber());
106  if (dif1 < dif2)
107  {
108  numcycles += 0x00010000;
109  extseqnr = numcycles + pack->GetExtendedSequenceNumber();
110  exthighseqnr = extseqnr;
111  }
112  else
113  extseqnr = numcycles + pack->GetExtendedSequenceNumber();
114  }
115 
116  pack->SetExtendedSequenceNumber(extseqnr);
117 
118  // Calculate jitter
119 
120  if (tsunit > 0)
121  {
122 #if 0
123  RTPTime curtime = receivetime;
124  double diffts1,diffts2,diff;
125 
126  curtime -= prevpacktime;
127  diffts1 = curtime.GetDouble()/tsunit;
128  diffts2 = (double)pack->GetTimestamp() - (double)prevtimestamp;
129  diff = diffts1 - diffts2;
130  if (diff < 0)
131  diff = -diff;
132  diff -= djitter;
133  diff /= 16.0;
134  djitter += diff;
136 #else
137  RTPTime curtime = receivetime;
138  double diffts1, diffts2, diff;
139  uint32_t curts = pack->GetTimestamp();
140 
141  curtime -= prevpacktime;
142  diffts1 = curtime.GetDouble() / tsunit;
143 
144  if (curts > prevtimestamp)
145  {
146  uint32_t unsigneddiff = curts - prevtimestamp;
147 
148  if (unsigneddiff < 0x10000000) // okay, curts realy is larger than prevtimestamp
149  diffts2 = (double) unsigneddiff;
150  else
151  {
152  // wraparound occurred and curts is actually smaller than prevtimestamp
153 
154  unsigneddiff = -unsigneddiff; // to get the actual difference (in absolute value)
155  diffts2 = -((double) unsigneddiff);
156  }
157  }
158  else if (curts < prevtimestamp)
159  {
160  uint32_t unsigneddiff = prevtimestamp - curts;
161 
162  if (unsigneddiff < 0x10000000) // okay, curts really is smaller than prevtimestamp
163  diffts2 = -((double) unsigneddiff); // negative since we actually need curts-prevtimestamp
164  else
165  {
166  // wraparound occurred and curts is actually larger than prevtimestamp
167 
168  unsigneddiff = -unsigneddiff; // to get the actual difference (in absolute value)
169  diffts2 = (double) unsigneddiff;
170  }
171  }
172  else
173  diffts2 = 0;
174 
175  diff = diffts1 - diffts2;
176  if (diff < 0)
177  diff = -diff;
178  diff -= djitter;
179  diff /= 16.0;
180  djitter += diff;
181  jitter = (uint32_t) djitter;
182 #endif
183  }
184  else
185  {
186  djitter = 0;
187  jitter = 0;
188  }
189 
190  prevpacktime = receivetime;
191  prevtimestamp = pack->GetTimestamp();
193  if (!ownpacket) // for own packet, this value is set on an outgoing packet
195  }
196 }
double GetDouble() const
unsigned int uint32_t
Definition: rtptypes_win.h:46
#define ACCEPTPACKETCODE
unsigned short uint16_t
Definition: rtptypes_win.h:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetLastMessageTime()

void qrtplib::RTPSourceStats::SetLastMessageTime ( const RTPTime t)
inline

◆ SetLastNoteTime()

void qrtplib::RTPSourceStats::SetLastNoteTime ( const RTPTime t)
inline

Definition at line 242 of file rtpsourcedata.h.

Referenced by qrtplib::RTPInternalSourceData::ProcessSDESItem().

243  {
244  lastnotetime = t;
245  }
+ Here is the caller graph for this function:

◆ SetLastRTPPacketTime()

void qrtplib::RTPSourceStats::SetLastRTPPacketTime ( const RTPTime t)
inline

Definition at line 233 of file rtpsourcedata.h.

234  {
235  lastrtptime = t;
236  }

◆ StartNewInterval()

void qrtplib::RTPSourceStats::StartNewInterval ( )
inline

Definition at line 219 of file rtpsourcedata.h.

220  {
221  numnewpackets = 0;
223  }

Member Data Documentation

◆ baseseqnr

uint32_t qrtplib::RTPSourceStats::baseseqnr
private

Definition at line 254 of file rtpsourcedata.h.

Referenced by RTPSourceStats().

◆ djitter

double qrtplib::RTPSourceStats::djitter
private

Definition at line 257 of file rtpsourcedata.h.

Referenced by ProcessPacket(), and RTPSourceStats().

◆ exthighseqnr

uint32_t qrtplib::RTPSourceStats::exthighseqnr
private

Definition at line 255 of file rtpsourcedata.h.

Referenced by ProcessPacket(), and RTPSourceStats().

◆ jitter

uint32_t qrtplib::RTPSourceStats::jitter
private

Definition at line 256 of file rtpsourcedata.h.

Referenced by ProcessPacket(), and RTPSourceStats().

◆ lastmsgtime

RTPTime qrtplib::RTPSourceStats::lastmsgtime
private

Definition at line 259 of file rtpsourcedata.h.

Referenced by ProcessPacket().

◆ lastnotetime

RTPTime qrtplib::RTPSourceStats::lastnotetime
private

Definition at line 261 of file rtpsourcedata.h.

◆ lastrtptime

RTPTime qrtplib::RTPSourceStats::lastrtptime
private

Definition at line 260 of file rtpsourcedata.h.

Referenced by ProcessPacket().

◆ numcycles

uint32_t qrtplib::RTPSourceStats::numcycles
private

Definition at line 253 of file rtpsourcedata.h.

Referenced by ProcessPacket(), and RTPSourceStats().

◆ numnewpackets

uint32_t qrtplib::RTPSourceStats::numnewpackets
private

Definition at line 262 of file rtpsourcedata.h.

Referenced by ProcessPacket(), and RTPSourceStats().

◆ packetsreceived

uint32_t qrtplib::RTPSourceStats::packetsreceived
private

Definition at line 252 of file rtpsourcedata.h.

Referenced by ProcessPacket(), and RTPSourceStats().

◆ prevexthighseqnr

uint32_t qrtplib::RTPSourceStats::prevexthighseqnr
private

Definition at line 255 of file rtpsourcedata.h.

Referenced by RTPSourceStats().

◆ prevpacktime

RTPTime qrtplib::RTPSourceStats::prevpacktime
private

Definition at line 258 of file rtpsourcedata.h.

Referenced by ProcessPacket().

◆ prevtimestamp

uint32_t qrtplib::RTPSourceStats::prevtimestamp
private

Definition at line 256 of file rtpsourcedata.h.

Referenced by ProcessPacket(), and RTPSourceStats().

◆ savedextseqnr

uint32_t qrtplib::RTPSourceStats::savedextseqnr
private

Definition at line 263 of file rtpsourcedata.h.

Referenced by RTPSourceStats().

◆ sentdata

bool qrtplib::RTPSourceStats::sentdata
private

Definition at line 251 of file rtpsourcedata.h.

Referenced by ProcessPacket(), and RTPSourceStats().


The documentation for this class was generated from the following files: