ntp: Add method to get jitter

pts-frame-sched
Andri Yngvason 2023-10-01 22:11:44 +00:00
parent edff36f211
commit 4d24c5936e
2 changed files with 14 additions and 0 deletions

View File

@ -57,3 +57,5 @@ bool ntp_client_get_best_sample(const struct ntp_client* self,
bool ntp_client_translate_server_time(const struct ntp_client* self,
uint32_t* dst, const uint32_t t);
uint32_t ntp_client_get_jitter(const struct ntp_client* self);

View File

@ -118,3 +118,15 @@ bool ntp_client_translate_server_time(const struct ntp_client* self,
*dst = (int32_t)t - sample.theta;
return true;
}
uint32_t ntp_client_get_jitter(const struct ntp_client* self)
{
uint32_t max_delta = 0;
for (int i = 0; i < self->sample_count; ++i) {
const struct ntp_sample *sample = &self->samples[i];
if (sample->delta > max_delta) {
max_delta = sample->delta;
}
}
return max_delta;
}