diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 1f6a52a780..b6febad57b 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1392,6 +1392,10 @@ gst_debug_bin_to_dot_file_with_ts gst_info_vasprintf gst_info_strdup_vprintf gst_info_strdup_printf +gst_print +gst_println +gst_printerr +gst_printerrln GST_TYPE_DEBUG_COLOR_FLAGS GST_TYPE_DEBUG_COLOR_MODE diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 7f314b9e20..8e8f00f6e6 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -2438,7 +2438,7 @@ gst_info_strdup_vprintf (const gchar * format, va_list args) * @format: a printf style format string * @...: the printf arguments for @format * - * Allocates, fills and returns a null terminated string from the printf style + * Allocates, fills and returns a 0-terminated string from the printf style * @format string and corresponding arguments. * * See gst_info_vasprintf() for when this function is required. @@ -2462,6 +2462,146 @@ gst_info_strdup_printf (const gchar * format, ...) return ret; } +/** + * gst_print: + * @format: a printf style format string + * @...: the printf arguments for @format + * + * Outputs a formatted message via the GLib print handler. The default print + * handler simply outputs the message to stdout. + * + * This function will not append a new-line character at the end, unlike + * gst_println() which will. + * + * All strings must be in ASCII or UTF-8 encoding. + * + * This function differs from g_print() in that it supports all the additional + * printf specifiers that are supported by GStreamer's debug logging system, + * such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT. + * + * This function is primarily for printing debug output. + * + * Since: 1.12 + */ +void +gst_print (const gchar * format, ...) +{ + va_list args; + gchar *str; + + va_start (args, format); + str = gst_info_strdup_vprintf (format, args); + va_end (args); + + g_print ("%s", str); + g_free (str); +} + +/** + * gst_println: + * @format: a printf style format string + * @...: the printf arguments for @format + * + * Outputs a formatted message via the GLib print handler. The default print + * handler simply outputs the message to stdout. + * + * This function will append a new-line character at the end, unlike + * gst_print() which will not. + * + * All strings must be in ASCII or UTF-8 encoding. + * + * This function differs from g_print() in that it supports all the additional + * printf specifiers that are supported by GStreamer's debug logging system, + * such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT. + * + * This function is primarily for printing debug output. + * + * Since: 1.12 + */ +void +gst_println (const gchar * format, ...) +{ + va_list args; + gchar *str; + + va_start (args, format); + str = gst_info_strdup_vprintf (format, args); + va_end (args); + + g_print ("%s\n", str); + g_free (str); +} + +/** + * gst_printerr: + * @format: a printf style format string + * @...: the printf arguments for @format + * + * Outputs a formatted message via the GLib error message handler. The default + * handler simply outputs the message to stderr. + * + * This function will not append a new-line character at the end, unlike + * gst_printerrln() which will. + * + * All strings must be in ASCII or UTF-8 encoding. + * + * This function differs from g_printerr() in that it supports the additional + * printf specifiers that are supported by GStreamer's debug logging system, + * such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT. + * + * This function is primarily for printing debug output. + * + * Since: 1.12 + */ +void +gst_printerr (const gchar * format, ...) +{ + va_list args; + gchar *str; + + va_start (args, format); + str = gst_info_strdup_vprintf (format, args); + va_end (args); + + g_printerr ("%s", str); + g_free (str); +} + +/** + * gst_printerrln: + * @format: a printf style format string + * @...: the printf arguments for @format + * + * Outputs a formatted message via the GLib error message handler. The default + * handler simply outputs the message to stderr. + * + * This function will append a new-line character at the end, unlike + * gst_printerr() which will not. + * + * All strings must be in ASCII or UTF-8 encoding. + * + * This function differs from g_printerr() in that it supports the additional + * printf specifiers that are supported by GStreamer's debug logging system, + * such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT. + * + * This function is primarily for printing debug output. + * + * Since: 1.12 + */ +void +gst_printerrln (const gchar * format, ...) +{ + va_list args; + gchar *str; + + va_start (args, format); + str = gst_info_strdup_vprintf (format, args); + va_end (args); + + g_printerr ("%s\n", str); + g_free (str); +} + #ifdef HAVE_UNWIND #ifdef HAVE_DW static gboolean diff --git a/gst/gstinfo.h b/gst/gstinfo.h index d274fe0727..8d67885862 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -413,6 +413,12 @@ gint gst_info_vasprintf (gchar ** result, gchar * gst_info_strdup_vprintf (const gchar *format, va_list args) G_GNUC_PRINTF (1, 0); gchar * gst_info_strdup_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2); +void gst_print (const gchar * format, ...) G_GNUC_PRINTF (1, 2); +void gst_println (const gchar * format, ...) G_GNUC_PRINTF (1, 2); + +void gst_printerr (const gchar * format, ...) G_GNUC_PRINTF (1, 2); +void gst_printerrln (const gchar * format, ...) G_GNUC_PRINTF (1, 2); + #ifndef GST_DISABLE_GST_DEBUG /* cast to void * avoids a warning with gcc 6 diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 129bd03290..9b29c79978 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -1064,6 +1064,10 @@ EXPORTS gst_preset_save_preset gst_preset_set_app_dir gst_preset_set_meta + gst_print + gst_printerr + gst_printerrln + gst_println gst_progress_type_get_type gst_protection_meta_api_get_type gst_protection_meta_get_info