TimeMeasurement Class Reference

This class is used to measure the elapsed time of a streaming session. More...

#include <TimeMeasurement.hpp>

List of all members.


Public Member Functions

 TimeMeasurement ()
 default constructor
 ~TimeMeasurement ()
 default destructor
void addNewSection (ulong prebuffertime)
 Add a new section to the list of sections.
void setPreviousSessionDuration (ulong previousSessionDuration)
 Set the endtime of previous session.
void setDuration (ulong duration)
 Set the duration of the movie.
ulong getPreviousSessionDuration ()
ulong getDuration ()
ulong getElapsedTime (uint sectionNr=0, ulong serverPlayout=0, ulong clientPlayout=0)
uint getTimeSectionCount ()
void startTS ()
 Set start-timestamp of current time-section.
void stopTS ()
 Set stop-timestamp of current time-section.
void setTSrequestedFrom (ulong reqfrom)
 Set requested range-from value of current time-section (and correct duration of previous time-section).
void setTSserverPlayout (ulong playout)
 Set client playout-time (retrieved from mediaserver) of current time-section.
void setTSclientPlayout (ulong playout)
 Set client playout-time (retrieved from client) of current time-section.

Detailed Description

This class is used to measure the elapsed time of a streaming session.

Author:
Klaus Schoeffmann

Definition at line 68 of file TimeMeasurement.hpp.


Member Function Documentation

ulong TimeMeasurement::getDuration  ) 
 

Returns:
duration of current session
Definition at line 113 of file TimeMeasurement.cpp.

Referenced by SSession::getDuration().

00114 { 00115 return duration; 00116 }

ulong TimeMeasurement::getElapsedTime uint  sectionNr = 0,
ulong  serverPlayout = 0,
ulong  clientPlayout = 0
 

Returns:
estimated elapsed time of current session. This value is either calculated as the difference between measured end-time/start-time and client-buffer-size or from retrieved server-estimation and client-buffer-size. Furthermore, if this session contains more than one time-sections, the range-values of the client-requests are considered, to minimize the deviation from the real mediatime
Definition at line 186 of file TimeMeasurement.cpp.

References TimeSection::getClientPlayout(), TimeSection::getClientReceived(), TimeSection::getCurrentMsecs(), TimeSection::getMeasuredEndtime(), TimeSection::getMeasuredStarttime(), TimeSection::getPrebufferTime(), and TimeSection::getServerPlayout().

Referenced by SSession::getElapsedMsecs().

00187 { 00188 assert(sections->back() != NULL); 00189 00190 Globals::sdebug << "\n********************************\n"; 00191 Globals::sdebug << "\nTimeMeasurement::getElapsedTime() sectionNr=" << sectionNr << ", currserverPlayout=" << currserverPlayout << ", currclientPlayout=" << currclientPlayout; 00192 00193 //elapsed time, considering all time-sections 00194 long tmElapsed = 0; 00195 00196 //cumulative client-received 00197 //this value contains the duration of all time-sections, which 00198 //were confirmed by the client 00199 ulong cumClientReceived = 0; 00200 00201 //if there was a section-number specified, iterate 00202 //through the sections only until specified section-number 00203 uint untilSection = sections->size(); 00204 if (sectionNr != 0) 00205 { 00206 untilSection = sectionNr; 00207 } 00208 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): untilSection=" << untilSection; 00209 00210 //iterate through sections 00211 vector<TimeSection*>::const_iterator iter = sections->begin(); 00212 for (uint i =1; iter != sections->end() && i <= untilSection; iter++, i++) 00213 { 00214 TimeSection *ts = *iter; 00215 long tsElapsed; //elapsed time of time-section 00216 00217 if (ts->getMeasuredStarttime() == 0) 00218 { 00219 cerr << "\nWARNING: getmeasuredstarttime of timesection " << i << " == 0 !!!" << endl; 00220 } 00221 else 00222 { 00223 00224 Globals::sdebug << "\nTimeMeasurement::getElapsedTime()" << i << ": "; 00225 00226 //calculate elapsed time of this time-section 00227 //if we do not have an endtime yet, use current time as end-time 00228 Globals::sdebug << "\n\t measuredendtime=" << ts->getMeasuredEndtime() << " "; 00229 if (ts->getMeasuredEndtime() != 0) 00230 { 00231 tsElapsed = ts->getMeasuredEndtime() - ts->getMeasuredStarttime() - ts->getPrebufferTime(); 00232 } 00233 else 00234 { 00235 tsElapsed = ts->getCurrentMsecs() - ts->getMeasuredStarttime() - ts->getPrebufferTime(); 00236 } 00237 00238 //if session has not been started already, correct value to null 00239 if (tsElapsed < 0) tsElapsed = 0; 00240 00241 //if we have a value confirmed by the player for this section, use this instead of 00242 if (currclientPlayout != 0 && ((iter+1) == sections->end())) 00243 { 00244 tmElapsed = currclientPlayout; 00245 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): current CLIENT playout chosen"; 00246 } 00247 else if (ts->getClientReceived() != 0) 00248 { 00249 tmElapsed += ts->getClientReceived(); 00250 cumClientReceived += ts->getClientReceived(); 00251 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): CLIENTRECEIVE(pause) chosen"; 00252 Globals::sdebug << "\t(clientreceived=" << ts->getClientReceived() << " cumclientreceived=" << cumClientReceived << ") "; 00253 } 00254 else if (currserverPlayout != 0 && ((iter+1) == sections->end())) 00255 { 00256 Globals::sdebug << "\n\t currserverPlayout=" << currserverPlayout; 00257 //if we have a value confirmed by the player for the last section, use this instead of 00258 if (i > 1 && cumClientReceived != 0) 00259 { 00260 tmElapsed = cumClientReceived + (currserverPlayout - (*(iter-1))->getServerPlayout()); 00261 cumClientReceived = 0; //do not use this value for later sections 00262 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): CORRECTED SERVERPLAYOUT chosen"; 00263 Globals::sdebug << "\t corrected clientplayout=" << tmElapsed; 00264 } 00265 else 00266 { 00267 tmElapsed = currserverPlayout; 00268 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): current SERVER playout chosen"; 00269 } 00270 } 00271 else 00272 { 00273 00274 //if we have a value from the client or the mediaserver, use this instead of 00275 //(attention!: this value is cumulative) 00276 //otherwise use calculation above 00277 if (ts->getClientPlayout() != 0) 00278 { 00279 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): CLIENT playout chosen"; 00280 Globals::sdebug << "(\t clientplayout=" << ts->getClientPlayout() << ") "; 00281 tmElapsed += ts->getClientPlayout(); 00282 } 00283 else if (ts->getServerPlayout() != 0) 00284 { 00285 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): SERVER playout chosen"; 00286 Globals::sdebug << "(\t serverplayout=" << ts->getServerPlayout() << ") "; 00287 //on more than one timesections: if we have a previous section, which 00288 //were confirmed by the client, add difference to that confirmed value 00289 if (i > 1 && cumClientReceived != 0) 00290 { 00291 tmElapsed = cumClientReceived + (ts->getServerPlayout() - (*(iter-1))->getServerPlayout()); 00292 cumClientReceived = 0; //do not use this value for later sections 00293 Globals::sdebug << "\n\t corrected clientplayout=" << tmElapsed << " "; 00294 } 00295 else 00296 { 00297 tmElapsed = ts->getServerPlayout(); 00298 } 00299 } 00300 else 00301 { 00302 tmElapsed += tsElapsed; 00303 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): OWN ESTIMANTION chosen (tmElapsed=" << tmElapsed << ")"; 00304 } 00305 00306 } 00307 } 00308 } 00309 00310 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): tmElapsed=" << tmElapsed << " prevSD=" << previousSessionDuration; 00311 Globals::sdebug << "\nTimeMeasurement::getElapsedTime(): RESULT=" << (tmElapsed + previousSessionDuration); 00312 Globals::sdebug << "\n********************************\n"; 00313 00314 return tmElapsed + previousSessionDuration; 00315 }

ulong TimeMeasurement::getPreviousSessionDuration  ) 
 

Returns:
endtime of previous session
Definition at line 107 of file TimeMeasurement.cpp.

Referenced by SSession::getPreviousSessionDuration().

00108 { 00109 return previousSessionDuration; 00110 }

uint TimeMeasurement::getTimeSectionCount  ) 
 

Returns:
current number of time-sections
Definition at line 180 of file TimeMeasurement.cpp.

Referenced by SSession::getTimeSectionCount().

00181 { 00182 return sections->size(); 00183 }


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