mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 00:06:36 +00:00
gst-full: add 'gst-full-' features options
These options allow to select a set of features from a given plugin with the following syntax: -Dgst-full-plugins=plugin1;plugin10 -Dgst-full-elements=plugin2:element1,element2 -Dgst-full-typefind-functions=plugins3:func -Dgst-full-device-providers=plugin4,dp1 -Dgst-full-dynamic-types=plugin5:dt1 By default all the enabled plugin are registered and gst-full-plugins will allow to include only a set of plugin If a feature(element, typefind etc.) is selected from a plugin, the plugin is removed from the plugins list. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199>
This commit is contained in:
parent
f0210bf92e
commit
b6f61768d3
4 changed files with 141 additions and 14 deletions
27
README.md
27
README.md
|
@ -138,6 +138,33 @@ the gstreamer-full library, allowing the linker to garbage collect unused code
|
|||
and so reduce the total library size. A default script `gstreamer-full-default.map`
|
||||
declares only glib/gstreamer symbols as public.
|
||||
|
||||
One can use the `gst-full-plugins` option to pass a list of plugins to be registered
|
||||
in the gstreamer-full library. The default value is '*' which means that all the plugins selected
|
||||
during the build process will be registered statically. An empty value will prevent any plugins to
|
||||
be registered.
|
||||
|
||||
One can select a specific set of features with `gst-full-elements`, `gst-full-typefind-functions`, `gst-full-device-providers` or `gst-full-dynamic-types` to select specific feature from a plugin.
|
||||
When a feature has been listed in one of those options, the other features from its plugin will no longer be automatically included, even if the plugin is listed in `gst-full-plugins`.
|
||||
|
||||
The user must insure that all selected plugins and features (element, typefind, etc.) have been
|
||||
enabled during the build configuration.
|
||||
|
||||
To register features, the syntax is the following:
|
||||
plugins are separated by ';' and features from a plugin starts after ':' and are ',' separated.
|
||||
|
||||
As an example:
|
||||
* `-Dgst-full-plugins=coreelements;playback;typefindfunctions;alsa;pbtypes`: enable only `coreelements`, `playback`, `typefindfunctions`, `alsa`, `pbtypes` plugins.
|
||||
* `-Dgst-full-elements=coreelements:filesrc,fakesink,identity;alsa:alsasrc`: enable only `filesrc`, `identity` and `fakesink` elements from `coreelements` and `alsasrc` element from `alsa` plugin.
|
||||
* `-Dgst-full-typefind-functions=typefindfunctions:wav,flv`: enable only typefind func `wav` and `flv` from `typefindfunctions`
|
||||
* `-Dgst-full-device-providers=alsa:alsadeviceprovider`: enable `alsadeviceprovider` from `alsa`.
|
||||
* `-Dgst-full-dynamic-types=pbtypes:video_multiview_flagset`: enable `video_multiview_flagset` from `pbtypes
|
||||
|
||||
All features from the `playback` plugin will be enabled and the other plugins will be restricted to the specific features requested.
|
||||
|
||||
All the selected features will be registered into a dedicated `NULL` plugin name.
|
||||
|
||||
This will cause the features/plugins that are not registered to not be included in the final gstreamer-full library.
|
||||
|
||||
This is an experimental feature, backward uncompatible changes could still be
|
||||
made in the future.
|
||||
|
||||
|
|
19
meson.build
19
meson.build
|
@ -249,12 +249,27 @@ libraries_map = {
|
|||
|
||||
if get_option('default_library') == 'static'
|
||||
# Generate a .c file which declare and register all built plugins
|
||||
plugins_names = []
|
||||
foreach plugin: all_plugins
|
||||
plugins_names += plugin.full_path()
|
||||
endforeach
|
||||
all_plugin_names = ';'.join(plugins_names)
|
||||
|
||||
static_plugins = get_option('gst-full-plugins')
|
||||
if static_plugins == '*'
|
||||
static_plugins = all_plugin_names
|
||||
endif
|
||||
generate_init_static_plugins = find_program('scripts/generate_init_static_plugins.py')
|
||||
init_static_plugins_c = configure_file(
|
||||
output: 'gstinitstaticplugins.c',
|
||||
command : [generate_init_static_plugins,
|
||||
'@OUTPUT@',
|
||||
all_plugins_paths]
|
||||
'-o ' + '@OUTPUT@',
|
||||
'-p ' + static_plugins,
|
||||
'-e ' + get_option('gst-full-elements'),
|
||||
'-t ' + get_option('gst-full-typefind-functions'),
|
||||
'-d ' + get_option('gst-full-device-providers'),
|
||||
'-T ' + get_option('gst-full-dynamic-types')
|
||||
]
|
||||
)
|
||||
|
||||
gstfull_link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions'])
|
||||
|
|
|
@ -23,6 +23,16 @@ option('gst-full-libraries', type : 'array', value : [],
|
|||
description : '''List of libraries to expose in gstreamer-full's ABI. gstreamer, glib and gobject are always included.''')
|
||||
option('gst-full-version-script', type : 'string', value: 'gstreamer-full-default.map',
|
||||
description : 'path of the version script to be used by the linker, see https://www.gnu.org/software/gnulib/manual/html_node/LD-Version-Scripts.html')
|
||||
option('gst-full-plugins', type : 'string', value : '*',
|
||||
description : '''List of plugins to expose in gstreamer-full's ABI with the syntax plugin1;plugin2. By default '*' will export all plugins enabled by the build process.''')
|
||||
option('gst-full-elements', type : 'string', value : '',
|
||||
description : '''List of elements to expose in gstreamer-full's ABI with the syntax plugin1;plugin2:element1,element2. By default '' will export all element of the enabled plugin.''')
|
||||
option('gst-full-typefind-functions', type : 'string', value : '',
|
||||
description : '''List of typefind functions to expose in gstreamer-full's ABI with the syntax plugin:func1,func2. By default '' will export all typefind functions of the enabled plugin.''')
|
||||
option('gst-full-device-providers', type : 'string', value : '',
|
||||
description : '''List of device providers to expose in gstreamer-full's ABI with the syntax plugin1:dp1;plugin2:dp1:dp2. By default '' will export all device provider of the enabled plugin.''')
|
||||
option('gst-full-dynamic-types', type : 'string', value : '',
|
||||
description : '''List of dynamic types to expose in gstreamer-full's ABI with the syntax plugin:dt1,dt2. By default '' will export all device provider of the enabled plugin.''')
|
||||
|
||||
# Common options, automatically inherited by subprojects
|
||||
option('tests', type : 'feature', value : 'auto', description : 'Build tests')
|
||||
|
|
|
@ -7,6 +7,10 @@ from string import Template
|
|||
TEMPLATE = Template('''
|
||||
#include <gst/gst.h>
|
||||
|
||||
$elements_declaration
|
||||
$typefind_funcs_declaration
|
||||
$device_providers_declaration
|
||||
$dynamic_types_declaration
|
||||
$plugins_declaration
|
||||
|
||||
void
|
||||
|
@ -14,30 +18,101 @@ 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
|
||||
$plugins_registration
|
||||
|
||||
g_once_init_leave (&initialization_value, 1);
|
||||
}
|
||||
}
|
||||
''')
|
||||
# Retrieve the plugin name as it can be a plugin filename
|
||||
def get_plugin_name(name):
|
||||
for p in plugins:
|
||||
if name in p:
|
||||
return p
|
||||
return ''
|
||||
|
||||
def process_features(features_list, plugins, feature_prefix):
|
||||
plugins_list = plugins
|
||||
feature_declaration = []
|
||||
feature_registration = []
|
||||
if features_list is not None:
|
||||
feature_plugins = features_list.split(';')
|
||||
for plugin in feature_plugins:
|
||||
split = plugin.split(':')
|
||||
plugin_name = split[0].strip()
|
||||
if len(split) == 2:
|
||||
if (get_plugin_name(plugin_name)) != '':
|
||||
plugins_list.remove(get_plugin_name(plugin_name))
|
||||
features = split[1].split(',')
|
||||
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)]
|
||||
return (plugins_list, feature_declaration, feature_registration)
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(dest="output", help="Output file")
|
||||
parser.add_argument(dest="plugins", help="The list of plugins")
|
||||
|
||||
parser.add_argument('-o', dest="output", help="Output file")
|
||||
parser.add_argument('-p','--plugins', nargs='?', default='', dest="plugins", help="The list of plugins")
|
||||
parser.add_argument('-e', '--elements', nargs='?', default='', dest="elements", help="The list of plugin:elements")
|
||||
parser.add_argument('-t', '--type-finds', nargs='?', default='', dest="typefindfuncs", help="The list of plugin:typefinds")
|
||||
parser.add_argument('-d', '--devide-providers', nargs='?', default='', dest="deviceproviders", help="The list of plugin:deviceproviders")
|
||||
parser.add_argument('-T', '--dynamic-types', nargs='?', default='', dest="dynamictypes", help="The list of plugin:dynamictypes")
|
||||
options = parser.parse_args()
|
||||
if options.output is None:
|
||||
output_file = 'gstinitstaticplugins.c'
|
||||
else:
|
||||
output_file = options.output
|
||||
enable_staticelements_plugin = 0;
|
||||
elements_declaration = []
|
||||
elements_registration = []
|
||||
typefind_funcs_declaration = []
|
||||
typefind_funcs_registration = []
|
||||
device_providers_declaration = []
|
||||
device_providers_registration = []
|
||||
dynamic_types_declaration = []
|
||||
dynamic_types_registration = []
|
||||
plugins_declaration = []
|
||||
plugins_registration = []
|
||||
|
||||
names = set()
|
||||
for plugin in options.plugins.split(os.pathsep):
|
||||
if options.plugins is None:
|
||||
plugins = []
|
||||
else:
|
||||
plugins = options.plugins.split(';')
|
||||
|
||||
# process the features
|
||||
(plugins, elements_declaration, elements_registration) = process_features(options.elements, plugins, 'GST_ELEMENT')
|
||||
(plugins, typefind_funcs_declaration, typefind_funcs_registration) = process_features(options.typefindfuncs, plugins, 'GST_TYPE_FIND')
|
||||
(plugins, device_providers_declaration, device_providers_registration) = process_features(options.deviceproviders, plugins, 'GST_DEVICE_PROVIDER')
|
||||
(plugins, dynamic_types_declaration, dynamic_types_registration) = process_features(options.dynamictypes, plugins, 'GST_DYNAMIC_TYPE')
|
||||
|
||||
# Enable plugin or elements according to the ';' separated list.
|
||||
for plugin in plugins:
|
||||
split = plugin.split(':')
|
||||
plugin_name = split[0]
|
||||
if plugin_name == '':
|
||||
continue
|
||||
filename = os.path.basename(plugin)
|
||||
if filename.startswith('libgst') and filename.endswith('.a'):
|
||||
names.add(filename[len('libgst'):-len('.a')])
|
||||
plugin_name = filename[len('libgst'):-len('.a')]
|
||||
plugins_registration += ['GST_PLUGIN_STATIC_REGISTER(%s);' % (plugin_name)]
|
||||
plugins_declaration += ['GST_PLUGIN_STATIC_DECLARE(%s);' % (plugin_name)]
|
||||
|
||||
registration = ['GST_PLUGIN_STATIC_REGISTER(%s);' % name for name in names]
|
||||
declaration = ['GST_PLUGIN_STATIC_DECLARE(%s);' % name for name in names]
|
||||
|
||||
with open(options.output, "w") as f:
|
||||
with open(output_file.strip(), "w") as f:
|
||||
static_elements_plugin = ''
|
||||
f.write(TEMPLATE.substitute({
|
||||
'plugins_declaration': '\n'.join(declaration),
|
||||
'plugins_registration': '\n '.join(registration),
|
||||
'elements_declaration': '\n'.join(elements_declaration),
|
||||
'elements_registration': '\n '.join(elements_registration),
|
||||
'typefind_funcs_declaration': '\n'.join(typefind_funcs_declaration),
|
||||
'typefind_funcs_registration': '\n '.join(typefind_funcs_registration),
|
||||
'device_providers_declaration': '\n'.join(device_providers_declaration),
|
||||
'device_providers_registration': '\n '.join(device_providers_registration),
|
||||
'dynamic_types_declaration': '\n'.join(dynamic_types_declaration),
|
||||
'dynamic_types_registration': '\n '.join(dynamic_types_registration),
|
||||
'plugins_declaration': '\n'.join(plugins_declaration),
|
||||
'plugins_registration': '\n '.join(plugins_registration),
|
||||
}))
|
||||
|
|
Loading…
Reference in a new issue