From 3645f050af36a31df3b74157de8b59403e77a75a Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 30 Jan 2025 23:05:58 -0500 Subject: [PATCH] v4l2codecs: Remove uneeded per-codec abstract class That subclass was not needed and was causing issues wit doc generation. The only down side of removing it is that the decoder cast macro is no longer type safe. Part-of: --- .../v4l2codecs/gstv4l2codecalphadecodebin.c | 13 ++++-- .../sys/v4l2codecs/gstv4l2codecav1dec.c | 40 +++++++----------- .../sys/v4l2codecs/gstv4l2codech264dec.c | 41 +++++++------------ .../sys/v4l2codecs/gstv4l2codech265dec.c | 40 +++++++----------- .../sys/v4l2codecs/gstv4l2codecmpeg2dec.c | 40 +++++++----------- .../sys/v4l2codecs/gstv4l2codecvp8dec.c | 40 +++++++----------- .../sys/v4l2codecs/gstv4l2codecvp9dec.c | 41 +++++++------------ .../sys/v4l2codecs/gstv4l2decoder.c | 23 +++-------- .../sys/v4l2codecs/gstv4l2decoder.h | 4 +- 9 files changed, 100 insertions(+), 182 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecalphadecodebin.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecalphadecodebin.c index eaafd257b5..18eb411a72 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecalphadecodebin.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecalphadecodebin.c @@ -232,8 +232,15 @@ gst_v4l2_codec_alpha_decode_bin_register (GstPlugin * plugin, { /* TODO check that we have compatible src format */ - gst_v4l2_decoder_register (plugin, - GST_TYPE_V4L2_CODEC_ALPHA_DECODE_BIN, class_init, class_data, NULL, - element_name_tmpl, device, + GTypeInfo type_info = { + .class_size = sizeof (GstV4l2CodecAlphaDecodeBinClass), + .class_init = class_init, + .class_data = class_data, + .instance_size = sizeof (GstV4l2CodecAlphaDecodeBin), + .instance_init = NULL, + }; + + gst_v4l2_decoder_register (plugin, GST_TYPE_V4L2_CODEC_ALPHA_DECODE_BIN, + &type_info, element_name_tmpl, device, rank + GST_V4L2_CODEC_ALPHA_DECODE_BIN_RANK_OFFSET, NULL); } diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecav1dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecav1dec.c index 5365153037..3ea1b848cb 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecav1dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecav1dec.c @@ -41,10 +41,7 @@ GST_DEBUG_CATEGORY_STATIC (v4l2_av1dec_debug); #define GST_CAT_DEFAULT v4l2_av1dec_debug -#define GST_TYPE_V4L2_CODEC_AV1_DEC \ - (gst_v4l2_codec_av1_dec_get_type()) -#define GST_V4L2_CODEC_AV1_DEC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_V4L2_CODEC_AV1_DEC,GstV4l2CodecAV1Dec)) +#define GST_V4L2_CODEC_AV1_DEC(obj) ((GstV4l2CodecAV1Dec *) obj) /* Used to mark picture that have been outputted */ #define FLAG_PICTURE_HOLDS_BUFFER GST_MINI_OBJECT_FLAG_LAST @@ -117,12 +114,7 @@ struct _GstV4l2CodecAV1Dec GstMapInfo bitstream_map; }; -static GType gst_v4l2_codec_av1_dec_get_type (void); - -G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecAV1Dec, gst_v4l2_codec_av1_dec, - GST_TYPE_AV1_DECODER); - -#define parent_class gst_v4l2_codec_av1_dec_parent_class +static GstElementClass *parent_class = NULL; static GstFlowReturn gst_v4l2_codec_av1_dec_ensure_bitstream (GstV4l2CodecAV1Dec * self) @@ -1537,7 +1529,7 @@ gst_v4l2_codec_av1_dec_dispose (GObject * object) } static void -gst_v4l2_codec_av1_dec_subclass_init (GstV4l2CodecAV1DecClass * klass, +gst_v4l2_codec_av1_dec_class_init (GstV4l2CodecAV1DecClass * klass, GstV4l2CodecDevice * device) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -1555,6 +1547,8 @@ gst_v4l2_codec_av1_dec_subclass_init (GstV4l2CodecAV1DecClass * klass, "A V4L2 based AV1 video decoder", "Daniel Almeida "); + parent_class = g_type_class_peek_parent (klass); + gst_element_class_add_static_pad_template (element_class, &sink_template); gst_element_class_add_pad_template (element_class, gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, @@ -1596,7 +1590,7 @@ gst_v4l2_codec_av1_dec_subclass_init (GstV4l2CodecAV1DecClass * klass, } static void -gst_v4l2_codec_av1_dec_subinit (GstV4l2CodecAV1Dec * self, +gst_v4l2_codec_av1_dec_init (GstV4l2CodecAV1Dec * self, GstV4l2CodecAV1DecClass * klass) { self->decoder = gst_v4l2_decoder_new (klass->device); @@ -1605,20 +1599,17 @@ gst_v4l2_codec_av1_dec_subinit (GstV4l2CodecAV1Dec * self, g_array_new (FALSE, TRUE, sizeof (struct v4l2_ctrl_av1_tile_group_entry)); } -static void -gst_v4l2_codec_av1_dec_class_init (GstV4l2CodecAV1DecClass * klass) -{ -} - -static void -gst_v4l2_codec_av1_dec_init (GstV4l2CodecAV1Dec * self) -{ -} - void gst_v4l2_codec_av1_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, GstV4l2CodecDevice * device, guint rank) { + GTypeInfo type_info = { + .class_size = sizeof (GstV4l2CodecAV1DecClass), + .class_init = (GClassInitFunc) gst_v4l2_codec_av1_dec_class_init, + .class_data = gst_mini_object_ref (GST_MINI_OBJECT (device)), + .instance_size = sizeof (GstV4l2CodecAV1Dec), + .instance_init = (GInstanceInitFunc) gst_v4l2_codec_av1_dec_init, + }; GstCaps *src_caps = NULL; guint version; @@ -1659,10 +1650,7 @@ gst_v4l2_codec_av1_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, } register_element: - gst_v4l2_decoder_register (plugin, GST_TYPE_V4L2_CODEC_AV1_DEC, - (GClassInitFunc) gst_v4l2_codec_av1_dec_subclass_init, - gst_mini_object_ref (GST_MINI_OBJECT (device)), - (GInstanceInitFunc) gst_v4l2_codec_av1_dec_subinit, + gst_v4l2_decoder_register (plugin, GST_TYPE_AV1_DECODER, &type_info, "v4l2sl%sav1dec", device, rank, NULL); done: diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c index 033f80aaf8..640ccd44f1 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c @@ -39,10 +39,7 @@ GST_DEBUG_CATEGORY_STATIC (v4l2_h264dec_debug); #define GST_CAT_DEFAULT v4l2_h264dec_debug -#define GST_TYPE_V4L2_CODEC_H264_DEC \ - (gst_v4l2_codec_h264_dec_get_type()) -#define GST_V4L2_CODEC_H264_DEC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_V4L2_CODEC_H264_DEC,GstV4l2CodecH264Dec)) +#define GST_V4L2_CODEC_H264_DEC(obj) ((GstV4l2CodecH264Dec *) obj); enum { @@ -117,12 +114,7 @@ struct _GstV4l2CodecH264Dec GstMapInfo bitstream_map; }; -static GType gst_v4l2_codec_h264_dec_get_type (void); - -G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecH264Dec, gst_v4l2_codec_h264_dec, - GST_TYPE_H264_DECODER); - -#define parent_class gst_v4l2_codec_h264_dec_parent_class +static GstElementClass *parent_class = NULL; static gboolean is_frame_based (GstV4l2CodecH264Dec * self) @@ -1520,12 +1512,7 @@ gst_v4l2_codec_h264_dec_get_property (GObject * object, guint prop_id, } static void -gst_v4l2_codec_h264_dec_init (GstV4l2CodecH264Dec * self) -{ -} - -static void -gst_v4l2_codec_h264_dec_subinit (GstV4l2CodecH264Dec * self, +gst_v4l2_codec_h264_dec_init (GstV4l2CodecH264Dec * self, GstV4l2CodecH264DecClass * klass) { self->decoder = gst_v4l2_decoder_new (klass->device); @@ -1547,12 +1534,7 @@ gst_v4l2_codec_h264_dec_dispose (GObject * object) } static void -gst_v4l2_codec_h264_dec_class_init (GstV4l2CodecH264DecClass * klass) -{ -} - -static void -gst_v4l2_codec_h264_dec_subclass_init (GstV4l2CodecH264DecClass * klass, +gst_v4l2_codec_h264_dec_class_init (GstV4l2CodecH264DecClass * klass, GstV4l2CodecDevice * device) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -1570,6 +1552,8 @@ gst_v4l2_codec_h264_dec_subclass_init (GstV4l2CodecH264DecClass * klass, "A V4L2 based H.264 video decoder", "Nicolas Dufresne "); + parent_class = g_type_class_peek_parent (klass); + gst_element_class_add_static_pad_template (element_class, &sink_template); gst_element_class_add_pad_template (element_class, gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, @@ -1612,6 +1596,13 @@ void gst_v4l2_codec_h264_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, GstV4l2CodecDevice * device, guint rank) { + GTypeInfo type_info = { + .class_size = sizeof (GstV4l2CodecH264DecClass), + .class_init = (GClassInitFunc) gst_v4l2_codec_h264_dec_class_init, + .class_data = gst_mini_object_ref (GST_MINI_OBJECT (device)), + .instance_size = sizeof (GstV4l2CodecH264Dec), + .instance_init = (GInstanceInitFunc) gst_v4l2_codec_h264_dec_init, + }; GstCaps *src_caps = NULL; guint version; @@ -1652,11 +1643,7 @@ gst_v4l2_codec_h264_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, } register_element: - gst_v4l2_decoder_register (plugin, - GST_TYPE_V4L2_CODEC_H264_DEC, - (GClassInitFunc) gst_v4l2_codec_h264_dec_subclass_init, - gst_mini_object_ref (GST_MINI_OBJECT (device)), - (GInstanceInitFunc) gst_v4l2_codec_h264_dec_subinit, + gst_v4l2_decoder_register (plugin, GST_TYPE_H264_DECODER, &type_info, "v4l2sl%sh264dec", device, rank, NULL); done: diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech265dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech265dec.c index f97c660be3..9270a9367e 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech265dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech265dec.c @@ -40,10 +40,7 @@ GST_DEBUG_CATEGORY_STATIC (v4l2_h265dec_debug); #define GST_CAT_DEFAULT v4l2_h265dec_debug -#define GST_TYPE_V4L2_CODEC_H265_DEC \ - (gst_v4l2_codec_h265_dec_get_type()) -#define GST_V4L2_CODEC_H265_DEC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_V4L2_CODEC_H265_DEC,GstV4l2CodecH265Dec)) +#define GST_V4L2_CODEC_H265_DEC(obj) ((GstV4l2CodecH265Dec *) obj) enum { @@ -125,12 +122,7 @@ struct _GstV4l2CodecH265Dec gint crop_rect_x, crop_rect_y; }; -static GType gst_v4l2_codec_h265_dec_get_type (void); - -G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecH265Dec, gst_v4l2_codec_h265_dec, - GST_TYPE_H265_DECODER); - -#define parent_class gst_v4l2_codec_h265_dec_parent_class +static GstElementClass *parent_class = NULL; static gboolean is_frame_based (GstV4l2CodecH265Dec * self) @@ -1650,12 +1642,7 @@ gst_v4l2_codec_h265_dec_get_property (GObject * object, guint prop_id, } static void -gst_v4l2_codec_h265_dec_init (GstV4l2CodecH265Dec * self) -{ -} - -static void -gst_v4l2_codec_h265_dec_subinit (GstV4l2CodecH265Dec * self, +gst_v4l2_codec_h265_dec_init (GstV4l2CodecH265Dec * self, GstV4l2CodecH265DecClass * klass) { self->decoder = gst_v4l2_decoder_new (klass->device); @@ -1680,12 +1667,7 @@ gst_v4l2_codec_h265_dec_dispose (GObject * object) } static void -gst_v4l2_codec_h265_dec_class_init (GstV4l2CodecH265DecClass * klass) -{ -} - -static void -gst_v4l2_codec_h265_dec_subclass_init (GstV4l2CodecH265DecClass * klass, +gst_v4l2_codec_h265_dec_class_init (GstV4l2CodecH265DecClass * klass, GstV4l2CodecDevice * device) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -1703,6 +1685,8 @@ gst_v4l2_codec_h265_dec_subclass_init (GstV4l2CodecH265DecClass * klass, "A V4L2 based H.265 video decoder", "Nicolas Dufresne "); + parent_class = g_type_class_peek_parent (klass); + gst_element_class_add_static_pad_template (element_class, &sink_template); gst_element_class_add_pad_template (element_class, gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, @@ -1743,6 +1727,13 @@ void gst_v4l2_codec_h265_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, GstV4l2CodecDevice * device, guint rank) { + GTypeInfo type_info = { + .class_size = sizeof (GstV4l2CodecH265DecClass), + .class_init = (GClassInitFunc) gst_v4l2_codec_h265_dec_class_init, + .class_data = gst_mini_object_ref (GST_MINI_OBJECT (device)), + .instance_size = sizeof (GstV4l2CodecH265Dec), + .instance_init = (GInstanceInitFunc) gst_v4l2_codec_h265_dec_init, + }; GstCaps *src_caps = NULL; guint version; @@ -1783,10 +1774,7 @@ gst_v4l2_codec_h265_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, } register_element: - gst_v4l2_decoder_register (plugin, GST_TYPE_V4L2_CODEC_H265_DEC, - (GClassInitFunc) gst_v4l2_codec_h265_dec_subclass_init, - gst_mini_object_ref (GST_MINI_OBJECT (device)), - (GInstanceInitFunc) gst_v4l2_codec_h265_dec_subinit, + gst_v4l2_decoder_register (plugin, GST_TYPE_H265_DECODER, &type_info, "v4l2sl%sh265dec", device, rank, NULL); done: diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c index ab8d0403e1..d4a1826843 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c @@ -43,10 +43,7 @@ GST_DEBUG_CATEGORY_STATIC (v4l2_mpeg2dec_debug); #define GST_CAT_DEFAULT v4l2_mpeg2dec_debug -#define GST_TYPE_V4L2_CODEC_MPEG2_DEC \ - (gst_v4l2_codec_mpeg2_dec_get_type()) -#define GST_V4L2_CODEC_MPEG2_DEC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_V4L2_CODEC_MPEG2_DEC,GstV4l2CodecMpeg2Dec)) +#define GST_V4L2_CODEC_MPEG2_DEC(obj) ((GstV4l2CodecMpeg2Dec *) obj) enum { @@ -116,12 +113,7 @@ struct _GstV4l2CodecMpeg2Dec gboolean copy_frames; }; -static GType gst_v4l2_codec_mpeg2_dec_get_type (void); - -G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecMpeg2Dec, gst_v4l2_codec_mpeg2_dec, - GST_TYPE_MPEG2_DECODER); - -#define parent_class gst_v4l2_codec_mpeg2_dec_parent_class +static GstElementClass *parent_class = NULL; static guint gst_v4l2_codec_mpeg2_dec_get_preferred_output_delay (GstMpeg2Decoder * decoder, @@ -1045,12 +1037,7 @@ gst_v4l2_codec_mpeg2_dec_get_property (GObject * object, guint prop_id, } static void -gst_v4l2_codec_mpeg2_dec_init (GstV4l2CodecMpeg2Dec * self) -{ -} - -static void -gst_v4l2_codec_mpeg2_dec_subinit (GstV4l2CodecMpeg2Dec * self, +gst_v4l2_codec_mpeg2_dec_init (GstV4l2CodecMpeg2Dec * self, GstV4l2CodecMpeg2DecClass * klass) { self->decoder = gst_v4l2_decoder_new (klass->device); @@ -1068,12 +1055,7 @@ gst_v4l2_codec_mpeg2_dec_dispose (GObject * object) } static void -gst_v4l2_codec_mpeg2_dec_class_init (GstV4l2CodecMpeg2DecClass * klass) -{ -} - -static void -gst_v4l2_codec_mpeg2_dec_subclass_init (GstV4l2CodecMpeg2DecClass * klass, +gst_v4l2_codec_mpeg2_dec_class_init (GstV4l2CodecMpeg2DecClass * klass, GstV4l2CodecDevice * device) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -1091,6 +1073,8 @@ gst_v4l2_codec_mpeg2_dec_subclass_init (GstV4l2CodecMpeg2DecClass * klass, "A V4L2 based Mpeg2 video decoder", "Daniel Almeida "); + parent_class = g_type_class_peek_parent (klass); + gst_element_class_add_static_pad_template (element_class, &sink_template); gst_element_class_add_pad_template (element_class, gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, @@ -1131,6 +1115,13 @@ void gst_v4l2_codec_mpeg2_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, GstV4l2CodecDevice * device, guint rank) { + GTypeInfo type_info = { + .class_size = sizeof (GstV4l2CodecMpeg2DecClass), + .class_init = (GClassInitFunc) gst_v4l2_codec_mpeg2_dec_class_init, + .class_data = gst_mini_object_ref (GST_MINI_OBJECT (device)), + .instance_size = sizeof (GstV4l2CodecMpeg2Dec), + .instance_init = (GInstanceInitFunc) gst_v4l2_codec_mpeg2_dec_init, + }; GstCaps *src_caps = NULL; GST_DEBUG_CATEGORY_INIT (v4l2_mpeg2dec_debug, "v4l2codecs-mpeg2dec", 0, @@ -1159,10 +1150,7 @@ gst_v4l2_codec_mpeg2_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, gst_v4l2_decoder_enum_all_src_formats (decoder, &static_src_caps); register_element: - gst_v4l2_decoder_register (plugin, GST_TYPE_V4L2_CODEC_MPEG2_DEC, - (GClassInitFunc) gst_v4l2_codec_mpeg2_dec_subclass_init, - gst_mini_object_ref (GST_MINI_OBJECT (device)), - (GInstanceInitFunc) gst_v4l2_codec_mpeg2_dec_subinit, + gst_v4l2_decoder_register (plugin, GST_TYPE_MPEG2_DECODER, &type_info, "v4l2sl%smpeg2dec", device, rank, NULL); done: diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c index 2c9e57b32b..a55d4d8519 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c @@ -39,10 +39,7 @@ GST_DEBUG_CATEGORY_STATIC (v4l2_vp8dec_debug); #define GST_CAT_DEFAULT v4l2_vp8dec_debug -#define GST_TYPE_V4L2_CODEC_VP8_DEC \ - (gst_v4l2_codec_vp8_dec_get_type()) -#define GST_V4L2_CODEC_VP8_DEC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_V4L2_CODEC_VP8_DEC,GstV4l2CodecVp8Dec)) +#define GST_V4L2_CODEC_VP8_DEC(obj) ((GstV4l2CodecVp8Dec *) obj) enum { @@ -104,12 +101,7 @@ struct _GstV4l2CodecVp8Dec GstMapInfo bitstream_map; }; -static GType gst_v4l2_codec_vp8_dec_get_type (void); - -G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecVp8Dec, gst_v4l2_codec_vp8_dec, - GST_TYPE_VP8_DECODER); - -#define parent_class gst_v4l2_codec_vp8_dec_parent_class +static GstElementClass *parent_class = NULL; static guint gst_v4l2_codec_vp8_dec_get_preferred_output_delay (GstVp8Decoder * decoder, @@ -903,12 +895,7 @@ gst_v4l2_codec_vp8_dec_get_property (GObject * object, guint prop_id, } static void -gst_v4l2_codec_vp8_dec_init (GstV4l2CodecVp8Dec * self) -{ -} - -static void -gst_v4l2_codec_vp8_dec_subinit (GstV4l2CodecVp8Dec * self, +gst_v4l2_codec_vp8_dec_init (GstV4l2CodecVp8Dec * self, GstV4l2CodecVp8DecClass * klass) { self->decoder = gst_v4l2_decoder_new (klass->device); @@ -926,12 +913,7 @@ gst_v4l2_codec_vp8_dec_dispose (GObject * object) } static void -gst_v4l2_codec_vp8_dec_class_init (GstV4l2CodecVp8DecClass * klass) -{ -} - -static void -gst_v4l2_codec_vp8_dec_subclass_init (GstV4l2CodecVp8DecClass * klass, +gst_v4l2_codec_vp8_dec_class_init (GstV4l2CodecVp8DecClass * klass, GstV4l2CodecDevice * device) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -949,6 +931,8 @@ gst_v4l2_codec_vp8_dec_subclass_init (GstV4l2CodecVp8DecClass * klass, "A V4L2 based VP8 video decoder", "Nicolas Dufresne "); + parent_class = g_type_class_peek_parent (klass); + gst_element_class_add_static_pad_template (element_class, &sink_template); gst_element_class_add_pad_template (element_class, gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, @@ -1005,6 +989,13 @@ void gst_v4l2_codec_vp8_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, GstV4l2CodecDevice * device, guint rank) { + GTypeInfo type_info = { + .class_size = sizeof (GstV4l2CodecVp8DecClass), + .class_init = (GClassInitFunc) gst_v4l2_codec_vp8_dec_class_init, + .class_data = gst_mini_object_ref (GST_MINI_OBJECT (device)), + .instance_size = sizeof (GstV4l2CodecVp8Dec), + .instance_init = (GInstanceInitFunc) gst_v4l2_codec_vp8_dec_init, + }; gchar *element_name; GstCaps *src_caps = NULL, *alpha_caps; @@ -1034,10 +1025,7 @@ gst_v4l2_codec_vp8_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, gst_v4l2_decoder_enum_all_src_formats (decoder, &static_src_caps); register_element: - gst_v4l2_decoder_register (plugin, GST_TYPE_V4L2_CODEC_VP8_DEC, - (GClassInitFunc) gst_v4l2_codec_vp8_dec_subclass_init, - gst_mini_object_ref (GST_MINI_OBJECT (device)), - (GInstanceInitFunc) gst_v4l2_codec_vp8_dec_subinit, + gst_v4l2_decoder_register (plugin, GST_TYPE_VP8_DECODER, &type_info, "v4l2sl%svp8dec", device, rank, &element_name); if (!element_name) diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c index b6f4f9a642..1282e9f45a 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c @@ -36,10 +36,7 @@ GST_DEBUG_CATEGORY_STATIC (v4l2_vp9dec_debug); #define GST_CAT_DEFAULT v4l2_vp9dec_debug -#define GST_TYPE_V4L2_CODEC_VP9_DEC \ - (gst_v4l2_codec_vp9_dec_get_type()) -#define GST_V4L2_CODEC_VP9_DEC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_V4L2_CODEC_VP9_DEC,GstV4l2CodecVp9Dec)) +#define GST_V4L2_CODEC_VP9_DEC(obj) ((GstV4l2CodecVp9Dec *) obj) /* Used to mark picture that have been outputed */ #define FLAG_PICTURE_HOLDS_BUFFER GST_MINI_OBJECT_FLAG_LAST @@ -115,12 +112,7 @@ struct _GstV4l2CodecVp9Dec guint subsampling_y; }; -static GType gst_v4l2_codec_vp9_dec_get_type (void); - -G_DEFINE_ABSTRACT_TYPE (GstV4l2CodecVp9Dec, gst_v4l2_codec_vp9_dec, - GST_TYPE_VP9_DECODER); - -#define parent_class gst_v4l2_codec_vp9_dec_parent_class +static GstElementClass *parent_class = NULL; static guint gst_v4l2_codec_vp9_dec_get_preferred_output_delay (GstVp9Decoder * decoder, @@ -1179,13 +1171,7 @@ gst_v4l2_codec_vp9_dec_get_property (GObject * object, guint prop_id, } static void -gst_v4l2_codec_vp9_dec_init (GstV4l2CodecVp9Dec * self) -{ - self->need_negotiation = TRUE; -} - -static void -gst_v4l2_codec_vp9_dec_subinit (GstV4l2CodecVp9Dec * self, +gst_v4l2_codec_vp9_dec_init (GstV4l2CodecVp9Dec * self, GstV4l2CodecVp9DecClass * klass) { self->decoder = gst_v4l2_decoder_new (klass->device); @@ -1203,12 +1189,7 @@ gst_v4l2_codec_vp9_dec_dispose (GObject * object) } static void -gst_v4l2_codec_vp9_dec_class_init (GstV4l2CodecVp9DecClass * klass) -{ -} - -static void -gst_v4l2_codec_vp9_dec_subclass_init (GstV4l2CodecVp9DecClass * klass, +gst_v4l2_codec_vp9_dec_class_init (GstV4l2CodecVp9DecClass * klass, GstV4l2CodecDevice * device) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -1226,6 +1207,8 @@ gst_v4l2_codec_vp9_dec_subclass_init (GstV4l2CodecVp9DecClass * klass, "A V4L2 based VP9 video decoder", "Daniel Almeida "); + parent_class = g_type_class_peek_parent (klass); + gst_element_class_add_static_pad_template (element_class, &sink_template); gst_element_class_add_pad_template (element_class, gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, @@ -1286,6 +1269,13 @@ void gst_v4l2_codec_vp9_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, GstV4l2CodecDevice * device, guint rank) { + GTypeInfo type_info = { + .class_size = sizeof (GstV4l2CodecVp9DecClass), + .class_init = (GClassInitFunc) gst_v4l2_codec_vp9_dec_class_init, + .class_data = gst_mini_object_ref (GST_MINI_OBJECT (device)), + .instance_size = sizeof (GstV4l2CodecVp9Dec), + .instance_init = (GInstanceInitFunc) gst_v4l2_codec_vp9_dec_init, + }; gchar *element_name; GstCaps *src_caps = NULL, *alpha_caps; @@ -1315,10 +1305,7 @@ gst_v4l2_codec_vp9_dec_register (GstPlugin * plugin, GstV4l2Decoder * decoder, gst_v4l2_decoder_enum_all_src_formats (decoder, &static_src_caps); register_element: - gst_v4l2_decoder_register (plugin, GST_TYPE_V4L2_CODEC_VP9_DEC, - (GClassInitFunc) gst_v4l2_codec_vp9_dec_subclass_init, - gst_mini_object_ref (GST_MINI_OBJECT (device)), - (GInstanceInitFunc) gst_v4l2_codec_vp9_dec_subinit, + gst_v4l2_decoder_register (plugin, GST_TYPE_VP9_DECODER, &type_info, "v4l2sl%svp9dec", device, rank, &element_name); if (!element_name) diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.c index e4c40aa4c0..4a0c468c94 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.c @@ -1164,13 +1164,11 @@ gst_v4l2_decoder_get_property (GObject * object, guint prop_id, /** * gst_v4l2_decoder_register: * @plugin: a #GstPlugin - * @dec_type: A #GType for the codec - * @class_init: The #GClassInitFunc for #dec_type - * @instance_init: The #GInstanceInitFunc for #dec_type + * @dec_type: Base #GType for the codec + * @type_info: a #GTypeInfo for the codec * @element_name_tmpl: A string to use for the first codec found and as a template for the next ones. * @device: (transfer full) A #GstV4l2CodecDevice * @rank: The rank to use for the element - * @class_data: (nullable) (transfer full) A #gpointer to pass as class_data, set to @device if null * @element_name (nullable) (out) Sets the pointer to the new element name * * Registers a decoder element as a subtype of @dec_type for @plugin. @@ -1179,24 +1177,13 @@ gst_v4l2_decoder_get_property (GObject * object, guint prop_id, */ void gst_v4l2_decoder_register (GstPlugin * plugin, - GType dec_type, GClassInitFunc class_init, gconstpointer class_data, - GInstanceInitFunc instance_init, const gchar * element_name_tmpl, + GType dec_type, GTypeInfo * type_info, const gchar * element_name_tmpl, GstV4l2CodecDevice * device, guint rank, gchar ** element_name) { - GTypeQuery type_query; - GTypeInfo type_info = { 0, }; GType subtype; gchar *type_name; - g_type_query (dec_type, &type_query); - memset (&type_info, 0, sizeof (type_info)); - type_info.class_size = type_query.class_size; - type_info.instance_size = type_query.instance_size; - type_info.class_init = class_init; - type_info.class_data = class_data; - type_info.instance_init = instance_init; - - if (class_data == device) + if (type_info->class_data == device) GST_MINI_OBJECT_FLAG_SET (device, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); /* The first decoder to be registered should use a constant name, like @@ -1213,7 +1200,7 @@ gst_v4l2_decoder_register (GstPlugin * plugin, g_free (basename); } - subtype = g_type_register_static (dec_type, type_name, &type_info, 0); + subtype = g_type_register_static (dec_type, type_name, type_info, 0); if (!gst_element_register (plugin, type_name, rank, subtype)) { GST_WARNING ("Failed to register plugin '%s'", type_name); diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.h b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.h index ebfb4ca4e3..ec410fecc7 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.h +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.h @@ -128,9 +128,7 @@ void gst_v4l2_decoder_get_property (GObject * object, guint prop_id void gst_v4l2_decoder_register (GstPlugin * plugin, GType dec_type, - GClassInitFunc class_init, - gconstpointer class_data, - GInstanceInitFunc instance_init, + GTypeInfo * type_info, const gchar *element_name_tmpl, GstV4l2CodecDevice * device, guint rank,