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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib;
use glib::translate::*;
use glib::GString;
use gst_sys;
use Caps;
use Element;
use ElementFactoryListType;
use Object;
use PadDirection;
use PluginFeature;
use Rank;
use StaticPadTemplate;
use URIType;

glib_wrapper! {
    pub struct ElementFactory(Object<gst_sys::GstElementFactory, gst_sys::GstElementFactoryClass, ElementFactoryClass>) @extends PluginFeature, Object;

    match fn {
        get_type => || gst_sys::gst_element_factory_get_type(),
    }
}

impl ElementFactory {
    pub fn can_sink_all_caps(&self, caps: &Caps) -> bool {
        unsafe {
            from_glib(gst_sys::gst_element_factory_can_sink_all_caps(
                self.to_glib_none().0,
                caps.to_glib_none().0,
            ))
        }
    }

    pub fn can_sink_any_caps(&self, caps: &Caps) -> bool {
        unsafe {
            from_glib(gst_sys::gst_element_factory_can_sink_any_caps(
                self.to_glib_none().0,
                caps.to_glib_none().0,
            ))
        }
    }

    pub fn can_src_all_caps(&self, caps: &Caps) -> bool {
        unsafe {
            from_glib(gst_sys::gst_element_factory_can_src_all_caps(
                self.to_glib_none().0,
                caps.to_glib_none().0,
            ))
        }
    }

    pub fn can_src_any_caps(&self, caps: &Caps) -> bool {
        unsafe {
            from_glib(gst_sys::gst_element_factory_can_src_any_caps(
                self.to_glib_none().0,
                caps.to_glib_none().0,
            ))
        }
    }

    pub fn create(&self, name: Option<&str>) -> Result<Element, glib::BoolError> {
        unsafe {
            Option::<_>::from_glib_none(gst_sys::gst_element_factory_create(
                self.to_glib_none().0,
                name.to_glib_none().0,
            ))
            .ok_or_else(|| glib_bool_error!("Failed to create element from factory"))
        }
    }

    pub fn get_element_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(gst_sys::gst_element_factory_get_element_type(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_metadata(&self, key: &str) -> Option<GString> {
        unsafe {
            from_glib_none(gst_sys::gst_element_factory_get_metadata(
                self.to_glib_none().0,
                key.to_glib_none().0,
            ))
        }
    }

    pub fn get_metadata_keys(&self) -> Vec<GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(gst_sys::gst_element_factory_get_metadata_keys(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_num_pad_templates(&self) -> u32 {
        unsafe { gst_sys::gst_element_factory_get_num_pad_templates(self.to_glib_none().0) }
    }

    pub fn get_static_pad_templates(&self) -> Vec<StaticPadTemplate> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(
                gst_sys::gst_element_factory_get_static_pad_templates(self.to_glib_none().0),
            )
        }
    }

    pub fn get_uri_protocols(&self) -> Vec<GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(gst_sys::gst_element_factory_get_uri_protocols(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn get_uri_type(&self) -> URIType {
        unsafe {
            from_glib(gst_sys::gst_element_factory_get_uri_type(
                self.to_glib_none().0,
            ))
        }
    }

    pub fn has_interface(&self, interfacename: &str) -> bool {
        unsafe {
            from_glib(gst_sys::gst_element_factory_has_interface(
                self.to_glib_none().0,
                interfacename.to_glib_none().0,
            ))
        }
    }

    pub fn list_is_type(&self, type_: ElementFactoryListType) -> bool {
        unsafe {
            from_glib(gst_sys::gst_element_factory_list_is_type(
                self.to_glib_none().0,
                type_,
            ))
        }
    }

    pub fn find(name: &str) -> Option<ElementFactory> {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(gst_sys::gst_element_factory_find(name.to_glib_none().0)) }
    }

    pub fn list_filter(
        list: &[ElementFactory],
        caps: &Caps,
        direction: PadDirection,
        subsetonly: bool,
    ) -> Vec<ElementFactory> {
        assert_initialized_main_thread!();
        unsafe {
            FromGlibPtrContainer::from_glib_full(gst_sys::gst_element_factory_list_filter(
                list.to_glib_none().0,
                caps.to_glib_none().0,
                direction.to_glib(),
                subsetonly.to_glib(),
            ))
        }
    }

    pub fn list_get_elements(type_: ElementFactoryListType, minrank: Rank) -> Vec<ElementFactory> {
        assert_initialized_main_thread!();
        unsafe {
            FromGlibPtrContainer::from_glib_full(gst_sys::gst_element_factory_list_get_elements(
                type_,
                minrank.to_glib(),
            ))
        }
    }

    pub fn make(factoryname: &str, name: Option<&str>) -> Result<Element, glib::BoolError> {
        assert_initialized_main_thread!();
        unsafe {
            Option::<_>::from_glib_none(gst_sys::gst_element_factory_make(
                factoryname.to_glib_none().0,
                name.to_glib_none().0,
            ))
            .ok_or_else(|| glib_bool_error!("Failed to create element from factory name"))
        }
    }
}

unsafe impl Send for ElementFactory {}
unsafe impl Sync for ElementFactory {}