Add stats for frequency offset when converting RTP timestamp to NTP time.
- Add histogram: "WebRTC.Video.RtpToNtpFreqOffsetInKhz"
The absolute value of the difference between the estimated frequency during RTP timestamp to NTP time conversion and the actual value (i.e. 90 kHz) is measured per received video frame. The max offset during 40 second intervals is stored. The average of these stored offsets per received video stream is recorded when a stream is removed.
Updated rtp_to_ntp.cc:
- Add validation for only inserting newer RTCP sender reports to the rtcp list.
- Move calculation of frequency/offset (from RTP/NTP timestamp pairs) to UpdateRtcpList. Calculated when a new RTCP SR in inserted (and not in RtpToNtpMs per packet).
BUG=webrtc:6579
Review-Url: https://codereview.webrtc.org/2385763002
Cr-Commit-Position: refs/heads/master@{#14891}
diff --git a/webrtc/video/receive_statistics_proxy.cc b/webrtc/video/receive_statistics_proxy.cc
index e7310e8..ded510a 100644
--- a/webrtc/video/receive_statistics_proxy.cc
+++ b/webrtc/video/receive_statistics_proxy.cc
@@ -18,6 +18,10 @@
#include "webrtc/system_wrappers/include/metrics.h"
namespace webrtc {
+namespace {
+// Periodic time interval for processing samples for |freq_offset_counter_|.
+const int64_t kFreqOffsetProcessIntervalMs = 40000;
+} // namespace
ReceiveStatisticsProxy::ReceiveStatisticsProxy(
const VideoReceiveStream::Config* config,
@@ -29,7 +33,8 @@
decode_fps_estimator_(1000, 1000),
renders_fps_estimator_(1000, 1000),
render_fps_tracker_(100, 10u),
- render_pixel_tracker_(100, 10u) {
+ render_pixel_tracker_(100, 10u),
+ freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs) {
stats_.ssrc = config_.rtp.remote_ssrc;
for (auto it : config_.rtp.rtx)
rtx_stats_[it.second.ssrc] = StreamDataCounters();
@@ -68,6 +73,11 @@
if (sync_offset_ms != -1) {
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.AVSyncOffsetInMs", sync_offset_ms);
}
+ AggregatedStats freq_offset_stats = freq_offset_counter_.GetStats();
+ if (freq_offset_stats.num_samples > 0) {
+ RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtpToNtpFreqOffsetInKhz",
+ freq_offset_stats.average);
+ }
int qp = qp_counters_.vp8.Avg(kMinRequiredSamples);
if (qp != -1)
@@ -276,10 +286,19 @@
}
}
-void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms) {
+void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms,
+ double estimated_freq_khz) {
rtc::CritScope lock(&crit_);
sync_offset_counter_.Add(std::abs(sync_offset_ms));
stats_.sync_offset_ms = sync_offset_ms;
+
+ const double kMaxFreqKhz = 10000.0;
+ int offset_khz = kMaxFreqKhz;
+ // Should not be zero or negative. If so, report max.
+ if (estimated_freq_khz < kMaxFreqKhz && estimated_freq_khz > 0.0)
+ offset_khz = static_cast<int>(std::fabs(estimated_freq_khz - 90.0) + 0.5);
+
+ freq_offset_counter_.Add(offset_khz);
}
void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate,