flvmux: Use GDateTime instead of gmtime()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6872>
This commit is contained in:
Sebastian Dröge 2024-05-17 14:13:11 +03:00 committed by GStreamer Marge Bot
parent a6a1fd03cc
commit 441e71d1ff

View file

@ -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 */