debug: Category init should happen in class_init when possible

plugin_init() will not get called if element/feature registration
happens manually, such as when using linking only specific plugin
features with gstreamer-full. That is possible when plugins contain
static features.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9496>
This commit is contained in:
Nirbheek Chauhan 2025-07-21 03:41:05 +01:00
parent fdeca0767d
commit e8e12db5f4
22 changed files with 71 additions and 52 deletions

View File

@ -627,6 +627,9 @@ gst_svthevc_enc_class_init (GstSvtHevcEncClass * klass)
gst_type_mark_as_plugin_api (GST_SVTHEVC_ENC_PRED_STRUCT_TYPE, 0);
gst_type_mark_as_plugin_api (GST_SVTHEVC_ENC_RC_TYPE, 0);
gst_type_mark_as_plugin_api (GST_SVTHEVC_ENC_TUNE_TYPE, 0);
GST_DEBUG_CATEGORY_INIT (svthevc_enc_debug, "svthevcenc", 0,
"h265 encoding element");
}
static void
@ -2283,9 +2286,6 @@ gst_svthevc_enc_get_property (GObject * object, guint prop_id,
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (svthevc_enc_debug, "svthevcenc", 0,
"h265 encoding element");
return gst_element_register (plugin, "svthevcenc",
GST_RANK_PRIMARY, GST_TYPE_SVTHEVC_ENC);
}

View File

@ -209,6 +209,9 @@ gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
* Since: 1.22
*/
gst_video_overlay_install_properties (gobject_class, PROP_LAST);
GST_DEBUG_CATEGORY_INIT (gstwayland_debug, "waylandsink", 0,
" wayland video sink");
}
static void
@ -1252,9 +1255,6 @@ gst_wayland_sink_expose (GstVideoOverlay * overlay)
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gstwayland_debug, "waylandsink", 0,
" wayland video sink");
return GST_ELEMENT_REGISTER (waylandsink, plugin);
}

View File

@ -65,6 +65,8 @@ gst_ks_clock_class_init (GstKsClockClass * klass)
gobject_class->dispose = gst_ks_clock_dispose;
gobject_class->finalize = gst_ks_clock_finalize;
gst_ks_debug_init ();
}
static void

View File

@ -131,6 +131,8 @@ gst_ks_video_device_class_init (GstKsVideoDeviceClass * klass)
g_param_spec_string ("device-path", "Device Path",
"The device path", DEFAULT_DEVICE_PATH,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
gst_ks_debug_init ();
}
static void

View File

@ -221,6 +221,8 @@ gst_ks_video_src_class_init (GstKsVideoSrcClass * klass)
g_param_spec_boolean ("enable-quirks", "Enable quirks",
"Enable driver-specific quirks", DEFAULT_ENABLE_QUIRKS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_ks_debug_init ();
}
static void
@ -1028,8 +1030,7 @@ error_alloc_buffer:
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_ks_debug, "ksvideosrc",
0, "Kernel streaming video source");
gst_ks_debug_init ();
if (!gst_element_register (plugin, "ksvideosrc",
GST_RANK_PRIMARY, GST_TYPE_KS_VIDEO_SRC))

View File

@ -66,6 +66,8 @@ gst_ks_device_provider_class_init (GstKsDeviceProviderClass * klass)
"KernelStreaming Device Provider", "Sink/Source/Audio/Video",
"List and provide KernelStreaming source and sink devices",
"Руслан Ижбулатов <lrn1986@gmail.com>");
gst_ks_debug_init ();
}
static void
@ -658,6 +660,8 @@ gst_ks_device_class_init (GstKsDeviceClass * klass)
g_param_spec_string ("path", "System device path",
"The system path to the device", "",
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
gst_ks_debug_init ();
}
static void

View File

@ -748,3 +748,14 @@ ks_video_get_all_caps (void)
return caps;
}
void
gst_ks_debug_init (void)
{
static gsize res = 0;
if (g_once_init_enter (&res)) {
GST_DEBUG_CATEGORY_INIT (gst_ks_debug, "ksvideosrc",
0, "Kernel streaming video source");
g_once_init_leave (&res, 1);
}
}

View File

