Search code examples
gstreamerglib

Unable to get Appsrc element from gstreamer


I need to make a GStreamer audio pipeline to redirect audio stream. GStreamer has been built from vcpg (v 1.19.2).

I also made an install from msi file, with same issue.

Project is made with Visual Studio 2019.

I succeed to get some elements from factories :

GstElement* queue2 = gst_element_factory_make("queue", "queue");
GstElement* audio_sink = gst_element_factory_make("autoaudiosink", "sink");

but still failed to get appsrc element:

GstElement* app_source = gst_element_factory_make("appsrc", "source"); // null !!!

It appears that relevant plugin exists (gst-inpect):

appsrc: Factory Details:
appsrc:   Rank                     none (0)
appsrc:   Long-name                AppSrc
appsrc:   Klass                    Generic/Source
appsrc:   Description              Allow the application to feed buffers to a pipeline
appsrc:   Author                   David Schleef <[email protected]>, Wim Taymans <[email protected]>
appsrc: 
appsrc: Plugin Details:
appsrc:   Name                     app
appsrc:   Description              Elements used to communicate with applications
appsrc:   Filename                 C:\src\vcpkg\installed\x64-windows\bin\gstapp.dll
appsrc:   Version                  1.19.2
appsrc:   License                  LGPL
appsrc:   Source module            gst-plugins-base
appsrc:   Source release date      2021-09-23
appsrc:   Binary package           GStreamer Base Plug-ins source release
appsrc:   Origin URL               Unknown package origin
appsrc: 
appsrc: GObject
appsrc:  +----GInitiallyUnowned
appsrc:        +----GstObject
appsrc:              +----GstElement
appsrc:                    +----GstBaseSrc
appsrc:                          +----GstAppSrc
...

I tested:

GstPlugin*  pl = gst_plugin_load_file("C:\\src\\vcpkg\\installed\\x64-windows\\bin\\gstapp.dll",&error);
// still NULL... after warning message "specified module not found"

However same code works with other plugins. e.g. "gstcoreelements.dll"

Strangely, looping on element factories and plugins show me what I need:

GList* list, * walk;
list = gst_registry_feature_filter(registry, filter_vis_features, FALSE, NULL);
for (walk = list; walk != NULL; walk = g_list_next(walk)) {
    const gchar* name;
    GstElementFactory* factory;
        factory = GST_ELEMENT_FACTORY(walk->data);
    name = gst_element_factory_get_longname(factory);
    g_print("  %s\n", name);
   
    // returns notably:   AppSink and AppSrc
}

GList *list2 = gst_registry_plugin_filter(registry, filter_vis_plugins, FALSE, NULL);

for (walk = list2; walk != NULL; walk = g_list_next(walk)) {
    const gchar* name;
    GstPlugin* plugin;
    plugin = GST_PLUGIN(walk->data);
    name = gst_plugin_get_filename(plugin);
    g_print(" ----  %s\n", name);
    name = gst_plugin_get_name(plugin);
    g_print(" ----  %s\n", name);

    //  ----  C:\src\vcpkg\installed\x64-windows\bin\gstapp.dll
    // ----  app
}

Using break points, it seems that module loading failed in glib "g_module_open_full" function.

I don't know why at the moment, because debug infos stopped with "gmodule-win32.c not found".

Any idea, tip, clue (,solution) will be highly appreciated.


Solution

  • Finally get it working by adding gstapp-1.0-0.dll in .exe directory.