[gstreamermm] register.h: move code from base_init to class_init
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] register.h: move code from base_init to class_init
- Date: Sun, 25 Sep 2016 13:02:59 +0000 (UTC)
commit 902757b4bcd92eb6d2e743913d73cbce35e3b1f7
Author: Marcin Kolny <marcin kolny gmail com>
Date: Sun Sep 25 15:02:46 2016 +0200
register.h: move code from base_init to class_init
gstreamer/gstreamermm/register.h | 22 +++++++++-------------
tests/plugins/derivedfromappsink.h | 2 +-
tests/plugins/derivedfromappsrc.h | 2 +-
tests/plugins/derivedfrombasetransform.h | 2 +-
tests/plugins/foo.h | 2 +-
tests/plugins/test-plugin-pushsrc.cc | 2 +-
tests/regression/pluginbin.h | 2 +-
tests/test-urihandler.cc | 2 +-
8 files changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/gstreamer/gstreamermm/register.h b/gstreamer/gstreamermm/register.h
index ed9b0bb..db66d17 100644
--- a/gstreamer/gstreamermm/register.h
+++ b/gstreamer/gstreamermm/register.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <glibmm/property.h>
+#include <glibmm/init.h>
#include <gstreamermm/padtemplate.h>
namespace Gst
@@ -36,7 +37,7 @@ class ElementClass
{
friend GType register_mm_type<DerivedCppType>(const gchar * type_name);
GstElementClass* klass;
- ElementClass(typename DerivedCppType::BaseClassType* klass): klass((GstElementClass*)klass){}
+ ElementClass(typename DerivedCppType::BaseClassType* klass): klass((GstElementClass*) klass){}
ElementClass(ElementClass const&);
void operator=(ElementClass const&);
public:
@@ -70,14 +71,10 @@ register_mm_type(const gchar * type_name)
static void init(GlibCppType *instance, gpointer /* g_class */)
{
//instance->parent will be passed to C++ base of DerivedCppType; this will cause registerging
"self" as MM wrapper of "parent"
+ Gst::init();
instance->self = new DerivedCppType(&instance->parent);
-
- }
- static void base_init(typename DerivedCppType::BaseClassType *klass)
- {
- Gst::ElementClass<DerivedCppType> element_class(klass);
- DerivedCppType::base_init(&element_class);
}
+
static void finalize(GObject *object)
{
//the following will destroy q_data, among which MM wrapper to this "object" is stored. This
will cause implicit delete on "self", since it is registered as wrapper of "object".
@@ -95,19 +92,18 @@ register_mm_type(const gchar * type_name)
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
-// gstelement_class = (GstElementClass *) klass;
gobject_class->get_property = &Glib::custom_get_property_callback;
gobject_class->set_property = &Glib::custom_set_property_callback;
gobject_class->finalize = &GlibCppType::finalize;
- }
- static void base_init(typename DerivedCppType::BaseClassType * /* klass */)
- {
- Gst::init();
+ Gst::ElementClass<DerivedCppType> element_class((typename DerivedCppType::BaseClassType*) klass);
+ DerivedCppType::class_init(&element_class);
}
};
+ Glib::init();
+
// the "most derived" pure glib type
GType parent_type = DerivedCppType::get_base_type();
@@ -119,7 +115,7 @@ register_mm_type(const gchar * type_name)
GTypeInfo info;
info.class_size = sizeof(GlibCppTypeClass);
- info.base_init = (GBaseInitFunc)&GlibCppType::base_init;
+ info.base_init = nullptr;
info.base_finalize = nullptr;
info.class_init = (GClassInitFunc) &GlibCppTypeClass::init;
info.class_finalize = nullptr;
diff --git a/tests/plugins/derivedfromappsink.h b/tests/plugins/derivedfromappsink.h
index 178adc6..2ad28f4 100644
--- a/tests/plugins/derivedfromappsink.h
+++ b/tests/plugins/derivedfromappsink.h
@@ -9,7 +9,7 @@
class DerivedFromAppSink : public Gst::AppSink
{
public:
- static void base_init(Gst::ElementClass<DerivedFromAppSink> *klass)
+ static void class_init(Gst::ElementClass<DerivedFromAppSink> *klass)
{
klass->set_metadata("derivedfromappsink_longname",
"derivedfromappsink_classification", "derivedfromappsink_detail_description",
"derivedfromappsink_detail_author");
diff --git a/tests/plugins/derivedfromappsrc.h b/tests/plugins/derivedfromappsrc.h
index d76f9b4..eed8a8c 100644
--- a/tests/plugins/derivedfromappsrc.h
+++ b/tests/plugins/derivedfromappsrc.h
@@ -9,7 +9,7 @@
class DerivedFromAppSrc : public Gst::AppSrc
{
public:
- static void base_init(Gst::ElementClass<DerivedFromAppSrc> *klass)
+ static void class_init(Gst::ElementClass<DerivedFromAppSrc> *klass)
{
klass->set_metadata("derivedfromappsrc_longname",
"derivedfromappsrc_classification", "derivedfromappsrc_detail_description",
"derivedfromappsrc_detail_author");
diff --git a/tests/plugins/derivedfrombasetransform.h b/tests/plugins/derivedfrombasetransform.h
index 9319f7b..9950995 100644
--- a/tests/plugins/derivedfrombasetransform.h
+++ b/tests/plugins/derivedfrombasetransform.h
@@ -8,7 +8,7 @@
class DerivedFromBaseTransform : public Gst::BaseTransform
{
public:
- static void base_init(Gst::ElementClass<DerivedFromBaseTransform> *klass)
+ static void class_init(Gst::ElementClass<DerivedFromBaseTransform> *klass)
{
klass->set_metadata("derivedfrombasetransform_longname",
"derivedfrombasetransform_classification", "derivedfrombasetransform_detail_description",
"derivedfrombasetransform_detail_author");
diff --git a/tests/plugins/foo.h b/tests/plugins/foo.h
index c74cd9d..5186199 100644
--- a/tests/plugins/foo.h
+++ b/tests/plugins/foo.h
@@ -19,7 +19,7 @@ class Foo : public Gst::Element
Glib::Property<Glib::ustring> sample_property;
public:
- static void base_init(Gst::ElementClass<Foo> *klass)
+ static void class_init(Gst::ElementClass<Foo> *klass)
{
klass->set_metadata("foo_longname",
"foo_classification", "foo_detail_description", "foo_detail_author");
diff --git a/tests/plugins/test-plugin-pushsrc.cc b/tests/plugins/test-plugin-pushsrc.cc
index a207724..bd057ae 100644
--- a/tests/plugins/test-plugin-pushsrc.cc
+++ b/tests/plugins/test-plugin-pushsrc.cc
@@ -20,7 +20,7 @@ class FooSrc : public Gst::PushSrc
public:
static const int COUNT = 5;
- static void base_init(Gst::ElementClass<FooSrc> *klass)
+ static void class_init(Gst::ElementClass<FooSrc> *klass)
{
klass->set_metadata("foosrc_longname",
"foosrc_classification", "foosrc_detail_description", "foosrc_detail_author");
diff --git a/tests/regression/pluginbin.h b/tests/regression/pluginbin.h
index bb973ee..a62f6da 100644
--- a/tests/regression/pluginbin.h
+++ b/tests/regression/pluginbin.h
@@ -23,7 +23,7 @@ private:
Glib::Property<Glib::ustring> location;
public:
- static void base_init(Gst::ElementClass<PluginBin> *klass)
+ static void class_init(Gst::ElementClass<PluginBin> *klass)
{
klass->set_metadata("Custom test bin", "test/bins", "test bin", "author");
}
diff --git a/tests/test-urihandler.cc b/tests/test-urihandler.cc
index 49d4389..a974db9 100644
--- a/tests/test-urihandler.cc
+++ b/tests/test-urihandler.cc
@@ -22,7 +22,7 @@ public:
return Element::get_base_type();
}
- static void base_init(Gst::ElementClass<UriTestElement> *klass)
+ static void class_init(Gst::ElementClass<UriTestElement> *klass)
{
klass->set_metadata("uri_longname", "uri_classification",
"uri_detail_description", "uri_detail_author");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]