From 64773fee9c27543555c66c5c0a062ff96a2630c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 7 Jun 2015 08:59:23 +0200 Subject: [PATCH] ptpclock: Use the current path delay for calculation the local/remote clock times The mean might currently be changing, and the current path delay is the closest we can get to the actual delay around the current SYNC message. --- libs/gst/net/gstptpclock.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/gst/net/gstptpclock.c b/libs/gst/net/gstptpclock.c index 3d8cccec7c..37d13d9e07 100644 --- a/libs/gst/net/gstptpclock.c +++ b/libs/gst/net/gstptpclock.c @@ -1048,15 +1048,29 @@ update_ptp_time (PtpDomainData * domain, PtpPendingSync * sync) #endif #ifdef USE_ONLY_SYNC_WITH_DELAY + GstClockTime mean_path_delay; + if (sync->delay_req_send_time_local == GST_CLOCK_TIME_NONE) return; + + /* IEEE 1588 11.3 */ + mean_path_delay = + (sync->delay_req_recv_time_remote - sync->sync_send_time_remote + + sync->sync_recv_time_local - sync->delay_req_send_time_local - + (sync->correction_field_sync + sync->correction_field_delay + + 32768) / 65536) / 2; #endif /* IEEE 1588 11.2 */ corrected_ptp_time = sync->sync_send_time_remote + (sync->correction_field_sync + 32768) / 65536; + +#ifdef USE_ONLY_SYNC_WITH_DELAY + corrected_local_time = sync->sync_recv_time_local - mean_path_delay; +#else corrected_local_time = sync->sync_recv_time_local - domain->mean_path_delay; +#endif #ifdef USE_MEASUREMENT_FILTERING /* We check this here and when updating the mean path delay, because