2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2019-06-04 09:34:50 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use glib::{
|
|
|
|
prelude::*,
|
|
|
|
translate::{from_glib, FromGlibPtrFull, IntoGlib, ToGlibPtr},
|
|
|
|
};
|
2019-06-04 09:34:50 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use crate::{PluginFeature, Rank};
|
2019-06-04 09:34:50 +00:00
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
mod sealed {
|
|
|
|
pub trait Sealed {}
|
|
|
|
impl<T: super::IsA<super::PluginFeature>> Sealed for T {}
|
2019-06-04 09:34:50 +00:00
|
|
|
}
|
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
pub trait PluginFeatureExtManual: sealed::Sealed + IsA<PluginFeature> + Sized + 'static {
|
|
|
|
#[doc(alias = "get_rank")]
|
|
|
|
#[doc(alias = "gst_plugin_feature_get_rank")]
|
2021-04-11 19:39:50 +00:00
|
|
|
fn rank(&self) -> Rank {
|
2019-06-04 09:34:50 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let rank = ffi::gst_plugin_feature_get_rank(self.as_ref().to_glib_none().0);
|
2019-06-04 09:34:50 +00:00
|
|
|
from_glib(rank as i32)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
#[doc(alias = "gst_plugin_feature_set_rank")]
|
2019-06-04 09:34:50 +00:00
|
|
|
fn set_rank(&self, rank: Rank) {
|
|
|
|
unsafe {
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_plugin_feature_set_rank(
|
|
|
|
self.as_ref().to_glib_none().0,
|
|
|
|
rank.into_glib() as u32,
|
|
|
|
);
|
2019-06-04 09:34:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-19 10:52:12 +00:00
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
#[doc(alias = "gst_plugin_feature_load")]
|
2021-02-19 10:52:12 +00:00
|
|
|
fn load(&self) -> Result<Self, glib::BoolError> {
|
|
|
|
unsafe {
|
|
|
|
let loaded = Option::<PluginFeature>::from_glib_full(ffi::gst_plugin_feature_load(
|
|
|
|
self.as_ref().to_glib_none().0,
|
|
|
|
))
|
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to load plugin feature"))?;
|
|
|
|
Ok(loaded.unsafe_cast())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
impl<O: IsA<PluginFeature>> PluginFeatureExtManual for O {}
|
|
|
|
|
2021-02-19 10:52:12 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_load() {
|
|
|
|
crate::init().unwrap();
|
|
|
|
|
|
|
|
let factory = crate::ElementFactory::find("identity").unwrap();
|
|
|
|
let loaded = factory.load().unwrap();
|
2021-04-11 19:39:50 +00:00
|
|
|
assert_eq!(factory.type_(), loaded.type_());
|
2022-10-19 11:13:57 +00:00
|
|
|
let _element = loaded.create().build().unwrap();
|
2021-02-19 10:52:12 +00:00
|
|
|
}
|
2019-06-04 09:34:50 +00:00
|
|
|
}
|