"Linking" to dynamically loaded plugins.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"Linking" to dynamically loaded plugins.

benoitlahoz
Hello,

I'm building an umbrella framework on OSX (XCode) including GStreamer.
Everything works fine except for the plugins that doesn't have a dylib.

I add -undefined dynamic_lookup to the Other Linker Flags in order to avoid errors at build time.
Then, for instance, when I instantiate a gstdecklinksrc plugin it works fine, but when I try to use its own specific functions in my code, the runtime tells me that library was not loaded.

I'm wondering how GStreamer loads its plugins and how I can use the functions of these plugins that don't have a shared library.

For information, before GStreamer initialization I run this method:

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{

        /**
         * Get paths for GStreamer framework.
         */
       
        NSString *frameworksPath = [[NSBundle mainBundle] privateFrameworksPath];
       
        NSString *scannerPath = [NSString stringWithFormat:@"%@/%@",
                                 frameworksPath,
                                 @"PiplStream.Framework/Versions/A/Frameworks/GStreamer.framework/Versions/0.3/libexec/gstreamer-1.0/gst-plugin-scanner"];
       
        NSString *pluginsPath = [NSString stringWithFormat:@"%@/%@",
                                 frameworksPath,
                                 @"PiplStream.Framework/Versions/A/Frameworks/GStreamer.framework/Versions/0.3/lib/gstreamer-1.0/"];
       
        NSString *gtkPath = [NSString stringWithFormat:@"%@/%@",
                             frameworksPath,
                             @"PiplStream.Framework/Versions/A/Frameworks/GStreamer.framework/Versions/0.3/"];
       
        NSString *gioPath = [NSString stringWithFormat:@"%@/%@",
                             frameworksPath,
                             @"PiplStream.Framework/Versions/A/Frameworks/GStreamer.framework/Versions/0.3/lib/gio/modules/"];
       
        NSString *gdkDirPath = [NSString stringWithFormat:@"%@/%@",
                                frameworksPath,
                                @"PiplStream.Framework/Versions/A/Frameworks/GStreamer.framework/Versions/0.3/lib/gdk-pixbuf-2.0/2.10.0/loaders/"];
       
        NSString *gdkModPath = [NSString stringWithFormat:@"%@/%@",
                                frameworksPath,
                                @"PiplStream.Framework/Versions/A/Frameworks/GStreamer.framework/Versions/0.3/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"];
       
        /**
         * Load libraries at this path if a compatible version is not found on system.
         */
       
        NSString *priorityPath = [NSString stringWithFormat:@"%@/%@",
                                  frameworksPath,
                                  @"PiplStream.Framework/Versions/A/Frameworks/GStreamer.framework/Versions/0.3/lib/"];
       
        setenv("DYLD_FALLBACK_LIBRARY_PATH", [priorityPath UTF8String], 1);
       
        /**
         * Setup environment variables for GStreamer.
         */
       
        setenv("GST_PLUGIN_SCANNER", [scannerPath UTF8String], 1);
        setenv("GST_PLUGIN_PATH", [pluginsPath UTF8String], 1);
        setenv("GTK_PATH", [gtkPath UTF8String], 1);
        setenv("GIO_EXTRA_MODULES", [gioPath UTF8String], 1);
        setenv("GDK_PIXBUF_MODULEDIR", [gdkDirPath UTF8String], 1);
        setenv("GDK_PIXBUF_MODULE_FILE", [gdkModPath UTF8String], 1);
       
        // Initialize GStreamer
        gst_init(NULL, NULL);
       
    });

Thank you!

Ben
Reply | Threaded
Open this post in threaded view
|

Re: "Linking" to dynamically loaded plugins.

Sebastian Dröge-3
On Mo, 2016-05-02 at 01:39 -0700, benoitlahoz wrote:

> Hello, 
>
> I'm building an umbrella framework on OSX (XCode) including GStreamer. 
> Everything works fine except for the plugins that doesn't have a dylib.
>
> I add /-undefined dynamic_lookup/ to the Other Linker Flags in order to
> avoid errors at build time. 
> Then, for instance, when I instantiate a gstdecklinksrc plugin it works
> fine, but when I try to use its own specific functions in my code, the
> runtime tells me that library was not loaded.
>
> I'm wondering how GStreamer loads its plugins and how I can use the
> functions of these plugins that don't have a shared library. 
What do you mean with plugins that don't have a shared library? All of
the ones shipped with the binaries should have a shared library in
lib/gstreamer-1.0 and a corresponding static one in lib/gstreamer-
1.0/static.

The static ones need special attention to work, check
GST_STATIC_PLUGIN_DECLARE() and GST_STATIC_PLUGIN_REGISTER() in the
docs for seeing how that works.

The dynamic ones only need to be in a path that is considered by the
GstRegistry. This is configured via the GST_PLUGIN_PATH,
GST_PLUGIN_SYSTEM_PATH environment variables and API on GstRegistry.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment