Statistics Class Reference

<class description="" goes="" here=""> <short description=""> More...

#include <Statistics.hpp>

List of all members.


Public Member Functions

 Statistics (ESInfo *esi, bool channelIsWriter)
void setESInfo (ESInfo *new_es)
u32 getStreamoutSec ()
double getStreamoutFloatSec ()
double getPlayoutSec ()
long getBWfromStreamoutSec (u32 sec)
long getBWfromPlayoutSec (u32 sec)
u32 getNumStreamoutSecs ()
double getBufferFillLevelInSecs () const
 returns the number of stored video seconds in the preQ buffer
void setFirstPacketTS (u32 ts)
u32 getFirstPacketTS ()
void setHighestPacketTS (u32 ts)
u32 getHighestPacketTS ()
void setStreamoutFullSec (u32 sec)
u32 getStreamoutFullSec ()
void setStreamoutFloatSec (double sec)
void setPlayoutSec (double sec)
void setBufAheadSec (double sec)
double getBufAheadSec ()
void setClientPreQMaxSize (u32 size)
u32 getClientPreQMaxSize ()
void setStillToPrefetchSecs (double secs)
double getStillToPrefetchSecs ()
void setPrefetchedSecs (double secs)
double getPrefetchedSecs ()
void setFirstPacketTime (double time)
double getFirstPacketTime ()
void setLastPacketTime (double time)
double getLastPacketTime ()
int setAvgRTT (int rtt)
int getAvgRTT ()
int setAvgInterarrivalTime (int msecs)
int getAvgInterarrivalTime ()
void setStreamBW (int bw)
int getStreamBW ()
void setBaseStreamBW (int bw)
int getBaseStreamBW ()
void setAdaptRate (int rate)
int getAdaptRate ()
void setAdaptSecs (double secs)
double getAdaptSecs ()
bool checkForNewPlayoutSec (int this_frame_sec, int highest_ts_sec)
 used by RTP sendThread and readThread to check if the currently processed frame TS is for the next second to keep statistics up-to-date
void writePlayoutSecStats (int this_frame_sec)
void setVOPTimeIncrement (int incr)
float getOriginalFPS ()
bool incPlayoutSecNetFPS (int sec)
bool decPlayoutSecNetFPS (int sec)
int getPlayoutSecNetFPS (int sec)
bool incPlayoutSecFPS (int sec)
bool decPlayoutSecFPS (int sec)
int getPlayoutSecFPS (int sec)
bool incPlayoutSecIFrame (int sec)
bool decPlayoutSecIFrame (int sec)
int getPlayoutSecIFrame (int sec)
bool incPlayoutSecPFrame (int sec)
bool decPlayoutSecPFrame (int sec)
int getPlayoutSecPFrame (int sec)
bool incPlayoutSecBFrame (int sec)
bool decPlayoutSecBFrame (int sec)
int getPlayoutSecBFrame (int sec)
bool incPlayoutSecPSNR (int sec, double psnr)
double getPlayoutSecPSNR (int sec)
bool incPlayoutSecDataPkts (int sec)
bool decPlayoutSecDataPkts (int sec)
int getPlayoutSecDataPkts (int sec)
bool incPlayoutSecRtxPkts (int sec)
int getPlayoutSecRtxPkts (int sec)
bool incPlayoutSecDataBW (int sec, int bw)
bool decPlayoutSecDataBW (int sec, int bw)
int getPlayoutSecDataBW (int sec)
bool incPlayoutSecRtxBW (int sec, int bw)
int getPlayoutSecRtxBW (int sec)
bool incPlayoutSecNackedBW (int sec, int bw)
int getPlayoutSecNackedBW (int sec)
bool checkForNewStreamoutSec (double now_dtime)
 used by sendThread and readThread to check for new streamout sec to keep statistics up-to-date
