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 <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33538}
This commit is contained in:
Alessio Bazzica
2021-03-23 09:36:51 +01:00
committed by Commit Bot
parent 3889de1c4c
commit f0adf38d51
2 changed files with 9 additions and 3 deletions

View File

@ -797,10 +797,14 @@ CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const {
absl::optional<RtpRtcpInterface::SenderReportStats> 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;

View File

@ -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<int64_t> 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<int64_t> last_sender_report_timestamp_ms;
absl::optional<int64_t> last_sender_report_remote_timestamp_ms;