Handle input_rate of 0 more correctly.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user