Add TimeMicrosToNtp to calculate current NtpTime without Clock

Bug: webrtc:6733, webrtc:8239
Change-Id: I8ac4464cd7a7ec2b2dbad44430f1141a80ba39c1
Reviewed-on: https://webrtc-review.googlesource.com/25541
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20904}
This commit is contained in:
Danil Chapovalov
2017-11-28 10:26:54 +01:00
committed by Commit Bot
parent fb09eeb8f1
commit 2492984441
3 changed files with 84 additions and 3 deletions

View File

@ -17,6 +17,13 @@
namespace webrtc {
// Converts time obtained using rtc::TimeMicros to ntp format.
// TimeMicrosToNtp guarantees difference of the returned values matches
// difference of the passed values.
// As a result TimeMicrosToNtp(rtc::TimeMicros()) doesn't guarantte to match
// system time after first call.
NtpTime TimeMicrosToNtp(int64_t time_us);
// Converts NTP timestamp to RTP timestamp.
inline uint32_t NtpToRtp(NtpTime ntp, uint32_t freq) {
uint32_t tmp = (static_cast<uint64_t>(ntp.fractions()) * freq) >> 32;