teltek / gst-plugin-ndi

GStreamer NDI Plugin for Linux
GNU Lesser General Public License v2.1
154 stars 27 forks source link

libgstndi.so initialize fail #110

Open knarziss opened 1 year ago

knarziss commented 1 year ago

Can you please let me know the reason why the following error happens? I installed gstreamer 1.18.2 and libndi 5.5.3. And then I built gst-plugin-ndi latest version.

gst-inspect-1.0 /media/libgstndi.so

(gst-inspect-1.0:12139): GLib-GObject-WARNING **: 00:03:54.627: specified instance size for type 'NdiSrc' is smaller than the parent type's 'GstBaseSrc' instance size

(gst-inspect-1.0:12139): GLib-GObject-WARNING **: 00:03:54.630: cannot add private field to invalid (non-instantiatable) type '' thread '' panicked at 'assertion failed: type_.is_valid()', src/ndisrc/imp.rs:89:1 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace 0:00:00.020210060 12139 0x217dee0 ERROR GST_PLUGIN_LOADING src/lib.rs:149:gstndi::plugindesc: Failed to initialize plugin due to panic: assertion failed: type.is_valid() Could not load plugin file: File "/media/libgstndi.so" appears to be a GStreamer plugin, but it failed to initialize

sdroege commented 1 year ago

That looks like a build environment issue, but also a more up-to-date version of the plugin is available from https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/tree/main/net/ndi . If you still reproduce it with that, please provide more details about your build environment and how you built GStreamer and the plugin.

knarziss commented 1 year ago

I built gst-plugins-rs 10.0.4. But our system gstreamer version is 1.18. Because of gstreamer version pkg-config error, I forcibly modified the gstreamer version in the pkg-config file. 1.18->1.20 Build was success. But when I copied libgstndi.so to our embeded firmware, it cannot be loaded.

0:00:26.150714320 7042 0x1d4f400 WARN GST_PLUGIN_LOADING gstplugin.c:491:gst_plugin_register_func: plugin "/usr/lib/gstreamer-1.0/libgstndi.so" has incompatible version (plugin: 1.20, gst: 1.18), not loading Could not load plugin file: File "/usr/lib/gstreamer-1.0/libgstndi.so" appears to be a GStreamer plugin, but it failed to initialize

How can I build gst-plugins-rs with gstreamer 1.18?

knarziss commented 1 year ago

Hi @sdroege, I used yocto build system. "('meta-rust', 21, 'http://github.com/meta-rust/meta-rust.git', 'branch=master,commit=816a860', ''),"

When I tried gst-plugins-rs 0.8, there was no net/ndi. But to check build environment, I checked other gst-plugins-rs plugins with gst-inspect-1.0. Some plugins had similar problem.

  • libgstcdg.so (OK)
  • libgstclaxon.so (OK)
  • libgstfallbackswitch.so (OK)
  • libgstffv1.so (OK)
  • libgstgif.so (OK)
  • libgsthsv.so (OK)
  • libgstlewton.so (OK)
  • libgstrav1e.so (OK)
  • libgstrsaudiofx.so (OK)
  • libgstrsflv.so (OK)
  • libgstrsjson.so (OK)
  • libgstrspng.so (OK)
  • libgstrsregex.so (OK)
  • libgstrstextwrap.so (OK)
  • libgsttextahead.so (OK)
  • libgstthreadshare.so (OK)
  • libgsturiplaylistbin.so (OK)
  • libgstreqwest.so (Error)
    
    (gst-inspect-1.0:22102): GLib-GObject-WARNING **: 04:12:42.409: specified instance size for type 'ReqwestHttpSrc' is smaller than the parent type's 'GstPushSrc' instance size

(gst-inspect-1.0:22102): GLib-GObject-WARNING **: 04:12:42.412: cannot add private field to invalid (non-instantiatable) type ''

