diff --git a/subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtcpbuffer.c b/subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtcpbuffer.c index dea2a7933d..cdff0a811b 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtcpbuffer.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtcpbuffer.c @@ -2136,7 +2136,7 @@ gst_rtcp_ntp_to_unix (guint64 ntptime) unixtime = ntptime - (G_GUINT64_CONSTANT (2208988800) << 32); /* conversion to nanoseconds */ unixtime = - gst_util_uint64_scale (unixtime, GST_SECOND, + gst_util_uint64_scale_ceil (unixtime, GST_SECOND, (G_GINT64_CONSTANT (1) << 32)); return unixtime; diff --git a/subprojects/gst-plugins-base/tests/check/libs/rtp.c b/subprojects/gst-plugins-base/tests/check/libs/rtp.c index 1fd25f3d6b..5906d74728 100644 --- a/subprojects/gst-plugins-base/tests/check/libs/rtp.c +++ b/subprojects/gst-plugins-base/tests/check/libs/rtp.c @@ -1699,6 +1699,22 @@ GST_START_TEST (test_rtcp_buffer_xr_voipmtrx) GST_END_TEST; +GST_START_TEST (test_rtcp_utils) +{ + /* Make sure conversion from NTP doesn't incur precision loss */ + GstClockTime orig_ts = gst_util_get_timestamp (); + guint64 ntp_ts = gst_rtcp_unix_to_ntp (orig_ts); + GstClockTime new_ts = gst_rtcp_ntp_to_unix (ntp_ts); + fail_unless_equals_clocktime (orig_ts, new_ts); + + GstClockTime hardcoded_ts = 185774825249347; + ntp_ts = gst_rtcp_unix_to_ntp (hardcoded_ts); + new_ts = gst_rtcp_ntp_to_unix (ntp_ts); + fail_unless_equals_clocktime (hardcoded_ts, new_ts); +} + +GST_END_TEST; + GST_START_TEST (test_rtp_ntp64_extension) { GstBuffer *buf; @@ -2357,6 +2373,7 @@ rtp_suite (void) tcase_add_test (tc_chain, test_rtcp_buffer_xr_dlrr); tcase_add_test (tc_chain, test_rtcp_buffer_xr_ssumm); tcase_add_test (tc_chain, test_rtcp_buffer_xr_voipmtrx); + tcase_add_test (tc_chain, test_rtcp_utils); tcase_add_test (tc_chain, test_rtp_ntp64_extension); tcase_add_test (tc_chain, test_rtp_ntp56_extension);