Rename corruption related metrics according to WebRTC's Statistics API.

See https://www.w3.org/TR/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalcorruptionprobability for more details.

Bug: webrtc:358039777
Change-Id: I34236b9423864008486a9f9949f46397ff8b9f92
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/367960
Commit-Queue: Emil Vardar (xWF) <vardar@google.com>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43379}
This commit is contained in:
Emil Vardar 2024-11-08 09:56:44 +00:00 committed by WebRTC LUCI CQ
parent 6c8b8e0a2b
commit 416cb498cc
7 changed files with 30 additions and 29 deletions

View file

@ -297,10 +297,9 @@ class RTC_EXPORT RTCInboundRtpStreamStats final
std::optional<uint32_t> pli_count;
std::optional<uint32_t> nack_count;
std::optional<uint64_t> qp_sum;
// https://webrtc.googlesource.com/src/+/refs/heads/main/docs/native-code/rtp-hdrext/corruption-detection
std::optional<double> corruption_score_sum;
std::optional<double> corruption_score_squared_sum;
std::optional<uint32_t> corruption_score_count;
std::optional<double> total_corruption_probability;
std::optional<double> total_squared_corruption_probability;
std::optional<uint64_t> corruption_measurements;
// This is a remnant of the legacy getStats() API. When the "video-timing"
// header extension is used,
// https://webrtc.github.io/webrtc-org/experiments/rtp-hdrext/video-timing/,

View file

@ -4142,20 +4142,20 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
for (const auto& stat : inbound_stream_stats) {
if (*stat->kind == "video") {
if (pair == caller()) {
EXPECT_TRUE(stat->corruption_score_sum.has_value());
EXPECT_TRUE(stat->corruption_score_squared_sum.has_value());
EXPECT_TRUE(stat->total_corruption_probability.has_value());
EXPECT_TRUE(stat->total_squared_corruption_probability.has_value());
double average_corruption_score =
(*stat->corruption_score_sum) /
static_cast<int32_t>(*stat->corruption_score_count);
(*stat->total_corruption_probability) /
static_cast<int32_t>(*stat->corruption_measurements);
EXPECT_GE(average_corruption_score, 0.0);
EXPECT_LE(average_corruption_score, 1.0);
}
if (pair == callee()) {
// Since only `caller` requests corruption score calculation the
// callee should not aggregate it.
EXPECT_FALSE(stat->corruption_score_sum.has_value());
EXPECT_FALSE(stat->corruption_score_squared_sum.has_value());
EXPECT_FALSE(stat->total_corruption_probability.has_value());
EXPECT_FALSE(stat->total_squared_corruption_probability.has_value());
}
}
}
@ -4196,12 +4196,12 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
report->GetStatsOfType<RTCInboundRtpStreamStats>();
for (const auto& stat : inbound_stream_stats) {
if (*stat->kind == "video") {
EXPECT_TRUE(stat->corruption_score_sum.has_value());
EXPECT_TRUE(stat->corruption_score_squared_sum.has_value());
EXPECT_TRUE(stat->total_corruption_probability.has_value());
EXPECT_TRUE(stat->total_squared_corruption_probability.has_value());
double average_corruption_score =
(*stat->corruption_score_sum) /
static_cast<int32_t>(*stat->corruption_score_count);
(*stat->total_corruption_probability) /
static_cast<int32_t>(*stat->corruption_measurements);
EXPECT_GE(average_corruption_score, 0.0);
EXPECT_LE(average_corruption_score, 1.0);
}
@ -4245,8 +4245,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
report->GetStatsOfType<RTCInboundRtpStreamStats>();
for (const auto& stat : inbound_stream_stats) {
if (*stat->kind == "video") {
EXPECT_FALSE(stat->corruption_score_sum.has_value());
EXPECT_FALSE(stat->corruption_score_squared_sum.has_value());
EXPECT_FALSE(stat->total_corruption_probability.has_value());
EXPECT_FALSE(stat->total_squared_corruption_probability.has_value());
}
}
}