void writeStreamoutSecClientStats (long preQsize)
void writeStreamoutSecServerStats ()
float getStreamoutSecLossPercent (int sec)
bool incStreamoutSecDataPkts (int sec)
bool decStreamoutSecDataPkts (int sec)
int getStreamoutSecDataPkts (int sec)
bool incStreamoutSecRtxPkts (int sec)
int getStreamoutSecRtxPkts (int sec)
bool incStreamoutSecDataBW (int sec, int bw)
bool decStreamoutSecDataBW (int sec, int bw)
int getStreamoutSecDataBW (int sec)
bool incStreamoutSecRtxBW (int sec, int bw)
int getStreamoutSecRtxBW (int sec)
bool incStreamoutSecNackedBW (int sec, int bw)
int getStreamoutSecNackedBW (int sec)
bool setStreamoutSecNetBW (int sec, int bw)
int getStreamoutSecNetBW (int sec)
bool setStreamoutSecClientBufFill (int sec, int size)
bool incStreamoutSecClientBufFill (int sec, int size)
int getStreamoutSecClientBufFill (int sec)
bool setStreamoutSecPlayoutSec (int sec, double plSec)
double getStreamoutSecPlayoutSec (int sec)
bool setStreamoutSecBufAhead (int sec, double time)
double getStreamoutSecBufAhead (int sec)
bool incStreamoutSecNumBKeepChecks (int sec)
int getStreamoutSecNumBKeepChecks (int sec)

Detailed Description

<class description="" goes="" here=""> <short description="">

Author:
Michael Kropfberger and Peter Schojer
Version:
Id
Statistics.hpp,v 1.13 2004/09/16 08:17:43 mtaschwer Exp

Definition at line 61 of file Statistics.hpp.


Member Function Documentation

bool Statistics::checkForNewPlayoutSec int  this_frame_sec,
int  highest_ts_sec
 

used by RTP sendThread and readThread to check if the currently processed frame TS is for the next second to keep statistics up-to-date

Parameters:
this_frame_sec is the floor'd sec of this frameTS
highest_ts_sec is the floor'd highest TS, which should be compared to this_frame_sec
Returns:
true if new frameTS sec was invoked
Definition at line 231 of file Statistics.cpp.

Referenced by StatisticsUpdater::adapt().

00231 { 00232 00233 if (highest_ts_sec < 0) //initial reader value is -1 !!! 00234 return true; 00235 00236 //new client buf second 00237 if ( highest_ts_sec < this_frame_sec ) { 00238 dprintf_full("Statistics(%p)::checkForNewPlayoutSec: this %i highest %i\n", 00239 this,highest_ts_sec,this_frame_sec); 00240 00241 if (this_frame_sec - highest_ts_sec > RTP_STAT_SECS) { 00242 memset(playsec_stat,0,sizeof(playsec_stat)); 00243 highest_ts_sec = this_frame_sec; 00244 } else 00245 while (highest_ts_sec < this_frame_sec ) { 00246 highest_ts_sec++; 00247 memset(&playsec_stat[highest_ts_sec % RTP_STAT_SECS],0,sizeof(OnePlayoutSecStat)); 00248 } 00249 00250 #ifdef VITOOKI_DEBUG 00251 if (this_frame_sec >= 1) { 00252 dprintf_full("Statistics(%p)::checkForNewPlayoutSec: netStat highest_ts_sec %i (last PSNR %3.3f): [data|rtx|pkts|fps]", this, highest_ts_sec, getPlayoutSecPSNR(this_frame_sec - 1)); 00253 for (int i=this_frame_sec - 1; 00254 i >= MAX(0,this_frame_sec +1 - RTP_STAT_SECS); 00255 i--) 00256 printf("#[%2i: %3i|%2i|%2i|%2i]",i, 00257 getPlayoutSecDataBW(i)/128, 00258 getPlayoutSecRtxBW(i)/128, 00259 getPlayoutSecDataPkts(i), 00260 getPlayoutSecNetFPS(i)); 00261 printf("\n"); 00262 } 00263 #endif 00264 writePlayoutSecStats(this_frame_sec); 00265 00266 return true; 00267 } 00268 return false; 00269 }

bool Statistics::checkForNewStreamoutSec double  now_dtime  ) 
 

used by sendThread and readThread to check for new streamout sec to keep statistics up-to-date

Parameters:
now_dtime gives the actual time which should be compared to old streamoutSec, if -1, getTimeOfDay will be used
Returns:
true if new streamout sec was invoked
Definition at line 306 of file Statistics.cpp.

References ESInfo::getMediaTimeScale(), getPlayoutSec(), and getStreamoutFloatSec().

Referenced by StatisticsUpdater::adapt().