(gst-inspect-1.0:22102): GLib-GObject-CRITICAL **: 04:12:42.412: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instancetype)' failed thread '' panicked at 'assertion failed: type.is_valid()', net/reqwest/src/reqwesthttpsrc/imp.rs:1285:1 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Could not load plugin file: File "/usr/lib/gstreamer-1.0/libgstreqwest.so" appears to be a GStreamer plugin, but it failed to initialize


* libgstrsfile.so (Error)

(gst-inspect-1.0:22102): GLib-GObject-WARNING **: 04:12:42.409: specified instance size for type 'ReqwestHttpSrc' is smaller than the parent type's 'GstPushSrc' instance size

(gst-inspect-1.0:22145): GLib-GObject-WARNING **: 04:13:23.312: specified class size for type 'RsFileSink' is smaller than the parent type's 'GstBaseSink' class size

(gst-inspect-1.0:22145): GLib-GObject-WARNING **: 04:13:23.315: cannot add private field to invalid (non-instantiatable) type ''

(gst-inspect-1.0:22145): GLib-GObject-CRITICAL **: 04:13:23.315: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instancetype)' failed thread '' panicked at 'assertion failed: type.is_valid()', generic/file/src/filesink/imp.rs:111:1 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Could not load plugin file: File "/usr/lib/gstreamer-1.0/libgstrsfile.so" appears to be a GStreamer plugin, but it failed to initialize

* libgstrstutorial.so (Error)

(gst-inspect-1.0:22181): GLib-GObject-WARNING **: 04:13:46.794: specified instance size for type 'RsSineSrc' is smaller than the parent type's 'GstPushSrc' instance size

(gst-inspect-1.0:22181): GLib-GObject-WARNING **: 04:13:46.797: cannot add private field to invalid (non-instantiatable) type '' thread '' panicked at 'assertion failed: type_.is_valid()', tutorial/src/sinesrc/imp.rs:159:1 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Could not load plugin file: File "/usr/lib/gstreamer-1.0/libgstrstutorial.so" appears to be a GStreamer plugin, but it failed to initialize

* libgstrusoto.so (Error)

(gst-inspect-1.0:22212): GLib-GObject-WARNING **: 04:14:06.139: specified class size for type 'RusotoS3Sink' is smaller than the parent type's 'GstBaseSink' class size

(gst-inspect-1.0:22212): GLib-GObject-WARNING **: 04:14:06.142: cannot add private field to invalid (non-instantiatable) type ''

(gst-inspect-1.0:22212): GLib-GObject-CRITICAL **: 04:14:06.142: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instancetype)' failed thread '' panicked at 'assertion failed: type.is_valid()', net/rusoto/src/s3sink/imp.rs:636:1 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Could not load plugin file: File "/usr/lib/gstreamer-1.0/libgstrusoto.so" appears to be a GStreamer plugin, but it failed to initialize

* libgsttogglerecord.so (Error)

Could not load plugin file: File "/usr/lib/gstreamer-1.0/libgsttogglerecord.so" appears to be a GStreamer plugin, but it failed to initialize

knarziss commented 1 year ago

@sdroege I added latest net/ndi into gst-plugins-rs 0.8. But result is same. (gst-inspect-1.0:6510): GLib-GObject-WARNING **: 03:55:36.050: specified instance size for type 'GstNdiSrc' is smaller than the parent type's 'GstBaseSrc' instance size thread '<unnamed>' panicked at 'assertion failed: type_.is_valid()', /usr/src/debug/lib32-gstreamer1.0-plugins-rs/0.8.4-r0/cargo_home/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3e6519c/glib/src/subclass/types.rs:984:9 note: run withRUST_BACKTRACE=1environment variable to display a backtrace 0:00:25.059181620 [[31m 6510[[00m 0x149f400 [[31;01mERROR [[00m [[00;01;36m GST_PLUGIN_LOADING net/ndi/src/lib.rs:155:gstndi::plugin_desc::plugin_init_trampoline:[[00m Failed to initialize plugin due to panic: assertion failed: type_.is_valid() 0:00:25.059201900 [[31m 6510[[00m 0x149f400 [[33;01mWARN [[00m [[00;01;36m GST_PLUGIN_LOADING gstplugin.c:534:gst_plugin_register_func:[[00m plugin "/usr/lib/gstreamer-1.0/libgstndi.so" failed to initialise Could not load plugin file: File "/usr/lib/gstreamer-1.0/libgstndi.so" appears to be a GStreamer plugin, but it failed to initialize

