From 1c7fafd03e7314dd666ecabc7daf96159d0a223f Mon Sep 17 00:00:00 2001 From: Linus Svensson Date: Mon, 29 Aug 2016 13:14:26 +0200 Subject: [PATCH] modules/gst: Make modules/gst a real module modules/gst is moved from the pinoscore library to a separate loadable module. For now pinos will always try to load "module-gst". --- configure.ac | 14 +++++++++++++ pinos/Makefile.am | 27 ++++++++++++++++++++---- pinos/daemon/main.c | 12 +++++------ pinos/modules/gst/module.c | 42 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 pinos/modules/gst/module.c diff --git a/configure.ac b/configure.ac index 8df48cbc5..279093f9c 100644 --- a/configure.ac +++ b/configure.ac @@ -249,6 +249,17 @@ PKG_CHECK_MODULES(ALSA, alsa >= 0.9.1, dummy=yes, AC_SUBST(ALSA_CFLAGS) AC_SUBST(ALSA_LIBS) +################################### +# Modules # +################################### + +#### module-gst (Gstreamer module) #### +AC_ARG_ENABLE([module-gst], + AS_HELP_STRING([--disable-module-gst],[Disable building of GStreamer module])) + +AM_CONDITIONAL([BUILD_MODULE_GST], [test "x$enable_module_gst" != "xno"]) +AS_IF([test "x$enable_module_gst" != "xno"], ENABLE_MODULE_GST=yes, ENABLE_MODULE_GST=no) + #### Build and Install man pages #### AC_ARG_ENABLE([manpages], @@ -279,5 +290,8 @@ Configuration Moduledir : ${moduledir} Compiler : ${CC} +Modules + module-gst : ${ENABLE_MODULE_GST} + pinos configured. Type 'make' to build. " diff --git a/pinos/Makefile.am b/pinos/Makefile.am index 5edb9d01a..4d03a7b33 100644 --- a/pinos/Makefile.am +++ b/pinos/Makefile.am @@ -46,6 +46,9 @@ AM_LDFLAGS = $(NODELETE_LDFLAGS) -Wl,-rpath=/home/wim/gst/head/pinos/spa/build/l FOREIGN_CFLAGS = -w +MODULE_LDFLAGS = $(AM_LDFLAGS) $(AM_LIBLDFLAGS) -module -avoid-version +MODULE_LIBADD = $(AM_LIBADD) libpinoscore-@PINOS_MAJORMINOR@.la + ################################### # Extra files # ################################### @@ -208,10 +211,6 @@ libpinoscore_@PINOS_MAJORMINOR@_la_SOURCES = \ server/node.c server/node.h \ server/port.c server/port.h \ server/node-factory.c server/node-factory.h \ - modules/gst/gst-manager.c modules/gst/gst-manager.h \ - modules/gst/gst-source.c modules/gst/gst-source.h \ - modules/gst/gst-sink.c modules/gst/gst-sink.h \ - modules/gst/gst-node-factory.c modules/gst/gst-node-factory.h \ modules/spa/spa-alsa-sink.c modules/spa/spa-alsa-sink.h \ modules/spa/spa-v4l2-source.c modules/spa/spa-v4l2-source.h \ dbus/org-pinos.c dbus/org-pinos.h @@ -221,6 +220,26 @@ libpinoscore_@PINOS_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version libpinoscore_@PINOS_MAJORMINOR@_la_LIBADD = $(LIBLTDL) $(LTLIBICONV) \ libpinos-@PINOS_MAJORMINOR@.la $(AM_LIBADD) +################################### +# Modules # +################################### + +module_LTLIBRARIES = + +if BUILD_MODULE_GST +module_LTLIBRARIES += module-gst.la + +module_gst_la_SOURCES = \ + modules/gst/gst-manager.c \ + modules/gst/gst-node-factory.c \ + modules/gst/gst-sink.c \ + modules/gst/gst-source.c \ + modules/gst/module.c +module_gst_la_CFLAGS = $(AM_CFLAGS) $(GST_CFLAGS) +module_gst_la_LDFLAGS = $(MODULE_LDFLAGS) +module_gst_la_LIBADD = $(MODULE_LIBADD) +endif + ################################### # GStreamer Plugin # ################################### diff --git a/pinos/daemon/main.c b/pinos/daemon/main.c index 66c118dd3..32fdd4920 100644 --- a/pinos/daemon/main.c +++ b/pinos/daemon/main.c @@ -19,13 +19,10 @@ #include #include -#include #include #include #include -#include -#include #include gint @@ -34,7 +31,7 @@ main (gint argc, gchar *argv[]) PinosDaemon *daemon; GMainLoop *loop; PinosProperties *props; - PinosNodeFactory *factory; + GError *err = NULL; pinos_init (&argc, &argv); spa_memory_init (); @@ -44,8 +41,10 @@ main (gint argc, gchar *argv[]) props = pinos_properties_new ("test", "test", NULL); daemon = pinos_daemon_new (props); - factory = pinos_gst_node_factory_new ("gst-node-factory"); - pinos_daemon_add_node_factory (daemon, factory); + if (pinos_module_load (daemon, "module-gst", &err) == NULL) { + g_error ("could not load module-gst: %s", err->message); + g_clear_error (&err); + } pinos_spa_alsa_sink_new (daemon, "alsa-sink", NULL); pinos_spa_v4l2_source_new (daemon, "v4l2-source", NULL); @@ -55,7 +54,6 @@ main (gint argc, gchar *argv[]) pinos_properties_free (props); g_main_loop_unref (loop); - g_object_unref (factory); g_object_unref (daemon); return 0; diff --git a/pinos/modules/gst/module.c b/pinos/modules/gst/module.c new file mode 100644 index 000000000..685f16e16 --- /dev/null +++ b/pinos/modules/gst/module.c @@ -0,0 +1,42 @@ +/* Pinos + * Copyright (C) 2016 Axis Communications + * @author Linus Svensson + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include + +#include "gst-manager.h" +#include "gst-node-factory.h" + +gboolean pinos__module_init (PinosModule *module); + +G_MODULE_EXPORT gboolean +pinos__module_init (PinosModule * module) +{ + PinosNodeFactory *factory; + + pinos_gst_manager_new (module->daemon); + + factory = pinos_gst_node_factory_new ("gst-node-factory"); + pinos_daemon_add_node_factory (module->daemon, factory); + + g_object_unref (factory); + + return TRUE; +}