<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 10 janv. 2022 07 h 00, amindfv--- via gstreamer-devel <<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jan 10, 2022 at 10:41:12AM +0100, Florian Echtler wrote:<br>
> On 10/01/2022 10:36, <a href="mailto:amindfv@mailbox.org" target="_blank" rel="noreferrer">amindfv@mailbox.org</a> wrote:<br>
> > On Mon, Jan 10, 2022 at 09:48:26AM +0100, Florian Echtler wrote:<br>
> > > On 10/01/2022 09:21, <a href="mailto:amindfv@mailbox.org" target="_blank" rel="noreferrer">amindfv@mailbox.org</a> wrote:<br>
> > > > On Sun, Jan 09, 2022 at 12:33:24PM -0800, <a href="mailto:amindfv@mailbox.org" target="_blank" rel="noreferrer">amindfv@mailbox.org</a> wrote:<br>
> > > > <br>
> > > > Here's my latest, boiled down to a simple example. I hope my inexperienced attempts aren't too horrifying, or if so they're easy enough to get on the right track.<br>
> > > > <br>
> > > > I've built the .so file, which is in the current directory. I then launch a hello world pipeline (unrelated to the new plugin), and hit an error loading the .so:<br>
> > > > <br>
> > > >       $ GST_PLUGIN_PATH=$GST_PLUGIN_PATH:. gst-launch-1.0 videotestsrc ! autovideosink<br>
> > > >       (gst-plugin-scanner:149635): GStreamer-WARNING **: 00:02:44.715: Failed to load plugin './libgstalphacombine.so': ./libgstalphacombine.so: undefined symbol: gst_video_info_init<br>
> > > >       Setting pipeline to PAUSED ...<br>
> > > >       Pipeline is PREROLLING ...<br>
> > > >       Pipeline is PREROLLED ...<br>
> > > >       Setting pipeline to PLAYING ...<br>
> > > > <br>
> > > > gstalphacombine.c contains "#include <gst/video/video.h>", which in turn includes gst/video/video-info.h. In other words, gst_video_info_init "shouldn't" be undefined.<br>
> > > <br>
> > > It's defined for compile time, but apparently not for link time (which is<br>
> > > partially deferred until the library is actually loaded in this case).<br>
> > <br>
> > Thanks for the fast reply!<br>
> > <br>
> > > You can check with `ldd ./libgstalphacombine.so` whether there's just a<br>
> > > library path missing at load time;<br>
> > <br>
> > Here's the output; seems to my untrained eye not to be missing anything:<br>
> > <br>
> >      $ ldd ./libgstalphacombine.so<br>
> >      linux-vdso.so.1 (0x00007ffdbeded000)<br>
> >      libgstreamer-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0 (0x00007f75529fa000)<br>
> >      libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f75529a0000)<br>
> >      libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f7552871000)<br>
> >      libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f755286b000)<br>
> >      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7552727000)<br>
> >      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7552721000)<br>
> >      libunwind.so.8 => /usr/lib/x86_64-linux-gnu/libunwind.so.8 (0x00007f7552704000)<br>
> >      libdw.so.1 => /usr/lib/x86_64-linux-gnu/libdw.so.1 (0x00007f755265b000)<br>
> >      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7552639000)<br>
> >      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7552474000)<br>
> >      libffi.so.7 => /usr/lib/x86_64-linux-gnu/libffi.so.7 (0x00007f7552468000)<br>
> >      libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f75523f5000)<br>
> >      /lib64/ld-linux-x86-64.so.2 (0x00007f7552b8b000)<br>
> >      liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f75523cb000)<br>
> >      libelf.so.1 => /usr/lib/x86_64-linux-gnu/libelf.so.1 (0x00007f75523b0000)<br>
> >      libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7552393000)<br>
> >      libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f7552380000)<br>
> <br>
> Yes, this looks okay, but...<br>
> <br>
> > > if this is not the case, then you would<br>
> > > need to modify your compiler flags to include whatever GStreamer sub-library<br>
> > > contains gst_video_info_init.<br>
> > <br>
> > The Makefile includes<br>
> > <br>
> >      -I/usr/include/gstreamer-1.0<br>
> > <br>
> > and /usr/include/gstreamer-1.0/gst/video/video-info.h appears to define `gst_video_info_init`.<br>
> <br>
> I think you also need to add `-lgstvideo-1.0` to the link step (where all<br>
> the other -lgst... options are defined).<br>
<br>
Yes, that was it - thank you!<br>
<br>
I'm now able to, seemingly, load the .so file, but GStreamer doesn't seem to recognize the plugin:<br>
<br>
    $ GST_PLUGIN_PATH=$GST_PLUGIN_PATH:. gst-launch-1.0 videotestsrc ! alphacombine ! autovideosink # obviously this isn't a real pipeline<br>
    WARNING: erroneous pipeline: no element "alphacombine"<br>
    $ GST_PLUGIN_PATH=$GST_PLUGIN_PATH:. gst-inspect-1.0 alphacombine<br>
    No such element or plugin 'alphacombine'<br>
<br>
Could it be related to the symbols the .so exports?:<br>
<br>
    $ nm -D --defined-only libgstalphacombine.so<br>
    0000000000006220 D format_map<br>
    0000000000002830 T gst_alpha_combine_get_type<br>
<br>
I notice for the installed plugins there seem to be a uniform (and different) set of symbols:<br>
<br>
    $ nm -D --defined-only /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstalpha.so<br>
    000000000000a670 T gst_plugin_alpha_get_desc<br>
    000000000000a680 T gst_plugin_alpha_register<br>
    $ nm -D --defined-only /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcompositor.so<br>
    000000000000cee0 T gst_plugin_compositor_get_desc<br>
    000000000000cef0 T gst_plugin_compositor_register<br>
<br>
I managed to get the `*_get_desc` and `*_register` symbols exported by copying from gstplugin.c, but clearly I'm still taking shots in the dark, and not yet successfully:<br>
<br>
    #ifndef PACKAGE<br>
    #define PACKAGE "jankyalphacombine"<br>
    #endif<br>
<br>
    GST_PLUGIN_DEFINE (<br>
        GST_VERSION_MAJOR,<br>
        GST_VERSION_MINOR,<br>
        alpha_combine,<br>
        "alphacombine thing",<br>
        gst_alpha_combine_init,<br>
        "1.0.0",<br>
        "LGPL",<br>
        "GStreamer",<br>
        "<a href="http://gstreamer.net/" rel="noreferrer noreferrer" target="_blank">http://gstreamer.net/</a>"<br>
    )<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">To help a little, alphacombibe is a feature (of type GstElement), it needs to be registered in a plugin. Make sure to keep enough of plugin.c so this feature is registered. Notice the original plugin is named codecalpha, plugins .so files needs to be strictly named, since the entry function are deduced from it.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
Tom<br>
</blockquote></div></div></div>