From 441e71d1ff3f4ac7ac9aa40c5af445a9430d87f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 17 May 2024 14:13:11 +0300 Subject: [PATCH] flvmux: Use GDateTime instead of gmtime() Part-of: --- .../gst-plugins-good/gst/flv/gstflvmux.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/flv/gstflvmux.c b/subprojects/gst-plugins-good/gst/flv/gstflvmux.c index 9fe9d75f20..c86d66bf6b 100644 --- a/subprojects/gst-plugins-good/gst/flv/gstflvmux.c +++ b/subprojects/gst-plugins-good/gst/flv/gstflvmux.c @@ -1180,8 +1180,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) tag_string = NULL; { - time_t secs; - struct tm tm; + GDateTime *now; gchar *s; static const gchar *weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -1191,16 +1190,15 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) "Aug", "Sep", "Oct", "Nov", "Dec" }; - secs = g_get_real_time () / G_USEC_PER_SEC; -#ifdef HAVE_GMTIME_R - gmtime_r (&secs, &tm); -#else - tm = *gmtime (&secs); -#endif + now = g_date_time_new_now_utc (); - s = g_strdup_printf ("%s %s %d %02d:%02d:%02d %d", weekdays[tm.tm_wday], - months[tm.tm_mon], tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, - tm.tm_year + 1900); + s = g_strdup_printf ("%s %s %u %02u:%02u:%02u %u", + weekdays[g_date_time_get_day_of_week (now)], + months[g_date_time_get_month (now)], g_date_time_get_day_of_month (now), + g_date_time_get_hour (now), g_date_time_get_minute (now), + g_date_time_get_second (now), g_date_time_get_year (now)); + + g_date_time_unref (now); _gst_buffer_new_and_alloc (2 + 12 + 1 + 2 + strlen (s), &tmp, &data); data[0] = 0; /* 12 bytes name */