mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
gst-node-factory: node factory for GstSource nodes
The GstNodeFactory creates GstSource nodes without ports. When an output port is created later, the proper GStreamer element will be created in the node. main.c registers a GstNodeFactory in the daemon, so clients can use it in calls to CreateNode and CreatePort.
This commit is contained in:
parent
649882f42a
commit
00ff707208
4 changed files with 134 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include <client/pinos.h>
|
||||
#include <server/daemon.h>
|
||||
#include <modules/gst/gst-manager.h>
|
||||
#include <modules/gst/gst-node-factory.h>
|
||||
|
||||
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;
|
||||
|
|
|
|||
71
pinos/modules/gst/gst-node-factory.c
Normal file
71
pinos/modules/gst/gst-node-factory.c
Normal file
|
|
@ -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 <gst/gst.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
55
pinos/modules/gst/gst-node-factory.h
Normal file
55
pinos/modules/gst/gst-node-factory.h
Normal file
|
|
@ -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 <glib-object.h>
|
||||
|
||||
#include <server/node-factory.h>
|
||||
|
||||
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__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue