diff --git a/dom/media/webrtc/WebrtcGlobal.h b/dom/media/webrtc/WebrtcGlobal.h index 3c637e112265..99f4181809a2 100644 --- a/dom/media/webrtc/WebrtcGlobal.h +++ b/dom/media/webrtc/WebrtcGlobal.h @@ -300,12 +300,17 @@ struct ParamTraits { WriteParam(aWriter, aParam.mFramesDecoded); WriteParam(aWriter, aParam.mFrameWidth); WriteParam(aWriter, aParam.mFrameHeight); + WriteParam(aWriter, aParam.mFramesPerSecond); WriteParam(aWriter, aParam.mBytesReceived); WriteParam(aWriter, aParam.mNackCount); WriteParam(aWriter, aParam.mFirCount); WriteParam(aWriter, aParam.mPliCount); - WriteParam(aWriter, aParam.mFramesPerSecond); WriteParam(aWriter, aParam.mFramesReceived); + WriteParam(aWriter, aParam.mJitterBufferDelay); + WriteParam(aWriter, aParam.mJitterBufferEmittedCount); + WriteParam(aWriter, aParam.mTotalSamplesReceived); + WriteParam(aWriter, aParam.mConcealedSamples); + WriteParam(aWriter, aParam.mSilentConcealedSamples); WriteRTCReceivedRtpStreamStats(aWriter, aParam); } @@ -314,12 +319,17 @@ struct ParamTraits { ReadParam(aReader, &(aResult->mFramesDecoded)) && ReadParam(aReader, &(aResult->mFrameWidth)) && ReadParam(aReader, &(aResult->mFrameHeight)) && + ReadParam(aReader, &(aResult->mFramesPerSecond)) && ReadParam(aReader, &(aResult->mBytesReceived)) && ReadParam(aReader, &(aResult->mNackCount)) && ReadParam(aReader, &(aResult->mFirCount)) && ReadParam(aReader, &(aResult->mPliCount)) && - ReadParam(aReader, &(aResult->mFramesPerSecond)) && ReadParam(aReader, &(aResult->mFramesReceived)) && + ReadParam(aReader, &(aResult->mJitterBufferDelay)) && + ReadParam(aReader, &(aResult->mJitterBufferEmittedCount)) && + ReadParam(aReader, &(aResult->mTotalSamplesReceived)) && + ReadParam(aReader, &(aResult->mConcealedSamples)) && + ReadParam(aReader, &(aResult->mSilentConcealedSamples)) && ReadRTCReceivedRtpStreamStats(aReader, aResult); } }; diff --git a/dom/media/webrtc/jsapi/RTCRtpReceiver.cpp b/dom/media/webrtc/jsapi/RTCRtpReceiver.cpp index 2e2702f573f1..5f81e35eea6d 100644 --- a/dom/media/webrtc/jsapi/RTCRtpReceiver.cpp +++ b/dom/media/webrtc/jsapi/RTCRtpReceiver.cpp @@ -314,6 +314,15 @@ nsTArray> RTCRtpReceiver::GetStatsInternal() { local.mPacketsReceived.Construct(audioStats->packets_rcvd); local.mPacketsDiscarded.Construct(audioStats->packets_discarded); local.mBytesReceived.Construct(audioStats->payload_bytes_rcvd); + local.mJitterBufferDelay.Construct( + audioStats->jitter_buffer_delay_seconds); + local.mJitterBufferEmittedCount.Construct( + audioStats->jitter_buffer_emitted_count); + local.mTotalSamplesReceived.Construct( + audioStats->total_samples_received); + local.mConcealedSamples.Construct(audioStats->concealed_samples); + local.mSilentConcealedSamples.Construct( + audioStats->silent_concealed_samples); /* * Potential new stats that are now available upstream. if (audioStats->last_packet_received_timestamp_ms) { @@ -335,15 +344,6 @@ nsTArray> RTCRtpReceiver::GetStatsInternal() { webrtc::Timestamp::Millis( *audioStats->estimated_playout_ntp_timestamp_ms))); } - local.mJitterBufferDelay.Construct( - audioStats->jitter_buffer_delay_seconds); - local.mJitterBufferEmittedCount.Construct( - audioStats->jitter_buffer_emitted_count); - local.mTotalSamplesReceived.Construct( - audioStats->total_samples_received); - local.mConcealedSamples.Construct(audioStats->concealed_samples); - local.mSilentConcealedSamples.Construct( - audioStats->silent_concealed_samples); local.mConcealmentEvents.Construct( audioStats->concealment_events); local.mInsertedSamplesForDeceleration.Construct( @@ -435,7 +435,10 @@ nsTArray> RTCRtpReceiver::GetStatsInternal() { local.mFramesReceived.Construct( videoStats->frame_counts.key_frames + videoStats->frame_counts.delta_frames); - + local.mJitterBufferDelay.Construct( + videoStats->jitter_buffer_delay_seconds); + local.mJitterBufferEmittedCount.Construct( + videoStats->jitter_buffer_emitted_count); /* * Potential new stats that are now available upstream. if (videoStats->qp_sum) { @@ -464,10 +467,6 @@ nsTArray> RTCRtpReceiver::GetStatsInternal() { webrtc::Timestamp::Millis( *videoStats->estimated_playout_ntp_timestamp_ms))); } - local.mJitterBufferDelay.Construct( - videoStats->jitter_buffer_delay_seconds); - local.mJitterBufferEmittedCount.Construct( - videoStats->jitter_buffer_emitted_count); local.mFramesReceived.Construct( videoStats->frame_counts.key_frames + videoStats->frame_counts.delta_frames); diff --git a/dom/media/webrtc/tests/mochitests/stats.js b/dom/media/webrtc/tests/mochitests/stats.js index da64064660ea..b9ab2d869fca 100644 --- a/dom/media/webrtc/tests/mochitests/stats.js +++ b/dom/media/webrtc/tests/mochitests/stats.js @@ -19,6 +19,8 @@ const statsExpectedByType = { "packetsDiscarded", "bytesReceived", "jitter", + "jitterBufferDelay", + "jitterBufferEmittedCount", ], optional: ["remoteId", "nackCount"], localVideoOnly: [ @@ -31,6 +33,11 @@ const statsExpectedByType = { "frameHeight", "framesReceived", ], + localAudioOnly: [ + "totalSamplesReceived", + "concealedSamples", + "silentConcealedSamples", + ], unimplemented: [ "mediaTrackId", "transportId", @@ -65,6 +72,7 @@ const statsExpectedByType = { "retransmittedBytesSent", ], optional: ["nackCount", "qpSum"], + localAudioOnly: [], localVideoOnly: [ "framesEncoded", "firCount", @@ -230,7 +238,7 @@ const statsExpectedByType = { ["in", "out"].forEach(pre => { let s = statsExpectedByType[pre + "bound-rtp"]; - s.optional = [...s.optional, ...s.localVideoOnly]; + s.optional = [...s.optional, ...s.localVideoOnly, ...s.localAudioOnly]; }); // @@ -490,10 +498,67 @@ function pedanticChecks(report) { `local only test. value=${stat.jitter}` ); + // jitterBufferEmittedCount + let expectedJitterBufferEmmitedCount = stat.kind == "video" ? 10 : 1000; + ok( + stat.jitterBufferEmittedCount > expectedJitterBufferEmmitedCount, + `${stat.type}.jitterBufferEmittedCount is a sane number for a short ` + + `${stat.kind} test. value=${stat.jitterBufferEmittedCount}` + ); + + // jitterBufferDelay + let avgJitterBufferDelay = + stat.jitterBufferDelay / stat.jitterBufferEmittedCount; + ok( + avgJitterBufferDelay > 0.01 && avgJitterBufferDelay < 10, + `${stat.type}.jitterBufferDelay is a sane number for a short ` + + `${stat.kind} test. value=${stat.jitterBufferDelay}/${stat.jitterBufferEmittedCount}=${avgJitterBufferDelay}` + ); + // // Optional fields // + // + // Local audio only stats + // + if (stat.inner.kind != "audio") { + expectations.localAudioOnly.forEach(field => { + ok( + stat[field] === undefined, + `${stat.type} does not have field ${field}` + + ` when kind is not 'audio'` + ); + }); + } else { + expectations.localAudioOnly.forEach(field => { + ok( + stat.inner[field] !== undefined, + stat.type + " has field " + field + " when kind is video" + ); + }); + // totalSamplesReceived + ok( + stat.totalSamplesReceived > 1000, + `${stat.type}.totalSamplesReceived is a sane number for a short ` + + `${stat.kind} test. value=${stat.totalSamplesReceived}` + ); + + // concealedSamples + ok( + stat.concealedSamples > 100, + `${stat.type}.concealedSamples is a sane number for a short ` + + `${stat.kind} test. value=${stat.concealedSamples}` + ); + + // silentConcealedSamples + ok( + stat.silentConcealedSamples >= 0, + `${stat.type}.silentConcealedSamples is a sane number for a short ` + + `${stat.kind} test. value=${stat.silentConcealedSamples}` + ); + } + // // Local video only stats // diff --git a/dom/webidl/RTCStatsReport.webidl b/dom/webidl/RTCStatsReport.webidl index 8d3ffbd13c85..ee5f3c85e107 100644 --- a/dom/webidl/RTCStatsReport.webidl +++ b/dom/webidl/RTCStatsReport.webidl @@ -6,6 +6,7 @@ * The origin of this IDL file is * http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcstatsreport-object * http://www.w3.org/2011/04/webrtc/wiki/Stats + * https://www.w3.org/TR/webrtc-stats/ */ enum RTCStatsType { @@ -66,11 +67,16 @@ dictionary RTCInboundRtpStreamStats : RTCReceivedRtpStreamStats { unsigned long framesDecoded; unsigned long frameWidth; unsigned long frameHeight; + double framesPerSecond; unsigned long long bytesReceived; unsigned long nackCount; unsigned long firCount; unsigned long pliCount; - double framesPerSecond; + double jitterBufferDelay; + unsigned long long jitterBufferEmittedCount; + unsigned long long totalSamplesReceived; + unsigned long long concealedSamples; + unsigned long long silentConcealedSamples; unsigned long framesReceived; }; diff --git a/testing/web-platform/meta/webrtc-stats/supported-stats.html.ini b/testing/web-platform/meta/webrtc-stats/supported-stats.html.ini index c3a6cfc2dc7d..74b44befe3b6 100644 --- a/testing/web-platform/meta/webrtc-stats/supported-stats.html.ini +++ b/testing/web-platform/meta/webrtc-stats/supported-stats.html.ini @@ -35,21 +35,6 @@ [inbound-rtp's estimatedPlayoutTimestamp] expected: FAIL - [inbound-rtp's jitterBufferDelay] - expected: FAIL - - [inbound-rtp's jitterBufferEmittedCount] - expected: FAIL - - [inbound-rtp's totalSamplesReceived] - expected: FAIL - - [inbound-rtp's concealedSamples] - expected: FAIL - - [inbound-rtp's silentConcealedSamples] - expected: FAIL - [inbound-rtp's concealmentEvents] expected: FAIL