Register plugin with system installation of GStreamer
Opened this issue · 4 comments
After successfully running the plugin from gst-launch, I'd like to integrate it in a Standalone ROS2 C++ node. In order to register the compiled plugin library (.so) I added it to the GST_PLUGIN_PATH environment variable. However, gst-inspect complains of a dependency not found: libaudio_msgs__rosidl_typesupport_cpp.so
. So I added the path of this .so file to GST_PLUGIN_PATH but still cannot get the GStreamer instrospection to work.
The only thing that works is sourcing the overlay from the ROS2 workspace.
How can I get gst_bridge and gst_pipeline detected as native plugins in GStreamer?
P.S.: Fantastic work on this project! Works like a charm and would be nice to extend it for more and more use cases as the project matures.
After a deeper look, the LD_LIBRARY_PATH does not contain the path of the GStreamer libraries. It seems to be loaded by the gst-inspect binary at runtime (dynamic linking). Adding the GStreamer libraries path to LD_LIBRARY_PATH solves the issue of gst-inspect finding the ros-gst-bridge plugins. However, the standalone ROS2 node still does not detect the plugin(s). I suspect this is related to the way colcon
is picking up the LD_LIBRARY_PATH.
The only way I've been able to run the plug-in is by sourcing the ROS overlay that built it, then handing the .so to gstreamer.
I image static linkage for ROS dependencies would be kinda huge, but that flexibility would be absolutely worth it for many players.
I'll look up my notes for the ROS-inside-OBS-studio trick, I don't think it was very sophisticated.
edit: it was the simplest way. GST_PLUGIN_PATH=install/gst_bridge/lib/gst_bridge/ obs
but it hangs on shutdown if it doesn't receive frames.
You don't need the whole ROS overlay, just the LD_LIBRARY_PATH for the system ROS, gst_bridge, and audio_msgs; and GST_PLUGIN_PATH for gstreamer.
In my case, ROS is the only thing writing to LD_LIBRARY_PATH.
You can get your LD_LIBRARY_PATH by diffing env before and after sourcing the ROS overlay.
env > without_ros.env
. install/setup.bash
env > with_ros.env
diff without_ros.env with_ros.env
This suggests that a statically-linked version is possible just with a change to CMakelists.txt
GStreamer docs hint at a plugin-helper and system cache to handle system installation, but I suspect these are provided by the (truly enormous) collection of autotools scripts that is the gstreamer default build environment.
A seamless system install is doable, but it'll take some digging.
Thanks @BrettRD ! Yes, what worked for me was to copy the .so files to the GStreamer library path and then updating LD_LIBRARY_PATH to include the GStreamer library path in the terminal of the ROS node. However, a static build would be best for many reasons...devops, portability, etc.