rtp: Fix precision loss in gst_rtcp_ntp_to_unix()
Without this patch the UNIX timestamp resulting from the translation from NTP would be off by one nano-second. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8010>
This commit is contained in:
parent
1ee349f986
commit
c683cdc914
@ -2136,7 +2136,7 @@ gst_rtcp_ntp_to_unix (guint64 ntptime)
|
|||||||
unixtime = ntptime - (G_GUINT64_CONSTANT (2208988800) << 32);
|
unixtime = ntptime - (G_GUINT64_CONSTANT (2208988800) << 32);
|
||||||
/* conversion to nanoseconds */
|
/* conversion to nanoseconds */
|
||||||
unixtime =
|
unixtime =
|
||||||
gst_util_uint64_scale (unixtime, GST_SECOND,
|
gst_util_uint64_scale_ceil (unixtime, GST_SECOND,
|
||||||
(G_GINT64_CONSTANT (1) << 32));
|
(G_GINT64_CONSTANT (1) << 32));
|
||||||
|
|
||||||
return unixtime;
|
return unixtime;
|
||||||
|
@ -1699,6 +1699,22 @@ GST_START_TEST (test_rtcp_buffer_xr_voipmtrx)
|
|||||||
|
|
||||||
GST_END_TEST;
|
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)
|
GST_START_TEST (test_rtp_ntp64_extension)
|
||||||
{
|
{
|
||||||
GstBuffer *buf;
|
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_dlrr);
|
||||||
tcase_add_test (tc_chain, test_rtcp_buffer_xr_ssumm);
|
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_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_ntp64_extension);
|
||||||
tcase_add_test (tc_chain, test_rtp_ntp56_extension);
|
tcase_add_test (tc_chain, test_rtp_ntp56_extension);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user