Introduce MicrosecondsToCompactNtp function
webrtc clocks use 10based fraction time to calculate intervals.
Rtcp require 16based fraction time to report intervals.
Bug: webrtc:8239
Change-Id: I25cab5ad7b7614c86c174813a195e7ba767ee43b
Reviewed-on: https://webrtc-review.googlesource.com/21383
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20619}
diff --git a/modules/rtp_rtcp/source/time_util.h b/modules/rtp_rtcp/source/time_util.h
index d13e080..a87a5b7 100644
--- a/modules/rtp_rtcp/source/time_util.h
+++ b/modules/rtp_rtcp/source/time_util.h
@@ -34,6 +34,11 @@
inline uint32_t CompactNtp(NtpTime ntp) {
return (ntp.seconds() << 16) | (ntp.fractions() >> 16);
}
+
+// Converts interval in microseconds to compact ntp (1/2^16 seconds) resolution.
+// Negative values converted to 0, Overlarge values converted to max uint32_t.
+uint32_t SaturatedUsToCompactNtp(int64_t us);
+
// Converts interval between compact ntp timestamps to milliseconds.
// This interval can be up to ~9.1 hours (2^15 seconds).
// Values close to 2^16 seconds consider negative and result in minimum rtt = 1.