From 2adf5a43558d7ec3cc6de03277c7b1c705fa4b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 14 Jun 2024 08:01:13 -0300 Subject: [PATCH] stream: gst: util: Improve is_gst_plugin_available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/stream/gst/utils.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/stream/gst/utils.rs b/src/stream/gst/utils.rs index d6cbd697..c15abbf4 100644 --- a/src/stream/gst/utils.rs +++ b/src/stream/gst/utils.rs @@ -8,20 +8,24 @@ pub struct PluginRankConfig { } #[allow(dead_code)] // TODO: Use this to check all used plugins are available -pub fn is_gst_plugin_available(plugin_name: &str, min_version: &str) -> bool { +pub fn is_gst_plugin_available(plugin_name: &str, min_version: Option<&str>) -> bool { // reference: https://github.com/GStreamer/gst/blob/b4ca58df7624b005a33e182a511904d7cceea890/tools/gst-inspect.c#L2148 if let Err(error) = gst::init() { tracing::error!("Error! {error}"); } - let version = semver::Version::parse(min_version).unwrap(); - gst::Registry::get().check_feature_version( - plugin_name, - version.major.try_into().unwrap(), - version.minor.try_into().unwrap(), - version.patch.try_into().unwrap(), - ) + if let Some(min_version) = min_version { + let version = semver::Version::parse(min_version).unwrap(); + gst::Registry::get().check_feature_version( + plugin_name, + version.major.try_into().unwrap(), + version.minor.try_into().unwrap(), + version.patch.try_into().unwrap(), + ) + } else { + gst::Registry::get().lookup_feature(plugin_name).is_some() + } } pub fn set_plugin_rank(plugin_name: &str, rank: gst::Rank) -> Result<()> {