plugins: use G_DEFINE_TYPE_* instead of deprecated GST_BOILERPLATE_*.
authorJavier Jardón <jjardon@gnome.org>
Sat, 30 Jun 2012 17:58:36 +0000 (02:58 +0900)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 19 Jul 2012 09:25:15 +0000 (11:25 +0200)
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
configure.ac
gst/vaapi/gstvaapidecode.c
gst/vaapi/gstvaapidownload.c
gst/vaapi/gstvaapipostproc.c
gst/vaapi/gstvaapisink.c
gst/vaapi/gstvaapiupload.c

index ffe158b..6201f3d 100644 (file)
@@ -9,6 +9,15 @@ m4_if(gst_vaapi_pre_version, [0], [], [
 m4_append([gst_vaapi_version], gst_vaapi_pre_version, [.pre])
 ])
 
+# glib version number
+m4_define([glib_major_version], [2])
+m4_define([glib_minor_version], [4])
+m4_define([glib_micro_version], [0])
+m4_define([glib_major_minor_version],
+          [glib_major_version.glib_minor_version])
+m4_define([glib_version],
+          [glib_major_version.glib_minor_version.glib_micro_version])
+
 # gst version number
 m4_define([gst_major_version], [0])
 m4_define([gst_minor_version], [10])
@@ -146,7 +155,7 @@ AC_SUBST(GTKDOC_VERSION)
 
 dnl Check for GLib
 AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
-PKG_CHECK_MODULES([GLIB], [glib-2.0])
+PKG_CHECK_MODULES([GLIB], [glib-2.0 >= glib_version])
 AC_CHECK_LIB([glib-2.0], [g_list_free_full], [
     AC_DEFINE([HAVE_G_LIST_FREE_FULL], [1],
               [Define to 1 if g_list_free_full() is available.])])
index 6595566..ea34345 100644 (file)
@@ -104,15 +104,16 @@ static GstStaticPadTemplate gst_vaapidecode_src_factory =
         GST_PAD_ALWAYS,
         GST_STATIC_CAPS(gst_vaapidecode_src_caps_str));
 
+static void
+gst_video_context_interface_init(GstVideoContextInterface *iface);
+
 #define GstVideoContextClass GstVideoContextInterface
-GST_BOILERPLATE_WITH_INTERFACE(
+G_DEFINE_TYPE_WITH_CODE(
     GstVaapiDecode,
     gst_vaapidecode,
-    GstElement,
     GST_TYPE_ELEMENT,
-    GstVideoContext,
-    GST_TYPE_VIDEO_CONTEXT,
-    gst_video_context);
+    G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
+                          gst_video_context_interface_init));
 
 enum {
     PROP_0,
@@ -426,31 +427,6 @@ gst_video_context_interface_init(GstVideoContextInterface *iface)
 }
 
 static void
-gst_vaapidecode_base_init(gpointer klass)
-{
-    GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
-    GstPadTemplate *pad_template;
-
-    gst_element_class_set_details_simple(
-        element_class,
-        gst_vaapidecode_details.longname,
-        gst_vaapidecode_details.klass,
-        gst_vaapidecode_details.description,
-        gst_vaapidecode_details.author
-    );
-
-    /* sink pad */
-    pad_template = gst_static_pad_template_get(&gst_vaapidecode_sink_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-
-    /* src pad */
-    pad_template = gst_static_pad_template_get(&gst_vaapidecode_src_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-}
-
-static void
 gst_vaapidecode_finalize(GObject *object)
 {
     GstVaapiDecode * const decode = GST_VAAPIDECODE(object);
@@ -482,7 +458,7 @@ gst_vaapidecode_finalize(GObject *object)
         decode->delayed_new_seg = NULL;
     }
 
-    G_OBJECT_CLASS(parent_class)->finalize(object);
+    G_OBJECT_CLASS(gst_vaapidecode_parent_class)->finalize(object);
 }
 
 static void
@@ -543,7 +519,7 @@ gst_vaapidecode_change_state(GstElement *element, GstStateChange transition)
         break;
     }
 
-    ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
+    ret = GST_ELEMENT_CLASS(gst_vaapidecode_parent_class)->change_state(element, transition);
     if (ret != GST_STATE_CHANGE_SUCCESS)
         return ret;
 
