info: Make gst_debug_print_object() and gst_debug_print_segment() public

It can be useful in custom logging code to easily get string
representations of all kinds of objects or a segment.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6820>
This commit is contained in:
Sebastian Dröge 2024-05-09 10:17:39 +03:00 committed by GStreamer Marge Bot
parent 299a000917
commit a7908b05da
3 changed files with 85 additions and 6 deletions

View file

@ -51551,6 +51551,47 @@ would write out.</doc>
</parameter>
</parameters>
</function>
<function name="debug_print_object" c:identifier="gst_debug_print_object" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstinfo.c">Returns a string that represents @ptr. This is safe to call with
%GstStructure, %GstCapsFeatures, %GstMiniObject s (e.g. %GstCaps,
%GstBuffer or %GstMessage), and %GObjects (e.g. %GstElement or %GstPad).
The string representation is meant to be used for debugging purposes and
might change between GStreamer versions.
Passing other kind of pointers might or might not work and is generally
unsafe to do.</doc>
<source-position filename="../subprojects/gstreamer/gst/gstinfo.h"/>
<return-value transfer-ownership="full">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstinfo.c">a string containing a string
representation of the object</doc>
<type name="utf8" c:type="gchar*"/>
</return-value>
<parameters>
<parameter name="ptr" transfer-ownership="none" nullable="1" allow-none="1">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstinfo.c">the object</doc>
<type name="gpointer" c:type="gconstpointer"/>
</parameter>
</parameters>
</function>
<function name="debug_print_segment" c:identifier="gst_debug_print_segment" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstinfo.c">Returns a string that represents @segments.
The string representation is meant to be used for debugging purposes and
might change between GStreamer versions.</doc>
<source-position filename="../subprojects/gstreamer/gst/gstinfo.h"/>
<return-value transfer-ownership="full">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstinfo.c">a string containing a string
representation of the segment</doc>
<type name="utf8" c:type="gchar*"/>
</return-value>
<parameters>
<parameter name="segment" transfer-ownership="none" nullable="1" allow-none="1">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstinfo.c">the %GstSegment</doc>
<type name="Segment" c:type="const GstSegment*"/>
</parameter>
</parameters>
</function>
<function name="debug_print_stack_trace" c:identifier="gst_debug_print_stack_trace">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstinfo.c">If libunwind, glibc backtrace or DbgHelp are present
a stack trace is printed.</doc>

View file

@ -1065,8 +1065,27 @@ gst_info_describe_stream_collection (GstStreamCollection * collection)
return ret;
}
static gchar *
gst_debug_print_object (gpointer ptr)
/**
* gst_debug_print_object:
* @ptr: (nullable): the object
*
* Returns a string that represents @ptr. This is safe to call with
* %GstStructure, %GstCapsFeatures, %GstMiniObject s (e.g. %GstCaps,
* %GstBuffer or %GstMessage), and %GObjects (e.g. %GstElement or %GstPad).
*
* The string representation is meant to be used for debugging purposes and
* might change between GStreamer versions.
*
* Passing other kind of pointers might or might not work and is generally
* unsafe to do.
*
* Returns: (transfer full) (type gchar*): a string containing a string
* representation of the object
*
* Since: 1.26
*/
gchar *
gst_debug_print_object (gconstpointer ptr)
{
GObject *object = (GObject *) ptr;
@ -1162,11 +1181,23 @@ gst_debug_print_object (gpointer ptr)
return g_strdup_printf ("%p", ptr);
}
static gchar *
gst_debug_print_segment (gpointer ptr)
/**
* gst_debug_print_segment:
* @segment: (nullable): the %GstSegment
*
* Returns a string that represents @segments.
*
* The string representation is meant to be used for debugging purposes and
* might change between GStreamer versions.
*
* Returns: (transfer full) (type gchar*): a string containing a string
* representation of the segment
*
* Since: 1.26
*/
gchar *
gst_debug_print_segment (const GstSegment * segment)
{
GstSegment *segment = (GstSegment *) ptr;
/* nicely printed segment */
if (segment == NULL) {
return g_strdup ("(NULL)");

View file

@ -27,6 +27,7 @@
#include <glib.h>
#include <glib-object.h>
#include <gst/gstconfig.h>
#include <gst/gstsegment.h>
G_BEGIN_DECLS
@ -553,6 +554,12 @@ GST_API
GSList * gst_debug_get_all_categories (void);
GST_API
gchar * gst_debug_print_object (gconstpointer ptr);
GST_API
gchar * gst_debug_print_segment (const GstSegment *segment);
GST_API
gchar * gst_debug_construct_term_color (guint colorinfo);