From bdbf6e1c17357d2116a07d63e5f1bd1d8cd31804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Thu, 28 Sep 2023 18:22:38 +0200 Subject: [PATCH] gst-full: register full features in a plugin 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: --- meson.build | 6 +++-- meson_options.txt | 2 ++ scripts/generate_init_static_plugins.py | 25 +++++++++++++++---- tests/static-plugins/meson.build | 4 +-- tests/static-plugins/test-gst-full-features.c | 11 ++++++-- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 4863ee54ee..89e169ac8f 100644 --- a/meson.build +++ b/meson.build @@ -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'] @@ -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, diff --git a/meson_options.txt b/meson_options.txt index df7bac3643..8b3c316abd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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)') \ No newline at end of file diff --git a/scripts/generate_init_static_plugins.py b/scripts/generate_init_static_plugins.py index f490aafc69..6f477266ae 100755 --- a/scripts/generate_init_static_plugins.py +++ b/scripts/generate_init_static_plugins.py @@ -6,6 +6,9 @@ from string import Template TEMPLATE = Template(''' #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif $elements_declaration $typefind_funcs_declaration @@ -14,16 +17,28 @@ $dynamic_types_declaration $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 @@ -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) diff --git a/tests/static-plugins/meson.build b/tests/static-plugins/meson.build index 227e9e4af9..0faeab20c8 100644 --- a/tests/static-plugins/meson.build +++ b/tests/static-plugins/meson.build @@ -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 diff --git a/tests/static-plugins/test-gst-full-features.c b/tests/static-plugins/test-gst-full-features.c index 5e8afbe14f..098ccb2a32 100644 --- a/tests/static-plugins/test-gst-full-features.c +++ b/tests/static-plugins/test-gst-full-features.c @@ -1,4 +1,7 @@ #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif void @@ -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); }