From 74d29ca77117580bbc63cf8fd3af9e68d9bb9dbf Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 18 Jun 2020 13:46:29 -0400 Subject: [PATCH] info: Add a printf extension for ClockTime/ClockTimeDiff pointers Using both GST_TIME_FORMAT+GST_TIME_ARGS and friend is cumbersome, this makes it sensibly more user friendly. Part-of: --- gst/gstinfo.c | 10 ++++++++++ gst/gstinfo.h | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 5c9e7d633b..f2c07c36b1 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -959,6 +959,16 @@ gst_info_printf_pointer_extension_func (const char *format, void *ptr) case 'B': /* GST_SEGMENT_FORMAT */ s = gst_debug_print_segment (ptr); break; + case 'T': /* GST_TIMEP_FORMAT */ + if (ptr) + s = g_strdup_printf ("%" GST_TIME_FORMAT, + GST_TIME_ARGS (*(GstClockTime *) ptr)); + break; + case 'S': /* GST_STIMEP_FORMAT */ + if (ptr) + s = g_strdup_printf ("%" GST_STIME_FORMAT, + GST_STIME_ARGS (*(gint64 *) ptr)); + break; case 'a': /* GST_WRAPPED_PTR_FORMAT */ s = priv_gst_string_take_and_wrap (gst_debug_print_object (ptr)); break; diff --git a/gst/gstinfo.h b/gst/gstinfo.h index d3c36b3dff..070ea07a4d 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -302,6 +302,32 @@ struct _GstDebugCategory { */ #define GST_SEGMENT_FORMAT "p\aB" +/** + * GST_TIMEP_FORMAT: (skip): + * + * printf format type used to debug GStreamer ClockTime pointers. You can use + * this in combination with GStreamer's debug logging system as well as the + * functions gst_info_vasprintf(), gst_info_strdup_vprintf() and + * gst_info_strdup_printf() to pretty-print #GstClockTime pointers. This can + * only be used on pointers to GstClockTime values. + * + * Since: 1.18 + */ +#define GST_TIMEP_FORMAT "p\aT" + +/** + * GST_STIMEP_FORMAT: (skip): + * + * printf format type used to debug GStreamer signed time value pointers. You + * can use this in combination with GStreamer's debug logging system as well as + * the functions gst_info_vasprintf(), gst_info_strdup_vprintf() and + * gst_info_strdup_printf() to pretty-print signed time (pointers to + * #GstClockTimeDiff or #gint64). + * + * Since: 1.18 + */ +#define GST_STIMEP_FORMAT "p\aS" + typedef struct _GstDebugMessage GstDebugMessage; /**