From f0adf38d51a18abbbe3a6a2041ef21861cc3ea96 Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Tue, 23 Mar 2021 09:36:51 +0100 Subject: [PATCH] Fix timestamps for the remote outbound audio stream stats The timestamps must correspond to the time elapsed since the Unix epoch and not since Jan 1 1900 (which is used by the RTCP SRs). Bug: webrtc:12529,webrtc:12605 Change-Id: I6013cf3d9bf9915b5f5db8661f7b2b84231cca57 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212606 Commit-Queue: Alessio Bazzica Reviewed-by: Sam Zackrisson Cr-Commit-Position: refs/heads/master@{#33538} --- audio/channel_receive.cc | 8 ++++++-- audio/channel_receive.h | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 8b3c924e0a..dcc2d251de 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -797,10 +797,14 @@ CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const { absl::optional rtcp_sr_stats = rtp_rtcp_->GetSenderReportStats(); if (rtcp_sr_stats.has_value()) { + // Number of seconds since 1900 January 1 00:00 GMT (see + // https://tools.ietf.org/html/rfc868). + constexpr int64_t kNtpJan1970Millisecs = + 2208988800 * rtc::kNumMillisecsPerSec; stats.last_sender_report_timestamp_ms = - rtcp_sr_stats->last_arrival_timestamp.ToMs(); + rtcp_sr_stats->last_arrival_timestamp.ToMs() - kNtpJan1970Millisecs; stats.last_sender_report_remote_timestamp_ms = - rtcp_sr_stats->last_remote_timestamp.ToMs(); + rtcp_sr_stats->last_remote_timestamp.ToMs() - kNtpJan1970Millisecs; stats.sender_reports_packets_sent = rtcp_sr_stats->packets_sent; stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent; stats.sender_reports_reports_count = rtcp_sr_stats->reports_count; diff --git a/audio/channel_receive.h b/audio/channel_receive.h index 261357d578..c55968b55f 100644 --- a/audio/channel_receive.h +++ b/audio/channel_receive.h @@ -58,7 +58,7 @@ struct CallReceiveStatistics { int64_t payload_bytes_rcvd = 0; int64_t header_and_padding_bytes_rcvd = 0; int packetsReceived; - // The capture ntp time (in local timebase) of the first played out audio + // The capture NTP time (in local timebase) of the first played out audio // frame. int64_t capture_start_ntp_time_ms_; // The timestamp at which the last packet was received, i.e. the time of the @@ -66,6 +66,8 @@ struct CallReceiveStatistics { // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp absl::optional last_packet_received_timestamp_ms; // Remote outbound stats derived by the received RTCP sender reports. + // Note that the timestamps below correspond to the time elapsed since the + // Unix epoch. // https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict* absl::optional last_sender_report_timestamp_ms; absl::optional last_sender_report_remote_timestamp_ms;