RTPTransmissionStats Class Reference

#include <RTPSink.hh>

Collaboration diagram for RTPTransmissionStats:

Collaboration graph
[legend]

Public Member Functions

u_int32_t SSRC () const
sockaddr_in const & lastFromAddress () const
unsigned lastPacketNumReceived () const
unsigned firstPacketNumReported () const
unsigned totNumPacketsLost () const
unsigned jitter () const
unsigned lastSRTime () const
unsigned diffSR_RRTime () const
unsigned roundTripDelay () const
timeval timeCreated () const
timeval lastTimeReceived () const
void getTotalOctetCount (u_int32_t &hi, u_int32_t &lo)
void getTotalPacketCount (u_int32_t &hi, u_int32_t &lo)
unsigned packetsReceivedSinceLastRR () const
u_int8_t packetLossRatio () const
int packetsLostBetweenRR () const

Private Member Functions

 RTPTransmissionStats (RTPSink &rtpSink, u_int32_t SSRC)
virtual ~RTPTransmissionStats ()
void noteIncomingRR (struct sockaddr_in const &lastFromAddress, unsigned lossStats, unsigned lastPacketNumReceived, unsigned jitter, unsigned lastSRTime, unsigned diffSR_RRTime)

Private Attributes

RTPSinkfOurRTPSink
u_int32_t fSSRC
sockaddr_in fLastFromAddress
unsigned fLastPacketNumReceived
u_int8_t fPacketLossRatio
unsigned fTotNumPacketsLost
unsigned fJitter
unsigned fLastSRTime
unsigned fDiffSR_RRTime
timeval fTimeCreated fTimeReceived
Boolean fAtLeastTwoRRsHaveBeenReceived
unsigned fOldLastPacketNumReceived
unsigned fOldTotNumPacketsLost
Boolean fFirstPacket
unsigned fFirstPacketNumReported
u_int32_t fLastOctetCount
u_int32_t fTotalOctetCount_hi
u_int32_t fTotalOctetCount_lo
u_int32_t fLastPacketCount
u_int32_t fTotalPacketCount_hi
u_int32_t fTotalPacketCount_lo

Friends

class RTPTransmissionStatsDB

Detailed Description

Definition at line 178 of file RTPSink.hh.


Constructor & Destructor Documentation

RTPTransmissionStats::RTPTransmissionStats ( RTPSink rtpSink,
u_int32_t  SSRC 
) [private]

Definition at line 241 of file RTPSink.cpp.

References fLastOctetCount, fLastPacketCount, NULL, RTPSink::octetCount(), and RTPSink::packetCount().

00242   : fOurRTPSink(rtpSink), fSSRC(SSRC), fLastPacketNumReceived(0),
00243     fPacketLossRatio(0), fTotNumPacketsLost(0), fJitter(0),
00244     fLastSRTime(0), fDiffSR_RRTime(0), fAtLeastTwoRRsHaveBeenReceived(False), fFirstPacket(True),
00245     fTotalOctetCount_hi(0), fTotalOctetCount_lo(0),
00246     fTotalPacketCount_hi(0), fTotalPacketCount_lo(0) {
00247   gettimeofday(&fTimeCreated, NULL);
00248 
00249   fLastOctetCount = rtpSink.octetCount();
00250   fLastPacketCount = rtpSink.packetCount();
00251 }

RTPTransmissionStats::~RTPTransmissionStats (  )  [private, virtual]

Definition at line 253 of file RTPSink.cpp.

00253 {}


Member Function Documentation

u_int32_t RTPTransmissionStats::SSRC (  )  const [inline]

Definition at line 180 of file RTPSink.hh.

References fSSRC.

00180 {return fSSRC;}

struct sockaddr_in const& RTPTransmissionStats::lastFromAddress (  )  const [inline, read]

Definition at line 181 of file RTPSink.hh.

References fLastFromAddress.

00181 {return fLastFromAddress;}

unsigned RTPTransmissionStats::lastPacketNumReceived (  )  const [inline]

Definition at line 182 of file RTPSink.hh.

References fLastPacketNumReceived.

00182 {return fLastPacketNumReceived;}

unsigned RTPTransmissionStats::firstPacketNumReported (  )  const [inline]

Definition at line 183 of file RTPSink.hh.

References fFirstPacketNumReported.

00183 {return fFirstPacketNumReported;}

