Skip to content

Commit

Permalink
stream: gst: util: Improve is_gst_plugin_available
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric authored and joaoantoniocardoso committed Jun 14, 2024
1 parent 789ddda commit 2adf5a4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/stream/gst/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down

0 comments on commit 2adf5a4

Please sign in to comment.