diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2020-03-14 15:25:59 +0100 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2020-03-14 15:27:38 +0100 |
commit | 581abbd4cc45dc4cd8a7d971349ea09002c3959a (patch) | |
tree | 74062ba6bc26a9c699326cc79cd29005473093fc /gst-plugin | |
parent | c363a3105e80c560f18500948ff1d0e1b7eca6e9 (diff) |
Use G_DECLARE_FINAL_TYPE()
The GObject boilerplate macro's which you need to define a new type can
be quite daunting. GLib added `G_DECLARE_FINAL_TYPE()` to mitigate this
in 2.44 already, which is now also a hard dependency of GStreamer. Let's
use this in our advantage to clean up code for people who want to write
GStreamer for the first time.
Diffstat (limited to 'gst-plugin')
-rw-r--r-- | gst-plugin/src/gstaudiofilter.c | 23 | ||||
-rw-r--r-- | gst-plugin/src/gstplugin.h | 25 | ||||
-rw-r--r-- | gst-plugin/src/gsttransform.h | 23 |
3 files changed, 12 insertions, 59 deletions
diff --git a/gst-plugin/src/gstaudiofilter.c b/gst-plugin/src/gstaudiofilter.c index 5b3ff0c..0c67a9f 100644 --- a/gst-plugin/src/gstaudiofilter.c +++ b/gst-plugin/src/gstaudiofilter.c @@ -1,6 +1,7 @@ /* GStreamer audio filter example class * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> * Copyright (C) <2003> David Schleef <ds@schleef.org> + * Copyright (C) <2020> Niels De Graef <niels.degraef@gmail.com> * Copyright (C) YEAR AUTHOR_NAME AUTHOR_EMAIL * * Permission is hereby granted, free of charge, to any person obtaining a @@ -67,20 +68,9 @@ GST_DEBUG_CATEGORY_STATIC (audiofiltertemplate_debug); #define GST_CAT_DEFAULT audiofiltertemplate_debug -typedef struct _GstAudioFilterTemplate GstAudioFilterTemplate; -typedef struct _GstAudioFilterTemplateClass GstAudioFilterTemplateClass; - -/* These are boilerplate cast macros and type check macros */ -#define GST_TYPE_AUDIO_FILTER_TEMPLATE \ - (gst_audio_filter_template_get_type()) -#define GST_AUDIO_FILTER_TEMPLATE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_FILTER_TEMPLATE,GstAudioFilterTemplate)) -#define GST_AUDIO_FILTER_TEMPLATE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_FILTER_TEMPLATE,GstAudioFilterTemplateClass)) -#define GST_IS_AUDIO_FILTER_TEMPLATE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_FILTER_TEMPLATE)) -#define GST_IS_AUDIO_FILTER_TEMPLATE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_FILTER_TEMPLATE)) +#define GST_TYPE_AUDIO_FILTER_TEMPLATE (gst_audio_filter_template_get_type()) +G_DECLARE_FINAL_TYPE (GstAudioFilterTemplate, gst_audio_filter_template, + GST, AUDIO_FILTER_TEMPLATE, GstAudioFilter) struct _GstAudioFilterTemplate { @@ -90,11 +80,6 @@ struct _GstAudioFilterTemplate * data such as properties */ }; -struct _GstAudioFilterTemplateClass -{ - GstAudioFilterClass audiofilter_class; -}; - enum { diff --git a/gst-plugin/src/gstplugin.h b/gst-plugin/src/gstplugin.h index f1fe4ed..5d6a647 100644 --- a/gst-plugin/src/gstplugin.h +++ b/gst-plugin/src/gstplugin.h @@ -2,6 +2,7 @@ * GStreamer * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org> * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net> + * Copyright (C) 2020 Niels De Graef <niels.degraef@gmail.com> * Copyright (C) YEAR AUTHOR_NAME AUTHOR_EMAIL * * Permission is hereby granted, free of charge, to any person obtaining a @@ -50,20 +51,9 @@ G_BEGIN_DECLS -/* #defines don't like whitespacey bits */ -#define GST_TYPE_PLUGIN_TEMPLATE \ - (gst_plugin_template_get_type()) -#define GST_PLUGIN_TEMPLATE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplate)) -#define GST_PLUGIN_TEMPLATE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplateClass)) -#define GST_IS_PLUGIN_TEMPLATE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLUGIN_TEMPLATE)) -#define GST_IS_PLUGIN_TEMPLATE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLUGIN_TEMPLATE)) - -typedef struct _GstPluginTemplate GstPluginTemplate; -typedef struct _GstPluginTemplateClass GstPluginTemplateClass; +#define GST_TYPE_PLUGIN_TEMPLATE (gst_plugin_template_get_type()) +G_DECLARE_FINAL_TYPE (GstPluginTemplate, gst_plugin_template, + GST, PLUGIN_TEMPLATE, GstElement) struct _GstPluginTemplate { @@ -74,13 +64,6 @@ struct _GstPluginTemplate gboolean silent; }; -struct _GstPluginTemplateClass -{ - GstElementClass parent_class; -}; - -GType gst_plugin_template_get_type (void); - G_END_DECLS #endif /* __GST_PLUGIN_TEMPLATE_H__ */ diff --git a/gst-plugin/src/gsttransform.h b/gst-plugin/src/gsttransform.h index be9ce86..548b2f8 100644 --- a/gst-plugin/src/gsttransform.h +++ b/gst-plugin/src/gsttransform.h @@ -1,6 +1,7 @@ /* * GStreamer * Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net> + * Copyright (C) 2020 Niels De Graef <niels.degraef@gmail.com> * Copyright (C) YEAR AUTHOR_NAME AUTHOR_EMAIL * * This library is free software; you can redistribute it and/or @@ -27,19 +28,9 @@ G_BEGIN_DECLS -#define GST_TYPE_PLUGIN_TEMPLATE \ - (gst_plugin_template_get_type()) -#define GST_PLUGIN_TEMPLATE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplate)) -#define GST_PLUGIN_TEMPLATE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplateClass)) -#define GST_IS_PLUGIN_TEMPLATE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLUGIN_TEMPLATE)) -#define GST_IS_PLUGIN_TEMPLATE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLUGIN_TEMPLATE)) - -typedef struct _GstPluginTemplate GstPluginTemplate; -typedef struct _GstPluginTemplateClass GstPluginTemplateClass; +#define GST_TYPE_PLUGIN_TEMPLATE (gst_plugin_template_get_type()) +G_DECLARE_FINAL_TYPE (GstPluginTemplate, gst_plugin_template, + GST, PLUGIN_TEMPLATE, GstBaseTransform) struct _GstPluginTemplate { GstBaseTransform element; @@ -47,12 +38,6 @@ struct _GstPluginTemplate { gboolean silent; }; -struct _GstPluginTemplateClass { - GstBaseTransformClass parent_class; -}; - -GType gst_plugin_template_get_type (void); - G_END_DECLS #endif /* __GST_PLUGIN_TEMPLATE_H__ */ |