unsigned RTPTransmissionStats::totNumPacketsLost (  )  const [inline]

Definition at line 184 of file RTPSink.hh.

References fTotNumPacketsLost.

00184 {return fTotNumPacketsLost;}

unsigned RTPTransmissionStats::jitter (  )  const [inline]

Definition at line 185 of file RTPSink.hh.

References fJitter.

00185 {return fJitter;}

unsigned RTPTransmissionStats::lastSRTime (  )  const [inline]

Definition at line 186 of file RTPSink.hh.

References fLastSRTime.

00186 { return fLastSRTime; }

unsigned RTPTransmissionStats::diffSR_RRTime (  )  const [inline]

Definition at line 187 of file RTPSink.hh.

References fDiffSR_RRTime.

00187 { return fDiffSR_RRTime; }

unsigned RTPTransmissionStats::roundTripDelay (  )  const

Definition at line 305 of file RTPSink.cpp.

References fDiffSR_RRTime, fLastSRTime, and fTimeReceived.

Referenced by noteIncomingRR().

00305                                                     {
00306   // Compute the round-trip delay that was indicated by the most recently-received
00307   // RTCP RR packet.  Use the method noted in the RTP/RTCP specification (RFC 3350).
00308 
00309   if (fLastSRTime == 0) {
00310     // Either no RTCP RR packet has been received yet, or else the
00311     // reporting receiver has not yet received any RTCP SR packets from us:
00312     return 0;
00313   }
00314 
00315   // First, convert the time that we received the last RTCP RR packet to NTP format,
00316   // in units of 1/65536 (2^-16) seconds:
00317   unsigned lastReceivedTimeNTP_high
00318     = fTimeReceived.tv_sec + 0x83AA7E80; // 1970 epoch -> 1900 epoch
00319   double fractionalPart = (fTimeReceived.tv_usec*0x0400)/15625.0; // 2^16/10^6
00320   unsigned lastReceivedTimeNTP
00321     = (unsigned)((lastReceivedTimeNTP_high<<16) + fractionalPart + 0.5);
00322 
00323   int rawResult = lastReceivedTimeNTP - fLastSRTime - fDiffSR_RRTime;
00324   if (rawResult < 0) {
00325     // This can happen if there's clock drift between the sender and receiver,
00326     // and if the round-trip time was very small.
00327     rawResult = 0;
00328   }
00329   return (unsigned)rawResult;
00330 }

struct timeval RTPTransmissionStats::timeCreated (  )  const [inline, read]

Definition at line 191 of file RTPSink.hh.

00191 {return fTimeCreated;}

struct timeval RTPTransmissionStats::lastTimeReceived (  )  const [inline, read]

Definition at line 192 of file RTPSink.hh.

References fTimeReceived.

00192 {return fTimeReceived;}

void RTPTransmissionStats::getTotalOctetCount ( u_int32_t &  hi,
u_int32_t &  lo 
)

Definition at line 332 of file RTPSink.cpp.

References fTotalOctetCount_hi, and fTotalOctetCount_lo.

00332                                                                           {
00333   hi = fTotalOctetCount_hi;
00334   lo = fTotalOctetCount_lo;
00335 }

void RTPTransmissionStats::getTotalPacketCount ( u_int32_t &  hi,
u_int32_t &  lo 
)

Definition at line 337 of file RTPSink.cpp.

References fTotalPacketCount_hi, and fTotalPacketCount_lo.

00337                                                                            {
00338   hi = fTotalPacketCount_hi;
00339   lo = fTotalPacketCount_lo;
00340 }

unsigned RTPTransmissionStats::packetsReceivedSinceLastRR (  )  const

Definition at line 342 of file RTPSink.cpp.

References fAtLeastTwoRRsHaveBeenReceived, fLastPacketNumReceived, and fOldLastPacketNumReceived.

00342                                                                 {
00343   if (!fAtLeastTwoRRsHaveBeenReceived) return 0;
00344 
00345   return fLastPacketNumReceived-fOldLastPacketNumReceived;
00346 }

u_int8_t RTPTransmissionStats::packetLossRatio (  )  const [inline]

Definition at line 198 of file RTPSink.hh.

References fPacketLossRatio.

00198 { return fPacketLossRatio; }

int RTPTransmissionStats::packetsLostBetweenRR (  )  const

Definition at line 348 of file RTPSink.cpp.

References fAtLeastTwoRRsHaveBeenReceived, fOldTotNumPacketsLost, and fTotNumPacketsLost.

00348                                                      {
00349   if (!fAtLeastTwoRRsHaveBeenReceived) return 0;
00350 
00351   return fTotNumPacketsLost - fOldTotNumPacketsLost;
00352 }

void RTPTransmissionStats::noteIncomingRR ( struct sockaddr_in const &  lastFromAddress,
unsigned  lossStats,
unsigned  lastPacketNumReceived,
unsigned  jitter,
unsigned  lastSRTime,
unsigned  diffSR_RRTime 
) [private]

Definition at line 256 of file RTPSink.cpp.

References False, fAtLeastTwoRRsHaveBeenReceived, fDiffSR_RRTime, fFirstPacket, fFirstPacketNumReported, fJitter, fLastFromAddress, fLastOctetCount, fLastPacketCount, fLastPacketNumReceived, fLastSRTime, fOldLastPacketNumReceived, fOldTotNumPacketsLost, fOurRTPSink, fPacketLossRatio, fTimeReceived, fTotalOctetCount_hi, fTotalOctetCount_lo, fTotalPacketCount_hi, fTotalPacketCount_lo, fTotNumPacketsLost, NULL, RTPSink::octetCount(), RTPSink::packetCount(), roundTripDelay(), and True.

Referenced by RTPTransmissionStatsDB::noteIncomingRR().

00259                                          {
00260   if (fFirstPacket) {
00261     fFirstPacket = False;
00262     fFirstPacketNumReported = lastPacketNumReceived;
00263   } else {
00264     fAtLeastTwoRRsHaveBeenReceived = True;
00265     fOldLastPacketNumReceived = fLastPacketNumReceived;
00266     fOldTotNumPacketsLost = fTotNumPacketsLost;
00267   }
00268   gettimeofday(&fTimeReceived, NULL);
00269 
00270   fLastFromAddress = lastFromAddress;
00271   fPacketLossRatio = lossStats>>24;
00272   fTotNumPacketsLost = lossStats&0xFFFFFF;
00273   fLastPacketNumReceived = lastPacketNumReceived;
00274   fJitter = jitter;
00275   fLastSRTime = lastSRTime;
00276   fDiffSR_RRTime = diffSR_RRTime;
00277 #ifdef DEBUG_RR
00278   fprintf(stderr, "RTCP RR data (received at %lu.%06ld): lossStats 0x%08x, lastPacketNumReceived 0x%08x, jitter 0x%08x, lastSRTime 0x%08x, diffSR_RRTime 0x%08x\n",
00279           fTimeReceived.tv_sec, fTimeReceived.tv_usec, lossStats, lastPacketNumReceived, jitter, lastSRTime, diffSR_RRTime);
00280   unsigned rtd = roundTripDelay();
00281   fprintf(stderr, "=> round-trip delay: 0x%04x (== %f seconds)\n", rtd, rtd/65536.0);
00282 #endif
00283 
00284   // Update our counts of the total number of octets and packets sent towards
00285   // this receiver:
00286   u_int32_t newOctetCount = fOurRTPSink.octetCount();
00287   u_int32_t octetCountDiff = newOctetCount - fLastOctetCount;
00288   fLastOctetCount = newOctetCount;
00289   u_int32_t prevTotalOctetCount_lo = fTotalOctetCount_lo;
00290   fTotalOctetCount_lo += octetCountDiff;
00291   if (fTotalOctetCount_lo < prevTotalOctetCount_lo) { // wrap around
00292     ++fTotalOctetCount_hi;
00293   }
00294 
00295   u_int32_t newPacketCount = fOurRTPSink.packetCount();
00296   u_int32_t packetCountDiff = newPacketCount - fLastPacketCount;
00297   fLastPacketCount = newPacketCount;
00298   u_int32_t prevTotalPacketCount_lo = fTotalPacketCount_lo;
00299   fTotalPacketCount_lo += packetCountDiff;
00300   if (fTotalPacketCount_lo < prevTotalPacketCount_lo) { // wrap around
00301     ++fTotalPacketCount_hi;
00302   }
00303 }


Friends And Related Function Documentation

friend class RTPTransmissionStatsDB [friend]

Definition at line 204 of file RTPSink.hh.


