Add RTCStats for keyFramesEncoded, keyFramesDecoded.
This implements the correspondingly named JavaScript fields defined in
https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict* and
https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*.
Bug: webrtc:7066
Change-Id: I431045bca80bf5faf27132c54f59c1f723c92952
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143683
Commit-Queue: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28404}
diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc
index c368ec0..42d6c51 100644
--- a/pc/peer_connection_integrationtest.cc
+++ b/pc/peer_connection_integrationtest.cc
@@ -2708,6 +2708,12 @@
for (const auto& stat : outbound_stream_stats) {
ASSERT_TRUE(stat->bytes_sent.is_defined());
EXPECT_LT(0u, *stat->bytes_sent);
+ if (*stat->kind == "video") {
+ ASSERT_TRUE(stat->key_frames_encoded.is_defined());
+ EXPECT_GT(*stat->key_frames_encoded, 0u);
+ ASSERT_TRUE(stat->frames_encoded.is_defined());
+ EXPECT_GE(*stat->frames_encoded, *stat->key_frames_encoded);
+ }
ASSERT_TRUE(stat->track_id.is_defined());
const auto* track_stat =
caller_report->GetAs<webrtc::RTCMediaStreamTrackStats>(*stat->track_id);
@@ -2726,6 +2732,12 @@
for (const auto& stat : inbound_stream_stats) {
ASSERT_TRUE(stat->bytes_received.is_defined());
EXPECT_LT(0u, *stat->bytes_received);
+ if (*stat->kind == "video") {
+ ASSERT_TRUE(stat->key_frames_decoded.is_defined());
+ EXPECT_GT(*stat->key_frames_decoded, 0u);
+ ASSERT_TRUE(stat->frames_decoded.is_defined());
+ EXPECT_GE(*stat->frames_decoded, *stat->key_frames_decoded);
+ }
ASSERT_TRUE(stat->track_id.is_defined());
const auto* track_stat =
callee_report->GetAs<webrtc::RTCMediaStreamTrackStats>(*stat->track_id);
diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc
index 5e0986d..fb85092 100644
--- a/pc/rtc_stats_collector.cc
+++ b/pc/rtc_stats_collector.cc
@@ -309,6 +309,7 @@
inbound_video->nack_count =
static_cast<uint32_t>(video_receiver_info.nacks_sent);
inbound_video->frames_decoded = video_receiver_info.frames_decoded;
+ inbound_video->key_frames_decoded = video_receiver_info.key_frames_decoded;
if (video_receiver_info.qp_sum)
inbound_video->qp_sum = *video_receiver_info.qp_sum;
if (video_receiver_info.last_packet_received_timestamp_ms) {
@@ -378,6 +379,7 @@
if (video_sender_info.qp_sum)
outbound_video->qp_sum = *video_sender_info.qp_sum;
outbound_video->frames_encoded = video_sender_info.frames_encoded;
+ outbound_video->key_frames_encoded = video_sender_info.key_frames_encoded;
outbound_video->total_encode_time =
static_cast<double>(video_sender_info.total_encode_time_ms) /
rtc::kNumMillisecsPerSec;
diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc
index 11500d6..2f0e78b 100644
--- a/pc/rtc_stats_collector_unittest.cc
+++ b/pc/rtc_stats_collector_unittest.cc
@@ -1801,6 +1801,7 @@
video_media_info.receivers[0].plis_sent = 6;
video_media_info.receivers[0].nacks_sent = 7;
video_media_info.receivers[0].frames_decoded = 8;
+ video_media_info.receivers[0].key_frames_decoded = 3;
video_media_info.receivers[0].qp_sum = absl::nullopt;
video_media_info.receivers[0].last_packet_received_timestamp_ms =
absl::nullopt;
@@ -1837,6 +1838,7 @@
expected_video.bytes_received = 3;
expected_video.packets_lost = 42;
expected_video.frames_decoded = 8;
+ expected_video.key_frames_decoded = 3;
// |expected_video.qp_sum| should be undefined.
// |expected_video.last_packet_received_timestamp| should be undefined.
// |expected_video.content_type| should be undefined.
@@ -1938,6 +1940,7 @@
video_media_info.senders[0].retransmitted_bytes_sent = 60;
video_media_info.senders[0].codec_payload_type = 42;
video_media_info.senders[0].frames_encoded = 8;
+ video_media_info.senders[0].key_frames_encoded = 3;
video_media_info.senders[0].total_encode_time_ms = 9000;
video_media_info.senders[0].total_encoded_bytes_target = 1234;
video_media_info.senders[0].total_packet_send_delay_ms = 10000;
@@ -1985,6 +1988,7 @@
expected_video.bytes_sent = 6;
expected_video.retransmitted_bytes_sent = 60;
expected_video.frames_encoded = 8;
+ expected_video.key_frames_encoded = 3;
expected_video.total_encode_time = 9.0;
expected_video.total_encoded_bytes_target = 1234;
expected_video.total_packet_send_delay = 10.0;
diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc
index 4f10a1d..79d6faf 100644
--- a/pc/rtc_stats_integrationtest.cc
+++ b/pc/rtc_stats_integrationtest.cc
@@ -804,11 +804,13 @@
if (inbound_stream.media_type.is_defined() &&
*inbound_stream.media_type == "video") {
verifier.TestMemberIsDefined(inbound_stream.frames_decoded);
+ verifier.TestMemberIsDefined(inbound_stream.key_frames_decoded);
// The integration test is not set up to test screen share; don't require
// this to be present.
verifier.MarkMemberTested(inbound_stream.content_type, true);
} else {
verifier.TestMemberIsUndefined(inbound_stream.frames_decoded);
+ verifier.TestMemberIsUndefined(inbound_stream.key_frames_decoded);
verifier.TestMemberIsUndefined(inbound_stream.content_type);
}
return verifier.ExpectAllMembersSuccessfullyTested();
@@ -838,6 +840,7 @@
if (outbound_stream.media_type.is_defined() &&
*outbound_stream.media_type == "video") {
verifier.TestMemberIsDefined(outbound_stream.frames_encoded);
+ verifier.TestMemberIsDefined(outbound_stream.key_frames_encoded);
verifier.TestMemberIsNonNegative<double>(
outbound_stream.total_encode_time);
verifier.TestMemberIsNonNegative<uint64_t>(
@@ -850,6 +853,7 @@
verifier.MarkMemberTested(outbound_stream.content_type, true);
} else {
verifier.TestMemberIsUndefined(outbound_stream.frames_encoded);
+ verifier.TestMemberIsUndefined(outbound_stream.key_frames_encoded);
verifier.TestMemberIsUndefined(outbound_stream.total_encode_time);
verifier.TestMemberIsUndefined(
outbound_stream.total_encoded_bytes_target);