gstreamer/auto/
element_factory.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::{ffi, Object, PluginFeature, URIType};
7use glib::translate::*;
8
9glib::wrapper! {
10    /// [`ElementFactory`][crate::ElementFactory] is used to create instances of elements. A
11    /// GstElementFactory can be added to a [`Plugin`][crate::Plugin] as it is also a
12    /// [`PluginFeature`][crate::PluginFeature].
13    ///
14    /// Use the [`find()`][Self::find()] and [`create_with_name()`][Self::create_with_name()]
15    /// functions to create element instances or use [`make_with_name()`][Self::make_with_name()] as a
16    /// convenient shortcut.
17    ///
18    /// The following code example shows you how to create a GstFileSrc element.
19    ///
20    /// ## Using an element factory
21    ///
22    ///
23    /// **⚠️ The following code is in C ⚠️**
24    ///
25    /// ```C
26    ///   #include <gst/gst.h>
27    ///
28    ///   GstElement *src;
29    ///   GstElementFactory *srcfactory;
30    ///
31    ///   gst_init (&argc, &argv);
32    ///
33    ///   srcfactory = gst_element_factory_find ("filesrc");
34    ///   g_return_if_fail (srcfactory != NULL);
35    ///   src = gst_element_factory_create (srcfactory, "src");
36    ///   g_return_if_fail (src != NULL);
37    ///   ...
38    /// ```
39    ///
40    /// # Implements
41    ///
42    /// [`PluginFeatureExt`][trait@crate::prelude::PluginFeatureExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`PluginFeatureExtManual`][trait@crate::prelude::PluginFeatureExtManual]
43    #[doc(alias = "GstElementFactory")]
44    pub struct ElementFactory(Object<ffi::GstElementFactory, ffi::GstElementFactoryClass>) @extends PluginFeature, Object;
45
46    match fn {
47        type_ => || ffi::gst_element_factory_get_type(),
48    }
49}
50
51impl ElementFactory {
52    /// Get the `GType` for elements managed by this factory. The type can
53    /// only be retrieved if the element factory is loaded, which can be
54    /// assured with [`PluginFeatureExtManual::load()`][crate::prelude::PluginFeatureExtManual::load()].
55    ///
56    /// # Returns
57    ///
58    /// the `GType` for elements managed by this factory or 0 if
59    /// the factory is not loaded.
60    #[doc(alias = "gst_element_factory_get_element_type")]
61    #[doc(alias = "get_element_type")]
62    pub fn element_type(&self) -> glib::types::Type {
63        unsafe {
64            from_glib(ffi::gst_element_factory_get_element_type(
65                self.to_glib_none().0,
66            ))
67        }
68    }
69
70    /// Get the available keys for the metadata on `self`.
71    ///
72    /// # Returns
73    ///
74    ///
75    /// a [`None`]-terminated array of key strings, or [`None`] when there is no
76    /// metadata. Free with `g_strfreev()` when no longer needed.
77    #[doc(alias = "gst_element_factory_get_metadata_keys")]
78    #[doc(alias = "get_metadata_keys")]
79    pub fn metadata_keys(&self) -> Vec<glib::GString> {
80        unsafe {
81            FromGlibPtrContainer::from_glib_full(ffi::gst_element_factory_get_metadata_keys(
82                self.to_glib_none().0,
83            ))
84        }
85    }
86
87    /// Gets the number of pad_templates in this factory.
88    ///
89    /// # Returns
90    ///
91    /// the number of pad_templates
92    #[doc(alias = "gst_element_factory_get_num_pad_templates")]
93    #[doc(alias = "get_num_pad_templates")]
94    pub fn num_pad_templates(&self) -> u32 {
95        unsafe { ffi::gst_element_factory_get_num_pad_templates(self.to_glib_none().0) }
96    }
97
98    /// Queries whether registered element managed by `self` needs to
99    /// be excluded from documentation system or not.
100    ///
101    /// # Returns
102    ///
103    /// [`true`] if documentation should be skipped
104    #[cfg(feature = "v1_20")]
105    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
106    #[doc(alias = "gst_element_factory_get_skip_documentation")]
107    #[doc(alias = "get_skip_documentation")]
108    pub fn skips_documentation(&self) -> bool {
109        unsafe {
110            from_glib(ffi::gst_element_factory_get_skip_documentation(
111                self.to_glib_none().0,
112            ))
113        }
114    }
115
116    /// Gets a [`None`]-terminated array of protocols this element supports or [`None`] if
117    /// no protocols are supported. You may not change the contents of the returned
118    /// array, as it is still owned by the element factory. Use `g_strdupv()` to
119    /// make a copy of the protocol string array if you need to.
120    ///
121    /// # Returns
122    ///
123    /// the supported protocols
124    ///  or [`None`]
125    #[doc(alias = "gst_element_factory_get_uri_protocols")]
126    #[doc(alias = "get_uri_protocols")]
127    pub fn uri_protocols(&self) -> Vec<glib::GString> {
128        unsafe {
129            FromGlibPtrContainer::from_glib_none(ffi::gst_element_factory_get_uri_protocols(
130                self.to_glib_none().0,
131            ))
132        }
133    }
134
135    /// Gets the type of URIs the element supports or [`URIType::Unknown`][crate::URIType::Unknown] if none.
136    ///
137    /// # Returns
138    ///
139    /// type of URIs this element supports
140    #[doc(alias = "gst_element_factory_get_uri_type")]
141    #[doc(alias = "get_uri_type")]
142    pub fn uri_type(&self) -> URIType {
143        unsafe { from_glib(ffi::gst_element_factory_get_uri_type(self.to_glib_none().0)) }
144    }
145
146    /// Check if `self` implements the interface with name `interfacename`.
147    /// ## `interfacename`
148    /// an interface name
149    ///
150    /// # Returns
151    ///
152    /// [`true`] when `self` implement the interface.
153    #[doc(alias = "gst_element_factory_has_interface")]
154    pub fn has_interface(&self, interfacename: &str) -> bool {
155        unsafe {
156            from_glib(ffi::gst_element_factory_has_interface(
157                self.to_glib_none().0,
158                interfacename.to_glib_none().0,
159            ))
160        }
161    }
162
163    /// Search for an element factory of the given name. Refs the returned
164    /// element factory; caller is responsible for unreffing.
165    /// ## `name`
166    /// name of factory to find
167    ///
168    /// # Returns
169    ///
170    /// [`ElementFactory`][crate::ElementFactory] if found,
171    /// [`None`] otherwise
172    #[doc(alias = "gst_element_factory_find")]
173    pub fn find(name: &str) -> Option<ElementFactory> {
174        assert_initialized_main_thread!();
175        unsafe { from_glib_full(ffi::gst_element_factory_find(name.to_glib_none().0)) }
176    }
177}
178
179unsafe impl Send for ElementFactory {}
180unsafe impl Sync for ElementFactory {}