gstreamer/auto/plugin_feature.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{Object, Plugin, ffi};
7#[cfg(feature = "v1_30")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
9use glib::signal::{SignalHandlerId, connect_raw};
10use glib::{prelude::*, translate::*};
11#[cfg(feature = "v1_30")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 /// This is a base class for anything that can be added to a [`Plugin`][crate::Plugin].
17 ///
18 /// This is an Abstract Base Class, you cannot instantiate it.
19 ///
20 /// ## Properties
21 ///
22 ///
23 /// #### `rank`
24 /// The rank of the plugin feature, used in autoplugging to select
25 /// the most appropriate feature.
26 ///
27 /// Readable | Writeable
28 /// <details><summary><h4>Object</h4></summary>
29 ///
30 ///
31 /// #### `name`
32 /// Readable | Writeable | Construct
33 ///
34 ///
35 /// #### `parent`
36 /// The parent of the object. Please note, that when changing the 'parent'
37 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::Object#deep-notify]
38 /// signals due to locking issues. In some cases one can use
39 /// [`element-added`][struct@crate::Bin#element-added] or [`element-removed`][struct@crate::Bin#element-removed] signals on the parent to
40 /// achieve a similar effect.
41 ///
42 /// Readable | Writeable
43 /// </details>
44 ///
45 /// # Implements
46 ///
47 /// [`PluginFeatureExt`][trait@crate::prelude::PluginFeatureExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`PluginFeatureExtManual`][trait@crate::prelude::PluginFeatureExtManual], [`GstObjectExtManual`][trait@crate::prelude::GstObjectExtManual]
48 #[doc(alias = "GstPluginFeature")]
49 pub struct PluginFeature(Object<ffi::GstPluginFeature, ffi::GstPluginFeatureClass>) @extends Object;
50
51 match fn {
52 type_ => || ffi::gst_plugin_feature_get_type(),
53 }
54}
55
56impl PluginFeature {
57 pub const NONE: Option<&'static PluginFeature> = None;
58}
59
60unsafe impl Send for PluginFeature {}
61unsafe impl Sync for PluginFeature {}
62
63/// Trait containing all [`struct@PluginFeature`] methods.
64///
65/// # Implementors
66///
67/// [`DeviceProviderFactory`][struct@crate::DeviceProviderFactory], [`DynamicTypeFactory`][struct@crate::DynamicTypeFactory], [`ElementFactory`][struct@crate::ElementFactory], [`PluginFeature`][struct@crate::PluginFeature], [`TracerFactory`][struct@crate::TracerFactory], [`TypeFindFactory`][struct@crate::TypeFindFactory]
68pub trait PluginFeatureExt: IsA<PluginFeature> + 'static {
69 /// Checks whether the given plugin feature is at least the required version.
70 ///
71 /// Note: Since version 1.24 this function no longer returns [`true`] if the
72 /// version is a git development version (e.g. 1.23.0.1) and the check is
73 /// for the "next" micro version, that is it will no longer return [`true`] for
74 /// e.g. 1.23.0.1 if the check is for 1.23.1. It is still possible to parse
75 /// the nano version from the string and do this check that way if needed.
76 /// ## `min_major`
77 /// minimum required major version
78 /// ## `min_minor`
79 /// minimum required minor version
80 /// ## `min_micro`
81 /// minimum required micro version
82 ///
83 /// # Returns
84 ///
85 /// [`true`] if the plugin feature has at least
86 /// the required version, otherwise [`false`].
87 #[doc(alias = "gst_plugin_feature_check_version")]
88 fn check_version(&self, min_major: u32, min_minor: u32, min_micro: u32) -> bool {
89 unsafe {
90 from_glib(ffi::gst_plugin_feature_check_version(
91 self.as_ref().to_glib_none().0,
92 min_major,
93 min_minor,
94 min_micro,
95 ))
96 }
97 }
98
99 /// Get the plugin that provides this feature.
100 ///
101 /// # Returns
102 ///
103 /// the plugin that provides this
104 /// feature, or [`None`]. Unref with `gst_object_unref()` when no
105 /// longer needed.
106 #[doc(alias = "gst_plugin_feature_get_plugin")]
107 #[doc(alias = "get_plugin")]
108 fn plugin(&self) -> Option<Plugin> {
109 unsafe {
110 from_glib_full(ffi::gst_plugin_feature_get_plugin(
111 self.as_ref().to_glib_none().0,
112 ))
113 }
114 }
115
116 /// Get the name of the plugin that provides this feature.
117 ///
118 /// # Returns
119 ///
120 /// the name of the plugin that provides this
121 /// feature, or [`None`] if the feature is not associated with a
122 /// plugin.
123 #[doc(alias = "gst_plugin_feature_get_plugin_name")]
124 #[doc(alias = "get_plugin_name")]
125 fn plugin_name(&self) -> Option<glib::GString> {
126 unsafe {
127 from_glib_none(ffi::gst_plugin_feature_get_plugin_name(
128 self.as_ref().to_glib_none().0,
129 ))
130 }
131 }
132
133 #[cfg(feature = "v1_30")]
134 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
135 #[doc(alias = "rank")]
136 fn connect_rank_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
137 unsafe extern "C" fn notify_rank_trampoline<
138 P: IsA<PluginFeature>,
139 F: Fn(&P) + Send + Sync + 'static,
140 >(
141 this: *mut ffi::GstPluginFeature,
142 _param_spec: glib::ffi::gpointer,
143 f: glib::ffi::gpointer,
144 ) {
145 unsafe {
146 let f: &F = &*(f as *const F);
147 f(PluginFeature::from_glib_borrow(this).unsafe_cast_ref())
148 }
149 }
150 unsafe {
151 let f: Box_<F> = Box_::new(f);
152 connect_raw(
153 self.as_ptr() as *mut _,
154 c"notify::rank".as_ptr(),
155 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
156 notify_rank_trampoline::<Self, F> as *const (),
157 )),
158 Box_::into_raw(f),
159 )
160 }
161 }
162}
163
164impl<O: IsA<PluginFeature>> PluginFeatureExt for O {}