Revert "Migrate RemoteNtpTimeEstimator to more precise time representations"

This reverts commit a154a15c978a0eae133d957dcad3581fd5f98c7b.

Reason for revert: breaks downstream tests

Original change's description:
> Migrate RemoteNtpTimeEstimator to more precise time representations
>
> Bug: webrtc:13757
> Change-Id: I880ab3cc6e4f72da587ae42ddca051332907c07f
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261311
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org>
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Emil Lundmark <lndmrk@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36817}

Bug: webrtc:13757
Change-Id: Id21edb1378e6e944b24955396250ddc33fa70663
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261722
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36819}
This commit is contained in:
Danil Chapovalov
2022-05-09 15:40:05 +00:00
committed by WebRTC LUCI CQ
parent cb7c7366d0
commit 853a407273
9 changed files with 117 additions and 171 deletions

View File

@ -13,10 +13,7 @@
#include <stdint.h>
#include "absl/base/attributes.h"
#include "absl/types/optional.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "rtc_base/numerics/moving_median_filter.h"
#include "system_wrappers/include/rtp_to_ntp_estimator.h"
@ -31,63 +28,32 @@ class Clock;
class RemoteNtpTimeEstimator {
public:
explicit RemoteNtpTimeEstimator(Clock* clock);
~RemoteNtpTimeEstimator();
RemoteNtpTimeEstimator(const RemoteNtpTimeEstimator&) = delete;
RemoteNtpTimeEstimator& operator=(const RemoteNtpTimeEstimator&) = delete;
~RemoteNtpTimeEstimator() = default;
// Updates the estimator with round trip time `rtt`, NTP seconds `ntp_secs`,
// NTP fraction `ntp_frac` and RTP timestamp `rtp_timestamp`.
ABSL_DEPRECATED(
"Use UpdateRtcpTimestamp with strict time types: TimeDelta and NtpTime.")
bool UpdateRtcpTimestamp(int64_t rtt,
uint32_t ntp_secs,
uint32_t ntp_frac,
uint32_t rtp_timestamp) {
return UpdateRtcpTimestamp(TimeDelta::Millis(rtt),
NtpTime(ntp_secs, ntp_frac), rtp_timestamp);
}
bool UpdateRtcpTimestamp(TimeDelta rtt,
NtpTime sender_send_time,
uint32_t rtp_timestamp);
// Estimates the NTP timestamp in local timebase from `rtp_timestamp`.
// Returns the NTP timestamp in ms when success. -1 if failed.
int64_t Estimate(uint32_t rtp_timestamp) {
NtpTime ntp_time = EstimateNtp(rtp_timestamp);
if (!ntp_time.Valid()) {
return -1;
}
return ntp_time.ToMs();
}
// Estimates the NTP timestamp in local timebase from `rtp_timestamp`.
// Returns invalid NtpTime (i.e. NtpTime(0)) on failure.
NtpTime EstimateNtp(uint32_t rtp_timestamp);
int64_t Estimate(uint32_t rtp_timestamp);
// Estimates the offset, in milliseconds, between the remote clock and the
// local one. This is equal to local NTP clock - remote NTP clock.
ABSL_DEPRECATED("Use EstimateRemoteToLocalClockOffset.")
absl::optional<int64_t> EstimateRemoteToLocalClockOffsetMs() {
if (absl::optional<int64_t> offset = EstimateRemoteToLocalClockOffset()) {
return (*offset * 1'000) / (int64_t{1} << 32);
}
return absl::nullopt;
}
// Estimates the offset between the remote clock and the
// local one. This is equal to local NTP clock - remote NTP clock.
// The offset is returned in ntp time resolution, i.e. 1/2^32 sec ~= 0.2 ns.
// Returns nullopt on failure.
absl::optional<int64_t> EstimateRemoteToLocalClockOffset();
absl::optional<int64_t> EstimateRemoteToLocalClockOffsetMs();
private:
Clock* clock_;
// Offset is measured with the same precision as NtpTime: in 1/2^32 seconds ~=
// 0.2 ns.
MovingMedianFilter<int64_t> ntp_clocks_offset_estimator_;
RtpToNtpEstimator rtp_to_ntp_;
Timestamp last_timing_log_ = Timestamp::MinusInfinity();
int64_t last_timing_log_ms_;
};
} // namespace webrtc