gst.c
#ifndef GST_DISABLE_REGISTRY
static void
add_path_func (gpointer data, gpointer user_data)
{
GST_INFO ("Adding plugin path: \"%s\", will scan later", (gchar *) data);
_priv_gst_plugin_paths =
g_list_append (_priv_gst_plugin_paths, g_strdup (data));
}
#endif
gstregistry.c
static GstRegistryScanAndUpdateResult
scan_and_update_registry (GstRegistry * default_registry,
const gchar * registry_file, gboolean write_changes, GError ** error)
{
const gchar *plugin_path;
gboolean changed = FALSE;
GList *l;
GstRegistryScanContext context;
GST_INFO ("Validating plugins from registry cache: %s", registry_file);
init_scan_context (&context, default_registry);
/* It sounds tempting to just compare the mtime of directories with the mtime
* of the registry cache, but it does not work. It would not catch updated
* plugins, which might bring more or less features.
*/
/* scan paths specified via --gst-plugin-path */
GST_DEBUG ("scanning paths added via --gst-plugin-path");
for (l = _priv_gst_plugin_paths; l != NULL; l = l->next) {
GST_INFO ("Scanning plugin path: \"%s\"", (gchar *) l->data);
changed |= gst_registry_scan_path_internal (&context, (gchar *) l->data);
}
/* keep plugin_paths around in case a re-scan is forced later on */
/* GST_PLUGIN_PATH specifies a list of directories to scan for
* additional plugins. These take precedence over the system plugins */
plugin_path = g_getenv ("GST_PLUGIN_PATH_1_0");
if (plugin_path == NULL)
plugin_path = g_getenv ("GST_PLUGIN_PATH");
if (plugin_path) {
char **list;
int i;
GST_DEBUG ("GST_PLUGIN_PATH set to %s", plugin_path);
list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0);
for (i = 0; list[i]; i++) {
changed |= gst_registry_scan_path_internal (&context, list[i]);
}
g_strfreev (list);
} else {
GST_DEBUG ("GST_PLUGIN_PATH not set");
}
/* GST_PLUGIN_SYSTEM_PATH specifies a list of plugins that are always
* loaded by default. If not set, this defaults to the system-installed
* path, and the plugins installed in the user's home directory */
plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH_1_0");
if (plugin_path == NULL)
plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
if (plugin_path == NULL) {
char *home_plugins;
GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH not set");
/* plugins in the user's home directory take precedence over
* system-installed ones */
home_plugins = g_build_filename (g_get_user_data_dir (),
"gstreamer-" GST_API_VERSION, "plugins", NULL);
GST_DEBUG ("scanning home plugins %s", home_plugins);
changed |= gst_registry_scan_path_internal (&context, home_plugins);
g_free (home_plugins);
/* add the main (installed) library path */
#ifdef G_OS_WIN32
{
char *base_dir;
char *dir;
base_dir =
g_win32_get_package_installation_directory_of_module
(_priv_gst_dll_handle);
dir = g_build_filename (base_dir,
#ifdef _DEBUG
"debug"
#endif
"lib", "gstreamer-" GST_API_VERSION, NULL);
GST_DEBUG ("scanning DLL dir %s", dir);
changed |= gst_registry_scan_path_internal (&context, dir);
g_free (dir);
g_free (base_dir);
}
#else
GST_DEBUG ("scanning main plugins %s", PLUGINDIR);
changed |= gst_registry_scan_path_internal (&context, PLUGINDIR);
#endif
} else {
gchar **list;
gint i;
GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH set to %s", plugin_path);
list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0);
for (i = 0; list[i]; i++) {
changed |= gst_registry_scan_path_internal (&context, list[i]);
}
g_strfreev (list);
}
clear_scan_context (&context);
changed |= context.changed;
/* Remove cached plugins so stale info is cleared. */
changed |= gst_registry_remove_cache_plugins (default_registry);
if (!changed) {
GST_INFO ("Registry cache has not changed");
return REGISTRY_SCAN_AND_UPDATE_SUCCESS_NOT_CHANGED;
}
if (!write_changes) {
GST_INFO ("Registry cache changed, but writing is disabled. Not writing.");
return REGISTRY_SCAN_AND_UPDATE_FAILURE;
}
GST_INFO ("Registry cache changed. Writing new registry cache");
if (!priv_gst_registry_binary_write_cache (default_registry,
default_registry->priv->plugins, registry_file)) {
g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
_("Error writing registry cache to %s: %s"),
registry_file, g_strerror (errno));
return REGISTRY_SCAN_AND_UPDATE_FAILURE;
}
GST_INFO ("Registry cache written successfully");
return REGISTRY_SCAN_AND_UPDATE_SUCCESS_UPDATED;
}
1.首先搜索_priv_gst_plugin_paths下的目录
2.再搜索环境变量GST_PLUGIN_PATH_1_0或者GST_PLUGIN_PATH下的目录
3.然后搜索GST_PLUGIN_SYSTEM_PATH_1_0或者GST_PLUGIN_SYSTEM_PATH下的目录
4.再搜索dll文件所在路径_priv_gst_dll_handle的目录或者PLUGINDIR
5.在搜索环境变量GST_PLUGIN_SYSTEM_PATH定义的路径
6.最后把gstregistry写进cache文件