res = gst_plugin_loader_try_helper (loader, helper_bin);
g_free (helper_bin);
} else {
+ char *relocated_libgstreamer;
+
/* use the installed version */
GST_LOG ("Trying installed plugin scanner");
#ifdef G_OS_WIN32
- {
- 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);
- }
+#define EXESUFFIX ".exe"
#else
- helper_bin = g_strdup (GST_PLUGIN_SCANNER_INSTALLED);
+#define EXESUFFIX
#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);
g_free (helper_bin);
+ g_free (relocated_libgstreamer);
}
if (!res) {
#include <windows.h>
extern HMODULE _priv_gst_dll_handle;
#endif
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
/* Use a toolchain-dependent suffix on Windows */
#ifdef G_OS_WIN32
}
}
+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
/* Unref all plugins marked 'cached', to clear old plugins that no
* longer exist. Returns %TRUE if any plugins were removed */
if (plugin_path == NULL)
plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
if (plugin_path == NULL) {
- char *home_plugins;
+ char *home_plugins, *relocated_libgstreamer, *system_plugindir;
GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH not set");
/* 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, GST_PLUGIN_SUBDIR,
+ relocated_libgstreamer = priv_gst_get_relocated_libgstreamer ();
+ if (relocated_libgstreamer) {
+ GST_DEBUG ("found libgstreamer-" GST_API_VERSION " library "
+ "at %s", relocated_libgstreamer);
+ system_plugindir = g_build_filename (relocated_libgstreamer,
"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);
+ GST_DEBUG ("using plugin dir %s", system_plugindir);
+ changed |= gst_registry_scan_path_internal (&context, system_plugindir);
- g_free (dir);
- g_free (base_dir);
- }
-#else
- GST_DEBUG ("scanning main plugins %s", PLUGINDIR);
- changed |= gst_registry_scan_path_internal (&context, PLUGINDIR);
-#endif
+ g_clear_pointer (&system_plugindir, g_free);
+ g_clear_pointer (&relocated_libgstreamer, g_free);
} else {
gchar **list;
gint i;