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
00194
long tmElapsed = 0;
00195
00196
00197
00198
00199 ulong cumClientReceived = 0;
00200
00201
00202
00203 uint untilSection = sections->size();
00204
if (sectionNr != 0)
00205 {
00206 untilSection = sectionNr;
00207 }
00208
Globals::sdebug <<
"\nTimeMeasurement::getElapsedTime(): untilSection=" << untilSection;
00209
00210
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;
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
00227
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
00239
if (tsElapsed < 0) tsElapsed = 0;
00240
00241
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
00258
if (i > 1 && cumClientReceived != 0)
00259 {
00260 tmElapsed = cumClientReceived + (currserverPlayout - (*(iter-1))->getServerPlayout());
00261 cumClientReceived = 0;
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
00275
00276
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
00288
00289
if (i > 1 && cumClientReceived != 0)
00290 {
00291 tmElapsed = cumClientReceived + (ts->
getServerPlayout() - (*(iter-1))->getServerPlayout());
00292 cumClientReceived = 0;
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 }