diff --git a/pinos/Makefile.am b/pinos/Makefile.am index e41fd1bec..e6c43069a 100644 --- a/pinos/Makefile.am +++ b/pinos/Makefile.am @@ -219,6 +219,7 @@ libpinoscore_@PINOS_MAJORMINOR@_la_SOURCES = \ 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 \ dbus/org-pinos.c dbus/org-pinos.h libpinoscore_@PINOS_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(SERVER_CFLAGS) diff --git a/pinos/daemon/main.c b/pinos/daemon/main.c index 5baf5a06a..2d5738bc9 100644 --- a/pinos/daemon/main.c +++ b/pinos/daemon/main.c @@ -23,6 +23,7 @@ #include #include #include +#include gint main (gint argc, gchar *argv[]) @@ -30,6 +31,7 @@ main (gint argc, gchar *argv[]) PinosDaemon *daemon; GMainLoop *loop; PinosProperties *props; + PinosNodeFactory *factory; pinos_init (&argc, &argv); @@ -39,12 +41,17 @@ main (gint argc, gchar *argv[]) daemon = pinos_daemon_new (props); pinos_gst_manager_new (daemon); + + factory = pinos_gst_node_factory_new ("gst-node-factory"); + pinos_daemon_add_node_factory (daemon, factory); + pinos_daemon_start (daemon); g_main_loop_run (loop); 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/gst-node-factory.c b/pinos/modules/gst/gst-node-factory.c new file mode 100644 index 000000000..7a3e559a0 --- /dev/null +++ b/pinos/modules/gst/gst-node-factory.c @@ -0,0 +1,71 @@ +#/* Pinos + * Copyright (C) 2016 Axis Communications AB + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "gst-node-factory.h" +#include "gst-source.h" + +G_DEFINE_TYPE (PinosGstNodeFactory, pinos_gst_node_factory, PINOS_TYPE_NODE_FACTORY); + +static PinosNode * +factory_create_node (PinosNodeFactory * factory, + PinosDaemon * daemon, + const gchar * sender, + const gchar * name, + PinosProperties * properties) +{ + PinosNode *node; + + node = g_object_new (PINOS_TYPE_GST_SOURCE, + "daemon", daemon, + "sender", sender, + "name", name, + "properties", properties, + NULL); + return node; +} + +static void +pinos_gst_node_factory_class_init (PinosGstNodeFactoryClass * klass) +{ + PinosNodeFactoryClass *factory_class = PINOS_NODE_FACTORY_CLASS (klass); + + factory_class->create_node = factory_create_node; +} + +static void +pinos_gst_node_factory_init (PinosGstNodeFactory * factory) +{ +} + +PinosNodeFactory * +pinos_gst_node_factory_new (const gchar * name) +{ + PinosNodeFactory *factory; + + factory = g_object_new (PINOS_TYPE_GST_NODE_FACTORY, + "name", name, + NULL); + return factory; +} diff --git a/pinos/modules/gst/gst-node-factory.h b/pinos/modules/gst/gst-node-factory.h new file mode 100644 index 000000000..21174d8d9 --- /dev/null +++ b/pinos/modules/gst/gst-node-factory.h @@ -0,0 +1,55 @@ +/* Pinos + * Copyright (C) 2016 Axis Communications AB + * + * 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. + */ + +#ifndef __PINOS_GST_NODE_FACTORY_H__ +#define __PINOS_GST_NODE_FACTORY_H__ + +#include + +#include + +G_BEGIN_DECLS + +#define PINOS_TYPE_GST_NODE_FACTORY (pinos_gst_node_factory_get_type ()) +#define PINOS_IS_GST_NODE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_GST_NODE_FACTORY)) +#define PINOS_IS_GST_NODE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_GST_NODE_FACTORY)) +#define PINOS_GST_NODE_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_GST_NODE_FACTORY, PinosGstNodeFactoryClass)) +#define PINOS_GST_NODE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_GST_NODE_FACTORY, PinosGstNodeFactory)) +#define PINOS_GST_NODE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_GST_NODE_FACTORY, PinosGstNodeFactoryClass)) +#define PINOS_GST_NODE_FACTORY_CAST(obj) ((PinosGstNodeFactory*)(obj)) +#define PINOS_GST_NODE_FACTORY_CLASS_CAST(klass) ((PinosGstNodeFactoryClass*)(klass)) + +typedef struct _PinosGstNodeFactory PinosGstNodeFactory; +typedef struct _PinosGstNodeFactoryClass PinosGstNodeFactoryClass; + +struct _PinosGstNodeFactory { + PinosNodeFactory object; +}; + +struct _PinosGstNodeFactoryClass { + PinosNodeFactoryClass parent_class; +}; + +GType pinos_gst_node_factory_get_type (void); + +PinosNodeFactory * pinos_gst_node_factory_new (const gchar * name); + +G_END_DECLS + +#endif /* __PINOS_GST_NODE_FACTORY_H__ */