2019-09-17 15:52:10 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
from string import Template
|
|
|
|
|
|
|
|
TEMPLATE = Template('''
|
|
|
|
#include <gst/gst.h>
|
2023-09-28 16:22:38 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2019-09-17 15:52:10 +00:00
|
|
|
|
2020-07-16 11:18:38 +00:00
|
|
|
$elements_declaration
|
|
|
|
$typefind_funcs_declaration
|
|
|
|
$device_providers_declaration
|
|
|
|
$dynamic_types_declaration
|
2019-09-17 15:52:10 +00:00
|
|
|
$plugins_declaration
|
2022-06-23 15:50:00 +00:00
|
|
|
$giomodules_declaration
|
2019-09-17 15:52:10 +00:00
|
|
|
|
2023-09-28 16:22:38 +00:00
|
|
|
static
|
|
|
|
gboolean register_features_full (GstPlugin* plugin)
|
|
|
|
{
|
|
|
|
$elements_registration
|
|
|
|
$typefind_funcs_registration
|
|
|
|
$device_providers_registration
|
|
|
|
$dynamic_types_registration
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-08-16 16:07:36 +00:00
|
|
|
_GST_EXPORT
|
2019-09-17 15:52:10 +00:00
|
|
|
void
|
|
|
|
gst_init_static_plugins (void)
|
|
|
|
{
|
2020-10-01 14:43:36 +00:00
|
|
|
static gsize initialization_value = 0;
|
|
|
|
if (g_once_init_enter (&initialization_value)) {
|
2023-09-28 16:22:38 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2020-10-01 14:43:36 +00:00
|
|
|
$plugins_registration
|
2022-06-23 15:50:00 +00:00
|
|
|
$giomodules_registration
|
2020-07-16 11:18:38 +00:00
|
|
|
|
2020-10-01 14:43:36 +00:00
|
|
|
g_once_init_leave (&initialization_value, 1);
|
|
|
|
}
|
2019-09-17 15:52:10 +00:00
|
|
|
}
|
|
|
|
''')
|
2022-02-04 13:47:32 +00:00
|
|
|
|
|
|
|
|
2020-07-16 11:18:38 +00:00
|
|
|
# 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 ''
|
|
|
|
|
2022-02-04 13:47:32 +00:00
|
|
|
|
2020-07-16 11:18:38 +00:00
|
|
|
def process_features(features_list, plugins, feature_prefix):
|
|
|
|
plugins_list = plugins
|
|
|
|
feature_declaration = []
|
|
|
|
feature_registration = []
|
|
|
|
if features_list is not None:
|
2022-02-04 13:47:32 +00:00
|
|
|
feature_plugins = features_list.split(';')
|
2020-07-16 11:18:38 +00:00
|
|
|
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)]
|
2023-09-28 16:22:38 +00:00
|
|
|
feature_registration += ['%s_REGISTER(%s, plugin);' % (feature_prefix, feature)]
|
2020-07-16 11:18:38 +00:00
|
|
|
return (plugins_list, feature_declaration, feature_registration)
|
2019-09-17 15:52:10 +00:00
|
|
|
|
2022-02-04 13:47:32 +00:00
|
|
|
|
2019-09-17 15:52:10 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser()
|
2020-07-16 11:18:38 +00:00
|
|
|
parser.add_argument('-o', dest="output", help="Output file")
|
2022-02-04 13:47:32 +00:00
|
|
|
parser.add_argument('-p', '--plugins', nargs='?', default='', dest="plugins", help="The list of plugins")
|
2020-07-16 11:18:38 +00:00
|
|
|
parser.add_argument('-e', '--elements', nargs='?', default='', dest="elements", help="The list of plugin:elements")
|
2022-02-04 13:47:32 +00:00
|
|
|
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")
|
2022-06-23 15:50:00 +00:00
|
|
|
parser.add_argument('--giomodules', nargs='?', default='',
|
|
|
|
dest="giomodules", help="The list of GIO modules")
|
2019-09-17 15:52:10 +00:00
|
|
|
options = parser.parse_args()
|
2020-07-16 11:18:38 +00:00
|
|
|
if options.output is None:
|
|
|
|
output_file = 'gstinitstaticplugins.c'
|
|
|
|
else:
|
|
|
|
output_file = options.output
|
2022-02-04 13:47:32 +00:00
|
|
|
enable_staticelements_plugin = 0
|
2020-07-16 11:18:38 +00:00
|
|
|
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 = []
|
2022-06-23 15:50:00 +00:00
|
|
|
giomodules_declaration = []
|
|
|
|
giomodules_registration = []
|
2019-09-17 15:52:10 +00:00
|
|
|
|
2022-02-04 13:46:24 +00:00
|
|
|
if ',' in options.plugins or ':' in options.plugins:
|
|
|
|
print("Only ';' is allowed in the list of plugins.")
|
|
|
|
exit(1)
|
|
|
|
|
2021-05-18 12:30:33 +00:00
|
|
|
if options.plugins is None or options.plugins.isspace():
|
2020-07-16 11:18:38 +00:00
|
|
|
plugins = []
|
|
|
|
else:
|
|
|
|
plugins = options.plugins.split(';')
|
|
|
|
|
|
|
|
# process the features
|
|
|
|
(plugins, elements_declaration, elements_registration) = process_features(options.elements, plugins, 'GST_ELEMENT')
|
2022-02-04 13:47:32 +00:00
|
|
|
(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')
|
2020-07-16 11:18:38 +00:00
|
|
|
|
|
|
|
# Enable plugin or elements according to the ';' separated list.
|
|
|
|
for plugin in plugins:
|
|
|
|
split = plugin.split(':')
|
|
|
|
plugin_name = split[0]
|
|
|
|
if plugin_name == '':
|
2022-02-04 13:47:32 +00:00
|
|
|
continue
|
2022-12-05 08:50:43 +00:00
|
|
|
filename = os.path.basename(plugin).strip()
|
2019-09-17 15:52:10 +00:00
|
|
|
if filename.startswith('libgst') and filename.endswith('.a'):
|
2020-07-16 11:18:38 +00:00
|
|
|
plugin_name = filename[len('libgst'):-len('.a')]
|
2023-08-18 01:19:19 +00:00
|
|
|
elif filename.startswith('libgst') and filename.endswith('.lib'):
|
|
|
|
plugin_name = filename[len('libgst'):-len('.lib')]
|
2020-07-16 11:18:38 +00:00
|
|
|
plugins_registration += ['GST_PLUGIN_STATIC_REGISTER(%s);' % (plugin_name)]
|
|
|
|
plugins_declaration += ['GST_PLUGIN_STATIC_DECLARE(%s);' % (plugin_name)]
|
2019-09-17 15:52:10 +00:00
|
|
|
|
2022-06-23 15:50:00 +00:00
|
|
|
giomodules = options.giomodules.split(';') if options.giomodules else []
|
|
|
|
for module_name in giomodules:
|
|
|
|
if module_name.startswith('gio'):
|
|
|
|
module_name = module_name[3:]
|
|
|
|
giomodules_declaration.append(f'extern void g_io_{module_name}_load (gpointer data);')
|
|
|
|
giomodules_registration.append(f'g_io_{module_name}_load (NULL);')
|
|
|
|
|
2020-07-16 11:18:38 +00:00
|
|
|
with open(output_file.strip(), "w") as f:
|
|
|
|
static_elements_plugin = ''
|
2019-09-17 15:52:10 +00:00
|
|
|
f.write(TEMPLATE.substitute({
|
2020-07-16 11:18:38 +00:00
|
|
|
'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),
|
2022-06-23 15:50:00 +00:00
|
|
|
'giomodules_declaration': '\n'.join(giomodules_declaration),
|
|
|
|
'giomodules_registration': '\n '.join(giomodules_registration),
|
2022-02-04 13:47:32 +00:00
|
|
|
}))
|