From 0f1741da23a1705db4889db31c0dd0113a9e8d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 19 Apr 2011 10:47:15 +0200 Subject: [PATCH] app: Use G_DEFINE_TYPE instead of GST_BOILERPLATE --- gst-libs/gst/app/gstappsink.c | 45 ++++++++++++----------------------- gst-libs/gst/app/gstappsrc.c | 44 +++++++++++----------------------- 2 files changed, 29 insertions(+), 60 deletions(-) diff --git a/gst-libs/gst/app/gstappsink.c b/gst-libs/gst/app/gstappsink.c index 11dff3222f..7d4445b2ed 100644 --- a/gst-libs/gst/app/gstappsink.c +++ b/gst-libs/gst/app/gstappsink.c @@ -185,20 +185,10 @@ static GstMiniObject *gst_app_sink_pull_object (GstAppSink * appsink); static guint gst_app_sink_signals[LAST_SIGNAL] = { 0 }; -static void -_do_init (GType filesrc_type) -{ - static const GInterfaceInfo urihandler_info = { - gst_app_sink_uri_handler_init, - NULL, - NULL - }; - g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, - &urihandler_info); -} - -GST_BOILERPLATE_FULL (GstAppSink, gst_app_sink, GstBaseSink, GST_TYPE_BASE_SINK, - _do_init); +#define gst_app_sink_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstAppSink, gst_app_sink, GST_TYPE_BASE_SINK, + G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, + gst_app_sink_uri_handler_init)); /* Can't use glib-genmarshal for this, as it doesn't know how to handle * GstMiniObject-based types, which are a new fundamental type */ @@ -234,27 +224,15 @@ gst_app_marshal_BUFFER__VOID (GClosure * closure, gst_value_take_buffer (return_value, v_return); } -static void -gst_app_sink_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - - GST_DEBUG_CATEGORY_INIT (app_sink_debug, "appsink", 0, "appsink element"); - - gst_element_class_set_details_simple (element_class, "AppSink", - "Generic/Sink", "Allow the application to get access to raw buffer", - "David Schleef , Wim Taymans "); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_app_sink_template)); -} - static void gst_app_sink_class_init (GstAppSinkClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; + GstElementClass *element_class = (GstElementClass *) klass; GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass; + GST_DEBUG_CATEGORY_INIT (app_sink_debug, "appsink", 0, "appsink element"); + gobject_class->dispose = gst_app_sink_dispose; gobject_class->finalize = gst_app_sink_finalize; @@ -441,6 +419,13 @@ gst_app_sink_class_init (GstAppSinkClass * klass) pull_buffer_list), NULL, NULL, gst_app_marshal_BUFFER__VOID, GST_TYPE_BUFFER_LIST, 0, G_TYPE_NONE); + gst_element_class_set_details_simple (element_class, "AppSink", + "Generic/Sink", "Allow the application to get access to raw buffer", + "David Schleef , Wim Taymans "); + + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_app_sink_template)); + basesink_class->unlock = gst_app_sink_unlock_start; basesink_class->unlock_stop = gst_app_sink_unlock_stop; basesink_class->start = gst_app_sink_start; @@ -459,7 +444,7 @@ gst_app_sink_class_init (GstAppSinkClass * klass) } static void -gst_app_sink_init (GstAppSink * appsink, GstAppSinkClass * klass) +gst_app_sink_init (GstAppSink * appsink) { GstAppSinkPrivate *priv; diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c index 08831414a6..6f2be8074b 100644 --- a/gst-libs/gst/app/gstappsrc.c +++ b/gst-libs/gst/app/gstappsrc.c @@ -249,42 +249,19 @@ static GstFlowReturn gst_app_src_push_buffer_action (GstAppSrc * appsrc, static guint gst_app_src_signals[LAST_SIGNAL] = { 0 }; -static void -_do_init (GType filesrc_type) -{ - static const GInterfaceInfo urihandler_info = { - gst_app_src_uri_handler_init, - NULL, - NULL - }; - g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, - &urihandler_info); -} - -GST_BOILERPLATE_FULL (GstAppSrc, gst_app_src, GstBaseSrc, GST_TYPE_BASE_SRC, - _do_init); - -static void -gst_app_src_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - - GST_DEBUG_CATEGORY_INIT (app_src_debug, "appsrc", 0, "appsrc element"); - - gst_element_class_set_details_simple (element_class, "AppSrc", - "Generic/Source", "Allow the application to feed buffers to a pipeline", - "David Schleef , Wim Taymans "); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_app_src_template)); -} +#define gst_app_src_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstAppSrc, gst_app_src, GST_TYPE_BASE_SRC, + G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_app_src_uri_handler_init)); static void gst_app_src_class_init (GstAppSrcClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; + GstElementClass *element_class = (GstElementClass *) klass; GstBaseSrcClass *basesrc_class = (GstBaseSrcClass *) klass; + GST_DEBUG_CATEGORY_INIT (app_src_debug, "appsrc", 0, "appsrc element"); + gobject_class->dispose = gst_app_src_dispose; gobject_class->finalize = gst_app_src_finalize; @@ -498,6 +475,13 @@ gst_app_src_class_init (GstAppSrcClass * klass) end_of_stream), NULL, NULL, __gst_app_marshal_ENUM__VOID, GST_TYPE_FLOW_RETURN, 0, G_TYPE_NONE); + gst_element_class_set_details_simple (element_class, "AppSrc", + "Generic/Source", "Allow the application to feed buffers to a pipeline", + "David Schleef , Wim Taymans "); + + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_app_src_template)); + basesrc_class->create = gst_app_src_create; basesrc_class->start = gst_app_src_start; basesrc_class->stop = gst_app_src_stop; @@ -517,7 +501,7 @@ gst_app_src_class_init (GstAppSrcClass * klass) } static void -gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass) +gst_app_src_init (GstAppSrc * appsrc) { GstAppSrcPrivate *priv;