mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
registry/macos: retrieve plugins relative to location of libgstreamer.dylib
Provides a relocatable directory structure for running GStreamer applications as used in GStreamer.framework. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1627>
This commit is contained in:
parent
0600acd715
commit
747a82006c
4 changed files with 74 additions and 34 deletions
|
@ -585,7 +585,9 @@ init_pre (GOptionContext * context, GOptionGroup * group, gpointer data,
|
||||||
g_free (basedir);
|
g_free (basedir);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
libdir = g_strdup (LIBDIR);
|
libdir = priv_gst_get_relocated_libgstreamer ();
|
||||||
|
if (!libdir)
|
||||||
|
libdir = g_strdup (LIBDIR);
|
||||||
#endif
|
#endif
|
||||||
GST_INFO ("Initializing GStreamer Core Library version %s", VERSION);
|
GST_INFO ("Initializing GStreamer Core Library version %s", VERSION);
|
||||||
GST_INFO ("Using library installed in %s", libdir);
|
GST_INFO ("Using library installed in %s", libdir);
|
||||||
|
|
|
@ -525,5 +525,7 @@ struct _GstClockEntryImpl
|
||||||
* virtual functions on the clock */
|
* virtual functions on the clock */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char * priv_gst_get_relocated_libgstreamer (void);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* __GST_PRIVATE_H__ */
|
#endif /* __GST_PRIVATE_H__ */
|
||||||
|
|
|
@ -476,26 +476,33 @@ gst_plugin_loader_spawn (GstPluginLoader * loader)
|
||||||
res = gst_plugin_loader_try_helper (loader, helper_bin);
|
res = gst_plugin_loader_try_helper (loader, helper_bin);
|
||||||
g_free (helper_bin);
|
g_free (helper_bin);
|
||||||
} else {
|
} else {
|
||||||
|
char *relocated_libgstreamer;
|
||||||
|
|
||||||
/* use the installed version */
|
/* use the installed version */
|
||||||
GST_LOG ("Trying installed plugin scanner");
|
GST_LOG ("Trying installed plugin scanner");
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
{
|
#define EXESUFFIX ".exe"
|
||||||
gchar *basedir;
|
|
||||||
|
|
||||||
basedir =
|
|
||||||
g_win32_get_package_installation_directory_of_module
|
|
||||||
(_priv_gst_dll_handle);
|
|
||||||
helper_bin =
|
|
||||||
g_build_filename (basedir, GST_PLUGIN_SCANNER_SUBDIR,
|
|
||||||
"gstreamer-" GST_API_VERSION, "gst-plugin-scanner.exe", NULL);
|
|
||||||
g_free (basedir);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
helper_bin = g_strdup (GST_PLUGIN_SCANNER_INSTALLED);
|
#define EXESUFFIX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
relocated_libgstreamer = priv_gst_get_relocated_libgstreamer ();
|
||||||
|
if (relocated_libgstreamer) {
|
||||||
|
GST_DEBUG ("found libgstreamer-" GST_API_VERSION " library "
|
||||||
|
"at %s", relocated_libgstreamer);
|
||||||
|
helper_bin = g_build_filename (relocated_libgstreamer,
|
||||||
|
"..", GST_PLUGIN_SCANNER_SUBDIR, "gstreamer-" GST_API_VERSION,
|
||||||
|
"gst-plugin-scanner" EXESUFFIX, NULL);
|
||||||
|
} else {
|
||||||
|
helper_bin = g_strdup (GST_PLUGIN_SCANNER_INSTALLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_DEBUG ("using system plugin scanner at %s", helper_bin);
|
||||||
|
|
||||||
res = gst_plugin_loader_try_helper (loader, helper_bin);
|
res = gst_plugin_loader_try_helper (loader, helper_bin);
|
||||||
g_free (helper_bin);
|
g_free (helper_bin);
|
||||||
|
g_free (relocated_libgstreamer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
|
|
|
@ -121,6 +121,9 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
extern HMODULE _priv_gst_dll_handle;
|
extern HMODULE _priv_gst_dll_handle;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DLFCN_H
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Use a toolchain-dependent suffix on Windows */
|
/* Use a toolchain-dependent suffix on Windows */
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
@ -1543,6 +1546,39 @@ load_plugin_func (gpointer data, gpointer user_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
priv_gst_get_relocated_libgstreamer (void)
|
||||||
|
{
|
||||||
|
char *dir = NULL;
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
{
|
||||||
|
char *base_dir;
|
||||||
|
|
||||||
|
base_dir =
|
||||||
|
g_win32_get_package_installation_directory_of_module
|
||||||
|
(_priv_gst_dll_handle);
|
||||||
|
|
||||||
|
dir = g_build_filename (base_dir, GST_PLUGIN_SUBDIR, NULL);
|
||||||
|
GST_DEBUG ("using DLL dir %s", dir);
|
||||||
|
|
||||||
|
g_free (base_dir);
|
||||||
|
}
|
||||||
|
#elif defined(__APPLE__) && defined(HAVE_DLADDR)
|
||||||
|
{
|
||||||
|
Dl_info info;
|
||||||
|
|
||||||
|
if (dladdr (&gst_init, &info)) {
|
||||||
|
dir = g_path_get_dirname (info.dli_fname);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef GST_DISABLE_REGISTRY
|
#ifndef GST_DISABLE_REGISTRY
|
||||||
/* Unref all plugins marked 'cached', to clear old plugins that no
|
/* Unref all plugins marked 'cached', to clear old plugins that no
|
||||||
* longer exist. Returns %TRUE if any plugins were removed */
|
* longer exist. Returns %TRUE if any plugins were removed */
|
||||||
|
@ -1654,7 +1690,7 @@ scan_and_update_registry (GstRegistry * default_registry,
|
||||||
if (plugin_path == NULL)
|
if (plugin_path == NULL)
|
||||||
plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
|
plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
|
||||||
if (plugin_path == NULL) {
|
if (plugin_path == NULL) {
|
||||||
char *home_plugins;
|
char *home_plugins, *relocated_libgstreamer, *system_plugindir;
|
||||||
|
|
||||||
GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH not set");
|
GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH not set");
|
||||||
|
|
||||||
|
@ -1669,28 +1705,21 @@ scan_and_update_registry (GstRegistry * default_registry,
|
||||||
|
|
||||||
/* add the main (installed) library path */
|
/* add the main (installed) library path */
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
relocated_libgstreamer = priv_gst_get_relocated_libgstreamer ();
|
||||||
{
|
if (relocated_libgstreamer) {
|
||||||
char *base_dir;
|
GST_DEBUG ("found libgstreamer-" GST_API_VERSION " library "
|
||||||
char *dir;
|
"at %s", relocated_libgstreamer);
|
||||||
|
system_plugindir = g_build_filename (relocated_libgstreamer,
|
||||||
base_dir =
|
|
||||||
g_win32_get_package_installation_directory_of_module
|
|
||||||
(_priv_gst_dll_handle);
|
|
||||||
|
|
||||||
dir = g_build_filename (base_dir, GST_PLUGIN_SUBDIR,
|
|
||||||
"gstreamer-" GST_API_VERSION, NULL);
|
"gstreamer-" GST_API_VERSION, NULL);
|
||||||
GST_DEBUG ("scanning DLL dir %s", dir);
|
} else {
|
||||||
|
system_plugindir = g_strdup (PLUGINDIR);
|
||||||
changed |= gst_registry_scan_path_internal (&context, dir);
|
|
||||||
|
|
||||||
g_free (dir);
|
|
||||||
g_free (base_dir);
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
GST_DEBUG ("scanning main plugins %s", PLUGINDIR);
|
GST_DEBUG ("using plugin dir %s", system_plugindir);
|
||||||
changed |= gst_registry_scan_path_internal (&context, PLUGINDIR);
|
changed |= gst_registry_scan_path_internal (&context, system_plugindir);
|
||||||
#endif
|
|
||||||
|
g_clear_pointer (&system_plugindir, g_free);
|
||||||
|
g_clear_pointer (&relocated_libgstreamer, g_free);
|
||||||
} else {
|
} else {
|
||||||
gchar **list;
|
gchar **list;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
Loading…
Reference in a new issue