sdroege commented 1 year ago

Why do you build version 0.8? That's quite old and two major releases in the past.

Generally, all your problems seem to be from a broken build environment. I can't really help with that, you'll have to figure that one out yourself or get someone with access to your hardware and environment to look into it.

knarziss commented 1 year ago

It wasn't a build environment problem, but I solved it. Anyway, thank you for your reply.

sdroege commented 1 year ago

So what was the problem in the end?

knarziss commented 1 year ago

In fact, the GstBaseSrc size was different because some variables were added to our GstBaseSrc structure.

sdroege commented 1 year ago

Who added those and where does your GStreamer version come from?

sdroege commented 1 year ago

But yes, that's a build environment problem. You have a broken version of GStreamer in your environment. The GstBaseSrc struct is supposed to be ABI stable and has to be updated carefully in a way that its size and the position of existing fields does not change. That's also why there is padding at the end of the struct which can be used for extensions.

If someone supplied this version of GStreamer to you then stop using that supplier as they clearly don't know what they're doing. If it was changed on your side, then the changes have to be applied in a different way.

knarziss commented 1 year ago

@sdroege I understood exactly what you said. Your last comment was of great help to me.

knarziss commented 1 year ago

@sdroege Now build and gst-inspect-1.0 do success. I can see NDI source. `/ # gst-device-monitor-1.0 -f Source/Network:application/x-ndi Probing devices...

Monitoring devices, waiting for devices to be removed or new devices to be added...

Device found:

    name  : PTHRD10-NA100UQ (VLC)
    class : Source/Audio/Video/Network
    caps  : application/x-ndi
    properties:
            ndi-name = "PTHRD10-NA100UQ\ \(VLC\)"
            url-address = 192.168.0.2:5961
    gst-launch-1.0 ndisrc ndi-name="PTHRD10-NA100UQ\ \(VLC\)" url-address=192.168.0.2:5961 ! ...`

But actually my device cannot receive ndi data.

/ # gst-launch-1.0 playbin3 uri=ndi://192.168.0.2:5961 Setting pipeline to PAUSED ... URI setting done uri is : 'ndi://192.168.0.2:5961' uri schema is : 'ndi' host is : '192.168.0.2' port is : '5961' url-address is : '192.168.0.2:5961' ------------URI property implementated ................ Getting uri from ndisrc : 'Some("ndi://192.168.0.2:5961")' Pipeline is live and does not need PREROLL ... Pipeline is PREROLLED ... Setting pipeline to PLAYING ... New clock: GstSystemClock ERROR: from element /GstPlayBin3:playbin3-0/GstURIDecodeBin3:uridecodebin3-0/GstDecodebin3:decodebin3-0/GstParseBin:parsebin0/NdiSrcDemux:ndisrcdemux0: Could not demultiplex stream. Additional debug info: src/ndisrcdemux/imp.rs(302): gstndi::ndisrcdemux::imp (): /GstPlayBin3:playbin3-0/GstURIDecodeBin3:uridecodebin3-0/GstDecodebin3:decodebin3-0/GstParseBin:parsebin0/NdiSrcDemux:ndisrcdemux0: EOS without available srcpad(s) Execution ended after 0:00:10.015455220 Setting pipeline to NULL ... Freeing pipeline ...

From tcp dump, it received only 12288byte.

What could be the problem? From gstreamer log,

0:00:00.168564520 19926 0x19226c0 LOG GST_DEBUG gstinfo.c:1729:gst_debug_apply_entry: category ndireceiver matches pattern 0x195cfc0 - gets set to level 9 0:00:00.168585440 19926 0x19226c0 DEBUG ndireceiver src/receiver.rs:580:gstndi::receiver: Starting NDI connection... 0:00:00.168603040 19926 0x19226c0 DEBUG ndireceiver src/receiver.rs:584:gstndi::receiver: Connecting to NDI source with NDI name 'None', URL/Address Some("192.168.0.2:5961") and URI Some("ndi://192.168.0.2:5961") 0:00:00.174084480 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:688:gstndi::receiver: No frame received yet, retry 0:00:00.200803940 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:688:gstndi::receiver: No frame received yet, retry 0:00:00.200857500 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:721:gstndi::receiver: Received metadata at timecode 0:00:00.000000000: 0:00:00.200874140 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:721:gstndi::receiver: Received metadata at timecode 0:00:00.000000000: <ndi_product long_name="NewTek VLC Media plugin" short_name="NewTek VLC Media plugin" manufacturer="NewTek, inc." version="2.0200.0000" serial_number="0000" model_name="NewTek VLC Media plugin" session_name="" /> 0:00:00.250905480 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:688:gstndi::receiver: No frame received yet, retry 0:00:00.300970720 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:688:gstndi::receiver: No frame received yet, retry 0:00:00.351049260 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:688:gstndi::receiver: No frame received yet, retry ... 0:00:10.168882520 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:688:gstndi::receiver: No frame received yet, retry 0:00:10.218946420 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:684:gstndi::receiver: Timed out -- assuming EOS 0:00:10.218995640 19926 0x1a4d580 DEBUG ndireceiver src/receiver.rs:751:gstndi::receiver: Signalling EOS 0:00:10.239460760 19926 0x19226c0 DEBUG ndireceiver src/receiver.rs:460:gstndi::receiver: Closed NDI connection

sdroege commented 1 year ago

As you can see, the NDI SDK simply receives no frames and then after 10s the plugin times out. A problem with either the SDK or the NDI source.

knarziss commented 1 year ago

@sdroege NDI source is my PC VLC. Other windows PC NDI receiver within same network can receive A/V frames from PC VLC and play it. => So NDI source has no problem. Ubuntu x86 PC can play it, too. I checked SDK(libndi), too. With NDI SDK example(NDIlib_recv C++), it can receive A/V frames.

/media # ./NDIlib_Recv Looking for sources ... No data received. No data received. Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Video data received (1920x1080). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). Audio data received (1152 samples). Video data received (1920x1080). Audio data received (1152 samples). In fact, in NDIlib_Recv source, I changed NDIlib_recv_create_v2 to NDIlib_recv_create_v3. Anyway it seems that libndi.so.5.5.3 is working well. In NDIlib_Recv source, there is a following code. "NDIlib_recv_connect(pNDI_recv, p_sources + 0);" In case gst-plugins-ndi, without that call, how does it work?

sdroege commented 1 year ago

Unless you give me a way to reproduce this you'll have to debug yourself what the differences in SDK calls between the example and the GStreamer plugin are.

TilakVar commented 2 weeks ago

I have cross compiled ndi plugin from https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/tree/main/net/ndi for arm aarch64 with cargo. The plugin is listed on the target board. For some reason, the NDI SDK fails to load.

I tried a simple pipeline:

gst-launch-1.0 videotestsrc is-live=true ! video/x-raw,format=UYVY ! ndisinkcombiner name=combiner ! ndisink ndi-name="My NDI source"

ERROR: from element /GstPipeline:pipeline0/GstNdiSink:ndisink0: Failed loading NDI SDK Additional debug info: net/ndi/src/ndisink/imp.rs(180): ::change_state (): /GstPipeline:pipeline0/GstNdiSink:ndisink0 ERROR: pipeline doesn't want to preroll. Failed to set pipeline to PAUSED. Setting pipeline to NULL ... Freeing pipeline ...

Should I set NDI_RUNTIME_DIR_V6 or NDI_RUNTIME_DIR_V5 to a specific directory?

TilakVar commented 2 weeks ago

solved the issue by placing the libndi.so.6.1 in the /usr/lib and setting : export NDI_RUNTIME_DIR_V6=/usr/lib