00306 { 00307 double this_sec; 00308 u32 old_streamout_sec; 00309 int i=0; 00310 00311 if (getFirstPacketTime() == 0) { 00312 dprintf_err("Statistics::checkForNewStreamoutSec no firstPacketTime for calculations....\n"); 00313 return false; 00314 } 00315 00316 if (now_dtime < 0.0) { //no time given, so get real now time... 00317 struct timeval now_tv; 00318 gettimeofday(&now_tv,NULL); 00319 now_dtime = now_tv.tv_sec + now_tv.tv_usec/1000000.0; 00320 } 00321 00322 this_sec = now_dtime - getFirstPacketTime(); 00323 setStreamoutFloatSec(this_sec); 00324 00325 //negative playout sec for initial prefetching! 00326 setPlayoutSec(getStreamoutFloatSec() - getPrefetchedSecs()); 00327 00328 if (getStreamoutFloatSec() >= getPrefetchedSecs()) { 00329 setBufAheadSec(((double)(getHighestPacketTS()-getFirstPacketTS())/(double)es->getMediaTimeScale()) 00330 - (getStreamoutFloatSec() - getPrefetchedSecs()) 00331 - (float)getAvgRTT()/1000.0); //is always zero on client side! 00332 // conservative approach: we use RTT instead of latency, since RTT/2 might be wrong on 00333 // unevenly loaded links 00334 } else 00335 setBufAheadSec( ((double)(getHighestPacketTS()-getFirstPacketTS()) / (double)es->getMediaTimeScale()) ); 00336 00337 00338 old_streamout_sec = getStreamoutFullSec(); 00339 setStreamoutFullSec((int)float(this_sec)); 00340 00341 if (old_streamout_sec < getStreamoutFullSec()) { //NEW STREAMOUT SEC 00342 if (getStreamoutFullSec() - old_streamout_sec > RTP_STAT_SECS) { 00343 //eg. paused for over 15 secs 00344 old_streamout_sec = getStreamoutFullSec(); 00345 memset(&streamsec_stat, 0, sizeof(OneStreamoutSecStat)*RTP_STAT_SECS); 00346 } else { 00347 //reset all skipped-over secs 00348 while(old_streamout_sec < getStreamoutFullSec()) { 00349 old_streamout_sec++; //advance to next skipped one 00350 memset(&streamsec_stat[old_streamout_sec % RTP_STAT_SECS], 0, sizeof(OneStreamoutSecStat)); 00351 } 00352 } 00353 00354 streamsec_stat[(getStreamoutFullSec()-1) % RTP_STAT_SECS].stream_bw = getStreamBW(); 00355 if (getPlayoutSec() > 1) 00356 playsec_stat[((int)floor(getPlayoutSec()-1)) % RTP_STAT_SECS].stream_bw = getStreamBW(); 00357 00358 // calc client buffer fill rate 00359 //fake float part by non-exact percentage of according full sec 00360 int playout_floor_sec = MAX(0,(int)floor(getPlayoutSec())); 00361 // int buf_ahead_floor_sec = (int)floor(getBufAheadSec()); 00362 setStreamoutSecClientBufFill(getStreamoutFullSec()-1, 0); 00363 setStreamoutSecBufAhead(getStreamoutFullSec()-1, getBufAheadSec()); 00364 setStreamoutSecPlayoutSec(getStreamoutFullSec()-1, getPlayoutSec()); 00365 00366 // left-over buffers from actual playout sec 00367 double playout_fract = (double)playout_floor_sec + 1 - MAX(0.0, getPlayoutSec()); 00368 //ignore case that buf_ahead could be < 1.0, since the rest wont be in our playsec_stat anyway... 00369 incStreamoutSecClientBufFill(getStreamoutFullSec()-1, 00370 (int)( (double)(getPlayoutSecDataBW(playout_floor_sec) 00371 + getPlayoutSecRtxBW(playout_floor_sec) ) 00372 * playout_fract ) ); 00373 00374 int buf_ahead_floor_sec_left = (int)floor(getBufAheadSec() - playout_fract); 00375 for (i=1; i <= buf_ahead_floor_sec_left; i++) 00376 incStreamoutSecClientBufFill(getStreamoutFullSec()-1, 00377 getPlayoutSecDataBW(playout_floor_sec + i) 00378 + getPlayoutSecRtxBW(playout_floor_sec + i) ); 00379 00380 // and now the tail of the last sec 00381 playout_fract = getBufAheadSec() - playout_fract - buf_ahead_floor_sec_left; 00382 if (playout_fract > 0) //still more ahead 00383 incStreamoutSecClientBufFill(getStreamoutFullSec()-1, 00384 (int)((double) (getPlayoutSecDataBW( 00385 (int)floor(MAX(0,(int)getPlayoutSec()) 00386 + getBufAheadSec())) 00387 + getPlayoutSecRtxBW((int)floor(MAX(0,(int)getPlayoutSec()) 00388 + getBufAheadSec())) ) 00389 * playout_fract ) ); 00390 00391 #ifdef VITOOKI_DEBUG 00392 dprintf_full("Statistics(%p)::checkForNewStreamoutSec: netStat this_sec %6.3f" 00393 " (playout %6.3f): [data|rtx|nacked|ClBuf]", 00394 this, getStreamoutFloatSec(),getPlayoutSec()); 00395 for (i=getStreamoutFullSec() - 1; 00396 i >= MAX(0,(int)getStreamoutFullSec() + 1 - RTP_STAT_SECS); 00397 i--) 00398 printf("#[%2i: %3i|%2i|%2i|%i]",i, 00399 getStreamoutSecDataBW(i)/128, 00400 getStreamoutSecRtxBW(i)/128, 00401 getStreamoutSecNackedBW(i)/128, 00402 getStreamoutSecClientBufFill(i)/128); 00403 printf("\n"); 00404 #endif 00405 00406 return true; 00407 } 00408 00409 return false; 00410 }

long Statistics::getBWfromPlayoutSec u32  sec  ) 
 

Returns:
the overall bytes/sec of the specified playout sec or -1 if the requested sec is not available any more
Definition at line 184 of file Statistics.cpp.

References getPlayoutSec().

00184 { 00185 if ((sec > (unsigned)ceil(getPlayoutSec())) 00186 || ((signed)sec < MAX(0,(signed)ceil(getPlayoutSec()) - RTP_STAT_SECS)) ) { 00187 return -1; 00188 } 00189 00190 //dprintf_full("Statistics::getBWfromStreamoutSec %i data|rtx|nacked %6i:%6i:%6i\n",sec, 00191 //getStreamoutSecDataBW(sec), getStreamoutSecRtxBW(sec), getStreamoutSecNackedBW(sec)); 00192 return getPlayoutSecDataBW(sec) + getPlayoutSecRtxBW(sec) - getPlayoutSecNackedBW(sec); 00193 }

long Statistics::getBWfromStreamoutSec u32  sec  ) 
 

Returns:
the overall bytes/sec of the specified streamout sec or -1 if the requested sec is not available any more
Definition at line 172 of file Statistics.cpp.
00172 { 00173 if ((sec > getStreamoutFullSec()) 00174 || ((signed)sec < MAX(0,(signed)getStreamoutFullSec() - RTP_STAT_SECS)) ) { 00175 return -1; 00176 } 00177 00178 //dprintf_full("Statistics::getBWfromStreamoutSec %i data|rtx|nacked %6i:%6i:%6i\n",sec, 00179 //getStreamoutSecDataBW(sec), getStreamoutSecRtxBW(sec), getStreamoutSecNackedBW(sec)); 00180 return getStreamoutSecDataBW(sec) + getStreamoutSecRtxBW(sec) - getStreamoutSecNackedBW(sec); 00181 }

u32 Statistics::getNumStreamoutSecs  ) 
 

Returns:
the number of stored BW secs *
Definition at line 198 of file Statistics.cpp.
00198 { 00199 return RTP_STAT_SECS; 00200 }

double Statistics::getPlayoutSec  )  [inline]
 

Returns:
the actual second+msecs, where the playout is right now initial prefetching will cause a negative playout_sec!
Definition at line 88 of file Statistics.hpp.

Referenced by PSNR::adapt(), Rtp::addToPreQ(), checkForNewStreamoutSec(), getBWfromPlayoutSec(), and Rtp::reinsertToPreQ().

00088 { return playout_sec; };

double Statistics::getStreamoutFloatSec  )  [inline]
 

Returns:
the actual second+msecs, for how long the Rtp class is already sending/recv data
Definition at line 83 of file Statistics.hpp.

Referenced by Rtp::addToPreQ(), and checkForNewStreamoutSec().

00083 { return streamout_float_sec; };

u32 Statistics::getStreamoutSec  )  [inline]
 

Returns:
the actual second, for how long the Rtp class is already sending/recv data
Definition at line 79 of file Statistics.hpp.

Referenced by Rtp::calcAdaptPreQValues().

00079 { return streamout_sec; };


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