ptpclock: Use the current path delay for calculation the local/remote clock times
authorSebastian Dröge <sebastian@centricular.com>
Sun, 7 Jun 2015 06:59:23 +0000 (08:59 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Sun, 7 Jun 2015 06:59:23 +0000 (08:59 +0200)
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

index 3d8ccce..37d13d9 100644 (file)
@@ -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