From c47e1383ca78c06ca36bc17b5054c1c58a1bd839 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Fri, 13 Nov 2015 17:32:57 -0500 Subject: [PATCH] plugin: Add prefix support to dependencies This adds a new flags, GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX, which allow using the names as prefix for plugin depencies. https://bugzilla.gnome.org/show_bug.cgi?id=758083 --- gst/gstplugin.c | 10 ++++++++-- gst/gstplugin.h | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 1626f33..8bdf1b5 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -1513,6 +1513,9 @@ gst_plugin_ext_dep_direntry_matches (GstPlugin * plugin, const gchar * entry, if (((flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX)) && g_str_has_suffix (entry, *filenames)) { return TRUE; + } else if (((flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX)) && + g_str_has_prefix (entry, *filenames)) { + return TRUE; /* else it's an exact match that's needed */ } else if (strcmp (entry, *filenames) == 0) { return TRUE; @@ -1589,7 +1592,7 @@ gst_plugin_ext_dep_scan_path_with_filenames (GstPlugin * plugin, GstPluginDependencyFlags flags) { const gchar *empty_filenames[] = { "", NULL }; - gboolean recurse_into_dirs, partial_names; + gboolean recurse_into_dirs, partial_names = FALSE; guint i, hash = 0; /* to avoid special-casing below (FIXME?) */ @@ -1597,7 +1600,10 @@ gst_plugin_ext_dep_scan_path_with_filenames (GstPlugin * plugin, filenames = empty_filenames; recurse_into_dirs = ! !(flags & GST_PLUGIN_DEPENDENCY_FLAG_RECURSE); - partial_names = ! !(flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX); + + if ((flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX) || + (flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX)) + partial_names = TRUE; /* if we can construct the exact paths to check with the data we have, just * stat them one by one; this is more efficient than opening the directory diff --git a/gst/gstplugin.h b/gst/gstplugin.h index c76302f..ff6041f 100644 --- a/gst/gstplugin.h +++ b/gst/gstplugin.h @@ -93,6 +93,9 @@ typedef enum * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX : interpret * filename argument as filter suffix and check all matching files in * the directory + * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX : interpret + * filename argument as filter prefix and check all matching files in + * the directory. Since 1.8. * * Flags used in connection with gst_plugin_add_dependency(). */ @@ -100,7 +103,8 @@ typedef enum { GST_PLUGIN_DEPENDENCY_FLAG_NONE = 0, GST_PLUGIN_DEPENDENCY_FLAG_RECURSE = (1 << 0), GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY = (1 << 1), - GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX = (1 << 2) + GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX = (1 << 2), + GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX = (1 << 3) } GstPluginDependencyFlags; /** -- 2.7.4