@ -78,6 +78,8 @@ gboolean ks_video_fixate_media_type (const KSDATARANGE * range, guint8 * format,
GstCaps * ks_video_get_all_caps (void);
void gst_ks_debug_init (void);
G_END_DECLS
#endif /* __KSVIDEOHELPERS_H__ */

View File

@ -198,6 +198,9 @@ gst_cd_paranoia_src_class_init (GstCdParanoiaSrcClass * klass)
NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_INT);
gst_type_mark_as_plugin_api (GST_TYPE_CD_PARANOIA_MODE, 0);
GST_DEBUG_CATEGORY_INIT (gst_cd_paranoia_src_debug, "cdparanoiasrc", 0,
"CD Paranoia Source");
}
static gboolean
@ -515,9 +518,6 @@ plugin_init (GstPlugin * plugin)
{
gboolean ret = FALSE;
GST_DEBUG_CATEGORY_INIT (gst_cd_paranoia_src_debug, "cdparanoiasrc", 0,
"CD Paranoia Source");
ret |= GST_ELEMENT_REGISTER (cdparanoiasrc, plugin);
#ifdef ENABLE_NLS

View File

@ -2338,6 +2338,10 @@ gst_ogg_demux_class_init (GstOggDemuxClass * klass)
gstelement_class->send_event = gst_ogg_demux_receive_event;
gobject_class->finalize = gst_ogg_demux_finalize;
GST_DEBUG_CATEGORY_INIT (gst_ogg_demux_debug, "oggdemux", 0, "ogg demuxer");
GST_DEBUG_CATEGORY_INIT (gst_ogg_demux_setup_debug, "oggdemux_setup", 0,
"ogg demuxer setup stage when parsing pipeline");
}
static void
@ -5295,13 +5299,7 @@ gst_ogg_demux_change_state (GstElement * element, GstStateChange transition)
static gboolean
gst_ogg_demux_plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_ogg_demux_debug, "oggdemux", 0, "ogg demuxer");
GST_DEBUG_CATEGORY_INIT (gst_ogg_demux_setup_debug, "oggdemux_setup", 0,
"ogg demuxer setup stage when parsing pipeline");
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif

View File

@ -873,6 +873,9 @@ gst_adder_class_init (GstAdderClass * klass)
GST_DEBUG_FUNCPTR (gst_adder_request_new_pad);
gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_adder_release_pad);
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_adder_change_state);
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "adder", 0,
"audio channel mixing element");
}
static void
@ -1587,13 +1590,7 @@ gst_adder_child_proxy_init (gpointer g_iface, gpointer iface_data)
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean ret = FALSE;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "adder", 0,
"audio channel mixing element");
ret |= GST_ELEMENT_REGISTER (adder, plugin);
return ret;
return GST_ELEMENT_REGISTER (adder, plugin);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View File

@ -723,6 +723,11 @@ gst_compositor_pad_class_init (GstCompositorPadClass * klass)
GST_DEBUG_FUNCPTR (gst_compositor_pad_create_conversion_info);
gst_type_mark_as_plugin_api (GST_TYPE_COMPOSITOR_SIZING_POLICY, 0);
GST_DEBUG_CATEGORY_INIT (gst_compositor_debug, "compositor", 0, "compositor");
gst_compositor_init_blend ();
}
static void
@ -2109,10 +2114,6 @@ gst_compositor_child_proxy_init (gpointer g_iface, gpointer iface_data)
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_compositor_debug, "compositor", 0, "compositor");
gst_compositor_init_blend ();
return GST_ELEMENT_REGISTER (compositor, plugin);
}

View File

@ -352,6 +352,9 @@ gst_video_rate_class_init (GstVideoRateClass * klass)
&gst_video_rate_sink_template);
gst_element_class_add_static_pad_template (element_class,
&gst_video_rate_src_template);
GST_DEBUG_CATEGORY_INIT (video_rate_debug, "videorate", 0,
"VideoRate stream fixer");
}
static void
@ -2239,9 +2242,6 @@ gst_video_rate_get_property (GObject * object,
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (video_rate_debug, "videorate", 0,
"VideoRate stream fixer");
return GST_ELEMENT_REGISTER (videorate, plugin);
}

View File

@ -405,6 +405,9 @@ gst_video_test_src_class_init (GstVideoTestSrcClass * klass)
gst_type_mark_as_plugin_api (GST_TYPE_VIDEO_TEST_SRC_ANIMATION_MODE, 0);
gst_type_mark_as_plugin_api (GST_TYPE_VIDEO_TEST_SRC_MOTION_TYPE, 0);
gst_type_mark_as_plugin_api (GST_TYPE_VIDEO_TEST_SRC_PATTERN, 0);
GST_DEBUG_CATEGORY_INIT (video_test_src_debug, "videotestsrc", 0,
"Video Test Source");
}
static void
@ -1462,9 +1465,6 @@ gst_video_test_src_stop (GstBaseSrc * basesrc)
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (video_test_src_debug, "videotestsrc", 0,
"Video Test Source");
return GST_ELEMENT_REGISTER (videotestsrc, plugin);
}

View File

@ -412,6 +412,8 @@ gst_volume_class_init (GstVolumeClass * klass)
trans_class->transform_ip_on_passthrough = FALSE;
filter_class->setup = GST_DEBUG_FUNCPTR (volume_setup);
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "volume", 0, "Volume gain");
}
static void
@ -1038,8 +1040,6 @@ volume_get_property (GObject * object, guint prop_id, GValue * value,
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "volume", 0, "Volume gain");
return GST_ELEMENT_REGISTER (volume, plugin);
}

