From 6003f8f9785880e54c0d2dcede699a4d51abff41 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Sat, 30 May 2026 22:40:52 +0100 Subject: [PATCH] Handle input_rate of 0 more correctly. --- rtp.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/rtp.c b/rtp.c index f00f41db..569c8fc3 100644 --- a/rtp.c +++ b/rtp.c @@ -1508,17 +1508,11 @@ int frame_to_ptp_local_time(uint32_t timestamp, uint64_t *time, rtsp_conn_info * int result = -1; uint32_t anchor_rtptime = 0; uint64_t anchor_local_time = 0; - if (get_ptp_anchor_local_time_info(conn, &anchor_rtptime, &anchor_local_time) == clock_ok) { + if ((conn->input_rate != 0) && (get_ptp_anchor_local_time_info(conn, &anchor_rtptime, &anchor_local_time) == clock_ok)) { int32_t frame_difference = timestamp - anchor_rtptime; int64_t time_difference = frame_difference; time_difference = time_difference * 1000000000; - if (conn->input_rate == 0) { - debug(1, "Connection %d: in a call to frame_to_ptp_local_time, conn->input_rate is zero!", - conn->connection_number); - time_difference = 0; - } else { - time_difference = time_difference / conn->input_rate; - } + time_difference = time_difference / conn->input_rate; uint64_t ltime = anchor_local_time + time_difference; *time = ltime; result = 0; @@ -1532,7 +1526,7 @@ int local_ptp_time_to_frame(uint64_t time, uint32_t *frame, rtsp_conn_info *conn int result = -1; uint32_t anchor_rtptime = 0; uint64_t anchor_local_time = 0; - if (get_ptp_anchor_local_time_info(conn, &anchor_rtptime, &anchor_local_time) == clock_ok) { + if ((conn->input_rate != 0) && (get_ptp_anchor_local_time_info(conn, &anchor_rtptime, &anchor_local_time) == clock_ok)) { int64_t time_difference = time - anchor_local_time; int64_t frame_difference = time_difference; frame_difference = frame_difference * conn->input_rate; // but this is by 10^9