Reland of "Use moving median filters in RemoteNtpTimeEstimator, RtpToNtpEstimator""
Use moving median filters in RemoteNtpTimeEstimator, RtpToNtpEstimator If Webrtc-ClockEstimation experiment is enabled, median filtering is applied to results of RtpToNtpEstimator and RemoteNtpEstimator to smooth out random errors introduced by incorrect RTCP SR reports and networking delays. Bug: webrtc:8468 Change-Id: I592c4083fefc0dbdebe7b3ff30b92e95ba337595 NOTRY=TRUE NOPRESUBMIT=TRUE Change-Id: I592c4083fefc0dbdebe7b3ff30b92e95ba337595 Reviewed-on: https://webrtc-review.googlesource.com/23263 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20708}
This commit is contained in:
committed by
Commit Bot
parent
da850ef88b
commit
8b64fd8a85
@ -15,6 +15,7 @@
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "modules/include/module_common_types_public.h"
|
||||
#include "rtc_base/numerics/moving_median_filter.h"
|
||||
#include "system_wrappers/include/ntp_time.h"
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
|
||||
@ -40,8 +41,23 @@ class RtpToNtpEstimator {
|
||||
|
||||
// Estimated parameters from RTP and NTP timestamp pairs in |measurements_|.
|
||||
struct Parameters {
|
||||
// Implicit conversion from int because MovingMedianFilter returns 0
|
||||
// internally if no samples are present. However, it should never happen as
|
||||
// we don't ask smoothing_filter_ to return anything if there were no
|
||||
// samples.
|
||||
Parameters(const int& value) { // NOLINT
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
Parameters() : frequency_khz(0.0), offset_ms(0.0) {}
|
||||
|
||||
double frequency_khz;
|
||||
double offset_ms;
|
||||
|
||||
// Needed to make it work inside MovingMedianFilter
|
||||
bool operator<(const Parameters& other) const;
|
||||
bool operator==(const Parameters& other) const;
|
||||
bool operator<=(const Parameters& other) const;
|
||||
bool operator!=(const Parameters& other) const;
|
||||
};
|
||||
|
||||
// Updates measurements with RTP/NTP timestamp pair from a RTCP sender report.
|
||||
@ -55,13 +71,8 @@ class RtpToNtpEstimator {
|
||||
// Returns true on success, false otherwise.
|
||||
bool Estimate(int64_t rtp_timestamp, int64_t* rtp_timestamp_ms) const;
|
||||
|
||||
const rtc::Optional<Parameters> params() const {
|
||||
rtc::Optional<Parameters> res;
|
||||
if (params_calculated_) {
|
||||
res.emplace(params_);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// Returns estimated rtp to ntp linear transform parameters.
|
||||
const rtc::Optional<Parameters> params() const;
|
||||
|
||||
static const int kMaxInvalidSamples = 3;
|
||||
|
||||
@ -71,8 +82,10 @@ class RtpToNtpEstimator {
|
||||
int consecutive_invalid_samples_;
|
||||
std::list<RtcpMeasurement> measurements_;
|
||||
Parameters params_;
|
||||
MovingMedianFilter<Parameters> smoothing_filter_;
|
||||
bool params_calculated_;
|
||||
mutable TimestampUnwrapper unwrapper_;
|
||||
const bool is_experiment_enabled_;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user