From 709913b1d2f5a518ebf3626cc8aca2d5736760cd Mon Sep 17 00:00:00 2001 From: Alexander Slobodeniuk Date: Fri, 20 Oct 2023 00:55:00 +0200 Subject: [PATCH] insertbin: make it available in the registry so it could also be used from the gst-parse-launch Part-of: --- girs/GstInsertBin-1.0.gir | 26 +++- .../docs/plugins/gst_plugins_cache.json | 146 ++++++++++++++++++ .../gst-libs/gst/insertbin/gstinsertbin.c | 24 +++ .../gst-plugins-bad/gst/insertbin/meson.build | 13 ++ .../gst-plugins-bad/gst/insertbin/plugin.c | 42 +++++ subprojects/gst-plugins-bad/gst/meson.build | 2 +- subprojects/gst-plugins-bad/meson_options.txt | 1 + 7 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 subprojects/gst-plugins-bad/gst/insertbin/meson.build create mode 100644 subprojects/gst-plugins-bad/gst/insertbin/plugin.c diff --git a/girs/GstInsertBin-1.0.gir b/girs/GstInsertBin-1.0.gir index a6f3c31b53..72a6350cd2 100644 --- a/girs/GstInsertBin-1.0.gir +++ b/girs/GstInsertBin-1.0.gir @@ -52,7 +52,31 @@ Each operation (addition or removal) can take a callback, this callback is guaranteed to be called. Unlike GIO, there is no guarantee about where this callback will be called from, it could be called before the action returns or it could be called later from another thread. The signature of -this callback GstInsertBinCallback(). +this callback GstInsertBinCallback(). + +Apart from the library API, since 1.24 insertbin can also be found in the +registry: + +``` C + GstElement *pipeline, *insertbin, *videoflip; + + gst_init (NULL, NULL); + pipeline = + gst_parse_launch ("videotestsrc ! insertbin name=i ! autovideosink", + NULL); + + ... + + insertbin = gst_bin_get_by_name (GST_BIN (pipeline), "i"); + videoflip = gst_element_factory_make ("videoflip", NULL); + + ... + + g_object_set (videoflip, "method", 1, NULL); + g_signal_emit_by_name (insertbin, "append", videoflip, NULL, NULL); + + ... +``` diff --git a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json index 3cc95a3ecc..e5a8fe8c41 100644 --- a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json +++ b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json @@ -33552,6 +33552,152 @@ "tracers": {}, "url": "Unknown package origin" }, + "insertbin": { + "description": "insertbin", + "elements": { + "insertbin": { + "author": "Olivier Crete ", + "description": "Auto-links filter style elements insertally", + "hierarchy": [ + "GstInsertBin", + "GstBin", + "GstElement", + "GstObject", + "GInitiallyUnowned", + "GObject" + ], + "interfaces": [ + "GstChildProxy" + ], + "klass": "Generic/Bin/Filter", + "pad-templates": { + "sink": { + "caps": "ANY", + "direction": "sink", + "presence": "always" + }, + "src": { + "caps": "ANY", + "direction": "src", + "presence": "always" + } + }, + "rank": "none", + "signals": { + "append": { + "action": true, + "args": [ + { + "name": "arg0", + "type": "GstElement" + }, + { + "name": "arg1", + "type": "gpointer" + }, + { + "name": "arg2", + "type": "gpointer" + } + ], + "return-type": "void", + "when": "last" + }, + "insert-after": { + "action": true, + "args": [ + { + "name": "arg0", + "type": "GstElement" + }, + { + "name": "arg1", + "type": "GstElement" + }, + { + "name": "arg2", + "type": "gpointer" + }, + { + "name": "arg3", + "type": "gpointer" + } + ], + "return-type": "void", + "when": "last" + }, + "insert-before": { + "action": true, + "args": [ + { + "name": "arg0", + "type": "GstElement" + }, + { + "name": "arg1", + "type": "GstElement" + }, + { + "name": "arg2", + "type": "gpointer" + }, + { + "name": "arg3", + "type": "gpointer" + } + ], + "return-type": "void", + "when": "last" + }, + "prepend": { + "action": true, + "args": [ + { + "name": "arg0", + "type": "GstElement" + }, + { + "name": "arg1", + "type": "gpointer" + }, + { + "name": "arg2", + "type": "gpointer" + } + ], + "return-type": "void", + "when": "last" + }, + "remove": { + "action": true, + "args": [ + { + "name": "arg0", + "type": "GstElement" + }, + { + "name": "arg1", + "type": "gpointer" + }, + { + "name": "arg2", + "type": "gpointer" + } + ], + "return-type": "void", + "when": "last" + } + } + } + }, + "filename": "gstinsertbin", + "license": "LGPL", + "other-types": {}, + "package": "GStreamer Bad Plug-ins", + "source": "gst-plugins-bad", + "tracers": {}, + "url": "Unknown package origin" + }, "inter": { "description": "plugin for inter-pipeline communication", "elements": { diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/insertbin/gstinsertbin.c b/subprojects/gst-plugins-bad/gst-libs/gst/insertbin/gstinsertbin.c index e3a81f6efe..a911bccc86 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/insertbin/gstinsertbin.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/insertbin/gstinsertbin.c @@ -37,6 +37,30 @@ * returns or it could be called later from another thread. The signature of * this callback GstInsertBinCallback(). * + * Apart from the library API, since 1.24 insertbin can also be found in the + * registry: + * + * ``` C + * GstElement *pipeline, *insertbin, *videoflip; + * + * gst_init (NULL, NULL); + * pipeline = + * gst_parse_launch ("videotestsrc ! insertbin name=i ! autovideosink", + * NULL); + * + * ... + * + * insertbin = gst_bin_get_by_name (GST_BIN (pipeline), "i"); + * videoflip = gst_element_factory_make ("videoflip", NULL); + * + * ... + * + * g_object_set (videoflip, "method", 1, NULL); + * g_signal_emit_by_name (insertbin, "append", videoflip, NULL, NULL); + * + * ... + * ``` + * * Since: 1.2 */ diff --git a/subprojects/gst-plugins-bad/gst/insertbin/meson.build b/subprojects/gst-plugins-bad/gst/insertbin/meson.build new file mode 100644 index 0000000000..1c8be395cf --- /dev/null +++ b/subprojects/gst-plugins-bad/gst/insertbin/meson.build @@ -0,0 +1,13 @@ +insertbin_sources = [ + 'plugin.c' +] + +gstinsertbin = library('gstinsertbin', + insertbin_sources, + c_args : gst_plugins_bad_args + [ '-DGST_USE_UNSTABLE_API' ], + include_directories : [configinc], + dependencies : [gst_dep, gstinsertbin_dep], + install : true, + install_dir : plugins_install_dir, +) +plugins += [gstinsertbin] diff --git a/subprojects/gst-plugins-bad/gst/insertbin/plugin.c b/subprojects/gst-plugins-bad/gst/insertbin/plugin.c new file mode 100644 index 0000000000..ebd71161bc --- /dev/null +++ b/subprojects/gst-plugins-bad/gst/insertbin/plugin.c @@ -0,0 +1,42 @@ +/* GStreamer + * + * Copyright (C) 2023 Alexander Slobodeniuk + * + * insertbin: a GstBin to insertally link filter-like elements. + * + * 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 +#endif + +#include + +GST_ELEMENT_REGISTER_DECLARE (insertbin); +GST_ELEMENT_REGISTER_DEFINE (insertbin, "insertbin", GST_RANK_NONE, + GST_TYPE_INSERT_BIN); + +static gboolean +plugin_init (GstPlugin * plugin) +{ + return GST_ELEMENT_REGISTER (insertbin, plugin); +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + insertbin, + "insertbin", + plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/subprojects/gst-plugins-bad/gst/meson.build b/subprojects/gst-plugins-bad/gst/meson.build index 699560f9b9..81f8f62092 100644 --- a/subprojects/gst-plugins-bad/gst/meson.build +++ b/subprojects/gst-plugins-bad/gst/meson.build @@ -5,7 +5,7 @@ foreach plugin : ['accurip', 'adpcmdec', 'adpcmenc', 'aiff', 'asfmux', 'debugutils', 'dvbsubenc', 'dvbsuboverlay', 'dvdspu', 'faceoverlay', 'festival', 'fieldanalysis', 'freeverb', 'frei0r', 'gaudieffects', 'gdp', - 'geometrictransform', 'id3tag', 'inter', 'interlace', + 'geometrictransform', 'id3tag', 'insertbin', 'inter', 'interlace', 'ivfparse', 'ivtc', 'jp2kdecimator', 'jpegformat', 'librfb', 'midi', 'mpegdemux', 'mpegpsmux', 'mpegtsdemux', 'mpegtsmux', 'mxf', 'netsim', 'onvif', 'pcapparse', 'pnm', 'proxy', diff --git a/subprojects/gst-plugins-bad/meson_options.txt b/subprojects/gst-plugins-bad/meson_options.txt index 662b0246f3..8fe3b8fc7f 100644 --- a/subprojects/gst-plugins-bad/meson_options.txt +++ b/subprojects/gst-plugins-bad/meson_options.txt @@ -32,6 +32,7 @@ option('gaudieffects', type : 'feature', value : 'auto') option('gdp', type : 'feature', value : 'auto') option('geometrictransform', type : 'feature', value : 'auto') option('id3tag', type : 'feature', value : 'auto') +option('insertbin', type : 'feature', value : 'auto') option('inter', type : 'feature', value : 'auto') option('interlace', type : 'feature', value : 'auto') option('ivfparse', type : 'feature', value : 'auto')