Bug 970686 - Add stat.packetsLost. r=jesup

This commit is contained in:
Jan-Ivar Bruaroey 2014-02-13 22:35:13 -08:00
parent a77e1c2641
commit dfeece3017
13 changed files with 50 additions and 32 deletions

View File

@ -37,6 +37,7 @@ dictionary RTCInboundRTPStreamStats : RTCRTPStreamStats {
unsigned long packetsReceived;
unsigned long long bytesReceived;
double jitter;
unsigned long packetsLost;
};
dictionary RTCOutboundRTPStreamStats : RTCRTPStreamStats {

View File

@ -148,11 +148,14 @@ bool WebrtcAudioConduit::GetRemoteSSRC(unsigned int* ssrc) {
return !mPtrRTP->GetRemoteSSRC(mChannel, *ssrc);
}
bool WebrtcAudioConduit::GetRTPJitter(unsigned int* jitterMs) {
unsigned int maxJitterMs;
bool WebrtcAudioConduit::GetRTPStats(unsigned int* jitterMs,
unsigned int* cumulativeLost) {
unsigned int maxJitterMs = 0;
unsigned int discardedPackets;
*jitterMs = 0;
*cumulativeLost = 0;
return !mPtrRTP->GetRTPStatistics(mChannel, *jitterMs, maxJitterMs,
discardedPackets);
discardedPackets, *cumulativeLost);
}
DOMHighResTimeStamp
@ -164,22 +167,22 @@ NTPtoDOMHighResTimeStamp(uint32_t ntpHigh, uint32_t ntpLow) {
bool WebrtcAudioConduit::GetRTCPReceiverReport(DOMHighResTimeStamp* timestamp,
unsigned int* jitterMs,
unsigned int* packetsReceived,
uint64_t* bytesReceived) {
uint64_t* bytesReceived,
unsigned int *cumulativeLost) {
unsigned int ntpHigh, ntpLow;
unsigned int rtpTimestamp, playoutTimestamp;
unsigned int packetsSent;
unsigned int bytesSent32;
unsigned short fractionLost;
unsigned int cumulativeLost;
bool result = !mPtrRTP->GetRemoteRTCPData(mChannel, ntpHigh, ntpLow,
rtpTimestamp, playoutTimestamp,
packetsSent, bytesSent32,
jitterMs,
&fractionLost, &cumulativeLost);
&fractionLost, cumulativeLost);
if (result) {
*timestamp = NTPtoDOMHighResTimeStamp(ntpHigh, ntpLow);
*packetsReceived = (packetsSent >= cumulativeLost) ?
(packetsSent - cumulativeLost) : 0;
*packetsReceived = (packetsSent >= *cumulativeLost) ?
(packetsSent - *cumulativeLost) : 0;
*bytesReceived = (packetsSent ?
(bytesSent32 / packetsSent) : 0) * (*packetsReceived);
}

View File

@ -178,11 +178,12 @@ public:
webrtc::VoiceEngine* GetVoiceEngine() { return mVoiceEngine; }
bool GetLocalSSRC(unsigned int* ssrc);
bool GetRemoteSSRC(unsigned int* ssrc);
bool GetRTPJitter(unsigned int* jitterMs);
bool GetRTPStats(unsigned int* jitterMs, unsigned int* cumulativeLost);
bool GetRTCPReceiverReport(DOMHighResTimeStamp* timestamp,
unsigned int* jitterMs,
unsigned int* packetsReceived,
uint64_t* bytesReceived);
uint64_t* bytesReceived,
unsigned int *cumulativeLost);
bool GetRTCPSenderReport(DOMHighResTimeStamp* timestamp,
unsigned int* packetsSent,
uint64_t* bytesSent);

View File

@ -143,11 +143,13 @@ public:
/**
* Functions returning stats needed by w3c stats model.
*/
virtual bool GetRTPJitter(unsigned int* jitterMs) = 0;
virtual bool GetRTPStats(unsigned int* jitterMs,
unsigned int* cumulativeLost) = 0;
virtual bool GetRTCPReceiverReport(DOMHighResTimeStamp* timestamp,
unsigned int* jitterMs,
unsigned int* packetsReceived,
uint64_t* bytesReceived) = 0;
uint64_t* bytesReceived,
unsigned int* cumulativeLost) = 0;
virtual bool GetRTCPSenderReport(DOMHighResTimeStamp* timestamp,
unsigned int* packetsSent,
uint64_t* bytesSent) = 0;

View File

@ -145,18 +145,18 @@ bool WebrtcVideoConduit::GetRemoteSSRC(unsigned int* ssrc) {
return !mPtrRTP->GetRemoteSSRC(mChannel, *ssrc);
}
bool WebrtcVideoConduit::GetRTPJitter(unsigned int* jitterMs) {
bool WebrtcVideoConduit::GetRTPStats(unsigned int* jitterMs,
unsigned int* cumulativeLost) {
unsigned int ntpHigh, ntpLow;
unsigned int packetsSent, bytesSent;
unsigned short fractionLost;
unsigned int cumulativeLost;
unsigned extendedMax;
int rttMs;
// GetReceivedRTCPStatistics is a poorly named GetRTPStatistics variant
return !mPtrRTP->GetReceivedRTCPStatistics(mChannel, ntpHigh, ntpLow,
packetsSent, bytesSent,
fractionLost,
cumulativeLost,
*cumulativeLost,
extendedMax,
*jitterMs,
rttMs);
@ -165,25 +165,25 @@ bool WebrtcVideoConduit::GetRTPJitter(unsigned int* jitterMs) {
bool WebrtcVideoConduit::GetRTCPReceiverReport(DOMHighResTimeStamp* timestamp,
unsigned int* jitterMs,
unsigned int* packetsReceived,
uint64_t* bytesReceived) {
uint64_t* bytesReceived,
unsigned int* cumulativeLost) {
unsigned int ntpHigh, ntpLow;
unsigned int packetsSent;
unsigned int bytesSent32;
unsigned short fractionLost;
unsigned int cumulativeLost;
unsigned extendedMax;
int rttMs;
bool result = !mPtrRTP->GetSentRTCPStatistics(mChannel, ntpHigh, ntpLow,
bytesSent32, packetsSent,
fractionLost,
cumulativeLost,
*cumulativeLost,
extendedMax,
*jitterMs,
rttMs);
if (result) {
*timestamp = NTPtoDOMHighResTimeStamp(ntpHigh, ntpLow);
*packetsReceived = (packetsSent >= cumulativeLost) ?
(packetsSent - cumulativeLost) : 0;
*packetsReceived = (packetsSent >= *cumulativeLost) ?
(packetsSent - *cumulativeLost) : 0;
*bytesReceived = (packetsSent ?
(bytesSent32 / packetsSent) : 0) * (*packetsReceived);
}

View File

@ -210,11 +210,12 @@ public:
webrtc::VideoEngine* GetVideoEngine() { return mVideoEngine; }
bool GetLocalSSRC(unsigned int* ssrc);
bool GetRemoteSSRC(unsigned int* ssrc);
bool GetRTPJitter(unsigned int* jitterMs);
bool GetRTPStats(unsigned int* jitterMs, unsigned int* cumulativeLost);
bool GetRTCPReceiverReport(DOMHighResTimeStamp* timestamp,
unsigned int* jitterMs,
unsigned int* packetsReceived,
uint64_t* bytesReceived);
uint64_t* bytesReceived,
unsigned int* cumulativeLost);
bool GetRTCPSenderReport(DOMHighResTimeStamp* timestamp,
unsigned int* packetsSent,
uint64_t* bytesSent);

View File

@ -1993,9 +1993,11 @@ PeerConnectionImpl::GetStatsImpl_s(
uint32_t jitterMs;
uint32_t packetsReceived;
uint64_t bytesReceived;
uint32_t packetsLost;
if (mp.Conduit()->GetRTCPReceiverReport(&timestamp, &jitterMs,
&packetsReceived,
&bytesReceived)) {
&bytesReceived,
&packetsLost)) {
remoteId = NS_LITERAL_STRING("outbound_rtcp_") + idstr;
RTCInboundRTPStreamStats s;
s.mTimestamp.Construct(timestamp);
@ -2009,6 +2011,7 @@ PeerConnectionImpl::GetStatsImpl_s(
s.mIsRemote = true;
s.mPacketsReceived.Construct(packetsReceived);
s.mBytesReceived.Construct(bytesReceived);
s.mPacketsLost.Construct(packetsLost);
report->mInboundRTPStreamStats.Value().AppendElement(s);
}
}
@ -2067,9 +2070,10 @@ PeerConnectionImpl::GetStatsImpl_s(
if (ssrc.Length()) {
s.mSsrc.Construct(ssrc);
}
unsigned int jitterMs;
if (mp.Conduit()->GetRTPJitter(&jitterMs)) {
unsigned int jitterMs, packetsLost;
if (mp.Conduit()->GetRTPStats(&jitterMs, &packetsLost)) {
s.mJitter.Construct(double(jitterMs)/1000);
s.mPacketsLost.Construct(packetsLost);
}
if (remoteId.Length()) {
s.mRemoteId.Construct(remoteId);

View File

@ -3954,7 +3954,8 @@ int
Channel::GetRTPStatistics(
unsigned int& averageJitterMs,
unsigned int& maxJitterMs,
unsigned int& discardedPackets)
unsigned int& discardedPackets,
unsigned int& cumulativeLost)
{
// The jitter statistics is updated for each received RTP packet and is
// based on received packets.
@ -3975,6 +3976,7 @@ Channel::GetRTPStatistics(
// Scale RTP statistics given the current playout frequency
maxJitterMs = statistics.max_jitter / (playoutFrequency / 1000);
averageJitterMs = statistics.jitter / (playoutFrequency / 1000);
cumulativeLost = statistics.cumulative_lost;
}
discardedPackets = _numberOfDiscardedPackets;

View File

@ -275,7 +275,8 @@ public:
unsigned short dataLengthInBytes);
int GetRTPStatistics(unsigned int& averageJitterMs,
unsigned int& maxJitterMs,
unsigned int& discardedPackets);
unsigned int& discardedPackets,
unsigned int& cumulativeLost);
int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
int GetRTPStatistics(CallStatistics& stats);

View File

@ -192,7 +192,7 @@ public:
// Gets RTP statistics for a specific |channel|.
virtual int GetRTPStatistics(
int channel, unsigned int& averageJitterMs, unsigned int& maxJitterMs,
unsigned int& discardedPackets) = 0;
unsigned int& discardedPackets, unsigned int& cumulativeLost) = 0;
// Gets RTCP statistics for a specific |channel|.
virtual int GetRTCPStatistics(int channel, CallStatistics& stats) = 0;

View File

@ -440,7 +440,8 @@ int VoERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
unsigned int& averageJitterMs,
unsigned int& maxJitterMs,
unsigned int& discardedPackets)
unsigned int& discardedPackets,
unsigned int& cumulativeLost)
{
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRTPStatistics(channel=%d,....)", channel);
@ -459,7 +460,8 @@ int VoERTP_RTCPImpl::GetRTPStatistics(int channel,
}
return channelPtr->GetRTPStatistics(averageJitterMs,
maxJitterMs,
discardedPackets);
discardedPackets,
cumulativeLost);
}
int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)

View File

@ -81,7 +81,8 @@ public:
virtual int GetRTPStatistics(int channel,
unsigned int& averageJitterMs,
unsigned int& maxJitterMs,
unsigned int& discardedPackets);
unsigned int& discardedPackets,
unsigned int& cumulativeLost);
virtual int GetRTCPStatistics(int channel, CallStatistics& stats);

View File

@ -157,7 +157,7 @@ function dumpStat(stat, label) {
if (stat.bytesReceived !== undefined) {
statsString += " (" + round00(stat.bytesReceived/1024) + " Kb)";
}
statsString += " Jitter: " + stat.jitter;
statsString += " Jitter: " + stat.jitter + " Lost: " + stat.packetsLost;
} else if (stat.packetsSent !== undefined) {
statsString += " Sent: " + stat.packetsSent + " packets";
if (stat.bytesSent !== undefined) {