From 5b8d76cfbe45edf36e3be7f776d96b8c69e3b14f Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 1 Jun 2021 22:30:31 +0100 Subject: [PATCH] When the master clock returns to what the real anchor clock is, the difference between the actual and estimate is calculated and logged. Might have to actually use it... --- rtp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rtp.c b/rtp.c index 8d8e0680..270866f5 100644 --- a/rtp.c +++ b/rtp.c @@ -1329,13 +1329,19 @@ int get_ptp_anchor_local_time_info(rtsp_conn_info *conn, uint32_t *anchorRTP, // but if the master clock has become equal to the actual anchor clock // then we can reinstate it all + // first, calculate the cumulative offset after swapping all the clocks... + conn->anchor_time = conn->last_anchor_local_time + actual_offset; + // we can check how much of a deviation there was going from clock to clock and bakc around to the master clock + + if (actual_clock_id == conn->actual_anchor_clock) { - debug(1, "Master clock has become equal to the anchor clock"); + int64_t cumulative_deviation = conn->actual_anchor_time - conn->anchor_time; + debug(1, "Master clock has become equal to the anchor clock. The actual clock is %f ms ahead/behind (+/-) the calculated clock.", 0.000001 * cumulative_deviation); conn->anchor_clock = conn->actual_anchor_clock; conn->anchor_time = conn->actual_anchor_time; conn->anchor_rtptime = conn->actual_anchor_rtptime; } else { - conn->anchor_time = conn->last_anchor_local_time + actual_offset; + // conn->anchor_time = conn->last_anchor_local_time + actual_offset; // already done conn->anchor_clock = actual_clock_id; } }