Field Documentation

RTPSink& RTPTransmissionStats::fOurRTPSink [private]

Definition at line 214 of file RTPSink.hh.

Referenced by noteIncomingRR().

u_int32_t RTPTransmissionStats::fSSRC [private]

Definition at line 215 of file RTPSink.hh.

Referenced by SSRC().

struct sockaddr_in RTPTransmissionStats::fLastFromAddress [read, private]

Definition at line 216 of file RTPSink.hh.

Referenced by lastFromAddress(), and noteIncomingRR().

unsigned RTPTransmissionStats::fLastPacketNumReceived [private]

Definition at line 217 of file RTPSink.hh.

Referenced by lastPacketNumReceived(), noteIncomingRR(), and packetsReceivedSinceLastRR().

u_int8_t RTPTransmissionStats::fPacketLossRatio [private]

Definition at line 218 of file RTPSink.hh.

Referenced by noteIncomingRR(), and packetLossRatio().

unsigned RTPTransmissionStats::fTotNumPacketsLost [private]

Definition at line 219 of file RTPSink.hh.

Referenced by noteIncomingRR(), packetsLostBetweenRR(), and totNumPacketsLost().

unsigned RTPTransmissionStats::fJitter [private]

Definition at line 220 of file RTPSink.hh.

Referenced by jitter(), and noteIncomingRR().

unsigned RTPTransmissionStats::fLastSRTime [private]

Definition at line 221 of file RTPSink.hh.

Referenced by lastSRTime(), noteIncomingRR(), and roundTripDelay().

unsigned RTPTransmissionStats::fDiffSR_RRTime [private]

Definition at line 222 of file RTPSink.hh.

Referenced by diffSR_RRTime(), noteIncomingRR(), and roundTripDelay().

struct timeval fTimeCreated RTPTransmissionStats::fTimeReceived [read, private]

Definition at line 223 of file RTPSink.hh.

Referenced by lastTimeReceived(), noteIncomingRR(), and roundTripDelay().

Boolean RTPTransmissionStats::fAtLeastTwoRRsHaveBeenReceived [private]

Definition at line 224 of file RTPSink.hh.

Referenced by noteIncomingRR(), packetsLostBetweenRR(), and packetsReceivedSinceLastRR().

unsigned RTPTransmissionStats::fOldLastPacketNumReceived [private]

Definition at line 225 of file RTPSink.hh.

Referenced by noteIncomingRR(), and packetsReceivedSinceLastRR().

unsigned RTPTransmissionStats::fOldTotNumPacketsLost [private]

Definition at line 226 of file RTPSink.hh.

Referenced by noteIncomingRR(), and packetsLostBetweenRR().

Boolean RTPTransmissionStats::fFirstPacket [private]

Definition at line 227 of file RTPSink.hh.

Referenced by noteIncomingRR().

unsigned RTPTransmissionStats::fFirstPacketNumReported [private]

Definition at line 228 of file RTPSink.hh.

Referenced by firstPacketNumReported(), and noteIncomingRR().

u_int32_t RTPTransmissionStats::fLastOctetCount [private]

Definition at line 229 of file RTPSink.hh.

Referenced by noteIncomingRR(), and RTPTransmissionStats().

u_int32_t RTPTransmissionStats::fTotalOctetCount_hi [private]

Definition at line 229 of file RTPSink.hh.

Referenced by getTotalOctetCount(), and noteIncomingRR().

u_int32_t RTPTransmissionStats::fTotalOctetCount_lo [private]

Definition at line 229 of file RTPSink.hh.

Referenced by getTotalOctetCount(), and noteIncomingRR().

u_int32_t RTPTransmissionStats::fLastPacketCount [private]

Definition at line 230 of file RTPSink.hh.

Referenced by noteIncomingRR(), and RTPTransmissionStats().

u_int32_t RTPTransmissionStats::fTotalPacketCount_hi [private]

Definition at line 230 of file RTPSink.hh.

Referenced by getTotalPacketCount(), and noteIncomingRR().

u_int32_t RTPTransmissionStats::fTotalPacketCount_lo [private]

Definition at line 230 of file RTPSink.hh.

Referenced by getTotalPacketCount(), and noteIncomingRR().


The documentation for this class was generated from the following files:
Generated on Mon Apr 29 13:32:30 2013 for live by  doxygen 1.5.2