Skip to content

Commit

Permalink
gst-full: register full features in a plugin
Browse files Browse the repository at this point in the history
To offer the possibility to get information at plugin
level and get it from the registry, all the
full features are now registered in 'fullstaticfeatures'
meta plugin instead of NULL plugin.
In the case of gst-inspect, the features were not displayed
at plugin level because it was a NULL plugin.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5421>
  • Loading branch information
dabrain34 authored and GStreamer Marge Bot committed Oct 5, 2023
1 parent aeef97d commit bdbf6e1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
6 changes: 4 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,10 @@ if building_full
cdata = configuration_data()
cdata.set_quoted('GST_API_VERSION', apiversion)
cdata.set_quoted('GETTEXT_PACKAGE', 'gstreamer-full-1.0')
cdata.set_quoted('PACKAGE_VERSION', gst_version)
cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
cdata.set_quoted('GST_FULL_LICENSE', get_option('gstreamer-full-license'))
cdata.set_quoted('GST_PLUGIN_FULL_FEATURES_NAME', 'fullstaticfeatures')
configure_file(output : 'config.h', configuration : cdata)
configinc = include_directories('.')
gst_c_args = ['-DHAVE_CONFIG_H']
Expand Down Expand Up @@ -441,7 +443,7 @@ if building_full
# Build shared library
gstfull = build_target('gstreamer-full-1.0',
init_static_plugins_c,
c_args: ['-DBUILDING_GST'],
c_args: ['-DBUILDING_GST'] + gst_c_args,
target_type: get_option('gst-full-target-type'),
link_args: gstfull_link_args,
link_whole : exposed_libs,
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ option('glib-checks', type : 'feature', value : 'enabled', yield : true,

option('package-name', type : 'string', yield : true,
description : 'package name to use in plugins')
option('gstreamer-full-license', type : 'string', value : 'unknown',
description : 'gstreamer-full license (default unknown)')
25 changes: 20 additions & 5 deletions scripts/generate_init_static_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

TEMPLATE = Template('''
#include <gst/gst.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
$elements_declaration
$typefind_funcs_declaration
Expand All @@ -14,16 +17,28 @@
$plugins_declaration
$giomodules_declaration
static
gboolean register_features_full (GstPlugin* plugin)
{
$elements_registration
$typefind_funcs_registration
$device_providers_registration
$dynamic_types_registration
return TRUE;
}
_GST_EXPORT
void
gst_init_static_plugins (void)
{
static gsize initialization_value = 0;
if (g_once_init_enter (&initialization_value)) {
$elements_registration
$typefind_funcs_registration
$device_providers_registration
$dynamic_types_registration
gst_plugin_register_static (GST_VERSION_MAJOR, GST_VERSION_MINOR,
GST_PLUGIN_FULL_FEATURES_NAME, "features linked into the gstreamer-full library", register_features_full, PACKAGE_VERSION, GST_FULL_LICENSE,
"gstreamer-full", GETTEXT_PACKAGE, GST_PACKAGE_ORIGIN);
$plugins_registration
$giomodules_registration
Expand Down Expand Up @@ -57,7 +72,7 @@ def process_features(features_list, plugins, feature_prefix):
for feature in features:
feature = feature.replace("-", "_")
feature_declaration += ['%s_REGISTER_DECLARE(%s);' % (feature_prefix, feature)]
feature_registration += ['%s_REGISTER(%s, NULL);' % (feature_prefix, feature)]
feature_registration += ['%s_REGISTER(%s, plugin);' % (feature_prefix, feature)]
return (plugins_list, feature_declaration, feature_registration)


Expand Down
4 changes: 2 additions & 2 deletions tests/static-plugins/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

dep = dependency('gstreamer-full-1.0', required: get_option('default_library') == 'static')
if dep.found()
test_gst_full_features = executable('test-gst-full-features', 'test-gst-full-features.c', dependencies : gst_full_dep)
test_gst_full_features = executable('test-gst-full-features', 'test-gst-full-features.c', dependencies : gst_full_dep, c_args: ['-DHAVE_CONFIG_H'])
test('test-gst-full-features', test_gst_full_features)
test_gst_full = executable('test-gst-full', 'test-gst-full.c', dependencies : gst_full_dep)
test_gst_full = executable('test-gst-full', 'test-gst-full.c', dependencies : gst_full_dep, c_args: ['-DHAVE_CONFIG_H'])
test('test-gst-full', test_gst_full)
endif
11 changes: 9 additions & 2 deletions tests/static-plugins/test-gst-full-features.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <gst/gst.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


void
Expand All @@ -14,10 +17,14 @@ assert_feature_names (gchar * names, GType feature_type, gboolean spook)
for (i = 0; split[i]; i++) {
feature = gst_registry_find_feature (gst_registry_get (),
split[i], feature_type);
if (spook)
if (spook) {
g_assert_null (feature);
else
} else {
g_assert_nonnull (feature);
g_assert_cmpstr (gst_plugin_feature_get_plugin_name (feature), ==,
GST_PLUGIN_FULL_FEATURES_NAME);
}

if (feature)
gst_object_unref (feature);
}
Expand Down

0 comments on commit bdbf6e1

Please sign in to comment.