@@ -571,6 +547,7 @@ gst_vaapidecode_class_init(GstVaapiDecodeClass *klass)
 {
     GObjectClass * const object_class = G_OBJECT_CLASS(klass);
     GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
+    GstPadTemplate *pad_template;
 
     GST_DEBUG_CATEGORY_INIT(gst_debug_vaapidecode,
                             GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
@@ -581,6 +558,24 @@ gst_vaapidecode_class_init(GstVaapiDecodeClass *klass)
 
     element_class->change_state = gst_vaapidecode_change_state;
 
+    gst_element_class_set_details_simple(
+        element_class,
+        gst_vaapidecode_details.longname,
+        gst_vaapidecode_details.klass,
+        gst_vaapidecode_details.description,
+        gst_vaapidecode_details.author
+    );
+
+    /* sink pad */
+    pad_template = gst_static_pad_template_get(&gst_vaapidecode_sink_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
+
+    /* src pad */
+    pad_template = gst_static_pad_template_get(&gst_vaapidecode_src_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
+
 #if USE_FFMPEG
     g_object_class_install_property
         (object_class,
@@ -764,8 +759,9 @@ gst_vaapidecode_query (GstPad *pad, GstQuery *query) {
 }
 
 static void
-gst_vaapidecode_init(GstVaapiDecode *decode, GstVaapiDecodeClass *klass)
+gst_vaapidecode_init(GstVaapiDecode *decode)
 {
+    GstVaapiDecodeClass *klass = GST_VAAPIDECODE_GET_CLASS(decode);
     GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
 
     decode->display             = NULL;
index 31e7eea..eb0c7c5 100644 (file)
@@ -108,15 +108,16 @@ struct _GstVaapiDownloadClass {
     GstBaseTransformClass parent_class;
 };
 
+static void
+gst_video_context_interface_init(GstVideoContextInterface *iface);
+
 #define GstVideoContextClass GstVideoContextInterface
-GST_BOILERPLATE_WITH_INTERFACE(
+G_DEFINE_TYPE_WITH_CODE(
     GstVaapiDownload,
     gst_vaapidownload,
-    GstBaseTransform,
     GST_TYPE_BASE_TRANSFORM,
-    GstVideoContext,
-    GST_TYPE_VIDEO_CONTEXT,
-    gst_video_context);
+    G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
+                          gst_video_context_interface_init));
 
 static gboolean
 gst_vaapidownload_start(GstBaseTransform *trans);
@@ -217,36 +218,11 @@ gst_vaapidownload_destroy(GstVaapiDownload *download)
 }
 
 static void
-gst_vaapidownload_base_init(gpointer klass)
-{
-    GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
-    GstPadTemplate *pad_template;
-
-    gst_element_class_set_details_simple(
-        element_class,
-        gst_vaapidownload_details.longname,
-        gst_vaapidownload_details.klass,
-        gst_vaapidownload_details.description,
-        gst_vaapidownload_details.author
-    );
-
-    /* sink pad */
-    pad_template = gst_static_pad_template_get(&gst_vaapidownload_sink_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-
-    /* src pad */
-    pad_template = gst_static_pad_template_get(&gst_vaapidownload_src_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-}
-
-static void
 gst_vaapidownload_finalize(GObject *object)
 {
     gst_vaapidownload_destroy(GST_VAAPIDOWNLOAD(object));
 
-    G_OBJECT_CLASS(parent_class)->finalize(object);
+    G_OBJECT_CLASS(gst_vaapidownload_parent_class)->finalize(object);
 }
 
 static void
@@ -254,6 +230,8 @@ gst_vaapidownload_class_init(GstVaapiDownloadClass *klass)
 {
     GObjectClass * const object_class = G_OBJECT_CLASS(klass);
     GstBaseTransformClass * const trans_class = GST_BASE_TRANSFORM_CLASS(klass);
+    GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
+    GstPadTemplate *pad_template;
 
     GST_DEBUG_CATEGORY_INIT(gst_debug_vaapidownload,
                             GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
@@ -266,10 +244,28 @@ gst_vaapidownload_class_init(GstVaapiDownloadClass *klass)
     trans_class->transform_caps   = gst_vaapidownload_transform_caps;
     trans_class->transform_size   = gst_vaapidownload_transform_size;
     trans_class->set_caps         = gst_vaapidownload_set_caps;
+
+    gst_element_class_set_details_simple(
+        element_class,
+        gst_vaapidownload_details.longname,
+        gst_vaapidownload_details.klass,
+        gst_vaapidownload_details.description,
+        gst_vaapidownload_details.author
+    );
+
+    /* sink pad */
+    pad_template = gst_static_pad_template_get(&gst_vaapidownload_sink_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
+
+    /* src pad */
+    pad_template = gst_static_pad_template_get(&gst_vaapidownload_src_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
 }
 
 static void
-gst_vaapidownload_init(GstVaapiDownload *download, GstVaapiDownloadClass *klass)
+gst_vaapidownload_init(GstVaapiDownload *download)
 {
     GstPad *sinkpad, *srcpad;
 
index 476ce19..8d38a35 100644 (file)
@@ -74,15 +74,16 @@ static GstStaticPadTemplate gst_vaapipostproc_src_factory =
         GST_PAD_ALWAYS,
         GST_STATIC_CAPS(gst_vaapipostproc_src_caps_str));
 
+static void
+gst_video_context_interface_init(GstVideoContextInterface *iface);
+
 #define GstVideoContextClass GstVideoContextInterface
-GST_BOILERPLATE_WITH_INTERFACE(
+G_DEFINE_TYPE_WITH_CODE(
     GstVaapiPostproc,
     gst_vaapipostproc,
-    GstElement,
     GST_TYPE_ELEMENT,
-    GstVideoContext,
-    GST_TYPE_VIDEO_CONTEXT,
-    gst_video_context);
+    G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
+                          gst_video_context_interface_init));
 
 enum {
     PROP_0,
@@ -526,7 +527,7 @@ gst_vaapipostproc_finalize(GObject *object)
     gst_caps_replace(&postproc->srcpad_caps,  NULL);
     gst_caps_replace(&postproc->allowed_caps, NULL);
 
-    G_OBJECT_CLASS(parent_class)->finalize(object);
+    G_OBJECT_CLASS(gst_vaapipostproc_parent_class)->finalize(object);
 }
 
 static void
@@ -594,7 +595,7 @@ gst_vaapipostproc_change_state(GstElement *element, GstStateChange transition)
         break;
     }
 
-    ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition);
+    ret = GST_ELEMENT_CLASS(gst_vaapipostproc_parent_class)->change_state(element, transition);
     if (ret != GST_STATE_CHANGE_SUCCESS)
         return ret;
 
@@ -618,6 +619,7 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
 {
     GObjectClass * const object_class = G_OBJECT_CLASS(klass);
     GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
+    GstPadTemplate *pad_template;
 
     GST_DEBUG_CATEGORY_INIT(gst_debug_vaapipostproc,
                             GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
@@ -628,6 +630,24 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
 
     element_class->change_state = gst_vaapipostproc_change_state;
 
+    gst_element_class_set_details_simple(
+        element_class,
+        gst_vaapipostproc_details.longname,
+        gst_vaapipostproc_details.klass,
+        gst_vaapipostproc_details.description,
+        gst_vaapipostproc_details.author
+    );
+
+    /* sink pad */
+    pad_template = gst_static_pad_template_get(&gst_vaapipostproc_sink_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
+
+    /* src pad */
+    pad_template = gst_static_pad_template_get(&gst_vaapipostproc_src_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
+
     /**
      * GstVaapiPostproc:deinterlace-mode:
      *
@@ -662,33 +682,9 @@ gst_vaapipostproc_class_init(GstVaapiPostprocClass *klass)
 }
 
 static void
-gst_vaapipostproc_base_init(gpointer klass)
-{
-    GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
-    GstPadTemplate *pad_template;
-
-    gst_element_class_set_details_simple(
-        element_class,
-        gst_vaapipostproc_details.longname,
-        gst_vaapipostproc_details.klass,
-        gst_vaapipostproc_details.description,
-        gst_vaapipostproc_details.author
-    );
-
-    /* sink pad */
-    pad_template = gst_static_pad_template_get(&gst_vaapipostproc_sink_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-
-    /* src pad */
-    pad_template = gst_static_pad_template_get(&gst_vaapipostproc_src_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-}
-
-static void
-gst_vaapipostproc_init(GstVaapiPostproc *postproc, GstVaapiPostprocClass *klass)
+gst_vaapipostproc_init(GstVaapiPostproc *postproc)
 {
+    GstVaapiPostprocClass *klass = GST_VAAPIPOSTPROC_GET_CLASS(postproc);
     GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
 
     postproc->allowed_caps              = NULL;
index 8c84d33..2c7f268 100644 (file)
@@ -77,14 +77,25 @@ static GstStaticPadTemplate gst_vaapisink_sink_factory =
         GST_PAD_ALWAYS,
         GST_STATIC_CAPS(GST_VAAPI_SURFACE_CAPS));
 
-static void gst_vaapisink_iface_init(GType type);
+static void
+gst_vaapisink_implements_iface_init(GstImplementsInterfaceClass *iface);
+
+static void
+gst_vaapisink_video_context_iface_init(GstVideoContextInterface *iface);
 
-GST_BOILERPLATE_FULL(
+static void
+gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface);
+
+G_DEFINE_TYPE_WITH_CODE(
     GstVaapiSink,
     gst_vaapisink,
-    GstVideoSink,
     GST_TYPE_VIDEO_SINK,
-    gst_vaapisink_iface_init);
+    G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
+                          gst_vaapisink_implements_iface_init);
+    G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
+                          gst_vaapisink_video_context_iface_init);
+    G_IMPLEMENT_INTERFACE(GST_TYPE_X_OVERLAY,
+                          gst_vaapisink_xoverlay_iface_init));
 
 enum {
     PROP_0,
@@ -216,19 +227,6 @@ gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface)
 }
 
 static void
-gst_vaapisink_iface_init(GType type)
-{
-    const GType g_define_type_id = type;
-
-    G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
-                          gst_vaapisink_implements_iface_init);
-    G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
-                          gst_vaapisink_video_context_iface_init);
-    G_IMPLEMENT_INTERFACE(GST_TYPE_X_OVERLAY,
-                          gst_vaapisink_xoverlay_iface_init);
-}
-
-static void
 gst_vaapisink_destroy(GstVaapiSink *sink)
 {
     if (sink->texture) {
@@ -733,7 +731,7 @@ gst_vaapisink_finalize(GObject *object)
 {
     gst_vaapisink_destroy(GST_VAAPISINK(object));
 
-    G_OBJECT_CLASS(parent_class)->finalize(object);
+    G_OBJECT_CLASS(gst_vaapisink_parent_class)->finalize(object);
 }
 
 static void
@@ -795,29 +793,12 @@ gst_vaapisink_get_property(
 }
 
 static void
-gst_vaapisink_base_init(gpointer klass)
-{
-    GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
-    GstPadTemplate *pad_template;
-
-    gst_element_class_set_details_simple(
-        element_class,
-        gst_vaapisink_details.longname,
-        gst_vaapisink_details.klass,
-        gst_vaapisink_details.description,
-        gst_vaapisink_details.author
-    );
-
-    pad_template = gst_static_pad_template_get(&gst_vaapisink_sink_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-}
-
-static void
 gst_vaapisink_class_init(GstVaapiSinkClass *klass)
 {
     GObjectClass * const     object_class   = G_OBJECT_CLASS(klass);
+    GstElementClass * const  element_class  = GST_ELEMENT_CLASS(klass);
     GstBaseSinkClass * const basesink_class = GST_BASE_SINK_CLASS(klass);
+    GstPadTemplate *pad_template;
 
     GST_DEBUG_CATEGORY_INIT(gst_debug_vaapisink,
                             GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
@@ -833,6 +814,18 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
     basesink_class->render       = gst_vaapisink_show_frame;
     basesink_class->query        = gst_vaapisink_query;
 
+    gst_element_class_set_details_simple(
+        element_class,
+        gst_vaapisink_details.longname,
+        gst_vaapisink_details.klass,
+        gst_vaapisink_details.description,
+        gst_vaapisink_details.author
+    );
+
+    pad_template = gst_static_pad_template_get(&gst_vaapisink_sink_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
+
 #if USE_VAAPISINK_GLX
     g_object_class_install_property
         (object_class,
@@ -879,7 +872,7 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
 }
 
 static void
-gst_vaapisink_init(GstVaapiSink *sink, GstVaapiSinkClass *klass)
+gst_vaapisink_init(GstVaapiSink *sink)
 {
     sink->caps           = NULL;
     sink->display        = NULL;
index 923a6f6..d96f366 100644 (file)
@@ -84,15 +84,16 @@ static GstStaticPadTemplate gst_vaapiupload_src_factory =
         GST_PAD_ALWAYS,
         GST_STATIC_CAPS(gst_vaapiupload_vaapi_caps_str));
 
+static void
+gst_video_context_interface_init(GstVideoContextInterface *iface);
+
 #define GstVideoContextClass GstVideoContextInterface
-GST_BOILERPLATE_WITH_INTERFACE(
+G_DEFINE_TYPE_WITH_CODE(
     GstVaapiUpload,
     gst_vaapiupload,
-    GstBaseTransform,
     GST_TYPE_BASE_TRANSFORM,
-    GstVideoContext,
-    GST_TYPE_VIDEO_CONTEXT,
-    gst_video_context);
+    G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
+                          gst_video_context_interface_init));
 
 /*
  * Direct rendering levels (direct-rendering)
@@ -208,36 +209,11 @@ gst_vaapiupload_destroy(GstVaapiUpload *upload)
 }
 
 static void
-gst_vaapiupload_base_init(gpointer klass)
-{
-    GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
-    GstPadTemplate *pad_template;
-
-    gst_element_class_set_details_simple(
-        element_class,
-        gst_vaapiupload_details.longname,
-        gst_vaapiupload_details.klass,
-        gst_vaapiupload_details.description,
-        gst_vaapiupload_details.author
-    );
-
-    /* sink pad */
-    pad_template = gst_static_pad_template_get(&gst_vaapiupload_sink_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-
-    /* src pad */
-    pad_template = gst_static_pad_template_get(&gst_vaapiupload_src_factory);
-    gst_element_class_add_pad_template(element_class, pad_template);
-    gst_object_unref(pad_template);
-}
-
-static void
 gst_vaapiupload_finalize(GObject *object)
 {
     gst_vaapiupload_destroy(GST_VAAPIUPLOAD(object));
 
-    G_OBJECT_CLASS(parent_class)->finalize(object);
+    G_OBJECT_CLASS(gst_vaapiupload_parent_class)->finalize(object);
 }
 
 
@@ -287,7 +263,9 @@ static void
 gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
 {
     GObjectClass * const object_class = G_OBJECT_CLASS(klass);
+    GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
     GstBaseTransformClass * const trans_class = GST_BASE_TRANSFORM_CLASS(klass);
+    GstPadTemplate *pad_template;
 
     GST_DEBUG_CATEGORY_INIT(gst_debug_vaapiupload,
                             GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
@@ -304,6 +282,24 @@ gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
     trans_class->get_unit_size  = gst_vaapiupload_get_unit_size;
     trans_class->prepare_output_buffer = gst_vaapiupload_prepare_output_buffer;
 
+    gst_element_class_set_details_simple(
+        element_class,
+        gst_vaapiupload_details.longname,
+        gst_vaapiupload_details.klass,
+        gst_vaapiupload_details.description,
+        gst_vaapiupload_details.author
+    );
+
+    /* sink pad */
+    pad_template = gst_static_pad_template_get(&gst_vaapiupload_sink_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
+
+    /* src pad */
+    pad_template = gst_static_pad_template_get(&gst_vaapiupload_src_factory);
+    gst_element_class_add_pad_template(element_class, pad_template);
+    gst_object_unref(pad_template);
+
     /**
      * GstVaapiUpload:direct-rendering:
      *
@@ -335,7 +331,7 @@ gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
 }
 
 static void
-gst_vaapiupload_init(GstVaapiUpload *upload, GstVaapiUploadClass *klass)
+gst_vaapiupload_init(GstVaapiUpload *upload)
 {
     GstPad *sinkpad, *srcpad;