Populate jitter stats for video RTP streams
Trying to take my first stab at contributing to WebRTC and I chose to populate jitter stats for video RTP streams. Please yell at me if this isn't something I'm not supposed to pick up. Appreciate a review, thanks!
Bug: webrtc:12487
Change-Id: Ifda985e9e20b1d87e4a7268f34ef2e45b1cbefa3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208360
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33325}
diff --git a/AUTHORS b/AUTHORS
index c20602b..ce35bb3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -36,6 +36,7 @@
Dax Booysen <dax@younow.com>
Dennis Angelo <dennis.angelo@gmail.com>
Dharmesh Chauhan <dharmesh.r.chauhan@gmail.com>
+Di Wu <meetwudi@gmail.com>
Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
Dmitry Lizin <sdkdimon@gmail.com>
Eike Rathke <erathke@redhat.com>
diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h
index ee3d707..7e0970d 100644
--- a/api/stats/rtcstats_objects.h
+++ b/api/stats/rtcstats_objects.h
@@ -417,8 +417,6 @@
RTCStatsMember<uint64_t> header_bytes_received;
RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
RTCStatsMember<double> last_packet_received_timestamp;
- // TODO(hbos): Collect and populate this value for both "audio" and "video",
- // currently not collected for "video". https://bugs.webrtc.org/7065
RTCStatsMember<double> jitter;
RTCStatsMember<double> jitter_buffer_delay;
RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
diff --git a/media/base/media_channel.h b/media/base/media_channel.h
index 79b3c2b..fbe2df9 100644
--- a/media/base/media_channel.h
+++ b/media/base/media_channel.h
@@ -616,6 +616,7 @@
uint32_t total_pauses_duration_ms = 0;
uint32_t total_frames_duration_ms = 0;
double sum_squared_frame_durations = 0.0;
+ uint32_t jitter_ms = 0;
webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED;
diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc
index 6c8b72b..d5b0f40 100644
--- a/media/engine/webrtc_video_engine.cc
+++ b/media/engine/webrtc_video_engine.cc
@@ -3057,6 +3057,7 @@
stats.rtp_stats.packet_counter.padding_bytes;
info.packets_rcvd = stats.rtp_stats.packet_counter.packets;
info.packets_lost = stats.rtp_stats.packets_lost;
+ info.jitter_ms = stats.rtp_stats.jitter;
info.framerate_rcvd = stats.network_frame_rate;
info.framerate_decoded = stats.decode_frame_rate;
diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc
index 139b33f..5a741a1 100644
--- a/pc/rtc_stats_collector.cc
+++ b/pc/rtc_stats_collector.cc
@@ -374,6 +374,8 @@
inbound_video->codec_id = RTCCodecStatsIDFromMidDirectionAndPayload(
mid, true, *video_receiver_info.codec_payload_type);
}
+ inbound_video->jitter = static_cast<double>(video_receiver_info.jitter_ms) /
+ rtc::kNumMillisecsPerSec;
inbound_video->fir_count =
static_cast<uint32_t>(video_receiver_info.firs_sent);
inbound_video->pli_count =
diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc
index 73579ff..cb300e0 100644
--- a/pc/rtc_stats_collector_unittest.cc
+++ b/pc/rtc_stats_collector_unittest.cc
@@ -1895,6 +1895,7 @@
video_media_info.receivers[0].total_decode_time_ms = 9000;
video_media_info.receivers[0].total_inter_frame_delay = 0.123;
video_media_info.receivers[0].total_squared_inter_frame_delay = 0.00456;
+ video_media_info.receivers[0].jitter_ms = 1199;
video_media_info.receivers[0].last_packet_received_timestamp_ms =
absl::nullopt;
@@ -1942,6 +1943,7 @@
expected_video.total_decode_time = 9.0;
expected_video.total_inter_frame_delay = 0.123;
expected_video.total_squared_inter_frame_delay = 0.00456;
+ expected_video.jitter = 1.199;
// |expected_video.last_packet_received_timestamp| should be undefined.
// |expected_video.content_type| should be undefined.
// |expected_video.decoder_implementation| should be undefined.
diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc
index e2d7c35..6288f60 100644
--- a/pc/rtc_stats_integrationtest.cc
+++ b/pc/rtc_stats_integrationtest.cc
@@ -836,7 +836,7 @@
verifier.TestMemberIsUndefined(inbound_stream.frame_bit_depth);
if (inbound_stream.media_type.is_defined() &&
*inbound_stream.media_type == "video") {
- verifier.TestMemberIsUndefined(inbound_stream.jitter);
+ verifier.TestMemberIsNonNegative<double>(inbound_stream.jitter);
verifier.TestMemberIsUndefined(inbound_stream.jitter_buffer_delay);
verifier.TestMemberIsUndefined(
inbound_stream.jitter_buffer_emitted_count);