Newer
Older
// this is the only information source available for the upload stream.
long uploadNewNbRecv = feedback.getXtndSeqNum();
long newNbLost
= feedback.getNumLost() - nbLost[streamDirection.ordinal()];
long nbSteps = uploadNewNbRecv - uploadFeedbackNbPackets;
updateNbLoss(streamDirection, newNbLost, nbSteps);
// Updates the upload loss counters.
uploadFeedbackNbPackets = uploadNewNbRecv;
// Computes RTT.
rttMs = computeRTTInMs(feedback);

Boris Grozev
committed
}
/**
* Updates this stream stats with the new feedback sent.

Boris Grozev
committed
*
* @param feedback The last RTCP feedback sent by the MediaStream.

Boris Grozev
committed
*/
private void updateNewSentFeedback(RTCPFeedback feedback)

Boris Grozev
committed
{
updateJitterRTPTimestampUnits(feedback, StreamDirection.DOWNLOAD);
// No need to update the download loss as we have a more accurate value
// in the global reception stats, which are updated for each new packet
// received.

Boris Grozev
committed
}
/**
* Computes and updates information for a specific stream.

Boris Grozev
committed
*/

Boris Grozev
committed
{
// Gets the current time.
long currentTimeMs = System.currentTimeMillis();
// UPdates stats for the download stream.
updateStreamDirectionStats(StreamDirection.DOWNLOAD, currentTimeMs);
// UPdates stats for the upload stream.
updateStreamDirectionStats(StreamDirection.UPLOAD, currentTimeMs);
// Saves the last update values.
updateTimeMs = currentTimeMs;

Boris Grozev
committed
}
/**
* Computes and updates information for a specific stream.

Boris Grozev
committed
*
* @param streamDirection The stream direction (DOWNLOAD or UPLOAD) of the
* stream from which this function updates the stats.
* @param currentTimeMs The current time in ms.

Boris Grozev
committed
*/
private void updateStreamDirectionStats(
StreamDirection streamDirection,
long currentTimeMs)

Boris Grozev
committed
{
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
int streamDirectionIndex = streamDirection.ordinal();
// Gets the current number of packets correctly received since the
// beginning of this stream.
long newNbRecv = getNbPDU(streamDirection);
// Gets the number of byte received/sent since the beginning of this
// stream.
long newNbByte = getNbBytes(streamDirection);
// Computes the number of update steps which has not been done since
// last update.
long nbSteps = newNbRecv - nbPackets[streamDirectionIndex];
// Even if the remote peer does not send any packets (i.e. is
// microphone is muted), Jitsi must updates it stats. Thus, Jitsi
// computes a number of steps equivalent as if Jitsi receives a packet
// each 20ms (default value).
if(nbSteps == 0)
nbSteps = (currentTimeMs - updateTimeMs) / 20;
// The upload percentLoss is only computed when a new RTCP feedback is
// received. This is not the case for the download percentLoss which is
// updated for each new RTP packet received.
// Computes the loss rate for this stream.
if(streamDirection == StreamDirection.DOWNLOAD)

Boris Grozev
committed
{
// Gets the current number of losses in download since the beginning
// of this stream.
long newNbLost
= getDownloadNbPDULost() - nbLost[streamDirectionIndex];
updateNbLoss(streamDirection, newNbLost, nbSteps + newNbLost);
long newNbDiscarded = getNbDiscarded() - nbDiscarded;
updateNbDiscarded(newNbDiscarded, nbSteps + newNbDiscarded);

Boris Grozev
committed
}
// Computes the bandwidth used by this stream.
double newRateKiloBitPerSec
= MediaStreamStatsImpl.computeRateKiloBitPerSec(
newNbByte - nbByte[streamDirectionIndex],
currentTimeMs - updateTimeMs);
rateKiloBitPerSec[streamDirectionIndex]
= MediaStreamStatsImpl.computeEWMA(
nbSteps,
rateKiloBitPerSec[streamDirectionIndex],
newRateKiloBitPerSec);
// Saves the last update values.
nbPackets[streamDirectionIndex] = newNbRecv;
nbByte[streamDirectionIndex] = newNbByte;
updateNbFec();

Boris Grozev
committed
}