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}
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index 8b3c924..dcc2d25 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -797,10 +797,14 @@
   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;
diff --git a/audio/channel_receive.h b/audio/channel_receive.h
index 261357d..c55968b 100644
--- a/audio/channel_receive.h
+++ b/audio/channel_receive.h
@@ -58,7 +58,7 @@
   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 @@
   // 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;