View file

@ -627,11 +627,11 @@ CreateInboundRTPStreamStatsFromVideoReceiverInfo(
if (video_receiver_info.corruption_score_sum.has_value()) {
RTC_CHECK(video_receiver_info.corruption_score_squared_sum.has_value());
RTC_CHECK_GT(video_receiver_info.corruption_score_count, 0);
inbound_video->corruption_score_sum =
inbound_video->total_corruption_probability =
*video_receiver_info.corruption_score_sum;
inbound_video->corruption_score_squared_sum =
inbound_video->total_squared_corruption_probability =
*video_receiver_info.corruption_score_squared_sum;
inbound_video->corruption_score_count =
inbound_video->corruption_measurements =
video_receiver_info.corruption_score_count;
}
if (video_receiver_info.timing_frame_info.has_value()) {

View file

@ -2459,9 +2459,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Video) {
video_media_info.receivers[0].corruption_score_sum = 0.5;
video_media_info.receivers[0].corruption_score_squared_sum = 0.25;
video_media_info.receivers[0].corruption_score_count = 5;
expected_video.corruption_score_sum = 0.5;
expected_video.corruption_score_squared_sum = 0.25;
expected_video.corruption_score_count = 5;
expected_video.total_corruption_probability = 0.5;
expected_video.total_squared_corruption_probability = 0.25;
expected_video.corruption_measurements = 5;
video_media_info.receivers[0].last_packet_received = Timestamp::Seconds(1);
expected_video.last_packet_received_timestamp = 1000.0;
video_media_info.receivers[0].content_type = VideoContentType::SCREENSHARE;

View file

@ -563,10 +563,11 @@ class RTCStatsReportVerifier {
// As long as the corruption detection RTP header extension is not activated
// it should not aggregate any corruption score. The tests where this header
// extension is enabled are located in pc/peer_connection_integrationtest.cc
verifier.TestAttributeIsUndefined(inbound_stream.corruption_score_sum);
verifier.TestAttributeIsUndefined(
inbound_stream.corruption_score_squared_sum);
verifier.TestAttributeIsUndefined(inbound_stream.corruption_score_count);
inbound_stream.total_corruption_probability);
verifier.TestAttributeIsUndefined(
inbound_stream.total_squared_corruption_probability);
verifier.TestAttributeIsUndefined(inbound_stream.corruption_measurements);
verifier.TestAttributeIsNonNegative<uint32_t>(
inbound_stream.packets_received);
if (inbound_stream.kind.has_value() && *inbound_stream.kind == "audio") {

View file

@ -750,7 +750,7 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver,
report->GetStatsOfType<RTCInboundRtpStreamStats>();
for (const auto& stat : inbound_stream_stats) {
if (*stat->kind == "video") {
return stat->corruption_score_count.value_or(0);
return stat->corruption_measurements.value_or(0);
}
}
return 0;

View file

@ -267,9 +267,10 @@ WEBRTC_RTCSTATS_IMPL(
AttributeInit("pliCount", &pli_count),
AttributeInit("nackCount", &nack_count),
AttributeInit("qpSum", &qp_sum),
AttributeInit("corruptionScoreSum", &corruption_score_sum),
AttributeInit("corruptionScoreSumSquared", &corruption_score_squared_sum),
AttributeInit("corruptionScoreCount", &corruption_score_count),
AttributeInit("totalCorruptionProbability", &total_corruption_probability),
AttributeInit("totalSquaredCorruptionProbability",
&total_squared_corruption_probability),
AttributeInit("corruptionMeasurements", &corruption_measurements),
AttributeInit("googTimingFrameInfo", &goog_timing_frame_info),
AttributeInit("powerEfficientDecoder", &power_efficient_decoder),
AttributeInit("jitterBufferFlushes", &jitter_buffer_flushes),