summary refs log tree commit diff
path: root/src/voip/WebRTCSession.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-02-08 00:54:02 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2023-02-08 00:54:02 +0100
commitfc7937c73d5729066079484c32a9785bddd74bc5 (patch)
tree21699b53f95e0a7d11ef79478cc0f2de98f3b3c3 /src/voip/WebRTCSession.cpp
parentUse more modern flatpak build features (diff)
downloadnheko-fc7937c73d5729066079484c32a9785bddd74bc5.tar.xz
Fix required plugin check on gstreamer 1.22
GStreamer 1.22 merged the videoscale plugin into the videoconvertscale
plugin. So we should check if the Element is still loadable instead of
checking the plugin name.

fixes #1352
Diffstat (limited to 'src/voip/WebRTCSession.cpp')
-rw-r--r--src/voip/WebRTCSession.cpp92
1 files changed, 60 insertions, 32 deletions
diff --git a/src/voip/WebRTCSession.cpp b/src/voip/WebRTCSession.cpp

index 7760e2ea..001781e4 100644 --- a/src/voip/WebRTCSession.cpp +++ b/src/voip/WebRTCSession.cpp
@@ -580,53 +580,81 @@ getMediaAttributes(const GstSDPMessage *sdp, } bool -WebRTCSession::havePlugins(bool isVideo, std::string *errorMessage) +WebRTCSession::havePlugins(bool isVideo, bool isX11Screenshare, std::string *errorMessage) { if (!initialised_ && !init(errorMessage)) return false; - if (!isVideo && haveVoicePlugins_) - return true; - if (isVideo && haveVideoPlugins_) + if (haveVoicePlugins_ && (!isVideo || haveVideoPlugins_) && + (!isX11Screenshare || haveX11ScreensharePlugins_)) return true; - const gchar *voicePlugins[] = {"audioconvert", - "audioresample", - "autodetect", - "dtls", - "nice", - "opus", - "playback", - "rtpmanager", - "srtp", - "volume", - "webrtc", - nullptr}; + static constexpr std::initializer_list<const char *> audio_elements = { + "audioconvert", + "audioresample", + "autoaudiosink", + "capsfilter", + "decodebin", + "opusenc", + "queue", + "rtpopuspay", + "volume", + "webrtcbin", + }; - const gchar *videoPlugins[] = { - "compositor", "opengl", "qmlgl", "rtp", "videoconvert", "vpx", nullptr}; + static constexpr std::initializer_list<const char *> video_elements = { + "compositor", + "glcolorconvert", + "glsinkbin", + "glupload", + "qmlglsink", + "rtpvp8pay", + "tee", + "videoconvert", + "videoscale", + "vp8enc", + }; + static constexpr std::initializer_list<const char *> screenshare_elements = { + "ximagesink", + "ximagesrc", + }; - std::string strError("Missing GStreamer plugins: "); - const gchar **needed = isVideo ? videoPlugins : voicePlugins; - bool &havePlugins = isVideo ? haveVideoPlugins_ : haveVoicePlugins_; - havePlugins = true; + std::string strError("Missing GStreamer elements: "); GstRegistry *registry = gst_registry_get(); - for (guint i = 0; i < g_strv_length((gchar **)needed); i++) { - GstPlugin *plugin = gst_registry_find_plugin(registry, needed[i]); - if (!plugin) { - havePlugins = false; - strError += std::string(needed[i]) + " "; - continue; + + auto check_plugins = [&strError, + registry](const std::initializer_list<const char *> &elements) { + bool havePlugins = true; + for (const auto &element : elements) { + GstPluginFeature *plugin = + gst_registry_find_feature(registry, element, GST_TYPE_ELEMENT_FACTORY); + if (!plugin) { + havePlugins = false; + strError += std::string(element) + " "; + continue; + } + gst_object_unref(plugin); } - gst_object_unref(plugin); - } - if (!havePlugins) { + + return havePlugins; + }; + + haveVoicePlugins_ = check_plugins(audio_elements); + + // check both elements at once + if (isVideo) + haveVideoPlugins_ = check_plugins(video_elements); + if (isX11Screenshare) + haveX11ScreensharePlugins_ = check_plugins(screenshare_elements); + + if (!haveVoicePlugins_ || (isVideo && !haveVideoPlugins_) || + (isX11Screenshare && !haveX11ScreensharePlugins_)) { nhlog::ui()->error(strError); if (errorMessage) *errorMessage = strError; return false; } - if (isVideo) { + if (isVideo || isX11Screenshare) { // load qmlglsink to register GStreamer's GstGLVideoItem QML type GstElement *qmlglsink = gst_element_factory_make("qmlglsink", nullptr); gst_object_unref(qmlglsink);