From 3c5e5f8b85841442a30c10f1be9ed9fc4d326037 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Tue, 19 Nov 2019 19:29:26 -0800 Subject: adaptivedemux: fix 'utc now' gdatetime creation It broke after removal of usage of GTimeVal that was deprecated, it requires seconds in this unix-based creation instead of microseconds. The downside here is that it will create an extra object just to be discarded in order to add the microsecond part to it. It would end up segfaulting as it would return a NULL value --- gst-libs/gst/adaptivedemux/gstadaptivedemux.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'gst-libs/gst/adaptivedemux') diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index e84f7ecb1..0f27f7455 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -4476,10 +4476,18 @@ GDateTime * gst_adaptive_demux_get_client_now_utc (GstAdaptiveDemux * demux) { GstClockTime rtc_now; + GDateTime *unix_datetime; + GDateTime *result_datetime; + gint64 utc_now_in_us; rtc_now = gst_clock_get_time (demux->realtime_clock); - return g_date_time_new_from_unix_utc (demux->clock_offset + - GST_TIME_AS_USECONDS (rtc_now)); + utc_now_in_us = demux->clock_offset + GST_TIME_AS_USECONDS (rtc_now); + unix_datetime = + g_date_time_new_from_unix_utc (utc_now_in_us / G_TIME_SPAN_SECOND); + result_datetime = + g_date_time_add (unix_datetime, utc_now_in_us % G_TIME_SPAN_SECOND); + g_date_time_unref (unix_datetime); + return result_datetime; } /** -- cgit v1.2.3