gstreamer_pbutils/auto/
encoding_profile.rs1use crate::{ffi, DiscovererInfo};
7#[cfg(feature = "v1_20")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
9use glib::signal::{connect_raw, SignalHandlerId};
10use glib::{prelude::*, translate::*};
11#[cfg(feature = "v1_20")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GstEncodingProfile")]
42    pub struct EncodingProfile(Object<ffi::GstEncodingProfile, ffi::GstEncodingProfileClass>);
43
44    match fn {
45        type_ => || ffi::gst_encoding_profile_get_type(),
46    }
47}
48
49impl EncodingProfile {
50    pub const NONE: Option<&'static EncodingProfile> = None;
51
52    #[doc(alias = "gst_encoding_profile_find")]
65    pub fn find(
66        targetname: &str,
67        profilename: Option<&str>,
68        category: Option<&str>,
69    ) -> Option<EncodingProfile> {
70        assert_initialized_main_thread!();
71        unsafe {
72            from_glib_full(ffi::gst_encoding_profile_find(
73                targetname.to_glib_none().0,
74                profilename.to_glib_none().0,
75                category.to_glib_none().0,
76            ))
77        }
78    }
79
80    #[doc(alias = "gst_encoding_profile_from_discoverer")]
90    pub fn from_discoverer(info: &DiscovererInfo) -> Result<EncodingProfile, glib::BoolError> {
91        skip_assert_initialized!();
92        unsafe {
93            Option::<_>::from_glib_full(ffi::gst_encoding_profile_from_discoverer(
94                info.to_glib_none().0,
95            ))
96            .ok_or_else(|| {
97                glib::bool_error!("Failed to create EncodingProfile from DiscovererInfo")
98            })
99        }
100    }
101
102    #[cfg(feature = "v1_26")]
113    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
114    #[doc(alias = "gst_encoding_profile_from_string")]
115    pub fn from_string(string: &str) -> Result<EncodingProfile, glib::BoolError> {
116        assert_initialized_main_thread!();
117        unsafe {
118            Option::<_>::from_glib_full(ffi::gst_encoding_profile_from_string(
119                string.to_glib_none().0,
120            ))
121            .ok_or_else(|| glib::bool_error!("Failed to create EncodingProfile from string"))
122        }
123    }
124}
125
126#[cfg(feature = "v1_26")]
127#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
128impl std::fmt::Display for EncodingProfile {
129    #[inline]
130    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
131        f.write_str(&EncodingProfileExt::to_str(self))
132    }
133}
134
135unsafe impl Send for EncodingProfile {}
136unsafe impl Sync for EncodingProfile {}
137
138pub trait EncodingProfileExt: IsA<EncodingProfile> + 'static {
144    #[doc(alias = "gst_encoding_profile_copy")]
145    #[must_use]
146    fn copy(&self) -> EncodingProfile {
147        unsafe {
148            from_glib_full(ffi::gst_encoding_profile_copy(
149                self.as_ref().to_glib_none().0,
150            ))
151        }
152    }
153
154    #[doc(alias = "gst_encoding_profile_get_allow_dynamic_output")]
157    #[doc(alias = "get_allow_dynamic_output")]
158    fn allows_dynamic_output(&self) -> bool {
159        unsafe {
160            from_glib(ffi::gst_encoding_profile_get_allow_dynamic_output(
161                self.as_ref().to_glib_none().0,
162            ))
163        }
164    }
165
166    #[doc(alias = "gst_encoding_profile_get_description")]
171    #[doc(alias = "get_description")]
172    fn description(&self) -> Option<glib::GString> {
173        unsafe {
174            from_glib_none(ffi::gst_encoding_profile_get_description(
175                self.as_ref().to_glib_none().0,
176            ))
177        }
178    }
179
180    #[doc(alias = "gst_encoding_profile_get_file_extension")]
185    #[doc(alias = "get_file_extension")]
186    fn file_extension(&self) -> Option<glib::GString> {
187        unsafe {
188            from_glib_none(ffi::gst_encoding_profile_get_file_extension(
189                self.as_ref().to_glib_none().0,
190            ))
191        }
192    }
193
194    #[doc(alias = "gst_encoding_profile_get_format")]
200    #[doc(alias = "get_format")]
201    fn format(&self) -> gst::Caps {
202        unsafe {
203            from_glib_full(ffi::gst_encoding_profile_get_format(
204                self.as_ref().to_glib_none().0,
205            ))
206        }
207    }
208
209    #[doc(alias = "gst_encoding_profile_get_input_caps")]
216    #[doc(alias = "get_input_caps")]
217    fn input_caps(&self) -> gst::Caps {
218        unsafe {
219            from_glib_full(ffi::gst_encoding_profile_get_input_caps(
220                self.as_ref().to_glib_none().0,
221            ))
222        }
223    }
224
225    #[doc(alias = "gst_encoding_profile_get_name")]
230    #[doc(alias = "get_name")]
231    fn name(&self) -> Option<glib::GString> {
232        unsafe {
233            from_glib_none(ffi::gst_encoding_profile_get_name(
234                self.as_ref().to_glib_none().0,
235            ))
236        }
237    }
238
239    #[doc(alias = "gst_encoding_profile_get_presence")]
245    #[doc(alias = "get_presence")]
246    fn presence(&self) -> u32 {
247        unsafe { ffi::gst_encoding_profile_get_presence(self.as_ref().to_glib_none().0) }
248    }
249
250    #[doc(alias = "gst_encoding_profile_get_preset")]
256    #[doc(alias = "get_preset")]
257    fn preset(&self) -> Option<glib::GString> {
258        unsafe {
259            from_glib_none(ffi::gst_encoding_profile_get_preset(
260                self.as_ref().to_glib_none().0,
261            ))
262        }
263    }
264
265    #[doc(alias = "gst_encoding_profile_get_preset_name")]
270    #[doc(alias = "get_preset_name")]
271    fn preset_name(&self) -> Option<glib::GString> {
272        unsafe {
273            from_glib_none(ffi::gst_encoding_profile_get_preset_name(
274                self.as_ref().to_glib_none().0,
275            ))
276        }
277    }
278
279    #[cfg(feature = "v1_18")]
286    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
287    #[doc(alias = "gst_encoding_profile_get_single_segment")]
288    #[doc(alias = "get_single_segment")]
289    fn is_single_segment(&self) -> bool {
290        unsafe {
291            from_glib(ffi::gst_encoding_profile_get_single_segment(
292                self.as_ref().to_glib_none().0,
293            ))
294        }
295    }
296
297    #[doc(alias = "gst_encoding_profile_get_type_nick")]
302    #[doc(alias = "get_type_nick")]
303    fn type_nick(&self) -> glib::GString {
304        unsafe {
305            from_glib_none(ffi::gst_encoding_profile_get_type_nick(
306                self.as_ref().to_glib_none().0,
307            ))
308        }
309    }
310
311    #[doc(alias = "gst_encoding_profile_is_enabled")]
312    fn is_enabled(&self) -> bool {
313        unsafe {
314            from_glib(ffi::gst_encoding_profile_is_enabled(
315                self.as_ref().to_glib_none().0,
316            ))
317        }
318    }
319
320    #[doc(alias = "gst_encoding_profile_is_equal")]
321    fn is_equal(&self, b: &impl IsA<EncodingProfile>) -> bool {
322        unsafe {
323            from_glib(ffi::gst_encoding_profile_is_equal(
324                self.as_ref().to_glib_none().0,
325                b.as_ref().to_glib_none().0,
326            ))
327        }
328    }
329
330    #[cfg(feature = "v1_26")]
337    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
338    #[doc(alias = "gst_encoding_profile_to_string")]
339    #[doc(alias = "to_string")]
340    fn to_str(&self) -> glib::GString {
341        unsafe {
342            from_glib_full(ffi::gst_encoding_profile_to_string(
343                self.as_ref().to_glib_none().0,
344            ))
345        }
346    }
347
348    #[cfg(feature = "v1_20")]
349    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
350    #[doc(alias = "element-properties")]
351    fn connect_element_properties_notify<F: Fn(&Self) + Send + Sync + 'static>(
352        &self,
353        f: F,
354    ) -> SignalHandlerId {
355        unsafe extern "C" fn notify_element_properties_trampoline<
356            P: IsA<EncodingProfile>,
357            F: Fn(&P) + Send + Sync + 'static,
358        >(
359            this: *mut ffi::GstEncodingProfile,
360            _param_spec: glib::ffi::gpointer,
361            f: glib::ffi::gpointer,
362        ) {
363            let f: &F = &*(f as *const F);
364            f(EncodingProfile::from_glib_borrow(this).unsafe_cast_ref())
365        }
366        unsafe {
367            let f: Box_<F> = Box_::new(f);
368            connect_raw(
369                self.as_ptr() as *mut _,
370                c"notify::element-properties".as_ptr() as *const _,
371                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
372                    notify_element_properties_trampoline::<Self, F> as *const (),
373                )),
374                Box_::into_raw(f),
375            )
376        }
377    }
378}
379
380impl<O: IsA<EncodingProfile>> EncodingProfileExt for O {}