gnomemm r1783 - in gstreamermm/trunk: . build_shared gstreamer/src gstreamerbase/src tests tools/extra_defs_gen
- From: jaalburqu svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1783 - in gstreamermm/trunk: . build_shared gstreamer/src gstreamerbase/src tests tools/extra_defs_gen
- Date: Wed, 12 Nov 2008 20:39:09 +0000 (UTC)
Author: jaalburqu
Date: Wed Nov 12 20:39:09 2008
New Revision: 1783
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1783&view=rev
Log:
2008-11-12 Josà Alburquerque <jaalburqu svn gnome org>
* tools/extra_defs_gen/Makefile.am:
* tools/extra_defs_gen/generate_plugin_gmmproc_file.cc:
* tools/extra_defs_gen/generate_plugin_hg_file.cc: Renamed
generate_plugin_hg_file.cc to generate_plugin_gmmproc_file.cc.
Modified it to generate both .hg and .ccg files. Made it generate
basic stuff (class declaration, simple class docs and a *_get_type()
function which is needed for compilation).
* build_shared/Makefile_gensrc.am_fragment: Also made build process
use plugin geneneration tool to generate plugin .ccg file.
* gstreamer/src/Makefile.am:
* gstreamerbase/src/Makefile.am: Removed .defs extension in
declaration of `main_defs =' variable (used to pass the main def that
the plugin gen. tool should use).
* gstreamer/src/Makefile_list_of_hg.am_fragment: Added `fakesrc.hg' to
`files_plugin_hg =' list to test plugin generation.
* tests/Makefile.am:
* tests/test-plugin-gen.cc: Added minimal test.
Added:
gstreamermm/trunk/tests/test-plugin-gen.cc
gstreamermm/trunk/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
Removed:
gstreamermm/trunk/tools/extra_defs_gen/generate_plugin_hg_file.cc
Modified:
gstreamermm/trunk/ChangeLog
gstreamermm/trunk/build_shared/Makefile_gensrc.am_fragment
gstreamermm/trunk/gstreamer/src/Makefile.am
gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment
gstreamermm/trunk/gstreamerbase/src/Makefile.am
gstreamermm/trunk/tests/Makefile.am
gstreamermm/trunk/tools/extra_defs_gen/Makefile.am
Modified: gstreamermm/trunk/build_shared/Makefile_gensrc.am_fragment
==============================================================================
--- gstreamermm/trunk/build_shared/Makefile_gensrc.am_fragment (original)
+++ gstreamermm/trunk/build_shared/Makefile_gensrc.am_fragment Wed Nov 12 20:39:09 2008
@@ -48,10 +48,10 @@
gen_gst_wrap_init_args = --namespace=$(sublib_namespace) --parent_dir=$(sublib_parentdir)
run_gen_gst_wrap_init = $(PERL_PATH) $(gen_gst_wrap_init_path) $(gen_gst_wrap_init_args)
-# The generate_plugin_hg_file utility
-generate_plugin_hg_file_path = $(tools_dir)/extra_defs_gen/generate_plugin_hg_file
-generate_plugin_hg_file_args = --namespace=$(sublib_namespace) --main-defs=$(main_defs) --target=$(sublib_parentdir)
-run_generate_plugin_hg_file = $(generate_plugin_hg_file_path) $(generate_plugin_hg_file_args)
+# The generate_plugin_gmmproc_file utility
+generate_plugin_gmmproc_file_path = $(tools_dir)/extra_defs_gen/generate_plugin_gmmproc_file
+generate_plugin_gmmproc_file_args = --namespace=$(sublib_namespace) --main-defs=$(main_defs) --target=$(sublib_parentdir)
+run_generate_plugin_gmmproc_file = $(generate_plugin_gmmproc_file_path) $(generate_plugin_gmmproc_file_args)
EXTRA_DIST = Makefile_list_of_hg.am_fragment \
@@ -62,9 +62,9 @@
CLEANFILES = $(files_plugin_hg) $(files_plugin_hg:%.hg=%.ccg) $(gensrc_destdir)/wrap_init.cc $(gensrc_destdir)/gst_wrap_init.cc
-$(files_plugin_hg): $(generate_plugin_hg_file_path)
- $(run_generate_plugin_hg_file) $(subst .hg,,$@) > $@
- touch $(subst .hg,.ccg,$@)
+$(files_plugin_hg): $(generate_plugin_gmmproc_file_path)
+ $(run_generate_plugin_gmmproc_file) --hg $(subst .hg,,$@) > $@
+ $(run_generate_plugin_gmmproc_file) --ccg $(subst .hg,,$@) > $(subst .hg,.ccg,$@)
$(stamp_dir)/stamp-%: %.hg %.ccg $(tools_m4) $(files_defs)
Modified: gstreamermm/trunk/gstreamer/src/Makefile.am
==============================================================================
--- gstreamermm/trunk/gstreamer/src/Makefile.am (original)
+++ gstreamermm/trunk/gstreamer/src/Makefile.am Wed Nov 12 20:39:09 2008
@@ -6,7 +6,7 @@
sublib_parentdir = gstreamermm
files_defs = gst.defs gst_methods.defs gst_signals.defs gst_enums.defs gst_vfuncs.defs gst_others.defs gst_docs.xml gst_docs_override.xml
-main_defs = gst.defs
+main_defs = gst
include $(top_srcdir)/build_shared/Makefile_gensrc.am_fragment
Modified: gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment
==============================================================================
--- gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment (original)
+++ gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment Wed Nov 12 20:39:09 2008
@@ -17,6 +17,6 @@
files_general_deprecated_hg =
-files_plugin_hg =
+files_plugin_hg = fakesrc.hg
include $(top_srcdir)/build_shared/Makefile_build_gensrc.am_fragment
Modified: gstreamermm/trunk/gstreamerbase/src/Makefile.am
==============================================================================
--- gstreamermm/trunk/gstreamerbase/src/Makefile.am (original)
+++ gstreamermm/trunk/gstreamerbase/src/Makefile.am Wed Nov 12 20:39:09 2008
@@ -6,7 +6,7 @@
sublib_parentdir = gstreamerbasemm
files_defs = gstbase.defs gstbase_methods.defs gstbase_signals.defs gstbase_enums.defs gstbase_vfuncs.defs gstbase_others.defs gstbase_docs.xml gstbase_docs_override.xml
-main_defs = gstbase.defs
+main_defs = gstbase
include $(top_srcdir)/build_shared/Makefile_gensrc.am_fragment
Modified: gstreamermm/trunk/tests/Makefile.am
==============================================================================
--- gstreamermm/trunk/tests/Makefile.am (original)
+++ gstreamermm/trunk/tests/Makefile.am Wed Nov 12 20:39:09 2008
@@ -10,7 +10,8 @@
test-structure test-caps-structures test-interface \
test-create-bus test-taglist test-tagsetter test-pad \
test-init-check test-init test-init-check-noargs \
- test-init-noargs test-iterator test-property-caps
+ test-init-noargs test-iterator test-property-caps \
+ test-plugin-gen
#TODO: Add test-ghost-pad to tests when bug #539108 is fixed.
@@ -82,3 +83,6 @@
test_property_caps_SOURCES=test-property-caps.cc
test_property_caps_LDFLAGS= GSTREAMERMM_LIBS@
+
+test_plugin_gen_SOURCES=test-plugin-gen.cc
+test_plugin_gen_LDFLAGS= GSTREAMERMM_LIBS@
Added: gstreamermm/trunk/tests/test-plugin-gen.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tests/test-plugin-gen.cc Wed Nov 12 20:39:09 2008
@@ -0,0 +1,18 @@
+#include <gstreamermm.h>
+#include <gstreamermm/fakesrc.h>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ Gst::init(argc, argv);
+
+ Glib::RefPtr<Gst::Element> element =
+ Gst::ElementFactory::create_element("fakesrc");
+
+ Glib::RefPtr<Gst::FakeSrc> fakesrc = Glib::RefPtr<Gst::FakeSrc>::cast_dynamic(element);
+
+ if (!fakesrc)
+ std::cout << "fakesrc is invalid." << std::endl;
+
+ return 0;
+}
Modified: gstreamermm/trunk/tools/extra_defs_gen/Makefile.am
==============================================================================
--- gstreamermm/trunk/tools/extra_defs_gen/Makefile.am (original)
+++ gstreamermm/trunk/tools/extra_defs_gen/Makefile.am Wed Nov 12 20:39:09 2008
@@ -5,9 +5,9 @@
LIBS = $(GSTREAMERMM_LIBS) $(GSTREAMERBASEMM_LIBS) -lglibmm_generate_extra_defs-2.4
noinst_PROGRAMS = generate_extra_defs generate_defs_gstbase \
- generate_plugin_hg_file
+ generate_plugin_gmmproc_file
generate_extra_defs_SOURCES = generate_defs_gst.cc
generate_defs_gstbase_SOURCES = generate_defs_gstbase.cc
-generate_plugin_hg_file_SOURCES = generate_plugin_hg_file.cc
+generate_plugin_hg_file_SOURCES = generate_plugin_gmmproc_file.cc
Added: gstreamermm/trunk/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc Wed Nov 12 20:39:09 2008
@@ -0,0 +1,202 @@
+/* $Id: generate_extra_defs.cc 740 2008-10-15 15:58:17Z jaalburqu $ */
+
+/* generate_extra_defs.cc
+ *
+ * Copyright (C) 2001 The Free Software Foundation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "glibmm_generate_extra_defs/generate_extra_defs.h"
+
+#include <gst/gst.h>
+#include <glibmm.h>
+
+static gchar* nmspace;
+static gchar* defsFile;
+static gchar* target;
+
+static Glib::ustring pluginName;
+static Glib::ustring cTypeName;
+static Glib::ustring cParentTypeName;
+static Glib::ustring cppTypeName;
+static Glib::ustring cppParentTypeName;
+static Glib::ustring castMacro;
+
+Glib::ustring get_cast_macro(const Glib::ustring& typeName)
+{
+ Glib::ustring result;
+
+ Glib::ustring::const_iterator iter = typeName.begin();
+
+ if (iter != typeName.end())
+ result.push_back(*iter);
+
+ for ( ++iter; iter != typeName.end(); ++iter)
+ {
+ if (g_unichar_isupper(*iter))
+ {
+ result.push_back('_');
+ }
+ result.push_back(g_unichar_toupper(*iter));
+ }
+
+ return result;
+}
+
+void generate_hg_file()
+{
+ std::cout << "#include <" << target << "/" <<
+ cppParentTypeName.lowercase() << ".h>" << std::endl << std::endl;
+
+ std::cout << "_DEFS(" << target << "," << defsFile << ")" << std::endl <<
+ std::endl;
+
+ std::cout << "namespace " << nmspace << std::endl;
+ std::cout << "{" << std::endl << std::endl;
+
+ std::cout << "/** " << nmspace << "::" << cppTypeName << " â " << pluginName << " plugin." << std::endl;
+ std::cout << " * Please include <" << target << "/" << cppTypeName.lowercase() << ".h> to use." << std::endl;
+ std::cout << " */" << std::endl;
+ std::cout << "class " << cppTypeName << std::endl;
+ std::cout << ": public " << cppParentTypeName << std::endl;
+ std::cout << "{" << std::endl;
+ std::cout << " _CLASS_GOBJECT(" << cppTypeName << ", " << cTypeName <<
+ ", " << castMacro << ", " << cppParentTypeName <<
+ ", " << cParentTypeName << ")" << std::endl;
+ std::cout << "};" << std::endl;
+
+ std::cout << std::endl << "} //namespace " << nmspace << std::endl;
+}
+
+void generate_ccg_file()
+{
+ std::cout << "_PINCLUDE(" << target << "/private/" <<
+ cppParentTypeName.lowercase() << "_p.h)" << std::endl;
+ std::cout << "#include <glib/gprintf.h>" << std::endl << std::endl;
+
+ Glib::ustring getTypeName = castMacro.lowercase() + "_get_type";
+
+ std::cout << "extern \"C\" GType " << getTypeName << "();" << std::endl;
+ std::cout << "GType " << getTypeName << "()" << std::endl;
+ std::cout << "{" << std::endl;
+ std::cout << " static GType type = 0;" << std::endl;
+ std::cout << " GstElementFactory* factory = 0;" << std::endl;
+ std::cout << " GstPluginFeature* feature = 0;" << std::endl << std::endl;
+
+ std::cout << " if (!type)" << std::endl; std::cout << " {" << std::endl;
+ std::cout << " factory = gst_element_factory_find(\"" << pluginName << "\");" << std::endl;
+
+ std::cout << " // Make sure that the feature is actually loaded:" << std::endl;
+ std::cout << " if (factory)" << std::endl;
+ std::cout << " {" << std::endl;
+ std::cout << " feature =" << std::endl;
+ std::cout << " gst_plugin_feature_load(GST_PLUGIN_FEATURE(factory));" << std::endl << std::endl;
+
+ std::cout << " g_object_unref(factory);" << std::endl;
+ std::cout << " factory = GST_ELEMENT_FACTORY(feature);" << std::endl;
+ std::cout << " type = gst_element_factory_get_element_type(factory);" << std::endl;
+ std::cout << " g_object_unref(factory);" << std::endl;
+ std::cout << " }" << std::endl;
+ std::cout << " }" << std::endl << std::endl;
+
+ std::cout << " return type;" << std::endl;
+ std::cout << "}" << std::endl;
+}
+
+int main(int argc, char* argv[])
+{
+ gboolean hgFile = false;
+ gboolean ccgFile = false;
+
+ if (!g_thread_supported())
+ g_thread_init(NULL);
+
+ GOptionEntry optionEntries[] =
+ {
+ {"hg", 'h', 0, G_OPTION_ARG_NONE, &hgFile, "Generate .hg file", NULL },
+ {"ccg", 'c', 0, G_OPTION_ARG_NONE, &ccgFile, "Generate .ccg file", NULL },
+ {"namespace", 'n', 0, G_OPTION_ARG_STRING, &nmspace, "The namespace of the plugin", "namespace" },
+ {"main-defs", 'm', 0, G_OPTION_ARG_STRING, &defsFile, "The main .defs file without .defs extension (used in _DEFS() directive)", "def" },
+ {"target", 't', 0, G_OPTION_ARG_STRING, &target, "The target directory of the generated .h and .cc files (used in _DEFS() directive)", "directory" },
+ { NULL }
+ };
+
+ GOptionContext* gContext = g_option_context_new("<plugin name>");
+ g_option_context_set_summary(gContext, "Outputs a GStreamer plugin's gmmproc files to be processed by gmmproc for wrapping in gstreamermm. Use the same syntax for the plugin name as in gst-inspect.");
+
+ g_option_context_add_main_entries(gContext, optionEntries, NULL);
+ g_option_context_add_group(gContext, gst_init_get_option_group());
+
+ Glib::OptionContext optionContext(gContext, true);
+
+ try
+ {
+ if (!optionContext.parse(argc, argv))
+ {
+ std::cout << "Error parsing options and initializing. Sorry." <<
+ std::endl;
+ return -1;
+ }
+ }
+ catch (Glib::OptionError& error)
+ {
+ std::cout << "Error parsing options and initializing GStreamer." <<
+ std::endl << "Run `" << argv[0] << " -?' for a list of options." <<
+ std::endl;
+ return -1;
+ }
+
+ if (argc != 2)
+ {
+ std::cout << "A plugin name must be supplied to generate an .hg file." <<
+ std::endl << "Run `" << argv[0] << " -?' for a list of options." <<
+ std::endl;
+ return -1;
+ }
+
+ GType type = 0;
+ GstElementFactory* factory = 0;
+
+ factory = gst_element_factory_find(argv[1]);
+
+ // Make sure that the feature is actually loaded:
+ if (factory)
+ {
+ GstPluginFeature* loaded_feature =
+ gst_plugin_feature_load(GST_PLUGIN_FEATURE(factory));
+
+ g_object_unref(factory);
+ factory = GST_ELEMENT_FACTORY(loaded_feature);
+ type = gst_element_factory_get_element_type(factory);
+
+ pluginName = argv[1];
+ cTypeName = g_type_name(type);
+ cParentTypeName = g_type_name(g_type_parent(type));
+ cppTypeName = cTypeName.substr(3);
+ cppParentTypeName = cParentTypeName.substr(3);
+ castMacro = get_cast_macro(cTypeName);
+
+ if (hgFile)
+ generate_hg_file();
+ else if (ccgFile)
+ generate_ccg_file();
+
+ g_object_unref(factory);
+ }
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]