1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::DeviceProvider;
use crate::Object;
use crate::PluginFeature;
use crate::Rank;
use glib::translate::*;

glib::wrapper! {
    /// [`crate::DeviceProviderFactory`] is used to create instances of device providers. A
    /// GstDeviceProviderfactory can be added to a [`crate::Plugin`] as it is also a
    /// [`crate::PluginFeature`].
    ///
    /// Use the [`Self::find()`] and
    /// [`Self::get()`] functions to create device
    /// provider instances or use [`Self::get_by_name()`] as a
    /// convenient shortcut.
    ///
    /// # Implements
    ///
    /// [`trait@crate::prelude::PluginFeatureExt`], [`trait@crate::prelude::GstObjectExt`], [`trait@glib::object::ObjectExt`], [`trait@crate::prelude::PluginFeatureExtManual`]
    pub struct DeviceProviderFactory(Object<ffi::GstDeviceProviderFactory, ffi::GstDeviceProviderFactoryClass>) @extends PluginFeature, Object;

    match fn {
        type_ => || ffi::gst_device_provider_factory_get_type(),
    }
}

impl DeviceProviderFactory {
    /// Returns the device provider of the type defined by the given device
    /// providerfactory.
    ///
    /// # Returns
    ///
    /// the [`crate::DeviceProvider`] or [`None`]
    /// if the device provider couldn't be created
    #[doc(alias = "gst_device_provider_factory_get")]
    pub fn get(&self) -> Option<DeviceProvider> {
        unsafe { from_glib_full(ffi::gst_device_provider_factory_get(self.to_glib_none().0)) }
    }

    /// Get the [`crate::glib::Type`] for device providers managed by this factory. The type can
    /// only be retrieved if the device provider factory is loaded, which can be
    /// assured with [`crate::PluginFeature::load()`].
    ///
    /// # Returns
    ///
    /// the [`crate::glib::Type`] for device providers managed by this factory.
    #[doc(alias = "gst_device_provider_factory_get_device_provider_type")]
    #[doc(alias = "get_device_provider_type")]
    pub fn device_provider_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::gst_device_provider_factory_get_device_provider_type(
                self.to_glib_none().0,
            ))
        }
    }

    /// Get the metadata on `self` with `key`.
    /// ## `key`
    /// a key
    ///
    /// # Returns
    ///
    /// the metadata with `key` on `self` or [`None`]
    /// when there was no metadata with the given `key`.
    #[doc(alias = "gst_device_provider_factory_get_metadata")]
    #[doc(alias = "get_metadata")]
    pub fn metadata(&self, key: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gst_device_provider_factory_get_metadata(
                self.to_glib_none().0,
                key.to_glib_none().0,
            ))
        }
    }

    /// Get the available keys for the metadata on `self`.
    ///
    /// # Returns
    ///
    ///
    /// a [`None`]-terminated array of key strings, or [`None`] when there is no
    /// metadata. Free with `g_strfreev()` when no longer needed.
    #[doc(alias = "gst_device_provider_factory_get_metadata_keys")]
    #[doc(alias = "get_metadata_keys")]
    pub fn metadata_keys(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(
                ffi::gst_device_provider_factory_get_metadata_keys(self.to_glib_none().0),
            )
        }
    }

    /// Check if `self` matches all of the given `classes`
    /// ## `classes`
    /// a "/" separate list of classes to match, only match
    ///  if all classes are matched
    ///
    /// # Returns
    ///
    /// [`true`] if `self` matches or if `classes` is [`None`].
    #[doc(alias = "gst_device_provider_factory_has_classes")]
    pub fn has_classes(&self, classes: Option<&str>) -> bool {
        unsafe {
            from_glib(ffi::gst_device_provider_factory_has_classes(
                self.to_glib_none().0,
                classes.to_glib_none().0,
            ))
        }
    }

    /// Check if `self` matches all of the given classes
    /// ## `classes`
    /// a [`None`] terminated array
    ///  of classes to match, only match if all classes are matched
    ///
    /// # Returns
    ///
    /// [`true`] if `self` matches.
    #[doc(alias = "gst_device_provider_factory_has_classesv")]
    pub fn has_classesv(&self, classes: &[&str]) -> bool {
        unsafe {
            from_glib(ffi::gst_device_provider_factory_has_classesv(
                self.to_glib_none().0,
                classes.to_glib_none().0,
            ))
        }
    }

    /// Search for an device provider factory of the given name. Refs the returned
    /// device provider factory; caller is responsible for unreffing.
    /// ## `name`
    /// name of factory to find
    ///
    /// # Returns
    ///
    /// [`crate::DeviceProviderFactory`] if
    /// found, [`None`] otherwise
    #[doc(alias = "gst_device_provider_factory_find")]
    pub fn find(name: &str) -> Option<DeviceProviderFactory> {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gst_device_provider_factory_find(name.to_glib_none().0)) }
    }

    /// Returns the device provider of the type defined by the given device
    /// provider factory.
    /// ## `factoryname`
    /// a named factory to instantiate
    ///
    /// # Returns
    ///
    /// a [`crate::DeviceProvider`] or [`None`]
    /// if unable to create device provider
    #[doc(alias = "gst_device_provider_factory_get_by_name")]
    #[doc(alias = "get_by_name")]
    pub fn by_name(factoryname: &str) -> Option<DeviceProvider> {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_device_provider_factory_get_by_name(
                factoryname.to_glib_none().0,
            ))
        }
    }

    /// Get a list of factories with a rank greater or equal to `minrank`.
    /// The list of factories is returned by decreasing rank.
    /// ## `minrank`
    /// Minimum rank
    ///
    /// # Returns
    ///
    ///
    /// a [`crate::glib::List`] of [`crate::DeviceProviderFactory`] device providers. Use
    /// [`crate::PluginFeature::list_free()`] after usage.
    #[doc(alias = "gst_device_provider_factory_list_get_device_providers")]
    pub fn list_get_device_providers(minrank: Rank) -> Vec<DeviceProviderFactory> {
        assert_initialized_main_thread!();
        unsafe {
            FromGlibPtrContainer::from_glib_full(
                ffi::gst_device_provider_factory_list_get_device_providers(minrank.into_glib()),
            )
        }
    }
}

unsafe impl Send for DeviceProviderFactory {}
unsafe impl Sync for DeviceProviderFactory {}