View File

@ -522,6 +522,9 @@ gst_navigationtest_class_init (GstNavigationtestClass * klass)
vfilter_class->transform_frame =
GST_DEBUG_FUNCPTR (gst_navigationtest_transform_frame);
GST_DEBUG_CATEGORY_INIT (navigationtest_debug, "navigationtest", 0,
"navigationtest");
}
static void
@ -536,9 +539,6 @@ gst_navigationtest_init (GstNavigationtest * navtest)
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (navigationtest_debug, "navigationtest", 0,
"navigationtest");
return GST_ELEMENT_REGISTER (navigationtest, plugin);
}

View File

@ -47,7 +47,7 @@
#include "gst/net/net.h"
#include "gst/glib-compat-private.h"
GST_DEBUG_CATEGORY_STATIC (multiudpsink_debug);
GST_DEBUG_CATEGORY (multiudpsink_debug);
#define GST_CAT_DEFAULT (multiudpsink_debug)
#define UDP_MAX_SIZE 65507

View File

@ -30,8 +30,6 @@ plugin_init (GstPlugin * plugin)
{
gboolean ret = FALSE;
GST_DEBUG_CATEGORY_INIT (gst_udp_debug, "udp", 0, "udp");
ret |= GST_ELEMENT_REGISTER (udpsink, plugin);
ret |= GST_ELEMENT_REGISTER (multiudpsink, plugin);
ret |= GST_ELEMENT_REGISTER (dynudpsink, plugin);

View File

@ -28,8 +28,8 @@
#include "gstudpnetutils.h"
GST_DEBUG_CATEGORY_EXTERN (gst_udp_debug);
#define GST_CAT_DEFAULT gst_udp_debug
GST_DEBUG_CATEGORY_EXTERN (udpsrc_debug);
#define GST_CAT_DEFAULT (udpsrc_debug)
gboolean
gst_udp_parse_uri (const gchar * uristr, gchar ** host, guint16 * port,
@ -50,8 +50,8 @@ gst_udp_parse_uri (const gchar * uristr, gchar ** host, guint16 * port,
GST_ERROR ("error parsing uri %s: no protocol", uristr);
goto error;
} else if (g_strcmp0 (protocol, "udp")) {
GST_ERROR ("error parsing uri %s: wrong protocol (%s != udp)", uristr,
protocol);
GST_ERROR ("error parsing uri %s: wrong protocol (%s != udp)",
uristr, protocol);
goto error;
}
@ -112,8 +112,8 @@ gst_udp_parse_multicast_source (const gchar * multicast_source,
/* Begin without '+' or '-' prefix, assume it's positive filter */
if (prefix == multicast_source) {
GST_WARNING ("%s without prefix, assuming that it's positive filter",
list[i]);
GST_WARNING ("%s without prefix, assuming that it's positive "
"filter", list[i]);
is_positive = TRUE;
} else if (*(prefix - 1) == '+') {
is_positive = TRUE;

View File

@ -38,6 +38,9 @@
#include "gstudpelements.h"
#include "gstudpsink.h"
GST_DEBUG_CATEGORY_EXTERN (multiudpsink_debug);
#define GST_CAT_DEFAULT (multiudpsink_debug)
#define UDP_DEFAULT_HOST "localhost"
#define UDP_DEFAULT_PORT 5004

View File

@ -547,7 +547,7 @@ gst_udpsrc_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
/* not 100% correct, but a good upper bound for memory allocation purposes */
#define MAX_IPV4_UDP_PACKET_SIZE (65536 - 8)
GST_DEBUG_CATEGORY_STATIC (udpsrc_debug);
GST_DEBUG_CATEGORY (udpsrc_debug);
#define GST_CAT_DEFAULT (udpsrc_debug)
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",

View File

@ -1409,6 +1409,9 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass)
bc->unlock = gst_ximage_src_unlock;
push_class->create = gst_ximage_src_create;
bc->event = gst_ximage_src_event;
GST_DEBUG_CATEGORY_INIT (gst_debug_ximage_src, "ximagesrc", 0,
"ximagesrc element debug");
}
static void
@ -1439,9 +1442,6 @@ plugin_init (GstPlugin * plugin)
if (g_getenv ("GST_XINITTHREADS"))
XInitThreads ();
GST_DEBUG_CATEGORY_INIT (gst_debug_ximage_src, "ximagesrc", 0,
"ximagesrc element debug");
ret = gst_element_register (plugin, "ximagesrc", GST_RANK_NONE,
GST_TYPE_XIMAGE_SRC);